From 5225ea426beb873ab4d1906da352b5dde4b45067 Mon Sep 17 00:00:00 2001 From: yueh Date: Tue, 16 Jun 2020 21:41:28 +0200 Subject: [PATCH] pick 97420a31d The big reformat of 2020 --- src/api/java/appeng/api/AEApi.java | 67 +- src/api/java/appeng/api/AEInjectable.java | 13 +- src/api/java/appeng/api/AEPlugin.java | 16 +- src/api/java/appeng/api/IAppEngApi.java | 53 +- .../appeng/api/config/AccessRestriction.java | 71 +- .../java/appeng/api/config/ActionItems.java | 6 +- .../java/appeng/api/config/Actionable.java | 37 +- .../appeng/api/config/CondenserOutput.java | 12 +- src/api/java/appeng/api/config/CopyMode.java | 6 +- .../java/appeng/api/config/FullnessMode.java | 6 +- src/api/java/appeng/api/config/FuzzyMode.java | 32 +- .../appeng/api/config/IncludeExclude.java | 6 +- .../appeng/api/config/LevelEmitterMode.java | 8 +- src/api/java/appeng/api/config/LevelType.java | 8 +- .../java/appeng/api/config/ModSettings.java | 4 +- .../appeng/api/config/NetworkEmitterMode.java | 10 +- .../java/appeng/api/config/OperationMode.java | 6 +- .../java/appeng/api/config/OutputMode.java | 6 +- .../appeng/api/config/PowerMultiplier.java | 28 +- .../java/appeng/api/config/PowerUnits.java | 71 +- .../java/appeng/api/config/RedstoneMode.java | 6 +- .../appeng/api/config/RelativeDirection.java | 6 +- .../appeng/api/config/SchedulingMode.java | 6 +- .../java/appeng/api/config/SearchBoxMode.java | 21 +- .../api/config/SecurityPermissions.java | 71 +- src/api/java/appeng/api/config/Settings.java | 78 +- src/api/java/appeng/api/config/SortDir.java | 6 +- src/api/java/appeng/api/config/SortOrder.java | 6 +- .../java/appeng/api/config/StorageFilter.java | 8 +- .../java/appeng/api/config/TerminalStyle.java | 10 +- .../java/appeng/api/config/TunnelType.java | 22 +- src/api/java/appeng/api/config/Upgrades.java | 100 +- src/api/java/appeng/api/config/ViewItems.java | 6 +- src/api/java/appeng/api/config/YesNo.java | 6 +- .../api/definitions/IBlockDefinition.java | 53 +- .../java/appeng/api/definitions/IBlocks.java | 186 +- .../definitions/IComparableDefinition.java | 21 +- .../appeng/api/definitions/IDefinitions.java | 36 +- .../api/definitions/IItemDefinition.java | 54 +- .../java/appeng/api/definitions/IItems.java | 95 +- .../appeng/api/definitions/IMaterials.java | 118 +- .../java/appeng/api/definitions/IParts.java | 87 +- .../api/definitions/ITileDefinition.java | 13 +- .../api/events/LocatableEventAnnounce.java | 39 +- .../api/exceptions/AppEngException.java | 13 +- .../exceptions/CoreInaccessibleException.java | 13 +- .../ExistingConnectionException.java | 30 +- .../exceptions/FailedConnectionException.java | 23 +- .../MissingDefinitionException.java | 13 +- .../MissingIngredientException.java | 13 +- .../exceptions/ModNotInstalledException.java | 13 +- .../NullNodeConnectionException.java | 26 +- .../api/exceptions/RecipeException.java | 13 +- .../api/exceptions/RegistrationException.java | 13 +- .../SecurityConnectionException.java | 26 +- .../java/appeng/api/features/AEFeature.java | 404 ++- .../appeng/api/features/IChargerRegistry.java | 80 +- .../appeng/api/features/IItemComparison.java | 8 +- .../api/features/IItemComparisonProvider.java | 40 +- .../java/appeng/api/features/ILocatable.java | 18 +- .../api/features/ILocatableRegistry.java | 20 +- .../features/IMatterCannonAmmoRegistry.java | 36 +- .../api/features/INetworkEncodable.java | 37 +- .../api/features/IP2PTunnelRegistry.java | 44 +- .../appeng/api/features/IPlayerRegistry.java | 48 +- .../api/features/IRegistryContainer.java | 102 +- .../features/ISpecialComparisonRegistry.java | 33 +- .../api/features/IWirelessTermHandler.java | 70 +- .../api/features/IWirelessTermRegistry.java | 52 +- .../java/appeng/api/features/IWorldGen.java | 20 +- .../api/features/InscriberProcessType.java | 20 +- .../implementations/ICraftingPatternItem.java | 23 +- .../implementations/IPowerChannelState.java | 20 +- .../api/implementations/IUpgradeableHost.java | 25 +- .../api/implementations/TransitionResult.java | 17 +- .../implementations/guiobjects/IGuiItem.java | 29 +- .../guiobjects/IGuiItemObject.java | 7 +- .../guiobjects/INetworkTool.java | 9 +- .../guiobjects/IPortableCell.java | 5 +- .../items/IAEItemPowerStorage.java | 67 +- .../api/implementations/items/IAEWrench.java | 23 +- .../implementations/items/IBiometricCard.java | 95 +- .../items/IGrowableCrystal.java | 9 +- .../api/implementations/items/IItemGroup.java | 21 +- .../implementations/items/IMemoryCard.java | 108 +- .../items/ISpatialStorageCell.java | 71 +- .../implementations/items/IStorageCell.java | 134 +- .../items/IStorageComponent.java | 41 +- .../implementations/items/IUpgradeModule.java | 17 +- .../items/MemoryCardMessages.java | 6 +- .../api/implementations/parts/IPartCable.java | 82 +- .../implementations/parts/IPartMonitor.java | 15 +- .../parts/IPartStorageMonitor.java | 26 +- .../implementations/tiles/IChestOrDrive.java | 77 +- .../implementations/tiles/IColorableTile.java | 9 +- .../tiles/ICraftingMachine.java | 41 +- .../api/implementations/tiles/ICrankable.java | 33 +- .../tiles/ICrystalGrowthAccelerator.java | 6 +- .../api/implementations/tiles/IMEChest.java | 5 +- .../tiles/ISegmentedInventory.java | 24 +- .../tiles/IViewCellStorage.java | 17 +- .../tiles/IWirelessAccessPoint.java | 37 +- .../appeng/api/movable/IMovableHandler.java | 76 +- .../appeng/api/movable/IMovableRegistry.java | 135 +- .../java/appeng/api/movable/IMovableTile.java | 26 +- .../java/appeng/api/networking/GridFlags.java | 68 +- .../api/networking/GridNotification.java | 12 +- src/api/java/appeng/api/networking/IGrid.java | 123 +- .../appeng/api/networking/IGridBlock.java | 154 +- .../appeng/api/networking/IGridCache.java | 103 +- .../api/networking/IGridCacheRegistry.java | 36 +- .../api/networking/IGridConnection.java | 91 +- .../networking/IGridConnectionVisitor.java | 17 +- .../appeng/api/networking/IGridHelper.java | 57 +- .../java/appeng/api/networking/IGridHost.java | 60 +- .../api/networking/IGridMultiblock.java | 28 +- .../java/appeng/api/networking/IGridNode.java | 226 +- .../appeng/api/networking/IGridStorage.java | 23 +- .../appeng/api/networking/IGridVisitor.java | 26 +- .../appeng/api/networking/IMachineSet.java | 15 +- .../networking/crafting/CraftingItemList.java | 6 +- .../api/networking/crafting/ICraftingCPU.java | 46 +- .../crafting/ICraftingCallback.java | 17 +- .../networking/crafting/ICraftingGrid.java | 147 +- .../api/networking/crafting/ICraftingJob.java | 45 +- .../networking/crafting/ICraftingLink.java | 58 +- .../networking/crafting/ICraftingMedium.java | 37 +- .../crafting/ICraftingPatternDetails.java | 120 +- .../crafting/ICraftingProvider.java | 21 +- .../crafting/ICraftingProviderHelper.java | 24 +- .../crafting/ICraftingRequester.java | 52 +- .../networking/crafting/ICraftingWatcher.java | 45 +- .../crafting/ICraftingWatcherHost.java | 34 +- .../networking/energy/IAEPowerStorage.java | 72 +- .../api/networking/energy/IEnergyGrid.java | 149 +- .../energy/IEnergyGridProvider.java | 173 +- .../api/networking/energy/IEnergySource.java | 26 +- .../api/networking/energy/IEnergyWatcher.java | 45 +- .../networking/energy/IEnergyWatcherHost.java | 32 +- .../events/MENetworkBootingStatusChange.java | 9 +- .../events/MENetworkCellArrayUpdate.java | 4 +- .../events/MENetworkChannelChanged.java | 18 +- .../events/MENetworkChannelsChanged.java | 8 +- .../events/MENetworkControllerChange.java | 4 +- .../events/MENetworkCraftingCpuChange.java | 14 +- .../MENetworkCraftingPatternChange.java | 18 +- .../api/networking/events/MENetworkEvent.java | 73 +- .../events/MENetworkEventSubscribe.java | 7 +- .../MENetworkPostCacheConstruction.java | 4 +- .../events/MENetworkPowerIdleChange.java | 17 +- .../events/MENetworkPowerStatusChange.java | 8 +- .../events/MENetworkPowerStorage.java | 50 +- .../events/MENetworkSecurityChange.java | 4 +- .../events/MENetworkSpatialEvent.java | 29 +- .../events/MENetworkStorageEvent.java | 22 +- .../networking/pathing/ControllerState.java | 28 +- .../api/networking/pathing/IPathingGrid.java | 33 +- .../api/networking/security/IActionHost.java | 24 +- .../networking/security/IActionSource.java | 71 +- .../networking/security/ISecurityGrid.java | 58 +- .../security/ISecurityProvider.java | 46 +- .../security/ISecurityRegistry.java | 22 +- .../api/networking/spatial/ISpatialCache.java | 55 +- .../api/networking/storage/IBaseMonitor.java | 22 +- .../api/networking/storage/IStackWatcher.java | 45 +- .../networking/storage/IStackWatcherHost.java | 41 +- .../api/networking/storage/IStorageGrid.java | 54 +- .../api/networking/ticking/IGridTickable.java | 85 +- .../api/networking/ticking/ITickManager.java | 56 +- .../ticking/TickRateModulation.java | 52 +- .../networking/ticking/TickingRequest.java | 69 +- src/api/java/appeng/api/parts/BusSupport.java | 8 +- .../appeng/api/parts/CableRenderMode.java | 21 +- .../java/appeng/api/parts/IAlphaPassItem.java | 23 +- .../java/appeng/api/parts/IBoxProvider.java | 16 +- .../api/parts/ICustomCableConnection.java | 14 +- .../appeng/api/parts/IFacadeContainer.java | 109 +- .../java/appeng/api/parts/IFacadePart.java | 57 +- src/api/java/appeng/api/parts/IPart.java | 548 ++-- .../api/parts/IPartCollisionHelper.java | 63 +- .../java/appeng/api/parts/IPartHelper.java | 39 +- src/api/java/appeng/api/parts/IPartHost.java | 259 +- src/api/java/appeng/api/parts/IPartItem.java | 27 +- src/api/java/appeng/api/parts/IPartModel.java | 50 +- .../java/appeng/api/parts/IPartModels.java | 39 +- src/api/java/appeng/api/parts/LayerBase.java | 112 +- src/api/java/appeng/api/parts/LayerFlags.java | 6 +- .../java/appeng/api/parts/PartItemStack.java | 14 +- .../java/appeng/api/parts/SelectedPart.java | 62 +- .../appeng/api/recipes/ICraftHandler.java | 39 +- .../java/appeng/api/recipes/IIngredient.java | 105 +- .../appeng/api/recipes/IRecipeHandler.java | 26 +- .../appeng/api/recipes/IRecipeLoader.java | 21 +- .../appeng/api/recipes/ResolverResult.java | 33 +- .../appeng/api/recipes/ResolverResultSet.java | 18 +- .../appeng/api/storage/ICellContainer.java | 21 +- .../appeng/api/storage/ICellGuiHandler.java | 66 +- .../java/appeng/api/storage/ICellHandler.java | 120 +- .../appeng/api/storage/ICellInventory.java | 165 +- .../api/storage/ICellInventoryHandler.java | 25 +- .../appeng/api/storage/ICellProvider.java | 42 +- .../appeng/api/storage/ICellRegistry.java | 120 +- .../api/storage/ICellWorkbenchItem.java | 69 +- .../java/appeng/api/storage/IMEInventory.java | 79 +- .../api/storage/IMEInventoryHandler.java | 107 +- .../java/appeng/api/storage/IMEMonitor.java | 30 +- .../storage/IMEMonitorHandlerReceiver.java | 43 +- .../appeng/api/storage/ISaveProvider.java | 20 +- .../appeng/api/storage/ISpatialDimension.java | 34 +- .../appeng/api/storage/IStorageChannel.java | 125 +- .../appeng/api/storage/IStorageHelper.java | 171 +- .../api/storage/IStorageMonitorable.java | 12 +- .../storage/IStorageMonitorableAccessor.java | 27 +- .../appeng/api/storage/ITerminalHost.java | 5 +- .../channels/IFluidStorageChannel.java | 5 +- .../storage/channels/IItemStorageChannel.java | 5 +- .../api/storage/data/IAEFluidStack.java | 60 +- .../appeng/api/storage/data/IAEItemStack.java | 131 +- .../appeng/api/storage/data/IAEStack.java | 290 +- .../api/storage/data/IItemContainer.java | 52 +- .../appeng/api/storage/data/IItemList.java | 89 +- .../java/appeng/api/util/AEAxisAlignedBB.java | 63 +- src/api/java/appeng/api/util/AECableSize.java | 22 +- src/api/java/appeng/api/util/AECableType.java | 205 +- .../java/appeng/api/util/AECableVariant.java | 23 +- src/api/java/appeng/api/util/AEColor.java | 238 +- .../api/util/AEColoredItemDefinition.java | 67 +- .../java/appeng/api/util/AEPartLocation.java | 161 +- .../appeng/api/util/DimensionalCoord.java | 110 +- .../java/appeng/api/util/IClientHelper.java | 22 +- src/api/java/appeng/api/util/ICommonTile.java | 23 +- .../java/appeng/api/util/IConfigManager.java | 90 +- .../appeng/api/util/IConfigurableObject.java | 12 +- .../appeng/api/util/INetworkToolAgent.java | 10 +- src/api/java/appeng/api/util/IOrientable.java | 46 +- .../appeng/api/util/IOrientableBlock.java | 22 +- .../appeng/api/util/IReadOnlyCollection.java | 28 +- src/api/java/appeng/api/util/WorldCoord.java | 240 +- src/main/java/appeng/block/AEBaseBlock.java | 379 ++- .../java/appeng/block/AEBaseBlockItem.java | 229 +- .../block/AEBaseBlockItemChargeable.java | 197 +- .../java/appeng/block/AEBaseTileBlock.java | 475 ++-- .../crafting/AbstractCraftingUnitBlock.java | 115 +- .../block/crafting/BlockCraftingMonitor.java | 11 +- .../block/crafting/BlockCraftingStorage.java | 10 +- .../crafting/BlockMolecularAssembler.java | 70 +- .../block/crafting/CraftingUnitBlock.java | 11 +- .../block/crafting/ItemCraftingStorage.java | 33 +- .../appeng/block/grindstone/BlockCrank.java | 221 +- .../appeng/block/grindstone/BlockGrinder.java | 48 +- .../appeng/block/misc/BlockCellWorkbench.java | 50 +- .../java/appeng/block/misc/BlockCharger.java | 269 +- .../appeng/block/misc/BlockCondenser.java | 55 +- .../appeng/block/misc/BlockInscriber.java | 29 +- .../appeng/block/misc/BlockInterface.java | 106 +- .../appeng/block/misc/BlockLightDetector.java | 192 +- .../appeng/block/misc/BlockQuartzFixture.java | 282 +- .../misc/BlockQuartzGrowthAccelerator.java | 173 +- .../block/misc/BlockSecurityStation.java | 84 +- .../appeng/block/misc/BlockSkyCompass.java | 225 +- .../java/appeng/block/misc/BlockTinyTNT.java | 194 +- .../block/misc/BlockVibrationChamber.java | 162 +- .../appeng/block/misc/InscriberRendering.java | 19 +- .../block/misc/SecurityStationRendering.java | 20 +- .../block/misc/SkyCompassRendering.java | 19 +- .../block/networking/BlockCableBus.java | 539 ++-- .../block/networking/BlockController.java | 188 +- .../networking/BlockCreativeEnergyCell.java | 12 +- .../networking/BlockDenseEnergyCell.java | 18 +- .../block/networking/BlockEnergyAcceptor.java | 14 +- .../block/networking/BlockEnergyCell.java | 53 +- .../networking/BlockEnergyCellRendering.java | 23 +- .../block/networking/BlockWireless.java | 346 ++- .../block/networking/CableBusColor.java | 42 +- .../block/networking/CableBusRendering.java | 37 +- .../block/networking/ControllerRendering.java | 19 +- .../block/networking/WirelessRendering.java | 18 +- .../java/appeng/block/paint/BlockPaint.java | 114 +- .../appeng/block/paint/PaintRendering.java | 20 +- .../appeng/block/paint/PaintSplotches.java | 24 +- .../block/paint/PaintSplotchesBakedModel.java | 248 +- .../block/paint/PaintSplotchesModel.java | 31 +- .../appeng/block/qnb/BlockQuantumBase.java | 96 +- .../block/qnb/BlockQuantumLinkChamber.java | 98 +- .../appeng/block/qnb/BlockQuantumRing.java | 6 +- .../appeng/block/qnb/QnbFormedBakedModel.java | 341 ++- .../java/appeng/block/qnb/QnbFormedModel.java | 36 +- .../java/appeng/block/qnb/QnbFormedState.java | 43 +- .../block/qnb/QuantumBridgeRendering.java | 23 +- .../block/spatial/BlockMatrixFrame.java | 101 +- .../block/spatial/BlockSpatialIOPort.java | 74 +- .../block/spatial/BlockSpatialPylon.java | 53 +- .../java/appeng/block/storage/BlockChest.java | 112 +- .../java/appeng/block/storage/BlockDrive.java | 60 +- .../appeng/block/storage/BlockIOPort.java | 78 +- .../appeng/block/storage/BlockSkyChest.java | 139 +- .../appeng/block/storage/ChestRendering.java | 22 +- .../appeng/block/storage/DriveRendering.java | 15 +- .../block/storage/DriveSlotCellType.java | 29 +- .../appeng/block/storage/DriveSlotState.java | 74 +- .../appeng/block/storage/DriveSlotsState.java | 126 +- .../bootstrap/BlockDefinitionBuilder.java | 281 +- .../java/appeng/bootstrap/BlockRendering.java | 116 +- .../bootstrap/BlockRenderingCustomizer.java | 15 +- .../java/appeng/bootstrap/EntityBuilder.java | 24 +- .../java/appeng/bootstrap/FeatureFactory.java | 122 +- .../java/appeng/bootstrap/IBlockBuilder.java | 29 +- .../appeng/bootstrap/IBlockRendering.java | 24 +- .../appeng/bootstrap/IBootstrapComponent.java | 9 +- .../bootstrap/ICriterionTriggerRegistry.java | 7 +- .../java/appeng/bootstrap/IItemBuilder.java | 31 +- .../java/appeng/bootstrap/IItemRendering.java | 46 +- .../java/appeng/bootstrap/IModelRegistry.java | 7 +- .../bootstrap/ItemDefinitionBuilder.java | 204 +- .../java/appeng/bootstrap/ItemRendering.java | 58 +- .../bootstrap/ItemRenderingCustomizer.java | 15 +- .../appeng/bootstrap/TileEntityBuilder.java | 57 +- .../appeng/bootstrap/TileEntityRendering.java | 7 +- .../TileEntityRenderingCustomizer.java | 15 +- .../components/BlockColorComponent.java | 27 +- .../IBlockRegistrationComponent.java | 7 +- .../components/IClientSetupComponent.java | 3 +- .../IEntityRegistrationComponent.java | 7 +- .../bootstrap/components/IInitComponent.java | 7 +- .../IItemColorRegistrationComponent.java | 3 +- .../IItemRegistrationComponent.java | 7 +- .../components/IModelBakeComponent.java | 3 +- .../IModelRegistrationComponent.java | 7 +- .../components/IPostInitComponent.java | 7 +- .../IRecipeRegistrationComponent.java | 7 +- .../ITileEntityRegistrationComponent.java | 3 +- .../components/ItemColorComponent.java | 27 +- .../ItemMeshDefinitionComponent.java | 19 +- .../components/ItemVariantsComponent.java | 29 +- .../components/ModelOverrideComponent.java | 66 +- .../components/RenderTypeComponent.java | 4 +- .../components/StateMapperComponent.java | 26 +- .../definitions/TileEntityDefinition.java | 9 +- .../appeng/capabilities/Capabilities.java | 87 +- .../capabilities/NullMENetworkAccessor.java | 14 +- .../capabilities/NullSpatialDimension.java | 58 +- src/main/java/appeng/client/ActionKey.java | 29 +- src/main/java/appeng/client/ClientHelper.java | 377 ++- src/main/java/appeng/client/EffectType.java | 6 +- .../java/appeng/client/gui/AEBaseGui.java | 1585 +++++------ .../java/appeng/client/gui/AEBaseMEGui.java | 101 +- .../java/appeng/client/gui/Size1Slot.java | 110 +- .../client/gui/implementations/AESubGui.java | 52 +- .../gui/implementations/GuiCellWorkbench.java | 217 +- .../client/gui/implementations/GuiChest.java | 60 +- .../gui/implementations/GuiCondenser.java | 68 +- .../gui/implementations/GuiCraftAmount.java | 287 +- .../gui/implementations/GuiCraftConfirm.java | 918 +++---- .../gui/implementations/GuiCraftingCPU.java | 819 +++--- .../implementations/GuiCraftingStatus.java | 116 +- .../gui/implementations/GuiCraftingTerm.java | 81 +- .../client/gui/implementations/GuiDrive.java | 58 +- .../implementations/GuiFormationPlane.java | 78 +- .../gui/implementations/GuiGrinder.java | 39 +- .../client/gui/implementations/GuiIOPort.java | 100 +- .../gui/implementations/GuiInscriber.java | 93 +- .../gui/implementations/GuiInterface.java | 96 +- .../implementations/GuiInterfaceTerminal.java | 570 ++-- .../gui/implementations/GuiLevelEmitter.java | 329 ++- .../client/gui/implementations/GuiMAC.java | 86 +- .../gui/implementations/GuiMEMonitorable.java | 967 ++++--- .../implementations/GuiMEPortableCell.java | 22 +- .../gui/implementations/GuiNetworkStatus.java | 351 ++- .../gui/implementations/GuiNetworkTool.java | 71 +- .../gui/implementations/GuiPatternTerm.java | 190 +- .../gui/implementations/GuiPriority.java | 251 +- .../client/gui/implementations/GuiQNB.java | 39 +- .../gui/implementations/GuiQuartzKnife.java | 107 +- .../implementations/GuiSecurityStation.java | 117 +- .../gui/implementations/GuiSkyChest.java | 57 +- .../gui/implementations/GuiSpatialIOPort.java | 83 +- .../gui/implementations/GuiStorageBus.java | 108 +- .../gui/implementations/GuiUpgradeable.java | 203 +- .../implementations/GuiVibrationChamber.java | 80 +- .../gui/implementations/GuiWireless.java | 70 +- .../gui/implementations/GuiWirelessTerm.java | 16 +- .../client/gui/widgets/CommonButtons.java | 7 +- .../client/gui/widgets/GuiActionButton.java | 144 +- .../client/gui/widgets/GuiCustomSlot.java | 109 +- .../client/gui/widgets/GuiIconButton.java | 188 +- .../client/gui/widgets/GuiNumberBox.java | 57 +- .../client/gui/widgets/GuiProgressBar.java | 163 +- .../client/gui/widgets/GuiScrollbar.java | 196 +- .../widgets/GuiServerSettingToggleButton.java | 30 +- .../gui/widgets/GuiSettingToggleButton.java | 512 ++-- .../client/gui/widgets/GuiTabButton.java | 172 +- .../client/gui/widgets/GuiToggleButton.java | 178 +- .../client/gui/widgets/IScrollSource.java | 6 +- .../client/gui/widgets/ISortSource.java | 11 +- .../appeng/client/gui/widgets/ITooltip.java | 72 +- .../client/gui/widgets/MEGuiTextField.java | 213 +- .../appeng/client/me/ClientDCInternalInv.java | 65 +- src/main/java/appeng/client/me/FluidRepo.java | 288 +- .../appeng/client/me/InternalFluidSlotME.java | 54 +- .../java/appeng/client/me/InternalSlotME.java | 61 +- src/main/java/appeng/client/me/ItemRepo.java | 340 +-- .../appeng/client/me/SlotDisconnected.java | 109 +- .../java/appeng/client/me/SlotFluidME.java | 198 +- src/main/java/appeng/client/me/SlotME.java | 105 +- .../render/ColorableTileBlockColor.java | 32 +- .../client/render/DelegateBakedModel.java | 127 +- .../client/render/DummyFluidBakedModel.java | 77 +- .../DummyFluidDispatcherBakedModel.java | 118 +- .../client/render/DummyFluidItemModel.java | 45 +- .../client/render/FacadeBakedItemModel.java | 98 +- .../render/FacadeDispatcherBakedModel.java | 110 +- .../appeng/client/render/FacadeItemModel.java | 46 +- .../client/render/FacingToRotation.java | 172 +- .../client/render/SimpleModelLoader.java | 5 +- .../client/render/SpatialSkyRender.java | 241 +- .../client/render/StackSizeRenderer.java | 95 +- .../client/render/StaticBlockColor.java | 25 +- .../appeng/client/render/StaticItemColor.java | 23 +- .../client/render/TesrRenderHelper.java | 163 +- .../client/render/cablebus/CableBuilder.java | 1384 +++++----- .../render/cablebus/CableBusBakedModel.java | 509 ++-- .../cablebus/CableBusBreakingParticle.java | 3 +- .../client/render/cablebus/CableBusModel.java | 79 +- .../render/cablebus/CableBusModelLoader.java | 4 +- .../render/cablebus/CableBusRenderState.java | 293 +- .../client/render/cablebus/CableCoreType.java | 76 +- .../client/render/cablebus/CubeBuilder.java | 794 +++--- .../render/cablebus/FacadeBlockAccess.java | 80 +- .../client/render/cablebus/FacadeBuilder.java | 709 +++-- .../render/cablebus/FacadeRenderState.java | 34 +- .../P2PTunnelFrequencyBakedModel.java | 179 +- .../cablebus/P2PTunnelFrequencyModel.java | 43 +- .../cablebus/P2PTunnelFrequencyModelData.java | 5 +- .../client/render/cablebus/QuadRotator.java | 106 +- .../render/cablebus/SmartCableTextures.java | 107 +- .../crafting/CraftingCubeBakedModel.java | 445 ++- .../render/crafting/CraftingCubeModel.java | 158 +- .../crafting/CraftingCubeModelLoader.java | 48 +- .../crafting/CraftingCubeRendering.java | 25 +- .../render/crafting/CraftingMonitorTESR.java | 53 +- .../crafting/EncodedPatternBakedModel.java | 111 +- .../render/crafting/EncodedPatternModel.java | 18 +- .../crafting/EncodedPatternModelLoader.java | 4 +- .../render/crafting/LightBakedModel.java | 48 +- .../render/crafting/MonitorBakedModel.java | 128 +- .../render/crafting/UnitBakedModel.java | 31 +- .../client/render/effects/AssemblerFX.java | 310 ++- .../client/render/effects/ChargedOreFX.java | 69 +- .../client/render/effects/CraftingFx.java | 229 +- .../client/render/effects/EnergyFx.java | 115 +- .../client/render/effects/LightningArcFX.java | 96 +- .../effects/LightningArcParticleData.java | 14 +- .../client/render/effects/LightningFX.java | 392 ++- .../client/render/effects/MatterCannonFX.java | 108 +- .../client/render/effects/VibrantFX.java | 126 +- .../render/model/AEInternalModelData.java | 4 +- .../client/render/model/AEModelData.java | 22 +- .../render/model/AutoRotatingBakedModel.java | 479 ++-- .../render/model/AutoRotatingCacheKey.java | 83 +- .../render/model/BiometricCardBakedModel.java | 285 +- .../render/model/BiometricCardModel.java | 44 +- .../model/ColorApplicatorBakedModel.java | 176 +- .../render/model/ColorApplicatorModel.java | 51 +- .../client/render/model/DriveBakedModel.java | 164 +- .../client/render/model/DriveModel.java | 64 +- .../client/render/model/DriveModelData.java | 18 +- .../client/render/model/GlassBakedModel.java | 483 ++-- .../client/render/model/GlassModel.java | 35 +- .../render/model/MatrixVertexTransformer.java | 213 +- .../render/model/MemoryCardBakedModel.java | 278 +- .../client/render/model/MemoryCardModel.java | 43 +- .../client/render/model/RenderHelper.java | 98 +- .../render/model/SkyCompassBakedModel.java | 291 +- .../client/render/model/SkyCompassModel.java | 54 +- .../client/render/model/UVLModelLoader.java | 262 +- .../render/renderable/ItemRenderable.java | 55 +- .../client/render/renderable/Renderable.java | 9 +- .../spatial/SpatialPylonBakedModel.java | 330 +-- .../render/spatial/SpatialPylonModel.java | 52 +- .../render/spatial/SpatialPylonRendering.java | 33 +- .../spatial/SpatialPylonTextureType.java | 6 +- .../appeng/client/render/tesr/CrankTESR.java | 59 +- .../tesr/DriveLedTileEntityRenderer.java | 73 +- .../client/render/tesr/InscriberTESR.java | 325 +-- .../client/render/tesr/ModularTESR.java | 47 +- .../client/render/tesr/SkyChestTESR.java | 27 +- .../client/render/tesr/SkyCompassTESR.java | 125 +- .../appeng/container/AEBaseContainer.java | 2117 +++++++-------- .../appeng/container/ContainerLocator.java | 82 +- .../java/appeng/container/ContainerNull.java | 21 +- .../appeng/container/ContainerOpener.java | 7 +- .../appeng/container/guisync/GuiSync.java | 15 +- .../appeng/container/guisync/SyncData.java | 266 +- .../ContainerCellWorkbench.java | 360 ++- .../implementations/ContainerChest.java | 48 +- .../implementations/ContainerCondenser.java | 124 +- .../implementations/ContainerCraftAmount.java | 94 +- .../ContainerCraftConfirm.java | 811 +++--- .../implementations/ContainerCraftingCPU.java | 385 ++- .../ContainerCraftingStatus.java | 247 +- .../ContainerCraftingTerm.java | 167 +- .../implementations/ContainerDrive.java | 56 +- .../ContainerFormationPlane.java | 172 +- .../implementations/ContainerGrinder.java | 54 +- .../implementations/ContainerHelper.java | 81 +- .../implementations/ContainerIOPort.java | 184 +- .../implementations/ContainerInscriber.java | 224 +- .../implementations/ContainerInterface.java | 148 +- .../ContainerInterfaceTerminal.java | 718 +++-- .../ContainerLevelEmitter.java | 226 +- .../implementations/ContainerMAC.java | 222 +- .../ContainerMEMonitorable.java | 614 ++--- .../ContainerMEPortableCell.java | 137 +- .../ContainerNetworkStatus.java | 248 +- .../implementations/ContainerNetworkTool.java | 136 +- .../implementations/ContainerPatternTerm.java | 1040 ++++---- .../implementations/ContainerPriority.java | 111 +- .../implementations/ContainerQNB.java | 48 +- .../implementations/ContainerQuartzKnife.java | 228 +- .../ContainerSecurityStation.java | 238 +- .../implementations/ContainerSkyChest.java | 72 +- .../ContainerSpatialIOPort.java | 210 +- .../implementations/ContainerStorageBus.java | 251 +- .../implementations/ContainerUpgradeable.java | 456 ++-- .../ContainerVibrationChamber.java | 101 +- .../implementations/ContainerWireless.java | 105 +- .../ContainerWirelessTerm.java | 70 +- .../implementations/CraftingCPURecord.java | 73 +- .../interfaces/IInventorySlotAware.java | 72 +- .../interfaces/IProgressProvider.java | 96 +- .../container/slot/AppEngCraftingSlot.java | 299 +-- .../appeng/container/slot/AppEngSlot.java | 375 ++- .../appeng/container/slot/IOptionalSlot.java | 15 +- .../container/slot/IOptionalSlotHost.java | 6 +- .../java/appeng/container/slot/NullSlot.java | 97 +- .../container/slot/OptionalSlotFake.java | 104 +- .../slot/OptionalSlotFakeTypeOnly.java | 42 +- .../container/slot/OptionalSlotNormal.java | 55 +- .../slot/OptionalSlotRestrictedInput.java | 37 +- .../container/slot/SlotCraftingMatrix.java | 65 +- .../container/slot/SlotCraftingTerm.java | 433 ++- .../appeng/container/slot/SlotDisabled.java | 30 +- .../java/appeng/container/slot/SlotFake.java | 64 +- .../container/slot/SlotFakeBlacklist.java | 46 +- .../slot/SlotFakeCraftingMatrix.java | 12 +- .../container/slot/SlotFakeTypeOnly.java | 41 +- .../container/slot/SlotInaccessible.java | 66 +- .../container/slot/SlotInaccessibleHD.java | 12 +- .../appeng/container/slot/SlotMACPattern.java | 25 +- .../appeng/container/slot/SlotNormal.java | 12 +- .../appeng/container/slot/SlotOutput.java | 23 +- .../container/slot/SlotPatternOutputs.java | 31 +- .../container/slot/SlotPatternTerm.java | 70 +- .../container/slot/SlotPlayerHotBar.java | 14 +- .../appeng/container/slot/SlotPlayerInv.java | 14 +- .../container/slot/SlotRestrictedInput.java | 426 ++- src/main/java/appeng/core/AEConfig.java | 1392 +++++----- src/main/java/appeng/core/AEItemGroup.java | 13 +- src/main/java/appeng/core/AELog.java | 627 +++-- src/main/java/appeng/core/AERecipeType.java | 3 +- src/main/java/appeng/core/Api.java | 99 +- src/main/java/appeng/core/ApiDefinitions.java | 71 +- src/main/java/appeng/core/AppEng.java | 344 +-- src/main/java/appeng/core/CommonHelper.java | 31 +- src/main/java/appeng/core/CreativeTab.java | 12 +- .../java/appeng/core/CreativeTabFacade.java | 36 +- src/main/java/appeng/core/FacadeConfig.java | 102 +- src/main/java/appeng/core/PluginLoader.java | 191 +- src/main/java/appeng/core/Registration.java | 1078 ++++---- .../java/appeng/core/api/ApiClientHelper.java | 73 +- src/main/java/appeng/core/api/ApiGrid.java | 36 +- src/main/java/appeng/core/api/ApiPart.java | 24 +- src/main/java/appeng/core/api/ApiStorage.java | 256 +- .../core/api/definitions/ApiBlocks.java | 1838 ++++++------- .../appeng/core/api/definitions/ApiItems.java | 1008 ++++--- .../core/api/definitions/ApiMaterials.java | 974 ++++--- .../appeng/core/api/definitions/ApiParts.java | 639 +++-- .../core/crash/ModCrashEnhancement.java | 6 +- .../appeng/core/features/ActivityState.java | 24 +- .../appeng/core/features/BlockDefinition.java | 60 +- .../appeng/core/features/BlockStackSrc.java | 53 +- .../core/features/ColoredItemDefinition.java | 104 +- .../core/features/DamagedItemDefinition.java | 90 +- .../java/appeng/core/features/IStackSrc.java | 11 +- .../appeng/core/features/ItemDefinition.java | 75 +- .../appeng/core/features/ItemStackSrc.java | 53 +- .../core/features/MaterialStackSrc.java | 47 +- .../appeng/core/features/TileDefinition.java | 28 +- .../registries/GridCacheRegistry.java | 87 +- .../registries/LocatableRegistry.java | 52 +- .../registries/MatterCannonAmmoRegistry.java | 58 +- .../registries/MovableTileRegistry.java | 200 +- .../registries/P2PTunnelRegistry.java | 313 +-- .../core/features/registries/PartModels.java | 39 +- .../features/registries/PlayerRegistry.java | 65 +- .../registries/RegistryContainer.java | 135 +- .../registries/SpecialComparisonRegistry.java | 46 +- .../features/registries/WirelessRegistry.java | 141 +- .../features/registries/WorldGenRegistry.java | 136 +- .../registries/cell/BasicCellHandler.java | 33 +- .../cell/BasicItemCellGuiHandler.java | 34 +- .../registries/cell/CellRegistry.java | 165 +- .../registries/cell/CreativeCellHandler.java | 51 +- .../registries/charger/ChargerRegistry.java | 57 +- .../core/localization/ButtonToolTips.java | 169 +- .../appeng/core/localization/GuiText.java | 217 +- .../core/localization/PlayerMessages.java | 38 +- .../appeng/core/localization/WailaText.java | 67 +- .../java/appeng/core/settings/TickRates.java | 98 +- .../core/stats/AdvancementTriggers.java | 54 +- src/main/java/appeng/core/stats/AeStats.java | 55 +- .../core/stats/AppEngAdvancementTrigger.java | 201 +- .../core/stats/IAdvancementTrigger.java | 7 +- .../appeng/core/stats/PartItemPredicate.java | 57 +- .../java/appeng/core/sync/AppEngPacket.java | 67 +- .../core/sync/AppEngPacketHandlerBase.java | 95 +- src/main/java/appeng/core/sync/GuiBridge.java | 697 +++-- .../java/appeng/core/sync/GuiHostType.java | 20 +- .../network/AppEngClientPacketHandler.java | 30 +- .../network/AppEngServerPacketHandler.java | 30 +- .../core/sync/network/INetworkInfo.java | 4 +- .../core/sync/network/IPacketHandler.java | 7 +- .../core/sync/network/NetworkHandler.java | 198 +- .../appeng/core/sync/network/TargetPoint.java | 55 +- .../packets/PacketAssemblerAnimation.java | 73 +- .../appeng/core/sync/packets/PacketClick.java | 241 +- .../sync/packets/PacketCompassRequest.java | 75 +- .../sync/packets/PacketCompassResponse.java | 71 +- .../sync/packets/PacketCompressedNBT.java | 111 +- .../core/sync/packets/PacketConfigButton.java | 71 +- .../core/sync/packets/PacketCraftRequest.java | 131 +- .../core/sync/packets/PacketFluidSlot.java | 90 +- .../sync/packets/PacketInventoryAction.java | 208 +- .../core/sync/packets/PacketJEIRecipe.java | 289 +- .../core/sync/packets/PacketLightning.java | 72 +- .../packets/PacketMEFluidInventoryUpdate.java | 235 +- .../sync/packets/PacketMEInventoryUpdate.java | 265 +- .../core/sync/packets/PacketMatterCannon.java | 115 +- .../sync/packets/PacketMockExplosion.java | 60 +- .../sync/packets/PacketPaintedEntity.java | 52 +- .../sync/packets/PacketPartPlacement.java | 80 +- .../core/sync/packets/PacketPatternSlot.java | 112 +- .../core/sync/packets/PacketProgressBar.java | 71 +- .../core/sync/packets/PacketSwapSlots.java | 49 +- .../core/sync/packets/PacketSwitchGuis.java | 61 +- .../sync/packets/PacketTargetFluidStack.java | 169 +- .../sync/packets/PacketTargetItemStack.java | 85 +- .../sync/packets/PacketTransitionEffect.java | 132 +- .../core/sync/packets/PacketValueConfig.java | 402 ++- .../appeng/core/worlddata/CompassData.java | 27 +- .../core/worlddata/IWorldCompassData.java | 7 +- .../appeng/core/worlddata/IWorldData.java | 21 +- .../core/worlddata/IWorldDimensionData.java | 13 +- .../core/worlddata/IWorldGridStorageData.java | 15 +- .../core/worlddata/IWorldPlayerData.java | 26 +- .../core/worlddata/IWorldSpawnData.java | 13 +- .../core/worlddata/MeteorDataNameEncoder.java | 53 +- .../appeng/core/worlddata/PlayerData.java | 27 +- .../appeng/core/worlddata/StorageData.java | 210 +- .../java/appeng/core/worlddata/WorldData.java | 185 +- .../appeng/crafting/CraftBranchFailure.java | 20 +- .../crafting/CraftingCalculationFailure.java | 20 +- .../java/appeng/crafting/CraftingJob.java | 540 ++-- .../java/appeng/crafting/CraftingLink.java | 273 +- .../appeng/crafting/CraftingLinkNexus.java | 218 +- .../appeng/crafting/CraftingTreeNode.java | 548 ++-- .../appeng/crafting/CraftingTreeProcess.java | 441 ++- .../java/appeng/crafting/CraftingWatcher.java | 73 +- .../appeng/crafting/MECraftingInventory.java | 483 ++-- .../java/appeng/debug/BlockChunkloader.java | 3 +- .../java/appeng/debug/BlockCubeGenerator.java | 31 +- .../appeng/debug/BlockEnergyGenerator.java | 12 +- src/main/java/appeng/debug/BlockItemGen.java | 12 +- .../java/appeng/debug/BlockPhantomNode.java | 26 +- .../java/appeng/debug/TileChunkLoader.java | 8 +- .../java/appeng/debug/TileCubeGenerator.java | 152 +- .../appeng/debug/TileEnergyGenerator.java | 147 +- src/main/java/appeng/debug/TileItemGen.java | 172 +- .../java/appeng/debug/TilePhantomNode.java | 60 +- src/main/java/appeng/debug/ToolDebugCard.java | 301 +-- .../appeng/debug/ToolDebugPartPlacer.java | 25 +- src/main/java/appeng/debug/ToolEraser.java | 96 +- .../appeng/debug/ToolMeteoritePlacer.java | 79 +- .../java/appeng/debug/ToolReplicatorCard.java | 261 +- .../appeng/decorative/AEDecorativeBlock.java | 11 +- .../solid/BlockChargedQuartzOre.java | 97 +- .../decorative/solid/BlockQuartzGlass.java | 30 +- .../decorative/solid/BlockQuartzLamp.java | 40 +- .../decorative/solid/BlockQuartzOre.java | 27 +- .../decorative/solid/BlockQuartzPillar.java | 38 +- .../decorative/solid/BlockSkyStone.java | 99 +- .../appeng/decorative/solid/GlassState.java | 58 +- .../java/appeng/entity/AEBaseEntityItem.java | 45 +- .../appeng/entity/EntityChargedQuartz.java | 190 +- .../appeng/entity/EntityFloatingItem.java | 78 +- .../appeng/entity/EntityGrowingCrystal.java | 256 +- .../java/appeng/entity/EntitySingularity.java | 143 +- .../appeng/entity/EntityTinyTNTPrimed.java | 235 +- src/main/java/appeng/entity/ICanDie.java | 6 +- .../appeng/entity/RenderFloatingItem.java | 64 +- .../appeng/entity/RenderTinyTNTPrimed.java | 87 +- .../java/appeng/facade/FacadeContainer.java | 276 +- src/main/java/appeng/facade/FacadePart.java | 172 +- src/main/java/appeng/facade/IFacadeItem.java | 11 +- .../fluids/block/BlockFluidInterface.java | 53 +- .../client/gui/GuiFluidFormationPlane.java | 92 +- .../appeng/fluids/client/gui/GuiFluidIO.java | 57 +- .../fluids/client/gui/GuiFluidInterface.java | 95 +- .../client/gui/GuiFluidLevelEmitter.java | 284 +- .../fluids/client/gui/GuiFluidStorageBus.java | 288 +- .../fluids/client/gui/GuiFluidTerminal.java | 652 +++-- .../client/gui/widgets/GuiFluidSlot.java | 143 +- .../client/gui/widgets/GuiFluidTank.java | 159 +- .../gui/widgets/GuiOptionalFluidSlot.java | 91 +- .../client/render/FluidStackSizeRenderer.java | 100 +- .../container/ContainerFluidConfigurable.java | 146 +- .../ContainerFluidFormationPlane.java | 156 +- .../fluids/container/ContainerFluidIO.java | 60 +- .../container/ContainerFluidInterface.java | 158 +- .../container/ContainerFluidLevelEmitter.java | 140 +- .../container/ContainerFluidStorageBus.java | 427 ++- .../container/ContainerFluidTerminal.java | 933 +++---- .../fluids/container/IFluidSyncContainer.java | 7 +- .../fluids/container/slots/IMEFluidSlot.java | 14 +- .../fluids/helper/DualityFluidInterface.java | 982 +++---- .../appeng/fluids/helper/FluidCellConfig.java | 124 +- .../appeng/fluids/helper/FluidSyncHelper.java | 123 +- .../fluids/helper/IFluidInterfaceHost.java | 13 +- .../fluids/items/BasicFluidStorageCell.java | 125 +- .../appeng/fluids/items/FluidDummyItem.java | 74 +- .../fluids/items/FluidDummyItemRendering.java | 15 +- .../fluids/parts/FluidHandlerAdapter.java | 379 ++- .../parts/PartFluidAnnihilationPlane.java | 446 ++-- .../fluids/parts/PartFluidExportBus.java | 211 +- .../fluids/parts/PartFluidFormationPlane.java | 312 +-- .../fluids/parts/PartFluidImportBus.java | 232 +- .../fluids/parts/PartFluidInterface.java | 278 +- .../fluids/parts/PartFluidLevelEmitter.java | 515 ++-- .../fluids/parts/PartFluidStorageBus.java | 659 +++-- .../fluids/parts/PartFluidTerminal.java | 47 +- .../fluids/parts/PartSharedFluidBus.java | 223 +- .../registries/BasicFluidCellGuiHandler.java | 34 +- .../fluids/tile/TileFluidInterface.java | 211 +- .../appeng/fluids/util/AEFluidInventory.java | 570 ++-- .../java/appeng/fluids/util/AEFluidStack.java | 393 ++- .../java/appeng/fluids/util/AEFluidTank.java | 74 +- .../java/appeng/fluids/util/FluidList.java | 245 +- .../java/appeng/fluids/util/FluidSorters.java | 97 +- .../appeng/fluids/util/IAEFluidInventory.java | 6 +- .../java/appeng/fluids/util/IAEFluidTank.java | 11 +- .../fluids/util/MeaningfulFluidIterator.java | 72 +- .../appeng/forge/data/AE2DataGenerators.java | 36 +- .../data/providers/IAE2DataProvider.java | 26 +- .../providers/loot/BlockDropProvider.java | 144 +- .../providers/recipes/QuartzToolRecipes.java | 164 +- .../providers/recipes/SlabStairRecipes.java | 157 +- .../providers/recipes/SpecialRecipes.java | 107 +- .../java/appeng/helpers/AEGlassMaterial.java | 8 +- src/main/java/appeng/helpers/AEMultiTile.java | 5 +- .../java/appeng/helpers/DualityInterface.java | 2251 +++++++--------- .../helpers/IContainerCraftingPacket.java | 49 +- .../appeng/helpers/ICustomNameObject.java | 8 +- .../java/appeng/helpers/IInterfaceHost.java | 13 +- .../java/appeng/helpers/IMouseWheelItem.java | 7 +- .../java/appeng/helpers/IPriorityHost.java | 34 +- .../appeng/helpers/InvalidPatternHelper.java | 184 +- .../java/appeng/helpers/InventoryAction.java | 32 +- .../java/appeng/helpers/LocationRotation.java | 69 +- .../java/appeng/helpers/MetaRotation.java | 125 +- .../appeng/helpers/MultiCraftingTracker.java | 367 ++- .../appeng/helpers/NonNullArrayIterator.java | 54 +- .../java/appeng/helpers/NullRotation.java | 44 +- .../java/appeng/helpers/PatternHelper.java | 769 +++--- .../appeng/helpers/PlayerSecurityWrapper.java | 23 +- src/main/java/appeng/helpers/Reflected.java | 9 +- src/main/java/appeng/helpers/Splotch.java | 131 +- .../helpers/WirelessTerminalGuiObject.java | 465 ++-- src/main/java/appeng/hooks/AETrading.java | 110 +- .../java/appeng/hooks/CompassManager.java | 147 +- src/main/java/appeng/hooks/CompassResult.java | 69 +- .../hooks/DispenserBehaviorTinyTNT.java | 31 +- .../java/appeng/hooks/DispenserBlockTool.java | 36 +- .../appeng/hooks/DispenserMatterCannon.java | 55 +- src/main/java/appeng/hooks/IBlockTool.java | 15 +- src/main/java/appeng/hooks/TickHandler.java | 456 ++-- .../integration/IIntegrationModule.java | 25 +- .../appeng/integration/abstraction/IJEI.java | 22 +- .../modules/jei/CondenserCategory.java | 281 +- .../modules/jei/GrinderRecipeCategory.java | 130 +- .../modules/jei/InscriberRecipeCategory.java | 140 +- .../integration/modules/jei/JEIPlugin.java | 208 +- .../modules/jei/JeiRuntimeAdapter.java | 44 +- .../modules/jei/RecipeTransferHandler.java | 158 +- .../modules/waila/BaseWailaDataProvider.java | 48 +- .../modules/waila/PartWailaDataProvider.java | 211 +- .../modules/waila/TileWailaDataProvider.java | 121 +- .../modules/waila/WailaModule.java | 33 +- .../waila/part/BasePartWailaDataProvider.java | 54 +- .../waila/part/ChannelWailaDataProvider.java | 198 +- .../waila/part/IPartWailaDataProvider.java | 25 +- .../waila/part/P2PStateWailaDataProvider.java | 211 +- .../modules/waila/part/PartAccessor.java | 54 +- .../part/PartStackWailaDataProvider.java | 16 +- .../part/PowerStateWailaDataProvider.java | 84 +- .../part/StorageMonitorWailaDataProvider.java | 70 +- .../modules/waila/part/Tracer.java | 107 +- .../waila/tile/ChargerWailaDataProvider.java | 45 +- .../CraftingMonitorWailaDataProvider.java | 35 +- .../tile/PowerStateWailaDataProvider.java | 47 +- .../tile/PowerStorageWailaDataProvider.java | 191 +- src/main/java/appeng/items/AEBaseItem.java | 32 +- .../appeng/items/contents/CellConfig.java | 27 +- .../appeng/items/contents/CellUpgrades.java | 27 +- .../items/contents/NetworkToolViewer.java | 107 +- .../items/contents/PortableCellViewer.java | 101 +- .../appeng/items/contents/QuartzKnifeObj.java | 23 +- .../appeng/items/materials/ItemMaterial.java | 366 ++- .../appeng/items/materials/MaterialType.java | 275 +- .../appeng/items/misc/ItemCrystalSeed.java | 189 +- .../appeng/items/misc/ItemEncodedPattern.java | 298 +-- .../java/appeng/items/misc/ItemPaintBall.java | 36 +- .../items/misc/ItemPaintBallRendering.java | 55 +- .../appeng/items/parts/ColoredPartItem.java | 7 +- .../appeng/items/parts/FacadeRendering.java | 21 +- .../java/appeng/items/parts/ItemFacade.java | 412 ++- .../java/appeng/items/parts/ItemPart.java | 208 +- .../appeng/items/parts/ItemPartRendering.java | 33 +- .../java/appeng/items/parts/PartModels.java | 18 +- .../appeng/items/parts/PartModelsHelper.java | 196 +- .../java/appeng/items/parts/PartType.java | 264 +- .../items/storage/AbstractStorageCell.java | 282 +- .../items/storage/BasicItemStorageCell.java | 107 +- .../storage/ItemCreativeStorageCell.java | 91 +- .../items/storage/ItemSpatialStorageCell.java | 212 +- .../appeng/items/storage/ItemViewCell.java | 182 +- .../appeng/items/tools/ToolBiometricCard.java | 252 +- .../appeng/items/tools/ToolMemoryCard.java | 293 +- .../appeng/items/tools/ToolNetworkTool.java | 218 +- .../items/tools/powered/ToolChargedStaff.java | 53 +- .../tools/powered/ToolColorApplicator.java | 701 +++-- .../powered/ToolColorApplicatorRendering.java | 87 +- .../tools/powered/ToolEntropyManipulator.java | 427 ++- .../items/tools/powered/ToolMatterCannon.java | 840 +++--- .../items/tools/powered/ToolPortableCell.java | 207 +- .../tools/powered/ToolWirelessTerminal.java | 153 +- .../powered/powersink/AEBasePoweredItem.java | 192 +- .../powersink/PoweredItemCapabilities.java | 95 +- .../items/tools/quartz/ToolQuartzAxe.java | 25 +- .../tools/quartz/ToolQuartzCuttingKnife.java | 111 +- .../items/tools/quartz/ToolQuartzHoe.java | 25 +- .../items/tools/quartz/ToolQuartzPickaxe.java | 25 +- .../items/tools/quartz/ToolQuartzSpade.java | 25 +- .../items/tools/quartz/ToolQuartzSword.java | 25 +- .../items/tools/quartz/ToolQuartzWrench.java | 71 +- src/main/java/appeng/me/Grid.java | 387 ++- .../java/appeng/me/GridAccessException.java | 6 +- src/main/java/appeng/me/GridCacheWrapper.java | 86 +- src/main/java/appeng/me/GridConnection.java | 394 ++- src/main/java/appeng/me/GridException.java | 13 +- src/main/java/appeng/me/GridNode.java | 1243 ++++----- .../java/appeng/me/GridNodeCollection.java | 94 +- src/main/java/appeng/me/GridNodeIterator.java | 83 +- src/main/java/appeng/me/GridPropagator.java | 34 +- .../java/appeng/me/GridSplitDetector.java | 46 +- src/main/java/appeng/me/GridStorage.java | 142 +- src/main/java/appeng/me/MachineSet.java | 25 +- src/main/java/appeng/me/NetworkEventBus.java | 292 +- .../appeng/me/cache/CraftingGridCache.java | 1059 ++++---- .../java/appeng/me/cache/EnergyGridCache.java | 1164 ++++---- .../appeng/me/cache/GridStorageCache.java | 425 ++- .../java/appeng/me/cache/NetworkMonitor.java | 427 ++- src/main/java/appeng/me/cache/P2PCache.java | 316 +-- .../java/appeng/me/cache/PathGridCache.java | 589 ++-- .../java/appeng/me/cache/SecurityCache.java | 231 +- .../appeng/me/cache/SpatialPylonCache.java | 326 ++- .../appeng/me/cache/TickManagerCache.java | 340 ++- .../me/cache/helpers/ConnectionWrapper.java | 28 +- .../appeng/me/cache/helpers/Connections.java | 84 +- .../appeng/me/cache/helpers/TickTracker.java | 159 +- .../me/cache/helpers/TunnelCollection.java | 69 +- .../me/cache/helpers/TunnelConnection.java | 32 +- .../me/cache/helpers/TunnelIterator.java | 74 +- .../java/appeng/me/cluster/IAECluster.java | 11 +- .../java/appeng/me/cluster/IAEMultiBlock.java | 10 +- .../java/appeng/me/cluster/MBCalculator.java | 341 ++- .../CraftingCPUCalculator.java | 174 +- .../implementations/CraftingCPUCluster.java | 2375 ++++++++--------- .../implementations/QuantumCalculator.java | 202 +- .../implementations/QuantumCluster.java | 402 ++- .../SpatialPylonCalculator.java | 118 +- .../implementations/SpatialPylonCluster.java | 160 +- .../appeng/me/energy/EnergyThreshold.java | 148 +- .../java/appeng/me/energy/EnergyWatcher.java | 85 +- .../appeng/me/helpers/AENetworkProxy.java | 606 ++--- .../me/helpers/AENetworkProxyMultiblock.java | 36 +- .../appeng/me/helpers/BaseActionSource.java | 32 +- .../appeng/me/helpers/ChannelPowerSrc.java | 34 +- .../me/helpers/GenericInterestManager.java | 142 +- .../appeng/me/helpers/IGridProxyable.java | 11 +- .../appeng/me/helpers/MEMonitorHandler.java | 261 +- .../java/appeng/me/helpers/MachineSource.java | 41 +- .../java/appeng/me/helpers/PlayerSource.java | 47 +- .../me/pathfinding/AdHocChannelUpdater.java | 46 +- .../pathfinding/ControllerChannelUpdater.java | 29 +- .../me/pathfinding/ControllerValidator.java | 115 +- .../java/appeng/me/pathfinding/IPathItem.java | 53 +- .../appeng/me/pathfinding/PathSegment.java | 212 +- .../me/storage/AbstractCellInventory.java | 488 ++-- .../appeng/me/storage/BasicCellInventory.java | 414 ++- .../me/storage/BasicCellInventoryHandler.java | 159 +- .../me/storage/CreativeCellInventory.java | 154 +- .../java/appeng/me/storage/DriveWatcher.java | 90 +- .../appeng/me/storage/ITickingMonitor.java | 9 +- .../java/appeng/me/storage/ItemWatcher.java | 73 +- .../appeng/me/storage/MEInventoryHandler.java | 248 +- .../me/storage/MEMonitorIFluidHandler.java | 478 ++-- .../me/storage/MEMonitorIInventory.java | 479 ++-- .../me/storage/MEMonitorPassThrough.java | 204 +- .../java/appeng/me/storage/MEPassThrough.java | 129 +- .../me/storage/NetworkInventoryHandler.java | 425 ++- .../java/appeng/me/storage/NullInventory.java | 95 +- .../me/storage/SecurityStationInventory.java | 248 +- src/main/java/appeng/parts/AEBasePart.java | 857 +++--- .../java/appeng/parts/BusCollisionHelper.java | 245 +- .../java/appeng/parts/CableBusContainer.java | 2224 +++++++-------- .../java/appeng/parts/CableBusStorage.java | 167 +- .../java/appeng/parts/ICableBusContainer.java | 37 +- .../appeng/parts/NullCableBusContainer.java | 134 +- .../java/appeng/parts/PartBasicState.java | 132 +- src/main/java/appeng/parts/PartModel.java | 71 +- src/main/java/appeng/parts/PartPlacement.java | 684 +++-- .../automation/BlockUpgradeInventory.java | 45 +- .../DefinitionUpgradeInventory.java | 41 +- .../PartAbstractFormationPlane.java | 370 ++- .../automation/PartAnnihilationPlane.java | 1048 ++++---- .../parts/automation/PartExportBus.java | 473 ++-- .../parts/automation/PartFormationPlane.java | 522 ++-- .../PartIdentityAnnihilationPlane.java | 109 +- .../parts/automation/PartImportBus.java | 424 ++- .../parts/automation/PartLevelEmitter.java | 910 +++---- .../parts/automation/PartSharedItemBus.java | 217 +- .../parts/automation/PartUpgradeable.java | 202 +- .../parts/automation/PlaneBakedModel.java | 135 +- .../parts/automation/PlaneConnections.java | 170 +- .../appeng/parts/automation/PlaneModel.java | 48 +- .../parts/automation/PlaneModelLoader.java | 8 +- .../appeng/parts/automation/PlaneModels.java | 71 +- .../automation/StackUpgradeInventory.java | 41 +- .../parts/automation/UpgradeInventory.java | 260 +- .../appeng/parts/misc/ItemHandlerAdapter.java | 481 ++-- .../appeng/parts/misc/PartCableAnchor.java | 285 +- .../java/appeng/parts/misc/PartInterface.java | 371 ++- .../parts/misc/PartInvertedToggleBus.java | 68 +- .../parts/misc/PartSharedStorageBus.java | 367 ++- .../appeng/parts/misc/PartStorageBus.java | 1036 ++++--- .../java/appeng/parts/misc/PartToggleBus.java | 284 +- .../appeng/parts/networking/PartCable.java | 613 ++--- .../parts/networking/PartCableCovered.java | 118 +- .../parts/networking/PartCableGlass.java | 14 +- .../parts/networking/PartCableSmart.java | 118 +- .../parts/networking/PartDenseCable.java | 196 +- .../networking/PartDenseCableCovered.java | 21 +- .../parts/networking/PartDenseCableSmart.java | 21 +- .../parts/networking/PartQuartzFiber.java | 225 +- src/main/java/appeng/parts/p2p/P2PModels.java | 75 +- .../java/appeng/parts/p2p/PartP2PFEPower.java | 375 ++- .../java/appeng/parts/p2p/PartP2PFluids.java | 385 ++- .../java/appeng/parts/p2p/PartP2PItems.java | 378 ++- .../java/appeng/parts/p2p/PartP2PLight.java | 291 +- .../appeng/parts/p2p/PartP2PRedstone.java | 264 +- .../java/appeng/parts/p2p/PartP2PTunnel.java | 735 +++-- .../appeng/parts/p2p/PartP2PTunnelME.java | 342 +-- .../parts/reporting/AbstractPartDisplay.java | 49 +- .../parts/reporting/AbstractPartMonitor.java | 465 ++-- .../parts/reporting/AbstractPartPanel.java | 43 +- .../reporting/AbstractPartReporting.java | 429 ++- .../parts/reporting/AbstractPartTerminal.java | 166 +- .../reporting/PartConversionMonitor.java | 350 ++- .../parts/reporting/PartCraftingTerminal.java | 125 +- .../appeng/parts/reporting/PartDarkPanel.java | 44 +- .../reporting/PartInterfaceTerminal.java | 65 +- .../appeng/parts/reporting/PartPanel.java | 44 +- .../parts/reporting/PartPatternTerminal.java | 273 +- .../parts/reporting/PartSemiDarkPanel.java | 50 +- .../parts/reporting/PartStorageMonitor.java | 56 +- .../appeng/parts/reporting/PartTerminal.java | 35 +- .../recipes/conditions/FeaturesEnabled.java | 157 +- .../recipes/game/DisassembleRecipe.java | 240 +- .../appeng/recipes/game/FacadeRecipe.java | 122 +- .../recipes/handlers/GrinderRecipe.java | 8 +- .../handlers/GrinderRecipeSerializer.java | 18 +- .../recipes/handlers/GrinderRecipes.java | 10 +- .../recipes/handlers/InscriberRecipe.java | 8 +- .../handlers/InscriberRecipeSerializer.java | 35 +- src/main/java/appeng/server/AECommand.java | 8 +- src/main/java/appeng/server/AccessType.java | 52 +- src/main/java/appeng/server/Commands.java | 29 +- src/main/java/appeng/server/ISubCommand.java | 10 +- src/main/java/appeng/server/ServerHelper.java | 201 +- .../server/subcommands/ChunkLogger.java | 107 +- .../appeng/server/subcommands/Supporters.java | 26 +- .../java/appeng/services/CompassService.java | 496 ++-- .../services/compass/CompassException.java | 15 +- .../services/compass/CompassReader.java | 77 +- .../services/compass/CompassRegion.java | 199 +- .../compass/CompassThreadFactory.java | 16 +- .../services/compass/ICompassCallback.java | 22 +- src/main/java/appeng/spatial/CachedPlane.java | 788 +++--- .../appeng/spatial/DefaultSpatialHandler.java | 52 +- .../java/appeng/spatial/ISpatialVisitor.java | 7 +- .../spatial/SpatialDimensionExtraData.java | 29 +- .../spatial/SpatialDimensionManager.java | 230 +- .../java/appeng/spatial/StorageCellBiome.java | 66 +- .../appeng/spatial/StorageCellDimension.java | 173 +- .../spatial/StorageCellModDimension.java | 23 +- .../appeng/spatial/StorageChunkGenerator.java | 108 +- .../java/appeng/spatial/StorageHelper.java | 375 ++- .../codechicken/lib/math/InterpHelper.java | 175 +- .../codechicken/lib/model/CachedFormat.java | 248 +- .../lib/model/ISmartVertexConsumer.java | 22 +- .../codechicken/lib/model/Quad.java | 892 +++---- .../lib/model/pipeline/BakedPipeline.java | 676 +++-- .../lib/model/pipeline/IPipelineConsumer.java | 52 +- .../pipeline/IPipelineElementFactory.java | 6 +- .../lib/model/pipeline/QuadTransformer.java | 212 +- .../transformers/QuadAlphaOverride.java | 59 +- .../pipeline/transformers/QuadClamper.java | 76 +- .../transformers/QuadCornerKicker.java | 289 +- .../transformers/QuadFaceStripper.java | 156 +- .../transformers/QuadMatrixTransformer.java | 98 +- .../transformers/QuadReInterpolator.java | 92 +- .../pipeline/transformers/QuadTinter.java | 73 +- src/main/java/appeng/tile/AEBaseInvTile.java | 145 +- src/main/java/appeng/tile/AEBaseTile.java | 904 +++---- .../tile/crafting/CraftingCubeModelData.java | 22 +- .../crafting/CraftingMonitorModelData.java | 19 +- .../crafting/TileCraftingMonitorTile.java | 248 +- .../crafting/TileCraftingStorageTile.java | 123 +- .../tile/crafting/TileCraftingTile.java | 579 ++-- .../tile/crafting/TileMolecularAssembler.java | 1049 ++++---- .../appeng/tile/grid/AENetworkInvTile.java | 117 +- .../appeng/tile/grid/AENetworkPowerTile.java | 135 +- .../java/appeng/tile/grid/AENetworkTile.java | 142 +- .../appeng/tile/grindstone/TileCrank.java | 198 +- .../appeng/tile/grindstone/TileGrinder.java | 256 +- .../tile/inventory/AppEngCellInventory.java | 163 +- .../inventory/AppEngInternalAEInventory.java | 378 ++- .../inventory/AppEngInternalInventory.java | 282 +- .../tile/misc/CondenserItemInventory.java | 254 +- .../tile/misc/CondenserVoidInventory.java | 150 +- .../appeng/tile/misc/InscriberRecipes.java | 85 +- .../appeng/tile/misc/TileCellWorkbench.java | 324 +-- .../java/appeng/tile/misc/TileCharger.java | 393 ++- .../java/appeng/tile/misc/TileCondenser.java | 528 ++-- .../java/appeng/tile/misc/TileInscriber.java | 683 +++-- .../java/appeng/tile/misc/TileInterface.java | 458 ++-- .../appeng/tile/misc/TileLightDetector.java | 69 +- src/main/java/appeng/tile/misc/TilePaint.java | 386 ++- .../misc/TileQuartzGrowthAccelerator.java | 129 +- .../appeng/tile/misc/TileSecurityStation.java | 456 ++-- .../java/appeng/tile/misc/TileSkyCompass.java | 12 +- .../tile/misc/TileVibrationChamber.java | 429 ++- .../appeng/tile/networking/CableBusTESR.java | 39 +- .../appeng/tile/networking/TileCableBus.java | 547 ++-- .../tile/networking/TileCableBusTESR.java | 26 +- .../tile/networking/TileController.java | 263 +- .../networking/TileCreativeEnergyCell.java | 77 +- .../tile/networking/TileDenseEnergyCell.java | 12 +- .../tile/networking/TileEnergyAcceptor.java | 87 +- .../tile/networking/TileEnergyCell.java | 334 ++- .../appeng/tile/networking/TileWireless.java | 250 +- .../tile/powersink/AEBasePoweredTile.java | 387 ++- .../tile/powersink/ForgeEnergyAdapter.java | 73 +- .../tile/powersink/IExternalPowerSink.java | 37 +- .../appeng/tile/qnb/TileQuantumBridge.java | 469 ++-- .../tile/spatial/TileSpatialIOPort.java | 253 +- .../appeng/tile/spatial/TileSpatialPylon.java | 360 ++- .../java/appeng/tile/storage/TileChest.java | 1594 +++++------ .../java/appeng/tile/storage/TileDrive.java | 822 +++--- .../java/appeng/tile/storage/TileIOPort.java | 823 +++--- .../appeng/tile/storage/TileSkyChest.java | 232 +- src/main/java/appeng/util/BlockUpdate.java | 30 +- .../java/appeng/util/ClassInstantiation.java | 144 +- src/main/java/appeng/util/ConfigManager.java | 153 +- src/main/java/appeng/util/EnumCycler.java | 42 +- .../java/appeng/util/IConfigManagerHost.java | 7 +- .../util/ISlimReadableNumberConverter.java | 35 +- .../util/IWideReadableNumberConverter.java | 31 +- src/main/java/appeng/util/IWorldCallable.java | 35 +- .../util/InWorldToolOperationResult.java | 84 +- .../java/appeng/util/InventoryAdaptor.java | 74 +- src/main/java/appeng/util/ItemSorters.java | 124 +- src/main/java/appeng/util/Lazy.java | 32 +- src/main/java/appeng/util/LookDirection.java | 32 +- src/main/java/appeng/util/Platform.java | 2229 +++++++--------- .../java/appeng/util/ReadOnlyCollection.java | 50 +- .../appeng/util/ReadableNumberConverter.java | 140 +- src/main/java/appeng/util/SettingsFrom.java | 12 +- src/main/java/appeng/util/UUIDMatcher.java | 44 +- .../util/helpers/ItemComparisonHelper.java | 175 +- .../appeng/util/helpers/ItemHandlerUtil.java | 85 +- .../java/appeng/util/helpers/P2PHelper.java | 57 +- .../appeng/util/inv/AdaptorItemHandler.java | 361 ++- .../util/inv/AdaptorItemHandlerPlayerInv.java | 71 +- .../java/appeng/util/inv/AdaptorList.java | 313 +-- .../appeng/util/inv/IAEAppEngInventory.java | 9 +- .../util/inv/IInventoryDestination.java | 7 +- src/main/java/appeng/util/inv/IMEAdaptor.java | 259 +- .../appeng/util/inv/IMEAdaptorIterator.java | 83 +- .../util/inv/IMEInventoryDestination.java | 39 +- .../java/appeng/util/inv/InvOperation.java | 6 +- .../appeng/util/inv/ItemHandlerIterator.java | 51 +- .../util/inv/ItemListIgnoreCrafting.java | 122 +- src/main/java/appeng/util/inv/ItemSlot.java | 81 +- .../util/inv/WrapperChainedItemHandler.java | 224 +- .../util/inv/WrapperCursorItemHandler.java | 27 +- .../util/inv/WrapperFilteredItemHandler.java | 102 +- .../util/inv/WrapperInvItemHandler.java | 140 +- .../util/inv/WrapperRangeItemHandler.java | 138 +- .../util/inv/WrapperSupplierItemHandler.java | 77 +- .../inv/filter/AEItemDefinitionFilter.java | 32 +- .../appeng/util/inv/filter/AEItemFilters.java | 60 +- .../appeng/util/inv/filter/IAEItemFilter.java | 9 +- .../java/appeng/util/item/AEItemStack.java | 450 ++-- .../appeng/util/item/AEItemStackRegistry.java | 74 +- .../appeng/util/item/AESharedItemStack.java | 290 +- src/main/java/appeng/util/item/AEStack.java | 146 +- .../appeng/util/item/AbstractItemList.java | 243 +- .../java/appeng/util/item/FuzzyItemList.java | 43 +- src/main/java/appeng/util/item/ItemList.java | 276 +- .../java/appeng/util/item/ItemModList.java | 90 +- .../util/item/MeaningfulItemIterator.java | 86 +- .../java/appeng/util/item/NullItemList.java | 94 +- .../java/appeng/util/item/StrictItemList.java | 16 +- .../appeng/util/iterators/AEInvIterator.java | 51 +- .../util/iterators/ChainedIterator.java | 47 +- .../appeng/util/iterators/InvIterator.java | 51 +- .../appeng/util/iterators/NullIterator.java | 30 +- .../util/iterators/ProxyNodeIterator.java | 43 +- .../util/iterators/StackToSlotIterator.java | 51 +- .../prioritylist/DefaultPriorityList.java | 32 +- .../util/prioritylist/FuzzyPriorityList.java | 47 +- .../util/prioritylist/IPartitionList.java | 11 +- .../util/prioritylist/MergedPriorityList.java | 85 +- .../prioritylist/PrecisePriorityList.java | 41 +- .../java/appeng/worldgen/MeteoritePiece.java | 7 +- .../java/appeng/worldgen/MeteoritePlacer.java | 606 ++--- .../appeng/worldgen/MeteoriteSpawnData.java | 61 +- .../appeng/worldgen/MeteoriteSpawner.java | 135 +- .../appeng/worldgen/MeteoriteWorldGen.java | 123 +- .../worldgen/PlacedMeteoriteSettings.java | 17 +- .../java/appeng/worldgen/QuartzWorldGen.java | 144 +- .../appeng/worldgen/meteorite/ChunkOnly.java | 113 +- .../appeng/worldgen/meteorite/Fallout.java | 103 +- .../worldgen/meteorite/FalloutCopy.java | 85 +- .../worldgen/meteorite/FalloutSand.java | 43 +- .../worldgen/meteorite/FalloutSnow.java | 51 +- .../worldgen/meteorite/IMeteoriteWorld.java | 29 +- .../meteorite/MeteoriteBlockPutter.java | 23 +- .../worldgen/meteorite/StandardWorld.java | 168 +- .../blockstates/16k_crafting_storage.json | 14 +- .../blockstates/1k_crafting_storage.json | 14 +- .../blockstates/4k_crafting_storage.json | 14 +- .../blockstates/64k_crafting_storage.json | 14 +- .../blockstates/cable_bus.json | 8 +- .../blockstates/cell_workbench.json | 8 +- .../blockstates/charged_quartz_ore.json | 8 +- .../blockstates/charger.json | 8 +- .../blockstates/chiseled_quartz_block.json | 8 +- .../blockstates/chiseled_quartz_slab.json | 20 +- .../blockstates/chiseled_quartz_stairs.json | 412 +-- .../blockstates/condenser.json | 8 +- .../blockstates/controller.json | 274 +- .../blockstates/crafting_accelerator.json | 14 +- .../blockstates/crafting_monitor.json | 14 +- .../blockstates/crafting_unit.json | 14 +- .../blockstates/crank.json | 8 +- .../blockstates/creative_energy_cell.json | 8 +- .../blockstates/debug_chunk_loader.json | 8 +- .../blockstates/debug_cube_gen.json | 8 +- .../blockstates/debug_energy_gen.json | 8 +- .../blockstates/debug_item_gen.json | 8 +- .../blockstates/debug_phantom_node.json | 8 +- .../blockstates/dense_energy_cell.json | 50 +- .../blockstates/drive.json | 8 +- .../blockstates/energy_acceptor.json | 8 +- .../blockstates/energy_cell.json | 50 +- .../blockstates/fluid_interface.json | 8 +- .../blockstates/fluix_block.json | 8 +- .../blockstates/fluix_slab.json | 20 +- .../blockstates/fluix_stairs.json | 412 +-- .../blockstates/grindstone.json | 8 +- .../blockstates/inscriber.json | 8 +- .../blockstates/interface.json | 16 +- .../blockstates/io_port.json | 8 +- .../blockstates/light_detector.json | 90 +- .../blockstates/matrix_frame.json | 8 +- .../blockstates/molecular_assembler.json | 32 +- .../blockstates/paint.json | 8 +- .../blockstates/quantum_link.json | 14 +- .../blockstates/quantum_ring.json | 14 +- .../blockstates/quartz_block.json | 8 +- .../blockstates/quartz_fixture.json | 90 +- .../blockstates/quartz_glass.json | 8 +- .../quartz_growth_accelerator.json | 16 +- .../blockstates/quartz_ore.json | 8 +- .../blockstates/quartz_pillar.json | 26 +- .../blockstates/quartz_pillar_slab.json | 20 +- .../blockstates/quartz_pillar_stairs.json | 412 +-- .../blockstates/quartz_slab.json | 20 +- .../blockstates/quartz_stairs.json | 412 +-- .../blockstates/quartz_vibrant_glass.json | 8 +- .../blockstates/security_station.json | 14 +- .../blockstates/sky_compass.json | 8 +- .../blockstates/sky_stone_block.json | 8 +- .../blockstates/sky_stone_brick.json | 8 +- .../blockstates/sky_stone_brick_slab.json | 20 +- .../blockstates/sky_stone_brick_stairs.json | 412 +-- .../blockstates/sky_stone_chest.json | 10 +- .../blockstates/sky_stone_slab.json | 20 +- .../blockstates/sky_stone_small_brick.json | 8 +- .../sky_stone_small_brick_slab.json | 20 +- .../sky_stone_small_brick_stairs.json | 412 +-- .../blockstates/sky_stone_stairs.json | 412 +-- .../blockstates/smooth_sky_stone_block.json | 8 +- .../blockstates/smooth_sky_stone_chest.json | 10 +- .../blockstates/smooth_sky_stone_slab.json | 20 +- .../blockstates/smooth_sky_stone_stairs.json | 412 +-- .../blockstates/spatial_io_port.json | 8 +- .../blockstates/spatial_pylon.json | 2 +- .../blockstates/tiny_tnt.json | 8 +- .../blockstates/vibration_chamber.json | 14 +- .../blockstates/wireless_access_point.json | 106 +- .../appliedenergistics2/lang/cs_cz.json | 2 +- .../appliedenergistics2/lang/de_de.json | 2 +- .../appliedenergistics2/lang/en_gb.json | 2 +- .../appliedenergistics2/lang/en_us.json | 2 +- .../appliedenergistics2/lang/es_es.json | 2 +- .../appliedenergistics2/lang/fr_fr.json | 2 +- .../appliedenergistics2/lang/hu_hu.json | 2 +- .../appliedenergistics2/lang/it_it.json | 2 +- .../appliedenergistics2/lang/ko_kr.json | 2 +- .../appliedenergistics2/lang/pt_br.json | 2 +- .../appliedenergistics2/lang/ro_ro.json | 2 +- .../appliedenergistics2/lang/ru_ru.json | 2 +- .../appliedenergistics2/lang/zh_cn.json | 2 +- .../appliedenergistics2/lang/zh_tw.json | 2 +- .../models/block/cable_bus.json | 2 +- .../models/block/cell_workbench.json | 12 +- .../models/block/charged_quartz_ore.json | 194 +- .../models/block/charger.json | 514 ++-- .../models/block/chest/base.json | 20 +- .../models/block/chest/cell_state_empty.json | 34 +- .../models/block/chest/cell_state_full.json | 72 +- .../block/chest/cell_state_offline.json | 34 +- .../models/block/chest/cell_state_online.json | 72 +- .../block/chest/cell_state_types_full.json | 72 +- .../models/block/chest/lights_off.json | 36 +- .../models/block/chest/lights_on.json | 122 +- .../models/block/chiseled_quartz_block.json | 10 +- .../models/block/condenser.json | 8 +- .../controller_block_conflicted.json | 260 +- .../controller/controller_block_offline.json | 8 +- .../controller/controller_block_online.json | 260 +- .../controller_column_conflicted.json | 260 +- .../controller/controller_column_offline.json | 10 +- .../controller/controller_column_online.json | 260 +- .../block/controller/controller_inside_a.json | 8 +- .../block/controller/controller_inside_b.json | 8 +- .../models/block/crafting/16k_storage.json | 8 +- .../block/crafting/16k_storage_formed.json | 4 +- .../models/block/crafting/1k_storage.json | 8 +- .../block/crafting/1k_storage_formed.json | 4 +- .../models/block/crafting/4k_storage.json | 8 +- .../block/crafting/4k_storage_formed.json | 4 +- .../models/block/crafting/64k_storage.json | 8 +- .../block/crafting/64k_storage_formed.json | 4 +- .../models/block/crafting/accelerator.json | 8 +- .../block/crafting/accelerator_formed.json | 4 +- .../models/block/crafting/monitor.json | 20 +- .../models/block/crafting/monitor_formed.json | 4 +- .../models/block/crafting/unit.json | 8 +- .../models/block/crafting/unit_formed.json | 4 +- .../models/block/crank.json | 126 +- .../models/block/crank_inventory.json | 8 +- .../models/block/cube/cube_ae.json | 90 +- .../models/block/cube/cube_ae_all.json | 20 +- .../models/block/cube/cube_ae_bottom_top.json | 20 +- .../models/block/cube/cube_ae_machine.json | 20 +- .../models/block/debug/chunk_loader.json | 8 +- .../models/block/debug/cube_gen.json | 8 +- .../models/block/debug/energy_gen.json | 8 +- .../models/block/debug/item_gen.json | 8 +- .../models/block/debug/phantom_node.json | 8 +- .../models/block/drive.json | 2 +- .../models/block/drive/drive_base.json | 364 ++- .../models/block/drive/drive_cell_empty.json | 6 +- .../models/block/drive/drive_cell_fluids.json | 69 +- .../models/block/drive/drive_cell_items.json | 69 +- .../block/drive/drive_cell_led_base.json | 137 +- .../models/block/energy_acceptor.json | 8 +- .../energy_cell/creative_energy_cell.json | 8 +- .../block/energy_cell/dense_energy_cell0.json | 8 +- .../block/energy_cell/dense_energy_cell1.json | 8 +- .../block/energy_cell/dense_energy_cell2.json | 8 +- .../block/energy_cell/dense_energy_cell3.json | 8 +- .../block/energy_cell/dense_energy_cell4.json | 8 +- .../block/energy_cell/dense_energy_cell5.json | 8 +- .../block/energy_cell/dense_energy_cell6.json | 8 +- .../block/energy_cell/dense_energy_cell7.json | 8 +- .../block/energy_cell/energy_cell0.json | 8 +- .../block/energy_cell/energy_cell1.json | 8 +- .../block/energy_cell/energy_cell2.json | 8 +- .../block/energy_cell/energy_cell3.json | 8 +- .../block/energy_cell/energy_cell4.json | 8 +- .../block/energy_cell/energy_cell5.json | 8 +- .../block/energy_cell/energy_cell6.json | 8 +- .../block/energy_cell/energy_cell7.json | 8 +- .../models/block/fluid_interface.json | 8 +- .../models/block/fluix_block.json | 8 +- .../models/block/grindstone.json | 14 +- .../models/block/inscriber.json | 550 ++-- .../models/block/interface.json | 8 +- .../models/block/interface_oriented.json | 20 +- .../models/block/io_port.json | 12 +- .../models/block/matrix_frame.json | 3 +- .../models/block/molecular_assembler.json | 506 ++-- .../block/molecular_assembler_lights.json | 122 +- .../models/block/paint.json | 2 +- .../models/block/qnb/link.json | 68 +- .../models/block/qnb/qnb_formed.json | 2 +- .../models/block/qnb/ring.json | 68 +- .../models/block/quartz_block.json | 8 +- .../models/block/quartz_fixture_standing.json | 522 ++-- .../block/quartz_fixture_standing_odd.json | 522 ++-- .../models/block/quartz_fixture_wall.json | 350 ++- .../models/block/quartz_fixture_wall_odd.json | 350 ++- .../models/block/quartz_glass.json | 2 +- .../block/quartz_growth_accelerator_off.json | 12 +- .../block/quartz_growth_accelerator_on.json | 12 +- .../models/block/quartz_ore.json | 8 +- .../models/block/quartz_pillar.json | 10 +- .../models/block/security_station_off.json | 156 +- .../models/block/security_station_on.json | 182 +- .../models/block/sky_compass.json | 2 +- .../models/block/sky_compass_base.json | 734 ++--- .../models/block/sky_compass_pointer.json | 110 +- .../models/block/sky_stone_block.json | 8 +- .../models/block/sky_stone_brick.json | 8 +- .../models/block/sky_stone_small_brick.json | 8 +- .../block/slabs/chiseled_quartz_half.json | 12 +- .../block/slabs/chiseled_quartz_upper.json | 12 +- .../models/block/slabs/fluix_half.json | 12 +- .../models/block/slabs/fluix_upper.json | 12 +- .../models/block/slabs/quartz_half.json | 12 +- .../block/slabs/quartz_pillar_half.json | 12 +- .../block/slabs/quartz_pillar_upper.json | 12 +- .../models/block/slabs/quartz_upper.json | 12 +- .../block/slabs/sky_stone_brick_half.json | 12 +- .../block/slabs/sky_stone_brick_upper.json | 12 +- .../models/block/slabs/sky_stone_half.json | 12 +- .../slabs/sky_stone_small_brick_half.json | 12 +- .../slabs/sky_stone_small_brick_upper.json | 12 +- .../models/block/slabs/sky_stone_upper.json | 12 +- .../block/slabs/smooth_sky_stone_half.json | 12 +- .../block/slabs/smooth_sky_stone_upper.json | 12 +- .../models/block/smooth_sky_stone_block.json | 8 +- .../models/block/spatial_io_port.json | 12 +- .../models/block/spatial_pylon.json | 2 +- .../models/block/stairs/chiseled_quartz.json | 12 +- .../block/stairs/chiseled_quartz_inner.json | 12 +- .../block/stairs/chiseled_quartz_outer.json | 12 +- .../models/block/stairs/fluix.json | 12 +- .../models/block/stairs/fluix_inner.json | 12 +- .../models/block/stairs/fluix_outer.json | 12 +- .../models/block/stairs/quartz.json | 12 +- .../models/block/stairs/quartz_inner.json | 12 +- .../models/block/stairs/quartz_outer.json | 12 +- .../models/block/stairs/quartz_pillar.json | 12 +- .../block/stairs/quartz_pillar_inner.json | 12 +- .../block/stairs/quartz_pillar_outer.json | 12 +- .../models/block/stairs/sky_stone.json | 12 +- .../models/block/stairs/sky_stone_brick.json | 12 +- .../block/stairs/sky_stone_brick_inner.json | 12 +- .../block/stairs/sky_stone_brick_outer.json | 12 +- .../models/block/stairs/sky_stone_inner.json | 12 +- .../models/block/stairs/sky_stone_outer.json | 12 +- .../block/stairs/sky_stone_small_brick.json | 12 +- .../stairs/sky_stone_small_brick_inner.json | 12 +- .../stairs/sky_stone_small_brick_outer.json | 12 +- .../models/block/stairs/smooth_sky_stone.json | 12 +- .../block/stairs/smooth_sky_stone_inner.json | 12 +- .../block/stairs/smooth_sky_stone_outer.json | 12 +- .../models/block/tiny_tnt.json | 112 +- .../models/block/vibration_chamber_off.json | 14 +- .../models/block/vibration_chamber_on.json | 8 +- .../block/wireless_access_point_chassis.json | 584 ++-- .../block/wireless_access_point_off.json | 101 +- .../block/wireless_access_point_on.json | 263 +- ...eless_access_point_status_has_channel.json | 92 +- .../wireless_access_point_status_off.json | 52 +- .../wireless_access_point_status_on.json | 92 +- .../128_cubed_spatial_cell_component.json | 8 +- .../item/128_cubed_spatial_storage_cell.json | 8 +- .../item/16_cubed_spatial_cell_component.json | 8 +- .../item/16_cubed_spatial_storage_cell.json | 8 +- .../models/item/16k_cell_component.json | 8 +- .../models/item/16k_fluid_cell_component.json | 8 +- .../models/item/16k_fluid_storage_cell.json | 8 +- .../models/item/16k_storage_cell.json | 8 +- .../models/item/1k_cell_component.json | 8 +- .../models/item/1k_fluid_cell_component.json | 8 +- .../models/item/1k_fluid_storage_cell.json | 8 +- .../models/item/1k_storage_cell.json | 8 +- .../item/2_cubed_spatial_cell_component.json | 8 +- .../item/2_cubed_spatial_storage_cell.json | 8 +- .../models/item/4k_cell_component.json | 8 +- .../models/item/4k_fluid_cell_component.json | 8 +- .../models/item/4k_fluid_storage_cell.json | 8 +- .../models/item/4k_storage_cell.json | 8 +- .../models/item/64k_cell_component.json | 8 +- .../models/item/64k_fluid_cell_component.json | 8 +- .../models/item/64k_fluid_storage_cell.json | 8 +- .../models/item/64k_storage_cell.json | 8 +- .../models/item/advanced_card.json | 8 +- .../models/item/annihilation_core.json | 8 +- .../models/item/annihilation_plane.json | 120 +- .../models/item/basic_card.json | 8 +- .../models/item/biometric_card.json | 2 +- .../models/item/biometric_card_base.json | 8 +- .../models/item/black_covered_cable.json | 8 +- .../item/black_covered_dense_cable.json | 8 +- .../models/item/black_glass_cable.json | 8 +- .../models/item/black_lumen_paint_ball.json | 8 +- .../models/item/black_paint_ball.json | 8 +- .../models/item/black_smart_cable.json | 8 +- .../models/item/black_smart_dense_cable.json | 8 +- .../models/item/blank_pattern.json | 8 +- .../models/item/blue_covered_cable.json | 8 +- .../models/item/blue_covered_dense_cable.json | 8 +- .../models/item/blue_glass_cable.json | 8 +- .../models/item/blue_lumen_paint_ball.json | 8 +- .../models/item/blue_paint_ball.json | 8 +- .../models/item/blue_smart_cable.json | 8 +- .../models/item/blue_smart_dense_cable.json | 8 +- .../models/item/brown_covered_cable.json | 8 +- .../item/brown_covered_dense_cable.json | 8 +- .../models/item/brown_glass_cable.json | 8 +- .../models/item/brown_lumen_paint_ball.json | 8 +- .../models/item/brown_paint_ball.json | 8 +- .../models/item/brown_smart_cable.json | 8 +- .../models/item/brown_smart_dense_cable.json | 8 +- .../models/item/cable_anchor.json | 68 +- .../models/item/cable_bus.json | 2 +- .../models/item/cable_fluid_interface.json | 178 +- .../models/item/cable_interface.json | 178 +- .../models/item/calculation_processor.json | 8 +- .../item/calculation_processor_press.json | 8 +- .../models/item/capacity_card.json | 8 +- .../models/item/cell_workbench.json | 2 +- .../models/item/certus_crystal_seed.json | 34 +- .../models/item/certus_crystal_seed_2.json | 8 +- .../models/item/certus_crystal_seed_3.json | 8 +- .../models/item/certus_quartz_axe.json | 8 +- .../models/item/certus_quartz_crystal.json | 8 +- .../item/certus_quartz_cutting_knife.json | 8 +- .../models/item/certus_quartz_dust.json | 8 +- .../models/item/certus_quartz_hoe.json | 8 +- .../models/item/certus_quartz_pickaxe.json | 8 +- .../models/item/certus_quartz_shovel.json | 8 +- .../models/item/certus_quartz_sword.json | 8 +- .../models/item/certus_quartz_wrench.json | 8 +- .../item/charged_certus_quartz_crystal.json | 8 +- .../models/item/charged_quartz_ore.json | 2 +- .../models/item/charged_staff.json | 8 +- .../models/item/charger.json | 2 +- .../models/item/chiseled_quartz_block.json | 2 +- .../models/item/chiseled_quartz_slab.json | 2 +- .../models/item/chiseled_quartz_stairs.json | 2 +- .../models/item/color_applicator.json | 25 +- .../models/item/color_applicator_colored.json | 14 +- .../models/item/condenser.json | 2 +- .../models/item/conversion_monitor.json | 14 +- .../models/item/covered_cable_base.json | 104 +- .../models/item/covered_dense_cable_base.json | 104 +- .../models/item/crafting_card.json | 8 +- .../models/item/crafting_terminal.json | 14 +- .../models/item/crank.json | 2 +- .../models/item/creative_energy_cell.json | 2 +- .../models/item/creative_storage_cell.json | 8 +- .../models/item/cyan_covered_cable.json | 8 +- .../models/item/cyan_covered_dense_cable.json | 8 +- .../models/item/cyan_glass_cable.json | 8 +- .../models/item/cyan_lumen_paint_ball.json | 8 +- .../models/item/cyan_paint_ball.json | 8 +- .../models/item/cyan_smart_cable.json | 8 +- .../models/item/cyan_smart_dense_cable.json | 8 +- .../models/item/dark_monitor.json | 14 +- .../models/item/debug_card.json | 8 +- .../models/item/dense_energy_cell.json | 2 +- .../models/item/display_base.json | 234 +- .../models/item/drive.json | 8 +- .../models/item/dummy_fluid_item_base.json | 3 +- .../models/item/empty_storage_cell.json | 8 +- .../models/item/encoded_pattern.json | 6 +- .../models/item/encoded_pattern_base.json | 8 +- .../models/item/ender_dust.json | 8 +- .../models/item/energy_acceptor.json | 2 +- .../models/item/energy_cell.json | 2 +- .../models/item/engineering_processor.json | 8 +- .../item/engineering_processor_press.json | 8 +- .../models/item/entropy_manipulator.json | 8 +- .../models/item/export_bus.json | 178 +- .../models/item/facade_base.json | 10 +- .../models/item/fe_p2p_tunnel.json | 8 +- .../models/item/flour.json | 8 +- .../models/item/fluid_annihilation_plane.json | 120 +- .../models/item/fluid_export_bus.json | 178 +- .../models/item/fluid_formation_plane.json | 8 +- .../models/item/fluid_import_bus.json | 178 +- .../models/item/fluid_interface.json | 2 +- .../models/item/fluid_level_emitter.json | 108 +- .../models/item/fluid_p2p_tunnel.json | 8 +- .../models/item/fluid_storage_bus.json | 178 +- .../models/item/fluid_terminal.json | 14 +- .../models/item/fluix_block.json | 2 +- .../models/item/fluix_covered_cable.json | 8 +- .../item/fluix_covered_dense_cable.json | 8 +- .../models/item/fluix_crystal.json | 8 +- .../models/item/fluix_crystal_seed.json | 34 +- .../models/item/fluix_crystal_seed_2.json | 8 +- .../models/item/fluix_crystal_seed_3.json | 8 +- .../models/item/fluix_dust.json | 8 +- .../models/item/fluix_glass_cable.json | 8 +- .../models/item/fluix_pearl.json | 8 +- .../models/item/fluix_slab.json | 2 +- .../models/item/fluix_smart_cable.json | 8 +- .../models/item/fluix_smart_dense_cable.json | 8 +- .../models/item/fluix_stairs.json | 2 +- .../models/item/formation_core.json | 8 +- .../models/item/formation_plane.json | 8 +- .../models/item/fuzzy_card.json | 8 +- .../models/item/glass_cable_base.json | 60 +- .../models/item/gold_dust.json | 8 +- .../models/item/gray_covered_cable.json | 8 +- .../models/item/gray_covered_dense_cable.json | 8 +- .../models/item/gray_glass_cable.json | 8 +- .../models/item/gray_lumen_paint_ball.json | 8 +- .../models/item/gray_paint_ball.json | 8 +- .../models/item/gray_smart_cable.json | 8 +- .../models/item/gray_smart_dense_cable.json | 8 +- .../models/item/green_covered_cable.json | 8 +- .../item/green_covered_dense_cable.json | 8 +- .../models/item/green_glass_cable.json | 8 +- .../models/item/green_lumen_paint_ball.json | 8 +- .../models/item/green_paint_ball.json | 8 +- .../models/item/green_smart_cable.json | 8 +- .../models/item/green_smart_dense_cable.json | 8 +- .../models/item/grindstone.json | 2 +- .../models/item/ic2_p2p_tunnel.json | 8 +- .../item/identity_annihilation_plane.json | 8 +- .../models/item/import_bus.json | 178 +- .../models/item/inscriber.json | 2 +- .../models/item/interface.json | 2 +- .../models/item/interface_terminal.json | 14 +- .../models/item/invalid_type.json | 2 +- .../models/item/inverted_toggle_bus.json | 8 +- .../models/item/inverter_card.json | 8 +- .../models/item/io_port.json | 2 +- .../models/item/iron_dust.json | 8 +- .../models/item/item_p2p_tunnel.json | 8 +- .../models/item/level_emitter.json | 108 +- .../models/item/light_blue_covered_cable.json | 8 +- .../item/light_blue_covered_dense_cable.json | 8 +- .../models/item/light_blue_glass_cable.json | 8 +- .../item/light_blue_lumen_paint_ball.json | 8 +- .../models/item/light_blue_paint_ball.json | 8 +- .../models/item/light_blue_smart_cable.json | 8 +- .../item/light_blue_smart_dense_cable.json | 8 +- .../models/item/light_detector.json | 2 +- .../models/item/light_gray_covered_cable.json | 8 +- .../item/light_gray_covered_dense_cable.json | 8 +- .../models/item/light_gray_glass_cable.json | 8 +- .../item/light_gray_lumen_paint_ball.json | 8 +- .../models/item/light_gray_paint_ball.json | 8 +- .../models/item/light_gray_smart_cable.json | 8 +- .../item/light_gray_smart_dense_cable.json | 8 +- .../models/item/light_p2p_tunnel.json | 8 +- .../models/item/lime_covered_cable.json | 8 +- .../models/item/lime_covered_dense_cable.json | 8 +- .../models/item/lime_glass_cable.json | 8 +- .../models/item/lime_lumen_paint_ball.json | 8 +- .../models/item/lime_paint_ball.json | 8 +- .../models/item/lime_smart_cable.json | 8 +- .../models/item/lime_smart_dense_cable.json | 8 +- .../models/item/logic_processor.json | 8 +- .../models/item/logic_processor_press.json | 8 +- .../models/item/magenta_covered_cable.json | 8 +- .../item/magenta_covered_dense_cable.json | 8 +- .../models/item/magenta_glass_cable.json | 8 +- .../models/item/magenta_lumen_paint_ball.json | 8 +- .../models/item/magenta_paint_ball.json | 8 +- .../models/item/magenta_smart_cable.json | 8 +- .../item/magenta_smart_dense_cable.json | 8 +- .../models/item/matrix_frame.json | 2 +- .../models/item/matter_ball.json | 8 +- .../models/item/matter_cannon.json | 28 +- .../models/item/me_p2p_tunnel.json | 8 +- .../models/item/memory_card.json | 2 +- .../models/item/memory_card_base.json | 8 +- .../models/item/molecular_assembler.json | 2 +- .../models/item/monitor.json | 14 +- .../models/item/name_press.json | 8 +- .../models/item/nether_quartz_axe.json | 8 +- .../item/nether_quartz_cutting_knife.json | 8 +- .../models/item/nether_quartz_dust.json | 8 +- .../models/item/nether_quartz_hoe.json | 8 +- .../models/item/nether_quartz_pickaxe.json | 8 +- .../models/item/nether_quartz_seed.json | 34 +- .../models/item/nether_quartz_seed_2.json | 8 +- .../models/item/nether_quartz_seed_3.json | 8 +- .../models/item/nether_quartz_shovel.json | 8 +- .../models/item/nether_quartz_sword.json | 8 +- .../models/item/nether_quartz_wrench.json | 8 +- .../models/item/network_tool.json | 8 +- .../models/item/orange_covered_cable.json | 8 +- .../item/orange_covered_dense_cable.json | 8 +- .../models/item/orange_glass_cable.json | 8 +- .../models/item/orange_lumen_paint_ball.json | 8 +- .../models/item/orange_paint_ball.json | 8 +- .../models/item/orange_smart_cable.json | 8 +- .../models/item/orange_smart_dense_cable.json | 8 +- .../models/item/p2p_tunnel_base.json | 98 +- .../models/item/paint.json | 2 +- .../models/item/part_base.json | 134 +- .../models/item/pattern_terminal.json | 14 +- .../models/item/pink_covered_cable.json | 8 +- .../models/item/pink_covered_dense_cable.json | 8 +- .../models/item/pink_glass_cable.json | 8 +- .../models/item/pink_lumen_paint_ball.json | 8 +- .../models/item/pink_paint_ball.json | 8 +- .../models/item/pink_smart_cable.json | 8 +- .../models/item/pink_smart_dense_cable.json | 8 +- .../models/item/portable_cell.json | 8 +- .../item/printed_calculation_processor.json | 8 +- .../item/printed_engineering_processor.json | 8 +- .../models/item/printed_logic_processor.json | 8 +- .../models/item/printed_silicon.json | 8 +- .../item/purified_certus_quartz_crystal.json | 8 +- .../models/item/purified_fluix_crystal.json | 8 +- .../item/purified_nether_quartz_crystal.json | 8 +- .../models/item/purple_covered_cable.json | 8 +- .../item/purple_covered_dense_cable.json | 8 +- .../models/item/purple_glass_cable.json | 8 +- .../models/item/purple_lumen_paint_ball.json | 8 +- .../models/item/purple_paint_ball.json | 8 +- .../models/item/purple_smart_cable.json | 8 +- .../models/item/purple_smart_dense_cable.json | 8 +- .../item/quantum_entangled_singularity.json | 8 +- .../models/item/quantum_link.json | 2 +- .../models/item/quantum_ring.json | 2 +- .../models/item/quartz_block.json | 2 +- .../models/item/quartz_fiber.json | 66 +- .../models/item/quartz_fixture.json | 292 +- .../models/item/quartz_glass.json | 8 +- .../item/quartz_growth_accelerator.json | 2 +- .../models/item/quartz_ore.json | 2 +- .../models/item/quartz_pillar.json | 2 +- .../models/item/quartz_pillar_slab.json | 2 +- .../models/item/quartz_pillar_stairs.json | 2 +- .../models/item/quartz_slab.json | 2 +- .../models/item/quartz_stairs.json | 2 +- .../models/item/quartz_vibrant_glass.json | 8 +- .../models/item/red_covered_cable.json | 8 +- .../models/item/red_covered_dense_cable.json | 8 +- .../models/item/red_glass_cable.json | 8 +- .../models/item/red_lumen_paint_ball.json | 8 +- .../models/item/red_paint_ball.json | 8 +- .../models/item/red_smart_cable.json | 8 +- .../models/item/red_smart_dense_cable.json | 8 +- .../models/item/redstone_card.json | 8 +- .../models/item/redstone_p2p_tunnel.json | 8 +- .../models/item/replicator_card.json | 8 +- .../models/item/security_station.json | 2 +- .../models/item/semi_dark_monitor.json | 16 +- .../models/item/silicon.json | 8 +- .../models/item/silicon_press.json | 8 +- .../models/item/singularity.json | 8 +- .../models/item/sky_compass.json | 2 +- .../models/item/sky_dust.json | 8 +- .../models/item/sky_stone_block.json | 2 +- .../models/item/sky_stone_brick.json | 2 +- .../models/item/sky_stone_brick_slab.json | 2 +- .../models/item/sky_stone_brick_stairs.json | 2 +- .../models/item/sky_stone_chest.json | 301 +-- .../models/item/sky_stone_slab.json | 2 +- .../models/item/sky_stone_small_brick.json | 2 +- .../item/sky_stone_small_brick_slab.json | 2 +- .../item/sky_stone_small_brick_stairs.json | 2 +- .../models/item/sky_stone_stairs.json | 2 +- .../models/item/smart_cable_base.json | 308 +-- .../models/item/smart_dense_cable_base.json | 208 +- .../models/item/smooth_sky_stone_block.json | 2 +- .../models/item/smooth_sky_stone_chest.json | 10 +- .../models/item/smooth_sky_stone_slab.json | 2 +- .../models/item/smooth_sky_stone_stairs.json | 2 +- .../models/item/spatial_io_port.json | 2 +- .../models/item/spatial_pylon.json | 8 +- .../models/item/speed_card.json | 8 +- .../models/item/storage_bus.json | 178 +- .../models/item/storage_monitor.json | 14 +- .../models/item/terminal.json | 14 +- .../models/item/tiny_tnt.json | 2 +- .../models/item/toggle_bus.json | 232 +- .../models/item/vibration_chamber.json | 2 +- .../models/item/view_cell.json | 8 +- .../models/item/white_covered_cable.json | 8 +- .../item/white_covered_dense_cable.json | 8 +- .../models/item/white_glass_cable.json | 8 +- .../models/item/white_lumen_paint_ball.json | 8 +- .../models/item/white_paint_ball.json | 8 +- .../models/item/white_smart_cable.json | 8 +- .../models/item/white_smart_dense_cable.json | 8 +- .../models/item/wireless_access_point.json | 180 +- .../models/item/wireless_booster.json | 8 +- .../models/item/wireless_receiver.json | 8 +- .../models/item/wireless_terminal.json | 8 +- .../models/item/wooden_crank.json | 8 +- .../models/item/wooden_gear.json | 8 +- .../models/item/yellow_covered_cable.json | 8 +- .../item/yellow_covered_dense_cable.json | 8 +- .../models/item/yellow_glass_cable.json | 8 +- .../models/item/yellow_lumen_paint_ball.json | 8 +- .../models/item/yellow_paint_ball.json | 8 +- .../models/item/yellow_smart_cable.json | 8 +- .../models/item/yellow_smart_dense_cable.json | 8 +- .../models/part/annihilation_plane.json | 2 +- .../models/part/annihilation_plane_on.json | 2 +- .../models/part/cable/covered/center.json | 108 +- .../models/part/cable/covered/connection.json | 108 +- .../models/part/cable/covered/straight.json | 108 +- .../part/cable/dense_covered/center.json | 108 +- .../part/cable/dense_covered/connection.json | 108 +- .../part/cable/dense_covered/straight.json | 108 +- .../models/part/cable/dense_smart/center.json | 108 +- .../part/cable/dense_smart/connection.json | 208 +- .../part/cable/dense_smart/straight.json | 208 +- .../models/part/cable/glass/center.json | 108 +- .../models/part/cable/glass/connection.json | 82 +- .../models/part/cable/glass/straight.json | 304 +-- .../models/part/cable/smart/center.json | 108 +- .../models/part/cable/smart/connection.json | 208 +- .../models/part/cable/smart/straight.json | 208 +- .../models/part/cable_anchor.json | 110 +- .../models/part/cable_anchor_short.json | 110 +- .../models/part/cable_facade.json | 110 +- .../part/conversion_monitor_locked_off.json | 12 +- .../part/conversion_monitor_locked_on.json | 122 +- .../models/part/conversion_monitor_off.json | 12 +- .../models/part/conversion_monitor_on.json | 122 +- .../models/part/crafting_terminal.json | 407 +-- .../models/part/crafting_terminal_off.json | 12 +- .../models/part/crafting_terminal_on.json | 122 +- .../models/part/display_base.json | 120 +- .../models/part/display_off.json | 96 +- .../part/display_status_has_channel.json | 94 +- .../models/part/display_status_off.json | 52 +- .../models/part/display_status_on.json | 94 +- .../models/part/export_bus_base.json | 228 +- .../models/part/export_bus_has_channel.json | 94 +- .../models/part/export_bus_off.json | 52 +- .../models/part/export_bus_on.json | 94 +- .../models/part/fluid_annihilation_plane.json | 2 +- .../part/fluid_annihilation_plane_on.json | 2 +- .../models/part/fluid_export_bus_base.json | 228 +- .../part/fluid_export_bus_has_channel.json | 94 +- .../models/part/fluid_export_bus_off.json | 52 +- .../models/part/fluid_export_bus_on.json | 94 +- .../models/part/fluid_formation_plane.json | 2 +- .../models/part/fluid_formation_plane_on.json | 2 +- .../models/part/fluid_import_bus_base.json | 228 +- .../part/fluid_import_bus_has_channel.json | 94 +- .../models/part/fluid_import_bus_off.json | 52 +- .../models/part/fluid_import_bus_on.json | 94 +- .../models/part/fluid_interface_base.json | 174 +- .../part/fluid_interface_has_channel.json | 94 +- .../models/part/fluid_interface_off.json | 52 +- .../models/part/fluid_interface_on.json | 94 +- .../models/part/fluid_storage_bus_base.json | 216 +- .../part/fluid_storage_bus_has_channel.json | 94 +- .../models/part/fluid_storage_bus_off.json | 52 +- .../models/part/fluid_storage_bus_on.json | 94 +- .../models/part/fluid_terminal.json | 407 +-- .../models/part/fluid_terminal_off.json | 12 +- .../models/part/fluid_terminal_on.json | 122 +- .../models/part/formation_plane.json | 2 +- .../models/part/formation_plane_on.json | 2 +- .../part/identity_annihilation_plane.json | 2 +- .../part/identity_annihilation_plane_on.json | 2 +- .../models/part/import_bus_base.json | 228 +- .../models/part/import_bus_has_channel.json | 94 +- .../models/part/import_bus_off.json | 52 +- .../models/part/import_bus_on.json | 94 +- .../models/part/interface_base.json | 174 +- .../models/part/interface_has_channel.json | 94 +- .../models/part/interface_off.json | 52 +- .../models/part/interface_on.json | 94 +- .../models/part/interface_terminal_off.json | 12 +- .../models/part/interface_terminal_on.json | 122 +- .../models/part/inverted_toggle_bus_base.json | 8 +- .../models/part/level_emitter_base_off.json | 127 +- .../models/part/level_emitter_base_on.json | 265 +- .../level_emitter_status_has_channel.json | 94 +- .../models/part/level_emitter_status_off.json | 52 +- .../models/part/level_emitter_status_on.json | 94 +- .../models/part/monitor_base.json | 120 +- .../models/part/monitor_bright_off.json | 36 +- .../models/part/monitor_bright_on.json | 50 +- .../models/part/monitor_dark_off.json | 36 +- .../models/part/monitor_dark_on.json | 46 +- .../models/part/monitor_medium_off.json | 36 +- .../models/part/monitor_medium_on.json | 46 +- .../models/part/p2p/p2p_tunnel_base.json | 1391 +++------- .../models/part/p2p/p2p_tunnel_fe.json | 8 +- .../models/part/p2p/p2p_tunnel_fluids.json | 8 +- .../models/part/p2p/p2p_tunnel_frequency.json | 2 +- .../models/part/p2p/p2p_tunnel_ic2.json | 8 +- .../models/part/p2p/p2p_tunnel_items.json | 8 +- .../models/part/p2p/p2p_tunnel_light.json | 8 +- .../models/part/p2p/p2p_tunnel_me.json | 8 +- .../models/part/p2p/p2p_tunnel_redstone.json | 8 +- .../p2p/p2p_tunnel_status_has_channel.json | 94 +- .../part/p2p/p2p_tunnel_status_off.json | 52 +- .../models/part/p2p/p2p_tunnel_status_on.json | 94 +- .../models/part/pattern_terminal_off.json | 12 +- .../models/part/pattern_terminal_on.json | 122 +- .../models/part/quartz_fiber.json | 66 +- .../models/part/storage_bus_base.json | 216 +- .../models/part/storage_bus_has_channel.json | 94 +- .../models/part/storage_bus_off.json | 52 +- .../models/part/storage_bus_on.json | 94 +- .../part/storage_monitor_locked_off.json | 12 +- .../part/storage_monitor_locked_on.json | 122 +- .../models/part/storage_monitor_off.json | 12 +- .../models/part/storage_monitor_on.json | 122 +- .../models/part/terminal_off.json | 12 +- .../models/part/terminal_on.json | 122 +- .../models/part/toggle_bus_base.json | 152 +- .../part/toggle_bus_status_has_channel.json | 94 +- .../models/part/toggle_bus_status_off.json | 52 +- .../models/part/toggle_bus_status_on.json | 94 +- .../part/transition_plane_has_channel.json | 146 +- .../models/part/transition_plane_off.json | 106 +- .../models/part/transition_plane_on.json | 148 +- .../particles/assembler_fx.json | 3 +- .../particles/charged_ore_fx.json | 2 +- .../particles/crafting_fx.json | 6 +- .../particles/lightning_arc_fx.json | 6 +- .../particles/lightning_fx.json | 6 +- .../particles/matter_cannon_fx.json | 6 +- .../particles/vibrant_fx.json | 6 +- .../advancements/main/charged_quartz.json | 2 +- .../advancements/main/charger.json | 2 +- .../advancements/main/compass.json | 2 +- .../advancements/main/controller.json | 2 +- .../advancements/main/crafting_cpu.json | 11 +- .../advancements/main/crafting_terminal.json | 2 +- .../advancements/main/facade.json | 2 +- .../advancements/main/fluix.json | 2 +- .../advancements/main/glass_cable.json | 2 +- .../advancements/main/growth_accelerator.json | 2 +- .../advancements/main/interface.json | 2 +- .../advancements/main/ioport.json | 2 +- .../advancements/main/network1.json | 2 +- .../advancements/main/network2.json | 2 +- .../advancements/main/network3.json | 2 +- .../advancements/main/network_tool.json | 2 +- .../advancements/main/p2p.json | 2 +- .../advancements/main/pattern_terminal.json | 2 +- .../advancements/main/portable_cell.json | 2 +- .../advancements/main/presses.json | 11 +- .../advancements/main/qnb.json | 2 +- .../advancements/main/root.json | 2 +- .../advancements/main/spatial_explorer.json | 2 +- .../advancements/main/spatial_ioport.json | 2 +- .../advancements/main/storage_bus.json | 2 +- .../advancements/main/storage_cell.json | 11 +- .../recipes/_factories.json | 22 +- .../decorative/certus_quartz_block.json | 7 +- .../decorative/certus_quartz_block_pure.json | 8 +- .../decorative/certus_quartz_pillar.json | 7 +- .../decorative/chiseled_quartz_block.json | 6 +- .../recipes/decorative/fluix_block.json | 7 +- .../recipes/decorative/fluix_block_pure.json | 8 +- .../recipes/decorative/light_detector.json | 6 +- .../recipes/decorative/quartz_block_pure.json | 8 +- .../recipes/decorative/quartz_fixture.json | 6 +- .../recipes/decorative/quartz_glass.json | 8 +- .../decorative/quartz_vibrant_glass.json | 6 +- .../recipes/decorative/sky_stone_brick.json | 2 +- .../decorative/sky_stone_small_brick.json | 2 +- .../recipes/decorative/sky_stone_smooth.json | 2 +- .../recipes/grinder/bonemeal.json | 2 +- .../recipes/grinder/certus_quartz_dust.json | 2 +- .../grinder/certus_quartz_dust_ore.json | 2 +- .../recipes/grinder/ender_dust.json | 2 +- .../recipes/grinder/flint.json | 2 +- .../recipes/grinder/flour.json | 2 +- .../recipes/grinder/fluix_dust.json | 2 +- .../recipes/grinder/gold_dust_ingot.json | 2 +- .../recipes/grinder/gold_dust_ore.json | 2 +- .../recipes/grinder/iron_dust_ingot.json | 2 +- .../recipes/grinder/iron_dust_ore.json | 2 +- .../recipes/grinder/nether_quartz_dust.json | 2 +- .../grinder/nether_quartz_dust_ore.json | 2 +- .../recipes/grinder/sky_dust.json | 2 +- .../inscriber/calculation_processor.json | 2 +- .../calculation_processor_press.json | 2 +- .../calculation_processor_print.json | 2 +- .../inscriber/engineering_processor.json | 2 +- .../engineering_processor_press.json | 2 +- .../engineering_processor_print.json | 2 +- .../recipes/inscriber/logic_processor.json | 2 +- .../inscriber/logic_processor_press.json | 2 +- .../inscriber/logic_processor_print.json | 2 +- .../recipes/inscriber/silicon_press.json | 2 +- .../recipes/inscriber/silicon_print.json | 2 +- .../recipes/materials/advancedcard.json | 8 +- .../recipes/materials/annihilationcore.json | 6 +- .../recipes/materials/basiccard.json | 8 +- .../recipes/materials/cardcapacity.json | 2 +- .../recipes/materials/cardcrafting.json | 2 +- .../recipes/materials/cardfuzzy.json | 2 +- .../recipes/materials/cardinverter.json | 2 +- .../recipes/materials/cardredstone.json | 2 +- .../recipes/materials/cardspeed.json | 2 +- .../recipes/materials/formationcore.json | 6 +- .../recipes/misc/chests_sky_stone.json | 8 +- .../recipes/misc/chests_smooth_sky_stone.json | 8 +- ...deconstruction_certus_chiseled_quartz.json | 2 +- .../deconstruction_certus_quartz_block.json | 2 +- .../deconstruction_certus_quartz_pillar.json | 2 +- .../misc/deconstruction_fluix_block.json | 2 +- .../recipes/misc/fluixpearl.json | 8 +- .../recipes/misc/grindstone.json | 8 +- .../recipes/misc/grindstone_crank.json | 8 +- .../recipes/misc/grindstone_woodengear.json | 8 +- .../recipes/misc/meteors_sky_compass.json | 8 +- .../recipes/misc/seeds_certus.json | 2 +- .../recipes/misc/seeds_fluix.json | 2 +- .../recipes/misc/seeds_nether.json | 2 +- .../recipes/misc/tiny_tnt.json | 7 +- .../recipes/misc/vanilla_comparator.json | 8 +- .../misc/vanilla_daylight_detector.json | 8 +- .../network/blocks/cell_workbench.json | 8 +- .../recipes/network/blocks/controller.json | 8 +- .../blocks/crystal_processing_charger.json | 8 +- ..._processing_quartz_growth_accelerator.json | 8 +- .../blocks/energy_dense_energy_cell.json | 8 +- .../blocks/energy_energy_acceptor.json | 8 +- .../network/blocks/energy_energy_cell.json | 8 +- .../blocks/energy_vibration_chamber.json | 8 +- .../blocks/fluid_interfaces_interface.json | 8 +- .../fluid_interfaces_interface_alt.json | 2 +- .../fluid_interfaces_interface_part.json | 2 +- .../recipes/network/blocks/inscribers.json | 8 +- .../network/blocks/interfaces_interface.json | 8 +- .../blocks/interfaces_interface_alt.json | 2 +- .../blocks/interfaces_interface_part.json | 2 +- .../recipes/network/blocks/io_condenser.json | 8 +- .../recipes/network/blocks/io_port.json | 8 +- .../recipes/network/blocks/quantum_link.json | 8 +- .../recipes/network/blocks/quantum_ring.json | 8 +- .../network/blocks/security_station.json | 8 +- .../network/blocks/spatial_io_port.json | 8 +- .../network/blocks/spatial_io_pylon.json | 8 +- .../recipes/network/blocks/storage_chest.json | 8 +- .../recipes/network/blocks/storage_drive.json | 8 +- .../recipes/network/cables/covered_black.json | 8 +- .../recipes/network/cables/covered_blue.json | 8 +- .../recipes/network/cables/covered_brown.json | 8 +- .../recipes/network/cables/covered_cyan.json | 8 +- .../recipes/network/cables/covered_fluix.json | 2 +- .../network/cables/covered_fluix_clean.json | 2 +- .../recipes/network/cables/covered_gray.json | 8 +- .../recipes/network/cables/covered_green.json | 8 +- .../network/cables/covered_light_blue.json | 8 +- .../network/cables/covered_light_gray.json | 8 +- .../recipes/network/cables/covered_lime.json | 8 +- .../network/cables/covered_magenta.json | 8 +- .../network/cables/covered_orange.json | 8 +- .../recipes/network/cables/covered_pink.json | 8 +- .../network/cables/covered_purple.json | 8 +- .../recipes/network/cables/covered_red.json | 8 +- .../recipes/network/cables/covered_white.json | 8 +- .../network/cables/covered_yellow.json | 8 +- .../network/cables/dense_covered_black.json | 8 +- .../network/cables/dense_covered_blue.json | 8 +- .../network/cables/dense_covered_brown.json | 8 +- .../network/cables/dense_covered_cyan.json | 8 +- .../network/cables/dense_covered_fluix.json | 2 +- .../cables/dense_covered_fluix_clean.json | 2 +- .../network/cables/dense_covered_gray.json | 8 +- .../network/cables/dense_covered_green.json | 8 +- .../cables/dense_covered_light_blue.json | 8 +- .../cables/dense_covered_light_gray.json | 8 +- .../network/cables/dense_covered_lime.json | 8 +- .../network/cables/dense_covered_magenta.json | 8 +- .../network/cables/dense_covered_orange.json | 8 +- .../network/cables/dense_covered_pink.json | 8 +- .../network/cables/dense_covered_purple.json | 8 +- .../network/cables/dense_covered_red.json | 8 +- .../network/cables/dense_covered_white.json | 8 +- .../network/cables/dense_covered_yellow.json | 8 +- .../network/cables/dense_smart_black.json | 8 +- .../network/cables/dense_smart_blue.json | 8 +- .../network/cables/dense_smart_brown.json | 8 +- .../network/cables/dense_smart_cyan.json | 8 +- .../network/cables/dense_smart_fluix.json | 2 +- .../cables/dense_smart_fluix_clean.json | 2 +- .../network/cables/dense_smart_gray.json | 8 +- .../network/cables/dense_smart_green.json | 8 +- .../cables/dense_smart_light_blue.json | 8 +- .../cables/dense_smart_light_gray.json | 8 +- .../network/cables/dense_smart_lime.json | 8 +- .../network/cables/dense_smart_magenta.json | 8 +- .../network/cables/dense_smart_orange.json | 8 +- .../network/cables/dense_smart_pink.json | 8 +- .../network/cables/dense_smart_purple.json | 8 +- .../network/cables/dense_smart_red.json | 8 +- .../network/cables/dense_smart_white.json | 8 +- .../network/cables/dense_smart_yellow.json | 8 +- .../recipes/network/cables/glass_black.json | 8 +- .../recipes/network/cables/glass_blue.json | 8 +- .../recipes/network/cables/glass_brown.json | 8 +- .../recipes/network/cables/glass_cyan.json | 8 +- .../recipes/network/cables/glass_fluix.json | 2 +- .../network/cables/glass_fluix_clean.json | 2 +- .../recipes/network/cables/glass_gray.json | 8 +- .../recipes/network/cables/glass_green.json | 8 +- .../network/cables/glass_light_blue.json | 8 +- .../network/cables/glass_light_gray.json | 8 +- .../recipes/network/cables/glass_lime.json | 8 +- .../recipes/network/cables/glass_magenta.json | 8 +- .../recipes/network/cables/glass_orange.json | 8 +- .../recipes/network/cables/glass_pink.json | 8 +- .../recipes/network/cables/glass_purple.json | 8 +- .../recipes/network/cables/glass_red.json | 8 +- .../recipes/network/cables/glass_white.json | 8 +- .../recipes/network/cables/glass_yellow.json | 8 +- .../recipes/network/cables/smart_black.json | 8 +- .../recipes/network/cables/smart_blue.json | 8 +- .../recipes/network/cables/smart_brown.json | 8 +- .../recipes/network/cables/smart_cyan.json | 8 +- .../recipes/network/cables/smart_fluix.json | 2 +- .../network/cables/smart_fluix_clean.json | 2 +- .../recipes/network/cables/smart_gray.json | 8 +- .../recipes/network/cables/smart_green.json | 8 +- .../network/cables/smart_light_blue.json | 8 +- .../network/cables/smart_light_gray.json | 8 +- .../recipes/network/cables/smart_lime.json | 8 +- .../recipes/network/cables/smart_magenta.json | 8 +- .../recipes/network/cables/smart_orange.json | 8 +- .../recipes/network/cables/smart_pink.json | 8 +- .../recipes/network/cables/smart_purple.json | 8 +- .../recipes/network/cables/smart_red.json | 8 +- .../recipes/network/cables/smart_white.json | 8 +- .../recipes/network/cables/smart_yellow.json | 8 +- .../network/cells/empty_storage_cell.json | 8 +- .../network/cells/fluid_storage_cell_16k.json | 8 +- .../cells/fluid_storage_cell_16k_storage.json | 2 +- .../network/cells/fluid_storage_cell_1k.json | 8 +- .../cells/fluid_storage_cell_1k_storage.json | 2 +- .../network/cells/fluid_storage_cell_4k.json | 8 +- .../cells/fluid_storage_cell_4k_storage.json | 2 +- .../network/cells/fluid_storage_cell_64k.json | 8 +- .../cells/fluid_storage_cell_64k_storage.json | 2 +- ...luid_storage_components_cell_16k_part.json | 8 +- ...fluid_storage_components_cell_1k_part.json | 8 +- ...fluid_storage_components_cell_4k_part.json | 8 +- ...luid_storage_components_cell_64k_part.json | 8 +- .../network/cells/spatial_components.json | 8 +- .../network/cells/spatial_components_0.json | 8 +- .../network/cells/spatial_components_1.json | 8 +- .../cells/spatial_storage_cell_128_cubed.json | 8 +- ...patial_storage_cell_128_cubed_storage.json | 2 +- .../cells/spatial_storage_cell_16_cubed.json | 8 +- ...spatial_storage_cell_16_cubed_storage.json | 2 +- .../cells/spatial_storage_cell_2_cubed.json | 8 +- .../spatial_storage_cell_2_cubed_storage.json | 2 +- .../network/cells/storage_cell_16k.json | 8 +- .../cells/storage_cell_16k_storage.json | 2 +- .../network/cells/storage_cell_1k.json | 8 +- .../cells/storage_cell_1k_storage.json | 2 +- .../network/cells/storage_cell_4k.json | 8 +- .../cells/storage_cell_4k_storage.json | 2 +- .../network/cells/storage_cell_64k.json | 8 +- .../cells/storage_cell_64k_storage.json | 2 +- .../storage_components_cell_16k_part.json | 8 +- .../storage_components_cell_1k_part.json | 8 +- .../storage_components_cell_4k_part.json | 8 +- .../storage_components_cell_64k_part.json | 8 +- .../recipes/network/cells/view_cell.json | 8 +- .../network/cells/view_cell_storage.json | 2 +- .../crafting/16k_cpu_crafting_storage.json | 2 +- .../crafting/1k_cpu_crafting_storage.json | 2 +- .../crafting/4k_cpu_crafting_storage.json | 2 +- .../crafting/64k_cpu_crafting_storage.json | 2 +- .../crafting/cpu_crafting_accelerator.json | 2 +- .../crafting/cpu_crafting_monitor.json | 2 +- .../network/crafting/cpu_crafting_unit.json | 8 +- .../network/crafting/molecular_assembler.json | 8 +- .../network/crafting/patterns_blank.json | 8 +- .../recipes/network/parts/cable_anchor.json | 2 +- .../recipes/network/parts/export_bus.json | 7 +- .../network/parts/export_bus_fluid.json | 7 +- .../network/parts/fluid_level_emitter.json | 2 +- .../recipes/network/parts/import_bus.json | 7 +- .../network/parts/import_bus_fluid.json | 7 +- .../recipes/network/parts/level_emitter.json | 2 +- .../network/parts/monitors_conversion.json | 2 +- .../network/parts/monitors_storage.json | 2 +- .../network/parts/panels_dark_monitor.json | 2 +- .../recipes/network/parts/panels_monitor.json | 2 +- .../parts/panels_semi_dark_monitor.json | 8 +- .../parts/panels_semi_dark_monitor_alt.json | 2 +- .../parts/planes_annihilation_alt.json | 7 +- .../parts/planes_annihilation_alt2.json | 8 +- .../parts/planes_annihilation_fluid.json | 8 +- .../parts/planes_annihilation_fluid_alt.json | 8 +- .../parts/planes_annihilatition_identity.json | 2 +- .../network/parts/planes_formation.json | 7 +- .../network/parts/planes_formation_alt.json | 8 +- .../network/parts/planes_formation_fluid.json | 8 +- .../parts/planes_formation_fluid_alt.json | 8 +- .../network/parts/quartz_fiber_part.json | 8 +- .../recipes/network/parts/storage_bus.json | 2 +- .../network/parts/storage_bus_fluid.json | 2 +- .../recipes/network/parts/terminals.json | 2 +- .../network/parts/terminals_crafting.json | 2 +- .../network/parts/terminals_fluid.json | 2 +- .../network/parts/terminals_interface.json | 2 +- .../network/parts/terminals_pattern.json | 2 +- .../recipes/network/parts/toggle_bus.json | 8 +- .../recipes/network/parts/toggle_bus_alt.json | 2 +- .../parts/toggle_bus_inverted_alt.json | 2 +- .../recipes/network/parts/tunnels_me.json | 8 +- .../network/wireless_access_point.json | 8 +- .../recipes/network/wireless_booster.json | 7 +- .../recipes/network/wireless_part.json | 8 +- .../recipes/network/wireless_terminal.json | 8 +- .../recipes/smelting/bread.json | 2 +- .../recipes/smelting/gold_ingot.json | 2 +- .../recipes/smelting/iron_ingot.json | 2 +- .../recipes/smelting/silicon.json | 2 +- .../smelting/smooth_sky_stone_block.json | 2 +- .../recipes/tools/certus_quartz_axe.json | 8 +- .../tools/certus_quartz_cutting_knife.json | 8 +- .../recipes/tools/certus_quartz_hoe.json | 8 +- .../recipes/tools/certus_quartz_pickaxe.json | 8 +- .../recipes/tools/certus_quartz_spade.json | 8 +- .../recipes/tools/certus_quartz_sword.json | 8 +- .../recipes/tools/certus_quartz_wrench.json | 8 +- .../recipes/tools/matter_cannon.json | 8 +- .../tools/misctools_charged_staff.json | 8 +- .../tools/misctools_entropy_manipulator.json | 8 +- .../recipes/tools/nether_quartz_axe.json | 8 +- .../tools/nether_quartz_cutting_knife.json | 8 +- .../recipes/tools/nether_quartz_hoe.json | 8 +- .../recipes/tools/nether_quartz_pickaxe.json | 8 +- .../recipes/tools/nether_quartz_spade.json | 8 +- .../recipes/tools/nether_quartz_sword.json | 8 +- .../recipes/tools/nether_quartz_wrench.json | 8 +- .../recipes/tools/network_biometric_card.json | 7 +- .../tools/network_color_applicator.json | 8 +- .../recipes/tools/network_memory_card.json | 7 +- .../recipes/tools/network_portable_cell.json | 6 +- .../recipes/tools/network_tool.json | 2 +- .../recipes/tools/paintballs_black.json | 8 +- .../recipes/tools/paintballs_blue.json | 8 +- .../recipes/tools/paintballs_brown.json | 8 +- .../recipes/tools/paintballs_cyan.json | 8 +- .../recipes/tools/paintballs_gray.json | 8 +- .../recipes/tools/paintballs_green.json | 8 +- .../recipes/tools/paintballs_light_blue.json | 8 +- .../recipes/tools/paintballs_light_gray.json | 8 +- .../recipes/tools/paintballs_lime.json | 8 +- .../recipes/tools/paintballs_lumen_black.json | 8 +- .../recipes/tools/paintballs_lumen_blue.json | 8 +- .../recipes/tools/paintballs_lumen_brown.json | 8 +- .../recipes/tools/paintballs_lumen_cyan.json | 8 +- .../recipes/tools/paintballs_lumen_gray.json | 8 +- .../recipes/tools/paintballs_lumen_green.json | 8 +- .../tools/paintballs_lumen_light_blue.json | 8 +- .../tools/paintballs_lumen_light_gray.json | 8 +- .../recipes/tools/paintballs_lumen_lime.json | 8 +- .../tools/paintballs_lumen_magenta.json | 8 +- .../tools/paintballs_lumen_orange.json | 8 +- .../recipes/tools/paintballs_lumen_pink.json | 8 +- .../tools/paintballs_lumen_purple.json | 8 +- .../recipes/tools/paintballs_lumen_red.json | 8 +- .../recipes/tools/paintballs_lumen_white.json | 8 +- .../tools/paintballs_lumen_yellow.json | 8 +- .../recipes/tools/paintballs_magenta.json | 8 +- .../recipes/tools/paintballs_orange.json | 8 +- .../recipes/tools/paintballs_pink.json | 8 +- .../recipes/tools/paintballs_purple.json | 8 +- .../recipes/tools/paintballs_red.json | 8 +- .../recipes/tools/paintballs_white.json | 8 +- .../recipes/tools/paintballs_yellow.json | 8 +- .../tags/items/covered_cable.json | 2 +- .../tags/items/covered_dense_cable.json | 2 +- .../tags/items/crystals/certus.json | 2 +- .../tags/items/crystals/certus_quartz.json | 6 +- .../tags/items/crystals/fluix.json | 2 +- .../tags/items/crystals/nether.json | 2 +- .../tags/items/crystals/quartz.json | 2 +- .../tags/items/dusts/certus_quartz.json | 6 +- .../tags/items/dusts/ender.json | 2 +- .../tags/items/dusts/fluix.json | 6 +- .../tags/items/dusts/nether_quartz.json | 6 +- .../tags/items/dusts/quartz.json | 2 +- .../tags/items/fluid_interface.json | 2 +- .../tags/items/gears/wooden.json | 6 +- .../appliedenergistics2/tags/items/glass.json | 7 +- .../tags/items/glass_cable.json | 2 +- .../tags/items/illuminated_panel.json | 2 +- .../tags/items/interface.json | 2 +- .../appliedenergistics2/tags/items/knife.json | 2 +- .../tags/items/metal_ingots.json | 7 +- .../tags/items/nether_quartz_dust.json | 6 +- .../tags/items/quartz_wrench.json | 2 +- .../tags/items/silicon.json | 6 +- .../tags/items/smart_cable.json | 2 +- .../tags/items/smart_dense_cable.json | 2 +- .../appliedenergistics2/tags/items/wool.json | 6 +- .../tags/items/workbench.json | 6 +- .../data/forge/tags/items/dusts/gold.json | 6 +- .../data/forge/tags/items/dusts/iron.json | 6 +- .../forge/tags/items/gems/certus_quartz.json | 2 +- .../forge/tags/items/ores/certus_quartz.json | 2 +- .../worlddata/MeteorDataNameEncoderTest.java | 47 +- .../SpatialDimensionExtraDataTest.java | 13 +- .../util/SlimReadableNumberConverterTest.java | 163 +- .../java/appeng/util/UUIDMatcherTest.java | 47 +- .../util/WideReadableNumberConverterTest.java | 163 +- .../appeng/util/helpers/P2PHelperTest.java | 128 +- .../appeng/services/version/releases.json | 24 +- .../blockstates/uvlblock.json | 6 +- .../models/block/uvlblock.json | 228 +- .../models/block/uvlblock_vanilla.json | 8 +- .../models/item/uvlblock.json | 2 +- 2252 files changed, 95466 insertions(+), 118582 deletions(-) diff --git a/src/api/java/appeng/api/AEApi.java b/src/api/java/appeng/api/AEApi.java index daea9cfd1..1ee908340 100644 --- a/src/api/java/appeng/api/AEApi.java +++ b/src/api/java/appeng/api/AEApi.java @@ -23,54 +23,45 @@ package appeng.api; - import java.lang.reflect.Field; import appeng.api.exceptions.CoreInaccessibleException; - /** * Entry point for api. */ -public enum AEApi -{ - ; +public enum AEApi { + ; - private static final String CORE_API_FQN = "appeng.core.Api"; - private static final String CORE_API_FIELD = "INSTANCE"; - private static final IAppEngApi HELD_API; + private static final String CORE_API_FQN = "appeng.core.Api"; + private static final String CORE_API_FIELD = "INSTANCE"; + private static final IAppEngApi HELD_API; - static - { - try - { - final Class apiClass = Class.forName( CORE_API_FQN ); - final Field apiField = apiClass.getField( CORE_API_FIELD ); + static { + try { + final Class apiClass = Class.forName(CORE_API_FQN); + final Field apiField = apiClass.getField(CORE_API_FIELD); - HELD_API = (IAppEngApi) apiField.get( apiClass ); - } - catch( final ClassNotFoundException e ) - { - throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FQN + " class, without it being declared." ); - } - catch( final NoSuchFieldException e ) - { - throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FIELD + " field in " + CORE_API_FQN + " without it being declared." ); - } - catch( final IllegalAccessException e ) - { - throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FIELD + " field in " + CORE_API_FQN + " without enough access permissions." ); - } - } + HELD_API = (IAppEngApi) apiField.get(apiClass); + } catch (final ClassNotFoundException e) { + throw new CoreInaccessibleException( + "AE2 API tried to access the " + CORE_API_FQN + " class, without it being declared."); + } catch (final NoSuchFieldException e) { + throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in " + + CORE_API_FQN + " without it being declared."); + } catch (final IllegalAccessException e) { + throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in " + + CORE_API_FQN + " without enough access permissions."); + } + } - /** - * API Entry Point. - * - * @return the {@link IAppEngApi} - */ - public static IAppEngApi instance() - { - return HELD_API; - } + /** + * API Entry Point. + * + * @return the {@link IAppEngApi} + */ + public static IAppEngApi instance() { + return HELD_API; + } } diff --git a/src/api/java/appeng/api/AEInjectable.java b/src/api/java/appeng/api/AEInjectable.java index 0ddb29c2d..7dded1cbe 100644 --- a/src/api/java/appeng/api/AEInjectable.java +++ b/src/api/java/appeng/api/AEInjectable.java @@ -18,17 +18,16 @@ package appeng.api; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** - * Marks interfaces that can be used as injectable constructor arguments for an {@link AEPlugin}. + * Marks interfaces that can be used as injectable constructor arguments for an + * {@link AEPlugin}. */ -@Target( ElementType.TYPE ) -@Retention( RetentionPolicy.RUNTIME ) -public @interface AEInjectable -{} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface AEInjectable { +} diff --git a/src/api/java/appeng/api/AEPlugin.java b/src/api/java/appeng/api/AEPlugin.java index f9623585d..96186fff7 100644 --- a/src/api/java/appeng/api/AEPlugin.java +++ b/src/api/java/appeng/api/AEPlugin.java @@ -18,22 +18,20 @@ package appeng.api; - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** - * Use this annotation on a class in your Mod to have it instantiated during the initialization phase of Applied - * Energistics. - * AE expects your class to have a single constructor and can supply certain arguments to your constructor using + * Use this annotation on a class in your Mod to have it instantiated during the + * initialization phase of Applied Energistics. AE expects your class to have a + * single constructor and can supply certain arguments to your constructor using * dependency injection. */ -@Target( ElementType.TYPE ) -@Retention( RetentionPolicy.RUNTIME ) +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) @Documented -public @interface AEPlugin -{} +public @interface AEPlugin { +} diff --git a/src/api/java/appeng/api/IAppEngApi.java b/src/api/java/appeng/api/IAppEngApi.java index 3b9203b16..e09400db3 100644 --- a/src/api/java/appeng/api/IAppEngApi.java +++ b/src/api/java/appeng/api/IAppEngApi.java @@ -23,7 +23,6 @@ package appeng.api; - import appeng.api.definitions.IDefinitions; import appeng.api.features.IRegistryContainer; import appeng.api.networking.IGridHelper; @@ -32,38 +31,36 @@ import appeng.api.parts.IPartHelper; import appeng.api.storage.IStorageHelper; import appeng.api.util.IClientHelper; - @AEInjectable -public interface IAppEngApi -{ - /** - * @return Registry Container for the numerous registries in AE2. - */ - IRegistryContainer registries(); +public interface IAppEngApi { + /** + * @return Registry Container for the numerous registries in AE2. + */ + IRegistryContainer registries(); - /** - * @return A helper for working with storage data types. - */ - IStorageHelper storage(); + /** + * @return A helper for working with storage data types. + */ + IStorageHelper storage(); - /** - * @return A helper to create {@link IGridNode} and other grid related objects. - */ - IGridHelper grid(); + /** + * @return A helper to create {@link IGridNode} and other grid related objects. + */ + IGridHelper grid(); - /** - * @return A helper for working with grids, and buses. - */ - IPartHelper partHelper(); + /** + * @return A helper for working with grids, and buses. + */ + IPartHelper partHelper(); - /** - * @return An accessible list of all AE definitions - */ - IDefinitions definitions(); + /** + * @return An accessible list of all AE definitions + */ + IDefinitions definitions(); - /** - * @return Utility methods primarily useful for client side stuff - */ - IClientHelper client(); + /** + * @return Utility methods primarily useful for client side stuff + */ + IClientHelper client(); } \ 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 6788d744e..6a4fab333 100644 --- a/src/api/java/appeng/api/config/AccessRestriction.java +++ b/src/api/java/appeng/api/config/AccessRestriction.java @@ -23,51 +23,42 @@ package appeng.api.config; +public enum AccessRestriction { + NO_ACCESS(0), READ(1), WRITE(2), READ_WRITE(3); -public enum AccessRestriction -{ - NO_ACCESS( 0 ), READ( 1 ), WRITE( 2 ), READ_WRITE( 3 ); + private final int permissionBit; - private final int permissionBit; + AccessRestriction(final int v) { + this.permissionBit = v; + } - AccessRestriction( final int v ) - { - this.permissionBit = v; - } + public boolean hasPermission(final AccessRestriction ar) { + return (this.permissionBit & ar.permissionBit) == ar.permissionBit; + } - public boolean hasPermission( final AccessRestriction ar ) - { - return ( this.permissionBit & ar.permissionBit ) == ar.permissionBit; - } + public AccessRestriction restrictPermissions(final AccessRestriction ar) { + return this.getPermByBit(this.permissionBit & ar.permissionBit); + } - public AccessRestriction restrictPermissions( final AccessRestriction ar ) - { - return this.getPermByBit( this.permissionBit & ar.permissionBit ); - } + private AccessRestriction getPermByBit(final int bit) { + switch (bit) { + default: + case 0: + return NO_ACCESS; + case 1: + return READ; + case 2: + return WRITE; + case 3: + return READ_WRITE; + } + } - private AccessRestriction getPermByBit( final int bit ) - { - switch( bit ) - { - default: - case 0: - return NO_ACCESS; - case 1: - return READ; - case 2: - return WRITE; - case 3: - return READ_WRITE; - } - } + public AccessRestriction addPermissions(final AccessRestriction ar) { + return this.getPermByBit(this.permissionBit | ar.permissionBit); + } - public AccessRestriction addPermissions( final AccessRestriction ar ) - { - return this.getPermByBit( this.permissionBit | ar.permissionBit ); - } - - public AccessRestriction removePermissions( final AccessRestriction ar ) - { - return this.getPermByBit( this.permissionBit & ( ~ar.permissionBit ) ); - } + public AccessRestriction removePermissions(final AccessRestriction ar) { + return this.getPermByBit(this.permissionBit & (~ar.permissionBit)); + } } \ 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 3421abbb7..5d1c81d75 100644 --- a/src/api/java/appeng/api/config/ActionItems.java +++ b/src/api/java/appeng/api/config/ActionItems.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum ActionItems -{ - WRENCH, CLOSE, STASH, ENCODE, ENABLE_SUBSTITUTION, DISABLE_SUBSTITUTION +public enum ActionItems { + WRENCH, CLOSE, STASH, ENCODE, ENABLE_SUBSTITUTION, DISABLE_SUBSTITUTION } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/Actionable.java b/src/api/java/appeng/api/config/Actionable.java index f8edf0cf1..76948f9be 100644 --- a/src/api/java/appeng/api/config/Actionable.java +++ b/src/api/java/appeng/api/config/Actionable.java @@ -23,31 +23,26 @@ package appeng.api.config; - import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; +public enum Actionable { + /** + * Perform the intended action. + */ + MODULATE(FluidAction.EXECUTE), -public enum Actionable -{ - /** - * Perform the intended action. - */ - MODULATE( FluidAction.EXECUTE ), + /** + * Pretend to perform the action. + */ + SIMULATE(FluidAction.SIMULATE); - /** - * Pretend to perform the action. - */ - SIMULATE( FluidAction.SIMULATE ); + private final FluidAction fluidAction; - private final FluidAction fluidAction; + Actionable(FluidAction fluidAction) { + this.fluidAction = fluidAction; + } - Actionable( FluidAction fluidAction ) - { - this.fluidAction = fluidAction; - } - - public FluidAction getFluidAction() - { - return fluidAction; - } + public FluidAction getFluidAction() { + return fluidAction; + } } diff --git a/src/api/java/appeng/api/config/CondenserOutput.java b/src/api/java/appeng/api/config/CondenserOutput.java index cb9efae00..328877987 100644 --- a/src/api/java/appeng/api/config/CondenserOutput.java +++ b/src/api/java/appeng/api/config/CondenserOutput.java @@ -23,16 +23,14 @@ package appeng.api.config; +public enum CondenserOutput { -public enum CondenserOutput -{ + TRASH, // 0 - TRASH, // 0 + MATTER_BALLS, // 256 - MATTER_BALLS, // 256 + SINGULARITY; // 250,000 - SINGULARITY; // 250,000 - - public int requiredPower = 0; + public int requiredPower = 0; } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/CopyMode.java b/src/api/java/appeng/api/config/CopyMode.java index 7f2f39969..484e7bd38 100644 --- a/src/api/java/appeng/api/config/CopyMode.java +++ b/src/api/java/appeng/api/config/CopyMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum CopyMode -{ - CLEAR_ON_REMOVE, KEEP_ON_REMOVE +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 c52d4228f..4b213cc72 100644 --- a/src/api/java/appeng/api/config/FullnessMode.java +++ b/src/api/java/appeng/api/config/FullnessMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum FullnessMode -{ - EMPTY, HALF, FULL +public enum FullnessMode { + EMPTY, HALF, FULL } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/FuzzyMode.java b/src/api/java/appeng/api/config/FuzzyMode.java index 84c36c78f..b2b05e7b4 100644 --- a/src/api/java/appeng/api/config/FuzzyMode.java +++ b/src/api/java/appeng/api/config/FuzzyMode.java @@ -23,28 +23,20 @@ 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); -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 ); + public final float breakPoint; + public final float percentage; - public final float breakPoint; - public final float percentage; + FuzzyMode(final float p) { + this.percentage = p; + this.breakPoint = p / 100.0f; + } - FuzzyMode( final float p ) - { - this.percentage = p; - this.breakPoint = p / 100.0f; - } - - public int calculateBreakPoint( final int maxDamage ) - { - return (int) ( ( this.percentage * maxDamage ) / 100.0f ); - } + public int calculateBreakPoint(final int maxDamage) { + 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 53f0bbeb7..64a4a8e87 100644 --- a/src/api/java/appeng/api/config/IncludeExclude.java +++ b/src/api/java/appeng/api/config/IncludeExclude.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum IncludeExclude -{ - WHITELIST, BLACKLIST +public enum IncludeExclude { + WHITELIST, BLACKLIST } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/LevelEmitterMode.java b/src/api/java/appeng/api/config/LevelEmitterMode.java index dcdd0ef88..352c966f4 100644 --- a/src/api/java/appeng/api/config/LevelEmitterMode.java +++ b/src/api/java/appeng/api/config/LevelEmitterMode.java @@ -23,12 +23,10 @@ package appeng.api.config; +public enum LevelEmitterMode { -public enum LevelEmitterMode -{ + STORED_AMOUNT, - STORED_AMOUNT, - - STORABLE_AMOUNT + STORABLE_AMOUNT } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/LevelType.java b/src/api/java/appeng/api/config/LevelType.java index 0787abb75..86acc0e8b 100644 --- a/src/api/java/appeng/api/config/LevelType.java +++ b/src/api/java/appeng/api/config/LevelType.java @@ -23,12 +23,10 @@ package appeng.api.config; +public enum LevelType { -public enum LevelType -{ + ITEM_LEVEL, - ITEM_LEVEL, - - ENERGY_LEVEL + ENERGY_LEVEL } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/ModSettings.java b/src/api/java/appeng/api/config/ModSettings.java index b12258446..8805bcc70 100644 --- a/src/api/java/appeng/api/config/ModSettings.java +++ b/src/api/java/appeng/api/config/ModSettings.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum ModSettings -{ +public enum ModSettings { } diff --git a/src/api/java/appeng/api/config/NetworkEmitterMode.java b/src/api/java/appeng/api/config/NetworkEmitterMode.java index 03efd7c98..022cb0339 100644 --- a/src/api/java/appeng/api/config/NetworkEmitterMode.java +++ b/src/api/java/appeng/api/config/NetworkEmitterMode.java @@ -23,14 +23,12 @@ package appeng.api.config; +public enum NetworkEmitterMode { -public enum NetworkEmitterMode -{ + POWER_LEVEL, - POWER_LEVEL, + BOOTING, - BOOTING, - - CHANNEL_ERROR + CHANNEL_ERROR } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/OperationMode.java b/src/api/java/appeng/api/config/OperationMode.java index f2c8ff30e..b5016b0ac 100644 --- a/src/api/java/appeng/api/config/OperationMode.java +++ b/src/api/java/appeng/api/config/OperationMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum OperationMode -{ - FILL, EMPTY +public enum OperationMode { + FILL, EMPTY } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/OutputMode.java b/src/api/java/appeng/api/config/OutputMode.java index f9bcffa57..b5271c446 100644 --- a/src/api/java/appeng/api/config/OutputMode.java +++ b/src/api/java/appeng/api/config/OutputMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum OutputMode -{ - EXPORT_ONLY, EXPORT_OR_CRAFT, CRAFT_ONLY +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 dd50e79eb..898dd06e0 100644 --- a/src/api/java/appeng/api/config/PowerMultiplier.java +++ b/src/api/java/appeng/api/config/PowerMultiplier.java @@ -23,23 +23,19 @@ package appeng.api.config; +public enum PowerMultiplier { + ONE, CONFIG; -public enum PowerMultiplier -{ - ONE, CONFIG; + /** + * please do not edit this value, it is set when AE loads its config files. + */ + public double multiplier = 1.0; - /** - * please do not edit this value, it is set when AE loads its config files. - */ - public double multiplier = 1.0; + public double multiply(final double in) { + return in * this.multiplier; + } - public double multiply( final double in ) - { - return in * this.multiplier; - } - - public double divide( final double in ) - { - return in / this.multiplier; - } + public double divide(final 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 78dc456c0..f5816baa4 100644 --- a/src/api/java/appeng/api/config/PowerUnits.java +++ b/src/api/java/appeng/api/config/PowerUnits.java @@ -23,49 +23,46 @@ package appeng.api.config; - import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; -public enum PowerUnits -{ - AE( "gui.appliedenergistics2.units.appliedenergstics" ), // Native Units - AE Energy - EU( "gui.appliedenergistics2.units.ic2" ), // IndustrialCraft 2 - Energy Units - RF( "gui.appliedenergistics2.units.rf" ); // RF - Redstone Flux +public enum PowerUnits { + AE("gui.appliedenergistics2.units.appliedenergstics"), // Native Units - AE Energy + EU("gui.appliedenergistics2.units.ic2"), // IndustrialCraft 2 - Energy Units + RF("gui.appliedenergistics2.units.rf"); // RF - Redstone Flux - /** - * unlocalized name for the power unit. - */ - public final String unlocalizedName; - /** - * please do not edit this value, it is set when AE loads its config files. - */ - public double conversionRatio = 1.0; + /** + * unlocalized name for the power unit. + */ + public final String unlocalizedName; + /** + * please do not edit this value, it is set when AE loads its config files. + */ + public double conversionRatio = 1.0; - PowerUnits( final String un ) - { - this.unlocalizedName = un; - } + PowerUnits(final String un) { + this.unlocalizedName = un; + } - /** - * do power conversion using AE's conversion rates. - * - * Example: PowerUnits.EU.convertTo( PowerUnits.AE, 32 ); - * - * 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 - * - * @return value converted to target units, from this units. - */ - public double convertTo( final PowerUnits target, final double value ) - { - return ( value * this.conversionRatio ) / target.conversionRatio; - } + /** + * do power conversion using AE's conversion rates. + * + * Example: PowerUnits.EU.convertTo( PowerUnits.AE, 32 ); + * + * 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 + * + * @return value converted to target units, from this units. + */ + public double convertTo(final PowerUnits target, final double value) { + return (value * this.conversionRatio) / target.conversionRatio; + } - public ITextComponent textComponent() { - return new TranslationTextComponent(unlocalizedName); - } + public ITextComponent textComponent() { + return new TranslationTextComponent(unlocalizedName); + } } \ 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 0bb5a54da..6fcec573d 100644 --- a/src/api/java/appeng/api/config/RedstoneMode.java +++ b/src/api/java/appeng/api/config/RedstoneMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum RedstoneMode -{ - IGNORE, LOW_SIGNAL, HIGH_SIGNAL, SIGNAL_PULSE +public enum RedstoneMode { + IGNORE, LOW_SIGNAL, HIGH_SIGNAL, SIGNAL_PULSE } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/RelativeDirection.java b/src/api/java/appeng/api/config/RelativeDirection.java index a81d20473..e80bc5eea 100644 --- a/src/api/java/appeng/api/config/RelativeDirection.java +++ b/src/api/java/appeng/api/config/RelativeDirection.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum RelativeDirection -{ - LEFT, RIGHT, UP, DOW +public enum RelativeDirection { + LEFT, RIGHT, UP, DOW } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/SchedulingMode.java b/src/api/java/appeng/api/config/SchedulingMode.java index 395bf1ece..a04279778 100644 --- a/src/api/java/appeng/api/config/SchedulingMode.java +++ b/src/api/java/appeng/api/config/SchedulingMode.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum SchedulingMode -{ - DEFAULT, ROUNDROBIN, RANDOM +public enum SchedulingMode { + DEFAULT, ROUNDROBIN, RANDOM } diff --git a/src/api/java/appeng/api/config/SearchBoxMode.java b/src/api/java/appeng/api/config/SearchBoxMode.java index 05a368ec1..123b24cc8 100644 --- a/src/api/java/appeng/api/config/SearchBoxMode.java +++ b/src/api/java/appeng/api/config/SearchBoxMode.java @@ -23,19 +23,18 @@ package appeng.api.config; +public enum SearchBoxMode { + AUTOSEARCH(false), AUTOSEARCH_KEEP(false), MANUAL_SEARCH(false), MANUAL_SEARCH_KEEP(false), JEI_AUTOSEARCH(true), + JEI_AUTOSEARCH_KEEP(true), JEI_MANUAL_SEARCH(true), JEI_MANUAL_SEARCH_KEEP(true); -public enum SearchBoxMode -{ - AUTOSEARCH(false), AUTOSEARCH_KEEP(false), MANUAL_SEARCH(false), MANUAL_SEARCH_KEEP(false), JEI_AUTOSEARCH(true), JEI_AUTOSEARCH_KEEP(true), JEI_MANUAL_SEARCH(true), JEI_MANUAL_SEARCH_KEEP(true); + private final boolean requiresJei; - private final boolean requiresJei; + SearchBoxMode(boolean requiresJei) { + this.requiresJei = requiresJei; + } - SearchBoxMode(boolean requiresJei) { - this.requiresJei = requiresJei; - } - - public boolean isRequiresJei() { - return requiresJei; - } + public boolean isRequiresJei() { + return requiresJei; + } } diff --git a/src/api/java/appeng/api/config/SecurityPermissions.java b/src/api/java/appeng/api/config/SecurityPermissions.java index 8275a48f7..4e595f1ad 100644 --- a/src/api/java/appeng/api/config/SecurityPermissions.java +++ b/src/api/java/appeng/api/config/SecurityPermissions.java @@ -23,49 +23,48 @@ 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. + * Represent the security systems basic permissions, these are not for + * anti-griefing, they are part of the mod as a gameplay feature. */ -public enum SecurityPermissions -{ - /** - * required to insert items into the network via terminal ( also used for machines based on the owner of the - * network, which is determined by its Security Block. ) - */ - INJECT, +public enum SecurityPermissions { + /** + * required to insert items into the network via terminal ( also used for + * machines based on the owner of the network, which is determined by its + * Security Block. ) + */ + INJECT, - /** - * required to extract items from the network via terminal ( also used for machines based on the owner of the - * network, which is determined by its Security Block. ) - */ - EXTRACT, + /** + * required to extract items from the network via terminal ( also used for + * machines based on the owner of the network, which is determined by its + * Security Block. ) + */ + EXTRACT, - /** - * required to request crafting from the network via terminal. - */ - CRAFT, + /** + * required to request crafting from the network via terminal. + */ + CRAFT, - /** - * required to modify automation, and make modifications to the networks physical layout. - */ - BUILD, + /** + * required to modify automation, and make modifications to the networks + * physical layout. + */ + BUILD, - /** - * required to modify the security blocks settings. - */ - SECURITY; + /** + * required to modify the security blocks settings. + */ + SECURITY; - private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase(); + private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase(); - public String getTranslatedName() - { - return this.translationKey + ".name"; - } + public String getTranslatedName() { + return this.translationKey + ".name"; + } - public String getTranslatedTip() - { - return this.translationKey + ".tip"; - } + public String getTranslatedTip() { + return this.translationKey + ".tip"; + } } diff --git a/src/api/java/appeng/api/config/Settings.java b/src/api/java/appeng/api/config/Settings.java index 69c83625d..bab85a659 100644 --- a/src/api/java/appeng/api/config/Settings.java +++ b/src/api/java/appeng/api/config/Settings.java @@ -23,79 +23,73 @@ package appeng.api.config; - import java.util.EnumSet; import javax.annotation.Nonnull; +public enum Settings { + LEVEL_EMITTER_MODE(EnumSet.allOf(LevelEmitterMode.class)), -public enum Settings -{ - LEVEL_EMITTER_MODE( EnumSet.allOf( LevelEmitterMode.class ) ), + REDSTONE_EMITTER(EnumSet.of(RedstoneMode.HIGH_SIGNAL, RedstoneMode.LOW_SIGNAL)), - REDSTONE_EMITTER( EnumSet.of( RedstoneMode.HIGH_SIGNAL, RedstoneMode.LOW_SIGNAL ) ), + REDSTONE_CONTROLLED(EnumSet.allOf(RedstoneMode.class)), - REDSTONE_CONTROLLED( EnumSet.allOf( RedstoneMode.class ) ), + CONDENSER_OUTPUT(EnumSet.allOf(CondenserOutput.class)), - CONDENSER_OUTPUT( EnumSet.allOf( CondenserOutput.class ) ), + POWER_UNITS(EnumSet.allOf(PowerUnits.class)), - POWER_UNITS( EnumSet.allOf( PowerUnits.class ) ), + ACCESS(EnumSet.of(AccessRestriction.READ_WRITE, AccessRestriction.READ, AccessRestriction.WRITE)), - ACCESS( EnumSet.of( AccessRestriction.READ_WRITE, AccessRestriction.READ, AccessRestriction.WRITE ) ), + SORT_DIRECTION(EnumSet.allOf(SortDir.class)), - SORT_DIRECTION( EnumSet.allOf( SortDir.class ) ), + SORT_BY(EnumSet.allOf(SortOrder.class)), - SORT_BY( EnumSet.allOf( SortOrder.class ) ), + SEARCH_TOOLTIPS(EnumSet.of(YesNo.YES, YesNo.NO)), - SEARCH_TOOLTIPS( EnumSet.of( YesNo.YES, YesNo.NO ) ), + VIEW_MODE(EnumSet.allOf(ViewItems.class)), - VIEW_MODE( EnumSet.allOf( ViewItems.class ) ), + SEARCH_MODE(EnumSet.allOf(SearchBoxMode.class)), - SEARCH_MODE( EnumSet.allOf( SearchBoxMode.class ) ), + IO_DIRECTION(EnumSet.of(RelativeDirection.LEFT, RelativeDirection.RIGHT)), - IO_DIRECTION( EnumSet.of( RelativeDirection.LEFT, RelativeDirection.RIGHT ) ), + BLOCK(EnumSet.of(YesNo.YES, YesNo.NO)), - BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ), + OPERATION_MODE(EnumSet.allOf(OperationMode.class)), - OPERATION_MODE( EnumSet.allOf( OperationMode.class ) ), + FULLNESS_MODE(EnumSet.allOf(FullnessMode.class)), - FULLNESS_MODE( EnumSet.allOf( FullnessMode.class ) ), + CRAFT_ONLY(EnumSet.of(YesNo.YES, YesNo.NO)), - CRAFT_ONLY( EnumSet.of( YesNo.YES, YesNo.NO ) ), + FUZZY_MODE(EnumSet.allOf(FuzzyMode.class)), - FUZZY_MODE( EnumSet.allOf( FuzzyMode.class ) ), + LEVEL_TYPE(EnumSet.allOf(LevelType.class)), - LEVEL_TYPE( EnumSet.allOf( LevelType.class ) ), + TERMINAL_STYLE(EnumSet.of(TerminalStyle.TALL, TerminalStyle.SMALL)), - TERMINAL_STYLE( EnumSet.of( TerminalStyle.TALL, TerminalStyle.SMALL ) ), + COPY_MODE(EnumSet.allOf(CopyMode.class)), - COPY_MODE( EnumSet.allOf( CopyMode.class ) ), + INTERFACE_TERMINAL(EnumSet.of(YesNo.YES, YesNo.NO)), - INTERFACE_TERMINAL( EnumSet.of( YesNo.YES, YesNo.NO ) ), + CRAFT_VIA_REDSTONE(EnumSet.of(YesNo.YES, YesNo.NO)), - CRAFT_VIA_REDSTONE( EnumSet.of( YesNo.YES, YesNo.NO ) ), + STORAGE_FILTER(EnumSet.allOf(StorageFilter.class)), - STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), + PLACE_BLOCK(EnumSet.of(YesNo.YES, YesNo.NO)), - PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ), + SCHEDULING_MODE(EnumSet.allOf(SchedulingMode.class)); - SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) ); + private final EnumSet> values; - private final EnumSet> values; + Settings(@Nonnull final EnumSet> possibleOptions) { + if (possibleOptions.isEmpty()) { + throw new IllegalArgumentException("Tried to instantiate an empty setting."); + } - Settings( @Nonnull final EnumSet> possibleOptions ) - { - if( possibleOptions.isEmpty() ) - { - throw new IllegalArgumentException( "Tried to instantiate an empty setting." ); - } + this.values = possibleOptions; + } - this.values = possibleOptions; - } - - public EnumSet> getPossibleValues() - { - return this.values; - } + public EnumSet> getPossibleValues() { + return this.values; + } } diff --git a/src/api/java/appeng/api/config/SortDir.java b/src/api/java/appeng/api/config/SortDir.java index 654fda0dc..54b41285f 100644 --- a/src/api/java/appeng/api/config/SortDir.java +++ b/src/api/java/appeng/api/config/SortDir.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum SortDir -{ - ASCENDING, DESCENDING +public enum SortDir { + ASCENDING, DESCENDING } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/SortOrder.java b/src/api/java/appeng/api/config/SortOrder.java index 51cde4e64..cb0620cd4 100644 --- a/src/api/java/appeng/api/config/SortOrder.java +++ b/src/api/java/appeng/api/config/SortOrder.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum SortOrder -{ - NAME, AMOUNT, MOD, INVTWEAKS +public enum SortOrder { + NAME, AMOUNT, MOD, INVTWEAKS } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/StorageFilter.java b/src/api/java/appeng/api/config/StorageFilter.java index 64f63f704..83a08d7b7 100644 --- a/src/api/java/appeng/api/config/StorageFilter.java +++ b/src/api/java/appeng/api/config/StorageFilter.java @@ -23,12 +23,10 @@ package appeng.api.config; +public enum StorageFilter { -public enum StorageFilter -{ + NONE, - NONE, - - EXTRACTABLE_ONLY + EXTRACTABLE_ONLY } diff --git a/src/api/java/appeng/api/config/TerminalStyle.java b/src/api/java/appeng/api/config/TerminalStyle.java index d8687e1a3..6197b382d 100644 --- a/src/api/java/appeng/api/config/TerminalStyle.java +++ b/src/api/java/appeng/api/config/TerminalStyle.java @@ -23,14 +23,12 @@ package appeng.api.config; +public enum TerminalStyle { -public enum TerminalStyle -{ + TALL, - TALL, + FULL, - FULL, - - SMALL + SMALL } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/TunnelType.java b/src/api/java/appeng/api/config/TunnelType.java index fb6ff2f73..4cdc7807d 100644 --- a/src/api/java/appeng/api/config/TunnelType.java +++ b/src/api/java/appeng/api/config/TunnelType.java @@ -23,16 +23,14 @@ package appeng.api.config; - -public enum TunnelType -{ - ME, // Network Tunnel - IC2_POWER, // EU Tunnel - FE_POWER, // Forge Energy tunnel - REDSTONE, // Redstone Tunnel - FLUID, // Fluid Tunnel - ITEM, // Item Tunnel - LIGHT, // Light Tunnel - BUNDLED_REDSTONE, // Bundled Redstone Tunnel - COMPUTER_MESSAGE // Computer Message Tunnel +public enum TunnelType { + ME, // Network Tunnel + IC2_POWER, // EU Tunnel + FE_POWER, // Forge Energy tunnel + REDSTONE, // Redstone Tunnel + FLUID, // Fluid Tunnel + ITEM, // Item Tunnel + LIGHT, // Light Tunnel + BUNDLED_REDSTONE, // Bundled Redstone Tunnel + COMPUTER_MESSAGE // Computer Message Tunnel } diff --git a/src/api/java/appeng/api/config/Upgrades.java b/src/api/java/appeng/api/config/Upgrades.java index 228b7b5c8..4b2d5dd28 100644 --- a/src/api/java/appeng/api/config/Upgrades.java +++ b/src/api/java/appeng/api/config/Upgrades.java @@ -23,7 +23,6 @@ package appeng.api.config; - import java.util.HashMap; import java.util.Map; @@ -31,66 +30,55 @@ import net.minecraft.item.ItemStack; import appeng.api.definitions.IItemDefinition; +public enum Upgrades { + /** + * Gold Tier Upgrades. + */ + CAPACITY(0), REDSTONE(0), CRAFTING(0), -public enum Upgrades -{ - /** - * Gold Tier Upgrades. - */ - CAPACITY( 0 ), - REDSTONE( 0 ), - CRAFTING( 0 ), + /** + * Diamond Tier Upgrades. + */ + FUZZY(1), SPEED(1), INVERTER(1); - /** - * Diamond Tier Upgrades. - */ - FUZZY( 1 ), - SPEED( 1 ), - INVERTER( 1 ); + private final int tier; + private final Map supportedMax = new HashMap<>(); - private final int tier; - private final Map supportedMax = new HashMap<>(); + Upgrades(final int tier) { + this.tier = tier; + } - Upgrades( final int tier ) - { - this.tier = tier; - } + /** + * @return list of Items/Blocks that support this upgrade, and how many it + * supports. + */ + public Map getSupported() { + return this.supportedMax; + } - /** - * @return list of Items/Blocks that support this upgrade, and how many it supports. - */ - public Map getSupported() - { - return this.supportedMax; - } + /** + * 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(final IItemDefinition item, final int maxSupported) { + item.maybeStack(1).ifPresent(is -> this.registerItem(is, 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( final IItemDefinition item, final int maxSupported ) - { - item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, 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(final ItemStack stack, final int maxSupported) { + if (stack != null) { + this.supportedMax.put(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( final ItemStack stack, final int maxSupported ) - { - if( stack != null ) - { - this.supportedMax.put( stack, maxSupported ); - } - } - - public int getTier() - { - return this.tier; - } + 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 a87e0aa21..ad4186532 100644 --- a/src/api/java/appeng/api/config/ViewItems.java +++ b/src/api/java/appeng/api/config/ViewItems.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum ViewItems -{ - ALL, STORED, CRAFTABLE +public enum ViewItems { + ALL, STORED, CRAFTABLE } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/YesNo.java b/src/api/java/appeng/api/config/YesNo.java index c6bfcd602..edbeaf296 100644 --- a/src/api/java/appeng/api/config/YesNo.java +++ b/src/api/java/appeng/api/config/YesNo.java @@ -23,8 +23,6 @@ package appeng.api.config; - -public enum YesNo -{ - YES, NO, UNDECIDED +public enum YesNo { + YES, NO, UNDECIDED } diff --git a/src/api/java/appeng/api/definitions/IBlockDefinition.java b/src/api/java/appeng/api/definitions/IBlockDefinition.java index 4e7172918..5d37e4bc6 100644 --- a/src/api/java/appeng/api/definitions/IBlockDefinition.java +++ b/src/api/java/appeng/api/definitions/IBlockDefinition.java @@ -18,42 +18,39 @@ package appeng.api.definitions; +import java.util.Optional; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; -import java.util.Optional; +public interface IBlockDefinition extends IItemDefinition { + /** + * @return the {@link Block} implementation if applicable + */ + default Optional maybeBlock() { + return Optional.of(block()); + } + Block block(); -public interface IBlockDefinition extends IItemDefinition -{ - /** - * @return the {@link Block} implementation if applicable - */ - default Optional maybeBlock() { - return Optional.of(block()); - } + /** + * @return the {@link BlockItem} implementation if applicable + */ + default Optional maybeBlockItem() { + return Optional.of(blockItem()); + } - Block block(); + BlockItem blockItem(); - /** - * @return the {@link BlockItem} implementation if applicable - */ - default Optional maybeBlockItem() { - return Optional.of(blockItem()); - } - - BlockItem blockItem(); - - /** - * Compare Block with world. - * - * @param world world of block - * @param pos location - * - * @return if the block is placed in the world at the specific location. - */ - boolean isSameAs( IBlockReader world, BlockPos pos ); + /** + * Compare Block with world. + * + * @param world world of block + * @param pos location + * + * @return if the block is placed in the world at the specific location. + */ + boolean isSameAs(IBlockReader world, BlockPos pos); } diff --git a/src/api/java/appeng/api/definitions/IBlocks.java b/src/api/java/appeng/api/definitions/IBlocks.java index 66a0b8a7b..48ecc96fe 100644 --- a/src/api/java/appeng/api/definitions/IBlocks.java +++ b/src/api/java/appeng/api/definitions/IBlocks.java @@ -23,169 +23,167 @@ package appeng.api.definitions; - /** * A list of all blocks in AE */ -public interface IBlocks -{ - /* - * world gen - */ - IBlockDefinition quartzOre(); +public interface IBlocks { + /* + * world gen + */ + IBlockDefinition quartzOre(); - IBlockDefinition quartzOreCharged(); + IBlockDefinition quartzOreCharged(); - IBlockDefinition matrixFrame(); + IBlockDefinition matrixFrame(); - /* - * decorative - */ - IBlockDefinition quartzBlock(); + /* + * decorative + */ + IBlockDefinition quartzBlock(); - IBlockDefinition quartzPillar(); + IBlockDefinition quartzPillar(); - IBlockDefinition chiseledQuartzBlock(); + IBlockDefinition chiseledQuartzBlock(); - IBlockDefinition quartzGlass(); + IBlockDefinition quartzGlass(); - IBlockDefinition quartzVibrantGlass(); + IBlockDefinition quartzVibrantGlass(); - IBlockDefinition quartzFixture(); + IBlockDefinition quartzFixture(); - IBlockDefinition fluixBlock(); + IBlockDefinition fluixBlock(); - IBlockDefinition skyStoneBlock(); + IBlockDefinition skyStoneBlock(); - IBlockDefinition smoothSkyStoneBlock(); + IBlockDefinition smoothSkyStoneBlock(); - IBlockDefinition skyStoneBrick(); + IBlockDefinition skyStoneBrick(); - IBlockDefinition skyStoneSmallBrick(); + IBlockDefinition skyStoneSmallBrick(); - IBlockDefinition skyStoneChest(); + IBlockDefinition skyStoneChest(); - IBlockDefinition smoothSkyStoneChest(); + IBlockDefinition smoothSkyStoneChest(); - IBlockDefinition skyCompass(); + IBlockDefinition skyCompass(); - IBlockDefinition skyStoneStairs(); + IBlockDefinition skyStoneStairs(); - IBlockDefinition smoothSkyStoneStairs(); + IBlockDefinition smoothSkyStoneStairs(); - IBlockDefinition skyStoneBrickStairs(); + IBlockDefinition skyStoneBrickStairs(); - IBlockDefinition skyStoneSmallBrickStairs(); + IBlockDefinition skyStoneSmallBrickStairs(); - IBlockDefinition fluixStairs(); + IBlockDefinition fluixStairs(); - IBlockDefinition quartzStairs(); + IBlockDefinition quartzStairs(); - IBlockDefinition chiseledQuartzStairs(); + IBlockDefinition chiseledQuartzStairs(); - IBlockDefinition quartzPillarStairs(); + IBlockDefinition quartzPillarStairs(); - IBlockDefinition skyStoneSlab(); + IBlockDefinition skyStoneSlab(); - IBlockDefinition smoothSkyStoneSlab(); + IBlockDefinition smoothSkyStoneSlab(); - IBlockDefinition skyStoneBrickSlab(); + IBlockDefinition skyStoneBrickSlab(); - IBlockDefinition skyStoneSmallBrickSlab(); + IBlockDefinition skyStoneSmallBrickSlab(); - IBlockDefinition fluixSlab(); + IBlockDefinition fluixSlab(); - IBlockDefinition quartzSlab(); + IBlockDefinition quartzSlab(); - IBlockDefinition chiseledQuartzSlab(); + IBlockDefinition chiseledQuartzSlab(); - IBlockDefinition quartzPillarSlab(); + IBlockDefinition quartzPillarSlab(); - /* - * misc - */ - ITileDefinition grindstone(); + /* + * misc + */ + ITileDefinition grindstone(); - ITileDefinition crank(); + ITileDefinition crank(); - ITileDefinition inscriber(); + ITileDefinition inscriber(); - ITileDefinition wirelessAccessPoint(); + ITileDefinition wirelessAccessPoint(); - ITileDefinition charger(); + ITileDefinition charger(); - IBlockDefinition tinyTNT(); + IBlockDefinition tinyTNT(); - ITileDefinition securityStation(); + ITileDefinition securityStation(); - /* - * quantum Network Bridge - */ - ITileDefinition quantumRing(); + /* + * quantum Network Bridge + */ + ITileDefinition quantumRing(); - ITileDefinition quantumLink(); + ITileDefinition quantumLink(); - /* - * spatial iO - */ - ITileDefinition spatialPylon(); + /* + * spatial iO + */ + ITileDefinition spatialPylon(); - ITileDefinition spatialIOPort(); + ITileDefinition spatialIOPort(); - /* - * Bus / cables - */ - ITileDefinition multiPart(); + /* + * Bus / cables + */ + ITileDefinition multiPart(); - /* - * machines - */ - ITileDefinition controller(); + /* + * machines + */ + ITileDefinition controller(); - ITileDefinition drive(); + ITileDefinition drive(); - ITileDefinition chest(); + ITileDefinition chest(); - ITileDefinition iface(); + ITileDefinition iface(); - ITileDefinition fluidIface(); + ITileDefinition fluidIface(); - ITileDefinition cellWorkbench(); + ITileDefinition cellWorkbench(); - ITileDefinition iOPort(); + ITileDefinition iOPort(); - ITileDefinition condenser(); + ITileDefinition condenser(); - ITileDefinition energyAcceptor(); + ITileDefinition energyAcceptor(); - ITileDefinition vibrationChamber(); + ITileDefinition vibrationChamber(); - ITileDefinition quartzGrowthAccelerator(); + ITileDefinition quartzGrowthAccelerator(); - ITileDefinition energyCell(); + ITileDefinition energyCell(); - ITileDefinition energyCellDense(); + ITileDefinition energyCellDense(); - ITileDefinition energyCellCreative(); + ITileDefinition energyCellCreative(); - // rv1 - ITileDefinition craftingUnit(); + // rv1 + ITileDefinition craftingUnit(); - ITileDefinition craftingAccelerator(); + ITileDefinition craftingAccelerator(); - ITileDefinition craftingStorage1k(); + ITileDefinition craftingStorage1k(); - ITileDefinition craftingStorage4k(); + ITileDefinition craftingStorage4k(); - ITileDefinition craftingStorage16k(); + ITileDefinition craftingStorage16k(); - ITileDefinition craftingStorage64k(); + ITileDefinition craftingStorage64k(); - ITileDefinition craftingMonitor(); + ITileDefinition craftingMonitor(); - ITileDefinition molecularAssembler(); + ITileDefinition molecularAssembler(); - ITileDefinition lightDetector(); + ITileDefinition lightDetector(); - ITileDefinition paint(); + ITileDefinition paint(); } diff --git a/src/api/java/appeng/api/definitions/IComparableDefinition.java b/src/api/java/appeng/api/definitions/IComparableDefinition.java index ad8ff2468..cceb460a9 100644 --- a/src/api/java/appeng/api/definitions/IComparableDefinition.java +++ b/src/api/java/appeng/api/definitions/IComparableDefinition.java @@ -18,10 +18,8 @@ package appeng.api.definitions; - import net.minecraft.item.ItemStack; - /** * Interface to compare a definition with an itemstack or a block * @@ -29,14 +27,13 @@ import net.minecraft.item.ItemStack; * @version rv2 * @since rv2 */ -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 ); +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); } diff --git a/src/api/java/appeng/api/definitions/IDefinitions.java b/src/api/java/appeng/api/definitions/IDefinitions.java index 354f8899f..c07968abe 100644 --- a/src/api/java/appeng/api/definitions/IDefinitions.java +++ b/src/api/java/appeng/api/definitions/IDefinitions.java @@ -23,29 +23,27 @@ package appeng.api.definitions; - /** * All definitions in AE */ -public interface IDefinitions -{ - /** - * @return an accessible list of all of AE's blocks - */ - IBlocks blocks(); +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 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 materials; materials are items + */ + IMaterials materials(); - /** - * @return an accessible list of all of AE's parts, parts are items - */ - IParts parts(); + /** + * @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 index c43916641..c66503599 100644 --- a/src/api/java/appeng/api/definitions/IItemDefinition.java +++ b/src/api/java/appeng/api/definitions/IItemDefinition.java @@ -23,46 +23,44 @@ package appeng.api.definitions; - import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; -import appeng.api.features.AEFeature; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import appeng.api.features.AEFeature; -public interface IItemDefinition extends IComparableDefinition -{ - /** - * @return the unique name of the definition which will be used to register the underlying structure. Will never be - * null - */ - @Nonnull - String identifier(); +public interface IItemDefinition extends IComparableDefinition { + /** + * @return the unique name of the definition which will be used to register the + * underlying structure. Will never be null + */ + @Nonnull + String identifier(); - /** - * @return the {@link Item} Implementation if applicable - */ - default Optional maybeItem() { - return Optional.of(item()); - } + /** + * @return the {@link Item} Implementation if applicable + */ + default Optional maybeItem() { + return Optional.of(item()); + } - Item item(); + Item item(); - /** - * @return an {@link ItemStack} with specified quantity of this item. - */ - default Optional maybeStack( int stackSize ) { - return Optional.of(stack(stackSize)); - } + /** + * @return an {@link ItemStack} with specified quantity of this item. + */ + default Optional maybeStack(int stackSize) { + return Optional.of(stack(stackSize)); + } - ItemStack stack( int stackSize ); + ItemStack stack(int stackSize); - /** - * @return an immutable set of the features of this item - */ - Set features(); + /** + * @return an immutable set of the features of this item + */ + Set features(); } diff --git a/src/api/java/appeng/api/definitions/IItems.java b/src/api/java/appeng/api/definitions/IItems.java index 64f87fa24..3a44de288 100644 --- a/src/api/java/appeng/api/definitions/IItems.java +++ b/src/api/java/appeng/api/definitions/IItems.java @@ -23,101 +23,98 @@ package appeng.api.definitions; - import appeng.api.util.AEColoredItemDefinition; - /** * A list of all items in AE */ -public interface IItems -{ - IItemDefinition certusQuartzAxe(); +public interface IItems { + IItemDefinition certusQuartzAxe(); - IItemDefinition certusQuartzHoe(); + IItemDefinition certusQuartzHoe(); - IItemDefinition certusQuartzShovel(); + IItemDefinition certusQuartzShovel(); - IItemDefinition certusQuartzPick(); + IItemDefinition certusQuartzPick(); - IItemDefinition certusQuartzSword(); + IItemDefinition certusQuartzSword(); - IItemDefinition certusQuartzWrench(); + IItemDefinition certusQuartzWrench(); - IItemDefinition certusQuartzKnife(); + IItemDefinition certusQuartzKnife(); - IItemDefinition netherQuartzAxe(); + IItemDefinition netherQuartzAxe(); - IItemDefinition netherQuartzHoe(); + IItemDefinition netherQuartzHoe(); - IItemDefinition netherQuartzShovel(); + IItemDefinition netherQuartzShovel(); - IItemDefinition netherQuartzPick(); + IItemDefinition netherQuartzPick(); - IItemDefinition netherQuartzSword(); + IItemDefinition netherQuartzSword(); - IItemDefinition netherQuartzWrench(); + IItemDefinition netherQuartzWrench(); - IItemDefinition netherQuartzKnife(); + IItemDefinition netherQuartzKnife(); - IItemDefinition entropyManipulator(); + IItemDefinition entropyManipulator(); - IItemDefinition wirelessTerminal(); + IItemDefinition wirelessTerminal(); - IItemDefinition biometricCard(); + IItemDefinition biometricCard(); - IItemDefinition chargedStaff(); + IItemDefinition chargedStaff(); - IItemDefinition massCannon(); + IItemDefinition massCannon(); - IItemDefinition memoryCard(); + IItemDefinition memoryCard(); - IItemDefinition networkTool(); + IItemDefinition networkTool(); - IItemDefinition portableCell(); + IItemDefinition portableCell(); - IItemDefinition cellCreative(); + IItemDefinition cellCreative(); - IItemDefinition viewCell(); + IItemDefinition viewCell(); - IItemDefinition cell1k(); + IItemDefinition cell1k(); - IItemDefinition cell4k(); + IItemDefinition cell4k(); - IItemDefinition cell16k(); + IItemDefinition cell16k(); - IItemDefinition cell64k(); + IItemDefinition cell64k(); - IItemDefinition fluidCell1k(); + IItemDefinition fluidCell1k(); - IItemDefinition fluidCell4k(); + IItemDefinition fluidCell4k(); - IItemDefinition fluidCell16k(); + IItemDefinition fluidCell16k(); - IItemDefinition fluidCell64k(); + IItemDefinition fluidCell64k(); - IItemDefinition spatialCell2(); + IItemDefinition spatialCell2(); - IItemDefinition spatialCell16(); + IItemDefinition spatialCell16(); - IItemDefinition spatialCell128(); + IItemDefinition spatialCell128(); - IItemDefinition facade(); + IItemDefinition facade(); - IItemDefinition certusCrystalSeed(); + IItemDefinition certusCrystalSeed(); - IItemDefinition fluixCrystalSeed(); + IItemDefinition fluixCrystalSeed(); - IItemDefinition netherQuartzSeed(); + IItemDefinition netherQuartzSeed(); - IItemDefinition dummyFluidItem(); + IItemDefinition dummyFluidItem(); - // rv1 - IItemDefinition encodedPattern(); + // rv1 + IItemDefinition encodedPattern(); - IItemDefinition colorApplicator(); + IItemDefinition colorApplicator(); - AEColoredItemDefinition coloredPaintBall(); + AEColoredItemDefinition coloredPaintBall(); - AEColoredItemDefinition coloredLumenPaintBall(); + AEColoredItemDefinition coloredLumenPaintBall(); } diff --git a/src/api/java/appeng/api/definitions/IMaterials.java b/src/api/java/appeng/api/definitions/IMaterials.java index 5fcab30dc..c2716fe69 100644 --- a/src/api/java/appeng/api/definitions/IMaterials.java +++ b/src/api/java/appeng/api/definitions/IMaterials.java @@ -23,123 +23,121 @@ package appeng.api.definitions; - /** * A list of all materials in AE */ -public interface IMaterials -{ - IItemDefinition cell2SpatialPart(); +public interface IMaterials { + IItemDefinition cell2SpatialPart(); - IItemDefinition cell16SpatialPart(); + IItemDefinition cell16SpatialPart(); - IItemDefinition cell128SpatialPart(); + IItemDefinition cell128SpatialPart(); - IItemDefinition silicon(); + IItemDefinition silicon(); - IItemDefinition skyDust(); + IItemDefinition skyDust(); - IItemDefinition calcProcessorPress(); + IItemDefinition calcProcessorPress(); - IItemDefinition engProcessorPress(); + IItemDefinition engProcessorPress(); - IItemDefinition logicProcessorPress(); + IItemDefinition logicProcessorPress(); - IItemDefinition calcProcessorPrint(); + IItemDefinition calcProcessorPrint(); - IItemDefinition engProcessorPrint(); + IItemDefinition engProcessorPrint(); - IItemDefinition logicProcessorPrint(); + IItemDefinition logicProcessorPrint(); - IItemDefinition siliconPress(); + IItemDefinition siliconPress(); - IItemDefinition siliconPrint(); + IItemDefinition siliconPrint(); - IItemDefinition namePress(); + IItemDefinition namePress(); - IItemDefinition logicProcessor(); + IItemDefinition logicProcessor(); - IItemDefinition calcProcessor(); + IItemDefinition calcProcessor(); - IItemDefinition engProcessor(); + IItemDefinition engProcessor(); - IItemDefinition basicCard(); + IItemDefinition basicCard(); - IItemDefinition advCard(); + IItemDefinition advCard(); - IItemDefinition purifiedCertusQuartzCrystal(); + IItemDefinition purifiedCertusQuartzCrystal(); - IItemDefinition purifiedNetherQuartzCrystal(); + IItemDefinition purifiedNetherQuartzCrystal(); - IItemDefinition purifiedFluixCrystal(); + IItemDefinition purifiedFluixCrystal(); - IItemDefinition cell1kPart(); + IItemDefinition cell1kPart(); - IItemDefinition cell4kPart(); + IItemDefinition cell4kPart(); - IItemDefinition cell16kPart(); + IItemDefinition cell16kPart(); - IItemDefinition cell64kPart(); + IItemDefinition cell64kPart(); - IItemDefinition emptyStorageCell(); + IItemDefinition emptyStorageCell(); - IItemDefinition cardRedstone(); + IItemDefinition cardRedstone(); - IItemDefinition cardSpeed(); + IItemDefinition cardSpeed(); - IItemDefinition cardCapacity(); + IItemDefinition cardCapacity(); - IItemDefinition cardFuzzy(); + IItemDefinition cardFuzzy(); - IItemDefinition cardInverter(); + IItemDefinition cardInverter(); - IItemDefinition cardCrafting(); + IItemDefinition cardCrafting(); - IItemDefinition enderDust(); + IItemDefinition enderDust(); - IItemDefinition flour(); + IItemDefinition flour(); - IItemDefinition goldDust(); + IItemDefinition goldDust(); - IItemDefinition ironDust(); + IItemDefinition ironDust(); - IItemDefinition fluixDust(); + IItemDefinition fluixDust(); - IItemDefinition certusQuartzDust(); + IItemDefinition certusQuartzDust(); - IItemDefinition netherQuartzDust(); + IItemDefinition netherQuartzDust(); - IItemDefinition matterBall(); + IItemDefinition matterBall(); - IItemDefinition certusQuartzCrystal(); + IItemDefinition certusQuartzCrystal(); - IItemDefinition certusQuartzCrystalCharged(); + IItemDefinition certusQuartzCrystalCharged(); - IItemDefinition fluixCrystal(); + IItemDefinition fluixCrystal(); - IItemDefinition fluixPearl(); + IItemDefinition fluixPearl(); - IItemDefinition woodenGear(); + IItemDefinition woodenGear(); - IItemDefinition wirelessReceiver(); + IItemDefinition wirelessReceiver(); - IItemDefinition wirelessBooster(); + IItemDefinition wirelessBooster(); - IItemDefinition annihilationCore(); + IItemDefinition annihilationCore(); - IItemDefinition formationCore(); + IItemDefinition formationCore(); - IItemDefinition singularity(); + IItemDefinition singularity(); - IItemDefinition qESingularity(); + IItemDefinition qESingularity(); - IItemDefinition blankPattern(); + IItemDefinition blankPattern(); - IItemDefinition fluidCell1kPart(); + IItemDefinition fluidCell1kPart(); - IItemDefinition fluidCell4kPart(); + IItemDefinition fluidCell4kPart(); - IItemDefinition fluidCell16kPart(); + IItemDefinition fluidCell16kPart(); - IItemDefinition fluidCell64kPart(); + IItemDefinition fluidCell64kPart(); } diff --git a/src/api/java/appeng/api/definitions/IParts.java b/src/api/java/appeng/api/definitions/IParts.java index 5030f503e..10588c6ac 100644 --- a/src/api/java/appeng/api/definitions/IParts.java +++ b/src/api/java/appeng/api/definitions/IParts.java @@ -23,94 +23,91 @@ package appeng.api.definitions; - import appeng.api.util.AEColoredItemDefinition; - /** * A list of all parts in AE */ -public interface IParts -{ - AEColoredItemDefinition cableSmart(); +public interface IParts { + AEColoredItemDefinition cableSmart(); - AEColoredItemDefinition cableCovered(); + AEColoredItemDefinition cableCovered(); - AEColoredItemDefinition cableGlass(); + AEColoredItemDefinition cableGlass(); - AEColoredItemDefinition cableDenseCovered(); + AEColoredItemDefinition cableDenseCovered(); - AEColoredItemDefinition cableDenseSmart(); + AEColoredItemDefinition cableDenseSmart(); - IItemDefinition quartzFiber(); + IItemDefinition quartzFiber(); - IItemDefinition toggleBus(); + IItemDefinition toggleBus(); - IItemDefinition invertedToggleBus(); + IItemDefinition invertedToggleBus(); - IItemDefinition storageBus(); + IItemDefinition storageBus(); - IItemDefinition importBus(); + IItemDefinition importBus(); - IItemDefinition exportBus(); + IItemDefinition exportBus(); - IItemDefinition iface(); + IItemDefinition iface(); - IItemDefinition fluidIface(); + IItemDefinition fluidIface(); - IItemDefinition levelEmitter(); + IItemDefinition levelEmitter(); - IItemDefinition annihilationPlane(); + IItemDefinition annihilationPlane(); - IItemDefinition identityAnnihilationPlane(); + IItemDefinition identityAnnihilationPlane(); - IItemDefinition formationPlane(); + IItemDefinition formationPlane(); - IItemDefinition p2PTunnelME(); + IItemDefinition p2PTunnelME(); - IItemDefinition p2PTunnelRedstone(); + IItemDefinition p2PTunnelRedstone(); - IItemDefinition p2PTunnelItems(); + IItemDefinition p2PTunnelItems(); - IItemDefinition p2PTunnelFluids(); + IItemDefinition p2PTunnelFluids(); - IItemDefinition p2PTunnelEU(); + IItemDefinition p2PTunnelEU(); - IItemDefinition p2PTunnelFE(); + IItemDefinition p2PTunnelFE(); - IItemDefinition p2PTunnelLight(); + IItemDefinition p2PTunnelLight(); - IItemDefinition cableAnchor(); + IItemDefinition cableAnchor(); - IItemDefinition monitor(); + IItemDefinition monitor(); - IItemDefinition semiDarkMonitor(); + IItemDefinition semiDarkMonitor(); - IItemDefinition darkMonitor(); + IItemDefinition darkMonitor(); - IItemDefinition interfaceTerminal(); + IItemDefinition interfaceTerminal(); - IItemDefinition patternTerminal(); + IItemDefinition patternTerminal(); - IItemDefinition craftingTerminal(); + IItemDefinition craftingTerminal(); - IItemDefinition terminal(); + IItemDefinition terminal(); - IItemDefinition storageMonitor(); + IItemDefinition storageMonitor(); - IItemDefinition conversionMonitor(); + IItemDefinition conversionMonitor(); - IItemDefinition fluidTerminal(); + IItemDefinition fluidTerminal(); - IItemDefinition fluidImportBus(); + IItemDefinition fluidImportBus(); - IItemDefinition fluidExportBus(); + IItemDefinition fluidExportBus(); - IItemDefinition fluidStorageBus(); + IItemDefinition fluidStorageBus(); - IItemDefinition fluidLevelEmitter(); + IItemDefinition fluidLevelEmitter(); - IItemDefinition fluidAnnihilationPlane(); + IItemDefinition fluidAnnihilationPlane(); - IItemDefinition fluidFormationnPlane(); + IItemDefinition fluidFormationnPlane(); } diff --git a/src/api/java/appeng/api/definitions/ITileDefinition.java b/src/api/java/appeng/api/definitions/ITileDefinition.java index b6115520a..9e05c6fc5 100644 --- a/src/api/java/appeng/api/definitions/ITileDefinition.java +++ b/src/api/java/appeng/api/definitions/ITileDefinition.java @@ -18,16 +18,13 @@ package appeng.api.definitions; - import java.util.Optional; import net.minecraft.tileentity.TileEntity; - -public interface ITileDefinition extends IBlockDefinition -{ - /** - * @return the {@link TileEntity} Class if applicable. - */ - Optional> maybeEntity(); +public interface ITileDefinition extends IBlockDefinition { + /** + * @return the {@link TileEntity} Class if applicable. + */ + Optional> maybeEntity(); } diff --git a/src/api/java/appeng/api/events/LocatableEventAnnounce.java b/src/api/java/appeng/api/events/LocatableEventAnnounce.java index 5f9ee2e8a..88199b69e 100644 --- a/src/api/java/appeng/api/events/LocatableEventAnnounce.java +++ b/src/api/java/appeng/api/events/LocatableEventAnnounce.java @@ -23,39 +23,34 @@ package appeng.api.events; - import net.minecraftforge.eventbus.api.Event; import appeng.api.features.ILocatable; - /** * Input Event: * * Used to Notify the Location Registry of objects, and their availability. */ -public class LocatableEventAnnounce extends Event -{ +public class LocatableEventAnnounce extends Event { - public final ILocatable target; - public final LocatableEvent change; + public final ILocatable target; + public final LocatableEvent change; - public LocatableEventAnnounce( final ILocatable o, final LocatableEvent ev ) - { - this.target = o; - this.change = ev; - } + public LocatableEventAnnounce(final ILocatable o, final LocatableEvent ev) { + this.target = o; + this.change = ev; + } - public enum LocatableEvent - { - /** - * Adds the locatable to the registry - */ - REGISTER, + public enum LocatableEvent { + /** + * Adds the locatable to the registry + */ + REGISTER, - /** - * Removes the locatable from the registry - */ - UNREGISTER - } + /** + * Removes the locatable from the registry + */ + UNREGISTER + } } diff --git a/src/api/java/appeng/api/exceptions/AppEngException.java b/src/api/java/appeng/api/exceptions/AppEngException.java index 478cfd77e..0ab4c99ff 100644 --- a/src/api/java/appeng/api/exceptions/AppEngException.java +++ b/src/api/java/appeng/api/exceptions/AppEngException.java @@ -23,14 +23,11 @@ package appeng.api.exceptions; +public class AppEngException extends Exception { -public class AppEngException extends Exception -{ + private static final long serialVersionUID = -9051434206368465494L; - private static final long serialVersionUID = -9051434206368465494L; - - public AppEngException( final String t ) - { - super( t ); - } + public AppEngException(final String t) { + super(t); + } } diff --git a/src/api/java/appeng/api/exceptions/CoreInaccessibleException.java b/src/api/java/appeng/api/exceptions/CoreInaccessibleException.java index aab467db0..3169d8d3c 100644 --- a/src/api/java/appeng/api/exceptions/CoreInaccessibleException.java +++ b/src/api/java/appeng/api/exceptions/CoreInaccessibleException.java @@ -18,13 +18,10 @@ package appeng.api.exceptions; +public class CoreInaccessibleException extends RuntimeException { + private static final long serialVersionUID = -7434641554655517242L; -public class CoreInaccessibleException extends RuntimeException -{ - private static final long serialVersionUID = -7434641554655517242L; - - public CoreInaccessibleException( final String message ) - { - super( message ); - } + public CoreInaccessibleException(final String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/exceptions/ExistingConnectionException.java b/src/api/java/appeng/api/exceptions/ExistingConnectionException.java index f9ee7a711..6115832de 100644 --- a/src/api/java/appeng/api/exceptions/ExistingConnectionException.java +++ b/src/api/java/appeng/api/exceptions/ExistingConnectionException.java @@ -23,34 +23,30 @@ package appeng.api.exceptions; - import appeng.api.networking.IGridNode; - /** - * Exception occurred because of an already existing connection between the two {@link IGridNode}s + * Exception occurred because of an already existing connection between the two + * {@link IGridNode}s * - * Intended to signal an internal exception and not intended to be thrown by - * any 3rd party module. + * Intended to signal an internal exception and not intended to be thrown by any + * 3rd party module. * * @author yueh * @version rv3 * @since rv3 */ -public class ExistingConnectionException extends FailedConnectionException -{ +public class ExistingConnectionException extends FailedConnectionException { - private static final long serialVersionUID = 2975450379720353182L; - private static final String DEFAULT_MESSAGE = "Connection between both nodes already exists."; + private static final long serialVersionUID = 2975450379720353182L; + private static final String DEFAULT_MESSAGE = "Connection between both nodes already exists."; - public ExistingConnectionException() - { - super( DEFAULT_MESSAGE ); - } + public ExistingConnectionException() { + super(DEFAULT_MESSAGE); + } - public ExistingConnectionException( String message ) - { - super( message ); - } + public ExistingConnectionException(String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/exceptions/FailedConnectionException.java b/src/api/java/appeng/api/exceptions/FailedConnectionException.java index 9f6028652..8370c6229 100644 --- a/src/api/java/appeng/api/exceptions/FailedConnectionException.java +++ b/src/api/java/appeng/api/exceptions/FailedConnectionException.java @@ -23,15 +23,13 @@ package appeng.api.exceptions; - import appeng.api.networking.IGridNode; - /** * Exception indicating a failed connection between two {@link IGridNode}s. * - * Intended to signal an internal exception and not intended to be thrown by - * any 3rd party module. + * Intended to signal an internal exception and not intended to be thrown by any + * 3rd party module. * * See any subclass for a more specific reason. * @@ -40,17 +38,14 @@ import appeng.api.networking.IGridNode; * @version rv3 * @since rv0 */ -public class FailedConnectionException extends Exception -{ +public class FailedConnectionException extends Exception { - private static final long serialVersionUID = -2544208090248293753L; + private static final long serialVersionUID = -2544208090248293753L; - public FailedConnectionException() - { - } + public FailedConnectionException() { + } - public FailedConnectionException( String message ) - { - super( message ); - } + public FailedConnectionException(String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/exceptions/MissingDefinitionException.java b/src/api/java/appeng/api/exceptions/MissingDefinitionException.java index ce1f062a3..181e54d20 100644 --- a/src/api/java/appeng/api/exceptions/MissingDefinitionException.java +++ b/src/api/java/appeng/api/exceptions/MissingDefinitionException.java @@ -18,13 +18,10 @@ package appeng.api.exceptions; +public class MissingDefinitionException extends RuntimeException { + private static final long serialVersionUID = -6547396584255825761L; -public class MissingDefinitionException extends RuntimeException -{ - private static final long serialVersionUID = -6547396584255825761L; - - public MissingDefinitionException( final String message ) - { - super( message ); - } + public MissingDefinitionException(final String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/exceptions/MissingIngredientException.java b/src/api/java/appeng/api/exceptions/MissingIngredientException.java index bcad43754..c51e871dd 100644 --- a/src/api/java/appeng/api/exceptions/MissingIngredientException.java +++ b/src/api/java/appeng/api/exceptions/MissingIngredientException.java @@ -23,14 +23,11 @@ package appeng.api.exceptions; +public class MissingIngredientException extends Exception { -public class MissingIngredientException extends Exception -{ + private static final long serialVersionUID = -998858343831371697L; - private static final long serialVersionUID = -998858343831371697L; - - public MissingIngredientException( final String n ) - { - super( n ); - } + public MissingIngredientException(final String n) { + super(n); + } } diff --git a/src/api/java/appeng/api/exceptions/ModNotInstalledException.java b/src/api/java/appeng/api/exceptions/ModNotInstalledException.java index 1e7de1a01..5e8a63882 100644 --- a/src/api/java/appeng/api/exceptions/ModNotInstalledException.java +++ b/src/api/java/appeng/api/exceptions/ModNotInstalledException.java @@ -23,14 +23,11 @@ package appeng.api.exceptions; +public class ModNotInstalledException extends Exception { -public class ModNotInstalledException extends Exception -{ + private static final long serialVersionUID = -9052435206368425494L; - private static final long serialVersionUID = -9052435206368425494L; - - public ModNotInstalledException( final String t ) - { - super( t ); - } + public ModNotInstalledException(final String t) { + super(t); + } } diff --git a/src/api/java/appeng/api/exceptions/NullNodeConnectionException.java b/src/api/java/appeng/api/exceptions/NullNodeConnectionException.java index 1ed276169..b768c459c 100644 --- a/src/api/java/appeng/api/exceptions/NullNodeConnectionException.java +++ b/src/api/java/appeng/api/exceptions/NullNodeConnectionException.java @@ -23,31 +23,27 @@ package appeng.api.exceptions; - /** * Exception due to trying to connect one or more null values. * - * Intended to signal an internal exception and not intended to be thrown by - * any 3rd party module. + * Intended to signal an internal exception and not intended to be thrown by any + * 3rd party module. * * @author yueh * @version rv3 * @since rv3 */ -public class NullNodeConnectionException extends FailedConnectionException -{ +public class NullNodeConnectionException extends FailedConnectionException { - private static final long serialVersionUID = -2143719383495321764L; - private static final String DEFAULT_MESSAGE = "Connection forged between null entities."; + private static final long serialVersionUID = -2143719383495321764L; + private static final String DEFAULT_MESSAGE = "Connection forged between null entities."; - public NullNodeConnectionException() - { - super( DEFAULT_MESSAGE ); - } + public NullNodeConnectionException() { + super(DEFAULT_MESSAGE); + } - public NullNodeConnectionException( String message ) - { - super( message ); - } + public NullNodeConnectionException(String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/exceptions/RecipeException.java b/src/api/java/appeng/api/exceptions/RecipeException.java index 841bcd74c..a6c9b3c35 100644 --- a/src/api/java/appeng/api/exceptions/RecipeException.java +++ b/src/api/java/appeng/api/exceptions/RecipeException.java @@ -23,14 +23,11 @@ package appeng.api.exceptions; +public class RecipeException extends Exception { -public class RecipeException extends Exception -{ + private static final long serialVersionUID = -6602870588617670262L; - private static final long serialVersionUID = -6602870588617670262L; - - public RecipeException( final String n ) - { - super( n ); - } + public RecipeException(final String n) { + super(n); + } } diff --git a/src/api/java/appeng/api/exceptions/RegistrationException.java b/src/api/java/appeng/api/exceptions/RegistrationException.java index 0209f1214..d8deb5b0a 100644 --- a/src/api/java/appeng/api/exceptions/RegistrationException.java +++ b/src/api/java/appeng/api/exceptions/RegistrationException.java @@ -23,14 +23,11 @@ package appeng.api.exceptions; +public class RegistrationException extends Exception { -public class RegistrationException extends Exception -{ + private static final long serialVersionUID = -6602870588617670263L; - private static final long serialVersionUID = -6602870588617670263L; - - public RegistrationException( final String n ) - { - super( n ); - } + public RegistrationException(final String n) { + super(n); + } } diff --git a/src/api/java/appeng/api/exceptions/SecurityConnectionException.java b/src/api/java/appeng/api/exceptions/SecurityConnectionException.java index 680ea7dc1..ec079e24e 100644 --- a/src/api/java/appeng/api/exceptions/SecurityConnectionException.java +++ b/src/api/java/appeng/api/exceptions/SecurityConnectionException.java @@ -23,30 +23,26 @@ package appeng.api.exceptions; - /** * Exception due to trying to connect different security realms. * - * Intended to signal an internal exception and not intended to be thrown by - * any 3rd party module. + * Intended to signal an internal exception and not intended to be thrown by any + * 3rd party module. * * @author yueh * @version rv3 * @since rv3 */ -public class SecurityConnectionException extends FailedConnectionException -{ - private static final long serialVersionUID = 5048714900434215426L; - private static final String DEFAULT_MESSAGE = "Connection failed due to different security realms."; +public class SecurityConnectionException extends FailedConnectionException { + private static final long serialVersionUID = 5048714900434215426L; + private static final String DEFAULT_MESSAGE = "Connection failed due to different security realms."; - public SecurityConnectionException() - { - super( DEFAULT_MESSAGE ); - } + public SecurityConnectionException() { + super(DEFAULT_MESSAGE); + } - public SecurityConnectionException( String message ) - { - super( message ); - } + public SecurityConnectionException(String message) { + super(message); + } } diff --git a/src/api/java/appeng/api/features/AEFeature.java b/src/api/java/appeng/api/features/AEFeature.java index 79dcfbf34..c2b5c5f05 100644 --- a/src/api/java/appeng/api/features/AEFeature.java +++ b/src/api/java/appeng/api/features/AEFeature.java @@ -18,257 +18,223 @@ package appeng.api.features; +public enum AEFeature { + // stuff that has no reason for ever being turned off, or that + // is just flat out required by tons of + // important stuff. + CORE("Core", null) { + @Override + public boolean isVisible() { + return false; + } + }, -public enum AEFeature -{ - // stuff that has no reason for ever being turned off, or that - // is just flat out required by tons of - // important stuff. - CORE( "Core", null ) - { - @Override - public boolean isVisible() - { - return false; - } - }, + CERTUS_QUARTZ_WORLD_GEN("CertusQuartzWorldGen", Constants.CATEGORY_WORLD), + METEORITE_WORLD_GEN("MeteoriteWorldGen", Constants.CATEGORY_WORLD), + DECORATIVE_LIGHTS("DecorativeLights", Constants.CATEGORY_WORLD), + DECORATIVE_BLOCKS("DecorativeBlocks", Constants.CATEGORY_WORLD, + "Blocks that are not used in any essential recipes, also slabs and stairs."), + SKY_STONE_CHESTS("SkyStoneChests", Constants.CATEGORY_WORLD), + SPAWN_PRESSES_IN_METEORITES("SpawnPressesInMeteorites", Constants.CATEGORY_WORLD), + FLOUR("Flour", Constants.CATEGORY_WORLD), CHEST_LOOT("ChestLoot", Constants.CATEGORY_WORLD), + VILLAGER_TRADING("VillagerTrading", Constants.CATEGORY_WORLD), TINY_TNT("TinyTNT", Constants.CATEGORY_WORLD), + CERTUS_ORE("CertusOre", Constants.CATEGORY_WORLD), CHARGED_CERTUS_ORE("ChargedCertusOre", Constants.CATEGORY_WORLD), - CERTUS_QUARTZ_WORLD_GEN( "CertusQuartzWorldGen", Constants.CATEGORY_WORLD ), - METEORITE_WORLD_GEN( "MeteoriteWorldGen", Constants.CATEGORY_WORLD ), - DECORATIVE_LIGHTS( "DecorativeLights", Constants.CATEGORY_WORLD ), - DECORATIVE_BLOCKS( "DecorativeBlocks", Constants.CATEGORY_WORLD, "Blocks that are not used in any essential recipes, also slabs and stairs." ), - SKY_STONE_CHESTS( "SkyStoneChests", Constants.CATEGORY_WORLD ), - SPAWN_PRESSES_IN_METEORITES( "SpawnPressesInMeteorites", Constants.CATEGORY_WORLD ), - FLOUR( "Flour", Constants.CATEGORY_WORLD ), - CHEST_LOOT( "ChestLoot", Constants.CATEGORY_WORLD ), - VILLAGER_TRADING( "VillagerTrading", Constants.CATEGORY_WORLD ), - TINY_TNT( "TinyTNT", Constants.CATEGORY_WORLD ), - CERTUS_ORE( "CertusOre", Constants.CATEGORY_WORLD ), - CHARGED_CERTUS_ORE( "ChargedCertusOre", Constants.CATEGORY_WORLD ), + GRIND_STONE("GrindStone", Constants.CATEGORY_MACHINES), INSCRIBER("Inscriber", Constants.CATEGORY_MACHINES), + CHARGER("Charger", Constants.CATEGORY_MACHINES), + CRYSTAL_GROWTH_ACCELERATOR("CrystalGrowthAccelerator", Constants.CATEGORY_MACHINES), + POWER_GEN("VibrationChamber", Constants.CATEGORY_MACHINES), - GRIND_STONE( "GrindStone", Constants.CATEGORY_MACHINES ), - INSCRIBER( "Inscriber", Constants.CATEGORY_MACHINES ), - CHARGER( "Charger", Constants.CATEGORY_MACHINES ), - CRYSTAL_GROWTH_ACCELERATOR( "CrystalGrowthAccelerator", Constants.CATEGORY_MACHINES ), - POWER_GEN( "VibrationChamber", Constants.CATEGORY_MACHINES ), + POWERED_TOOLS("PoweredTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS), + CERTUS_QUARTZ_TOOLS("CertusQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS), + NETHER_QUARTZ_TOOLS("NetherQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS), - POWERED_TOOLS( "PoweredTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), - CERTUS_QUARTZ_TOOLS( "CertusQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), - NETHER_QUARTZ_TOOLS( "NetherQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ), + QUARTZ_HOE("QuartzHoe", Constants.CATEGORY_TOOLS), QUARTZ_SPADE("QuartzSpade", Constants.CATEGORY_TOOLS), + QUARTZ_SWORD("QuartzSword", Constants.CATEGORY_TOOLS), QUARTZ_PICKAXE("QuartzPickaxe", Constants.CATEGORY_TOOLS), + QUARTZ_AXE("QuartzAxe", Constants.CATEGORY_TOOLS), QUARTZ_KNIFE("QuartzKnife", Constants.CATEGORY_TOOLS), + QUARTZ_WRENCH("QuartzWrench", Constants.CATEGORY_TOOLS), CHARGED_STAFF("ChargedStaff", Constants.CATEGORY_TOOLS), + ENTROPY_MANIPULATOR("EntropyManipulator", Constants.CATEGORY_TOOLS), + MATTER_CANNON("MatterCannon", Constants.CATEGORY_TOOLS), + WIRELESS_ACCESS_TERMINAL("WirelessAccessTerminal", Constants.CATEGORY_TOOLS), + COLOR_APPLICATOR("ColorApplicator", Constants.CATEGORY_TOOLS), + METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS), - QUARTZ_HOE( "QuartzHoe", Constants.CATEGORY_TOOLS ), - QUARTZ_SPADE( "QuartzSpade", Constants.CATEGORY_TOOLS ), - QUARTZ_SWORD( "QuartzSword", Constants.CATEGORY_TOOLS ), - QUARTZ_PICKAXE( "QuartzPickaxe", Constants.CATEGORY_TOOLS ), - QUARTZ_AXE( "QuartzAxe", Constants.CATEGORY_TOOLS ), - QUARTZ_KNIFE( "QuartzKnife", Constants.CATEGORY_TOOLS ), - QUARTZ_WRENCH( "QuartzWrench", Constants.CATEGORY_TOOLS ), - CHARGED_STAFF( "ChargedStaff", Constants.CATEGORY_TOOLS ), - ENTROPY_MANIPULATOR( "EntropyManipulator", Constants.CATEGORY_TOOLS ), - MATTER_CANNON( "MatterCannon", Constants.CATEGORY_TOOLS ), - WIRELESS_ACCESS_TERMINAL( "WirelessAccessTerminal", Constants.CATEGORY_TOOLS ), - COLOR_APPLICATOR( "ColorApplicator", Constants.CATEGORY_TOOLS ), - METEORITE_COMPASS( "MeteoriteCompass", Constants.CATEGORY_TOOLS ), + SECURITY("Security", Constants.CATEGORY_NETWORK_FEATURES), + SPATIAL_IO("SpatialIO", Constants.CATEGORY_NETWORK_FEATURES), + QUANTUM_NETWORK_BRIDGE("QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES), + CHANNELS("Channels", Constants.CATEGORY_NETWORK_FEATURES), - SECURITY( "Security", Constants.CATEGORY_NETWORK_FEATURES ), - SPATIAL_IO( "SpatialIO", Constants.CATEGORY_NETWORK_FEATURES ), - QUANTUM_NETWORK_BRIDGE( "QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES ), - CHANNELS( "Channels", Constants.CATEGORY_NETWORK_FEATURES ), + INTERFACE("Interface", Constants.CATEGORY_NETWORK_BUSES), + FLUID_INTERFACE("FluidInterface", Constants.CATEGORY_NETWORK_BUSES), + LEVEL_EMITTER("LevelEmitter", Constants.CATEGORY_NETWORK_BUSES), + FLUID_LEVEL_EMITTER("FluidLevelEmitter", Constants.CATEGORY_NETWORK_BUSES), + FLUID_TERMINAL("FluidTerminal", Constants.CATEGORY_NETWORK_BUSES), + CRAFTING_TERMINAL("CraftingTerminal", Constants.CATEGORY_NETWORK_BUSES), + TERMINAL("Terminal", Constants.CATEGORY_NETWORK_BUSES), + STORAGE_MONITOR("StorageMonitor", Constants.CATEGORY_NETWORK_BUSES), + P2P_TUNNEL("P2PTunnel", Constants.CATEGORY_NETWORK_BUSES), + FORMATION_PLANE("FormationPlane", Constants.CATEGORY_NETWORK_BUSES), + FLUID_FORMATION_PLANE("FluidFormationPlane", Constants.CATEGORY_NETWORK_BUSES), + ANNIHILATION_PLANE("AnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES), + IDENTITY_ANNIHILATION_PLANE("IdentityAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES), + FLUID_ANNIHILATION_PLANE("FluidAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES), + IMPORT_BUS("ImportBus", Constants.CATEGORY_NETWORK_BUSES), + FLUID_IMPORT_BUS("FluidImportBus", Constants.CATEGORY_NETWORK_BUSES), + EXPORT_BUS("ExportBus", Constants.CATEGORY_NETWORK_BUSES), + FLUID_EXPORT_BUS("FluidExportBus", Constants.CATEGORY_NETWORK_BUSES), + STORAGE_BUS("StorageBus", Constants.CATEGORY_NETWORK_BUSES), + FLUID_STORAGE_BUS("FluidStorageBus", Constants.CATEGORY_NETWORK_BUSES), + PART_CONVERSION_MONITOR("PartConversionMonitor", Constants.CATEGORY_NETWORK_BUSES), + TOGGLE_BUS("ToggleBus", Constants.CATEGORY_NETWORK_BUSES), PANELS("Panels", Constants.CATEGORY_NETWORK_BUSES), + QUARTZ_FIBER("QuartzFiber", Constants.CATEGORY_NETWORK_BUSES), + CABLE_ANCHOR("CableAnchor", Constants.CATEGORY_NETWORK_BUSES), - INTERFACE( "Interface", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_INTERFACE( "FluidInterface", Constants.CATEGORY_NETWORK_BUSES ), - LEVEL_EMITTER( "LevelEmitter", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_LEVEL_EMITTER( "FluidLevelEmitter", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_TERMINAL( "FluidTerminal", Constants.CATEGORY_NETWORK_BUSES ), - CRAFTING_TERMINAL( "CraftingTerminal", Constants.CATEGORY_NETWORK_BUSES ), - TERMINAL( "Terminal", Constants.CATEGORY_NETWORK_BUSES ), - STORAGE_MONITOR( "StorageMonitor", Constants.CATEGORY_NETWORK_BUSES ), - P2P_TUNNEL( "P2PTunnel", Constants.CATEGORY_NETWORK_BUSES ), - FORMATION_PLANE( "FormationPlane", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_FORMATION_PLANE( "FluidFormationPlane", Constants.CATEGORY_NETWORK_BUSES ), - ANNIHILATION_PLANE( "AnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ), - IDENTITY_ANNIHILATION_PLANE( "IdentityAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_ANNIHILATION_PLANE( "FluidAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ), - IMPORT_BUS( "ImportBus", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_IMPORT_BUS( "FluidImportBus", Constants.CATEGORY_NETWORK_BUSES ), - EXPORT_BUS( "ExportBus", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_EXPORT_BUS( "FluidExportBus", Constants.CATEGORY_NETWORK_BUSES ), - STORAGE_BUS( "StorageBus", Constants.CATEGORY_NETWORK_BUSES ), - FLUID_STORAGE_BUS( "FluidStorageBus", Constants.CATEGORY_NETWORK_BUSES ), - PART_CONVERSION_MONITOR( "PartConversionMonitor", Constants.CATEGORY_NETWORK_BUSES ), - TOGGLE_BUS( "ToggleBus", Constants.CATEGORY_NETWORK_BUSES ), - PANELS( "Panels", Constants.CATEGORY_NETWORK_BUSES ), - QUARTZ_FIBER( "QuartzFiber", Constants.CATEGORY_NETWORK_BUSES ), - CABLE_ANCHOR( "CableAnchor", Constants.CATEGORY_NETWORK_BUSES ), + PORTABLE_CELL("PortableCell", Constants.CATEGORY_PORTABLE_CELL), - PORTABLE_CELL( "PortableCell", Constants.CATEGORY_PORTABLE_CELL ), + STORAGE_CELLS("StorageCells", Constants.CATEGORY_STORAGE), ME_CHEST("MEChest", Constants.CATEGORY_STORAGE), + ME_DRIVE("MEDrive", Constants.CATEGORY_STORAGE), IO_PORT("IOPort", Constants.CATEGORY_STORAGE), + CONDENSER("Condenser", Constants.CATEGORY_STORAGE), - STORAGE_CELLS( "StorageCells", Constants.CATEGORY_STORAGE ), - ME_CHEST( "MEChest", Constants.CATEGORY_STORAGE ), - ME_DRIVE( "MEDrive", Constants.CATEGORY_STORAGE ), - IO_PORT( "IOPort", Constants.CATEGORY_STORAGE ), - CONDENSER( "Condenser", Constants.CATEGORY_STORAGE ), + NETWORK_TOOL("NetworkTool", Constants.CATEGORY_NETWORK_TOOL), + MEMORY_CARD("MemoryCard", Constants.CATEGORY_NETWORK_TOOL), - NETWORK_TOOL( "NetworkTool", Constants.CATEGORY_NETWORK_TOOL ), - MEMORY_CARD( "MemoryCard", Constants.CATEGORY_NETWORK_TOOL ), + GLASS_CABLES("GlassCables", Constants.CATEGORY_CABLES), COVERED_CABLES("CoveredCables", Constants.CATEGORY_CABLES), + SMART_CABLES("SmartCables", Constants.CATEGORY_CABLES), DENSE_CABLES("DenseCables", Constants.CATEGORY_CABLES), - GLASS_CABLES( "GlassCables", Constants.CATEGORY_CABLES ), - COVERED_CABLES( "CoveredCables", Constants.CATEGORY_CABLES ), - SMART_CABLES( "SmartCables", Constants.CATEGORY_CABLES ), - DENSE_CABLES( "DenseCables", Constants.CATEGORY_CABLES ), + ENERGY_CELLS("EnergyCells", Constants.CATEGORY_ENERGY), + ENERGY_ACCEPTOR("EnergyAcceptor", Constants.CATEGORY_ENERGY), + DENSE_ENERGY_CELLS("DenseEnergyCells", Constants.CATEGORY_ENERGY), - ENERGY_CELLS( "EnergyCells", Constants.CATEGORY_ENERGY ), - ENERGY_ACCEPTOR( "EnergyAcceptor", Constants.CATEGORY_ENERGY ), - DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_ENERGY ), + P2P_TUNNEL_ME("P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_ITEMS("P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_REDSTONE("P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_EU("P2PTunnelEU", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_FE("P2PTunnelFE", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_FLUIDS("P2PTunnelFluids", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_LIGHT("P2PTunnelLight", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_OPEN_COMPUTERS("P2PTunnelOpenComputers", Constants.CATEGORY_P2P_TUNNELS), + P2P_TUNNEL_PRESSURE("P2PTunnelPressure", Constants.CATEGORY_P2P_TUNNELS), - P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_REDSTONE( "P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_EU( "P2PTunnelEU", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_FE( "P2PTunnelFE", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_FLUIDS( "P2PTunnelFluids", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_LIGHT( "P2PTunnelLight", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_OPEN_COMPUTERS( "P2PTunnelOpenComputers", Constants.CATEGORY_P2P_TUNNELS ), - P2P_TUNNEL_PRESSURE( "P2PTunnelPressure", Constants.CATEGORY_P2P_TUNNELS ), + MASS_CANNON_BLOCK_DAMAGE("MassCannonBlockDamage", Constants.CATEGORY_BLOCK_FEATURES), + TINY_TNT_BLOCK_DAMAGE("TinyTNTBlockDamage", Constants.CATEGORY_BLOCK_FEATURES), - MASS_CANNON_BLOCK_DAMAGE( "MassCannonBlockDamage", Constants.CATEGORY_BLOCK_FEATURES ), - TINY_TNT_BLOCK_DAMAGE( "TinyTNTBlockDamage", Constants.CATEGORY_BLOCK_FEATURES ), + FACADES("Facades", Constants.CATEGORY_FACADES), - FACADES( "Facades", Constants.CATEGORY_FACADES ), + UNSUPPORTED_DEVELOPER_TOOLS("UnsupportedDeveloperTools", Constants.CATEGORY_MISC, false), + CREATIVE("Creative", Constants.CATEGORY_MISC), GRINDER_LOGGING("GrinderLogging", Constants.CATEGORY_MISC, false), + LOGGING("Logging", Constants.CATEGORY_MISC), + INTEGRATION_LOGGING("IntegrationLogging", Constants.CATEGORY_MISC, false), + WEBSITE_RECIPES("WebsiteRecipes", Constants.CATEGORY_MISC, false), + LOG_SECURITY_AUDITS("LogSecurityAudits", Constants.CATEGORY_MISC, false), + ACHIEVEMENTS("Achievements", Constants.CATEGORY_MISC), + UPDATE_LOGGING("UpdateLogging", Constants.CATEGORY_MISC, false), + PACKET_LOGGING("PacketLogging", Constants.CATEGORY_MISC, false), + CRAFTING_LOG("CraftingLog", Constants.CATEGORY_MISC, false), + LIGHT_DETECTOR("LightDetector", Constants.CATEGORY_MISC), + DEBUG_LOGGING("DebugLogging", Constants.CATEGORY_MISC, false), - UNSUPPORTED_DEVELOPER_TOOLS( "UnsupportedDeveloperTools", Constants.CATEGORY_MISC, false ), - CREATIVE( "Creative", Constants.CATEGORY_MISC ), - GRINDER_LOGGING( "GrinderLogging", Constants.CATEGORY_MISC, false ), - LOGGING( "Logging", Constants.CATEGORY_MISC ), - INTEGRATION_LOGGING( "IntegrationLogging", Constants.CATEGORY_MISC, false ), - WEBSITE_RECIPES( "WebsiteRecipes", Constants.CATEGORY_MISC, false ), - LOG_SECURITY_AUDITS( "LogSecurityAudits", Constants.CATEGORY_MISC, false ), - ACHIEVEMENTS( "Achievements", Constants.CATEGORY_MISC ), - UPDATE_LOGGING( "UpdateLogging", Constants.CATEGORY_MISC, false ), - PACKET_LOGGING( "PacketLogging", Constants.CATEGORY_MISC, false ), - CRAFTING_LOG( "CraftingLog", Constants.CATEGORY_MISC, false ), - LIGHT_DETECTOR( "LightDetector", Constants.CATEGORY_MISC ), - DEBUG_LOGGING( "DebugLogging", Constants.CATEGORY_MISC, false ), + ENABLE_FACADE_CRAFTING("EnableFacadeCrafting", Constants.CATEGORY_CRAFTING), + IN_WORLD_SINGULARITY("InWorldSingularity", Constants.CATEGORY_CRAFTING), + IN_WORLD_FLUIX("InWorldFluix", Constants.CATEGORY_CRAFTING), + IN_WORLD_PURIFICATION("InWorldPurification", Constants.CATEGORY_CRAFTING), + INTERFACE_TERMINAL("InterfaceTerminal", Constants.CATEGORY_CRAFTING), + ENABLE_DISASSEMBLY_CRAFTING("EnableDisassemblyCrafting", Constants.CATEGORY_CRAFTING), - ENABLE_FACADE_CRAFTING( "EnableFacadeCrafting", Constants.CATEGORY_CRAFTING ), - IN_WORLD_SINGULARITY( "InWorldSingularity", Constants.CATEGORY_CRAFTING ), - IN_WORLD_FLUIX( "InWorldFluix", Constants.CATEGORY_CRAFTING ), - IN_WORLD_PURIFICATION( "InWorldPurification", Constants.CATEGORY_CRAFTING ), - INTERFACE_TERMINAL( "InterfaceTerminal", Constants.CATEGORY_CRAFTING ), - ENABLE_DISASSEMBLY_CRAFTING( "EnableDisassemblyCrafting", Constants.CATEGORY_CRAFTING ), + ALPHA_PASS("AlphaPass", Constants.CATEGORY_RENDERING), PAINT_BALLS("PaintBalls", Constants.CATEGORY_TOOLS), - ALPHA_PASS( "AlphaPass", Constants.CATEGORY_RENDERING ), - PAINT_BALLS( "PaintBalls", Constants.CATEGORY_TOOLS ), + MOLECULAR_ASSEMBLER("MolecularAssembler", Constants.CATEGORY_CRAFTING_FEATURES), + PATTERNS("Patterns", Constants.CATEGORY_CRAFTING_FEATURES), + CRAFTING_CPU("CraftingCPU", Constants.CATEGORY_CRAFTING_FEATURES), - MOLECULAR_ASSEMBLER( "MolecularAssembler", Constants.CATEGORY_CRAFTING_FEATURES ), - PATTERNS( "Patterns", Constants.CATEGORY_CRAFTING_FEATURES ), - CRAFTING_CPU( "CraftingCPU", Constants.CATEGORY_CRAFTING_FEATURES ), + BASIC_CARDS("BasicCards", Constants.CATEGORY_UPGRADES), + ADVANCED_CARDS("AdvancedCards", Constants.CATEGORY_UPGRADES), VIEW_CELL("ViewCell", Constants.CATEGORY_UPGRADES), - BASIC_CARDS( "BasicCards", Constants.CATEGORY_UPGRADES ), - ADVANCED_CARDS( "AdvancedCards", Constants.CATEGORY_UPGRADES ), - VIEW_CELL( "ViewCell", Constants.CATEGORY_UPGRADES ), + CRYSTAL_SEEDS("CrystalSeeds", Constants.CATEGORY_MATERIALS), + PURE_CRYSTALS("PureCrystals", Constants.CATEGORY_MATERIALS), CERTUS("Certus", Constants.CATEGORY_MATERIALS), + FLUIX("Fluix", Constants.CATEGORY_MATERIALS), SILICON("Silicon", Constants.CATEGORY_MATERIALS), + DUSTS("Dusts", Constants.CATEGORY_MATERIALS), NUGGETS("Nuggets", Constants.CATEGORY_MATERIALS), + QUARTZ_GLASS("QuartzGlass", Constants.CATEGORY_MATERIALS), SKY_STONE("SkyStone", Constants.CATEGORY_MATERIALS), - CRYSTAL_SEEDS( "CrystalSeeds", Constants.CATEGORY_MATERIALS ), - PURE_CRYSTALS( "PureCrystals", Constants.CATEGORY_MATERIALS ), - CERTUS( "Certus", Constants.CATEGORY_MATERIALS ), - FLUIX( "Fluix", Constants.CATEGORY_MATERIALS ), - SILICON( "Silicon", Constants.CATEGORY_MATERIALS ), - DUSTS( "Dusts", Constants.CATEGORY_MATERIALS ), - NUGGETS( "Nuggets", Constants.CATEGORY_MATERIALS ), - QUARTZ_GLASS( "QuartzGlass", Constants.CATEGORY_MATERIALS ), - SKY_STONE( "SkyStone", Constants.CATEGORY_MATERIALS ), + PROCESSORS("Processors", Constants.CATEGORY_COMPONENTS), + PRINTED_CIRCUITS("PrintedCircuits", Constants.CATEGORY_COMPONENTS), + PRESSES("Presses", Constants.CATEGORY_COMPONENTS), MATTER_BALL("MatterBall", Constants.CATEGORY_COMPONENTS), + CORES("Cores", Constants.CATEGORY_COMPONENTS), - PROCESSORS( "Processors", Constants.CATEGORY_COMPONENTS ), - PRINTED_CIRCUITS( "PrintedCircuits", Constants.CATEGORY_COMPONENTS ), - PRESSES( "Presses", Constants.CATEGORY_COMPONENTS ), - MATTER_BALL( "MatterBall", Constants.CATEGORY_COMPONENTS ), - CORES( "Cores", Constants.CATEGORY_COMPONENTS ), + CHUNK_LOGGER_TRACE("ChunkLoggerTrace", Constants.CATEGORY_COMMANDS, false); - CHUNK_LOGGER_TRACE( "ChunkLoggerTrace", Constants.CATEGORY_COMMANDS, false ); + private final String key; + private final String category; + private final boolean enabled; + private final String comment; - private final String key; - private final String category; - private final boolean enabled; - private final String comment; + AEFeature(final String key, final String cat) { + this(key, cat, true); + } - AEFeature( final String key, final String cat ) - { - this( key, cat, true ); - } + AEFeature(final String key, final String cat, final String comment) { + this(key, cat, true, comment); + } - AEFeature( final String key, final String cat, final String comment ) - { - this( key, cat, true, comment ); - } + AEFeature(final String key, final String cat, final boolean enabled) { + this(key, cat, enabled, null); + } - AEFeature( final String key, final String cat, final boolean enabled ) - { - this( key, cat, enabled, null ); - } + AEFeature(final String key, final String cat, final boolean enabled, final String comment) { + this.key = key; + this.category = cat; + this.enabled = enabled; + this.comment = comment; + } - AEFeature( final String key, final String cat, final boolean enabled, final String comment ) - { - this.key = key; - this.category = cat; - this.enabled = enabled; - this.comment = comment; - } + /** + * override to set visibility + * + * @return default true + */ + public boolean isVisible() { + return true; + } - /** - * override to set visibility - * - * @return default true - */ - public boolean isVisible() - { - return true; - } + public String key() { + return this.key; + } - public String key() - { - return this.key; - } + public String category() { + return this.category; + } - public String category() - { - return this.category; - } + public boolean isEnabled() { + return this.enabled; + } - public boolean isEnabled() - { - return this.enabled; - } + public String comment() { + return this.comment; + } - public String comment() - { - return this.comment; - } + private enum Constants { + ; - private enum Constants - { - ; - - private static final String CATEGORY_MISC = "Misc"; - private static final String CATEGORY_CRAFTING = "Crafting"; - private static final String CATEGORY_WORLD = "World"; - private static final String CATEGORY_MACHINES = "Machines"; - private static final String CATEGORY_TOOLS = "Tools"; - private static final String CATEGORY_TOOLS_CLASSIFICATIONS = "ToolsClassifications"; - private static final String CATEGORY_NETWORK_BUSES = "NetworkBuses"; - private static final String CATEGORY_P2P_TUNNELS = "P2PTunnels"; - private static final String CATEGORY_BLOCK_FEATURES = "BlockFeatures"; - private static final String CATEGORY_CRAFTING_FEATURES = "CraftingFeatures"; - private static final String CATEGORY_STORAGE = "Storage"; - private static final String CATEGORY_CABLES = "Cables"; - private static final String CATEGORY_NETWORK_FEATURES = "NetworkFeatures"; - private static final String CATEGORY_COMMANDS = "Commands"; - private static final String CATEGORY_RENDERING = "Rendering"; - private static final String CATEGORY_FACADES = "Facades"; - private static final String CATEGORY_NETWORK_TOOL = "NetworkTool"; - private static final String CATEGORY_PORTABLE_CELL = "PortableCell"; - private static final String CATEGORY_ENERGY = "Energy"; - private static final String CATEGORY_UPGRADES = "Upgrades"; - private static final String CATEGORY_MATERIALS = "Materials"; - private static final String CATEGORY_COMPONENTS = "CraftingComponents"; - } + private static final String CATEGORY_MISC = "Misc"; + private static final String CATEGORY_CRAFTING = "Crafting"; + private static final String CATEGORY_WORLD = "World"; + private static final String CATEGORY_MACHINES = "Machines"; + private static final String CATEGORY_TOOLS = "Tools"; + private static final String CATEGORY_TOOLS_CLASSIFICATIONS = "ToolsClassifications"; + private static final String CATEGORY_NETWORK_BUSES = "NetworkBuses"; + private static final String CATEGORY_P2P_TUNNELS = "P2PTunnels"; + private static final String CATEGORY_BLOCK_FEATURES = "BlockFeatures"; + private static final String CATEGORY_CRAFTING_FEATURES = "CraftingFeatures"; + private static final String CATEGORY_STORAGE = "Storage"; + private static final String CATEGORY_CABLES = "Cables"; + private static final String CATEGORY_NETWORK_FEATURES = "NetworkFeatures"; + private static final String CATEGORY_COMMANDS = "Commands"; + private static final String CATEGORY_RENDERING = "Rendering"; + private static final String CATEGORY_FACADES = "Facades"; + private static final String CATEGORY_NETWORK_TOOL = "NetworkTool"; + private static final String CATEGORY_PORTABLE_CELL = "PortableCell"; + private static final String CATEGORY_ENERGY = "Energy"; + private static final String CATEGORY_UPGRADES = "Upgrades"; + private static final String CATEGORY_MATERIALS = "Materials"; + private static final String CATEGORY_COMPONENTS = "CraftingComponents"; + } } diff --git a/src/api/java/appeng/api/features/IChargerRegistry.java b/src/api/java/appeng/api/features/IChargerRegistry.java index b49c3424f..cfb0c586d 100644 --- a/src/api/java/appeng/api/features/IChargerRegistry.java +++ b/src/api/java/appeng/api/features/IChargerRegistry.java @@ -23,7 +23,6 @@ package appeng.api.features; - import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -31,54 +30,57 @@ import net.minecraft.item.Item; import appeng.api.implementations.items.IAEItemPowerStorage; - /** - * A registry to allow mapping {@link Item}s to a specific charge rate when being placed inside a charger. + * A registry to allow mapping {@link Item}s to a specific charge rate when + * being placed inside a charger. * - * The registry is used in favor of an additional method for {@link IAEItemPowerStorage} with a fixed value per item. - * This allows more flexibility for other charger like machines to choose their own values when needed. + * The registry is used in favor of an additional method for + * {@link IAEItemPowerStorage} with a fixed value per item. This allows more + * flexibility for other charger like machines to choose their own values when + * needed. * - * There is no guarantee that this is charged per tick, it only represents the value per operation. - * By default this is one charging operation every 10 ticks in case of an AE2 charger. + * There is no guarantee that this is charged per tick, it only represents the + * value per operation. By default this is one charging operation every 10 ticks + * in case of an AE2 charger. * * @author yueh * @version rv5 * @since rv5 */ -public interface IChargerRegistry -{ +public interface IChargerRegistry { - /** - * Fetch a charge rate for a specific item. - * - * The specific item does not need to have a mapping registered at all. - * In this case it will use a default value of 160 AE. - * - * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. - * @return custom rate or default of 160 - */ - @Nonnegative - double getChargeRate( @Nonnull Item item ); + /** + * Fetch a charge rate for a specific item. + * + * The specific item does not need to have a mapping registered at all. In this + * case it will use a default value of 160 AE. + * + * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. + * @return custom rate or default of 160 + */ + @Nonnegative + double getChargeRate(@Nonnull Item item); - /** - * Register a custom charge rate for a specific item. - * - * Capped at 16000 to avoid extracting too much energy from a network for each operation. - * This is done silently without any feedback or exception. - * Further the cap is not fixed, it can change at any time in the future should power issues arise. - * - * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. - * @param chargeRate the custom rate, must be > 0, capped to 16000d - */ - void addChargeRate( @Nonnull Item item, @Nonnegative double chargeRate ); + /** + * Register a custom charge rate for a specific item. + * + * Capped at 16000 to avoid extracting too much energy from a network for each + * operation. This is done silently without any feedback or exception. Further + * the cap is not fixed, it can change at any time in the future should power + * issues arise. + * + * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. + * @param chargeRate the custom rate, must be > 0, capped to 16000d + */ + void addChargeRate(@Nonnull Item item, @Nonnegative double chargeRate); - /** - * Remove the custom rate for a specific item. - * - * It will revert to the default value afterwards. - * - * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. - */ - void removeChargeRate( @Nonnull Item item ); + /** + * Remove the custom rate for a specific item. + * + * It will revert to the default value afterwards. + * + * @param item A {@link Item} implementing {@link IAEItemPowerStorage}. + */ + void removeChargeRate(@Nonnull Item item); } diff --git a/src/api/java/appeng/api/features/IItemComparison.java b/src/api/java/appeng/api/features/IItemComparison.java index b7d2b982b..ce2ef184d 100644 --- a/src/api/java/appeng/api/features/IItemComparison.java +++ b/src/api/java/appeng/api/features/IItemComparison.java @@ -23,10 +23,8 @@ package appeng.api.features; +public interface IItemComparison { + boolean sameAsPrecise(IItemComparison comp); -public interface IItemComparison -{ - boolean sameAsPrecise( IItemComparison comp ); - - boolean sameAsFuzzy( 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 c432c0baf..f7ab3b0de 100644 --- a/src/api/java/appeng/api/features/IItemComparisonProvider.java +++ b/src/api/java/appeng/api/features/IItemComparisonProvider.java @@ -23,34 +23,32 @@ 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 * IItemComparison class. */ -public interface IItemComparisonProvider -{ +public interface IItemComparisonProvider { - /** - * should return a new IItemComparison, or return null if it doesn't handle - * the supplied item. - * - * @param is item - * - * @return IItemComparison, or null - */ - IItemComparison getComparison( ItemStack is ); + /** + * should return a new IItemComparison, or return null if it doesn't handle the + * supplied item. + * + * @param is item + * + * @return IItemComparison, or null + */ + 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 ); + /** + * 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 c64a937fc..4eed71a07 100644 --- a/src/api/java/appeng/api/features/ILocatable.java +++ b/src/api/java/appeng/api/features/ILocatable.java @@ -23,19 +23,17 @@ 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. + * A registration record for the {@link ILocatableRegistry} use the + * {@link LocatableEventAnnounce} event on the Forge Event bus to update the + * registry. */ -public interface ILocatable -{ +public interface ILocatable { - /** - * @return the serial for a locatable object - */ - long getLocatableSerial(); + /** + * @return the serial for a locatable object + */ + long getLocatableSerial(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/ILocatableRegistry.java b/src/api/java/appeng/api/features/ILocatableRegistry.java index d73305c2a..f87f891d4 100644 --- a/src/api/java/appeng/api/features/ILocatableRegistry.java +++ b/src/api/java/appeng/api/features/ILocatableRegistry.java @@ -23,19 +23,17 @@ package appeng.api.features; - /** * A Registry for locatable items, works based on serial numbers. */ -public interface ILocatableRegistry -{ +public interface ILocatableRegistry { - /** - * Gets the {@link ILocatable} with the registered serial, if available - * - * @param serial serial - * - * @return requestedObject, or null, if the object does not exist anymore - */ - ILocatable getLocatableBy( long serial ); + /** + * Gets the {@link ILocatable} with the registered serial, if available + * + * @param serial serial + * + * @return requestedObject, or null, if the object does not exist anymore + */ + ILocatable getLocatableBy(long serial); } \ 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 586470afa..b25b5c69c 100644 --- a/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java +++ b/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java @@ -23,27 +23,25 @@ package appeng.api.features; - import net.minecraft.item.ItemStack; +public interface IMatterCannonAmmoRegistry { -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); - /** - * 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 ); - - /** - * 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 ); + /** + * 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); } diff --git a/src/api/java/appeng/api/features/INetworkEncodable.java b/src/api/java/appeng/api/features/INetworkEncodable.java index d44ebecae..53e9c6463 100644 --- a/src/api/java/appeng/api/features/INetworkEncodable.java +++ b/src/api/java/appeng/api/features/INetworkEncodable.java @@ -23,28 +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); - /** - * Used to get the current key from the item. - * - * @param item item - * - * @return string key of item - */ - String getEncryptionKey( ItemStack item ); - - /** - * Encode the wireless frequency via the Controller. - * - * @param item the wireless terminal. - * @param encKey the wireless encryption key. - * @param name null for now. - */ - void setEncryptionKey( ItemStack item, String encKey, String name ); + /** + * Encode the wireless frequency via the Controller. + * + * @param item the wireless terminal. + * @param encKey the wireless encryption key. + * @param name null for now. + */ + void setEncryptionKey(ItemStack item, String encKey, String name); } diff --git a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java index 4f50b54d2..1a50c16a2 100644 --- a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java +++ b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java @@ -23,7 +23,6 @@ package appeng.api.features; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -32,33 +31,32 @@ import net.minecraftforge.common.capabilities.Capability; import appeng.api.config.TunnelType; - /** * A Registry for how p2p Tunnels are attuned */ -public interface IP2PTunnelRegistry -{ +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. Nullable, but then ignored - * @param type - the type of tunnel. Nullable, but then ignored - */ - void addNewAttunement( @Nonnull ItemStack trigger, @Nullable TunnelType type ); + /** + * Allows third parties to register items from their mod as potential + * attunements for AE's P2P Tunnels + * + * @param trigger - the item which triggers attunement. Nullable, but then + * ignored + * @param type - the type of tunnel. Nullable, but then ignored + */ + void addNewAttunement(@Nonnull ItemStack trigger, @Nullable TunnelType type); - void addNewAttunement( @Nonnull String ModId, @Nullable TunnelType type ); + void addNewAttunement(@Nonnull String ModId, @Nullable TunnelType type); - void addNewAttunement( @Nonnull Capability cap, @Nullable TunnelType type ); + void addNewAttunement(@Nonnull Capability cap, @Nullable TunnelType type); - /** - * returns null if no attunement can be found. - * - * @param trigger attunement trigger - * - * @return null if no attunement can be found or attunement - */ - @Nonnull - TunnelType getTunnelTypeByItem( ItemStack trigger ); + /** + * returns null if no attunement can be found. + * + * @param trigger attunement trigger + * + * @return null if no attunement can be found or attunement + */ + @Nonnull + 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 7ea2cab14..7bac6ef2b 100644 --- a/src/api/java/appeng/api/features/IPlayerRegistry.java +++ b/src/api/java/appeng/api/features/IPlayerRegistry.java @@ -23,40 +23,38 @@ package appeng.api.features; - import javax.annotation.Nullable; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; - /** - * 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. + * 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. */ -public interface IPlayerRegistry -{ +public interface IPlayerRegistry { - /** - * @param gameProfile user game profile - * - * @return user id of a username. - */ - int getID( GameProfile gameProfile ); + /** + * @param gameProfile user game profile + * + * @return user id of a username. + */ + int getID(GameProfile gameProfile); - /** - * @param player player - * - * @return user id of a player entity. - */ - int getID( PlayerEntity player ); + /** + * @param player player + * + * @return user id of a player entity. + */ + int getID(PlayerEntity player); - /** - * @param playerID to be found player id - * - * @return PlayerEntity, or null if the player could not be found. - */ - @Nullable - PlayerEntity findPlayer( int playerID ); + /** + * @param playerID to be found player id + * + * @return PlayerEntity, or null if the player could not be found. + */ + @Nullable + PlayerEntity findPlayer(int playerID); } diff --git a/src/api/java/appeng/api/features/IRegistryContainer.java b/src/api/java/appeng/api/features/IRegistryContainer.java index 114325ff6..81428fc17 100644 --- a/src/api/java/appeng/api/features/IRegistryContainer.java +++ b/src/api/java/appeng/api/features/IRegistryContainer.java @@ -23,14 +23,12 @@ package appeng.api.features; - import appeng.api.AEInjectable; import appeng.api.movable.IMovableRegistry; import appeng.api.networking.IGridCacheRegistry; import appeng.api.parts.IPartModels; import appeng.api.storage.ICellRegistry; - /** * @author AlgorithmX2 * @author thatsIch @@ -39,66 +37,66 @@ import appeng.api.storage.ICellRegistry; * @since rv0 */ @AEInjectable -public interface IRegistryContainer -{ +public interface IRegistryContainer { - /** - * Use the movable registry to white list your tiles. - */ - IMovableRegistry movable(); + /** + * Use the movable registry to white list your tiles. + */ + IMovableRegistry movable(); - /** - * Add new Grid Caches for use during run time, only use during loading phase. - */ - IGridCacheRegistry gridCache(); + /** + * Add new Grid Caches for use during run time, only use during loading phase. + */ + IGridCacheRegistry gridCache(); - /** - * Add additional special comparison functionality, AE Uses this internally for Bees. - */ - ISpecialComparisonRegistry specialComparison(); + /** + * Add additional special comparison functionality, AE Uses this internally for + * Bees. + */ + ISpecialComparisonRegistry specialComparison(); - /** - * Lets you register your items as wireless terminals - */ - IWirelessTermRegistry wireless(); + /** + * Lets you register your items as wireless terminals + */ + IWirelessTermRegistry wireless(); - /** - * Allows you to register new cell types, these will function in drives - */ - ICellRegistry cell(); + /** + * Allows you to register new cell types, these will function in drives + */ + ICellRegistry cell(); - /** - * Manage charger via API - */ - IChargerRegistry charger(); + /** + * Manage charger via API + */ + IChargerRegistry charger(); - /** - * get access to the locatable registry - */ - ILocatableRegistry locatable(); + /** + * get access to the locatable registry + */ + ILocatableRegistry locatable(); - /** - * get access to the p2p tunnel registry. - */ - IP2PTunnelRegistry p2pTunnel(); + /** + * get access to the p2p tunnel registry. + */ + IP2PTunnelRegistry p2pTunnel(); - /** - * get access to the ammo registry. - */ - IMatterCannonAmmoRegistry matterCannon(); + /** + * get access to the ammo registry. + */ + IMatterCannonAmmoRegistry matterCannon(); - /** - * get access to the player registry - */ - IPlayerRegistry players(); + /** + * get access to the player registry + */ + IPlayerRegistry players(); - /** - * get access to the world-gen api. - */ - IWorldGen worldgen(); + /** + * get access to the world-gen api. + */ + IWorldGen worldgen(); - /** - * Register your IPart models before using them. - */ - IPartModels partModels(); + /** + * Register your IPart models before using them. + */ + IPartModels partModels(); } diff --git a/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java b/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java index c55bf1757..fe1826bf4 100644 --- a/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java +++ b/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java @@ -23,29 +23,26 @@ package appeng.api.features; - import net.minecraft.item.ItemStack; - /** * A Registry of any special comparison handlers for AE To use. */ -public interface ISpecialComparisonRegistry -{ +public interface ISpecialComparisonRegistry { - /** - * return TheHandler or null. - * - * @param stack item - * - * @return a handler it found for a specific item - */ - IItemComparison getSpecialComparison( ItemStack stack ); + /** + * return TheHandler or null. + * + * @param stack item + * + * @return a handler it found for a specific item + */ + IItemComparison getSpecialComparison(ItemStack stack); - /** - * Register a new special comparison function with AE. - * - * @param prov comparison provider - */ - void addComparisonProvider( IItemComparisonProvider prov ); + /** + * Register a new special comparison function with AE. + * + * @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 842a0582e..033f239d5 100644 --- a/src/api/java/appeng/api/features/IWirelessTermHandler.java +++ b/src/api/java/appeng/api/features/IWirelessTermHandler.java @@ -23,52 +23,50 @@ package appeng.api.features; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import appeng.api.util.IConfigManager; - /** * A handler for a wireless terminal. */ -public interface IWirelessTermHandler extends INetworkEncodable -{ +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 ); + /** + * @param is wireless terminal + * + * @return true, if usePower, hasPower, etc... can be called for the provided + * item + */ + 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( PlayerEntity player, double amount, 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(PlayerEntity 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( PlayerEntity 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(PlayerEntity 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 ); + /** + * Return the config manager for the wireless terminal. + * + * @param is wireless terminal + * + * @return config manager of wireless terminal + */ + 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 57beeae53..b0e8655dd 100644 --- a/src/api/java/appeng/api/features/IWirelessTermRegistry.java +++ b/src/api/java/appeng/api/features/IWirelessTermRegistry.java @@ -23,44 +23,40 @@ package appeng.api.features; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.world.IBlockReader; - /** * Registration record for a Custom Cell handler. */ -public interface IWirelessTermRegistry -{ +public interface IWirelessTermRegistry { - /** - * add this handler to the list of other wireless handler. - * - * @param handler wireless handler - */ - void registerWirelessHandler( IWirelessTermHandler handler ); + /** + * add this handler to the list of other wireless handler. + * + * @param handler wireless 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 ); + /** + * @param is item which might have a handler + * + * @return true if there is a handler for this item + */ + boolean isWirelessTerminal(ItemStack is); - /** - * @param is item with handler - * PlayerEntity - * @return a register handler for the item in question, or null if there - * isn't one - */ - IWirelessTermHandler getWirelessTerminalHandler( ItemStack is ); + /** + * @param is item with handler PlayerEntity + * @return a register handler for the item in question, or null if there isn't + * one + */ + 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, IBlockReader world, PlayerEntity player, Hand hand ); + /** + * opens the wireless terminal gui, the wireless terminal item, must be in the + * active slot on the tool bar. + */ + void openWirelessTerminalGui(ItemStack item, IBlockReader world, PlayerEntity player, Hand hand); } diff --git a/src/api/java/appeng/api/features/IWorldGen.java b/src/api/java/appeng/api/features/IWorldGen.java index e9fa93136..880807ec9 100644 --- a/src/api/java/appeng/api/features/IWorldGen.java +++ b/src/api/java/appeng/api/features/IWorldGen.java @@ -23,25 +23,21 @@ package appeng.api.features; - import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.world.dimension.Dimension; +public interface IWorldGen { -public interface IWorldGen -{ + void disableWorldGenForProviderID(WorldGenType type, Class provider); - void disableWorldGenForProviderID( WorldGenType type, Class provider ); + void enableWorldGenForDimension(WorldGenType type, ResourceLocation dimID); - void enableWorldGenForDimension( WorldGenType type, ResourceLocation dimID ); + void disableWorldGenForDimension(WorldGenType type, ResourceLocation dimID); - void disableWorldGenForDimension( WorldGenType type, ResourceLocation dimID ); + boolean isWorldGenEnabled(WorldGenType type, World w); - boolean isWorldGenEnabled( WorldGenType type, World w ); - - enum WorldGenType - { - CERTUS_QUARTZ, CHARGED_CERTUS_QUARTZ, METEORITES - } + enum WorldGenType { + CERTUS_QUARTZ, CHARGED_CERTUS_QUARTZ, METEORITES + } } diff --git a/src/api/java/appeng/api/features/InscriberProcessType.java b/src/api/java/appeng/api/features/InscriberProcessType.java index d28ef0a2b..6c9571a46 100644 --- a/src/api/java/appeng/api/features/InscriberProcessType.java +++ b/src/api/java/appeng/api/features/InscriberProcessType.java @@ -18,16 +18,14 @@ package appeng.api.features; +public enum InscriberProcessType { + /** + * uses the optionals as catalyst + */ + INSCRIBE, -public enum InscriberProcessType -{ - /** - * uses the optionals as catalyst - */ - INSCRIBE, - - /** - * spends the optionals - */ - PRESS + /** + * spends the optionals + */ + PRESS } diff --git a/src/api/java/appeng/api/implementations/ICraftingPatternItem.java b/src/api/java/appeng/api/implementations/ICraftingPatternItem.java index a8bdbaac8..5b93bd7f6 100644 --- a/src/api/java/appeng/api/implementations/ICraftingPatternItem.java +++ b/src/api/java/appeng/api/implementations/ICraftingPatternItem.java @@ -23,27 +23,24 @@ 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} */ -public interface ICraftingPatternItem -{ +public interface ICraftingPatternItem { - /** - * Access Details about a pattern - * - * @param is pattern - * @param w crafting world - * - * @return details of pattern - */ - ICraftingPatternDetails getPatternForItem( ItemStack is, World w ); + /** + * Access Details about a pattern + * + * @param is pattern + * @param w crafting world + * + * @return details of pattern + */ + 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 ee5587929..9c4143d61 100644 --- a/src/api/java/appeng/api/implementations/IPowerChannelState.java +++ b/src/api/java/appeng/api/implementations/IPowerChannelState.java @@ -23,20 +23,18 @@ package appeng.api.implementations; - /** * This is intended for use on the client side to provide details to WAILA. */ -public interface IPowerChannelState -{ +public interface IPowerChannelState { - /** - * @return true if the part/tile is powered. - */ - boolean isPowered(); + /** + * @return true if the part/tile is powered. + */ + boolean isPowered(); - /** - * @return true if the part/tile isActive - */ - boolean isActive(); + /** + * @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 bbc728e1f..5f39fec70 100644 --- a/src/api/java/appeng/api/implementations/IUpgradeableHost.java +++ b/src/api/java/appeng/api/implementations/IUpgradeableHost.java @@ -23,26 +23,23 @@ package appeng.api.implementations; - 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 { -public interface IUpgradeableHost extends IConfigurableObject, ISegmentedInventory -{ + /** + * determine how many of an upgrade are installed. + */ + int getInstalledUpgrades(Upgrades u); - /** - * determine how many of an upgrade are installed. - */ - int getInstalledUpgrades( Upgrades u ); - - /** - * the tile... - * - * @return tile entity - */ - TileEntity getTile(); + /** + * the tile... + * + * @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 82b459cdf..209524a49 100644 --- a/src/api/java/appeng/api/implementations/TransitionResult.java +++ b/src/api/java/appeng/api/implementations/TransitionResult.java @@ -23,19 +23,16 @@ 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. */ -public class TransitionResult -{ - public final boolean success; - public final double energyUsage; +public class TransitionResult { + public final boolean success; + public final double energyUsage; - public TransitionResult( final boolean success, final double power ) - { - this.success = success; - this.energyUsage = power; - } + public TransitionResult(final boolean success, final 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 ef9b0fcf0..711285f58 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java @@ -23,28 +23,27 @@ package appeng.api.implementations.guiobjects; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import javax.annotation.Nullable; - - /** * Implemented on Item objects, to return objects used to manage, and interact * with the contents. */ -public interface IGuiItem -{ - /** - * - * @param is The item used to open the container. - * @param playerInventorySlot The slot in the player's inventory the item is in. - * @param world The world the player is in. - * @param pos If the item was used on a block in the world, has that block's position. Null if no block was targetted. - * @return Null if no GUI object is available. - */ - @Nullable - IGuiItemObject getGuiObject( ItemStack is, int playerInventorySlot, World world, @Nullable BlockPos pos ); +public interface IGuiItem { + /** + * + * @param is The item used to open the container. + * @param playerInventorySlot The slot in the player's inventory the item is in. + * @param world The world the player is in. + * @param pos If the item was used on a block in the world, has + * that block's position. Null if no block was + * targetted. + * @return Null if no GUI object is available. + */ + @Nullable + IGuiItemObject getGuiObject(ItemStack is, int playerInventorySlot, World world, @Nullable BlockPos pos); } diff --git a/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java b/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java index 342187394..5d08fb530 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java @@ -23,12 +23,9 @@ package appeng.api.implementations.guiobjects; - import net.minecraft.item.ItemStack; +public interface IGuiItemObject { -public interface IGuiItemObject -{ - - ItemStack getItemStack(); + ItemStack getItemStack(); } diff --git a/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java b/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java index ea0a2e774..10d073ef4 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java +++ b/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java @@ -23,18 +23,15 @@ package appeng.api.implementations.guiobjects; - import net.minecraftforge.items.IItemHandler; import appeng.api.networking.IGridHost; - /** * Obtained via {@link IGuiItem} getGuiObject */ -public interface INetworkTool extends IGuiItemObject -{ - IGridHost getGridHost(); // null for most purposes. +public interface INetworkTool extends IGuiItemObject { + IGridHost getGridHost(); // null for most purposes. - IItemHandler getInventory(); + IItemHandler getInventory(); } diff --git a/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java b/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java index 7a80a00b5..5caa0d620 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java @@ -23,17 +23,14 @@ 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 */ -public interface IPortableCell extends ITerminalHost, IMEMonitor, IEnergySource, IGuiItemObject -{ +public interface IPortableCell extends ITerminalHost, IMEMonitor, IEnergySource, IGuiItemObject { } diff --git a/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java b/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java index 1a20c8e1c..cfc3f62f4 100644 --- a/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java +++ b/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java @@ -23,53 +23,50 @@ package appeng.api.implementations.items; - import net.minecraft.item.ItemStack; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; import appeng.api.networking.energy.IAEPowerStorage; - /** * Basically the same as {@link IAEPowerStorage}, but for items. */ -public interface IAEItemPowerStorage -{ - /** - * Inject amt, power into the device, it will store what it can, and return - * the amount unable to be stored. - * - * @return amount unable to be stored - */ - double injectAEPower( ItemStack stack, double amount, Actionable mode ); +public interface IAEItemPowerStorage { + /** + * Inject amt, power into the device, it will store what it can, and return the + * amount unable to be stored. + * + * @return amount unable to be stored + */ + double injectAEPower(ItemStack stack, double amount, Actionable mode); - /** - * Attempt to extract power from the device, it will extract what it can and - * return it. - * - * @param amount to be extracted power from device - * - * @return what it could extract - */ - double extractAEPower( ItemStack stack, double amount, Actionable mode ); + /** + * Attempt to extract power from the device, it will extract what it can and + * return it. + * + * @param amount to be extracted power from device + * + * @return what it could extract + */ + double extractAEPower(ItemStack stack, double amount, Actionable mode); - /** - * @return the current maximum power ( this can change :P ) - */ - double getAEMaxPower( ItemStack stack ); + /** + * @return the current maximum power ( this can change :P ) + */ + double getAEMaxPower(ItemStack stack); - /** - * @return the current AE Power Level, this may exceed getMEMaxPower() - */ - double getAECurrentPower( ItemStack stack ); + /** + * @return the current AE Power Level, this may exceed getMEMaxPower() + */ + double getAECurrentPower(ItemStack stack); - /** - * Control the power flow by telling what the network can do, either add? or - * subtract? or both! - * - * @return access restriction of network - */ - AccessRestriction getPowerFlow( ItemStack stack ); + /** + * Control the power flow by telling what the network can do, either add? or + * subtract? or both! + * + * @return access restriction of network + */ + AccessRestriction getPowerFlow(ItemStack stack); } \ 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 3e4b8bab1..dc49c7654 100644 --- a/src/api/java/appeng/api/implementations/items/IAEWrench.java +++ b/src/api/java/appeng/api/implementations/items/IAEWrench.java @@ -23,26 +23,23 @@ package appeng.api.implementations.items; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; - /** * Implemented on AE's wrench(s) as a substitute for if BC's API is not * available. */ -public interface IAEWrench -{ +public interface IAEWrench { - /** - * Check if the wrench can be used. - * - * @param player wrenching player - * @param pos of block. - * - * @return true if wrench can be used - */ - boolean canWrench( ItemStack wrench, PlayerEntity player, BlockPos pos ); + /** + * Check if the wrench can be used. + * + * @param player wrenching player + * @param pos of block. + * + * @return true if wrench can be used + */ + boolean canWrench(ItemStack wrench, PlayerEntity player, BlockPos pos); } diff --git a/src/api/java/appeng/api/implementations/items/IBiometricCard.java b/src/api/java/appeng/api/implementations/items/IBiometricCard.java index b1128f45d..481f798a7 100644 --- a/src/api/java/appeng/api/implementations/items/IBiometricCard.java +++ b/src/api/java/appeng/api/implementations/items/IBiometricCard.java @@ -23,7 +23,6 @@ package appeng.api.implementations.items; - import java.util.EnumSet; import com.mojang.authlib.GameProfile; @@ -34,58 +33,58 @@ import appeng.api.config.SecurityPermissions; import appeng.api.features.IPlayerRegistry; import appeng.api.networking.security.ISecurityRegistry; +public interface IBiometricCard { -public interface IBiometricCard -{ + /** + * Set the {@link GameProfile} to null, to clear it. + */ + void setProfile(ItemStack itemStack, GameProfile username); - /** - * Set the {@link GameProfile} to null, to clear it. - */ - void setProfile( ItemStack itemStack, GameProfile username ); + /** + * @return {@link GameProfile} of the player encoded on this card, or a blank + * string. + */ + GameProfile getProfile(ItemStack is); - /** - * @return {@link GameProfile} of the player encoded on this card, or a blank string. - */ - GameProfile getProfile( ItemStack is ); + /** + * @param itemStack card + * + * @return the full list of permissions encoded on the card. + */ + EnumSet getPermissions(ItemStack itemStack); - /** - * @param itemStack card - * - * @return the full list of permissions encoded on the card. - */ - 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); - /** - * 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 ); + /** + * remove a permission from the item stack. + * + * @param itemStack card + * @param permission to be removed permission + */ + void removePermission(ItemStack itemStack, SecurityPermissions permission); - /** - * remove a permission from the item stack. - * - * @param itemStack card - * @param permission to be removed 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); - /** - * add a permission to the item stack. - * - * @param itemStack card - * @param permission to be added 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 - */ - void registerPermissions( ISecurityRegistry registry, IPlayerRegistry pr, ItemStack is ); + /** + * lets you handle submission of security values on the card for custom + * behavior. + * + * @param registry security registry + * @param pr player registry + * @param is card + */ + 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 489e2b89c..a76c2b0e7 100644 --- a/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java +++ b/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java @@ -23,16 +23,13 @@ package appeng.api.implementations.items; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; +public interface IGrowableCrystal { -public interface IGrowableCrystal -{ + ItemStack triggerGrowth(ItemStack is); - ItemStack triggerGrowth( ItemStack is ); - - float getMultiplier( Block blk, Material mat ); + 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 3d3f8cc0f..c9263a905 100644 --- a/src/api/java/appeng/api/implementations/items/IItemGroup.java +++ b/src/api/java/appeng/api/implementations/items/IItemGroup.java @@ -23,24 +23,21 @@ package appeng.api.implementations.items; - import java.util.Set; import net.minecraft.item.ItemStack; - /** * Lets you specify the name of the group of items this falls under. */ -public interface IItemGroup -{ +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 ); + /** + * 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); } diff --git a/src/api/java/appeng/api/implementations/items/IMemoryCard.java b/src/api/java/appeng/api/implementations/items/IMemoryCard.java index 9ded9eff5..0de3bbcf0 100644 --- a/src/api/java/appeng/api/implementations/items/IMemoryCard.java +++ b/src/api/java/appeng/api/implementations/items/IMemoryCard.java @@ -23,74 +23,74 @@ package appeng.api.implementations.items; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import appeng.api.util.AEColor; - /** * Memory Card API * * AE's Memory Card Item Class implements this interface. */ -public interface IMemoryCard -{ +public interface IMemoryCard { - /** - * Configures the data stored on the memory card, the SettingsName, will be - * localized when displayed. - * - * The data can contain an optional string with the key "tooltip", which will be used as - * unlocalized string to display it after the settings name. - * - * The data can contain an optional intArray using "colorCode" to be displayed on the model itself. - * It needs to have exactly 8 elements representing the ordinal of the matching {@link AEColor}. - * The first 4 values represent the top row, left to right. The second 4 the bottom row. - * - * @param is item - * @param settingsName unlocalized string that represents the tile entity. - * @param data the NBT tag, refer to the normal comment for special keys. - */ - void setMemoryCardContents( ItemStack is, String settingsName, CompoundNBT data ); + /** + * Configures the data stored on the memory card, the SettingsName, will be + * localized when displayed. + * + * The data can contain an optional string with the key "tooltip", which will be + * used as unlocalized string to display it after the settings name. + * + * The data can contain an optional intArray using "colorCode" to be displayed + * on the model itself. It needs to have exactly 8 elements representing the + * ordinal of the matching {@link AEColor}. The first 4 values represent the top + * row, left to right. The second 4 the bottom row. + * + * @param is item + * @param settingsName unlocalized string that represents the tile entity. + * @param data the NBT tag, refer to the normal comment for special + * keys. + */ + void setMemoryCardContents(ItemStack is, String settingsName, CompoundNBT data); - /** - * returns the settings name provided by a previous call to - * setMemoryCardContents, or "AppEng.GuiITooltip.Blank" if there was no - * previous call to setMemoryCardContents. - * - * @param is item - * - * @return setting name - */ - String getSettingsName( ItemStack is ); + /** + * returns the settings name provided by a previous call to + * setMemoryCardContents, or "AppEng.GuiITooltip.Blank" if there was no previous + * call to setMemoryCardContents. + * + * @param is item + * + * @return setting name + */ + String getSettingsName(ItemStack is); - /** - * @param is item - * - * @return the NBT Data previously saved by setMemoryCardContents, or an - * empty NBTCompound - */ - CompoundNBT getData( ItemStack is ); + /** + * @param is item + * + * @return the NBT Data previously saved by setMemoryCardContents, or an empty + * NBTCompound + */ + CompoundNBT getData(ItemStack is); - /** - * This represent as 4x2 grid of {@link AEColor} without transparent/fluix color. - * - * First 4 colors are used for the top row, second for the bottom one. - * - * @param is item - * - * @return a hash representation of the memory card content - */ - AEColor[] getColorCode( ItemStack is ); + /** + * This represent as 4x2 grid of {@link AEColor} without transparent/fluix + * color. + * + * First 4 colors are used for the top row, second for the bottom one. + * + * @param is item + * + * @return a hash representation of the memory card content + */ + AEColor[] getColorCode(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( PlayerEntity player, MemoryCardMessages msg ); + /** + * 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(PlayerEntity 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 47dc47025..491dae0da 100644 --- a/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java +++ b/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java @@ -23,57 +23,54 @@ package appeng.api.implementations.items; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.dimension.DimensionType; import appeng.api.implementations.TransitionResult; import appeng.api.storage.ISpatialDimension; import appeng.api.util.WorldCoord; -import net.minecraft.world.dimension.DimensionType; - /** * Implemented on a {@link Item} */ -public interface ISpatialStorageCell -{ +public interface ISpatialStorageCell { - /** - * @param is spatial storage cell - * - * @return true if this item is a spatial storage cell - */ - boolean isSpatialStorage( ItemStack is ); + /** + * @param is spatial storage cell + * + * @return true if this item is a spatial storage cell + */ + 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 ); + /** + * @param is spatial storage cell + * + * @return the maximum size of the spatial storage cell along any given axis + */ + int getMaxStoredDim(ItemStack is); - /** - * get the currently stored Dimension id. - * - * @param is spatial storage cell - * - * @return dimension id or -1 - */ - DimensionType getStoredDimension(ItemStack is ); + /** + * get the currently stored Dimension id. + * + * @param is spatial storage cell + * + * @return dimension id or -1 + */ + DimensionType getStoredDimension(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 playerId owner of current grid or -1 - * - * @return result of transition - */ - TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, int playerId ); + /** + * 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 playerId owner of current grid or -1 + * + * @return result of transition + */ + TransitionResult doSpatialTransition(ItemStack is, World w, WorldCoord min, WorldCoord max, int playerId); } \ 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 d85e34a8d..79763e2a7 100644 --- a/src/api/java/appeng/api/implementations/items/IStorageCell.java +++ b/src/api/java/appeng/api/implementations/items/IStorageCell.java @@ -23,7 +23,6 @@ package appeng.api.implementations.items; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -32,7 +31,6 @@ import appeng.api.storage.ICellWorkbenchItem; import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; - /** * Any item which implements this can be treated as an IMEInventory via * Util.getCell / Util.isCell It automatically handles the internals and NBT @@ -43,79 +41,77 @@ import appeng.api.storage.data.IAEStack; * * The standard AE implementation only provides 1-63 Types */ -public interface IStorageCell> extends ICellWorkbenchItem -{ +public interface IStorageCell> extends ICellWorkbenchItem { - /** - * It wont work if the return is not a multiple of 8. - * The limit is ({@link Integer#MAX_VALUE} + 1) / 8. - * - * @param cellItem item - * - * @return number of bytes - */ - int getBytes( @Nonnull ItemStack cellItem ); + /** + * It wont work if the return is not a multiple of 8. The limit is + * ({@link Integer#MAX_VALUE} + 1) / 8. + * + * @param cellItem item + * + * @return number of bytes + */ + int getBytes(@Nonnull ItemStack cellItem); - /** - * Determines the number of bytes used for any type included on the cell. - * - * @param cellItem item - * - * @return number of bytes - */ - int getBytesPerType( @Nonnull ItemStack cellItem ); + /** + * Determines the number of bytes used for any type included on the cell. + * + * @param cellItem item + * + * @return number of bytes + */ + int getBytesPerType(@Nonnull 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( @Nonnull 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(@Nonnull 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( @Nonnull ItemStack cellItem, @Nonnull T requestedAddition ); + /** + * 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(@Nonnull ItemStack cellItem, @Nonnull T requestedAddition); - /** - * Allows you to specify if this storage cell can be stored inside other - * storage cells, only set this for special items like the matter cannon - * that are not general purpose storage. - * - * @return 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. - */ - boolean storableInStorageCell(); + /** + * Allows you to specify if this storage cell can be stored inside other storage + * cells, only set this for special items like the matter cannon that are not + * general purpose storage. + * + * @return 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. + */ + boolean storableInStorageCell(); - /** - * Allows an item to selectively enable or disable its status as a storage - * cell. - * - * @param i item - * - * @return if the ItemStack should behavior as a storage cell. - */ - boolean isStorageCell( @Nonnull ItemStack i ); + /** + * Allows an item to selectively enable or disable its status as a storage cell. + * + * @param i item + * + * @return if the ItemStack should behavior as a storage cell. + */ + boolean isStorageCell(@Nonnull ItemStack i); - /** - * @return drain in ae/t this storage cell will use. - */ - double getIdleDrain(); + /** + * @return drain in ae/t this storage cell will use. + */ + double getIdleDrain(); - /** - * @return the type of channel your cell should be part of - */ - @Nonnull - IStorageChannel getChannel(); + /** + * @return the type of channel your cell should be part of + */ + @Nonnull + IStorageChannel getChannel(); } diff --git a/src/api/java/appeng/api/implementations/items/IStorageComponent.java b/src/api/java/appeng/api/implementations/items/IStorageComponent.java index b1958f9fc..a790e86d6 100644 --- a/src/api/java/appeng/api/implementations/items/IStorageComponent.java +++ b/src/api/java/appeng/api/implementations/items/IStorageComponent.java @@ -23,34 +23,31 @@ package appeng.api.implementations.items; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - /** * Implemented on a {@link Item} */ -public interface IStorageComponent -{ +public interface IStorageComponent { - /** - * This isn't necessarily the same as if you make a storage cell out of it, - * but all of AE's default cells do it that way, its currently only used for - * the condenser. - * - * @param is item - * - * @return number of bytes - */ - int getBytes( ItemStack is ); + /** + * This isn't necessarily the same as if you make a storage cell out of it, but + * all of AE's default cells do it that way, its currently only used for the + * condenser. + * + * @param is item + * + * @return number of bytes + */ + 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 ); + /** + * Just true or false for the item stack. + * + * @param is item + * + * @return true if item is a storage component + */ + 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 0b06911e0..afc90572e 100644 --- a/src/api/java/appeng/api/implementations/items/IUpgradeModule.java +++ b/src/api/java/appeng/api/implementations/items/IUpgradeModule.java @@ -23,19 +23,16 @@ package appeng.api.implementations.items; - import net.minecraft.item.ItemStack; import appeng.api.config.Upgrades; +public interface IUpgradeModule { -public interface IUpgradeModule -{ - - /** - * @param itemstack item with potential upgrades - * - * @return null, or a valid upgrade type. - */ - Upgrades getType( ItemStack itemstack ); + /** + * @param itemstack item with potential upgrades + * + * @return null, or a valid upgrade type. + */ + 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 cddc532ff..1eda5ad9c 100644 --- a/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java +++ b/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java @@ -23,11 +23,9 @@ package appeng.api.implementations.items; - /** * Status Results for use with {@link IMemoryCard} */ -public enum MemoryCardMessages -{ - INVALID_MACHINE, SETTINGS_LOADED, SETTINGS_SAVED, SETTINGS_RESET, SETTINGS_CLEARED +public enum MemoryCardMessages { + INVALID_MACHINE, SETTINGS_LOADED, SETTINGS_SAVED, SETTINGS_RESET, SETTINGS_CLEARED } diff --git a/src/api/java/appeng/api/implementations/parts/IPartCable.java b/src/api/java/appeng/api/implementations/parts/IPartCable.java index c261b6eb9..aa7ca7ef8 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartCable.java +++ b/src/api/java/appeng/api/implementations/parts/IPartCable.java @@ -23,7 +23,6 @@ package appeng.api.implementations.parts; - import java.util.EnumSet; import net.minecraft.entity.player.PlayerEntity; @@ -37,54 +36,53 @@ import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.api.util.AEPartLocation; - /** - * Implemented on the {@link IPart}s cable objects that can be placed at {@link AEPartLocation}.UNKNOWN in - * {@link IPartHost}s + * Implemented on the {@link IPart}s cable objects that can be placed at + * {@link AEPartLocation}.UNKNOWN in {@link IPartHost}s */ -public interface IPartCable extends IPart, IGridHost -{ +public interface IPartCable extends IPart, IGridHost { - /** - * does this cable support buses? - */ - BusSupport supportsBuses(); + /** + * does this cable support buses? + */ + BusSupport supportsBuses(); - /** - * @return the current color of the cable. - */ - AEColor getCableColor(); + /** + * @return the current color of the cable. + */ + AEColor getCableColor(); - /** - * @return the Cable type. - */ - AECableType getCableConnectionType(); + /** + * @return the Cable type. + */ + AECableType getCableConnectionType(); - /** - * 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, PlayerEntity who ); + /** + * 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, PlayerEntity who); - /** - * Change sides on the cables node. - * - * Called by AE, do not invoke. - * - * @param sides sides of cable - */ - void setValidSides( EnumSet sides ); + /** + * Change sides on the cables node. + * + * Called by AE, do not invoke. + * + * @param sides sides of cable + */ + 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( Direction side ); + /** + * 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(Direction side); } diff --git a/src/api/java/appeng/api/implementations/parts/IPartMonitor.java b/src/api/java/appeng/api/implementations/parts/IPartMonitor.java index 8b788e844..0f4f6476f 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartMonitor.java +++ b/src/api/java/appeng/api/implementations/parts/IPartMonitor.java @@ -23,20 +23,17 @@ package appeng.api.implementations.parts; - import appeng.api.networking.IGridHost; import appeng.api.parts.IPart; - /** * Implemented by all screen like parts provided by AE. */ -public interface IPartMonitor extends IPart, IGridHost -{ +public interface IPartMonitor extends IPart, IGridHost { - /** - * @return if the device is online you should check this before providing - * any other information. - */ - boolean isPowered(); + /** + * @return if the device is online you should check this before providing 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 9bdfe650c..099da92bc 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java +++ b/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java @@ -23,28 +23,26 @@ 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 */ -public interface IPartStorageMonitor extends IPartMonitor, IPart, IGridHost, INetworkToolAgent -{ +public interface IPartStorageMonitor extends IPartMonitor, IPart, IGridHost, INetworkToolAgent { - /** - * @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. - */ - IAEStack getDisplayed(); + /** + * @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. + */ + IAEStack getDisplayed(); - /** - * @return the current locked state of the Storage Monitor - */ - boolean isLocked(); + /** + * @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/IChestOrDrive.java b/src/api/java/appeng/api/implementations/tiles/IChestOrDrive.java index e6da86baa..342fd5972 100644 --- a/src/api/java/appeng/api/implementations/tiles/IChestOrDrive.java +++ b/src/api/java/appeng/api/implementations/tiles/IChestOrDrive.java @@ -23,54 +23,53 @@ package appeng.api.implementations.tiles; +import javax.annotation.Nullable; + +import net.minecraft.item.Item; import appeng.api.networking.IGridHost; import appeng.api.storage.ICellContainer; import appeng.api.util.IOrientable; -import net.minecraft.item.Item; -import javax.annotation.Nullable; +public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable { + /** + * @return how many slots are available. Chest has 1, Drive has 10. + */ + int getCellCount(); -public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable -{ + /** + * 0 - cell is missing. + * + * 1 - green, + * + * 2 - orange, + * + * 3 - red + * + * @param slot slot index + * + * @return status of the slot, one of the above indices. + */ + int getCellStatus(int slot); - /** - * @return how many slots are available. Chest has 1, Drive has 10. - */ - int getCellCount(); + /** + * @return if the device is online you should check this before providing any + * other information. + */ + boolean isPowered(); - /** - * 0 - cell is missing. - * - * 1 - green, - * - * 2 - orange, - * - * 3 - red - * - * @param slot slot index - * - * @return status of the slot, one of the above indices. - */ - int getCellStatus( int slot ); + /** + * @param slot slot index + * + * @return is the cell currently blinking to show activity. + */ + boolean isCellBlinking(int slot); - /** - * @return if the device is online you should check this before providing any other information. - */ - boolean isPowered(); - - /** - * @param slot slot index - * - * @return is the cell currently blinking to show activity. - */ - boolean isCellBlinking( int slot ); - - /** - * Returns the item of the cell in the given slot or null. - */ - @Nullable - Item getCellItem(int slot ); + /** + * Returns the item of the cell in the given slot or null. + */ + @Nullable + Item getCellItem(int slot); } diff --git a/src/api/java/appeng/api/implementations/tiles/IColorableTile.java b/src/api/java/appeng/api/implementations/tiles/IColorableTile.java index f48796f7e..e55314bc0 100644 --- a/src/api/java/appeng/api/implementations/tiles/IColorableTile.java +++ b/src/api/java/appeng/api/implementations/tiles/IColorableTile.java @@ -23,17 +23,14 @@ package appeng.api.implementations.tiles; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Direction; import appeng.api.util.AEColor; +public interface IColorableTile { -public interface IColorableTile -{ + AEColor getColor(); - AEColor getColor(); - - boolean recolourBlock( Direction side, AEColor colour, PlayerEntity who ); + boolean recolourBlock(Direction side, AEColor colour, PlayerEntity who); } diff --git a/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java b/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java index 785719304..adbaa75d6 100644 --- a/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java +++ b/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java @@ -23,32 +23,31 @@ package appeng.api.implementations.tiles; - import net.minecraft.inventory.CraftingInventory; import net.minecraft.util.Direction; import appeng.api.networking.crafting.ICraftingPatternDetails; +public interface ICraftingMachine { -public interface ICraftingMachine -{ + /** + * inserts a crafting plan, and the necessary items into the crafting machine. + * + * @param patternDetails details of pattern + * @param table crafting table + * @param ejectionDirection ejection direction + * + * @return if it was accepted, all or nothing. + */ + boolean pushPattern(ICraftingPatternDetails patternDetails, CraftingInventory table, Direction ejectionDirection); - /** - * inserts a crafting plan, and the necessary items into the crafting machine. - * - * @param patternDetails details of pattern - * @param table crafting table - * @param ejectionDirection ejection direction - * - * @return if it was accepted, all or nothing. - */ - boolean pushPattern( ICraftingPatternDetails patternDetails, CraftingInventory table, Direction ejectionDirection ); - - /** - * check if the crafting machine is accepting pushes via pushPattern, if this is false, all calls to push will fail, - * you can try inserting into the inventory instead. - * - * @return true, if pushPattern can complete, if its false push will always be false. - */ - boolean acceptsPlans(); + /** + * check if the crafting machine is accepting pushes via pushPattern, if this is + * false, all calls to push will fail, you can try inserting into the inventory + * instead. + * + * @return true, if pushPattern can complete, if its false push will always be + * false. + */ + boolean acceptsPlans(); } diff --git a/src/api/java/appeng/api/implementations/tiles/ICrankable.java b/src/api/java/appeng/api/implementations/tiles/ICrankable.java index c49d8057b..85e76463c 100644 --- a/src/api/java/appeng/api/implementations/tiles/ICrankable.java +++ b/src/api/java/appeng/api/implementations/tiles/ICrankable.java @@ -23,10 +23,8 @@ package appeng.api.implementations.tiles; - import net.minecraft.util.Direction; - /** * Crank/Crankable API, * @@ -37,23 +35,22 @@ import net.minecraft.util.Direction; * * This interface must be implemented by a tile entity. */ -public interface ICrankable -{ +public interface ICrankable { - /** - * Test if the crank can turn, return false if there is no work to be done. - * - * @return if crank should be allowed to turn. - */ - boolean canTurn(); + /** + * Test if the crank can turn, return false if there is no work to be done. + * + * @return if crank should be allowed to turn. + */ + boolean canTurn(); - /** - * The crank has completed one turn. - */ - void applyTurn(); + /** + * The crank has completed one turn. + */ + void applyTurn(); - /** - * @return true if the crank can attach on the given side. - */ - boolean canCrankAttach( Direction directionToCrank ); + /** + * @return true if the crank can attach on the given side. + */ + boolean canCrankAttach(Direction directionToCrank); } diff --git a/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java b/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java index 9d8a9c29d..e29196de0 100644 --- a/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java +++ b/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java @@ -23,9 +23,7 @@ package appeng.api.implementations.tiles; +public interface ICrystalGrowthAccelerator { -public interface ICrystalGrowthAccelerator -{ - - boolean isPowered(); + 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 794b45d7d..5d6b67557 100644 --- a/src/api/java/appeng/api/implementations/tiles/IMEChest.java +++ b/src/api/java/appeng/api/implementations/tiles/IMEChest.java @@ -23,11 +23,8 @@ package appeng.api.implementations.tiles; - import appeng.api.networking.energy.IEnergySource; - -public interface IMEChest extends IChestOrDrive, IEnergySource -{ +public interface IMEChest extends IChestOrDrive, IEnergySource { } diff --git a/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java b/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java index 3f034b33e..6be6a1ce2 100644 --- a/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java +++ b/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java @@ -23,20 +23,18 @@ package appeng.api.implementations.tiles; - import net.minecraftforge.items.IItemHandler; +public interface ISegmentedInventory { -public interface ISegmentedInventory -{ - - /** - * Access an internal inventory, note, not all inventories contain real items, some may be ghost items, and treating - * them a real inventories will result in duplication. - * - * @param name inventory name - * - * @return inventory with inventory name - */ - IItemHandler getInventoryByName( String name ); + /** + * Access an internal inventory, note, not all inventories contain real items, + * some may be ghost items, and treating them a real inventories will result in + * duplication. + * + * @param name inventory name + * + * @return inventory with inventory name + */ + IItemHandler getInventoryByName(String name); } diff --git a/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java b/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java index d3aa6582f..829a0ce18 100644 --- a/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java +++ b/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java @@ -23,17 +23,14 @@ package appeng.api.implementations.tiles; - import net.minecraftforge.items.IItemHandler; +public interface IViewCellStorage { -public interface IViewCellStorage -{ - - /** - * should contains at least 5 slot, the first 5 - * - * @return inventory with at least 5 slot - */ - IItemHandler getViewCellStorage(); + /** + * should contains at least 5 slot, the first 5 + * + * @return inventory with at least 5 slot + */ + IItemHandler getViewCellStorage(); } diff --git a/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java b/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java index 038bc52db..52a8e4eb0 100644 --- a/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java +++ b/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java @@ -23,32 +23,29 @@ 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 { -public interface IWirelessAccessPoint extends IActionHost -{ + /** + * @return location of WAP + */ + DimensionalCoord getLocation(); - /** - * @return location of WAP - */ - DimensionalCoord getLocation(); + /** + * @return max range for this WAP + */ + double getRange(); - /** - * @return max range for this WAP - */ - double getRange(); + /** + * @return can you use this WAP? + */ + boolean isActive(); - /** - * @return can you use this WAP? - */ - boolean isActive(); - - /** - * @return grid of linked WAP - */ - IGrid getGrid(); + /** + * @return grid of linked WAP + */ + IGrid getGrid(); } diff --git a/src/api/java/appeng/api/movable/IMovableHandler.java b/src/api/java/appeng/api/movable/IMovableHandler.java index f15f25fa9..7dec94c1f 100644 --- a/src/api/java/appeng/api/movable/IMovableHandler.java +++ b/src/api/java/appeng/api/movable/IMovableHandler.java @@ -23,50 +23,46 @@ package appeng.api.movable; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +public interface IMovableHandler { -public interface IMovableHandler -{ + /** + * if you return true from this, your saying you can handle the class, not that + * single entity, you cannot opt out of single entities. + * + * @param myClass tile entity class + * @param tile tile entity + * + * @return true if it can handle moving + */ + boolean canHandle(Class myClass, TileEntity tile); - /** - * if you return true from this, your saying you can handle the class, not - * that single entity, you cannot opt out of single entities. - * - * @param myClass tile entity class - * @param tile tile entity - * - * @return true if it can handle moving - */ - boolean canHandle( Class myClass, TileEntity tile ); - - /** - * request that the handler move the the tile from its current location to - * the new one. the tile has already been invalidated, and the blocks have - * already been fully moved. - * - * Potential Example: - * - *
-	 * {
-	 * 	@code
-	 * 	Chunk c = world.getChunkAt( x, z );
-	 * 	c.setChunkBlockTileEntity( x & 0xF, y + y, z & 0xF, tile );
-	 *
-	 * 	if( c.isChunkLoaded )
-	 * 	{
-	 * 		world.addTileEntity( tile );
-	 * 		world.markBlockForUpdate( x, y, z );
-	 * 	}
-	 * }
-	 * 
- * - * @param tile to be moved tile - * @param world world of tile - * @param newPosition the new location - */ - void moveTile( TileEntity tile, World world, BlockPos newPosition ); + /** + * request that the handler move the the tile from its current location to the + * new one. the tile has already been invalidated, and the blocks have already + * been fully moved. + * + * Potential Example: + * + *
+     * {
+     *     @code
+     *     Chunk c = world.getChunkAt(x, z);
+     *     c.setChunkBlockTileEntity(x & 0xF, y + y, z & 0xF, tile);
+     *
+     *     if (c.isChunkLoaded) {
+     *         world.addTileEntity(tile);
+     *         world.markBlockForUpdate(x, y, z);
+     *     }
+     * }
+     * 
+ * + * @param tile to be moved tile + * @param world world of tile + * @param newPosition the new location + */ + void moveTile(TileEntity tile, World world, BlockPos newPosition); } \ No newline at end of file diff --git a/src/api/java/appeng/api/movable/IMovableRegistry.java b/src/api/java/appeng/api/movable/IMovableRegistry.java index c4dbb3c35..5a6e1b2f4 100644 --- a/src/api/java/appeng/api/movable/IMovableRegistry.java +++ b/src/api/java/appeng/api/movable/IMovableRegistry.java @@ -23,94 +23,99 @@ package appeng.api.movable; - import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; - /** - * Used to determine if a tile is marked as movable, a block will be considered movable, if... + * Used to determine if a tile is marked as movable, a block will be considered + * movable, if... * - * 1. The Tile or its super classes have been white listed with whiteListTileEntity. + * 1. The Tile or its super classes have been white listed with + * whiteListTileEntity. * * 2. The Tile implements IMovableTile * - * 3. A IMovableHandler is register that returns canHandle = true for the {@link TileEntity} subclass + * 3. A IMovableHandler is register that returns canHandle = true for the + * {@link TileEntity} subclass * * * The movement process is as follows, * - * 1. IMovableTile.prepareToMove() or TileEntity.invalidate() depending on your opt-in method. 2. The tile will be - * removed from the world. 3. Its world, coordinates will be changed. *** this can be overridden with a IMovableHandler - * *** 4. It will then be re-added to the world, or a new world. 5. TileEntity.validate() 6. IMovableTile.doneMoving ( - * if you implemented IMovableTile ) + * 1. IMovableTile.prepareToMove() or TileEntity.invalidate() depending on your + * opt-in method. 2. The tile will be removed from the world. 3. Its world, + * coordinates will be changed. *** this can be overridden with a + * IMovableHandler *** 4. It will then be re-added to the world, or a new world. + * 5. TileEntity.validate() 6. IMovableTile.doneMoving ( if you implemented + * IMovableTile ) * - * Please note, this is a 100% white list only feature, I will never opt in any non-vanilla, non-AE blocks. If you do - * not want to support your tiles being moved, you don't have to do anything. + * Please note, this is a 100% white list only feature, I will never opt in any + * non-vanilla, non-AE blocks. If you do not want to support your tiles being + * moved, you don't have to do anything. * - * I appreciate anyone that takes the effort to get their tiles to work with this system to create a better use - * experience. + * I appreciate anyone that takes the effort to get their tiles to work with + * this system to create a better use experience. * * If you need a build of deobf build of AE for testing, do not hesitate to ask. */ -public interface IMovableRegistry -{ +public interface IMovableRegistry { - /** - * Black list a block from movement, please only use this to prevent exploits. - * - * @param blk block - */ - void blacklistBlock( Block blk ); + /** + * Black list a block from movement, please only use this to prevent exploits. + * + * @param blk block + */ + void blacklistBlock(Block blk); - /** - * White list your tile entity with the registry. - * - * If you tile is handled with IMovableHandler or IMovableTile you do not need to white list it. - */ - void whiteListTileEntity( Class c ); + /** + * White list your tile entity with the registry. + * + * If you tile is handled with IMovableHandler or IMovableTile you do not need + * to white list it. + */ + void whiteListTileEntity(Class c); - /** - * @param te to be moved tile entity - * - * @return true if the tile has accepted your request to move it - */ - boolean askToMove( TileEntity te ); + /** + * @param te to be moved tile entity + * + * @return true if the tile has accepted your request to move it + */ + boolean askToMove(TileEntity te); - /** - * tells the tile you are done moving it. - * - * @param te moved tile entity - */ - void doneMoving( TileEntity te ); + /** + * tells the tile you are done moving it. + * + * @param te moved tile entity + */ + void doneMoving(TileEntity te); - /** - * add a new handler movable handler. - * - * @param handler moving handler - */ - void addHandler( IMovableHandler handler ); + /** + * add a new handler movable handler. + * + * @param handler moving handler + */ + void addHandler(IMovableHandler handler); - /** - * handlers are used to perform movement, this allows you to override AE's internal version. - * - * only valid after askToMove(...) = true - * - * @param te tile entity - * - * @return moving handler of tile entity - */ - IMovableHandler getHandler( TileEntity te ); + /** + * handlers are used to perform movement, this allows you to override AE's + * internal version. + * + * only valid after askToMove(...) = true + * + * @param te tile entity + * + * @return moving handler of tile entity + */ + IMovableHandler getHandler(TileEntity te); - /** - * @return a copy of the default handler - */ - IMovableHandler getDefaultHandler(); + /** + * @return a copy of the default handler + */ + IMovableHandler getDefaultHandler(); - /** - * @param blk block - * - * @return true if this block is blacklisted - */ - boolean isBlacklisted( Block blk ); + /** + * @param blk block + * + * @return true if this block is blacklisted + */ + boolean isBlacklisted(Block blk); } \ No newline at end of file diff --git a/src/api/java/appeng/api/movable/IMovableTile.java b/src/api/java/appeng/api/movable/IMovableTile.java index feaaff287..4aa3a2c0b 100644 --- a/src/api/java/appeng/api/movable/IMovableTile.java +++ b/src/api/java/appeng/api/movable/IMovableTile.java @@ -23,24 +23,22 @@ package appeng.api.movable; - /** * You can implement this, or use the IMovableRegistry to white list your tile, * please see the registry for more information. */ -public interface IMovableTile -{ +public interface IMovableTile { - /** - * notification that your block will be moved, called instead of invalidate, - * return false to prevent movement. - * - * @return false to prevent movement - */ - boolean prepareToMove(); + /** + * notification that your block will be moved, called instead of invalidate, + * return false to prevent movement. + * + * @return false to prevent movement + */ + boolean prepareToMove(); - /** - * notification that your block was moved, called after validate. - */ - void doneMoving(); + /** + * 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 c296eb64e..82a778f8a 100644 --- a/src/api/java/appeng/api/networking/GridFlags.java +++ b/src/api/java/appeng/api/networking/GridFlags.java @@ -23,48 +23,46 @@ package appeng.api.networking; - /** * Various flags to determine network node behavior. */ -public enum GridFlags -{ - /** - * import/export buses, terminals, and other devices that use network features, will use this setting. - */ - REQUIRE_CHANNEL, +public enum GridFlags { + /** + * import/export buses, terminals, and other devices that use network features, + * will use this setting. + */ + REQUIRE_CHANNEL, - /** - * P2P ME tunnels use this setting. - */ - COMPRESSED_CHANNEL, + /** + * P2P ME tunnels use this setting. + */ + COMPRESSED_CHANNEL, - /** - * cannot carry channels over this node. - */ - CANNOT_CARRY, + /** + * cannot carry channels over this node. + */ + CANNOT_CARRY, - /** - * Used by P2P Tunnels to prevent tunnels from tunneling recursively. - */ - CANNOT_CARRY_COMPRESSED, + /** + * Used by P2P Tunnels to prevent tunnels from tunneling recursively. + */ + CANNOT_CARRY_COMPRESSED, - /** - * This node can transmit 32 signals, this should only apply to Tier2 Cable, P2P Tunnels, and Quantum Network - * Bridges. - */ - DENSE_CAPACITY, + /** + * This node can transmit 32 signals, this should only apply to Tier2 Cable, P2P + * Tunnels, and Quantum Network Bridges. + */ + DENSE_CAPACITY, - /** - * This block is part of a multiblock, used in conjunction with REQUIRE_CHANNEL, and {@link IGridMultiblock} see - * this - * interface for details. - */ - MULTIBLOCK, + /** + * This block is part of a multiblock, used in conjunction with REQUIRE_CHANNEL, + * and {@link IGridMultiblock} see this interface for details. + */ + MULTIBLOCK, - /** - * Indicates which path might be preferred, this only matters if two routes of equal length exist, ad only changes - * the order they are processed in. - */ - PREFERRED + /** + * Indicates which path might be preferred, this only matters if two routes of + * equal length exist, ad only changes the order they are processed in. + */ + PREFERRED } diff --git a/src/api/java/appeng/api/networking/GridNotification.java b/src/api/java/appeng/api/networking/GridNotification.java index 0815fc698..48c7a29b0 100644 --- a/src/api/java/appeng/api/networking/GridNotification.java +++ b/src/api/java/appeng/api/networking/GridNotification.java @@ -23,11 +23,9 @@ package appeng.api.networking; - -public enum GridNotification -{ - /** - * the visible connections for this node have changed, useful for cable. - */ - CONNECTIONS_CHANGED, +public enum GridNotification { + /** + * the visible connections for this node have changed, useful for cable. + */ + CONNECTIONS_CHANGED, } diff --git a/src/api/java/appeng/api/networking/IGrid.java b/src/api/java/appeng/api/networking/IGrid.java index 0f2fbfb1c..744bdca20 100644 --- a/src/api/java/appeng/api/networking/IGrid.java +++ b/src/api/java/appeng/api/networking/IGrid.java @@ -23,84 +23,83 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import appeng.api.networking.events.MENetworkEvent; import appeng.api.util.IReadOnlyCollection; - /** * Gives you access to Grid based information. * * Don't Implement. */ -public interface IGrid -{ +public interface IGrid { - /** - * Get Access to various grid modules - * - * @param iface face - * - * @return the IGridCache you requested. - */ - @Nonnull - C getCache( @Nonnull Class iface ); + /** + * Get Access to various grid modules + * + * @param iface face + * + * @return the IGridCache you requested. + */ + @Nonnull + C getCache(@Nonnull Class iface); - /** - * Post an event into the network event bus. - * - * @param ev - event to post - * - * @return returns ev back to original poster - */ - @Nonnull - MENetworkEvent postEvent( @Nonnull MENetworkEvent ev ); + /** + * Post an event into the network event bus. + * + * @param ev - event to post + * + * @return returns ev back to original poster + */ + @Nonnull + MENetworkEvent postEvent(@Nonnull MENetworkEvent ev); - /** - * Post an event into the network event bus, but direct it at a single node. - * - * @param ev event to post - * - * @return returns ev back to original poster - */ - @Nonnull - MENetworkEvent postEventTo( @Nonnull IGridNode node, @Nonnull MENetworkEvent ev ); + /** + * Post an event into the network event bus, but direct it at a single node. + * + * @param ev event to post + * + * @return returns ev back to original poster + */ + @Nonnull + MENetworkEvent postEventTo(@Nonnull IGridNode node, @Nonnull MENetworkEvent ev); - /** - * get a list of the diversity of classes, you can use this to better detect which machines your interested in, - * rather then iterating the entire grid to test them. - * - * @return IReadOnlyCollection of all available host types (Of Type IGridHost). - */ - @Nonnull - IReadOnlyCollection> getMachinesClasses(); + /** + * get a list of the diversity of classes, you can use this to better detect + * which machines your interested in, rather then iterating the entire grid to + * test them. + * + * @return IReadOnlyCollection of all available host types (Of Type IGridHost). + */ + @Nonnull + IReadOnlyCollection> getMachinesClasses(); - /** - * Get machines on the network. - * - * @param gridHostClass class of the grid host - * - * @return IMachineSet of all nodes belonging to hosts of specified class. - */ - @Nonnull - IMachineSet getMachines( @Nonnull Class gridHostClass ); + /** + * Get machines on the network. + * + * @param gridHostClass class of the grid host + * + * @return IMachineSet of all nodes belonging to hosts of specified class. + */ + @Nonnull + IMachineSet getMachines(@Nonnull Class gridHostClass); - /** - * @return IReadOnlyCollection for all nodes on the network, node visitors are preferred. - */ - @Nonnull - IReadOnlyCollection getNodes(); + /** + * @return IReadOnlyCollection for all nodes on the network, node visitors are + * preferred. + */ + @Nonnull + IReadOnlyCollection getNodes(); - /** - * @return true if the last node has been removed from the grid. - */ - boolean isEmpty(); + /** + * @return true if the last node has been removed from the grid. + */ + boolean isEmpty(); - /** - * @return the node considered the pivot point of the grid. - */ - @Nonnull - IGridNode getPivot(); + /** + * @return the node considered the pivot point of the grid. + */ + @Nonnull + IGridNode getPivot(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/IGridBlock.java b/src/api/java/appeng/api/networking/IGridBlock.java index 8bea72d7c..28b5ae88f 100644 --- a/src/api/java/appeng/api/networking/IGridBlock.java +++ b/src/api/java/appeng/api/networking/IGridBlock.java @@ -23,7 +23,6 @@ package appeng.api.networking; - import java.util.EnumSet; import javax.annotation.Nonnegative; @@ -36,95 +35,98 @@ import appeng.api.parts.IPart; import appeng.api.util.AEColor; import appeng.api.util.DimensionalCoord; - /** * An Implementation is required to create your node for IGridHost * * Implement for use with IGridHost */ -public interface IGridBlock -{ +public interface IGridBlock { - /** - * how much power to drain per tick as part of idle network usage. - * - * if the value of this changes, you must post a MENetworkPowerIdleChange - * - * @return ae/t to use. - */ - @Nonnegative - double getIdlePowerUsage(); + /** + * how much power to drain per tick as part of idle network usage. + * + * if the value of this changes, you must post a MENetworkPowerIdleChange + * + * @return ae/t to use. + */ + @Nonnegative + double getIdlePowerUsage(); - /** - * Various flags that AE uses to modify basic behavior for various parts of the network. - * - * @return Set of flags for this IGridBlock - */ - @Nonnull - EnumSet getFlags(); + /** + * Various flags that AE uses to modify basic behavior for various parts of the + * network. + * + * @return Set of flags for this IGridBlock + */ + @Nonnull + EnumSet getFlags(); - /** - * Generally speaking you will return true for this, the one exception is buses, or worm holes where the node - * represents something that isn't a real connection in the world, but rather one represented internally to the - * block. - * - * @return if the world can connect to this node, and the node can connect to the world. - */ - boolean isWorldAccessible(); + /** + * Generally speaking you will return true for this, the one exception is buses, + * or worm holes where the node represents something that isn't a real + * connection in the world, but rather one represented internally to the block. + * + * @return if the world can connect to this node, and the node can connect to + * the world. + */ + boolean isWorldAccessible(); - /** - * Must not return when {@link #isWorldAccessible()} is true. - * Otherwise the behavior is unspecified. - * - * @return current location of this node - */ - @Nonnull - DimensionalCoord getLocation(); + /** + * Must not return when {@link #isWorldAccessible()} is true. Otherwise the + * behavior is unspecified. + * + * @return current location of this node + */ + @Nonnull + DimensionalCoord getLocation(); - /** - * @return Transparent, or a valid color, NULL IS NOT A VALID RETURN - */ - @Nonnull - AEColor getGridColor(); + /** + * @return Transparent, or a valid color, NULL IS NOT A VALID RETURN + */ + @Nonnull + AEColor getGridColor(); - /** - * Notifies your IGridBlock that changes were made to your connections - */ - void onGridNotification( @Nonnull GridNotification notification ); + /** + * Notifies your IGridBlock that changes were made to your connections + */ + void onGridNotification(@Nonnull GridNotification notification); - /** - * Update Blocks network/connection/booting status. grid, - * - * @param grid grid - * @param channelsInUse used channels - * @deprecated to be removed in rv7 - */ - @Deprecated - void setNetworkStatus( IGrid grid, int channelsInUse ); + /** + * Update Blocks network/connection/booting status. grid, + * + * @param grid grid + * @param channelsInUse used channels + * @deprecated to be removed in rv7 + */ + @Deprecated + void setNetworkStatus(IGrid grid, int channelsInUse); - /** - * Determine which sides of the block can be connected too, only used when isWorldAccessible returns true, not used - * for {@link IPart} implementations. - */ - @Nonnull - EnumSet getConnectableSides(); + /** + * Determine which sides of the block can be connected too, only used when + * isWorldAccessible returns true, not used for {@link IPart} implementations. + */ + @Nonnull + EnumSet getConnectableSides(); - /** - * @return the IGridHost for the node, this will be an IGridPart or a TileEntity generally speaking. - */ - @Nonnull - IGridHost getMachine(); + /** + * @return the IGridHost for the node, this will be an IGridPart or a TileEntity + * generally speaking. + */ + @Nonnull + IGridHost getMachine(); - /** - * called when the grid for the node has changed, the general grid state should not be trusted at this point. - */ - void gridChanged(); + /** + * called when the grid for the node has changed, the general grid state should + * not be trusted at this point. + */ + void gridChanged(); - /** - * Determines what item stack is used to render this node in the GUI. - * - * @return the render item stack to use to render this node. Returning an empty ItemStack will not show this node. - */ - @Nonnull - ItemStack getMachineRepresentation(); + /** + * Determines what item stack is used to render this node in the GUI. + * + * @return the render item stack to use to render this node. Returning an empty + * ItemStack will not show this node. + */ + @Nonnull + ItemStack getMachineRepresentation(); } diff --git a/src/api/java/appeng/api/networking/IGridCache.java b/src/api/java/appeng/api/networking/IGridCache.java index 634ed1b6a..e14936150 100644 --- a/src/api/java/appeng/api/networking/IGridCache.java +++ b/src/api/java/appeng/api/networking/IGridCache.java @@ -23,10 +23,8 @@ package appeng.api.networking; - import javax.annotation.Nonnull; - /** * Allows you to create a network wise service, AE2 uses these for providing * item, spatial, and tunnel services. @@ -34,61 +32,60 @@ import javax.annotation.Nonnull; * Any Class that implements this, should have a public default constructor that * takes a single argument of type IGrid. */ -public interface IGridCache -{ +public interface IGridCache { - /** - * Called each tick for the network, allows you to have active network wide - * behaviors. - */ - void onUpdateTick(); + /** + * Called each tick for the network, allows you to have active network wide + * behaviors. + */ + void onUpdateTick(); - /** - * inform your cache, that a machine was removed from the grid. - * - * Important: Do not trust the grids state in this method, interact only - * with the node you are passed, if you need to manage other grid - * information, do it on the next updateTick. - * - * @param gridNode removed from that grid - * @param machine to be removed machine - */ - void removeNode( @Nonnull IGridNode gridNode, @Nonnull IGridHost machine ); + /** + * inform your cache, that a machine was removed from the grid. + * + * Important: Do not trust the grids state in this method, interact only with + * the node you are passed, if you need to manage other grid information, do it + * on the next updateTick. + * + * @param gridNode removed from that grid + * @param machine to be removed machine + */ + void removeNode(@Nonnull IGridNode gridNode, @Nonnull IGridHost machine); - /** - * informs you cache that a machine was added to the grid. - * - * Important: Do not trust the grids state in this method, interact only - * with the node you are passed, if you need to manage other grid - * information, do it on the next updateTick. - * - * @param gridNode added to grid node - * @param machine to be added machine - */ - void addNode( @Nonnull IGridNode gridNode, @Nonnull IGridHost machine ); + /** + * informs you cache that a machine was added to the grid. + * + * Important: Do not trust the grids state in this method, interact only with + * the node you are passed, if you need to manage other grid information, do it + * on the next updateTick. + * + * @param gridNode added to grid node + * @param machine to be added machine + */ + void addNode(@Nonnull IGridNode gridNode, @Nonnull IGridHost machine); - /** - * Called when a grid splits into two grids, AE will call a split as it - * Iteratively processes changes. The destination should receive half, and - * the current cache should receive half. - * - * @param destinationStorage storage which receives half of old grid - */ - void onSplit( @Nonnull IGridStorage destinationStorage ); + /** + * Called when a grid splits into two grids, AE will call a split as it + * Iteratively processes changes. The destination should receive half, and the + * current cache should receive half. + * + * @param destinationStorage storage which receives half of old grid + */ + void onSplit(@Nonnull IGridStorage destinationStorage); - /** - * Called when two grids merge into one, AE will call a join as it - * Iteratively processes changes. Use this method to incorporate all the - * data from the source into your cache. - * - * @param sourceStorage old storage - */ - void onJoin( @Nonnull IGridStorage sourceStorage ); + /** + * Called when two grids merge into one, AE will call a join as it Iteratively + * processes changes. Use this method to incorporate all the data from the + * source into your cache. + * + * @param sourceStorage old storage + */ + void onJoin(@Nonnull IGridStorage sourceStorage); - /** - * Called when saving changes, - * - * @param destinationStorage storage - */ - void populateGridStorage( @Nonnull IGridStorage destinationStorage ); + /** + * Called when saving changes, + * + * @param destinationStorage storage + */ + void populateGridStorage(@Nonnull IGridStorage destinationStorage); } diff --git a/src/api/java/appeng/api/networking/IGridCacheRegistry.java b/src/api/java/appeng/api/networking/IGridCacheRegistry.java index 47601abf5..6febca132 100644 --- a/src/api/java/appeng/api/networking/IGridCacheRegistry.java +++ b/src/api/java/appeng/api/networking/IGridCacheRegistry.java @@ -23,31 +23,31 @@ package appeng.api.networking; - import java.util.Map; import javax.annotation.Nonnull; - /** * A registry of grid caches to extend grid functionality. */ -public interface IGridCacheRegistry -{ +public interface IGridCacheRegistry { - /** - * Register a new grid cache for use during operation, must be called during the loading phase. - * - * @param iface grid cache class - */ - void registerGridCache( @Nonnull Class iface, @Nonnull Class implementation ); + /** + * Register a new grid cache for use during operation, must be called during the + * loading phase. + * + * @param iface grid cache class + */ + void registerGridCache(@Nonnull Class iface, + @Nonnull Class implementation); - /** - * requests a new INSTANCE of a grid cache for use, used internally - * - * @param grid grid - * - * @return a new Map of IGridCaches from the registry, called from IGrid when constructing a new grid. - */ - Map, IGridCache> createCacheInstance( IGrid grid ); + /** + * requests a new INSTANCE of a grid cache for use, used internally + * + * @param grid grid + * + * @return a new Map of IGridCaches from the registry, called from IGrid when + * constructing a new grid. + */ + Map, IGridCache> createCacheInstance(IGrid grid); } diff --git a/src/api/java/appeng/api/networking/IGridConnection.java b/src/api/java/appeng/api/networking/IGridConnection.java index 85ff26690..892412e4c 100644 --- a/src/api/java/appeng/api/networking/IGridConnection.java +++ b/src/api/java/appeng/api/networking/IGridConnection.java @@ -23,68 +23,65 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import appeng.api.util.AEPartLocation; - /** * Access to AE's internal grid connections. * - * Messing with connection is generally completely unnecessary, you should be able to just use IGridNode.updateState() - * to have AE manage them for you. + * Messing with connection is generally completely unnecessary, you should be + * able to just use IGridNode.updateState() to have AE manage them for you. * * Don't Implement. */ -public interface IGridConnection -{ +public interface IGridConnection { - /** - * lets you get the opposing node of the connection by passing your own node. - * - * @param gridNode current grid node - * - * @return the IGridNode which represents the opposite side of the connection. - */ - @Nonnull - IGridNode getOtherSide( IGridNode gridNode ); + /** + * lets you get the opposing node of the connection by passing your own node. + * + * @param gridNode current grid node + * + * @return the IGridNode which represents the opposite side of the connection. + */ + @Nonnull + IGridNode getOtherSide(IGridNode gridNode); - /** - * determine the direction of the connection based on your node. - * - * @param gridNode current grid node - * - * @return the direction of the connection, only valid for in world connections. - */ - @Nonnull - AEPartLocation getDirection( IGridNode gridNode ); + /** + * determine the direction of the connection based on your node. + * + * @param gridNode current grid node + * + * @return the direction of the connection, only valid for in world connections. + */ + @Nonnull + AEPartLocation getDirection(IGridNode gridNode); - /** - * by destroying a connection you may create new grids, and trigger un-expected behavior, you should only destroy - * connections if you created them. - */ - void destroy(); + /** + * by destroying a connection you may create new grids, and trigger un-expected + * behavior, you should only destroy connections if you created them. + */ + void destroy(); - /** - * @return node A - */ - @Nonnull - IGridNode a(); + /** + * @return node A + */ + @Nonnull + IGridNode a(); - /** - * @return node B - */ - @Nonnull - IGridNode b(); + /** + * @return node B + */ + @Nonnull + IGridNode b(); - /** - * @return if the connection is invisible this returns false - */ - boolean hasDirection(); + /** + * @return if the connection is invisible this returns false + */ + boolean hasDirection(); - /** - * @return how many channels pass over this connections. - */ - int getUsedChannels(); + /** + * @return how many channels pass over this connections. + */ + int getUsedChannels(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/IGridConnectionVisitor.java b/src/api/java/appeng/api/networking/IGridConnectionVisitor.java index 84cd12f91..5fc9dfe09 100644 --- a/src/api/java/appeng/api/networking/IGridConnectionVisitor.java +++ b/src/api/java/appeng/api/networking/IGridConnectionVisitor.java @@ -23,17 +23,14 @@ package appeng.api.networking; - import javax.annotation.Nonnull; +public interface IGridConnectionVisitor extends IGridVisitor { -public interface IGridConnectionVisitor extends IGridVisitor -{ - - /** - * Called for each connection on the network. - * - * @param n the connection. - */ - void visitConnection( @Nonnull IGridConnection n ); + /** + * Called for each connection on the network. + * + * @param n the connection. + */ + void visitConnection(@Nonnull IGridConnection n); } diff --git a/src/api/java/appeng/api/networking/IGridHelper.java b/src/api/java/appeng/api/networking/IGridHelper.java index b79b6a76b..31e9aacd0 100644 --- a/src/api/java/appeng/api/networking/IGridHelper.java +++ b/src/api/java/appeng/api/networking/IGridHelper.java @@ -23,46 +23,45 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import appeng.api.exceptions.FailedConnectionException; - /** - * A helper responsible for creating new {@link IGridNode}, {@link IGridConnection} or potentially similar tasks. + * A helper responsible for creating new {@link IGridNode}, + * {@link IGridConnection} or potentially similar tasks. * * @author yueh * @version rv5 * @since rv5 */ -public interface IGridHelper -{ +public interface IGridHelper { - /** - * Create a grid node for your {@link IGridHost} - * - * The passed {@link IGridBlock} represents the definition for properties like connectable sides. - * Refer to its documentation for further details. - * - * @param block grid block - * - * @return grid node of block - */ - @Nonnull - IGridNode createGridNode( @Nonnull IGridBlock block ); + /** + * Create a grid node for your {@link IGridHost} + * + * The passed {@link IGridBlock} represents the definition for properties like + * connectable sides. Refer to its documentation for further details. + * + * @param block grid block + * + * @return grid node of block + */ + @Nonnull + IGridNode createGridNode(@Nonnull IGridBlock block); - /** - * Create a direct connection between two {@link IGridNode}. - * - * This will be considered as having a distance of 1, regardless of the location of both nodes. - * - * @param a to be connected gridnode - * @param b to be connected gridnode - * - * @throws appeng.api.exceptions.FailedConnectionException - */ - @Nonnull - IGridConnection createGridConnection( @Nonnull IGridNode a, @Nonnull IGridNode b ) throws FailedConnectionException; + /** + * Create a direct connection between two {@link IGridNode}. + * + * This will be considered as having a distance of 1, regardless of the location + * of both nodes. + * + * @param a to be connected gridnode + * @param b to be connected gridnode + * + * @throws appeng.api.exceptions.FailedConnectionException + */ + @Nonnull + IGridConnection createGridConnection(@Nonnull IGridNode a, @Nonnull IGridNode b) throws FailedConnectionException; } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/IGridHost.java b/src/api/java/appeng/api/networking/IGridHost.java index 3738d778b..17e5f456c 100644 --- a/src/api/java/appeng/api/networking/IGridHost.java +++ b/src/api/java/appeng/api/networking/IGridHost.java @@ -23,7 +23,6 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -33,39 +32,38 @@ import appeng.api.parts.IPart; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; - /** - * Implement to create a networked {@link TileEntity} or {@link IPart} must - * be implemented for a part, or tile entity to become part of a grid. + * Implement to create a networked {@link TileEntity} or {@link IPart} must be + * implemented for a part, or tile entity to become part of a grid. */ -public interface IGridHost -{ +public interface IGridHost { - /** - * get the grid node for a particular side of a block, you can return null, - * by returning a valid node later and calling updateState, you can join the - * Grid when your block is ready. - * - * @param dir feel free to ignore this, most blocks will use the same node - * for every side. - * - * @return a new IGridNode, create these with - * AEApi.INSTANCE().createGridNode( MyIGridBlock ) - */ - @Nullable - IGridNode getGridNode( @Nonnull AEPartLocation dir ); + /** + * get the grid node for a particular side of a block, you can return null, by + * returning a valid node later and calling updateState, you can join the Grid + * when your block is ready. + * + * @param dir feel free to ignore this, most blocks will use the same node for + * every side. + * + * @return a new IGridNode, create these with AEApi.INSTANCE().createGridNode( + * MyIGridBlock ) + */ + @Nullable + IGridNode getGridNode(@Nonnull AEPartLocation dir); - /** - * Determines how cables render when they connect to this block. Priority is - * Smart > Covered > Glass - * - * @param dir direction - */ - @Nonnull - AECableType getCableConnectionType( @Nonnull AEPartLocation dir ); + /** + * Determines how cables render when they connect to this block. Priority is + * Smart > Covered > Glass + * + * @param dir direction + */ + @Nonnull + AECableType getCableConnectionType(@Nonnull AEPartLocation dir); - /** - * break this host, its violating security rules, just break your block, or part. - */ - void securityBreak(); + /** + * break this host, its violating security rules, just break your block, or + * part. + */ + void securityBreak(); } diff --git a/src/api/java/appeng/api/networking/IGridMultiblock.java b/src/api/java/appeng/api/networking/IGridMultiblock.java index f99b1b174..b8b17cb7c 100644 --- a/src/api/java/appeng/api/networking/IGridMultiblock.java +++ b/src/api/java/appeng/api/networking/IGridMultiblock.java @@ -23,25 +23,25 @@ package appeng.api.networking; - import java.util.Iterator; import javax.annotation.Nonnull; - /** - * 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 - * set. This means your entire Multiblock can work with a single channel, instead of one channel per block. + * 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 set. This means your entire Multiblock can work with a single + * channel, instead of one channel per block. */ -public interface IGridMultiblock extends IGridBlock -{ +public interface IGridMultiblock extends IGridBlock { - /** - * Used to acquire a list of all nodes that are part of the multiblock. - * - * @return an iterator that will iterate all the nodes for the multiblock. ( read-only iterator expected. ) - */ - @Nonnull - Iterator getMultiblockNodes(); + /** + * Used to acquire a list of all nodes that are part of the multiblock. + * + * @return an iterator that will iterate all the nodes for the multiblock. ( + * read-only iterator expected. ) + */ + @Nonnull + Iterator getMultiblockNodes(); } diff --git a/src/api/java/appeng/api/networking/IGridNode.java b/src/api/java/appeng/api/networking/IGridNode.java index 1ec23bb3d..f29bba536 100644 --- a/src/api/java/appeng/api/networking/IGridNode.java +++ b/src/api/java/appeng/api/networking/IGridNode.java @@ -23,7 +23,6 @@ package appeng.api.networking; - import java.util.EnumSet; import javax.annotation.Nonnull; @@ -36,7 +35,6 @@ import appeng.api.IAppEngApi; import appeng.api.util.AEPartLocation; import appeng.api.util.IReadOnlyCollection; - /** * Gives you a view into your Nodes connections and information. * @@ -44,130 +42,134 @@ import appeng.api.util.IReadOnlyCollection; * * Don't Implement; Acquire from {@link IAppEngApi}.createGridNode */ -public interface IGridNode -{ +public interface IGridNode { - /** - * lets you walk the grid stating at the current node using a IGridVisitor, generally not needed, please use only if - * required. - * - * @param visitor visitor - */ - void beginVisit( @Nonnull IGridVisitor visitor ); + /** + * lets you walk the grid stating at the current node using a IGridVisitor, + * generally not needed, please use only if required. + * + * @param visitor visitor + */ + void beginVisit(@Nonnull IGridVisitor visitor); - /** - * inform the node that your IGridBlock has changed its internal state, and force the node to update. - * - * ALWAYS make sure that your tile entity is in the world, and has its node properly saved to be returned from the - * host before updating state, - * - * If your entity is not in the world, or if you IGridHost returns a different node for the same side you will - * likely crash the game. - */ - void updateState(); + /** + * inform the node that your IGridBlock has changed its internal state, and + * force the node to update. + * + * ALWAYS make sure that your tile entity is in the world, and has its node + * properly saved to be returned from the host before updating state, + * + * If your entity is not in the world, or if you IGridHost returns a different + * node for the same side you will likely crash the game. + */ + void updateState(); - /** - * get the machine represented by the node. - * - * @return grid host - */ - @Nonnull - IGridHost getMachine(); + /** + * get the machine represented by the node. + * + * @return grid host + */ + @Nonnull + IGridHost getMachine(); - /** - * get the grid for the node, this can change at a moments notice. - * - * @return grid - */ - @Nonnull - IGrid getGrid(); + /** + * get the grid for the node, this can change at a moments notice. + * + * @return grid + */ + @Nonnull + IGrid getGrid(); - /** - * By destroying your node, you destroy any connections, and its existence in the grid, use in invalidate, or - * onChunkUnload - */ - void destroy(); + /** + * By destroying your node, you destroy any connections, and its existence in + * the grid, use in invalidate, or onChunkUnload + */ + void destroy(); - /** - * @return the world the node is located in - */ - @Nonnull - IWorld getWorld(); + /** + * @return the world the node is located in + */ + @Nonnull + IWorld getWorld(); - /** - * @return a set of the connected sides, INTERNAL represents an invisible connection - */ - @Nonnull - EnumSet getConnectedSides(); + /** + * @return a set of the connected sides, INTERNAL represents an invisible + * connection + */ + @Nonnull + EnumSet getConnectedSides(); - /** - * lets you iterate a nodes connections - * - * @return grid connections - */ - @Nonnull - IReadOnlyCollection getConnections(); + /** + * lets you iterate a nodes connections + * + * @return grid connections + */ + @Nonnull + IReadOnlyCollection getConnections(); - /** - * @return the IGridBlock for this node - */ - @Nonnull - IGridBlock getGridBlock(); + /** + * @return the IGridBlock for this node + */ + @Nonnull + IGridBlock getGridBlock(); - /** - * Reflects the networks status, returns true only if the network is powered, and the network is not booting, this - * also takes into account channels. - * - * @return true if is Network node active, and participating. - */ - boolean isActive(); + /** + * Reflects the networks status, returns true only if the network is powered, + * and the network is not booting, this also takes into account channels. + * + * @return true if is Network node active, and participating. + */ + boolean isActive(); - /** - * this should be called for each node you create, if you have a nodeData compound to load from, you can store all - * your nods on a single compound using name. - * - * Important: You must call this before updateState. - * - * @param name nbt name - * @param nodeData to be loaded data - */ - void loadFromNBT( @Nonnull String name, @Nonnull CompoundNBT nodeData ); + /** + * this should be called for each node you create, if you have a nodeData + * compound to load from, you can store all your nods on a single compound using + * name. + * + * Important: You must call this before updateState. + * + * @param name nbt name + * @param nodeData to be loaded data + */ + void loadFromNBT(@Nonnull String name, @Nonnull CompoundNBT nodeData); - /** - * this should be called for each node you maintain, you can save all your nodes to the same tag with different - * names, if you fail to complete the load / save procedure, network state may be lost between game load/saves. - * - * @param name nbt name - * @param nodeData to be saved data - */ - void saveToNBT( @Nonnull String name, @Nonnull CompoundNBT nodeData ); + /** + * this should be called for each node you maintain, you can save all your nodes + * to the same tag with different names, if you fail to complete the load / save + * procedure, network state may be lost between game load/saves. + * + * @param name nbt name + * @param nodeData to be saved data + */ + void saveToNBT(@Nonnull String name, @Nonnull CompoundNBT nodeData); - /** - * @return if the node's channel requirements are currently met, use this for display purposes, use isActive for - * status. - */ - boolean meetsChannelRequirements(); + /** + * @return if the node's channel requirements are currently met, use this for + * display purposes, use isActive for status. + */ + boolean meetsChannelRequirements(); - /** - * see if this node has a certain flag - * - * @param flag flags - * - * @return true if has flag - */ - boolean hasFlag( @Nonnull GridFlags flag ); + /** + * see if this node has a certain flag + * + * @param flag flags + * + * @return true if has flag + */ + boolean hasFlag(@Nonnull GridFlags flag); - /** - * @return the ownerID this represents the person who placed the node. - */ - int getPlayerID(); + /** + * @return the ownerID this represents the person who placed the node. + */ + int getPlayerID(); - /** - * tell the node who was responsible for placing it, failure to do this may result in in-compatibility with the - * security system. Called instead of loadFromNBT when initially placed, once set never required again, the value is - * saved with the Node NBT. - * - * @param playerID new player id - */ - void setPlayerID( int playerID ); + /** + * tell the node who was responsible for placing it, failure to do this may + * result in in-compatibility with the security system. Called instead of + * loadFromNBT when initially placed, once set never required again, the value + * is saved with the Node NBT. + * + * @param playerID new player id + */ + void setPlayerID(int playerID); } diff --git a/src/api/java/appeng/api/networking/IGridStorage.java b/src/api/java/appeng/api/networking/IGridStorage.java index f694ab19c..3f1b08a37 100644 --- a/src/api/java/appeng/api/networking/IGridStorage.java +++ b/src/api/java/appeng/api/networking/IGridStorage.java @@ -23,23 +23,20 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import net.minecraft.nbt.CompoundNBT; +public interface IGridStorage { -public interface IGridStorage -{ + /** + * @return an CompoundNBT that can be read, and written too. + */ + @Nonnull + CompoundNBT dataObject(); - /** - * @return an CompoundNBT that can be read, and written too. - */ - @Nonnull - CompoundNBT dataObject(); - - /** - * @return the id for this grid storage object, used internally - */ - long getID(); + /** + * @return the id for this grid storage object, used internally + */ + long getID(); } diff --git a/src/api/java/appeng/api/networking/IGridVisitor.java b/src/api/java/appeng/api/networking/IGridVisitor.java index d9386fdea..37d887ced 100644 --- a/src/api/java/appeng/api/networking/IGridVisitor.java +++ b/src/api/java/appeng/api/networking/IGridVisitor.java @@ -23,24 +23,22 @@ package appeng.api.networking; - import javax.annotation.Nonnull; - /** * Simple Visitor pattern access to network nodes. */ -public interface IGridVisitor -{ +public interface IGridVisitor { - /** - * Called for each node on the network. - * - * By returning false your informing the host to stop visiting nodes beyond the current node. - * - * @param n the current node. - * - * @return true to continue visiting nodes beyond this node. - */ - boolean visitNode( @Nonnull IGridNode n ); + /** + * Called for each node on the network. + * + * By returning false your informing the host to stop visiting nodes beyond the + * current node. + * + * @param n the current node. + * + * @return true to continue visiting nodes beyond this node. + */ + boolean visitNode(@Nonnull IGridNode n); } diff --git a/src/api/java/appeng/api/networking/IMachineSet.java b/src/api/java/appeng/api/networking/IMachineSet.java index 5d19ee18a..c86209ba5 100644 --- a/src/api/java/appeng/api/networking/IMachineSet.java +++ b/src/api/java/appeng/api/networking/IMachineSet.java @@ -23,18 +23,15 @@ package appeng.api.networking; - import javax.annotation.Nonnull; import appeng.api.util.IReadOnlyCollection; +public interface IMachineSet extends IReadOnlyCollection { -public interface IMachineSet extends IReadOnlyCollection -{ - - /** - * @return the machine class for this set. - */ - @Nonnull - Class getMachineClass(); + /** + * @return the machine class for this set. + */ + @Nonnull + 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 c84c275d7..6ccab4de7 100644 --- a/src/api/java/appeng/api/networking/crafting/CraftingItemList.java +++ b/src/api/java/appeng/api/networking/crafting/CraftingItemList.java @@ -23,8 +23,6 @@ package appeng.api.networking.crafting; - -public enum CraftingItemList -{ - ALL, STORAGE, ACTIVE, PENDING +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 b43366959..cdb52c20a 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java @@ -23,38 +23,36 @@ package appeng.api.networking.crafting; +import net.minecraft.util.text.ITextComponent; import appeng.api.networking.security.IActionSource; import appeng.api.networking.storage.IBaseMonitor; import appeng.api.storage.data.IAEItemStack; -import net.minecraft.util.text.ITextComponent; +public interface ICraftingCPU extends IBaseMonitor { -public interface ICraftingCPU extends IBaseMonitor -{ + /** + * @return true if the CPU currently has a job. + */ + boolean isBusy(); - /** - * @return true if the CPU currently has a job. - */ - boolean isBusy(); + /** + * @return the action source for the CPU. + */ + IActionSource getActionSource(); - /** - * @return the action source for the CPU. - */ - IActionSource getActionSource(); + /** + * @return the available storage in bytes + */ + long getAvailableStorage(); - /** - * @return the available storage in bytes - */ - long getAvailableStorage(); + /** + * @return the number of co-processors in the CPU. + */ + int getCoProcessors(); - /** - * @return the number of co-processors in the CPU. - */ - int getCoProcessors(); - - /** - * @return a null or the name of the cpu. - */ - ITextComponent getName(); + /** + * @return a null or the name of the cpu. + */ + ITextComponent getName(); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java b/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java index f86780b55..0d770f1e9 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java @@ -23,17 +23,14 @@ package appeng.api.networking.crafting; - import javax.annotation.Nonnull; +public interface ICraftingCallback { -public interface ICraftingCallback -{ - - /** - * this call back is synchronized with the world you passed. - * - * @param job - final job - */ - void calculationComplete( @Nonnull ICraftingJob job ); + /** + * this call back is synchronized with the world you passed. + * + * @param job - final job + */ + void calculationComplete(@Nonnull ICraftingJob job); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java b/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java index a0e32a434..16198f1ce 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java @@ -23,7 +23,6 @@ package appeng.api.networking.crafting; - import java.util.concurrent.Future; import com.google.common.collect.ImmutableCollection; @@ -36,81 +35,87 @@ import appeng.api.networking.IGridCache; import appeng.api.networking.security.IActionSource; import appeng.api.storage.data.IAEItemStack; +public interface ICraftingGrid extends IGridCache { -public interface ICraftingGrid extends IGridCache -{ + /** + * @param whatToCraft requested craft + * @param world crafting world + * @param slot slot index + * @param details pattern details + * + * @return a collection of crafting patterns for the item in question. + */ + ImmutableCollection getCraftingFor(IAEItemStack whatToCraft, + ICraftingPatternDetails details, int slot, World world); - /** - * @param whatToCraft requested craft - * @param world crafting world - * @param slot slot index - * @param details pattern details - * - * @return a collection of crafting patterns for the item in question. - */ - ImmutableCollection getCraftingFor( IAEItemStack whatToCraft, ICraftingPatternDetails details, int slot, World world ); + /** + * Begin calculating a crafting job. + * + * @param world crafting world + * @param grid network + * @param actionSrc source + * @param craftWhat result + * @param callback callback -- optional + * + * @return a future which will at an undetermined point in the future get you + * the {@link ICraftingJob} do not wait on this, your be waiting + * forever. + */ + Future beginCraftingJob(World world, IGrid grid, IActionSource actionSrc, IAEItemStack craftWhat, + ICraftingCallback callback); - /** - * Begin calculating a crafting job. - * - * @param world crafting world - * @param grid network - * @param actionSrc source - * @param craftWhat result - * @param callback callback - * -- optional - * - * @return a future which will at an undetermined point in the future get you the {@link ICraftingJob} do not wait - * on this, your be waiting forever. - */ - Future beginCraftingJob( World world, IGrid grid, IActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback ); + /** + * Submit the job to the Crafting system for processing. + * + * @param job - the crafting job from beginCraftingJob + * @param requestingMachine - a machine if its being requested via automation, + * may be null. + * @param target - can be null + * @param prioritizePower - if cpu is null, this determine if the system + * should prioritize power, or if it should find the + * lower end cpus, automatic processes generally should + * pick lower end cpus. + * @param src - the action source to use when starting the job, + * this will be used for extracting items, should + * usually be the same as the one provided to + * beginCraftingJob. + * + * @return null ( if failed ) or an {@link ICraftingLink} other wise, if you + * send requestingMachine you need to properly keep track of this and + * handle the nbt saving and loading of the object as well as the + * {@link ICraftingRequester} methods. if you send null, this object + * should be discarded after verifying the return state. + */ + ICraftingLink submitJob(ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, + boolean prioritizePower, IActionSource src); - /** - * Submit the job to the Crafting system for processing. - * - * @param job - the crafting job from beginCraftingJob - * @param requestingMachine - a machine if its being requested via automation, may be null. - * @param target - can be null - * @param prioritizePower - if cpu is null, this determine if the system should prioritize power, or if it should - * find the lower - * end cpus, automatic processes generally should pick lower end cpus. - * @param src - the action source to use when starting the job, this will be used for extracting items, should - * usually be the same as the one provided to beginCraftingJob. - * - * @return null ( if failed ) or an {@link ICraftingLink} other wise, if you send requestingMachine you need to - * properly keep track of this and handle the nbt saving and loading of the object as well as the - * {@link ICraftingRequester} methods. if you send null, this object should be discarded after verifying the - * return state. - */ - ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, boolean prioritizePower, IActionSource src ); + /** + * @return list of all the crafting cpus on the grid + */ + ImmutableSet getCpus(); - /** - * @return list of all the crafting cpus on the grid - */ - ImmutableSet getCpus(); + /** + * @param what to be requested item + * + * @return true if the item can be requested via a crafting emitter. + */ + boolean canEmitFor(IAEItemStack what); - /** - * @param what to be requested item - * - * @return true if the item can be requested via a crafting emitter. - */ - boolean canEmitFor( IAEItemStack what ); + /** + * is this item being crafted? + * + * @param what item being crafted + * + * @return true if it is being crafting + */ + boolean isRequesting(IAEItemStack what); - /** - * is this item being crafted? - * - * @param what item being crafted - * - * @return true if it is being crafting - */ - boolean isRequesting( IAEItemStack what ); - - /** - * The total amount being requested across all crafting cpus of a grid. - * - * @param what item being requested, ignores stacksize - * - * @return The total amount being requested. - */ - long requesting( IAEItemStack what ); + /** + * The total amount being requested across all crafting cpus of a grid. + * + * @param what item being requested, ignores stacksize + * + * @return The total amount being requested. + */ + long requesting(IAEItemStack what); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingJob.java b/src/api/java/appeng/api/networking/crafting/ICraftingJob.java index 559012303..220dcd4c0 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingJob.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingJob.java @@ -23,35 +23,32 @@ package appeng.api.networking.crafting; - import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +public interface ICraftingJob { -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. + */ + boolean isSimulation(); - /** - * @return if this job is a simulation, simulations cannot be submitted and only represent 1 possible future - * crafting job with fake items. - */ - boolean isSimulation(); + /** + * @return total number of bytes to process this job. + */ + long getByteTotal(); - /** - * @return total number of bytes to process this job. - */ - long getByteTotal(); + /** + * Populates the plan list with stack size, and requestable values that + * represent the stored, and crafting job contents respectively. + * + * @param plan plan + */ + void populatePlan(IItemList plan); - /** - * Populates the plan list with stack size, and requestable values that represent the stored, and crafting job - * contents respectively. - * - * @param plan plan - */ - void populatePlan( IItemList plan ); - - /** - * @return the final output of the job. - */ - IAEItemStack getOutput(); + /** + * @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 7b3dd8649..4a6a21c9b 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingLink.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingLink.java @@ -23,42 +23,40 @@ package appeng.api.networking.crafting; - import net.minecraft.nbt.CompoundNBT; +public interface ICraftingLink { -public interface ICraftingLink -{ + /** + * @return true if the job was canceled. + */ + boolean isCanceled(); - /** - * @return true if the job was canceled. - */ - boolean isCanceled(); + /** + * @return true if the job was completed. + */ + boolean isDone(); - /** - * @return true if the job was completed. - */ - boolean isDone(); + /** + * cancels the job. + */ + void cancel(); - /** - * cancels the job. - */ - void cancel(); + /** + * @return true if this link was generated without a requesting machine, such as + * a player generated request. + */ + boolean isStandalone(); - /** - * @return true if this link was generated without a requesting machine, such as a player generated request. - */ - boolean isStandalone(); + /** + * write the link to an NBT Tag + * + * @param tag to be written data + */ + void writeToNBT(CompoundNBT tag); - /** - * write the link to an NBT Tag - * - * @param tag to be written data - */ - void writeToNBT( CompoundNBT tag ); - - /** - * @return the crafting ID for this link. - */ - String getCraftingID(); + /** + * @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 f96d25631..d6bd9ecec 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java @@ -23,29 +23,28 @@ package appeng.api.networking.crafting; - import net.minecraft.inventory.CraftingInventory; - /** - * A place to send Items for crafting purposes, this is considered part of AE's External crafting system. + * A place to send Items for crafting purposes, this is considered part of AE's + * External crafting system. */ -public interface ICraftingMedium -{ +public interface ICraftingMedium { - /** - * instruct a medium to create the item represented by the pattern+details, the items on the table, and where if - * possible the output should be directed. - * - * @param patternDetails details - * @param table crafting table - * - * @return if the pattern was successfully pushed. - */ - boolean pushPattern( ICraftingPatternDetails patternDetails, CraftingInventory table ); + /** + * instruct a medium to create the item represented by the pattern+details, the + * items on the table, and where if possible the output should be directed. + * + * @param patternDetails details + * @param table crafting table + * + * @return if the pattern was successfully pushed. + */ + boolean pushPattern(ICraftingPatternDetails patternDetails, CraftingInventory table); - /** - * @return if this is false, the crafting engine will refuse to send new jobs to this medium. - */ - boolean isBusy(); + /** + * @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 958008467..795c5830b 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java @@ -23,7 +23,6 @@ package appeng.api.networking.crafting; - import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -31,80 +30,79 @@ import net.minecraft.world.World; import appeng.api.implementations.ICraftingPatternItem; import appeng.api.storage.data.IAEItemStack; - /** * do not implement provided by {@link ICraftingPatternItem} * * caching this INSTANCE will increase performance of validation and checks. */ -public interface ICraftingPatternDetails -{ +public interface ICraftingPatternDetails { - /** - * @return source item. - */ - ItemStack getPattern(); + /** + * @return source item. + */ + ItemStack getPattern(); - /** - * @param slotIndex specific slot index - * @param itemStack item in slot - * @param world crafting world - * - * @return if an item can be used in the specific slot for this pattern. - */ - boolean isValidItemForSlot( int slotIndex, ItemStack itemStack, World world ); + /** + * @param slotIndex specific slot index + * @param itemStack item in slot + * @param world crafting world + * + * @return if an item can be used in the specific slot for this pattern. + */ + boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world); - /** - * @return if this pattern is a crafting pattern ( work bench ) - */ - boolean isCraftable(); + /** + * @return if this pattern is a crafting pattern ( work bench ) + */ + boolean isCraftable(); - /** - * @return a list of the inputs, will include nulls. - */ - IAEItemStack[] getInputs(); + /** + * @return a list of the inputs, will include nulls. + */ + IAEItemStack[] getInputs(); - /** - * @return a list of the inputs, will be clean - */ - IAEItemStack[] getCondensedInputs(); + /** + * @return a list of the inputs, will be clean + */ + IAEItemStack[] getCondensedInputs(); - /** - * @return a list of the outputs, will be clean - */ - IAEItemStack[] getCondensedOutputs(); + /** + * @return a list of the outputs, will be clean + */ + IAEItemStack[] getCondensedOutputs(); - /** - * @return a list of the outputs, will include nulls. - */ - IAEItemStack[] getOutputs(); + /** + * @return a list of the outputs, will include nulls. + */ + IAEItemStack[] getOutputs(); - /** - * @return if this pattern is enabled to support substitutions. - */ - boolean canSubstitute(); + /** + * @return if this pattern is enabled to support substitutions. + */ + boolean canSubstitute(); - /** - * Allow using this INSTANCE of the pattern details to preform the crafting action with performance enhancements. - * - * @param craftingInv inventory - * @param world crafting world - * - * @return the crafted ( work bench ) item. - */ - ItemStack getOutput( CraftingInventory craftingInv, World world ); + /** + * Allow using this INSTANCE of the pattern details to preform the crafting + * action with performance enhancements. + * + * @param craftingInv inventory + * @param world crafting world + * + * @return the crafted ( work bench ) item. + */ + ItemStack getOutput(CraftingInventory craftingInv, World world); - /** - * Get the priority of this pattern - * - * @return the priority of this pattern - */ - int getPriority(); + /** + * Get the priority of this pattern + * + * @return the priority of this pattern + */ + int getPriority(); - /** - * Set the priority the of this pattern. - * - * @param priority priority of pattern - */ - void setPriority( int priority ); + /** + * Set the priority the of this pattern. + * + * @param priority priority of pattern + */ + void setPriority(int priority); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java b/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java index 79f89d448..890c5656f 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java @@ -23,21 +23,18 @@ 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. + * Allows a IGridHost to provide crafting patterns to the network, post a + * {@link MENetworkCraftingPatternChange} to tell AE2 to update. */ -public interface ICraftingProvider extends ICraftingMedium -{ +public interface ICraftingProvider extends ICraftingMedium { - /** - * called when the network is looking for possible crafting jobs. - * - * @param craftingTracker crafting helper - */ - void provideCrafting( ICraftingProviderHelper craftingTracker ); + /** + * called when the network is looking for possible crafting jobs. + * + * @param craftingTracker crafting helper + */ + 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 ba666de9b..00efcc1ca 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java @@ -23,23 +23,21 @@ package appeng.api.networking.crafting; - import appeng.api.storage.data.IAEItemStack; - /** - * Passed to a ICraftingProvider as a interface to manipulate the available crafting jobs. + * Passed to a ICraftingProvider as a interface to manipulate the available + * crafting jobs. */ -public interface ICraftingProviderHelper -{ +public interface ICraftingProviderHelper { - /** - * Add new Pattern to AE's crafting cache. - */ - void addCraftingOption( ICraftingMedium medium, ICraftingPatternDetails api ); + /** + * Add new Pattern to AE's crafting cache. + */ + void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api); - /** - * Set an item can Emitable - */ - void setEmitable( IAEItemStack what ); + /** + * Set an item can Emitable + */ + 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 e1684a124..f970161ad 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java @@ -23,40 +23,38 @@ 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; +public interface ICraftingRequester extends IActionHost { -public interface ICraftingRequester extends IActionHost -{ + /** + * called when the host is added to the grid, and should return all crafting + * links it poses so they can be connected with the cpu that hosts the job. + * + * @return set of jobs, or an empty list. + */ + ImmutableSet getRequestedJobs(); - /** - * called when the host is added to the grid, and should return all crafting links it poses so they can be connected - * with the cpu that hosts the job. - * - * @return set of jobs, or an empty list. - */ - ImmutableSet getRequestedJobs(); + /** + * items are injected into the requester as they are completed, any items that + * cannot be taken, or are unwanted can be returned. + * + * @param items item + * @param mode action mode + * + * @return unwanted item + */ + IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode); - /** - * items are injected into the requester as they are completed, any items that cannot be taken, or are unwanted can - * be returned. - * - * @param items item - * @param mode action mode - * - * @return unwanted item - */ - IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode ); - - /** - * called when the job changes from in progress, to either complete, or canceled. - * - * after this call the crafting link is "dead" and should be discarded. - */ - void jobStateChange( ICraftingLink link ); + /** + * called when the job changes from in progress, to either complete, or + * canceled. + * + * after this call the crafting link is "dead" and should be discarded. + */ + void jobStateChange(ICraftingLink link); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java b/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java index 6ecf79ade..b4c6c680d 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java @@ -23,37 +23,34 @@ package appeng.api.networking.crafting; - import appeng.api.storage.data.IAEStack; - /** * DO NOT IMPLEMENT. * * Will be injected when adding an {@link ICraftingWatcherHost} to a grid. */ -public interface ICraftingWatcher -{ - /** - * Add a specific {@link IAEStack} to watch. - * - * Supports multiple values, duplicate ones will not be added. - * - * @param stack - * @return true, if successfully added. - */ - boolean add( IAEStack stack ); +public interface ICraftingWatcher { + /** + * Add a specific {@link IAEStack} to watch. + * + * Supports multiple values, duplicate ones will not be added. + * + * @param stack + * @return true, if successfully added. + */ + boolean add(IAEStack stack); - /** - * Remove a specific {@link IAEStack} from the watcher. - * - * @param stack - * @return true, if successfully removed. - */ - boolean remove( IAEStack stack ); + /** + * Remove a specific {@link IAEStack} from the watcher. + * + * @param stack + * @return true, if successfully removed. + */ + boolean remove(IAEStack stack); - /** - * Removes all watched stacks and resets the watcher to a clean state. - */ - void reset(); + /** + * Removes all watched stacks and resets the watcher to a clean state. + */ + void reset(); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java b/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java index a18f4aa91..eb31e56b0 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java @@ -23,26 +23,24 @@ package appeng.api.networking.crafting; - import appeng.api.storage.data.IAEItemStack; +public interface ICraftingWatcherHost { -public interface ICraftingWatcherHost -{ + /** + * provides the ICraftingWatcher for this host, for the current network, is + * called when the hot changes networks. You do not need to clear your old + * watcher, its already been removed by the time this gets called. + * + * @param newWatcher crafting watcher for this host + */ + void updateWatcher(ICraftingWatcher newWatcher); - /** - * provides the ICraftingWatcher for this host, for the current network, is called when the hot changes networks. - * You do not need to clear your old watcher, its already been removed by the time this gets called. - * - * @param newWatcher crafting watcher for this host - */ - void updateWatcher( ICraftingWatcher newWatcher ); - - /** - * Called when a crafting status changes. - * - * @param craftingGrid current crafting grid - * @param what change - */ - void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what ); + /** + * Called when a crafting status changes. + * + * @param craftingGrid current crafting grid + * @param what change + */ + void onRequestChange(ICraftingGrid craftingGrid, IAEItemStack what); } diff --git a/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java b/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java index 30220d9b8..177cd6998 100644 --- a/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java +++ b/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java @@ -23,52 +23,52 @@ package appeng.api.networking.energy; - import javax.annotation.Nonnull; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; - /** - * Used to access information about AE's various power accepting blocks for monitoring purposes. + * Used to access information about AE's various power accepting blocks for + * monitoring purposes. */ -public interface IAEPowerStorage extends IEnergySource -{ +public interface IAEPowerStorage extends IEnergySource { - /** - * Inject amt, power into the device, it will store what it can, and return the amount unable to be stored. - * - * @param amt to be injected amount - * @param mode action mode - * - * @return amount of power which was unable to be stored - */ - double injectAEPower( double amt, @Nonnull Actionable mode ); + /** + * Inject amt, power into the device, it will store what it can, and return the + * amount unable to be stored. + * + * @param amt to be injected amount + * @param mode action mode + * + * @return amount of power which was unable to be stored + */ + double injectAEPower(double amt, @Nonnull Actionable mode); - /** - * @return the current maximum power ( this can change :P ) - */ - double getAEMaxPower(); + /** + * @return the current maximum power ( this can change :P ) + */ + double getAEMaxPower(); - /** - * @return the current AE Power Level, this may exceed getMEMaxPower() - */ - double getAECurrentPower(); + /** + * @return the current AE Power Level, this may exceed getMEMaxPower() + */ + double getAECurrentPower(); - /** - * Checked on network reset to see if your block can be used as a public power storage ( use getPowerFlow to control - * the behavior ) - * - * @return true if it can be used as a public power storage - */ - boolean isAEPublicPowerStorage(); + /** + * Checked on network reset to see if your block can be used as a public power + * storage ( use getPowerFlow to control the behavior ) + * + * @return true if it can be used as a public power storage + */ + boolean isAEPublicPowerStorage(); - /** - * Control the power flow by telling what the network can do, either add? or subtract? or both! - * - * @return access restriction what the network can do - */ - @Nonnull - AccessRestriction getPowerFlow(); + /** + * Control the power flow by telling what the network can do, either add? or + * subtract? or both! + * + * @return access restriction what the network can do + */ + @Nonnull + AccessRestriction getPowerFlow(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/energy/IEnergyGrid.java b/src/api/java/appeng/api/networking/energy/IEnergyGrid.java index fa4efa71b..0e2eca969 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyGrid.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyGrid.java @@ -23,7 +23,6 @@ package appeng.api.networking.energy; - import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -31,85 +30,93 @@ import appeng.api.config.Actionable; import appeng.api.networking.IGridCache; import appeng.api.networking.events.MENetworkPowerStatusChange; - /** * AE's Power system. */ -public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvider -{ +public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvider { - /** - * @return the current calculated idle energy drain each tick, is used internally to drain power for each tick. - */ - @Nonnegative - double getIdlePowerUsage(); + /** + * @return the current calculated idle energy drain each tick, is used + * internally to drain power for each tick. + */ + @Nonnegative + double getIdlePowerUsage(); - /** - * @return the average power drain over the past 10 ticks, includes idle usage during this time, and all use of - * extractPower. - */ - @Nonnegative - double getAvgPowerUsage(); + /** + * @return the average power drain over the past 10 ticks, includes idle usage + * during this time, and all use of extractPower. + */ + @Nonnegative + double getAvgPowerUsage(); - /** - * @return the average energy injected into the system per tick, for the last 10 ticks. - */ - @Nonnegative - double getAvgPowerInjection(); + /** + * @return the average energy injected into the system per tick, for the last 10 + * ticks. + */ + @Nonnegative + double getAvgPowerInjection(); - /** - * AE maintains an idle draw of power separate from active power draw, it condenses this into a single operation - * that determines the networks "powered state" if the network is considered off-line, your machines should not - * function. - * - * {@link MENetworkPowerStatusChange} events are posted when this value changes if you need to be notified of the - * change, most machines can simply test the value when they operate. - * - * @return if the network is powered or not. - */ - boolean isNetworkPowered(); + /** + * AE maintains an idle draw of power separate from active power draw, it + * condenses this into a single operation that determines the networks "powered + * state" if the network is considered off-line, your machines should not + * function. + * + * {@link MENetworkPowerStatusChange} events are posted when this value changes + * if you need to be notified of the change, most machines can simply test the + * value when they operate. + * + * @return if the network is powered or not. + */ + boolean isNetworkPowered(); - /** - * AE will accept any power, and store it, to maintain sanity please don't send more then 10,000 at a time. - * - * IMPORTANT: Network power knows no bounds, for less spamy power flow, networks can store more then their allotted - * storage, however, it should be kept to a minimum, to help with this, this method returns the networks current - * OVERFLOW, this is not energy you can store some where else, its already stored in the network, you can extract it - * if you want, however it it owned by the network, this is different then IAEEnergyStore - * - * Another important note, is that if a network that had overflow is deleted, its power is gone, this is one of the - * reasons why keeping overflow to a minimum is important. - * - * @param amt power to inject into the network - * @param mode should the action be simulated or performed? - * - * @return the amount of power that the network has OVER the limit. - */ - @Nonnegative - double injectPower( @Nonnegative double amt, @Nonnull Actionable mode ); + /** + * AE will accept any power, and store it, to maintain sanity please don't send + * more then 10,000 at a time. + * + * IMPORTANT: Network power knows no bounds, for less spamy power flow, networks + * can store more then their allotted storage, however, it should be kept to a + * minimum, to help with this, this method returns the networks current + * OVERFLOW, this is not energy you can store some where else, its already + * stored in the network, you can extract it if you want, however it it owned by + * the network, this is different then IAEEnergyStore + * + * Another important note, is that if a network that had overflow is deleted, + * its power is gone, this is one of the reasons why keeping overflow to a + * minimum is important. + * + * @param amt power to inject into the network + * @param mode should the action be simulated or performed? + * + * @return the amount of power that the network has OVER the limit. + */ + @Nonnegative + double injectPower(@Nonnegative double amt, @Nonnull Actionable mode); - /** - * this is should be considered an estimate, and not relied upon for real calculations. - * - * @return estimated available power. - */ - @Nonnegative - double getStoredPower(); + /** + * this is should be considered an estimate, and not relied upon for real + * calculations. + * + * @return estimated available power. + */ + @Nonnegative + double getStoredPower(); - /** - * this is should be considered an estimate, and not relied upon for real calculations. - * - * @return estimated available power. - */ - @Nonnegative - double getMaxStoredPower(); + /** + * this is should be considered an estimate, and not relied upon for real + * calculations. + * + * @return estimated available power. + */ + @Nonnegative + double getMaxStoredPower(); - /** - * Calculation will be capped at maxRequired, this improves performance by limiting the number of nodes needed to - * calculate the demand. - * - * @return Amount of power required to charge the grid, in AE. - */ - @Nonnegative - double getEnergyDemand( @Nonnegative double maxRequired ); + /** + * Calculation will be capped at maxRequired, this improves performance by + * limiting the number of nodes needed to calculate the demand. + * + * @return Amount of power required to charge the grid, in AE. + */ + @Nonnegative + double getEnergyDemand(@Nonnegative double maxRequired); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java b/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java index 37add40b3..572014ff8 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java @@ -23,7 +23,6 @@ package appeng.api.networking.energy; - import java.util.Collection; import javax.annotation.Nonnegative; @@ -31,98 +30,98 @@ import javax.annotation.Nonnull; import appeng.api.config.Actionable; - /** * internal use only. */ -public interface IEnergyGridProvider -{ - /** - * internal use only - * - * Can return a list of providers behind the current. - * - * An example would be something acting as proxy between different {@link IEnergyGrid}s. - * - * This can contain duplicate entries, AE will ensure that each provider is only visited once. - * - * internal use only - */ - @Nonnull - Collection providers(); +public interface IEnergyGridProvider { + /** + * internal use only + * + * Can return a list of providers behind the current. + * + * An example would be something acting as proxy between different + * {@link IEnergyGrid}s. + * + * This can contain duplicate entries, AE will ensure that each provider is only + * visited once. + * + * internal use only + */ + @Nonnull + Collection providers(); - /** - * internal use only - * - * Extracts the requested amount from the provider. - * - * This should never forward a call to another {@link IEnergyGridProvider}, instead return them via - * {@link IEnergyGridProvider#providers()} - * - * @return the used amount - */ - @Nonnegative - double extractProviderPower( @Nonnegative double amt, @Nonnull Actionable mode ); + /** + * internal use only + * + * Extracts the requested amount from the provider. + * + * This should never forward a call to another {@link IEnergyGridProvider}, + * instead return them via {@link IEnergyGridProvider#providers()} + * + * @return the used amount + */ + @Nonnegative + double extractProviderPower(@Nonnegative double amt, @Nonnull Actionable mode); - /** - * Injects the offered amount into the provider. - * - * This should never forward a call to another {@link IEnergyGridProvider}, instead return them via - * {@link IEnergyGridProvider#providers()} - * - * internal use only - * - * @return the leftover amount - */ - @Nonnegative - double injectProviderPower( @Nonnegative double amt, @Nonnull Actionable mode ); + /** + * Injects the offered amount into the provider. + * + * This should never forward a call to another {@link IEnergyGridProvider}, + * instead return them via {@link IEnergyGridProvider#providers()} + * + * internal use only + * + * @return the leftover amount + */ + @Nonnegative + double injectProviderPower(@Nonnegative double amt, @Nonnull Actionable mode); - /** - * internal use only - * - * Returns the current demand of an provider. - * - * This should never forward a call to another {@link IEnergyGridProvider}, instead return them via - * {@link IEnergyGridProvider#providers()} - * - * - * @param d the max amount offered, the demand should never exceed it. - * @return the total amount demanded - */ - @Nonnegative - double getProviderEnergyDemand( @Nonnegative double d ); + /** + * internal use only + * + * Returns the current demand of an provider. + * + * This should never forward a call to another {@link IEnergyGridProvider}, + * instead return them via {@link IEnergyGridProvider#providers()} + * + * + * @param d the max amount offered, the demand should never exceed it. + * @return the total amount demanded + */ + @Nonnegative + double getProviderEnergyDemand(@Nonnegative double d); - /** - * internal use only - * - * AE currently uses this to enqueue the next visited provider. - * - * There is no guarantee that this works on in a perfect way. - * It can be limited to the returns of the past {@link IEnergyGridProvider#providers()}, but not any future one - * discovered by visiting further providers. - * - * E.g. inject into the the lowest one first or extract from the highest one. - * - * @return the current stored amount. - * - * - */ - @Nonnegative - double getProviderStoredEnergy(); + /** + * internal use only + * + * AE currently uses this to enqueue the next visited provider. + * + * There is no guarantee that this works on in a perfect way. It can be limited + * to the returns of the past {@link IEnergyGridProvider#providers()}, but not + * any future one discovered by visiting further providers. + * + * E.g. inject into the the lowest one first or extract from the highest one. + * + * @return the current stored amount. + * + * + */ + @Nonnegative + double getProviderStoredEnergy(); - /** - * internal use only - * - * AE currently uses this to enqueue the next visited provider. - * - * There is no guarantee that this works on in a perfect way. - * It can be limited to the returns of the past {@link IEnergyGridProvider#providers()}, but not any future one - * discovered by visiting further providers. - * - * E.g. inject into the the lowest one first or extract from the highest one. - * - * @return the maximum amount stored. - */ - @Nonnegative - double getProviderMaxEnergy(); + /** + * internal use only + * + * AE currently uses this to enqueue the next visited provider. + * + * There is no guarantee that this works on in a perfect way. It can be limited + * to the returns of the past {@link IEnergyGridProvider#providers()}, but not + * any future one discovered by visiting further providers. + * + * E.g. inject into the the lowest one first or extract from the highest one. + * + * @return the maximum amount stored. + */ + @Nonnegative + double getProviderMaxEnergy(); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergySource.java b/src/api/java/appeng/api/networking/energy/IEnergySource.java index 45bdbc807..16c219a19 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergySource.java +++ b/src/api/java/appeng/api/networking/energy/IEnergySource.java @@ -23,25 +23,23 @@ package appeng.api.networking.energy; - import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; +public interface IEnergySource { -public interface IEnergySource -{ - - /** - * Extract power from the network. - * - * @param amt extracted power - * @param mode should the action be simulated or performed? - * - * @return returns extracted power. - */ - @Nonnegative - double extractAEPower( @Nonnegative double amt, @Nonnull Actionable mode, @Nonnull PowerMultiplier usePowerMultiplier ); + /** + * Extract power from the network. + * + * @param amt extracted power + * @param mode should the action be simulated or performed? + * + * @return returns extracted power. + */ + @Nonnegative + double extractAEPower(@Nonnegative double amt, @Nonnull Actionable mode, + @Nonnull PowerMultiplier usePowerMultiplier); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java index 809a92e8c..c196f4981 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java @@ -23,38 +23,35 @@ package appeng.api.networking.energy; - import javax.annotation.Nonnegative; - /** * DO NOT IMPLEMENT. * * Will be injected when adding an {@link IEnergyWatcherHost} to a grid. */ -public interface IEnergyWatcher -{ - /** - * Add a specific threshold to watch. - * - * Supports multiple values, duplicate ones will not be added. - * - * @param amount - * @return true, if successfully added. - */ - boolean add( @Nonnegative double amount ); +public interface IEnergyWatcher { + /** + * Add a specific threshold to watch. + * + * Supports multiple values, duplicate ones will not be added. + * + * @param amount + * @return true, if successfully added. + */ + boolean add(@Nonnegative double amount); - /** - * Remove a specific threshold from the watcher. - * - * @param amount - * @return true, if successfully removed. - */ - boolean remove( @Nonnegative double amount ); + /** + * Remove a specific threshold from the watcher. + * + * @param amount + * @return true, if successfully removed. + */ + boolean remove(@Nonnegative double amount); - /** - * Removes all thresholds and resets the watcher to a clean state. - */ - void reset(); + /** + * Removes all thresholds and resets the watcher to a clean state. + */ + void reset(); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java index e9b7c81c2..ad01cba16 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java @@ -23,25 +23,23 @@ package appeng.api.networking.energy; - import javax.annotation.Nonnull; +public interface IEnergyWatcherHost { -public interface IEnergyWatcherHost -{ + /** + * provides the IEnergyWatcher for this host, for the current network, is called + * when the hot changes networks. You do not need to clear your old watcher, its + * already been removed by the time this gets called. + * + * @param newWatcher new watcher + */ + void updateWatcher(@Nonnull IEnergyWatcher newWatcher); - /** - * provides the IEnergyWatcher for this host, for the current network, is called when the hot changes networks. You - * do not need to clear your old watcher, its already been removed by the time this gets called. - * - * @param newWatcher new watcher - */ - void updateWatcher( @Nonnull IEnergyWatcher newWatcher ); - - /** - * Called when a threshold is crossed. - * - * @param energyGrid grid - */ - void onThresholdPass( @Nonnull IEnergyGrid energyGrid ); + /** + * Called when a threshold is crossed. + * + * @param energyGrid grid + */ + void onThresholdPass(@Nonnull IEnergyGrid energyGrid); } diff --git a/src/api/java/appeng/api/networking/events/MENetworkBootingStatusChange.java b/src/api/java/appeng/api/networking/events/MENetworkBootingStatusChange.java index febd98024..1ef9ef16c 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkBootingStatusChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkBootingStatusChange.java @@ -23,17 +23,14 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridNode; - /** - * Posted by the network when the booting status of the network goes up - * or down, the change is reflected via {@link IGridNode}.isActive() + * Posted by the network when the booting status of the network goes up or down, + * the change is reflected via {@link IGridNode}.isActive() * * Note: Most machines just need to check {@link IGridNode}.isActive() */ -public class MENetworkBootingStatusChange extends MENetworkEvent -{ +public class MENetworkBootingStatusChange extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkCellArrayUpdate.java b/src/api/java/appeng/api/networking/events/MENetworkCellArrayUpdate.java index 42cb405f0..434106c1c 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkCellArrayUpdate.java +++ b/src/api/java/appeng/api/networking/events/MENetworkCellArrayUpdate.java @@ -23,7 +23,6 @@ package appeng.api.networking.events; - /** * Posted by storage devices to inform AE to refresh its storage structure. * @@ -33,7 +32,6 @@ package appeng.api.networking.events; * you do not need to send this event when your node is added / removed from the * grid. */ -public class MENetworkCellArrayUpdate extends MENetworkEvent -{ +public class MENetworkCellArrayUpdate extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java b/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java index b86631141..33055d571 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java +++ b/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java @@ -23,21 +23,17 @@ 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. + * Posted by storage devices to inform AE the channel cache that the included + * node has changed its mind about its channel requirements. */ -public class MENetworkChannelChanged extends MENetworkEvent -{ +public class MENetworkChannelChanged extends MENetworkEvent { - public final IGridNode node; + public final IGridNode node; - public MENetworkChannelChanged( final IGridNode n ) - { - this.node = n; - } + public MENetworkChannelChanged(final IGridNode n) { + this.node = n; + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkChannelsChanged.java b/src/api/java/appeng/api/networking/events/MENetworkChannelsChanged.java index cb2566f44..1a9232c1f 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkChannelsChanged.java +++ b/src/api/java/appeng/api/networking/events/MENetworkChannelsChanged.java @@ -23,16 +23,14 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridHost; - /** - * Posted to the {@link IGridHost} when the channels on the node connections are altered. + * Posted to the {@link IGridHost} when the channels on the node connections are + * altered. * * Never posted IGridCaches. */ -public class MENetworkChannelsChanged extends MENetworkEvent -{ +public class MENetworkChannelsChanged extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java b/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java index 040a3d4aa..e0f83c1be 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java @@ -23,13 +23,11 @@ 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 * to not conflicted. */ -public class MENetworkControllerChange extends MENetworkEvent -{ +public class MENetworkControllerChange extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java b/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java index 4a92e28cf..d0ebcf470 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java @@ -23,17 +23,13 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridNode; +public class MENetworkCraftingCpuChange extends MENetworkEvent { -public class MENetworkCraftingCpuChange extends MENetworkEvent -{ + public final IGridNode node; - public final IGridNode node; - - public MENetworkCraftingCpuChange( final IGridNode n ) - { - this.node = n; - } + public MENetworkCraftingCpuChange(final 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 77b6a2e33..f8ecd6e7d 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java @@ -23,20 +23,16 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridNode; import appeng.api.networking.crafting.ICraftingProvider; +public class MENetworkCraftingPatternChange extends MENetworkEvent { -public class MENetworkCraftingPatternChange extends MENetworkEvent -{ + public final ICraftingProvider provider; + public final IGridNode node; - public final ICraftingProvider provider; - public final IGridNode node; - - public MENetworkCraftingPatternChange( final ICraftingProvider p, final IGridNode n ) - { - this.provider = p; - this.node = n; - } + public MENetworkCraftingPatternChange(final ICraftingProvider p, final IGridNode n) { + this.provider = p; + this.node = n; + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkEvent.java b/src/api/java/appeng/api/networking/events/MENetworkEvent.java index 4c50e59de..5b11f1229 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkEvent.java +++ b/src/api/java/appeng/api/networking/events/MENetworkEvent.java @@ -23,56 +23,49 @@ package appeng.api.networking.events; - import appeng.api.networking.IGrid; - /** * Part of AE's Event Bus. * * Posted via {@link IGrid}.postEvent or {@link IGrid}.postEventTo */ -public class MENetworkEvent -{ +public class MENetworkEvent { - private int visited = 0; - private boolean canceled = false; + private int visited = 0; + private boolean canceled = false; - /** - * Call to prevent AE from posting the event to any further objects. - */ - public void cancel() - { - this.canceled = true; - } + /** + * Call to prevent AE from posting the event to any further objects. + */ + public void cancel() { + this.canceled = true; + } - /** - * called by AE after each object is called to cancel any future calls. - * - * @return true to cancel future calls - */ - public boolean isCanceled() - { - return this.canceled; - } + /** + * called by AE after each object is called to cancel any future calls. + * + * @return true to cancel future calls + */ + public boolean isCanceled() { + return this.canceled; + } - /** - * the number of objects that were visited by the event. - * - * @return number of visitors - */ - public int getVisitedObjects() - { - return this.visited; - } + /** + * the number of objects that were visited by the event. + * + * @return number of visitors + */ + public int getVisitedObjects() { + return this.visited; + } - /** - * Called by AE after iterating the event subscribers. - * - * @param v current number of visitors - */ - public void setVisitedObjects( final int v ) - { - this.visited = v; - } + /** + * Called by AE after iterating the event subscribers. + * + * @param v current number of visitors + */ + public void setVisitedObjects(final int v) { + this.visited = v; + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java b/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java index 198f5306f..936174947 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java +++ b/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java @@ -23,19 +23,16 @@ 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 1fddaa8ae..5240e8d79 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java +++ b/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java @@ -23,12 +23,10 @@ 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. */ -public class MENetworkPostCacheConstruction extends MENetworkEvent -{ +public class MENetworkPostCacheConstruction extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkPowerIdleChange.java b/src/api/java/appeng/api/networking/events/MENetworkPowerIdleChange.java index a9000064d..3ca050b3d 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkPowerIdleChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkPowerIdleChange.java @@ -23,24 +23,21 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridNode; - /** * Implementers of a IGridBlock must post this event when your getIdlePowerUsage * starts returning a new value, if you do not post this event the network will * not change the idle draw. * - * you do not need to send this event when your node is added / removed from the grid. + * you do not need to send this event when your node is added / removed from the + * grid. */ -public class MENetworkPowerIdleChange extends MENetworkEvent -{ +public class MENetworkPowerIdleChange extends MENetworkEvent { - public final IGridNode node; + public final IGridNode node; - public MENetworkPowerIdleChange( final IGridNode nodeThatChanged ) - { - this.node = nodeThatChanged; - } + public MENetworkPowerIdleChange(final IGridNode nodeThatChanged) { + this.node = nodeThatChanged; + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkPowerStatusChange.java b/src/api/java/appeng/api/networking/events/MENetworkPowerStatusChange.java index b60bdfe59..f36813903 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkPowerStatusChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkPowerStatusChange.java @@ -23,18 +23,16 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridNode; import appeng.api.networking.energy.IEnergyGrid; - /** * Posted by the network when the power status of the network goes up or down, - * the change is reflected via the {@link IEnergyGrid}.isNetworkPowered() or via {@link IGridNode}.isActive() + * the change is reflected via the {@link IEnergyGrid}.isNetworkPowered() or via + * {@link IGridNode}.isActive() * * Note: Most machines just need to check {@link IGridNode}.isActive() */ -public class MENetworkPowerStatusChange extends MENetworkEvent -{ +public class MENetworkPowerStatusChange extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkPowerStorage.java b/src/api/java/appeng/api/networking/events/MENetworkPowerStorage.java index 0afde8d82..efb580e6c 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkPowerStorage.java +++ b/src/api/java/appeng/api/networking/events/MENetworkPowerStorage.java @@ -23,41 +23,37 @@ package appeng.api.networking.events; - import appeng.api.networking.energy.IAEPowerStorage; - /** - * informs the network, that a {@link IAEPowerStorage} block that had either run, - * out of power, or was full, is no longer in that state. + * informs the network, that a {@link IAEPowerStorage} block that had either + * run, out of power, or was full, is no longer in that state. * - * failure to post this event when your {@link IAEPowerStorage} changes state will - * result in your block not charging, or not-discharging. + * failure to post this event when your {@link IAEPowerStorage} changes state + * will result in your block not charging, or not-discharging. * - * you do not need to send this event when your node is added / removed from the grid. + * you do not need to send this event when your node is added / removed from the + * grid. */ -public class MENetworkPowerStorage extends MENetworkEvent -{ +public class MENetworkPowerStorage extends MENetworkEvent { - public final IAEPowerStorage storage; - public final PowerEventType type; + public final IAEPowerStorage storage; + public final PowerEventType type; - public MENetworkPowerStorage( final IAEPowerStorage t, final PowerEventType y ) - { - this.storage = t; - this.type = y; - } + public MENetworkPowerStorage(final IAEPowerStorage t, final PowerEventType y) { + this.storage = t; + this.type = y; + } - public enum PowerEventType - { - /** - * informs the network this tile is ready to receive power again. - */ - REQUEST_POWER, + public enum PowerEventType { + /** + * informs the network this tile is ready to receive power again. + */ + REQUEST_POWER, - /** - * informs the network this tile is ready to provide power again. - */ - PROVIDE_POWER - } + /** + * informs the network this tile is ready to provide power again. + */ + PROVIDE_POWER + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java b/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java index 968d84752..f0efcf1a9 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java @@ -23,11 +23,9 @@ package appeng.api.networking.events; - /** * Posted by the security framework when permissions change */ -public class MENetworkSecurityChange extends MENetworkEvent -{ +public class MENetworkSecurityChange extends MENetworkEvent { } diff --git a/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java b/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java index 20cfc1177..baeb4d15a 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java +++ b/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java @@ -23,25 +23,22 @@ package appeng.api.networking.events; - import appeng.api.networking.IGridHost; - /** - * An event that is posted whenever a spatial IO is active, called for IGridCache + * An event that is posted whenever a spatial IO is active, called for + * IGridCache */ -public class MENetworkSpatialEvent extends MENetworkEvent -{ - public final IGridHost host; - public final double spatialEnergyUsage; +public class MENetworkSpatialEvent extends MENetworkEvent { + public final IGridHost host; + public final double spatialEnergyUsage; - /** - * @param SpatialIO ( INSTANCE of the SpatialIO block ) - * @param EnergyUsage ( the amount of energy that the SpatialIO uses) - */ - public MENetworkSpatialEvent( final IGridHost SpatialIO, final double EnergyUsage ) - { - this.host = SpatialIO; - this.spatialEnergyUsage = EnergyUsage; - } + /** + * @param SpatialIO ( INSTANCE of the SpatialIO block ) + * @param EnergyUsage ( the amount of energy that the SpatialIO uses) + */ + public MENetworkSpatialEvent(final IGridHost SpatialIO, final double EnergyUsage) { + this.host = SpatialIO; + this.spatialEnergyUsage = EnergyUsage; + } } diff --git a/src/api/java/appeng/api/networking/events/MENetworkStorageEvent.java b/src/api/java/appeng/api/networking/events/MENetworkStorageEvent.java index 4389d27ec..3e491279e 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkStorageEvent.java +++ b/src/api/java/appeng/api/networking/events/MENetworkStorageEvent.java @@ -23,28 +23,24 @@ package appeng.api.networking.events; - import appeng.api.storage.IMEMonitor; import appeng.api.storage.IStorageChannel; - /** - * posted by the network when the networks Storage Changes, you can use the currentItems list to check levels, and - * update status. + * posted by the network when the networks Storage Changes, you can use the + * currentItems list to check levels, and update status. * * this is the least useful method of getting info about changes in the network. * * Do not modify the list or its contents in anyway. */ -public class MENetworkStorageEvent extends MENetworkEvent -{ +public class MENetworkStorageEvent extends MENetworkEvent { - public final IMEMonitor monitor; - public final IStorageChannel channel; + public final IMEMonitor monitor; + public final IStorageChannel channel; - public MENetworkStorageEvent( final IMEMonitor o, final IStorageChannel chan ) - { - this.monitor = o; - this.channel = chan; - } + public MENetworkStorageEvent(final IMEMonitor o, final IStorageChannel chan) { + this.monitor = o; + this.channel = chan; + } } diff --git a/src/api/java/appeng/api/networking/pathing/ControllerState.java b/src/api/java/appeng/api/networking/pathing/ControllerState.java index 0bb0e5e1a..f6f4d510c 100644 --- a/src/api/java/appeng/api/networking/pathing/ControllerState.java +++ b/src/api/java/appeng/api/networking/pathing/ControllerState.java @@ -23,21 +23,19 @@ package appeng.api.networking.pathing; +public enum ControllerState { + /** + * No controller blocks are present in the network. + */ + NO_CONTROLLER, -public enum ControllerState -{ - /** - * No controller blocks are present in the network. - */ - NO_CONTROLLER, + /** + * Controller rules followed, booting enabled. + */ + CONTROLLER_ONLINE, - /** - * Controller rules followed, booting enabled. - */ - CONTROLLER_ONLINE, - - /** - * Controller rules not followed, lock up while booting. - */ - CONTROLLER_CONFLICT + /** + * Controller rules not followed, lock up while booting. + */ + CONTROLLER_CONFLICT } diff --git a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java index 8dc84df58..bdb56ff36 100644 --- a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java +++ b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java @@ -23,29 +23,26 @@ package appeng.api.networking.pathing; - import javax.annotation.Nonnull; import appeng.api.networking.IGridCache; +public interface IPathingGrid extends IGridCache { -public interface IPathingGrid extends IGridCache -{ + /** + * @return true if the network is in its booting stage + */ + boolean isNetworkBooting(); - /** - * @return true if the network is in its booting stage - */ - boolean isNetworkBooting(); + /** + * @return the controller state of the network, useful if you want to require a + * controller for a feature. + */ + @Nonnull + ControllerState getControllerState(); - /** - * @return the controller state of the network, useful if you want to - * require a controller for a feature. - */ - @Nonnull - ControllerState getControllerState(); - - /** - * trigger a network reset, booting, path-finding and all. - */ - void repath(); + /** + * 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/IActionHost.java b/src/api/java/appeng/api/networking/security/IActionHost.java index a3b695c0c..f97bb08f8 100644 --- a/src/api/java/appeng/api/networking/security/IActionHost.java +++ b/src/api/java/appeng/api/networking/security/IActionHost.java @@ -23,23 +23,19 @@ package appeng.api.networking.security; - import javax.annotation.Nonnull; import appeng.api.networking.IGridNode; +public interface IActionHost { -public interface IActionHost -{ - - /** - * Used to for calculating security rules, you must supply a node from your - * IGridHost for the security test, this should be the primary node for the - * machine, unless the action is preformed by a non primary node. - * - * @return the the gridnode that actions from this IGridHost are preformed - * by. - */ - @Nonnull // FIXME fishy annotation, every caller seems to check for null - IGridNode getActionableNode(); + /** + * Used to for calculating security rules, you must supply a node from your + * IGridHost for the security test, this should be the primary node for the + * machine, unless the action is preformed by a non primary node. + * + * @return the the gridnode that actions from this IGridHost are preformed by. + */ + @Nonnull // FIXME fishy annotation, every caller seems to check for null + IGridNode getActionableNode(); } diff --git a/src/api/java/appeng/api/networking/security/IActionSource.java b/src/api/java/appeng/api/networking/security/IActionSource.java index 830d97fc3..c9b68be98 100644 --- a/src/api/java/appeng/api/networking/security/IActionSource.java +++ b/src/api/java/appeng/api/networking/security/IActionSource.java @@ -23,55 +23,56 @@ package appeng.api.networking.security; - import java.util.Optional; import javax.annotation.Nonnull; import net.minecraft.entity.player.PlayerEntity; - /** * The source of any action. * * This can either be a {@link PlayerEntity} or an {@link IActionHost}. * - * In most cases this is used for security checks, but can be used to validate the source itself. + * In most cases this is used for security checks, but can be used to validate + * the source itself. * */ -public interface IActionSource -{ +public interface IActionSource { - /** - * If present, AE will consider the player being the source for the action. - * - * This will take precedence over {@link IActionSource#machine()} in any case. - * - * @return An optional player issuing the action. - */ - @Nonnull - Optional player(); + /** + * If present, AE will consider the player being the source for the action. + * + * This will take precedence over {@link IActionSource#machine()} in any case. + * + * @return An optional player issuing the action. + */ + @Nonnull + Optional player(); - /** - * If present, it indicates the {@link IActionHost} of the source. - * - * Should {@link IActionSource#player()} be absent, it will consider a machine as source. - * - * It is recommended to include the machine even when a player is present. - * - * @return An optional machine issuing the action or acting as proxy for a player. - */ - @Nonnull - Optional machine(); + /** + * If present, it indicates the {@link IActionHost} of the source. + * + * Should {@link IActionSource#player()} be absent, it will consider a machine + * as source. + * + * It is recommended to include the machine even when a player is present. + * + * @return An optional machine issuing the action or acting as proxy for a + * player. + */ + @Nonnull + Optional machine(); - /** - * An {@link IActionSource} can have multiple optional contexts. - * - * It is strongly recommended to limit the uses for absolutely necessary cases. - * - * Currently there are no public contexts made available by AE. - * An example would be the context interfaces use internally to avoid looping items between each other. - */ - @Nonnull - Optional context( @Nonnull Class key ); + /** + * An {@link IActionSource} can have multiple optional contexts. + * + * It is strongly recommended to limit the uses for absolutely necessary cases. + * + * Currently there are no public contexts made available by AE. An example would + * be the context interfaces use internally to avoid looping items between each + * other. + */ + @Nonnull + Optional context(@Nonnull Class key); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/security/ISecurityGrid.java b/src/api/java/appeng/api/networking/security/ISecurityGrid.java index 306bf1ea2..4e59cf657 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityGrid.java +++ b/src/api/java/appeng/api/networking/security/ISecurityGrid.java @@ -23,7 +23,6 @@ package appeng.api.networking.security; - import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -32,37 +31,36 @@ import net.minecraft.entity.player.PlayerEntity; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGridCache; +public interface ISecurityGrid extends IGridCache { -public interface ISecurityGrid extends IGridCache -{ + /** + * @return true if a security provider is in the network ( and only 1 ) + */ + boolean isAvailable(); - /** - * @return true if a security provider is in the network ( and only 1 ) - */ - boolean isAvailable(); + /** + * Check if a player has permissions. + * + * @param player to be checked player + * @param perm checked permissions + * + * @return true if the player has permissions. + */ + boolean hasPermission(@Nonnull PlayerEntity player, @Nonnull SecurityPermissions perm); - /** - * Check if a player has permissions. - * - * @param player to be checked player - * @param perm checked permissions - * - * @return true if the player has permissions. - */ - boolean hasPermission( @Nonnull PlayerEntity player, @Nonnull SecurityPermissions perm ); + /** + * Check if a player has permissions. + * + * @param playerID id of player + * @param perm checked permissions + * + * @return true if the player has permissions. + */ + boolean hasPermission(@Nonnegative int playerID, @Nonnull SecurityPermissions perm); - /** - * Check if a player has permissions. - * - * @param playerID id of player - * @param perm checked permissions - * - * @return true if the player has permissions. - */ - boolean hasPermission( @Nonnegative int playerID, @Nonnull SecurityPermissions perm ); - - /** - * @return PlayerID of the admin, or owner, this is the person who placed the security block. - */ - int getOwner(); + /** + * @return PlayerID of the admin, or owner, this is the person who placed the + * security block. + */ + int getOwner(); } diff --git a/src/api/java/appeng/api/networking/security/ISecurityProvider.java b/src/api/java/appeng/api/networking/security/ISecurityProvider.java index 6cd6a2d5f..71b86b5fb 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityProvider.java +++ b/src/api/java/appeng/api/networking/security/ISecurityProvider.java @@ -23,40 +23,38 @@ package appeng.api.networking.security; - import java.util.EnumSet; import java.util.Map; import appeng.api.config.SecurityPermissions; - /** * Implemented on Security Terminal to interface with security cache. */ -public interface ISecurityProvider -{ +public interface ISecurityProvider { - /** - * used to represent the security key for the network, should be based on a unique timestamp. - * - * @return unique key. - */ - long getSecurityKey(); + /** + * used to represent the security key for the network, should be based on a + * unique timestamp. + * + * @return unique key. + */ + long getSecurityKey(); - /** - * Push permission data into security cache. - * - * @param playerPerms player permissions - */ - void readPermissions( Map> playerPerms ); + /** + * Push permission data into security cache. + * + * @param playerPerms player permissions + */ + void readPermissions(Map> playerPerms); - /** - * @return is security on or off? - */ - boolean isSecurityEnabled(); + /** + * @return is security on or off? + */ + boolean isSecurityEnabled(); - /** - * @return player ID for who placed the security provider. - */ - int getOwner(); + /** + * @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 29c4f12ee..0be535aed 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityRegistry.java +++ b/src/api/java/appeng/api/networking/security/ISecurityRegistry.java @@ -23,25 +23,23 @@ package appeng.api.networking.security; - import java.util.EnumSet; import javax.annotation.Nonnull; import appeng.api.config.SecurityPermissions; - /** - * Used by vanilla Security Terminal to post biometric data into the security cache. + * Used by vanilla Security Terminal to post biometric data into the security + * cache. */ -public interface ISecurityRegistry -{ +public interface ISecurityRegistry { - /** - * Submit Permissions into the register. - * - * @param playerID player id - * @param permissions permissions of player - */ - void addPlayer( int playerID, @Nonnull EnumSet permissions ); + /** + * Submit Permissions into the register. + * + * @param playerID player id + * @param permissions permissions of player + */ + void addPlayer(int playerID, @Nonnull EnumSet permissions); } diff --git a/src/api/java/appeng/api/networking/spatial/ISpatialCache.java b/src/api/java/appeng/api/networking/spatial/ISpatialCache.java index 68259ad16..c7fcda0dd 100644 --- a/src/api/java/appeng/api/networking/spatial/ISpatialCache.java +++ b/src/api/java/appeng/api/networking/spatial/ISpatialCache.java @@ -23,42 +23,39 @@ package appeng.api.networking.spatial; - import appeng.api.networking.IGridCache; import appeng.api.util.DimensionalCoord; +public interface ISpatialCache extends IGridCache { -public interface ISpatialCache extends IGridCache -{ + /** + * @return true if a region is defined at all, it doesn't have to be valid, but + * all points must be in the same world. + */ + boolean hasRegion(); - /** - * @return true if a region is defined at all, it doesn't have to be valid, but all points must be in the same - * world. - */ - boolean hasRegion(); + /** + * @return true if the region defined is valid according to all rules. + */ + boolean isValidRegion(); - /** - * @return true if the region defined is valid according to all rules. - */ - boolean isValidRegion(); + /** + * @return the minimum anchor point for the spatial region. + */ + DimensionalCoord getMin(); - /** - * @return the minimum anchor point for the spatial region. - */ - DimensionalCoord getMin(); + /** + * @return the maximum anchor point for the spatial region. + */ + DimensionalCoord getMax(); - /** - * @return the maximum anchor point for the spatial region. - */ - DimensionalCoord getMax(); + /** + * @return how many AE units are required to preform the activation + */ + long requiredPower(); - /** - * @return how many AE units are required to preform the activation - */ - long requiredPower(); - - /** - * @return current 100% - 0% efficiency. - */ - float currentEfficiency(); + /** + * @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 054102e73..c49af053b 100644 --- a/src/api/java/appeng/api/networking/storage/IBaseMonitor.java +++ b/src/api/java/appeng/api/networking/storage/IBaseMonitor.java @@ -23,21 +23,19 @@ package appeng.api.networking.storage; - import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.data.IAEStack; +public interface IBaseMonitor> { -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); - /** - * add a new Listener to the monitor, be sure to properly remove yourself when your done. - */ - void addListener( IMEMonitorHandlerReceiver l, Object verificationToken ); - - /** - * remove a Listener to the monitor. - */ - void removeListener( IMEMonitorHandlerReceiver l ); + /** + * remove a Listener to the monitor. + */ + 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 8d3bf81bb..086149af9 100644 --- a/src/api/java/appeng/api/networking/storage/IStackWatcher.java +++ b/src/api/java/appeng/api/networking/storage/IStackWatcher.java @@ -23,37 +23,34 @@ package appeng.api.networking.storage; - import appeng.api.storage.data.IAEStack; - /** * DO NOT IMPLEMENT. * * Will be injected when adding an {@link IStackWatcherHost} to a grid. */ -public interface IStackWatcher -{ - /** - * Add a specific {@link IAEStack} to watch. - * - * Supports multiple values, duplicate ones will not be added. - * - * @param stack - * @return true, if successfully added. - */ - boolean add( IAEStack stack ); +public interface IStackWatcher { + /** + * Add a specific {@link IAEStack} to watch. + * + * Supports multiple values, duplicate ones will not be added. + * + * @param stack + * @return true, if successfully added. + */ + boolean add(IAEStack stack); - /** - * Remove a specific {@link IAEStack} from the watcher. - * - * @param stack - * @return true, if successfully removed. - */ - boolean remove( IAEStack stack ); + /** + * Remove a specific {@link IAEStack} from the watcher. + * + * @param stack + * @return true, if successfully removed. + */ + boolean remove(IAEStack stack); - /** - * Removes all watched stacks and resets the watcher to a clean state. - */ - void reset(); + /** + * Removes all watched stacks and resets the watcher to a clean state. + */ + void reset(); } diff --git a/src/api/java/appeng/api/networking/storage/IStackWatcherHost.java b/src/api/java/appeng/api/networking/storage/IStackWatcherHost.java index adcd12f2e..91082b34d 100644 --- a/src/api/java/appeng/api/networking/storage/IStackWatcherHost.java +++ b/src/api/java/appeng/api/networking/storage/IStackWatcherHost.java @@ -23,32 +23,31 @@ package appeng.api.networking.storage; - import appeng.api.networking.security.IActionSource; import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public interface IStackWatcherHost { -public interface IStackWatcherHost -{ + /** + * provides the IStackWatcher for this host, for the current network, is called + * when the hot changes networks. You do not need to clear your old watcher, its + * already been removed by the time this gets called. + * + * @param newWatcher stack watcher + */ + void updateWatcher(IStackWatcher newWatcher); - /** - * provides the IStackWatcher for this host, for the current network, is called when the hot changes networks. You - * do not need to clear your old watcher, its already been removed by the time this gets called. - * - * @param newWatcher stack watcher - */ - void updateWatcher( IStackWatcher newWatcher ); - - /** - * Called when a watched item changes amounts. - * - * @param o changed item list - * @param fullStack old stack - * @param diffStack new stack - * @param src action source - * @param chan storage channel - */ - void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan ); + /** + * Called when a watched item changes amounts. + * + * @param o changed item list + * @param fullStack old stack + * @param diffStack new stack + * @param src action source + * @param chan storage channel + */ + void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, + IStorageChannel chan); } diff --git a/src/api/java/appeng/api/networking/storage/IStorageGrid.java b/src/api/java/appeng/api/networking/storage/IStorageGrid.java index cec8900f8..7ad4376db 100644 --- a/src/api/java/appeng/api/networking/storage/IStorageGrid.java +++ b/src/api/java/appeng/api/networking/storage/IStorageGrid.java @@ -23,7 +23,6 @@ package appeng.api.networking.storage; - import appeng.api.networking.IGridCache; import appeng.api.networking.IGridHost; import appeng.api.networking.security.IActionSource; @@ -33,37 +32,36 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageMonitorable; import appeng.api.storage.data.IAEStack; - /** * Common base class for item / fluid storage caches. */ -public interface IStorageGrid extends IGridCache, IStorageMonitorable -{ +public interface IStorageGrid extends IGridCache, IStorageMonitorable { - /** - * Used to inform the network of alterations to the storage system that fall outside of the standard Network - * operations, Examples, ME Chest inputs from the world, or a Storage Bus detecting modifications made to the chest - * by an outside force. - * - * Expects the input to have either a negative or a positive stack size to correspond to the injection, or - * extraction operation. - * - * @param input injected items - */ - void postAlterationOfStoredItems( IStorageChannel chan, Iterable> input, IActionSource src ); + /** + * Used to inform the network of alterations to the storage system that fall + * outside of the standard Network operations, Examples, ME Chest inputs from + * the world, or a Storage Bus detecting modifications made to the chest by an + * outside force. + * + * Expects the input to have either a negative or a positive stack size to + * correspond to the injection, or extraction operation. + * + * @param input injected items + */ + void postAlterationOfStoredItems(IStorageChannel chan, Iterable> input, IActionSource src); - /** - * Used to add a cell provider to the storage system - * - * THIS IT NOT FOR USE {@link IGridHost} THAT PROVIDE {@link ICellContainer} - those are automatically handled by - * the storage system. - * - * @param cc to be added cell provider - */ - void registerCellProvider( ICellProvider cc ); + /** + * Used to add a cell provider to the storage system + * + * THIS IT NOT FOR USE {@link IGridHost} THAT PROVIDE {@link ICellContainer} - + * those are automatically handled by the storage system. + * + * @param cc to be added cell provider + */ + void registerCellProvider(ICellProvider cc); - /** - * remove a provider added with addCellContainer - */ - void unregisterCellProvider( ICellProvider cc ); + /** + * remove a provider added with addCellContainer + */ + void unregisterCellProvider(ICellProvider cc); } diff --git a/src/api/java/appeng/api/networking/ticking/IGridTickable.java b/src/api/java/appeng/api/networking/ticking/IGridTickable.java index 9fe4ac792..973fcf996 100644 --- a/src/api/java/appeng/api/networking/ticking/IGridTickable.java +++ b/src/api/java/appeng/api/networking/ticking/IGridTickable.java @@ -23,58 +23,55 @@ package appeng.api.networking.ticking; - import javax.annotation.Nonnull; import appeng.api.networking.IGridNode; - /** * Implement on IGridHosts which want to use AE's Network Ticking Feature. */ -public interface IGridTickable -{ +public interface IGridTickable { - /** - * Important note regarding IGridTickables with more then one one node, - * - * If your IGridHost hosts multiple nodes, it may be on multiple grids, or - * its node may be present on the same grid multiple times, this is as - * designed, however if you choose to use the grid to tick these Hosts you - * must be aware that they they should probably pick a single node to tick - * for, and not tick for each node. - * - */ + /** + * Important note regarding IGridTickables with more then one one node, + * + * If your IGridHost hosts multiple nodes, it may be on multiple grids, or its + * node may be present on the same grid multiple times, this is as designed, + * however if you choose to use the grid to tick these Hosts you must be aware + * that they they should probably pick a single node to tick for, and not tick + * for each node. + * + */ - /** - * Return a valid TickingRequest to tell AE a guide for which type of - * responsiveness your device wants. - * - * This will be called for your tile any time your tile changes grids, this - * can happen at any time, so if your using the sleep feature you may wish - * to preserve your sleep, in the result of this method. or you can simply - * reset it. - * - * @return a valid new TickingRequest - */ - @Nonnull - TickingRequest getTickingRequest( @Nonnull IGridNode node ); + /** + * Return a valid TickingRequest to tell AE a guide for which type of + * responsiveness your device wants. + * + * This will be called for your tile any time your tile changes grids, this can + * happen at any time, so if your using the sleep feature you may wish to + * preserve your sleep, in the result of this method. or you can simply reset + * it. + * + * @return a valid new TickingRequest + */ + @Nonnull + TickingRequest getTickingRequest(@Nonnull IGridNode node); - /** - * AE lets you adjust your tick rate based on the results of your tick, if - * your block as accomplished work you may wish to increase the ticking - * speed, if your block is idle you may wish to slow it down. - * - * Its up to you. - * - * Note: this is never called if you return null from getTickingRequest. - * - * @param ticksSinceLastCall the number of world ticks that were skipped since your last - * tick, you can use this to adjust speed of processing or adjust - * your tick rate. - * - * @return tick rate adjustment. - */ - @Nonnull - TickRateModulation tickingRequest( @Nonnull IGridNode node, int ticksSinceLastCall ); + /** + * AE lets you adjust your tick rate based on the results of your tick, if your + * block as accomplished work you may wish to increase the ticking speed, if + * your block is idle you may wish to slow it down. + * + * Its up to you. + * + * Note: this is never called if you return null from getTickingRequest. + * + * @param ticksSinceLastCall the number of world ticks that were skipped since + * your last tick, you can use this to adjust speed of + * processing or adjust your tick rate. + * + * @return tick rate adjustment. + */ + @Nonnull + TickRateModulation tickingRequest(@Nonnull IGridNode node, int ticksSinceLastCall); } diff --git a/src/api/java/appeng/api/networking/ticking/ITickManager.java b/src/api/java/appeng/api/networking/ticking/ITickManager.java index 5294cdb4b..8684a6dab 100644 --- a/src/api/java/appeng/api/networking/ticking/ITickManager.java +++ b/src/api/java/appeng/api/networking/ticking/ITickManager.java @@ -23,44 +23,42 @@ package appeng.api.networking.ticking; - import javax.annotation.Nonnull; import appeng.api.networking.IGridCache; import appeng.api.networking.IGridNode; - /** * The network tick manager. */ -public interface ITickManager extends IGridCache -{ +public interface ITickManager extends IGridCache { - /** - * immediately sets the node to tick, only valid if your node is marked as "Alertable" in its TickingRequest - * - * Sleeping Devices Still Alertable, when your tile is alerted its new status is determined by the result of its - * tick. - * - * @param node gridnode - */ - boolean alertDevice( @Nonnull IGridNode node ); + /** + * immediately sets the node to tick, only valid if your node is marked as + * "Alertable" in its TickingRequest + * + * Sleeping Devices Still Alertable, when your tile is alerted its new status is + * determined by the result of its tick. + * + * @param node gridnode + */ + boolean alertDevice(@Nonnull IGridNode node); - /** - * disables ticking for your device. - * - * @param node gridnode - * - * @return if the call was successful. - */ - boolean sleepDevice( @Nonnull IGridNode node ); + /** + * disables ticking for your device. + * + * @param node gridnode + * + * @return if the call was successful. + */ + boolean sleepDevice(@Nonnull IGridNode node); - /** - * enables ticking for your device, undoes a sleepDevice call. - * - * @param node gridnode - * - * @return if the call was successful. - */ - boolean wakeDevice( @Nonnull IGridNode node ); + /** + * enables ticking for your device, undoes a sleepDevice call. + * + * @param node gridnode + * + * @return if the call was successful. + */ + boolean wakeDevice(@Nonnull IGridNode node); } diff --git a/src/api/java/appeng/api/networking/ticking/TickRateModulation.java b/src/api/java/appeng/api/networking/ticking/TickRateModulation.java index 35e83b921..a83f2fbd1 100644 --- a/src/api/java/appeng/api/networking/ticking/TickRateModulation.java +++ b/src/api/java/appeng/api/networking/ticking/TickRateModulation.java @@ -23,36 +23,34 @@ package appeng.api.networking.ticking; +public enum TickRateModulation { + /** + * same as idle, but also puts the node to sleep. + */ + SLEEP, -public enum TickRateModulation -{ - /** - * same as idle, but also puts the node to sleep. - */ - SLEEP, + /** + * set tick rate to maximum. + */ + IDLE, - /** - * set tick rate to maximum. - */ - IDLE, + /** + * decrease the tick rate marginally. + */ + SLOWER, - /** - * decrease the tick rate marginally. - */ - SLOWER, + /** + * continue at current rate. + */ + SAME, - /** - * continue at current rate. - */ - SAME, + /** + * increase the tick rate marginally. + */ + FASTER, - /** - * increase the tick rate marginally. - */ - FASTER, - - /** - * changes the tick rate to the minimum tick rate. - */ - URGENT + /** + * changes the tick rate to the minimum tick rate. + */ + URGENT } diff --git a/src/api/java/appeng/api/networking/ticking/TickingRequest.java b/src/api/java/appeng/api/networking/ticking/TickingRequest.java index d14cab92c..68429e8a7 100644 --- a/src/api/java/appeng/api/networking/ticking/TickingRequest.java +++ b/src/api/java/appeng/api/networking/ticking/TickingRequest.java @@ -23,48 +23,45 @@ package appeng.api.networking.ticking; - /** * Describes how your tiles ticking is executed. */ -public class TickingRequest -{ +public class TickingRequest { - /** - * the minimum number of ticks that must pass between ticks. - * - * Valid Values are : 1+ - * - * Suggested is 5-20 - */ - public final int minTickRate; + /** + * the minimum number of ticks that must pass between ticks. + * + * Valid Values are : 1+ + * + * Suggested is 5-20 + */ + public final int minTickRate; - /** - * the maximum number of ticks that can pass between ticks, if this value is - * exceeded the tile must tick. - * - * Valid Values are 1+ - * - * Suggested is 20-40 - */ - public final int maxTickRate; + /** + * the maximum number of ticks that can pass between ticks, if this value is + * exceeded the tile must tick. + * + * Valid Values are 1+ + * + * Suggested is 20-40 + */ + public final int maxTickRate; - /** - * Determines the current expected state of your node, if your node expects - * to be sleeping, then return true. - */ - public final boolean isSleeping; + /** + * Determines the current expected state of your node, if your node expects to + * be sleeping, then return true. + */ + public final boolean isSleeping; - /** - * True only if you call {@link ITickManager}.alertDevice( IGridNode ); - */ - public final boolean canBeAlerted; + /** + * True only if you call {@link ITickManager}.alertDevice( IGridNode ); + */ + public final boolean canBeAlerted; - public TickingRequest( final int min, final int max, final boolean sleep, final boolean alertable ) - { - this.minTickRate = min; - this.maxTickRate = max; - this.isSleeping = sleep; - this.canBeAlerted = alertable; - } + public TickingRequest(final int min, final int max, final boolean sleep, final boolean alertable) { + this.minTickRate = min; + this.maxTickRate = max; + this.isSleeping = sleep; + this.canBeAlerted = alertable; + } } diff --git a/src/api/java/appeng/api/parts/BusSupport.java b/src/api/java/appeng/api/parts/BusSupport.java index 4a334d9e2..0a3f40408 100644 --- a/src/api/java/appeng/api/parts/BusSupport.java +++ b/src/api/java/appeng/api/parts/BusSupport.java @@ -23,11 +23,9 @@ package appeng.api.parts; +public enum BusSupport { + CABLE, -public enum BusSupport -{ - CABLE, - - DENSE_CABLE + DENSE_CABLE } diff --git a/src/api/java/appeng/api/parts/CableRenderMode.java b/src/api/java/appeng/api/parts/CableRenderMode.java index d232caab9..ddf3c588e 100644 --- a/src/api/java/appeng/api/parts/CableRenderMode.java +++ b/src/api/java/appeng/api/parts/CableRenderMode.java @@ -23,19 +23,16 @@ package appeng.api.parts; +public enum CableRenderMode { + STANDARD(false), -public enum CableRenderMode -{ - STANDARD( false ), + CABLE_VIEW(true); - CABLE_VIEW( true ); + public final boolean transparentFacades; + public final boolean opaqueFacades; - public final boolean transparentFacades; - public final boolean opaqueFacades; - - CableRenderMode( final boolean hideFacades ) - { - this.transparentFacades = hideFacades; - this.opaqueFacades = !hideFacades; - } + CableRenderMode(final 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 f6bccaecb..e3b1daa78 100644 --- a/src/api/java/appeng/api/parts/IAlphaPassItem.java +++ b/src/api/java/appeng/api/parts/IAlphaPassItem.java @@ -23,19 +23,18 @@ package appeng.api.parts; - import net.minecraft.item.ItemStack; +public interface IAlphaPassItem { -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 ); + /** + * 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); } diff --git a/src/api/java/appeng/api/parts/IBoxProvider.java b/src/api/java/appeng/api/parts/IBoxProvider.java index a03230ef1..105842f13 100644 --- a/src/api/java/appeng/api/parts/IBoxProvider.java +++ b/src/api/java/appeng/api/parts/IBoxProvider.java @@ -23,14 +23,12 @@ package appeng.api.parts; +public interface IBoxProvider { -public interface IBoxProvider -{ - - /** - * add your collision information to the the list. - * - * @param boxes collision boxes - */ - void getBoxes( IPartCollisionHelper boxes ); + /** + * add your collision information to the the list. + * + * @param boxes collision boxes + */ + void getBoxes(IPartCollisionHelper boxes); } diff --git a/src/api/java/appeng/api/parts/ICustomCableConnection.java b/src/api/java/appeng/api/parts/ICustomCableConnection.java index 8c578f63c..3c1eb2efa 100644 --- a/src/api/java/appeng/api/parts/ICustomCableConnection.java +++ b/src/api/java/appeng/api/parts/ICustomCableConnection.java @@ -23,16 +23,14 @@ package appeng.api.parts; - import appeng.api.util.AECableType; +public interface ICustomCableConnection { -public interface ICustomCableConnection -{ - - /** - * @return This controls the cable connection to the node. -1 to render connection yourself. - */ - public float getCableConnectionLength( AECableType cable ); + /** + * @return This controls the cable connection to the node. -1 to render + * connection yourself. + */ + public float getCableConnectionLength(AECableType cable); } diff --git a/src/api/java/appeng/api/parts/IFacadeContainer.java b/src/api/java/appeng/api/parts/IFacadeContainer.java index 145a662d3..b5576b70e 100644 --- a/src/api/java/appeng/api/parts/IFacadeContainer.java +++ b/src/api/java/appeng/api/parts/IFacadeContainer.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import java.io.IOException; import net.minecraft.nbt.CompoundNBT; @@ -31,73 +30,71 @@ import net.minecraft.network.PacketBuffer; import appeng.api.util.AEPartLocation; - /** * Used Internally. * * not intended for implementation. */ -public interface IFacadeContainer -{ +public interface IFacadeContainer { - /** - * Attempts to add the {@link IFacadePart} to the given side. - * - * @return true if the facade as successfully added. - */ - boolean addFacade( IFacadePart a ); + /** + * Attempts to add the {@link IFacadePart} to the given side. + * + * @return true if the facade as successfully added. + */ + boolean addFacade(IFacadePart a); - /** - * Removed the facade on the given side, or does nothing. - */ - void removeFacade( IPartHost host, AEPartLocation side ); + /** + * Removed the facade on the given side, or does nothing. + */ + void removeFacade(IPartHost host, AEPartLocation side); - /** - * @return the {@link IFacadePart} for a given side, or null. - */ - IFacadePart getFacade( AEPartLocation s ); + /** + * @return the {@link IFacadePart} for a given side, or null. + */ + IFacadePart getFacade(AEPartLocation s); - /** - * rotate the facades left. - */ - void rotateLeft(); + /** + * rotate the facades left. + */ + void rotateLeft(); - /** - * write nbt data - * - * @param data to be written data - */ - void writeToNBT( CompoundNBT data ); + /** + * write nbt data + * + * @param data to be written data + */ + void writeToNBT(CompoundNBT data); - /** - * read from stream - * - * @param data to be read data - * - * @return true if it was readable - * - * @throws IOException - */ - boolean readFromStream( PacketBuffer data ) throws IOException; + /** + * read from stream + * + * @param data to be read data + * + * @return true if it was readable + * + * @throws IOException + */ + boolean readFromStream(PacketBuffer data) throws IOException; - /** - * read from NBT - * - * @param data to be read data - */ - void readFromNBT( CompoundNBT data ); + /** + * read from NBT + * + * @param data to be read data + */ + void readFromNBT(CompoundNBT data); - /** - * write to stream - * - * @param data to be written data - * - * @throws IOException - */ - void writeToStream( PacketBuffer data ) throws IOException; + /** + * write to stream + * + * @param data to be written data + * + * @throws IOException + */ + void writeToStream(PacketBuffer data) throws IOException; - /** - * @return true if there are no facades. - */ - boolean isEmpty(); + /** + * @return true if there are no facades. + */ + boolean isEmpty(); } diff --git a/src/api/java/appeng/api/parts/IFacadePart.java b/src/api/java/appeng/api/parts/IFacadePart.java index 7e991169c..f70ea3726 100644 --- a/src/api/java/appeng/api/parts/IFacadePart.java +++ b/src/api/java/appeng/api/parts/IFacadePart.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.item.Item; @@ -31,47 +30,45 @@ import net.minecraft.item.ItemStack; import appeng.api.util.AEPartLocation; - /** * Used Internally. * * not intended for implementation. */ -public interface IFacadePart -{ +public interface IFacadePart { - /** - * used to save the part. - */ - ItemStack getItemStack(); + /** + * used to save the part. + */ + ItemStack getItemStack(); - /** - * used to collide, and pick the part - * - * @param ch collision helper - * @param e colliding entity - */ - void getBoxes( IPartCollisionHelper ch, Entity e ); + /** + * used to collide, and pick the part + * + * @param ch collision helper + * @param e colliding entity + */ + void getBoxes(IPartCollisionHelper ch, Entity e); - /** - * @return side the facade is in - */ - AEPartLocation getSide(); + /** + * @return side the facade is in + */ + AEPartLocation getSide(); - Item getItem(); + Item getItem(); - boolean notAEFacade(); + boolean notAEFacade(); - boolean isTransparent(); + boolean isTransparent(); - /** - * The item that this facade masquerades as. - */ - ItemStack getTextureItem(); + /** + * The item that this facade masquerades as. + */ + ItemStack getTextureItem(); - /** - * @return The block state used for rendering. - */ - BlockState getBlockState(); + /** + * @return The block state used for rendering. + */ + BlockState getBlockState(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/parts/IPart.java b/src/api/java/appeng/api/parts/IPart.java index af116ac8a..3b2aa7e7a 100644 --- a/src/api/java/appeng/api/parts/IPart.java +++ b/src/api/java/appeng/api/parts/IPart.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import java.io.IOException; import java.util.List; import java.util.Random; @@ -31,6 +30,7 @@ import java.util.Random; import javax.annotation.Nonnull; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -49,313 +49,319 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; import appeng.api.networking.IGridNode; import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.api.util.AEPartLocation; -import net.minecraftforge.common.util.LazyOptional; +public interface IPart extends IBoxProvider, ICustomCableConnection { -public interface IPart extends IBoxProvider, ICustomCableConnection -{ + /** + * get an ItemStack that represents the bus, should contain the settings for + * whatever, can also be used in conjunction with removePart to take a part off + * and drop it or something. + * + * This is used to drop the bus, and to save the bus, when saving the bus, + * wrenched is false, and writeToNBT will be called to save important details + * about the part, if the part is wrenched include in your NBT Data any settings + * you might want to keep around, you can restore those settings when + * constructing your part. + * + * @param type , what kind of ItemStack to return? + * + * @return item of part + */ + ItemStack getItemStack(PartItemStack type); - /** - * get an ItemStack that represents the bus, should contain the settings for whatever, can also be used in - * conjunction with removePart to take a part off and drop it or something. - * - * This is used to drop the bus, and to save the bus, when saving the bus, wrenched is false, and writeToNBT will be - * called to save important details about the part, if the part is wrenched include in your NBT Data any settings - * you might want to keep around, you can restore those settings when constructing your part. - * - * @param type , what kind of ItemStack to return? - * - * @return item of part - */ - ItemStack getItemStack( PartItemStack type ); + /** + * Render dynamic portions of this part, as part of the cable bus TESR. This + * part has to return true for {@link #requireDynamicRender()} in order for this + * method to be called. + */ + @OnlyIn(Dist.CLIENT) + default void renderDynamic(float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, + int combinedLightIn, int combinedOverlayIn) { + } - /** - * Render dynamic portions of this part, as part of the cable bus TESR. This part has to return true for - * {@link #requireDynamicRender()} in order for - * this method to be called. - */ - @OnlyIn( Dist.CLIENT ) - default void renderDynamic(float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) - { - } + /** + * return true only if your part require dynamic rendering, must be consistent. + * + * @return true to enable renderDynamic + */ + boolean requireDynamicRender(); - /** - * return true only if your part require dynamic rendering, must be consistent. - * - * @return true to enable renderDynamic - */ - boolean requireDynamicRender(); + /** + * @return if the bus has a solid side, and you can place random stuff on it + * like torches or levers + */ + boolean isSolid(); - /** - * @return if the bus has a solid side, and you can place random stuff on it like torches or levers - */ - boolean isSolid(); + /** + * @return true if this part can connect to redstone ( also MFR Rednet ) + */ + boolean canConnectRedstone(); - /** - * @return true if this part can connect to redstone ( also MFR Rednet ) - */ - boolean canConnectRedstone(); + /** + * Write the part information for saving, the part will be saved with + * getItemStack(false) and this method will be called after to load settings, + * inventory or other values from the world. + * + * @param data to be written nbt data + */ + void writeToNBT(CompoundNBT data); - /** - * Write the part information for saving, the part will be saved with getItemStack(false) and this method will be - * called after to load settings, inventory or other values from the world. - * - * @param data to be written nbt data - */ - void writeToNBT( CompoundNBT data ); + /** + * Read the previously written NBT Data. this is the mirror for writeToNBT + * + * @param data to be read nbt data + */ + void readFromNBT(CompoundNBT data); - /** - * Read the previously written NBT Data. this is the mirror for writeToNBT - * - * @param data to be read nbt data - */ - void readFromNBT( CompoundNBT data ); + /** + * @return get the amount of light produced by the bus + */ + int getLightLevel(); - /** - * @return get the amount of light produced by the bus - */ - int getLightLevel(); + /** + * does this part act like a ladder? + * + * @param entity climbing entity + * + * @return true if entity can climb + */ + boolean isLadder(LivingEntity entity); - /** - * does this part act like a ladder? - * - * @param entity climbing entity - * - * @return true if entity can climb - */ - boolean isLadder( LivingEntity entity ); + /** + * a block around the bus's host has been changed. + */ + void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor); - /** - * a block around the bus's host has been changed. - */ - void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ); + /** + * @return output redstone on facing side + */ + int isProvidingStrongPower(); - /** - * @return output redstone on facing side - */ - int isProvidingStrongPower(); + /** + * @return output redstone on facing side + */ + int isProvidingWeakPower(); - /** - * @return output redstone on facing side - */ - int isProvidingWeakPower(); + /** + * write data to bus packet. + * + * @param data to be written data + * + * @throws IOException + */ + void writeToStream(PacketBuffer data) throws IOException; - /** - * write data to bus packet. - * - * @param data to be written data - * - * @throws IOException - */ - void writeToStream( PacketBuffer data ) throws IOException; + /** + * read data from bus packet. + * + * @param data to be read data + * + * @return true will re-draw the part. + * + * @throws IOException + */ + boolean readFromStream(PacketBuffer data) throws IOException; - /** - * read data from bus packet. - * - * @param data to be read data - * - * @return true will re-draw the part. - * - * @throws IOException - */ - boolean readFromStream( PacketBuffer data ) throws IOException; + /** + * get the Grid Node for the Bus, be sure your IGridBlock is NOT + * isWorldAccessible, if it is your going to cause crashes. + * + * or null if you don't have a grid node. + * + * @return grid node + */ + IGridNode getGridNode(); - /** - * get the Grid Node for the Bus, be sure your IGridBlock is NOT isWorldAccessible, if it is your going to cause - * crashes. - * - * or null if you don't have a grid node. - * - * @return grid node - */ - IGridNode getGridNode(); + /** + * called when an entity collides with the bus. + * + * @param entity colliding entity + */ + void onEntityCollision(Entity entity); - /** - * called when an entity collides with the bus. - * - * @param entity colliding entity - */ - void onEntityCollision( Entity entity ); + /** + * called when your part is being removed from the world. + */ + void removeFromWorld(); - /** - * called when your part is being removed from the world. - */ - void removeFromWorld(); + /** + * called when your part is being added to the world. + */ + void addToWorld(); - /** - * called when your part is being added to the world. - */ - void addToWorld(); + /** + * used for tunnels. + * + * @return a grid node that represents the external facing side, these must be + * isWorldAccessible with the correct faces marked as external + */ + IGridNode getExternalFacingNode(); - /** - * used for tunnels. - * - * @return a grid node that represents the external facing side, these must be isWorldAccessible with the correct - * faces marked as external - */ - IGridNode getExternalFacingNode(); + /** + * called by the Part host to keep your part informed. + * + * @param host part side + * @param tile tile entity of part + */ + void setPartHostInfo(AEPartLocation side, IPartHost host, TileEntity tile); - /** - * called by the Part host to keep your part informed. - * - * @param host part side - * @param tile tile entity of part - */ - void setPartHostInfo( AEPartLocation side, IPartHost host, TileEntity tile ); + /** + * Called when you right click the part, very similar to Block.onActivateBlock + * + * @param player right clicking player + * @param hand hand used + * @param pos position of block + * + * @return if your activate method performed something. + */ + boolean onActivate(PlayerEntity player, Hand hand, Vec3d pos); - /** - * Called when you right click the part, very similar to Block.onActivateBlock - * - * @param player right clicking player - * @param hand hand used - * @param pos position of block - * - * @return if your activate method performed something. - */ - boolean onActivate( PlayerEntity player, Hand hand, Vec3d pos ); + /** + * Called when you right click the part, very similar to Block.onActivateBlock + * + * @param player shift right clicking player + * @param hand hand used + * @param pos position of block + * + * @return if your activate method performed something, you should use false + * unless you really need it. + */ + boolean onShiftActivate(PlayerEntity player, Hand hand, Vec3d pos); - /** - * Called when you right click the part, very similar to Block.onActivateBlock - * - * @param player shift right clicking player - * @param hand hand used - * @param pos position of block - * - * @return if your activate method performed something, you should use false unless you really need it. - */ - boolean onShiftActivate( PlayerEntity player, Hand hand, Vec3d pos ); + /** + * Called when you left click the part, very similar to Block.onBlockClicked + * + * @param player left clicking player + * @param hand hand used + * @param pos position of block + * + * @return if your activate method performed something, you should use false + * unless you really need it. + */ + default boolean onClicked(PlayerEntity player, Hand hand, Vec3d pos) { + return false; + } - /** - * Called when you left click the part, very similar to Block.onBlockClicked - * - * @param player left clicking player - * @param hand hand used - * @param pos position of block - * - * @return if your activate method performed something, you should use false unless you really need it. - */ - default boolean onClicked( PlayerEntity player, Hand hand, Vec3d pos ) - { - return false; - } + /** + * Called when you shift-left click the part, very similar to + * Block.onBlockClicked + * + * @param player shift-left clicking player + * @param hand hand used + * @param pos position of block + * + * @return if your activate method performed something, you should use false + * unless you really need it. + */ + default boolean onShiftClicked(PlayerEntity player, Hand hand, Vec3d pos) { + return false; + } - /** - * Called when you shift-left click the part, very similar to Block.onBlockClicked - * - * @param player shift-left clicking player - * @param hand hand used - * @param pos position of block - * - * @return if your activate method performed something, you should use false unless you really need it. - */ - default boolean onShiftClicked( PlayerEntity player, Hand hand, Vec3d pos ) - { - return false; - } + /** + * 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 wrenched control flag for wrenched vs broken + */ + void getDrops(List drops, boolean wrenched); - /** - * 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 wrenched control flag for wrenched vs broken - */ - void getDrops( List drops, boolean wrenched ); + /** + * @return 0 - 8, reasonable default 3-4, this controls the cable connection to + * the node. -1 to render connection yourself. + */ + @Override + public float getCableConnectionLength(AECableType cable); - /** - * @return 0 - 8, reasonable default 3-4, this controls the cable connection to the node. -1 to render connection - * yourself. - */ - @Override - public float getCableConnectionLength( AECableType cable ); + /** + * same as Block.animateTick, for but parts. + * + * @param world world of block + * @param pos location of block + * @param r random + */ + void animateTick(World world, BlockPos pos, Random r); - /** - * same as Block.animateTick, for but parts. - * - * @param world world of block - * @param pos location of block - * @param r random - */ - void animateTick( World world, BlockPos pos, 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 + */ + void onPlacement(PlayerEntity player, Hand hand, ItemStack held, AEPartLocation side); - /** - * 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 - */ - void onPlacement( PlayerEntity player, Hand hand, ItemStack held, AEPartLocation side ); + /** + * Used to determine which parts can be placed on what cables. + * + * Dense cables are not allowed for functional (getGridNode returns a node) + * parts. Doing so will result in crashes. + * + * @param what placed part + * + * @return true if the part can be placed on this support. + */ + boolean canBePlacedOn(BusSupport what); - /** - * Used to determine which parts can be placed on what cables. - * - * Dense cables are not allowed for functional (getGridNode returns a node) parts. - * Doing so will result in crashes. - * - * @param what placed part - * - * @return true if the part can be placed on this support. - */ - boolean canBePlacedOn( BusSupport what ); + /** + * This method is used when a chunk is rebuilt to determine how this part should + * be rendered. The returned models should represent the part oriented north. + * They will be automatically rotated to match the part's actual orientation. + * Tint indices 1-4 can be used in the models to access the parts color. + * + *
+ *
Tint Index 1
+ *
The {@link AEColor#blackVariant dark variant color} of the cable that + * this part is attached to.
+ *
Tint Index 2
+ *
The {@link AEColor#mediumVariant color} of the cable that this part is + * attached to.
+ *
Tint Index 3
+ *
The {@link AEColor#whiteVariant bright variant color} of the cable that + * this part is attached to.
+ *
Tint Index 4
+ *
A color variant that is between the cable's {@link AEColor#mediumVariant + * color} and its {@link AEColor#whiteVariant bright variant}.
+ *
+ * + * Important: All models must have been registered via the + * {@link IPartModels} API before use. + */ + @Nonnull + default IPartModel getStaticModels() { + return new IPartModel() { + }; + } - /** - * This method is used when a chunk is rebuilt to determine how this part should be rendered. The returned models - * should represent the - * part oriented north. They will be automatically rotated to match the part's actual orientation. Tint indices 1-4 - * can be used in the - * models to access the parts color. - * - *
- *
Tint Index 1
- *
The {@link AEColor#blackVariant dark variant color} of the cable that this part is attached to.
- *
Tint Index 2
- *
The {@link AEColor#mediumVariant color} of the cable that this part is attached to.
- *
Tint Index 3
- *
The {@link AEColor#whiteVariant bright variant color} of the cable that this part is attached to.
- *
Tint Index 4
- *
A color variant that is between the cable's {@link AEColor#mediumVariant color} and its - * {@link AEColor#whiteVariant bright variant}.
- *
- * - * Important: All models must have been registered via the {@link IPartModels} API before use. - */ - @Nonnull - default IPartModel getStaticModels() - { - return new IPartModel() - { - }; - } + /** + * Implement this method if your part exposes capabilitys. Any requests for + * capabilities on the cable bus will be forwarded to parts on the appropriate + * side. + * + * @see TileEntity#getCapability(Capability, net.minecraft.util.Direction) + * + * @return The capability or null. + */ + default LazyOptional getCapability(Capability capabilityClass) { + return LazyOptional.empty(); + } - /** - * Implement this method if your part exposes capabilitys. Any requests for capabilities on the cable bus will be - * forwarded to parts on the appropriate - * side. - * - * @see TileEntity#getCapability(Capability, net.minecraft.util.Direction) - * - * @return The capability or null. - */ - default LazyOptional getCapability(Capability capabilityClass ) - { - return LazyOptional.empty(); - } - - /** - * Additional model data to be passed to the models for rendering this part. - * - * @return The model data to pass to the model. Only useful if custom models are used. - */ - @Nonnull - default IModelData getModelData() - { - return EmptyModelData.INSTANCE; - } + /** + * Additional model data to be passed to the models for rendering this part. + * + * @return The model data to pass to the model. Only useful if custom models are + * used. + */ + @Nonnull + default IModelData getModelData() { + return EmptyModelData.INSTANCE; + } } diff --git a/src/api/java/appeng/api/parts/IPartCollisionHelper.java b/src/api/java/appeng/api/parts/IPartCollisionHelper.java index 14e62b491..d85a82260 100644 --- a/src/api/java/appeng/api/parts/IPartCollisionHelper.java +++ b/src/api/java/appeng/api/parts/IPartCollisionHelper.java @@ -23,44 +23,41 @@ package appeng.api.parts; - import net.minecraft.util.Direction; +public interface IPartCollisionHelper { -public interface IPartCollisionHelper -{ + /** + * add a collision box, expects 0.0 - 16.0 block coords. + * + * No complaints about the size, I like using pixels :P + * + * @param minX minimal x collision + * @param minY minimal y collision + * @param minZ minimal z collision + * @param maxX maximal x collision + * @param maxY maximal y collision + * @param maxZ maximal z collision + */ + void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ); - /** - * add a collision box, expects 0.0 - 16.0 block coords. - * - * No complaints about the size, I like using pixels :P - * - * @param minX minimal x collision - * @param minY minimal y collision - * @param minZ minimal z collision - * @param maxX maximal x collision - * @param maxY maximal y collision - * @param maxZ maximal z collision - */ - void addBox( double minX, double minY, double minZ, double maxX, double maxY, double maxZ ); + /** + * @return east in world space. + */ + Direction getWorldX(); - /** - * @return east in world space. - */ - Direction getWorldX(); + /** + * @return up in world space. + */ + Direction getWorldY(); - /** - * @return up in world space. - */ - Direction getWorldY(); + /** + * @return forward in world space. + */ + Direction getWorldZ(); - /** - * @return forward in world space. - */ - Direction getWorldZ(); - - /** - * @return true if this test is to get the BB Collision information. - */ - boolean isBBCollision(); + /** + * @return true if this test is to get the BB Collision information. + */ + boolean isBBCollision(); } diff --git a/src/api/java/appeng/api/parts/IPartHelper.java b/src/api/java/appeng/api/parts/IPartHelper.java index b7d33f538..82ee0eb5b 100644 --- a/src/api/java/appeng/api/parts/IPartHelper.java +++ b/src/api/java/appeng/api/parts/IPartHelper.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; @@ -32,25 +31,23 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +public interface IPartHelper { + /** + * use in use item, to try and place a IBusItem + * + * @param is ItemStack of an item which implements {@link IPartItem} + * @param pos pos of part + * @param side side which the part should be on + * @param player player placing part + * @param world part in world + * + * @return true if placing was successful + */ + // TODO, this should probably take ItemStack + ItemUseContext + ActionResultType placeBus(ItemStack is, BlockPos pos, Direction side, PlayerEntity player, Hand hand, World world); -public interface IPartHelper -{ - /** - * use in use item, to try and place a IBusItem - * - * @param is ItemStack of an item which implements {@link IPartItem} - * @param pos pos of part - * @param side side which the part should be on - * @param player player placing part - * @param world part in world - * - * @return true if placing was successful - */ - //TODO, this should probably take ItemStack + ItemUseContext - ActionResultType placeBus( ItemStack is, BlockPos pos, Direction side, PlayerEntity player, Hand hand, World world ); - - /** - * @return the render mode - */ - CableRenderMode getCableRenderMode(); + /** + * @return the render mode + */ + CableRenderMode getCableRenderMode(); } diff --git a/src/api/java/appeng/api/parts/IPartHost.java b/src/api/java/appeng/api/parts/IPartHost.java index d896d9d32..4291e047a 100644 --- a/src/api/java/appeng/api/parts/IPartHost.java +++ b/src/api/java/appeng/api/parts/IPartHost.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import java.util.Set; import net.minecraft.entity.player.PlayerEntity; @@ -37,158 +36,162 @@ import appeng.api.util.AEColor; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; - /** * Implemented on AE's TileEntity. * * Do Not Implement */ -public interface IPartHost extends ICustomCableConnection -{ +public interface IPartHost extends ICustomCableConnection { - /** - * @return the facade container - */ - IFacadeContainer getFacadeContainer(); + /** + * @return the facade container + */ + IFacadeContainer getFacadeContainer(); - /** - * Test if you can add a part to the specified side of the Part Host, {@link AEPartLocation}.UNKNOWN is used to - * represent the cable in the middle. - * - * @param part to be added part - * @param side part placed onto side - * - * @return returns false if the part cannot be added. - */ - boolean canAddPart( ItemStack part, AEPartLocation side ); + /** + * Test if you can add a part to the specified side of the Part Host, + * {@link AEPartLocation}.UNKNOWN is used to represent the cable in the middle. + * + * @param part to be added part + * @param side part placed onto side + * + * @return returns false if the part cannot be added. + */ + boolean canAddPart(ItemStack part, AEPartLocation side); - /** - * try to add a new part to the specified side, returns false if it failed to be added. - * - * @param is new part - * @param side onto side - * @param owner with owning player - * - * @return null if the item failed to add, the side it was placed on other wise ( may different for cables, - * {@link AEPartLocation}.UNKNOWN ) - */ - AEPartLocation addPart( ItemStack is, AEPartLocation side, PlayerEntity owner, Hand hand ); + /** + * try to add a new part to the specified side, returns false if it failed to be + * added. + * + * @param is new part + * @param side onto side + * @param owner with owning player + * + * @return null if the item failed to add, the side it was placed on other wise + * ( may different for cables, {@link AEPartLocation}.UNKNOWN ) + */ + AEPartLocation addPart(ItemStack is, AEPartLocation side, PlayerEntity owner, Hand hand); - /** - * Get part by side ( center is {@link AEPartLocation}.UNKNOWN ) - * - * @param side side of part - * - * @return the part located on the specified side, or null if there is no part. - */ - IPart getPart( AEPartLocation side ); + /** + * Get part by side ( center is {@link AEPartLocation}.UNKNOWN ) + * + * @param side side of part + * + * @return the part located on the specified side, or null if there is no part. + */ + IPart getPart(AEPartLocation side); - /** - * Get part by side, this method cannot aquire the center part, you must use the other varient of getPart. - * - * @param side side of part - * - * @return the part located on the specified side, or null if there is no part. - */ - IPart getPart( Direction side ); + /** + * Get part by side, this method cannot aquire the center part, you must use the + * other varient of getPart. + * + * @param side side of part + * + * @return the part located on the specified side, or null if there is no part. + */ + IPart getPart(Direction side); - /** - * removes the part on the side, this doesn't drop it or anything, if you don't do something with it, its just - * "gone" and its never coming back; think about it. - * - * if you want to drop the part you must request it prior to removing it. - * - * @param side side of part - * @param suppressUpdate - used if you need to replace a part's INSTANCE, without really removing it first. - */ - void removePart( AEPartLocation side, boolean suppressUpdate ); + /** + * removes the part on the side, this doesn't drop it or anything, if you don't + * do something with it, its just "gone" and its never coming back; think about + * it. + * + * if you want to drop the part you must request it prior to removing it. + * + * @param side side of part + * @param suppressUpdate - used if you need to replace a part's INSTANCE, + * without really removing it first. + */ + void removePart(AEPartLocation side, boolean suppressUpdate); - /** - * something changed, might want to send a packet to clients to update state. - */ - void markForUpdate(); + /** + * something changed, might want to send a packet to clients to update state. + */ + void markForUpdate(); - /** - * @return the physical location of the part host in the universe. - */ - DimensionalCoord getLocation(); + /** + * @return the physical location of the part host in the universe. + */ + DimensionalCoord getLocation(); - /** - * @return the tile entity for the host, this can either be an FMP tile, or a AE tile - */ - TileEntity getTile(); + /** + * @return the tile entity for the host, this can either be an FMP tile, or a AE + * tile + */ + TileEntity getTile(); - /** - * @return the color of the host type ( this is determined by the middle cable. ) if no cable is present, it returns - * {@link AEColor} .Transparent other wise it returns the color of the cable in the center. - */ - AEColor getColor(); + /** + * @return the color of the host type ( this is determined by the middle cable. + * ) if no cable is present, it returns {@link AEColor} .Transparent + * other wise it returns the color of the cable in the center. + */ + AEColor getColor(); - /** - * destroys the part container, for internal use. - */ - void clearContainer(); + /** + * destroys the part container, for internal use. + */ + void clearContainer(); - /** - * Used to test for FMP microblock blocking internally. - * - * @return returns if microblocks are blocking this cable path. - */ - boolean isBlocked( Direction side ); + /** + * Used to test for FMP microblock blocking internally. + * + * @return returns if microblocks are blocking this cable path. + */ + boolean isBlocked(Direction side); - /** - * finds the part located at the position ( pos must be relative, not global ) - * - * @param pos part position - * - * @return a new SelectedPart, this is never null. - */ - SelectedPart selectPart( Vec3d pos ); + /** + * finds the part located at the position ( pos must be relative, not global ) + * + * @param pos part position + * + * @return a new SelectedPart, this is never null. + */ + SelectedPart selectPart(Vec3d pos); - /** - * can be used by parts to trigger the tile or part to save. - */ - void markForSave(); + /** + * can be used by parts to trigger the tile or part to save. + */ + void markForSave(); - /** - * part of the {@link LayerBase} - */ - void partChanged(); + /** + * part of the {@link LayerBase} + */ + void partChanged(); - /** - * get the redstone state of host on this side, this value is cached internally. - * - * @param side side of part - * - * @return true of the part host is receiving redstone from an external source. - */ - boolean hasRedstone( AEPartLocation side ); + /** + * get the redstone state of host on this side, this value is cached internally. + * + * @param side side of part + * + * @return true of the part host is receiving redstone from an external source. + */ + boolean hasRedstone(AEPartLocation side); - /** - * returns false if this block contains any parts or facades, true other wise. - */ - boolean isEmpty(); + /** + * returns false if this block contains any parts or facades, true other wise. + */ + boolean isEmpty(); - /** - * @return a mutable list of flags you can adjust to track state. - */ - Set getLayerFlags(); + /** + * @return a mutable list of flags you can adjust to track state. + */ + Set getLayerFlags(); - /** - * remove host from world... - */ - void cleanup(); + /** + * remove host from world... + */ + void cleanup(); - /** - * notify neighbors uf updated status. - */ - void notifyNeighbors(); + /** + * notify neighbors uf updated status. + */ + void notifyNeighbors(); - /** - * true if the tile is in the world, other wise false. - * - * @return true if tile is in world - */ - boolean isInWorld(); + /** + * true if the tile is in the world, other wise false. + * + * @return true if tile is in world + */ + boolean isInWorld(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/parts/IPartItem.java b/src/api/java/appeng/api/parts/IPartItem.java index 10f3c9f9c..60a4b3076 100644 --- a/src/api/java/appeng/api/parts/IPartItem.java +++ b/src/api/java/appeng/api/parts/IPartItem.java @@ -23,18 +23,18 @@ package appeng.api.parts; - import javax.annotation.Nullable; import net.minecraft.item.ItemStack; //@formatter:off - /** - * This is a pretty basic requirement, once you implement the interface, and createPartFromItemStack + * This is a pretty basic requirement, once you implement the interface, and + * createPartFromItemStack * - * you must register your bus with the Bus renderer, using AEApi.INSTANCE().partHelper().setItemBusRenderer( this ); + * you must register your bus with the Bus renderer, using + * AEApi.INSTANCE().partHelper().setItemBusRenderer( this ); * * then simply add this, and call AE's Bus Placement Code. * @@ -49,16 +49,15 @@ import net.minecraft.item.ItemStack; * * */ -public interface IPartItem

-{ +public interface IPartItem

{ - /** - * create a new part INSTANCE - * - * @param is ItemStack of this item, may have additional properties. - * - * @return part from item - */ - P createPart(ItemStack is); + /** + * create a new part INSTANCE + * + * @param is ItemStack of this item, may have additional properties. + * + * @return part from item + */ + P createPart(ItemStack is); } \ No newline at end of file diff --git a/src/api/java/appeng/api/parts/IPartModel.java b/src/api/java/appeng/api/parts/IPartModel.java index 91b359a14..64e311e58 100644 --- a/src/api/java/appeng/api/parts/IPartModel.java +++ b/src/api/java/appeng/api/parts/IPartModel.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import java.util.Collections; import java.util.List; @@ -31,35 +30,32 @@ import javax.annotation.Nonnull; import net.minecraft.util.ResourceLocation; - /** - * A container to store a collection of {@link ResourceLocation} as models for a part as well as other properties. + * A container to store a collection of {@link ResourceLocation} as models for a + * part as well as other properties. */ -public interface IPartModel -{ +public interface IPartModel { - /** - * A solid {@link IPartModel} indicates that the rendering requires a cable connection, which will also result in - * creating an intersection for the cable. - * - * This should be true for pretty much all parts. - * - * @return true for a solid part. - */ - default boolean requireCableConnection() - { - return true; - } + /** + * A solid {@link IPartModel} indicates that the rendering requires a cable + * connection, which will also result in creating an intersection for the cable. + * + * This should be true for pretty much all parts. + * + * @return true for a solid part. + */ + default boolean requireCableConnection() { + return true; + } - /** - * A collection of {@link ResourceLocation} used as models for a part. - * - * @return a collection of models, never null. - */ - @Nonnull - default List getModels() - { - return Collections.emptyList(); - } + /** + * A collection of {@link ResourceLocation} used as models for a part. + * + * @return a collection of models, never null. + */ + @Nonnull + default List getModels() { + return Collections.emptyList(); + } } diff --git a/src/api/java/appeng/api/parts/IPartModels.java b/src/api/java/appeng/api/parts/IPartModels.java index 332386957..f7dffd397 100644 --- a/src/api/java/appeng/api/parts/IPartModels.java +++ b/src/api/java/appeng/api/parts/IPartModels.java @@ -18,7 +18,6 @@ package appeng.api.parts; - import java.util.Arrays; import java.util.Collection; @@ -26,28 +25,28 @@ import net.minecraft.util.ResourceLocation; import appeng.api.AEInjectable; - /** - * Allows registration of part models that can then be used in {@link IPart#getStaticModels()}. + * Allows registration of part models that can then be used in + * {@link IPart#getStaticModels()}. */ @AEInjectable -public interface IPartModels -{ +public interface IPartModels { - /** - * Allows registration of part models that can then be used in {@link IPart#getStaticModels()}. - * - * Models can be registered multiple times without causing issues. - * - * This method must be called during the pre-init phase (as part of your plugin's constructor). - */ - void registerModels( Collection partModels ); + /** + * Allows registration of part models that can then be used in + * {@link IPart#getStaticModels()}. + * + * Models can be registered multiple times without causing issues. + * + * This method must be called during the pre-init phase (as part of your + * plugin's constructor). + */ + void registerModels(Collection partModels); - /** - * Convenience overload of {@link #registerModels(Collection)} - */ - default void registerModels( ResourceLocation... partModels ) - { - registerModels( Arrays.asList( partModels ) ); - } + /** + * Convenience overload of {@link #registerModels(Collection)} + */ + default void registerModels(ResourceLocation... partModels) { + registerModels(Arrays.asList(partModels)); + } } diff --git a/src/api/java/appeng/api/parts/LayerBase.java b/src/api/java/appeng/api/parts/LayerBase.java index 16787e039..1dcd4c278 100644 --- a/src/api/java/appeng/api/parts/LayerBase.java +++ b/src/api/java/appeng/api/parts/LayerBase.java @@ -23,7 +23,6 @@ package appeng.api.parts; - import java.util.Set; import net.minecraft.tileentity.TileEntity; @@ -32,74 +31,71 @@ import net.minecraft.util.Direction; import appeng.api.util.AEPartLocation; - /** - * 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. + * 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. * * TODO: Consider removing and replacing with capabilities. */ public abstract class LayerBase extends TileEntity // implements IPartHost { - public LayerBase( TileEntityType tileEntityTypeIn ) - { - super( tileEntityTypeIn ); - // TODO Auto-generated constructor stub - } + public LayerBase(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + // TODO Auto-generated constructor stub + } - /** - * Grants access for the layer to the parts of the host. - * - * This Method looks silly, that is because its not used at runtime, a real implementation will be used instead. - * - * @param side side of part - * - * @return the part for the requested side. - */ - public IPart getPart( final AEPartLocation side ) - { - return null; // place holder. - } + /** + * Grants access for the layer to the parts of the host. + * + * This Method looks silly, that is because its not used at runtime, a real + * implementation will be used instead. + * + * @param side side of part + * + * @return the part for the requested side. + */ + public IPart getPart(final AEPartLocation side) { + return null; // place holder. + } - /** - * Grants access for the layer to the parts of the host. - * - * This Method looks silly, that is because its not used at runtime, a real implementation will be used instead. - * - * @param side side of part - * - * @return the part for the requested side. - */ - public IPart getPart( final Direction side ) - { - return null; // place holder. - } + /** + * Grants access for the layer to the parts of the host. + * + * This Method looks silly, that is because its not used at runtime, a real + * implementation will be used instead. + * + * @param side side of part + * + * @return the part for the requested side. + */ + public IPart getPart(final Direction side) { + return null; // place holder. + } - /** - * called when the parts change in the container, YOU MUST CALL super.PartChanged(); - */ - public void notifyNeighbors() - { - } + /** + * called when the parts change in the container, YOU MUST CALL + * super.PartChanged(); + */ + public void notifyNeighbors() { + } - /** - * called when the parts change in the container, YOU MUST CALL super.PartChanged(); - */ - public void partChanged() - { - } + /** + * called when the parts change in the container, YOU MUST CALL + * super.PartChanged(); + */ + public void partChanged() { + } - /** - * @return a mutable list of flags you can adjust to track state. - */ - public Set getLayerFlags() - { - return null; // place holder. - } + /** + * @return a mutable list of flags you can adjust to track state. + */ + public Set getLayerFlags() { + return null; // place holder. + } - public void markForSave() - { - // something! - } + public void markForSave() { + // something! + } } diff --git a/src/api/java/appeng/api/parts/LayerFlags.java b/src/api/java/appeng/api/parts/LayerFlags.java index 1995a5aa9..cce9cfc4a 100644 --- a/src/api/java/appeng/api/parts/LayerFlags.java +++ b/src/api/java/appeng/api/parts/LayerFlags.java @@ -23,13 +23,11 @@ package appeng.api.parts; - /** * TODO: Consider removing and replacing with capabilities. */ -public enum LayerFlags -{ +public enum LayerFlags { - IC2_ENET + IC2_ENET } diff --git a/src/api/java/appeng/api/parts/PartItemStack.java b/src/api/java/appeng/api/parts/PartItemStack.java index e619c420d..6643b4bf6 100644 --- a/src/api/java/appeng/api/parts/PartItemStack.java +++ b/src/api/java/appeng/api/parts/PartItemStack.java @@ -23,16 +23,14 @@ package appeng.api.parts; +public enum PartItemStack { + PICK, -public enum PartItemStack -{ - PICK, + BREAK, - BREAK, + WRENCH, - WRENCH, + NETWORK, - NETWORK, - - WORLD + WORLD } diff --git a/src/api/java/appeng/api/parts/SelectedPart.java b/src/api/java/appeng/api/parts/SelectedPart.java index 84396d616..372f73c95 100644 --- a/src/api/java/appeng/api/parts/SelectedPart.java +++ b/src/api/java/appeng/api/parts/SelectedPart.java @@ -23,50 +23,44 @@ package appeng.api.parts; - import appeng.api.util.AEPartLocation; - /** * Reports a selected part from the IPartHost * */ -public class SelectedPart -{ +public class SelectedPart { - /** - * selected part. - */ - public final IPart part; + /** + * selected part. + */ + public final IPart part; - /** - * facade part. - */ - public final IFacadePart facade; + /** + * facade part. + */ + public final IFacadePart facade; - /** - * side the part is mounted too, or {@link AEPartLocation}.UNKNOWN for cables. - */ - public final AEPartLocation side; + /** + * side the part is mounted too, or {@link AEPartLocation}.UNKNOWN for cables. + */ + public final AEPartLocation side; - public SelectedPart() - { - this.part = null; - this.facade = null; - this.side = AEPartLocation.INTERNAL; - } + public SelectedPart() { + this.part = null; + this.facade = null; + this.side = AEPartLocation.INTERNAL; + } - public SelectedPart( final IPart part, final AEPartLocation side ) - { - this.part = part; - this.facade = null; - this.side = side; - } + public SelectedPart(final IPart part, final AEPartLocation side) { + this.part = part; + this.facade = null; + this.side = side; + } - public SelectedPart( final IFacadePart facade, final AEPartLocation side ) - { - this.part = null; - this.facade = facade; - this.side = side; - } + public SelectedPart(final IFacadePart facade, final AEPartLocation side) { + this.part = null; + this.facade = facade; + this.side = side; + } } diff --git a/src/api/java/appeng/api/recipes/ICraftHandler.java b/src/api/java/appeng/api/recipes/ICraftHandler.java index 4f57f958c..c8eaf8bbc 100644 --- a/src/api/java/appeng/api/recipes/ICraftHandler.java +++ b/src/api/java/appeng/api/recipes/ICraftHandler.java @@ -23,33 +23,32 @@ package appeng.api.recipes; - import java.util.List; import appeng.api.exceptions.MissingIngredientException; import appeng.api.exceptions.RecipeException; import appeng.api.exceptions.RegistrationException; - @Deprecated -public interface ICraftHandler -{ +public interface ICraftHandler { - /** - * Called when your recipe handler receives a newly parsed list of inputs/outputs. - * - * @param input parsed inputs - * @param output parsed outputs - * - * @throws RecipeException - */ - void setup( List> input, List> output ) throws RecipeException; + /** + * Called when your recipe handler receives a newly parsed list of + * inputs/outputs. + * + * @param input parsed inputs + * @param output parsed outputs + * + * @throws RecipeException + */ + void setup(List> input, List> output) throws RecipeException; - /** - * called when all recipes are parsed, and your required to register your recipe. - * - * @throws RegistrationException - * @throws MissingIngredientException - */ - void register() throws RegistrationException, MissingIngredientException; + /** + * called when all recipes are parsed, and your required to register your + * recipe. + * + * @throws RegistrationException + * @throws MissingIngredientException + */ + void register() throws RegistrationException, MissingIngredientException; } diff --git a/src/api/java/appeng/api/recipes/IIngredient.java b/src/api/java/appeng/api/recipes/IIngredient.java index f95782362..cddf05b26 100644 --- a/src/api/java/appeng/api/recipes/IIngredient.java +++ b/src/api/java/appeng/api/recipes/IIngredient.java @@ -23,71 +23,70 @@ package appeng.api.recipes; - import net.minecraft.item.ItemStack; import appeng.api.exceptions.MissingIngredientException; import appeng.api.exceptions.RegistrationException; - @Deprecated -public interface IIngredient -{ +public interface IIngredient { - /** - * Acquire a single input stack for the current recipe, if more then one ItemStack is possible a - * RegistrationError exception will be thrown, ignore these and let the system handle the error. - * - * @return a single ItemStack for the recipe handler. - * - * @throws RegistrationException - * @throws MissingIngredientException - */ - ItemStack getItemStack() throws RegistrationException, MissingIngredientException; + /** + * Acquire a single input stack for the current recipe, if more then one + * ItemStack is possible a RegistrationError exception will be thrown, ignore + * these and let the system handle the error. + * + * @return a single ItemStack for the recipe handler. + * + * @throws RegistrationException + * @throws MissingIngredientException + */ + ItemStack getItemStack() throws RegistrationException, MissingIngredientException; - /** - * Acquire a list of all the input stacks for the current recipe, this is for handlers that support - * multiple inputs per slot. - * - * @return an array of ItemStacks for the recipe handler. - * - * @throws RegistrationException - * @throws MissingIngredientException - */ - ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException; + /** + * Acquire a list of all the input stacks for the current recipe, this is for + * handlers that support multiple inputs per slot. + * + * @return an array of ItemStacks for the recipe handler. + * + * @throws RegistrationException + * @throws MissingIngredientException + */ + ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException; - /** - * If you wish to support air, you must test before getting the ItemStack, or ItemStackSet - * - * @return true if this slot contains no ItemStack, this is passed as "_" - */ - boolean isAir(); + /** + * If you wish to support air, you must test before getting the ItemStack, or + * ItemStackSet + * + * @return true if this slot contains no ItemStack, this is passed as "_" + */ + boolean isAir(); - /** - * @return The Name Space of the item. Prefer getItemStack or getItemStackSet - */ - String getNameSpace(); + /** + * @return The Name Space of the item. Prefer getItemStack or getItemStackSet + */ + String getNameSpace(); - /** - * @return The Name of the item. Prefer getItemStack or getItemStackSet - */ - String getItemName(); + /** + * @return The Name of the item. Prefer getItemStack or getItemStackSet + */ + String getItemName(); - /** - * @return The Damage Value of the item. Prefer getItemStack or getItemStackSet - */ - int getDamageValue(); + /** + * @return The Damage Value of the item. Prefer getItemStack or getItemStackSet + */ + int getDamageValue(); - /** - * @return The Damage Value of the item. Prefer getItemStack or getItemStackSet - */ - int getQty(); + /** + * @return The Damage Value of the item. Prefer getItemStack or getItemStackSet + */ + int getQty(); - /** - * Bakes the lists in for faster runtime look-ups. - * - * @throws MissingIngredientException - * @throws RegistrationException - */ - void bake() throws RegistrationException, MissingIngredientException; + /** + * Bakes the lists in for faster runtime look-ups. + * + * @throws MissingIngredientException + * @throws RegistrationException + */ + void bake() throws RegistrationException, MissingIngredientException; } diff --git a/src/api/java/appeng/api/recipes/IRecipeHandler.java b/src/api/java/appeng/api/recipes/IRecipeHandler.java index 9f2e0bb96..6cc66a7dc 100644 --- a/src/api/java/appeng/api/recipes/IRecipeHandler.java +++ b/src/api/java/appeng/api/recipes/IRecipeHandler.java @@ -23,24 +23,22 @@ package appeng.api.recipes; - /** * Represents the AE2 Recipe Loading/Reading Class */ @Deprecated -public interface IRecipeHandler -{ +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 - */ - void parseRecipes( IRecipeLoader loader, String path ); + /** + * Call when you want to read recipes in from a file based on a loader + * + * @param loader recipe loader + * @param path path of file + */ + void parseRecipes(IRecipeLoader loader, String path); - /** - * this loads the read recipes into minecraft, should be called in Init. - */ - void injectRecipes(); + /** + * 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 a150741cc..96f1ef578 100644 --- a/src/api/java/appeng/api/recipes/IRecipeLoader.java +++ b/src/api/java/appeng/api/recipes/IRecipeLoader.java @@ -23,21 +23,18 @@ package appeng.api.recipes; - import java.io.BufferedReader; import javax.annotation.Nonnull; - @Deprecated -public interface IRecipeLoader -{ - /** - * @param filePath the path to the to be loaded file - * - * @return reader handler of the file - * - * @throws Exception if reading goes wrong - */ - BufferedReader getFile( @Nonnull String filePath ) throws Exception; +public interface IRecipeLoader { + /** + * @param filePath the path to the to be loaded file + * + * @return reader handler of the file + * + * @throws Exception if reading goes wrong + */ + BufferedReader getFile(@Nonnull String filePath) throws Exception; } diff --git a/src/api/java/appeng/api/recipes/ResolverResult.java b/src/api/java/appeng/api/recipes/ResolverResult.java index 2dd70f20f..e02c33ed7 100644 --- a/src/api/java/appeng/api/recipes/ResolverResult.java +++ b/src/api/java/appeng/api/recipes/ResolverResult.java @@ -23,28 +23,23 @@ package appeng.api.recipes; - import net.minecraft.nbt.CompoundNBT; +public class ResolverResult { -public class ResolverResult -{ + public final String itemName; + public final int damageValue; + public final CompoundNBT compound; - public final String itemName; - public final int damageValue; - public final CompoundNBT compound; + public ResolverResult(final String name, final int damage) { + this.itemName = name; + this.damageValue = damage; + this.compound = null; + } - public ResolverResult( final String name, final int damage ) - { - this.itemName = name; - this.damageValue = damage; - this.compound = null; - } - - public ResolverResult( final String name, final int damage, final CompoundNBT data ) - { - this.itemName = name; - this.damageValue = damage; - this.compound = data; - } + public ResolverResult(final String name, final int damage, final CompoundNBT 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 7705d8304..8750b2c55 100644 --- a/src/api/java/appeng/api/recipes/ResolverResultSet.java +++ b/src/api/java/appeng/api/recipes/ResolverResultSet.java @@ -23,22 +23,18 @@ package appeng.api.recipes; - import java.util.Arrays; import java.util.List; import net.minecraft.item.ItemStack; +public class ResolverResultSet { -public class ResolverResultSet -{ + public final String name; + public final List results; - public final String name; - public final List results; - - public ResolverResultSet( final String myName, final ItemStack... set ) - { - this.results = Arrays.asList( set ); - this.name = myName; - } + public ResolverResultSet(final String myName, final 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 4445dd3e4..db0c10d16 100644 --- a/src/api/java/appeng/api/storage/ICellContainer.java +++ b/src/api/java/appeng/api/storage/ICellContainer.java @@ -23,20 +23,19 @@ 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. + * Represents an {@link appeng.api.networking.IGridHost} that contributes to + * storage, such as a ME Chest, or ME Drive. */ -public interface ICellContainer extends IActionHost, ICellProvider, ISaveProvider -{ +public interface ICellContainer extends IActionHost, ICellProvider, ISaveProvider { - /** - * tell the Cell container that this slot should blink, the slot number is relative to the - * - * @param slot slot index - */ - void blinkCell( int slot ); + /** + * tell the Cell container that this slot should blink, the slot number is + * relative to the + * + * @param slot slot index + */ + void blinkCell(int slot); } diff --git a/src/api/java/appeng/api/storage/ICellGuiHandler.java b/src/api/java/appeng/api/storage/ICellGuiHandler.java index 733967852..43052d545 100644 --- a/src/api/java/appeng/api/storage/ICellGuiHandler.java +++ b/src/api/java/appeng/api/storage/ICellGuiHandler.java @@ -1,47 +1,45 @@ package appeng.api.storage; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import appeng.api.implementations.tiles.IChestOrDrive; import appeng.api.storage.data.IAEStack; +public interface ICellGuiHandler { + /** + * Return true if this handler can show GUI for this channel. + * + * @param channel Storage channel + * @return True if handled, else false. + */ + > boolean isHandlerFor(IStorageChannel channel); -public interface ICellGuiHandler -{ - /** - * Return true if this handler can show GUI for this channel. - * - * @param channel Storage channel - * @return True if handled, else false. - */ - > boolean isHandlerFor( IStorageChannel channel ); + /** + * Return true to prioritize this handler for the provided {@link ItemStack}. + * + * @param is Cell ItemStack + * @return True, if specialized else false. + */ + default boolean isSpecializedFor(ItemStack is) { + return false; + } - /** - * Return true to prioritize this handler for the provided {@link ItemStack}. - * - * @param is Cell ItemStack - * @return True, if specialized else false. - */ - default boolean isSpecializedFor( ItemStack is ) - { - return false; - } - - /** - * Called when the storage cell is placed in an ME Chest and the user tries to open the terminal side, if your item - * is not available via ME Chests simply tell the user they can't use it, or something, other wise you should open - * your gui and display the cell to the user. - * - * @param player player opening chest gui - * @param chest to be opened chest - * @param cellHandler cell handler - * @param inv inventory handler - * @param is item - * @param chan storage channel - */ - > void openChestGui( PlayerEntity player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, IStorageChannel chan ); + /** + * Called when the storage cell is placed in an ME Chest and the user tries to + * open the terminal side, if your item is not available via ME Chests simply + * tell the user they can't use it, or something, other wise you should open + * your gui and display the cell to the user. + * + * @param player player opening chest gui + * @param chest to be opened chest + * @param cellHandler cell handler + * @param inv inventory handler + * @param is item + * @param chan storage channel + */ + > void openChestGui(PlayerEntity player, IChestOrDrive chest, ICellHandler cellHandler, + IMEInventoryHandler inv, ItemStack is, IStorageChannel chan); } diff --git a/src/api/java/appeng/api/storage/ICellHandler.java b/src/api/java/appeng/api/storage/ICellHandler.java index 3b626d467..25788c672 100644 --- a/src/api/java/appeng/api/storage/ICellHandler.java +++ b/src/api/java/appeng/api/storage/ICellHandler.java @@ -23,79 +23,75 @@ package appeng.api.storage; - import net.minecraft.item.ItemStack; import appeng.api.storage.data.IAEStack; - /** * Registration record for {@link ICellRegistry} */ -public interface ICellHandler -{ +public interface ICellHandler { - /** - * return true if the provided item is handled by your cell handler. ( AE May choose to skip this method, and just - * request a handler ) - * - * @param is to be checked item - * - * @return return true, if getCellHandler will not return null. - */ - boolean isCell( ItemStack is ); + /** + * return true if the provided item is handled by your cell handler. ( AE May + * choose to skip this method, and just request a handler ) + * + * @param is to be checked item + * + * @return return true, if getCellHandler will not return null. + */ + boolean isCell(ItemStack is); - /** - * If you cannot handle the provided item, return null - * - * @param is a storage cell item. - * @param host anytime the contents of your storage cell changes it should use this to request a save, please - * note, this value can be null. If provided, the host is responsible for persisting the cell content. - * @param channel the storage channel requested. - * - * @return a new IMEHandler for the provided item - */ - > ICellInventoryHandler getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel channel ); + /** + * If you cannot handle the provided item, return null + * + * @param is a storage cell item. + * @param host anytime the contents of your storage cell changes it should + * use this to request a save, please note, this value can be + * null. If provided, the host is responsible for persisting the + * cell content. + * @param channel the storage channel requested. + * + * @return a new IMEHandler for the provided item + */ + > ICellInventoryHandler getCellInventory(ItemStack is, ISaveProvider host, + IStorageChannel channel); - /** - * 0 - cell is missing. - * - * 1 - green, ( usually means available room for types or items. ) - * - * 2 - orange, ( usually means available room for items, but not types. ) - * - * 3 - red, ( usually means the cell is 100% full ) - * - * @param is the cell item. ( use the handler for any details you can ) - * @param handler the handler for the cell is provides for reference, you can cast this to your handler. - * - * @return get the status of the cell based on its contents. - */ - default > int getStatusForCell( ItemStack is, ICellInventoryHandler handler ) - { - if( handler.getCellInv() != null ) - { - int val = handler.getCellInv().getStatusForCell(); + /** + * 0 - cell is missing. + * + * 1 - green, ( usually means available room for types or items. ) + * + * 2 - orange, ( usually means available room for items, but not types. ) + * + * 3 - red, ( usually means the cell is 100% full ) + * + * @param is the cell item. ( use the handler for any details you can ) + * @param handler the handler for the cell is provides for reference, you can + * cast this to your handler. + * + * @return get the status of the cell based on its contents. + */ + default > int getStatusForCell(ItemStack is, ICellInventoryHandler handler) { + if (handler.getCellInv() != null) { + int val = handler.getCellInv().getStatusForCell(); - if( val == 1 && handler.isPreformatted() ) - { - val = 2; - } + if (val == 1 && handler.isPreformatted()) { + val = 2; + } - return val; - } - return 0; - } + return val; + } + return 0; + } - /** - * @return the ae/t to drain for this storage cell inside a chest/drive. - */ - default > double cellIdleDrain( ItemStack is, ICellInventoryHandler handler ) - { - if( handler.getCellInv() != null ) - { - return handler.getCellInv().getIdleDrain(); - } - return 1.0; - } + /** + * @return the ae/t to drain for this storage cell inside a chest/drive. + */ + default > double cellIdleDrain(ItemStack is, ICellInventoryHandler handler) { + if (handler.getCellInv() != null) { + return handler.getCellInv().getIdleDrain(); + } + return 1.0; + } } \ No newline at end of file diff --git a/src/api/java/appeng/api/storage/ICellInventory.java b/src/api/java/appeng/api/storage/ICellInventory.java index fa37b4c3d..52d9010ab 100644 --- a/src/api/java/appeng/api/storage/ICellInventory.java +++ b/src/api/java/appeng/api/storage/ICellInventory.java @@ -23,112 +23,109 @@ package appeng.api.storage; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEStack; +public interface ICellInventory> extends IMEInventory { -public interface ICellInventory> extends IMEInventory -{ + /** + * @return the item stack of this storage cell. + */ + ItemStack getItemStack(); - /** - * @return the item stack of this storage cell. - */ - ItemStack getItemStack(); + /** + * @return the ae/t to drain for this storage cell inside a chest/drive. + */ + double getIdleDrain(); - /** - * @return the ae/t to drain for this storage cell inside a chest/drive. - */ - double getIdleDrain(); + /** + * @return fuzzy setting + */ + FuzzyMode getFuzzyMode(); - /** - * @return fuzzy setting - */ - FuzzyMode getFuzzyMode(); + /** + * @return access configured list + */ + IItemHandler getConfigInventory(); - /** - * @return access configured list - */ - IItemHandler getConfigInventory(); + /** + * @return access installed upgrades. + */ + IItemHandler getUpgradesInventory(); - /** - * @return access installed upgrades. - */ - IItemHandler getUpgradesInventory(); + /** + * @return How many bytes are used for each type? + */ + int getBytesPerType(); - /** - * @return How many bytes are used for each type? - */ - int getBytesPerType(); + /** + * @return true if a new item type can be added. + */ + boolean canHoldNewItem(); - /** - * @return true if a new item type can be added. - */ - boolean canHoldNewItem(); + /** + * @return total byte storage. + */ + long getTotalBytes(); - /** - * @return total byte storage. - */ - long getTotalBytes(); + /** + * @return how many bytes are free. + */ + long getFreeBytes(); - /** - * @return how many bytes are free. - */ - long getFreeBytes(); + /** + * @return how many bytes are in use. + */ + long getUsedBytes(); - /** - * @return how many bytes are in use. - */ - long getUsedBytes(); + /** + * @return max number of types. + */ + long getTotalItemTypes(); - /** - * @return max number of types. - */ - long getTotalItemTypes(); + /** + * @return how many items are stored. + */ + long getStoredItemCount(); - /** - * @return how many items are stored. - */ - long getStoredItemCount(); + /** + * @return how many items types are currently stored. + */ + long getStoredItemTypes(); - /** - * @return how many items types are currently stored. - */ - long getStoredItemTypes(); + /** + * @return how many item types remain. + */ + long getRemainingItemTypes(); - /** - * @return how many item types remain. - */ - long getRemainingItemTypes(); + /** + * @return how many more items can be stored. + */ + long getRemainingItemCount(); - /** - * @return how many more items can be stored. - */ - long getRemainingItemCount(); + /** + * @return how many items can be added without consuming another byte. + */ + int getUnusedItemCount(); - /** - * @return how many items can be added without consuming another byte. - */ - int getUnusedItemCount(); + /** + * 0 - cell is missing. + * + * 1 - green, ( usually means available room for types or items. ) + * + * 2 - orange, ( usually means available room for items, but not types. ) + * + * 3 - red, ( usually means the cell is 100% full ) + * + * @return get the status of the cell based on its contents. + */ + int getStatusForCell(); - /** - * 0 - cell is missing. - * - * 1 - green, ( usually means available room for types or items. ) - * - * 2 - orange, ( usually means available room for items, but not types. ) - * - * 3 - red, ( usually means the cell is 100% full ) - * - * @return get the status of the cell based on its contents. - */ - int getStatusForCell(); - - /** - * Tells the cell to persist to NBT - */ - void persist(); + /** + * Tells the cell to persist to NBT + */ + void persist(); } diff --git a/src/api/java/appeng/api/storage/ICellInventoryHandler.java b/src/api/java/appeng/api/storage/ICellInventoryHandler.java index a29228cf8..3325560d0 100644 --- a/src/api/java/appeng/api/storage/ICellInventoryHandler.java +++ b/src/api/java/appeng/api/storage/ICellInventoryHandler.java @@ -23,27 +23,24 @@ package appeng.api.storage; - import javax.annotation.Nullable; import appeng.api.config.IncludeExclude; import appeng.api.storage.data.IAEStack; +public interface ICellInventoryHandler> extends IMEInventoryHandler { -public interface ICellInventoryHandler> extends IMEInventoryHandler -{ + /** + * Get access to the ICellInventory. Can be null for custom cells. + * + * @return get access to the Cell Inventory. + */ + @Nullable + ICellInventory getCellInv(); - /** - * Get access to the ICellInventory. Can be null for custom cells. - * - * @return get access to the Cell Inventory. - */ - @Nullable - ICellInventory getCellInv(); + boolean isPreformatted(); - boolean isPreformatted(); + boolean isFuzzy(); - boolean isFuzzy(); - - IncludeExclude getIncludeExcludeMode(); + IncludeExclude getIncludeExcludeMode(); } diff --git a/src/api/java/appeng/api/storage/ICellProvider.java b/src/api/java/appeng/api/storage/ICellProvider.java index 4188ac705..2414354ad 100644 --- a/src/api/java/appeng/api/storage/ICellProvider.java +++ b/src/api/java/appeng/api/storage/ICellProvider.java @@ -23,31 +23,31 @@ package appeng.api.storage; - import java.util.List; - /** - * Allows you to provide cells via non IGridHosts directly to the storage system, drives, and similar features should go - * though {@link ICellContainer} and be automatically handled by the storage system. + * Allows you to provide cells via non IGridHosts directly to the storage + * system, drives, and similar features should go though {@link ICellContainer} + * and be automatically handled by the storage system. */ -public interface ICellProvider -{ +public interface ICellProvider { - /** - * Inventory of the tile for use with ME, should always return an valid list, never NULL. - * - * You must return the correct Handler for the correct channel, if your handler returns a IAEItemStack handler, for - * a Fluid Channel stuffs going to explode, same with the reverse. - * - * @return a valid list of handlers, NEVER NULL - */ - List getCellArray( IStorageChannel channel ); + /** + * Inventory of the tile for use with ME, should always return an valid list, + * never NULL. + * + * You must return the correct Handler for the correct channel, if your handler + * returns a IAEItemStack handler, for a Fluid Channel stuffs going to explode, + * same with the reverse. + * + * @return a valid list of handlers, NEVER NULL + */ + List getCellArray(IStorageChannel channel); - /** - * the storage's priority. - * - * Positive and negative are supported - */ - int getPriority(); + /** + * the storage's priority. + * + * Positive and negative are supported + */ + int getPriority(); } diff --git a/src/api/java/appeng/api/storage/ICellRegistry.java b/src/api/java/appeng/api/storage/ICellRegistry.java index c0f1577a6..2137579b1 100644 --- a/src/api/java/appeng/api/storage/ICellRegistry.java +++ b/src/api/java/appeng/api/storage/ICellRegistry.java @@ -23,7 +23,6 @@ package appeng.api.storage; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -32,72 +31,75 @@ import net.minecraft.item.ItemStack; import appeng.api.IAppEngApi; import appeng.api.storage.data.IAEStack; - /** - * Storage Cell Registry, used for specially implemented cells, if you just want to make a item act like a cell, or new - * cell with different bytes, then you should probably consider IStorageCell instead its considerably simpler. + * Storage Cell Registry, used for specially implemented cells, if you just want + * to make a item act like a cell, or new cell with different bytes, then you + * should probably consider IStorageCell instead its considerably simpler. * * Do not Implement, obtained via {@link IAppEngApi}.getCellRegistry() */ -public interface ICellRegistry -{ +public interface ICellRegistry { - /** - * Register a new handler. - * - * Never be call before {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} was handled by AE2. - * Will throw an exception otherwise. - * - * @param handler cell handler - */ - void addCellHandler( @Nonnull ICellHandler handler ); + /** + * Register a new handler. + * + * Never be call before + * {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} was + * handled by AE2. Will throw an exception otherwise. + * + * @param handler cell handler + */ + void addCellHandler(@Nonnull ICellHandler handler); - /** - * Register a new handler - * - * @param handler cell gui handler - */ - void addCellGuiHandler( @Nonnull ICellGuiHandler handler ); + /** + * Register a new handler + * + * @param handler cell gui handler + */ + void addCellGuiHandler(@Nonnull ICellGuiHandler handler); - /** - * return true, if you can get a InventoryHandler for the item passed. - * - * @param is to be checked item - * - * @return true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get - * the handler instead. ) - */ - boolean isCellHandled( ItemStack is ); + /** + * return true, if you can get a InventoryHandler for the item passed. + * + * @param is to be checked item + * + * @return true if the provided item, can be handled by a handler in AE, ( AE + * May choose to skip this and just get the handler instead. ) + */ + boolean isCellHandled(ItemStack is); - /** - * get the handler, for the requested item. - * - * @param is to be checked item - * - * @return the handler registered for this item type. - */ - @Nullable - ICellHandler getHandler( ItemStack is ); + /** + * get the handler, for the requested item. + * + * @param is to be checked item + * + * @return the handler registered for this item type. + */ + @Nullable + ICellHandler getHandler(ItemStack is); - /** - * get the handler, for the requested channel. - * - * @param channel requested channel - * @param Cell ItemStack - * @return the handler registered for this channel. - */ - @Nullable - > ICellGuiHandler getGuiHandler( IStorageChannel channel, ItemStack is ); + /** + * get the handler, for the requested channel. + * + * @param channel requested channel + * @param Cell ItemStack + * @return the handler registered for this channel. + */ + @Nullable + > ICellGuiHandler getGuiHandler(IStorageChannel channel, ItemStack is); - /** - * returns an ICellInventoryHandler for the provided item by querying all registered handlers. - * - * @param is item with inventory handler - * @param host can be null. If provided, the host is responsible for persisting the cell content. - * @param chan the storage channel to request the handler for. - * - * @return new ICellInventoryHandler, or null if there isn't one. - */ - @Nullable - > ICellInventoryHandler getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel chan ); + /** + * returns an ICellInventoryHandler for the provided item by querying all + * registered handlers. + * + * @param is item with inventory handler + * @param host can be null. If provided, the host is responsible for persisting + * the cell content. + * @param chan the storage channel to request the handler for. + * + * @return new ICellInventoryHandler, or null if there isn't one. + */ + @Nullable + > ICellInventoryHandler getCellInventory(ItemStack is, ISaveProvider host, + IStorageChannel chan); } \ No newline at end of file diff --git a/src/api/java/appeng/api/storage/ICellWorkbenchItem.java b/src/api/java/appeng/api/storage/ICellWorkbenchItem.java index d55efc2ae..a630584de 100644 --- a/src/api/java/appeng/api/storage/ICellWorkbenchItem.java +++ b/src/api/java/appeng/api/storage/ICellWorkbenchItem.java @@ -23,49 +23,48 @@ package appeng.api.storage; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.api.config.FuzzyMode; +public interface ICellWorkbenchItem { -public interface ICellWorkbenchItem -{ + /** + * if this return false, the item will not be treated as a cell, and cannot be + * inserted into the work bench. + * + * @param is item + * + * @return true if the item should be editable in the cell workbench. + */ + boolean isEditable(ItemStack is); - /** - * if this return false, the item will not be treated as a cell, and cannot be inserted into the work bench. - * - * @param is item - * - * @return true if the item should be editable in the cell workbench. - */ - boolean isEditable( ItemStack is ); + /** + * used to edit the upgrade slots on your cell, should have a capacity of 0-24, + * you are also responsible for implementing the valid checks, and any + * storage/usage of them. + * + * onInventoryChange will be called when saving is needed. + */ + IItemHandler getUpgradesInventory(ItemStack is); - /** - * used to edit the upgrade slots on your cell, should have a capacity of 0-24, you are also responsible for - * implementing the valid checks, and any storage/usage of them. - * - * onInventoryChange will be called when saving is needed. - */ - IItemHandler getUpgradesInventory( ItemStack is ); + /** + * Used to extract, or mirror the contents of the work bench onto the cell. + * + * - This should have exactly 63 slots, any more, or less might cause issues. + * + * onInventoryChange will be called when saving is needed. + */ + IItemHandler getConfigInventory(ItemStack is); - /** - * Used to extract, or mirror the contents of the work bench onto the cell. - * - * - This should have exactly 63 slots, any more, or less might cause issues. - * - * onInventoryChange will be called when saving is needed. - */ - IItemHandler getConfigInventory( ItemStack is ); + /** + * @return the current fuzzy status. + */ + FuzzyMode getFuzzyMode(ItemStack is); - /** - * @return the current fuzzy status. - */ - FuzzyMode getFuzzyMode( ItemStack is ); - - /** - * sets the setting on the cell. - */ - void setFuzzyMode( ItemStack is, FuzzyMode fzMode ); + /** + * sets the setting on the cell. + */ + void setFuzzyMode(ItemStack is, FuzzyMode fzMode); } diff --git a/src/api/java/appeng/api/storage/IMEInventory.java b/src/api/java/appeng/api/storage/IMEInventory.java index 4e2006b85..ea945dd90 100644 --- a/src/api/java/appeng/api/storage/IMEInventory.java +++ b/src/api/java/appeng/api/storage/IMEInventory.java @@ -23,58 +23,57 @@ package appeng.api.storage; - import appeng.api.config.Actionable; import appeng.api.networking.security.IActionSource; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; - /** - * AE's Equivalent to IInventory, used to reading contents, and manipulating contents of ME Inventories. + * AE's Equivalent to IInventory, used to reading contents, and manipulating + * contents of ME Inventories. * - * Implementations should COMPLETELY ignore stack size limits from an external view point, Meaning that you can inject - * Integer.MAX_VALUE items and it should work as defined, or be able to extract Integer.MAX_VALUE and have it work as + * Implementations should COMPLETELY ignore stack size limits from an external + * view point, Meaning that you can inject Integer.MAX_VALUE items and it should + * work as defined, or be able to extract Integer.MAX_VALUE and have it work as * defined, Translations to MC's max stack size are external to the AE API. * - * If you want to request a stack of an item, you should should determine that prior to requesting the stack from the - * inventory. + * If you want to request a stack of an item, you should should determine that + * prior to requesting the stack from the inventory. */ -public interface IMEInventory> -{ +public interface IMEInventory> { - /** - * Store new items, or simulate the addition of new items into the ME Inventory. - * - * @param input item to add. - * @param type action type - * @param src action source - * - * @return returns the number of items not added. - */ - T injectItems( T input, Actionable type, IActionSource src ); + /** + * Store new items, or simulate the addition of new items into the ME Inventory. + * + * @param input item to add. + * @param type action type + * @param src action source + * + * @return returns the number of items not added. + */ + T injectItems(T input, Actionable type, IActionSource src); - /** - * Extract the specified item from the ME Inventory - * - * @param request item to request ( with stack size. ) - * @param mode simulate, or perform action? - * - * @return returns the number of items extracted, null - */ - T extractItems( T request, Actionable mode, IActionSource src ); + /** + * Extract the specified item from the ME Inventory + * + * @param request item to request ( with stack size. ) + * @param mode simulate, or perform action? + * + * @return returns the number of items extracted, null + */ + T extractItems(T request, Actionable mode, IActionSource src); - /** - * request a full report of all available items, storage. - * - * @param out the IItemList the results will be written too - * - * @return returns same list that was passed in, is passed out - */ - IItemList getAvailableItems( IItemList out ); + /** + * request a full report of all available items, storage. + * + * @param out the IItemList the results will be written too + * + * @return returns same list that was passed in, is passed out + */ + IItemList getAvailableItems(IItemList out); - /** - * @return the type of channel your handler should be part of - */ - IStorageChannel getChannel(); + /** + * @return the type of channel your handler should be part of + */ + IStorageChannel getChannel(); } diff --git a/src/api/java/appeng/api/storage/IMEInventoryHandler.java b/src/api/java/appeng/api/storage/IMEInventoryHandler.java index 86f9aa632..b34e7d8b1 100644 --- a/src/api/java/appeng/api/storage/IMEInventoryHandler.java +++ b/src/api/java/appeng/api/storage/IMEInventoryHandler.java @@ -23,70 +23,71 @@ package appeng.api.storage; - import appeng.api.config.AccessRestriction; import appeng.api.storage.data.IAEStack; - /** - * Thin logic layer that can be swapped with different IMEInventory implementations, used to handle features related to - * storage, that are Separate from the storage medium itself. + * Thin logic layer that can be swapped with different IMEInventory + * implementations, used to handle features related to storage, that are + * Separate from the storage medium itself. * * @param */ -public interface IMEInventoryHandler> extends IMEInventory -{ +public interface IMEInventoryHandler> extends IMEInventory { - /** - * determine if items can be injected/extracted. - * - * @return the access - */ - AccessRestriction getAccess(); + /** + * determine if items can be injected/extracted. + * + * @return the access + */ + AccessRestriction getAccess(); - /** - * determine if a particular item is prioritized for this inventory handler, if it is, then it will be added to this - * inventory prior to any non-prioritized inventories. - * - * @param input - item that might be added - * - * @return if its prioritized - */ - boolean isPrioritized( T input ); + /** + * determine if a particular item is prioritized for this inventory handler, if + * it is, then it will be added to this inventory prior to any non-prioritized + * inventories. + * + * @param input - item that might be added + * + * @return if its prioritized + */ + boolean isPrioritized(T input); - /** - * determine if an item can be accepted and stored. - * - * @param input - item that might be added - * - * @return if the item can be added - */ - boolean canAccept( T input ); + /** + * determine if an item can be accepted and stored. + * + * @param input - item that might be added + * + * @return if the item can be added + */ + boolean canAccept(T input); - /** - * determine what the priority of the inventory is. - * - * @return the priority, zero is default, positive and negative are supported. - */ - int getPriority(); + /** + * determine what the priority of the inventory is. + * + * @return the priority, zero is default, positive and negative are supported. + */ + int getPriority(); - /** - * pass back value for blinkCell. - * - * @return the slot index for the cell that this represents in the storage unit, the method on the - * {@link ICellContainer} will be called with this value, only trust the return value of this method if you - * are the implementer of this. - */ - int getSlot(); + /** + * pass back value for blinkCell. + * + * @return the slot index for the cell that this represents in the storage unit, + * the method on the {@link ICellContainer} will be called with this + * value, only trust the return value of this method if you are the + * implementer of this. + */ + int getSlot(); - /** - * AE Uses a two pass placement system, the first pass checks contents and tries to find a place where the item - * belongs, however in some cases you can save processor time, or require that the second, or first pass is simply - * ignored, this allows you to do that. - * - * @param i - pass number ( 1 or 2 ) - * - * @return true, if this inventory is valid for this pass. - */ - boolean validForPass( int i ); + /** + * AE Uses a two pass placement system, the first pass checks contents and tries + * to find a place where the item belongs, however in some cases you can save + * processor time, or require that the second, or first pass is simply ignored, + * this allows you to do that. + * + * @param i - pass number ( 1 or 2 ) + * + * @return true, if this inventory is valid for this pass. + */ + boolean validForPass(int i); } diff --git a/src/api/java/appeng/api/storage/IMEMonitor.java b/src/api/java/appeng/api/storage/IMEMonitor.java index ecc89a440..a301a6028 100644 --- a/src/api/java/appeng/api/storage/IMEMonitor.java +++ b/src/api/java/appeng/api/storage/IMEMonitor.java @@ -23,26 +23,24 @@ 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 { -public interface IMEMonitor> extends IMEInventoryHandler, IBaseMonitor -{ + /** + * This method is discouraged when accessing data via a IMEMonitor + */ + @Override + @Deprecated + IItemList getAvailableItems(IItemList out); - /** - * This method is discouraged when accessing data via a IMEMonitor - */ - @Override - @Deprecated - IItemList getAvailableItems( IItemList out ); - - /** - * Get access to the full item list of the network, preferred over {@link IMEInventory} .getAvailableItems(...) - * - * @return full storage list. - */ - IItemList getStorageList(); + /** + * Get access to the full item list of the network, preferred over + * {@link IMEInventory} .getAvailableItems(...) + * + * @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 c7b0d88a7..63ca8d241 100644 --- a/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java +++ b/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java @@ -23,33 +23,32 @@ package appeng.api.storage; - import appeng.api.networking.security.IActionSource; import appeng.api.networking.storage.IBaseMonitor; import appeng.api.storage.data.IAEStack; +public interface IMEMonitorHandlerReceiver> { -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); - /** - * 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 ); + /** + * 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, IActionSource actionSource); - /** - * 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, IActionSource actionSource ); - - /** - * called when the list updates its contents, this is mostly for handling power events. - */ - void onListUpdate(); + /** + * 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 c6e8f0afa..521d118c6 100644 --- a/src/api/java/appeng/api/storage/ISaveProvider.java +++ b/src/api/java/appeng/api/storage/ISaveProvider.java @@ -23,20 +23,18 @@ package appeng.api.storage; - import javax.annotation.Nullable; - /** - * Tells the cell provider that changes have been made an the cell must be persisted + * Tells the cell provider that changes have been made an the cell must be + * persisted * */ -public interface ISaveProvider -{ - /** - * Cell has changed and needs to be changed. - * - * @param cellInventory can be null for custom cells. - */ - void saveChanges( @Nullable ICellInventory cellInventory ); +public interface ISaveProvider { + /** + * Cell has changed and needs to be changed. + * + * @param cellInventory can be null for custom cells. + */ + void saveChanges(@Nullable ICellInventory cellInventory); } diff --git a/src/api/java/appeng/api/storage/ISpatialDimension.java b/src/api/java/appeng/api/storage/ISpatialDimension.java index 08b607e6c..5f661c971 100644 --- a/src/api/java/appeng/api/storage/ISpatialDimension.java +++ b/src/api/java/appeng/api/storage/ISpatialDimension.java @@ -18,6 +18,9 @@ package appeng.api.storage; +import java.util.List; + +import javax.annotation.Nullable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; @@ -25,29 +28,24 @@ import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; -import javax.annotation.Nullable; -import java.util.List; +public interface ISpatialDimension { + ServerWorld getWorld(DimensionType cellDim); + @Nullable + DimensionType createNewCellDimension(BlockPos capacity); -public interface ISpatialDimension -{ - ServerWorld getWorld(DimensionType cellDim ); + void deleteCellDimension(DimensionType cellDim); - @Nullable - DimensionType createNewCellDimension(BlockPos capacity); + boolean isCellDimension(DimensionType cellDim); - void deleteCellDimension( DimensionType cellDim ); + BlockPos getCellDimensionOrigin(DimensionType cellDim); - boolean isCellDimension( DimensionType cellDim ); + BlockPos getCellDimensionSize(DimensionType cellDim); - BlockPos getCellDimensionOrigin( DimensionType cellDim ); - - BlockPos getCellDimensionSize(DimensionType cellDim ); - - /** - * Adds a user-facing tooltip that describes this dimension so that a player - * can keep storage cells apart. - */ - void addCellDimensionTooltip(DimensionType cellDim, List lines); + /** + * Adds a user-facing tooltip that describes this dimension so that a player can + * keep storage cells apart. + */ + void addCellDimensionTooltip(DimensionType cellDim, List lines); } diff --git a/src/api/java/appeng/api/storage/IStorageChannel.java b/src/api/java/appeng/api/storage/IStorageChannel.java index e455a12c4..a400fdc7a 100644 --- a/src/api/java/appeng/api/storage/IStorageChannel.java +++ b/src/api/java/appeng/api/storage/IStorageChannel.java @@ -23,8 +23,8 @@ package appeng.api.storage; - import java.io.IOException; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -36,73 +36,70 @@ import net.minecraftforge.fluids.FluidStack; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public interface IStorageChannel> { -public interface IStorageChannel> -{ + /** + * Can be used as factor for transferring stacks of a channel. + * + * E.g. used by IO Ports to transfer 1000 mB, not 1 mB to match the item channel + * transferring a full bucket per operation. + * + * @return + */ + default int transferFactor() { + return 1; + } - /** - * Can be used as factor for transferring stacks of a channel. - * - * E.g. used by IO Ports to transfer 1000 mB, not 1 mB to match the - * item channel transferring a full bucket per operation. - * - * @return - */ - default int transferFactor() - { - return 1; - } + /** + * The number of units (eg item count, or millibuckets) that can be stored per + * byte in a storage cell. Standard value for items is 8, and for fluids it's + * 8000 + * + * @return number of units + */ + default int getUnitsPerByte() { + return 8; + } - /** - * The number of units (eg item count, or millibuckets) that can be stored per byte in a storage cell. - * Standard value for items is 8, and for fluids it's 8000 - * - * @return number of units - */ - default int getUnitsPerByte() - { - return 8; - } + /** + * Create a new {@link IItemList} of the specific type. + * + * @return + */ + @Nonnull + IItemList createList(); - /** - * Create a new {@link IItemList} of the specific type. - * - * @return - */ - @Nonnull - IItemList createList(); + /** + * Create a new {@link IAEStack} subtype of the specific object. + * + * The parameter is unbound to allow a slightly more flexible approach. But the + * general intention is about converting an {@link ItemStack} or + * {@link FluidStack} into the corresponding {@link IAEStack}. Another valid + * case might be to use it instead of {@link IAEStack#copy()}, but this might + * not be supported by all types. IAEStacks that use custom items for + * {@link IAEStack#asItemStackRepresentation()} must also be able to convert + * these. + * + * @param input The object to turn into an {@link IAEStack} + * @return The converted stack or null + */ + @Nullable + T createStack(@Nonnull Object input); - /** - * Create a new {@link IAEStack} subtype of the specific object. - * - * The parameter is unbound to allow a slightly more flexible approach. - * But the general intention is about converting an {@link ItemStack} or {@link FluidStack} into the corresponding - * {@link IAEStack}. - * Another valid case might be to use it instead of {@link IAEStack#copy()}, but this might not be supported by all - * types. - * IAEStacks that use custom items for {@link IAEStack#asItemStackRepresentation()} must also be able to convert - * these. - * - * @param input The object to turn into an {@link IAEStack} - * @return The converted stack or null - */ - @Nullable - T createStack( @Nonnull Object input ); + /** + * @param input + * @return + * @throws IOException + */ + @Nullable + T readFromPacket(@Nonnull PacketBuffer input); - /** - * @param input - * @return - * @throws IOException - */ - @Nullable - T readFromPacket( @Nonnull PacketBuffer input ); - - /** - * create from nbt data - * - * @param nbt - * @return - */ - @Nullable - T createFromNBT( @Nonnull CompoundNBT nbt ); + /** + * create from nbt data + * + * @param nbt + * @return + */ + @Nullable + T createFromNBT(@Nonnull CompoundNBT nbt); } diff --git a/src/api/java/appeng/api/storage/IStorageHelper.java b/src/api/java/appeng/api/storage/IStorageHelper.java index b9f6b545b..642a32eda 100644 --- a/src/api/java/appeng/api/storage/IStorageHelper.java +++ b/src/api/java/appeng/api/storage/IStorageHelper.java @@ -23,7 +23,6 @@ package appeng.api.storage; - import java.util.Collection; import javax.annotation.Nonnull; @@ -41,92 +40,100 @@ import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; +public interface IStorageHelper { -public interface IStorageHelper -{ + /** + * Register a new storage channel. + * + * AE2 already provides native channels for {@link IAEItemStack} and + * {@link IAEFluidStack}. + * + * Each {@link IAEStack} subtype can only have a single factory instance. + * Overwriting is not intended. Each subtype should be a direct one, this might + * be enforced at any time. + * + * Channel class and factory instance can be used interchangeable as identifier. + * In most cases the factory instance is used as key as having direct access the + * methods is more beneficial compared to being forced to query the registry + * each time. + * + * Caching the factory instance in a field or local variable is perfectly for + * performance reasons. But do not use any AE2 internal field as they can change + * randomly between releases. + * + * @param channel The channel type, must be a subtype of {@link IStorageChannel} + * @param factory An instance implementing the channel, must be be an instance + * of channel + */ + @Nonnull + , C extends IStorageChannel> void registerStorageChannel(@Nonnull Class channel, + @Nonnull C factory); - /** - * Register a new storage channel. - * - * AE2 already provides native channels for {@link IAEItemStack} and {@link IAEFluidStack}. - * - * Each {@link IAEStack} subtype can only have a single factory instance. Overwriting is not intended. - * Each subtype should be a direct one, this might be enforced at any time. - * - * Channel class and factory instance can be used interchangeable as identifier. In most cases the factory instance - * is used as key as having direct access the methods is more beneficial compared to being forced to query the - * registry each time. - * - * Caching the factory instance in a field or local variable is perfectly for performance reasons. But do not use - * any AE2 internal field as they can change randomly between releases. - * - * @param channel The channel type, must be a subtype of {@link IStorageChannel} - * @param factory An instance implementing the channel, must be be an instance of channel - */ - @Nonnull - , C extends IStorageChannel> void registerStorageChannel( @Nonnull Class channel, @Nonnull C factory ); + /** + * Fetch the factory instance for a specific storage channel. + * + * Channel must be a direct subtype of {@link IStorageChannel}. + * + * @throws NullPointerException when fetching an unregistered channel. + * @param channel The channel type + * @return the factory instance + */ + @Nonnull + , C extends IStorageChannel> C getStorageChannel(@Nonnull Class channel); - /** - * Fetch the factory instance for a specific storage channel. - * - * Channel must be a direct subtype of {@link IStorageChannel}. - * - * @throws NullPointerException when fetching an unregistered channel. - * @param channel The channel type - * @return the factory instance - */ - @Nonnull - , C extends IStorageChannel> C getStorageChannel( @Nonnull Class channel ); + /** + * An unmodifiable collection of all registered factory instance. + * + * This is mainly used as helper to let storage grids construct their internal + * storage for each type. + */ + @Nonnull + Collection>> storageChannels(); - /** - * An unmodifiable collection of all registered factory instance. - * - * This is mainly used as helper to let storage grids construct their internal storage for each type. - */ - @Nonnull - Collection>> storageChannels(); + /** + * load a crafting link from nbt data. + * + * @param data to be loaded data + * + * @return crafting link + */ + ICraftingLink loadCraftingLink(CompoundNBT data, ICraftingRequester req); - /** - * load a crafting link from nbt data. - * - * @param data to be loaded data - * - * @return crafting link - */ - ICraftingLink loadCraftingLink( CompoundNBT data, ICraftingRequester req ); + /** + * Extracts items from a {@link IMEInventory} respecting power requirements. + * + * @param energy Energy source. + * @param inv Inventory to extract from. + * @param request Requested item and count. + * @param src Action source. + * @param mode Simulate or modulate + * @return extracted items or {@code null} of nothing was extracted. + */ + > T poweredExtraction(final IEnergySource energy, final IMEInventory inv, final T request, + final IActionSource src, final Actionable mode); - /** - * Extracts items from a {@link IMEInventory} respecting power requirements. - * - * @param energy Energy source. - * @param inv Inventory to extract from. - * @param request Requested item and count. - * @param src Action source. - * @param mode Simulate or modulate - * @return extracted items or {@code null} of nothing was extracted. - */ - > T poweredExtraction( final IEnergySource energy, final IMEInventory inv, final T request, final IActionSource src, final Actionable mode ); + /** + * Inserts items into a {@link IMEInventory} respecting power requirements. + * + * @param energy Energy source. + * @param inv Inventory to insert into. + * @param request Items to insert. + * @param src Action source. + * @param mode Simulate or modulate + * @return items not inserted or {@code null} if everything was inserted. + */ + > T poweredInsert(final IEnergySource energy, final IMEInventory inv, final T input, + final IActionSource src, final Actionable mode); - /** - * Inserts items into a {@link IMEInventory} respecting power requirements. - * - * @param energy Energy source. - * @param inv Inventory to insert into. - * @param request Items to insert. - * @param src Action source. - * @param mode Simulate or modulate - * @return items not inserted or {@code null} if everything was inserted. - */ - > T poweredInsert( final IEnergySource energy, final IMEInventory inv, final T input, final IActionSource src, final Actionable mode ); - - /** - * Posts alteration of stored items to the provided {@link IStorageGrid}. - * This can be used by cell containers to notify the grid of storage cell changes. - * - * @param gs the storage grid. - * @param removedCell the removed cell itemstack - * @param addedCell the added cell itemstack - * @param src the action source - */ - void postChanges( @Nonnull final IStorageGrid gs, @Nonnull final ItemStack removedCell, @Nonnull final ItemStack addedCell, @Nonnull final IActionSource src ); + /** + * Posts alteration of stored items to the provided {@link IStorageGrid}. This + * can be used by cell containers to notify the grid of storage cell changes. + * + * @param gs the storage grid. + * @param removedCell the removed cell itemstack + * @param addedCell the added cell itemstack + * @param src the action source + */ + void postChanges(@Nonnull final IStorageGrid gs, @Nonnull final ItemStack removedCell, + @Nonnull final ItemStack addedCell, @Nonnull final IActionSource src); } diff --git a/src/api/java/appeng/api/storage/IStorageMonitorable.java b/src/api/java/appeng/api/storage/IStorageMonitorable.java index d2ea1e6cb..11cf040fc 100644 --- a/src/api/java/appeng/api/storage/IStorageMonitorable.java +++ b/src/api/java/appeng/api/storage/IStorageMonitorable.java @@ -23,17 +23,15 @@ package appeng.api.storage; - import appeng.api.storage.data.IAEStack; - /** - * Exposes the monitorable network inventories of a grid node that choses to export them. - * This interface can only be obtained using Forge capabilities for {@link IStorageMonitorableAccessor}. + * Exposes the monitorable network inventories of a grid node that choses to + * export them. This interface can only be obtained using Forge capabilities for + * {@link IStorageMonitorableAccessor}. */ -public interface IStorageMonitorable -{ +public interface IStorageMonitorable { - > IMEMonitor getInventory( IStorageChannel channel ); + > IMEMonitor getInventory(IStorageChannel channel); } diff --git a/src/api/java/appeng/api/storage/IStorageMonitorableAccessor.java b/src/api/java/appeng/api/storage/IStorageMonitorableAccessor.java index 970e3a509..414fd8882 100644 --- a/src/api/java/appeng/api/storage/IStorageMonitorableAccessor.java +++ b/src/api/java/appeng/api/storage/IStorageMonitorableAccessor.java @@ -1,26 +1,25 @@ package appeng.api.storage; - import javax.annotation.Nullable; import appeng.api.networking.security.IActionSource; - /** - * Allows storage buses to request access to another ME network so it can be used as a subnetwork. - * This interface is used in conjunction with capabilities, so when an object of this is obtained, - * it already knows about which face the access was requested from. + * Allows storage buses to request access to another ME network so it can be + * used as a subnetwork. This interface is used in conjunction with + * capabilities, so when an object of this is obtained, it already knows about + * which face the access was requested from. *

- * To get access to the capability for this, use @CapabilityInject with this interface as the argument - * to the annotation. + * To get access to the capability for this, use @CapabilityInject with this + * interface as the argument to the annotation. */ -public interface IStorageMonitorableAccessor -{ +public interface IStorageMonitorableAccessor { - /** - * @return Null if the network cannot be accessed by the given action source (i.e. security doesn't permit it). - */ - @Nullable - IStorageMonitorable getInventory( IActionSource src ); + /** + * @return Null if the network cannot be accessed by the given action source + * (i.e. security doesn't permit it). + */ + @Nullable + IStorageMonitorable getInventory(IActionSource src); } diff --git a/src/api/java/appeng/api/storage/ITerminalHost.java b/src/api/java/appeng/api/storage/ITerminalHost.java index f802b6d65..81b44c595 100644 --- a/src/api/java/appeng/api/storage/ITerminalHost.java +++ b/src/api/java/appeng/api/storage/ITerminalHost.java @@ -23,11 +23,8 @@ package appeng.api.storage; - import appeng.api.util.IConfigurableObject; - -public interface ITerminalHost extends IStorageMonitorable, IConfigurableObject -{ +public interface ITerminalHost extends IStorageMonitorable, IConfigurableObject { } diff --git a/src/api/java/appeng/api/storage/channels/IFluidStorageChannel.java b/src/api/java/appeng/api/storage/channels/IFluidStorageChannel.java index 6a0f0407f..2c8f3cd93 100644 --- a/src/api/java/appeng/api/storage/channels/IFluidStorageChannel.java +++ b/src/api/java/appeng/api/storage/channels/IFluidStorageChannel.java @@ -23,12 +23,9 @@ package appeng.api.storage.channels; - import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEFluidStack; - -public interface IFluidStorageChannel extends IStorageChannel -{ +public interface IFluidStorageChannel extends IStorageChannel { } diff --git a/src/api/java/appeng/api/storage/channels/IItemStorageChannel.java b/src/api/java/appeng/api/storage/channels/IItemStorageChannel.java index 09f0dae9b..b1a216e53 100644 --- a/src/api/java/appeng/api/storage/channels/IItemStorageChannel.java +++ b/src/api/java/appeng/api/storage/channels/IItemStorageChannel.java @@ -23,12 +23,9 @@ package appeng.api.storage.channels; - import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEItemStack; - -public interface IItemStorageChannel extends IStorageChannel -{ +public interface IItemStorageChannel extends IStorageChannel { } diff --git a/src/api/java/appeng/api/storage/data/IAEFluidStack.java b/src/api/java/appeng/api/storage/data/IAEFluidStack.java index ec9f8f449..a1d20a17e 100644 --- a/src/api/java/appeng/api/storage/data/IAEFluidStack.java +++ b/src/api/java/appeng/api/storage/data/IAEFluidStack.java @@ -23,11 +23,9 @@ package appeng.api.storage.data; - import net.minecraft.fluid.Fluid; import net.minecraftforge.fluids.FluidStack; - /** * An alternate version of FluidStack for AE to keep tabs on things easier, and * to support larger storage. stackSizes of getFluidStack will be capped. @@ -37,38 +35,38 @@ import net.minecraftforge.fluids.FluidStack; * * Don't Implement. * - * Construct with Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class).createStack( FluidStack ) + * Construct with Api.INSTANCE.storage().getStorageChannel( + * IFluidStorageChannel.class).createStack( FluidStack ) */ -public interface IAEFluidStack extends IAEStack -{ +public interface IAEFluidStack extends IAEStack { - /** - * creates a standard Forge FluidStack for the fluid. - * - * @return new FluidStack - */ - FluidStack getFluidStack(); + /** + * creates a standard Forge FluidStack for the fluid. + * + * @return new FluidStack + */ + FluidStack getFluidStack(); - /** - * Combines two IAEItemStacks via addition. - * - * @param option , to add to the current one. - */ - @Override - void add( IAEFluidStack option ); + /** + * Combines two IAEItemStacks via addition. + * + * @param option , to add to the current one. + */ + @Override + void add(IAEFluidStack option); - /** - * create a AE Fluid clone. - * - * @return the copy. - */ - @Override - IAEFluidStack copy(); + /** + * create a AE Fluid clone. + * + * @return the copy. + */ + @Override + IAEFluidStack copy(); - /** - * quick way to get access to the Forge Fluid Definition. - * - * @return fluid definition - */ - Fluid getFluid(); + /** + * quick way to get access to the Forge Fluid Definition. + * + * @return fluid definition + */ + Fluid getFluid(); } diff --git a/src/api/java/appeng/api/storage/data/IAEItemStack.java b/src/api/java/appeng/api/storage/data/IAEItemStack.java index 80aa2ebaf..0f5f9b298 100644 --- a/src/api/java/appeng/api/storage/data/IAEItemStack.java +++ b/src/api/java/appeng/api/storage/data/IAEItemStack.java @@ -23,88 +23,87 @@ package appeng.api.storage.data; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - /** - * An alternate version of ItemStack for AE to keep tabs on things easier, and to support larger storage. stackSizes of - * getItemStack will be capped. + * An alternate version of ItemStack for AE to keep tabs on things easier, and + * to support larger storage. stackSizes of getItemStack will be capped. * - * You may hold on to these if you want, just make sure you let go of them when your not using them. + * You may hold on to these if you want, just make sure you let go of them when + * your not using them. * * Don't Implement. * - * Construct with Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class).createStack( ItemStack ) + * Construct with Api.INSTANCE.storage().getStorageChannel( + * IItemStorageChannel.class).createStack( ItemStack ) */ -public interface IAEItemStack extends IAEStack -{ +public interface IAEItemStack extends IAEStack { - /** - * creates a standard MC ItemStack for the item. - * - * @return new ItemStack - */ - ItemStack createItemStack(); + /** + * creates a standard MC ItemStack for the item. + * + * @return new ItemStack + */ + ItemStack createItemStack(); - /** - * is there NBT Data for this item? - * - * @return if there is - */ - boolean hasTagCompound(); + /** + * is there NBT Data for this item? + * + * @return if there is + */ + boolean hasTagCompound(); - /** - * Combines two IAEItemStacks via addition. - * - * @param option to add to the current one. - */ - @Override - void add( IAEItemStack option ); + /** + * Combines two IAEItemStacks via addition. + * + * @param option to add to the current one. + */ + @Override + void add(IAEItemStack option); - /** - * create a AE Item clone - * - * @return the copy - */ - @Override - IAEItemStack copy(); + /** + * create a AE Item clone + * + * @return the copy + */ + @Override + IAEItemStack copy(); - /** - * quick way to get access to the MC Item Definition. - * - * @return item definition - */ - Item getItem(); + /** + * quick way to get access to the MC Item Definition. + * + * @return item definition + */ + Item getItem(); - /** - * @return the items damage value - */ - int getItemDamage(); + /** + * @return the items damage value + */ + int getItemDamage(); - /** - * compare the item/damage/nbt of the stack. - * - * @param otherStack to be compared item - * - * @return true if it is the same type (same item, damage, nbt) - */ - boolean isSameType( IAEItemStack otherStack ); + /** + * compare the item/damage/nbt of the stack. + * + * @param otherStack to be compared item + * + * @return true if it is the same type (same item, damage, nbt) + */ + boolean isSameType(IAEItemStack otherStack); - /** - * compare the item/damage/nbt of the stack. - * - * @param stored to be compared item - * - * @return true if it is the same type (same item, damage, nbt) - */ - boolean isSameType( ItemStack stored ); + /** + * compare the item/damage/nbt of the stack. + * + * @param stored to be compared item + * + * @return true if it is the same type (same item, damage, nbt) + */ + boolean isSameType(ItemStack stored); - /** - * DO NOT MODIFY THIS STACK! NEVER. If you think about it .. DON'T - * - * @return definition stack - */ - ItemStack getDefinition(); + /** + * DO NOT MODIFY THIS STACK! NEVER. If you think about it .. DON'T + * + * @return definition stack + */ + ItemStack getDefinition(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/storage/data/IAEStack.java b/src/api/java/appeng/api/storage/data/IAEStack.java index 888b07ced..345405e2a 100644 --- a/src/api/java/appeng/api/storage/data/IAEStack.java +++ b/src/api/java/appeng/api/storage/data/IAEStack.java @@ -23,7 +23,6 @@ package appeng.api.storage.data; - import java.io.IOException; import net.minecraft.item.ItemStack; @@ -33,172 +32,171 @@ import net.minecraft.network.PacketBuffer; import appeng.api.config.FuzzyMode; import appeng.api.storage.IStorageChannel; +public interface IAEStack> { -public interface IAEStack> -{ + /** + * add two stacks together + * + * @param is added item + */ + void add(T is); - /** - * add two stacks together - * - * @param is added item - */ - void add( T is ); + /** + * number of items in the stack. + * + * @return basically ItemStack.stackSize + */ + long getStackSize(); - /** - * number of items in the stack. - * - * @return basically ItemStack.stackSize - */ - long getStackSize(); + /** + * changes the number of items in the stack. + * + * @param stackSize , ItemStack.stackSize = N + */ + T setStackSize(long stackSize); - /** - * changes the number of items in the stack. - * - * @param stackSize , ItemStack.stackSize = N - */ - T setStackSize( long stackSize ); + /** + * Same as getStackSize, but for requestable items. ( LP ) + * + * @return basically itemStack.stackSize but for requestable items. + */ + long getCountRequestable(); - /** - * Same as getStackSize, but for requestable items. ( LP ) - * - * @return basically itemStack.stackSize but for requestable items. - */ - long getCountRequestable(); + /** + * Same as setStackSize, but for requestable items. ( LP ) + * + * @return basically itemStack.stackSize = N but for setStackSize items. + */ + T setCountRequestable(long countRequestable); - /** - * Same as setStackSize, but for requestable items. ( LP ) - * - * @return basically itemStack.stackSize = N but for setStackSize items. - */ - T setCountRequestable( long countRequestable ); + /** + * true, if the item can be crafted. + * + * @return true, if it can be crafted. + */ + boolean isCraftable(); - /** - * true, if the item can be crafted. - * - * @return true, if it can be crafted. - */ - boolean isCraftable(); + /** + * change weather the item can be crafted. + * + * @param isCraftable can item be crafted + */ + T setCraftable(boolean isCraftable); - /** - * change weather the item can be crafted. - * - * @param isCraftable can item be crafted - */ - T setCraftable( boolean isCraftable ); + /** + * clears, requestable, craftable, and stack sizes. + */ + T reset(); - /** - * clears, requestable, craftable, and stack sizes. - */ - T reset(); + /** + * returns true, if the item can be crafted, requested, or extracted. + * + * @return isThisRecordMeaningful + */ + boolean isMeaningful(); - /** - * returns true, if the item can be crafted, requested, or extracted. - * - * @return isThisRecordMeaningful - */ - boolean isMeaningful(); + /** + * Adds more to the stack size... + * + * @param i additional stack size + */ + void incStackSize(long i); - /** - * Adds more to the stack size... - * - * @param i additional stack size - */ - void incStackSize( long i ); + /** + * removes some from the stack size. + */ + void decStackSize(long i); - /** - * removes some from the stack size. - */ - void decStackSize( long i ); + /** + * adds items to the requestable + * + * @param i increased amount of requested items + */ + void incCountRequestable(long i); - /** - * adds items to the requestable - * - * @param i increased amount of requested items - */ - void incCountRequestable( long i ); + /** + * removes items from the requestable + * + * @param i decreased amount of requested items + */ + void decCountRequestable(long i); - /** - * removes items from the requestable - * - * @param i decreased amount of requested items - */ - void decCountRequestable( long i ); + /** + * write to a CompoundNBT. + * + * @param i to be written data + */ + void writeToNBT(CompoundNBT i); - /** - * write to a CompoundNBT. - * - * @param i to be written data - */ - void writeToNBT( CompoundNBT i ); + /** + * Compare stacks using precise logic. + * + * a IAEItemStack to another AEItemStack or a ItemStack. + * + * or + * + * IAEFluidStack, FluidStack + * + * @param obj compared object + * + * @return true if they are the same. + */ + @Override + boolean equals(Object obj); - /** - * Compare stacks using precise logic. - * - * a IAEItemStack to another AEItemStack or a ItemStack. - * - * or - * - * IAEFluidStack, FluidStack - * - * @param obj compared object - * - * @return true if they are the same. - */ - @Override - boolean equals( Object obj ); + /** + * Compare the same subtype of {@link IAEStack} with another using a fuzzy + * comparison. + * + * @param other The stack to compare. + * @param mode Which {@link FuzzyMode} should be used. + * + * @return true if two stacks are equal based on AE Fuzzy Comparison. + */ + boolean fuzzyComparison(T other, FuzzyMode mode); - /** - * Compare the same subtype of {@link IAEStack} with another using a fuzzy comparison. - * - * @param other The stack to compare. - * @param mode Which {@link FuzzyMode} should be used. - * - * @return true if two stacks are equal based on AE Fuzzy Comparison. - */ - boolean fuzzyComparison( T other, FuzzyMode mode ); + /** + * Slower for disk saving, but smaller/more efficient for packets. + * + * @param data to be written data + * + * @throws IOException + */ + void writeToPacket(PacketBuffer data); - /** - * Slower for disk saving, but smaller/more efficient for packets. - * - * @param data to be written data - * - * @throws IOException - */ - void writeToPacket( PacketBuffer data ); + /** + * Clone the Item / Fluid Stack + * + * @return a new Stack, which is copied from the original. + */ + T copy(); - /** - * Clone the Item / Fluid Stack - * - * @return a new Stack, which is copied from the original. - */ - T copy(); + /** + * create an empty stack. + * + * @return a new stack, which represents an empty copy of the original. + */ + T empty(); - /** - * create an empty stack. - * - * @return a new stack, which represents an empty copy of the original. - */ - T empty(); + /** + * @return true if the stack is a {@link IAEItemStack} + */ + boolean isItem(); - /** - * @return true if the stack is a {@link IAEItemStack} - */ - boolean isItem(); + /** + * @return true if the stack is a {@link IAEFluidStack} + */ + boolean isFluid(); - /** - * @return true if the stack is a {@link IAEFluidStack} - */ - boolean isFluid(); + /** + * @return ITEM or FLUID + */ + IStorageChannel getChannel(); - /** - * @return ITEM or FLUID - */ - IStorageChannel getChannel(); - - /** - * Returns itemstack for display and similar purposes. Always has a count of 1. - * - * @return itemstack - */ - ItemStack asItemStackRepresentation(); + /** + * Returns itemstack for display and similar purposes. Always has a count of 1. + * + * @return itemstack + */ + ItemStack asItemStackRepresentation(); } diff --git a/src/api/java/appeng/api/storage/data/IItemContainer.java b/src/api/java/appeng/api/storage/data/IItemContainer.java index d46e53f0f..8821379a2 100644 --- a/src/api/java/appeng/api/storage/data/IItemContainer.java +++ b/src/api/java/appeng/api/storage/data/IItemContainer.java @@ -23,45 +23,43 @@ package appeng.api.storage.data; - import java.util.Collection; import appeng.api.config.FuzzyMode; - /** * Represents a list of items in AE. * * Don't Implement. * */ -public interface IItemContainer> -{ +public interface IItemContainer> { - /** - * add a stack to the list, this will merge the stack with an item already in the list if found. - * - * @param option added stack - */ - void add( T option ); // adds stack as is + /** + * add a stack to the list, this will merge the stack with an item already in + * the list if found. + * + * @param option added stack + */ + void add(T option); // adds stack as is - /** - * @param i compared item - * - * @return a stack equivalent to the stack passed in, but with the correct stack size information, or null if its - * not present - */ - T findPrecise( T i ); + /** + * @param i compared item + * + * @return a stack equivalent to the stack passed in, but with the correct stack + * size information, or null if its not present + */ + T findPrecise(T i); - /** - * @param input compared item - * - * @return a list of relevant fuzzy matched stacks - */ - Collection findFuzzy( T input, FuzzyMode fuzzy ); + /** + * @param input compared item + * + * @return a list of relevant fuzzy matched stacks + */ + Collection findFuzzy(T input, FuzzyMode fuzzy); - /** - * @return true if there are no items in the list - */ - boolean isEmpty(); + /** + * @return true if there are no items in the list + */ + boolean isEmpty(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/storage/data/IItemList.java b/src/api/java/appeng/api/storage/data/IItemList.java index d8b1de885..e52ecd7ca 100644 --- a/src/api/java/appeng/api/storage/data/IItemList.java +++ b/src/api/java/appeng/api/storage/data/IItemList.java @@ -23,66 +23,65 @@ package appeng.api.storage.data; - import java.util.Iterator; import appeng.api.storage.IStorageChannel; - /** * Represents a list of items in AE. * * Don't Implement. * - * Construct with - * - For items: Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class).createList() - * - For fluids: Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class).createList() - * - Replace with the corresponding {@link IStorageChannel} type for non native channels + * Construct with - For items: Api.INSTANCE.storage().getStorageChannel( + * IItemStorageChannel.class).createList() - For fluids: + * Api.INSTANCE.storage().getStorageChannel( + * IFluidStorageChannel.class).createList() - Replace with the corresponding + * {@link IStorageChannel} type for non native channels */ -public interface IItemList> extends IItemContainer, Iterable -{ +public interface IItemList> extends IItemContainer, Iterable { - /** - * add a stack to the list stackSize is used to add to stackSize, this will merge the stack with an item already in - * the list if found. - * - * @param option stacktype option - */ - void addStorage( T option ); // adds a stack as stored + /** + * add a stack to the list stackSize is used to add to stackSize, this will + * merge the stack with an item already in the list if found. + * + * @param option stacktype option + */ + void addStorage(T option); // adds a stack as stored - /** - * add a stack to the list as craftable, this will merge the stack with an item already in the list if found. - * - * @param option stacktype option - */ - void addCrafting( T option ); + /** + * add a stack to the list as craftable, this will merge the stack with an item + * already in the list if found. + * + * @param option stacktype option + */ + void addCrafting(T option); - /** - * add a stack to the list, stack size is used to add to requestable, this will merge the stack with an item already - * in the list if found. - * - * @param option stacktype option - */ - void addRequestable( T option ); // adds a stack as requestable + /** + * add a stack to the list, stack size is used to add to requestable, this will + * merge the stack with an item already in the list if found. + * + * @param option stacktype option + */ + void addRequestable(T option); // adds a stack as requestable - /** - * @return the first item in the list - */ - T getFirstItem(); + /** + * @return the first item in the list + */ + T getFirstItem(); - /** - * @return the number of items in the list - */ - int size(); + /** + * @return the number of items in the list + */ + int size(); - /** - * allows you to iterate the list. - */ - @Override - Iterator iterator(); + /** + * allows you to iterate the list. + */ + @Override + Iterator iterator(); - /** - * resets stack sizes to 0. - */ - void resetStatus(); + /** + * resets stack sizes to 0. + */ + void resetStatus(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/util/AEAxisAlignedBB.java b/src/api/java/appeng/api/util/AEAxisAlignedBB.java index 70776b79d..200cfd841 100644 --- a/src/api/java/appeng/api/util/AEAxisAlignedBB.java +++ b/src/api/java/appeng/api/util/AEAxisAlignedBB.java @@ -18,46 +18,43 @@ package appeng.api.util; - import net.minecraft.util.math.AxisAlignedBB; - /** - * Mutable stand in for Axis Aligned BB, this was used to prevent GC Thrashing.. Related code could also be re-written. + * Mutable stand in for Axis Aligned BB, this was used to prevent GC Thrashing.. + * Related code could also be re-written. * - * TODO: Replace with interface and maybe factory should it ever be needed for addons. + * TODO: Replace with interface and maybe factory should it ever be needed for + * addons. */ -public class AEAxisAlignedBB -{ - public double minX; - public double minY; - public double minZ; - public double maxX; - public double maxY; - public double maxZ; +public class AEAxisAlignedBB { + public double minX; + public double minY; + public double minZ; + public double maxX; + public double maxY; + public double maxZ; - public AxisAlignedBB getBoundingBox() - { - return new AxisAlignedBB( this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ ); - } + public AxisAlignedBB getBoundingBox() { + return new AxisAlignedBB(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ); + } - public AEAxisAlignedBB( final double a, final double b, final double c, final double d, final double e, final double f ) - { - this.minX = a; - this.minY = b; - this.minZ = c; - this.maxX = d; - this.maxY = e; - this.maxZ = f; - } + public AEAxisAlignedBB(final double a, final double b, final double c, final double d, final double e, + final double f) { + this.minX = a; + this.minY = b; + this.minZ = c; + this.maxX = d; + this.maxY = e; + this.maxZ = f; + } - public static AEAxisAlignedBB fromBounds( final double a, final double b, final double c, final double d, final double e, final double f ) - { - return new AEAxisAlignedBB( a, b, c, d, e, f ); - } + public static AEAxisAlignedBB fromBounds(final double a, final double b, final double c, final double d, + final double e, final double f) { + return new AEAxisAlignedBB(a, b, c, d, e, f); + } - public static AEAxisAlignedBB fromBounds( final AxisAlignedBB bb ) - { - return new AEAxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ ); - } + public static AEAxisAlignedBB fromBounds(final AxisAlignedBB bb) { + return new AEAxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); + } } diff --git a/src/api/java/appeng/api/util/AECableSize.java b/src/api/java/appeng/api/util/AECableSize.java index dc7c5ea92..cf500d925 100644 --- a/src/api/java/appeng/api/util/AECableSize.java +++ b/src/api/java/appeng/api/util/AECableSize.java @@ -23,20 +23,14 @@ package appeng.api.util; +public enum AECableSize { + NONE, NORMAL, DENSE; -public enum AECableSize -{ - NONE, - NORMAL, - DENSE; + public static AECableSize min(AECableSize a, AECableSize b) { + return a.compareTo(b) < 0 ? a : b; + } - public static AECableSize min( AECableSize a, AECableSize b ) - { - return a.compareTo( b ) < 0 ? a : b; - } - - public static AECableSize max( AECableSize a, AECableSize b ) - { - return a.compareTo( b ) > 0 ? a : b; - } + public static AECableSize max(AECableSize a, AECableSize b) { + return a.compareTo(b) > 0 ? a : b; + } } diff --git a/src/api/java/appeng/api/util/AECableType.java b/src/api/java/appeng/api/util/AECableType.java index daabefc26..9191274f7 100644 --- a/src/api/java/appeng/api/util/AECableType.java +++ b/src/api/java/appeng/api/util/AECableType.java @@ -23,138 +23,117 @@ package appeng.api.util; +public enum AECableType { + /** + * No Cable present. + */ + NONE(AECableVariant.NONE, AECableSize.NONE), -public enum AECableType -{ - /** - * No Cable present. - */ - NONE( AECableVariant.NONE, AECableSize.NONE ), + /** + * Connections to this block should render as glass. + */ + GLASS(AECableVariant.GLASS, AECableSize.NORMAL), - /** - * Connections to this block should render as glass. - */ - GLASS( AECableVariant.GLASS, AECableSize.NORMAL ), + /** + * Connections to this block should render as covered. + */ + COVERED(AECableVariant.COVERED, AECableSize.NORMAL), - /** - * Connections to this block should render as covered. - */ - COVERED( AECableVariant.COVERED, AECableSize.NORMAL ), + /** + * Connections to this block should render as smart. + */ + SMART(AECableVariant.SMART, AECableSize.NORMAL), - /** - * Connections to this block should render as smart. - */ - SMART( AECableVariant.SMART, AECableSize.NORMAL ), + /** + * Smart Dense Cable, represents a tier 2 block that can carry 32 channels. + */ + DENSE_COVERED(AECableVariant.COVERED, AECableSize.DENSE), - /** - * Smart Dense Cable, represents a tier 2 block that can carry 32 channels. - */ - DENSE_COVERED( AECableVariant.COVERED, AECableSize.DENSE ), + /** + * Smart Dense Cable, represents a tier 2 block that can carry 32 channels. + */ + DENSE_SMART(AECableVariant.SMART, AECableSize.DENSE); - /** - * Smart Dense Cable, represents a tier 2 block that can carry 32 channels. - */ - DENSE_SMART( AECableVariant.SMART, AECableSize.DENSE ); + public static final AECableType[] VALIDCABLES = { GLASS, COVERED, SMART, DENSE_COVERED, DENSE_SMART }; - public static final AECableType[] VALIDCABLES = { - GLASS, - COVERED, - SMART, - DENSE_COVERED, - DENSE_SMART - }; + private final AECableVariant variant; + private final AECableSize size; - private final AECableVariant variant; - private final AECableSize size; + private AECableType(AECableVariant variant, AECableSize size) { + this.variant = variant; + this.size = size; + } - private AECableType( AECableVariant variant, AECableSize size ) - { - this.variant = variant; - this.size = size; - } + public AECableSize size() { + return this.size; + } - public AECableSize size() - { - return this.size; - } + public AECableVariant variant() { + return this.variant; + } - public AECableVariant variant() - { - return this.variant; - } + public boolean isValid() { + return this.variant != AECableVariant.NONE && this.size != AECableSize.NONE; + } - public boolean isValid() - { - return this.variant != AECableVariant.NONE && this.size != AECableSize.NONE; - } + public boolean isDense() { + return this.size == AECableSize.DENSE; + } - public boolean isDense() - { - return this.size == AECableSize.DENSE; - } + public boolean isSmart() { + return this.variant == AECableVariant.SMART; + } - public boolean isSmart() - { - return this.variant == AECableVariant.SMART; - } + public static AECableType min(AECableType a, AECableType b) { + final AECableVariant v = AECableVariant.min(a.variant(), b.variant()); + final AECableSize s = AECableSize.min(a.size(), b.size()); - public static AECableType min( AECableType a, AECableType b ) - { - final AECableVariant v = AECableVariant.min( a.variant(), b.variant() ); - final AECableSize s = AECableSize.min( a.size(), b.size() ); + return AECableType.from(v, s); + } - return AECableType.from( v, s ); - } + public static AECableType max(AECableType a, AECableType b) { + final AECableVariant v = AECableVariant.max(a.variant(), b.variant()); + final AECableSize s = AECableSize.max(a.size(), b.size()); - public static AECableType max( AECableType a, AECableType b ) - { - final AECableVariant v = AECableVariant.max( a.variant(), b.variant() ); - final AECableSize s = AECableSize.max( a.size(), b.size() ); + return AECableType.from(v, s); + } - return AECableType.from( v, s ); - } + private static AECableType from(AECableVariant variant, AECableSize size) { + switch (variant) { + case GLASS: + switch (size) { + case NORMAL: + return GLASS; + default: + break; + } - private static AECableType from( AECableVariant variant, AECableSize size ) - { - switch( variant ) - { - case GLASS: - switch( size ) - { - case NORMAL: - return GLASS; - default: - break; - } + break; + case COVERED: + switch (size) { + case NORMAL: + return COVERED; + case DENSE: + return DENSE_COVERED; + default: + break; + } - break; - case COVERED: - switch( size ) - { - case NORMAL: - return COVERED; - case DENSE: - return DENSE_COVERED; - default: - break; - } + break; + case SMART: + switch (size) { + case NORMAL: + return SMART; + case DENSE: + return DENSE_SMART; + default: + break; + } + break; + default: + break; + } - break; - case SMART: - switch( size ) - { - case NORMAL: - return SMART; - case DENSE: - return DENSE_SMART; - default: - break; - } - break; - default: - break; - } - - return NONE; - } + return NONE; + } } diff --git a/src/api/java/appeng/api/util/AECableVariant.java b/src/api/java/appeng/api/util/AECableVariant.java index c4015d4d1..9e85c9d01 100644 --- a/src/api/java/appeng/api/util/AECableVariant.java +++ b/src/api/java/appeng/api/util/AECableVariant.java @@ -23,21 +23,14 @@ package appeng.api.util; +public enum AECableVariant { + NONE, GLASS, COVERED, SMART; -public enum AECableVariant -{ - NONE, - GLASS, - COVERED, - SMART; + public static AECableVariant min(AECableVariant a, AECableVariant b) { + return a.compareTo(b) < 0 ? a : b; + } - public static AECableVariant min( AECableVariant a, AECableVariant b ) - { - return a.compareTo( b ) < 0 ? a : b; - } - - public static AECableVariant max( AECableVariant a, AECableVariant b ) - { - return a.compareTo( b ) > 0 ? a : b; - } + public static AECableVariant max(AECableVariant a, AECableVariant b) { + return a.compareTo(b) > 0 ? a : b; + } } diff --git a/src/api/java/appeng/api/util/AEColor.java b/src/api/java/appeng/api/util/AEColor.java index 30cc1920d..85e8de1d5 100644 --- a/src/api/java/appeng/api/util/AEColor.java +++ b/src/api/java/appeng/api/util/AEColor.java @@ -23,166 +23,166 @@ package appeng.api.util; - import java.util.Arrays; import java.util.List; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.item.DyeColor; - /** - * List of all colors supported by AE, their names, and various colors for display. + * List of all colors supported by AE, their names, and various colors for + * display. * * Should be the same order as Dyes, excluding Transparent. */ -public enum AEColor -{ +public enum AEColor { - WHITE( "gui.appliedenergistics2.White", "white", DyeColor.WHITE, 0xBEBEBE, 0xDBDBDB, 0xFAFAFA ), + WHITE("gui.appliedenergistics2.White", "white", DyeColor.WHITE, 0xBEBEBE, 0xDBDBDB, 0xFAFAFA), - ORANGE( "gui.appliedenergistics2.Orange", "orange", DyeColor.ORANGE, 0xF99739, 0xFAAE44, 0xF4DEC3 ), + ORANGE("gui.appliedenergistics2.Orange", "orange", DyeColor.ORANGE, 0xF99739, 0xFAAE44, 0xF4DEC3), - MAGENTA( "gui.appliedenergistics2.Magenta", "magenta", DyeColor.MAGENTA, 0x821E82, 0xB82AB8, 0xC598C8 ), + MAGENTA("gui.appliedenergistics2.Magenta", "magenta", DyeColor.MAGENTA, 0x821E82, 0xB82AB8, 0xC598C8), - LIGHT_BLUE( "gui.appliedenergistics2.LightBlue", "light_blue", DyeColor.LIGHT_BLUE, 0x628DCB, 0x82ACE7, 0xD8F6FF ), + LIGHT_BLUE("gui.appliedenergistics2.LightBlue", "light_blue", DyeColor.LIGHT_BLUE, 0x628DCB, 0x82ACE7, 0xD8F6FF), - YELLOW( "gui.appliedenergistics2.Yellow", "yellow", DyeColor.YELLOW, 0xFFF7AA, 0xF8FF4A, 0xFFFFE8 ), + YELLOW("gui.appliedenergistics2.Yellow", "yellow", DyeColor.YELLOW, 0xFFF7AA, 0xF8FF4A, 0xFFFFE8), - LIME( "gui.appliedenergistics2.Lime", "lime", DyeColor.LIME, 0x7CFF4A, 0xBBFF51, 0xE7F7D7 ), + LIME("gui.appliedenergistics2.Lime", "lime", DyeColor.LIME, 0x7CFF4A, 0xBBFF51, 0xE7F7D7), - PINK( "gui.appliedenergistics2.Pink", "pink", DyeColor.PINK, 0xDC8DB5, 0xF8B5D7, 0xF7DEEB ), + PINK("gui.appliedenergistics2.Pink", "pink", DyeColor.PINK, 0xDC8DB5, 0xF8B5D7, 0xF7DEEB), - GRAY( "gui.appliedenergistics2.Gray", "gray", DyeColor.GRAY, 0x7C7C7C, 0xA0A0A0, 0xC9C9C9 ), + GRAY("gui.appliedenergistics2.Gray", "gray", DyeColor.GRAY, 0x7C7C7C, 0xA0A0A0, 0xC9C9C9), - LIGHT_GRAY( "gui.appliedenergistics2.LightGray", "light_gray", DyeColor.LIGHT_GRAY, 0x9D9D9D, 0xCDCDCD, 0xEFEFEF ), + LIGHT_GRAY("gui.appliedenergistics2.LightGray", "light_gray", DyeColor.LIGHT_GRAY, 0x9D9D9D, 0xCDCDCD, 0xEFEFEF), - CYAN( "gui.appliedenergistics2.Cyan", "cyan", DyeColor.CYAN, 0x2F9BA5, 0x51AAC6, 0xAEDDF4 ), + CYAN("gui.appliedenergistics2.Cyan", "cyan", DyeColor.CYAN, 0x2F9BA5, 0x51AAC6, 0xAEDDF4), - PURPLE( "gui.appliedenergistics2.Purple", "purple", DyeColor.PURPLE, 0x8230B2, 0xA453CE, 0xC7A3CC ), + PURPLE("gui.appliedenergistics2.Purple", "purple", DyeColor.PURPLE, 0x8230B2, 0xA453CE, 0xC7A3CC), - BLUE( "gui.appliedenergistics2.Blue", "blue", DyeColor.BLUE, 0x2D29A0, 0x514AFF, 0xDDE6FF ), + BLUE("gui.appliedenergistics2.Blue", "blue", DyeColor.BLUE, 0x2D29A0, 0x514AFF, 0xDDE6FF), - BROWN( "gui.appliedenergistics2.Brown", "brown", DyeColor.BROWN, 0x724E35, 0xB7967F, 0xE0D2C8 ), + BROWN("gui.appliedenergistics2.Brown", "brown", DyeColor.BROWN, 0x724E35, 0xB7967F, 0xE0D2C8), - GREEN( "gui.appliedenergistics2.Green", "green", DyeColor.GREEN, 0x45A021, 0x60E32E, 0xE3F2E3 ), + GREEN("gui.appliedenergistics2.Green", "green", DyeColor.GREEN, 0x45A021, 0x60E32E, 0xE3F2E3), - RED( "gui.appliedenergistics2.Red", "red", DyeColor.RED, 0xA50029, 0xFF003C, 0xFFE6ED ), + RED("gui.appliedenergistics2.Red", "red", DyeColor.RED, 0xA50029, 0xFF003C, 0xFFE6ED), - BLACK( "gui.appliedenergistics2.Black", "black", DyeColor.BLACK, 0x2B2B2B, 0x565656, 0x848484 ), + BLACK("gui.appliedenergistics2.Black", "black", DyeColor.BLACK, 0x2B2B2B, 0x565656, 0x848484), - TRANSPARENT( "gui.appliedenergistics2.Fluix", "fluix", null, 0x1B2344, 0x895CA8, 0xD7BBEC ); + TRANSPARENT("gui.appliedenergistics2.Fluix", "fluix", null, 0x1B2344, 0x895CA8, 0xD7BBEC); - public static final List VALID_COLORS = Arrays.asList( WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, - BLUE, BROWN, GREEN, RED, BLACK ); + public static final List VALID_COLORS = Arrays.asList(WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, + PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, BLACK); - /** - * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to get the {@link #blackVariant dark - * variant} of the apprioriate AE color. - */ - public static final int TINTINDEX_DARK = 1; + /** + * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to + * get the {@link #blackVariant dark variant} of the apprioriate AE color. + */ + public static final int TINTINDEX_DARK = 1; - /** - * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to get the {@link #mediumVariant medium - * variant} of the apprioriate AE color. - */ - public static final int TINTINDEX_MEDIUM = 2; + /** + * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to + * get the {@link #mediumVariant medium variant} of the apprioriate AE color. + */ + public static final int TINTINDEX_MEDIUM = 2; - /** - * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to get the {@link #whiteVariant bright - * variant} of the apprioriate AE color. - */ - public static final int TINTINDEX_BRIGHT = 3; + /** + * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to + * get the {@link #whiteVariant bright variant} of the apprioriate AE color. + */ + public static final int TINTINDEX_BRIGHT = 3; - /** - * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to get a color between the - * {@link #mediumVariant medium} - * and {@link #whiteVariant bright variant} of the apprioriate AE color. - */ - public static final int TINTINDEX_MEDIUM_BRIGHT = 4; + /** + * The {@link BakedQuad#getTintIndex() tint index} that can normally be used to + * get a color between the {@link #mediumVariant medium} and + * {@link #whiteVariant bright variant} of the apprioriate AE color. + */ + public static final int TINTINDEX_MEDIUM_BRIGHT = 4; - /** - * Unlocalized name for color. - */ - public final String translationKey; + /** + * Unlocalized name for color. + */ + public final String translationKey; - /** - * Darkest Variant of the color, nearly black; as a RGB HEX Integer - */ - public final int blackVariant; + /** + * Darkest Variant of the color, nearly black; as a RGB HEX Integer + */ + public final int blackVariant; - /** - * The Variant of the color that is used to represent the color normally; as a RGB HEX Integer - */ - public final int mediumVariant; + /** + * The Variant of the color that is used to represent the color normally; as a + * RGB HEX Integer + */ + public final int mediumVariant; - /** - * Lightest Variant of the color, nearly white; as a RGB HEX Integer - */ - public final int whiteVariant; + /** + * Lightest Variant of the color, nearly white; as a RGB HEX Integer + */ + public final int whiteVariant; - /** - * Vanilla Dye Equivilient - */ - public final DyeColor dye; + /** + * Vanilla Dye Equivilient + */ + public final DyeColor dye; - /** - * A convenient ID prefix for use with registering color variants of items and blocks. - */ - public final String registryPrefix; + /** + * A convenient ID prefix for use with registering color variants of items and + * blocks. + */ + public final String registryPrefix; - AEColor(final String translationKey, final String registryPrefix, final DyeColor dye, final int blackHex, final int medHex, final int whiteHex ) - { - this.translationKey = translationKey; - this.registryPrefix = registryPrefix; - this.blackVariant = blackHex; - this.mediumVariant = medHex; - this.whiteVariant = whiteHex; - this.dye = dye; - } + AEColor(final String translationKey, final String registryPrefix, final DyeColor dye, final int blackHex, + final int medHex, final int whiteHex) { + this.translationKey = translationKey; + this.registryPrefix = registryPrefix; + this.blackVariant = blackHex; + this.mediumVariant = medHex; + this.whiteVariant = whiteHex; + this.dye = dye; + } - /** - * Will return a variant of this color based on the given tint index. - * - * @param tintIndex A tint index as it can be used for {@link BakedQuad#getTintIndex()}. - * @return The appropriate color variant, or -1. - */ - public int getVariantByTintIndex( int tintIndex ) - { - switch( tintIndex ) - { - // Please note that tintindex 0 is hardcoded for the block breaking particles. Returning anything other than - // -1 for tintindex=0 here - // will cause issues with those particles - case 0: - return -1; - case TINTINDEX_DARK: - return this.blackVariant; - case TINTINDEX_MEDIUM: - return this.mediumVariant; - case TINTINDEX_BRIGHT: - return this.whiteVariant; - case TINTINDEX_MEDIUM_BRIGHT: - final int light = this.whiteVariant; - final int dark = this.mediumVariant; - return ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ); - default: - return -1; - } - } + /** + * Will return a variant of this color based on the given tint index. + * + * @param tintIndex A tint index as it can be used for + * {@link BakedQuad#getTintIndex()}. + * @return The appropriate color variant, or -1. + */ + public int getVariantByTintIndex(int tintIndex) { + switch (tintIndex) { + // Please note that tintindex 0 is hardcoded for the block breaking particles. + // Returning anything other than + // -1 for tintindex=0 here + // will cause issues with those particles + case 0: + return -1; + case TINTINDEX_DARK: + return this.blackVariant; + case TINTINDEX_MEDIUM: + return this.mediumVariant; + case TINTINDEX_BRIGHT: + return this.whiteVariant; + case TINTINDEX_MEDIUM_BRIGHT: + final int light = this.whiteVariant; + final int dark = this.mediumVariant; + return (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) + | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8) + | ((((light) & 0xff) + ((dark) & 0xff)) / 2); + default: + return -1; + } + } - /** - * Logic to see which colors match each other.. special handle for Transparent - */ - public boolean matches( final AEColor color ) - { - return this == TRANSPARENT || color == TRANSPARENT || this == color; - } + /** + * Logic to see which colors match each other.. special handle for Transparent + */ + public boolean matches(final AEColor color) { + return this == TRANSPARENT || color == TRANSPARENT || this == color; + } - @Override - public String toString() - { - return this.translationKey; - } + @Override + public String toString() { + return this.translationKey; + } } diff --git a/src/api/java/appeng/api/util/AEColoredItemDefinition.java b/src/api/java/appeng/api/util/AEColoredItemDefinition.java index 71367e862..8e43e977a 100644 --- a/src/api/java/appeng/api/util/AEColoredItemDefinition.java +++ b/src/api/java/appeng/api/util/AEColoredItemDefinition.java @@ -23,50 +23,47 @@ 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 { -public interface AEColoredItemDefinition -{ + /** + * @return the {@link Block} Implementation if applicable + */ + Block block(AEColor color); - /** - * @return the {@link Block} Implementation if applicable - */ - Block block( AEColor color ); + /** + * @return the {@link Item} Implementation if applicable + */ + Item item(AEColor color); - /** - * @return the {@link Item} Implementation if applicable - */ - Item item( AEColor color ); + /** + * @return the {@link TileEntity} Class if applicable. + */ + Class entity(AEColor color); - /** - * @return the {@link TileEntity} Class if applicable. - */ - Class entity( AEColor color ); + /** + * @return an {@link ItemStack} with specified quantity of this item. + */ + ItemStack stack(AEColor color, int stackSize); - /** - * @return an {@link ItemStack} with specified quantity of this item. - */ - ItemStack stack( AEColor color, int stackSize ); + /** + * @param stackSize - stack size of the result. + * + * @return an array of all colors. + */ + ItemStack[] allStacks(int stackSize); - /** - * @param stackSize - stack size of the result. - * - * @return an array of all colors. - */ - ItemStack[] allStacks( int stackSize ); - - /** - * Compare {@link ItemStack} with this - * - * @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 ); + /** + * Compare {@link ItemStack} with this + * + * @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); } diff --git a/src/api/java/appeng/api/util/AEPartLocation.java b/src/api/java/appeng/api/util/AEPartLocation.java index b9c5a785a..7fe61eb72 100644 --- a/src/api/java/appeng/api/util/AEPartLocation.java +++ b/src/api/java/appeng/api/util/AEPartLocation.java @@ -18,109 +18,100 @@ package appeng.api.util; - import net.minecraft.util.Direction; - /** - * Stand in for previous Forge Direction, Several uses of this class are simply legacy where as some uses of this class - * are intended. + * Stand in for previous Forge Direction, Several uses of this class are simply + * legacy where as some uses of this class are intended. */ -public enum AEPartLocation -{ - /** - * Negative Y - */ - DOWN( 0, -1, 0 ), +public enum AEPartLocation { + /** + * Negative Y + */ + DOWN(0, -1, 0), - /** - * Positive Y - */ - UP( 0, 1, 0 ), + /** + * Positive Y + */ + UP(0, 1, 0), - /** - * Negative Z - */ - NORTH( 0, 0, -1 ), + /** + * Negative Z + */ + NORTH(0, 0, -1), - /** - * Positive Z - */ - SOUTH( 0, 0, 1 ), + /** + * Positive Z + */ + SOUTH(0, 0, 1), - /** - * Negative X - */ - WEST( -1, 0, 0 ), + /** + * Negative X + */ + WEST(-1, 0, 0), - /** - * Posative X - */ - EAST( 1, 0, 0 ), + /** + * Posative X + */ + EAST(1, 0, 0), - /** - * Center or inside of the block. - */ - INTERNAL( 0, 0, 0 ); + /** + * Center or inside of the block. + */ + INTERNAL(0, 0, 0); - public final int xOffset; - public final int yOffset; - public final int zOffset; + public final int xOffset; + public final int yOffset; + public final int zOffset; - private static final Direction[] facings = { Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null }; - private static final int[] OPPOSITES = { 1, 0, 3, 2, 5, 4, 6 }; + private static final Direction[] facings = { Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, + Direction.WEST, Direction.EAST, null }; + private static final int[] OPPOSITES = { 1, 0, 3, 2, 5, 4, 6 }; - public static final AEPartLocation[] SIDE_LOCATIONS = { DOWN, UP, NORTH, SOUTH, WEST, EAST }; + public static final AEPartLocation[] SIDE_LOCATIONS = { DOWN, UP, NORTH, SOUTH, WEST, EAST }; - private AEPartLocation( final int x, final int y, final int z ) - { - this.xOffset = x; - this.yOffset = y; - this.zOffset = z; - } + private AEPartLocation(final int x, final int y, final int z) { + this.xOffset = x; + this.yOffset = y; + this.zOffset = z; + } - /** - * @return Part Location - */ - public static AEPartLocation fromOrdinal( final int id ) - { - if( id >= 0 && id < SIDE_LOCATIONS.length ) - { - return SIDE_LOCATIONS[id]; - } + /** + * @return Part Location + */ + public static AEPartLocation fromOrdinal(final int id) { + if (id >= 0 && id < SIDE_LOCATIONS.length) { + return SIDE_LOCATIONS[id]; + } - return INTERNAL; - } + return INTERNAL; + } - /** - * 100% chance of success. - * - * @param side - * @return proper Part Location for a facing enum. - */ - public static AEPartLocation fromFacing( final Direction side ) - { - if( side == null ) - { - return INTERNAL; - } - return values()[side.ordinal()]; - } + /** + * 100% chance of success. + * + * @param side + * @return proper Part Location for a facing enum. + */ + public static AEPartLocation fromFacing(final Direction side) { + if (side == null) { + return INTERNAL; + } + return values()[side.ordinal()]; + } - /** - * @return Opposite Part Location, INTERNAL remains INTERNAL. - */ - public AEPartLocation getOpposite() - { - return fromOrdinal( OPPOSITES[this.ordinal()] ); - } + /** + * @return Opposite Part Location, INTERNAL remains INTERNAL. + */ + public AEPartLocation getOpposite() { + return fromOrdinal(OPPOSITES[this.ordinal()]); + } - /** - * @return EnumFacing Equivalence, if Center returns null. - */ - public Direction getFacing() - { - return facings[this.ordinal()]; - } + /** + * @return EnumFacing Equivalence, if Center returns null. + */ + public Direction getFacing() { + return facings[this.ordinal()]; + } } diff --git a/src/api/java/appeng/api/util/DimensionalCoord.java b/src/api/java/appeng/api/util/DimensionalCoord.java index 544d99521..0b0112d8f 100644 --- a/src/api/java/appeng/api/util/DimensionalCoord.java +++ b/src/api/java/appeng/api/util/DimensionalCoord.java @@ -23,87 +23,73 @@ package appeng.api.util; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.dimension.Dimension; - /** * Represents a location in the Minecraft Universe */ -public class DimensionalCoord extends WorldCoord -{ +public class DimensionalCoord extends WorldCoord { - private final IWorld world; - private final Dimension dimension; + private final IWorld world; + private final Dimension dimension; - public DimensionalCoord( final DimensionalCoord coordinate ) - { - super( coordinate.x, coordinate.y, coordinate.z ); - this.world = coordinate.world; - this.dimension = coordinate.dimension; - } + public DimensionalCoord(final DimensionalCoord coordinate) { + super(coordinate.x, coordinate.y, coordinate.z); + this.world = coordinate.world; + this.dimension = coordinate.dimension; + } - public DimensionalCoord( final TileEntity tileEntity ) - { - super( tileEntity ); - this.world = tileEntity.getWorld(); - this.dimension = this.world.getDimension(); - } + public DimensionalCoord(final TileEntity tileEntity) { + super(tileEntity); + this.world = tileEntity.getWorld(); + this.dimension = this.world.getDimension(); + } - public DimensionalCoord( final IWorld world, final int x, final int y, final int z ) - { - super( x, y, z ); - this.world = world; - this.dimension = world.getDimension(); - } + public DimensionalCoord(final IWorld world, final int x, final int y, final int z) { + super(x, y, z); + this.world = world; + this.dimension = world.getDimension(); + } - public DimensionalCoord( final IWorld world, final BlockPos pos ) - { - super( pos ); - this.world = world; - this.dimension = world.getDimension(); - } + public DimensionalCoord(final IWorld world, final BlockPos pos) { + super(pos); + this.world = world; + this.dimension = world.getDimension(); + } - @Override - public DimensionalCoord copy() - { - return new DimensionalCoord( this ); - } + @Override + public DimensionalCoord copy() { + return new DimensionalCoord(this); + } - @Override - public int hashCode() - { - return super.hashCode() ^ this.dimension.hashCode(); - } + @Override + public int hashCode() { + return super.hashCode() ^ this.dimension.hashCode(); + } - @Override - public boolean equals( final Object obj ) - { - return obj instanceof DimensionalCoord && this.isEqual( (DimensionalCoord) obj ); - } + @Override + public boolean equals(final Object obj) { + return obj instanceof DimensionalCoord && this.isEqual((DimensionalCoord) obj); + } - @Override - public String toString() - { - return "dimension=" + this.dimension + ", " + super.toString(); - } + @Override + public String toString() { + return "dimension=" + this.dimension + ", " + super.toString(); + } - public boolean isInWorld( final IWorld world ) - { - return this.world == world; - } + public boolean isInWorld(final IWorld world) { + return this.world == world; + } - public IWorld getWorld() - { - return this.world; - } + public IWorld getWorld() { + return this.world; + } - private boolean isEqual( final DimensionalCoord c ) - { - return this.x == c.x && this.y == c.y && this.z == c.z && c.world == this.world; - } + private boolean isEqual(final DimensionalCoord c) { + return this.x == c.x && this.y == c.y && this.z == c.z && c.world == this.world; + } } diff --git a/src/api/java/appeng/api/util/IClientHelper.java b/src/api/java/appeng/api/util/IClientHelper.java index 83c69b6ed..4b7550500 100644 --- a/src/api/java/appeng/api/util/IClientHelper.java +++ b/src/api/java/appeng/api/util/IClientHelper.java @@ -1,22 +1,20 @@ package appeng.api.util; - import java.util.List; +import net.minecraft.util.text.ITextComponent; + import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.data.IAEStack; -import net.minecraft.util.text.ITextComponent; - -public interface IClientHelper -{ - /** - * Add cell information to the provided list. Used for tooltip content. - * - * @param handler Cell handler. - * @param lines List of lines to add to. - */ - > void addCellInformation( ICellInventoryHandler handler, List lines ); +public interface IClientHelper { + /** + * Add cell information to the provided list. Used for tooltip content. + * + * @param handler Cell handler. + * @param lines List of lines to add to. + */ + > void addCellInformation(ICellInventoryHandler handler, List lines); } diff --git a/src/api/java/appeng/api/util/ICommonTile.java b/src/api/java/appeng/api/util/ICommonTile.java index e6431aa49..561b524f8 100644 --- a/src/api/java/appeng/api/util/ICommonTile.java +++ b/src/api/java/appeng/api/util/ICommonTile.java @@ -23,24 +23,21 @@ package appeng.api.util; - import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +public interface ICommonTile { -public interface ICommonTile -{ - - /** - * implemented on AE's Tile Entities, Gets a list of drops that the entity will normally drop, this doesn't include - * the block itself. - * - * @param world world of tile entity - * @param pos location of the block - * @param drops drops of tile entity - */ - void getDrops( World world, BlockPos pos, List drops ); + /** + * implemented on AE's Tile Entities, Gets a list of drops that the entity will + * normally drop, this doesn't include the block itself. + * + * @param world world of tile entity + * @param pos location of the block + * @param drops drops of tile entity + */ + void getDrops(World world, BlockPos pos, List 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 02204735b..2bffe50df 100644 --- a/src/api/java/appeng/api/util/IConfigManager.java +++ b/src/api/java/appeng/api/util/IConfigManager.java @@ -23,67 +23,65 @@ package appeng.api.util; - import java.util.Set; import net.minecraft.nbt.CompoundNBT; import appeng.api.config.Settings; - /** * Used to adjust settings on an object, * * Obtained via {@link IConfigurableObject} */ -public interface IConfigManager -{ +public interface IConfigManager { - /** - * get a list of different settings - * - * @return enum set of settings - */ - Set getSettings(); + /** + * get a list of different settings + * + * @return enum set of settings + */ + Set getSettings(); - /** - * used to initialize the configuration manager, should be called for all settings. - * - * @param settingName name of setting - * @param defaultValue default value of setting - */ - void registerSetting( Settings settingName, Enum defaultValue ); + /** + * used to initialize the configuration manager, should be called for all + * settings. + * + * @param settingName name of setting + * @param defaultValue default value of setting + */ + void registerSetting(Settings settingName, Enum defaultValue); - /** - * Get Value of a particular setting - * - * @param settingName name of setting - * - * @return value of setting - */ - Enum getSetting( Settings settingName ); + /** + * Get Value of a particular setting + * + * @param settingName name of setting + * + * @return value of setting + */ + Enum getSetting(Settings settingName); - /** - * Change setting - * - * @param settingName to be changed setting - * @param newValue new value for setting - * - * @return changed setting - */ - Enum putSetting( Settings settingName, Enum newValue ); + /** + * Change setting + * + * @param settingName to be changed setting + * @param newValue new value for setting + * + * @return changed setting + */ + Enum putSetting(Settings settingName, Enum newValue); - /** - * write all settings to the NBT Tag so they can be read later. - * - * @param destination to be written nbt tag - */ - void writeToNBT( CompoundNBT destination ); + /** + * write all settings to the NBT Tag so they can be read later. + * + * @param destination to be written nbt tag + */ + void writeToNBT(CompoundNBT destination); - /** - * Only works after settings have been registered - * - * @param src to be read nbt tag - */ - void readFromNBT( CompoundNBT src ); + /** + * Only works after settings have been registered + * + * @param src to be read nbt tag + */ + void readFromNBT(CompoundNBT src); } diff --git a/src/api/java/appeng/api/util/IConfigurableObject.java b/src/api/java/appeng/api/util/IConfigurableObject.java index e25e74035..8c7a210f6 100644 --- a/src/api/java/appeng/api/util/IConfigurableObject.java +++ b/src/api/java/appeng/api/util/IConfigurableObject.java @@ -23,15 +23,13 @@ package appeng.api.util; - /** * Implemented by various Tiles or Parts in AE */ -public interface IConfigurableObject -{ +public interface IConfigurableObject { - /** - * get the config manager for the object. - */ - IConfigManager getConfigManager(); + /** + * 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 3c56060f8..bd4f3e193 100644 --- a/src/api/java/appeng/api/util/INetworkToolAgent.java +++ b/src/api/java/appeng/api/util/INetworkToolAgent.java @@ -23,15 +23,13 @@ package appeng.api.util; - import net.minecraft.util.math.RayTraceResult; - /** - * Implement on Tile or part to customize if the info gui opens, or an action is preformed. + * Implement on Tile or part to customize if the info gui opens, or an action is + * preformed. */ -public interface INetworkToolAgent -{ +public interface INetworkToolAgent { - boolean showNetworkInfo( RayTraceResult where ); + boolean showNetworkInfo(RayTraceResult where); } diff --git a/src/api/java/appeng/api/util/IOrientable.java b/src/api/java/appeng/api/util/IOrientable.java index f8b06fa08..e9280d0eb 100644 --- a/src/api/java/appeng/api/util/IOrientable.java +++ b/src/api/java/appeng/api/util/IOrientable.java @@ -23,40 +23,38 @@ package appeng.api.util; - import net.minecraft.util.Direction; - /** * Nearly all of AE's Tile Entities implement IOrientable. * - * and it can be used to manipulate the direction of some machines, most of these orientations are purely visual. + * and it can be used to manipulate the direction of some machines, most of + * these orientations are purely visual. * * AE also responds to Block.rotateBlock */ -public interface IOrientable -{ +public interface IOrientable { - /** - * @return true or false, if the tile rotation is meaningful, or even changeable - */ - boolean canBeRotated(); + /** + * @return true or false, if the tile rotation is meaningful, or even changeable + */ + boolean canBeRotated(); - /** - * @return the direction the tile is facing - */ - Direction getForward(); + /** + * @return the direction the tile is facing + */ + Direction getForward(); - /** - * @return the direction top of the tile - */ - Direction getUp(); + /** + * @return the direction top of the tile + */ + Direction getUp(); - /** - * Update the orientation - * - * @param Forward new forward direction - * @param Up new upwards direction - */ - void setOrientation( Direction Forward, Direction Up ); + /** + * Update the orientation + * + * @param Forward new forward direction + * @param Up new upwards direction + */ + void setOrientation(Direction Forward, Direction Up); } \ No newline at end of file diff --git a/src/api/java/appeng/api/util/IOrientableBlock.java b/src/api/java/appeng/api/util/IOrientableBlock.java index 516c3a9c3..3d68b062b 100644 --- a/src/api/java/appeng/api/util/IOrientableBlock.java +++ b/src/api/java/appeng/api/util/IOrientableBlock.java @@ -23,22 +23,20 @@ package appeng.api.util; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; - /** - * Implemented on many of AE's non Tile Entity Blocks as a way to get a IOrientable. + * Implemented on many of AE's non Tile Entity Blocks as a way to get a + * IOrientable. */ -public interface IOrientableBlock -{ +public interface IOrientableBlock { - /** - * @param world world of block - * @param pos The position of the block. - * - * @return a IOrientable if applicable - */ - IOrientable getOrientable( IBlockReader world, BlockPos pos ); + /** + * @param world world of block + * @param pos The position of the block. + * + * @return a IOrientable if applicable + */ + IOrientable getOrientable(IBlockReader world, BlockPos pos); } \ 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 84e042ae7..86b57ab31 100644 --- a/src/api/java/appeng/api/util/IReadOnlyCollection.java +++ b/src/api/java/appeng/api/util/IReadOnlyCollection.java @@ -23,22 +23,20 @@ package appeng.api.util; +public interface IReadOnlyCollection extends Iterable { -public interface IReadOnlyCollection extends Iterable -{ + /** + * @return the objects in in the set. + */ + int size(); - /** - * @return the objects in in the set. - */ - int size(); + /** + * @return true if there are objects in the set + */ + boolean isEmpty(); - /** - * @return true if there are objects in the set - */ - boolean isEmpty(); - - /** - * @return return true if the object is part of the set. - */ - boolean contains( Object node ); + /** + * @return return true if the object is part of the set. + */ + 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 b0af1c171..570847bff 100644 --- a/src/api/java/appeng/api/util/WorldCoord.java +++ b/src/api/java/appeng/api/util/WorldCoord.java @@ -23,172 +23,146 @@ package appeng.api.util; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; - /** * Represents a relative coordinate, either relative to another object, or * relative to the origin of a dimension. * * TODO: Consider replacing with {@link BlockPos} */ -public class WorldCoord -{ +public class WorldCoord { - public int x; - public int y; - public int z; + public int x; + public int y; + public int z; - public WorldCoord( final TileEntity s ) - { - this( s.getPos() ); - } + public WorldCoord(final TileEntity s) { + this(s.getPos()); + } - public WorldCoord( final int _x, final int _y, final int _z ) - { - this.x = _x; - this.y = _y; - this.z = _z; - } + public WorldCoord(final int _x, final int _y, final int _z) { + this.x = _x; + this.y = _y; + this.z = _z; + } - public WorldCoord( final BlockPos pos ) - { - this.x = pos.getX(); - this.y = pos.getY(); - this.z = pos.getZ(); - } + public WorldCoord(final BlockPos pos) { + this.x = pos.getX(); + this.y = pos.getY(); + this.z = pos.getZ(); + } - public WorldCoord subtract( final AEPartLocation direction, final int length ) - { - this.x -= direction.xOffset * length; - this.y -= direction.yOffset * length; - this.z -= direction.zOffset * length; - return this; - } + public WorldCoord subtract(final AEPartLocation direction, final int length) { + this.x -= direction.xOffset * length; + this.y -= direction.yOffset * length; + this.z -= direction.zOffset * length; + return this; + } - public WorldCoord add( final int _x, final int _y, final int _z ) - { - this.x += _x; - this.y += _y; - this.z += _z; - return this; - } + public WorldCoord add(final int _x, final int _y, final int _z) { + this.x += _x; + this.y += _y; + this.z += _z; + return this; + } - public WorldCoord subtract( final int _x, final int _y, final int _z ) - { - this.x -= _x; - this.y -= _y; - this.z -= _z; - return this; - } + public WorldCoord subtract(final int _x, final int _y, final int _z) { + this.x -= _x; + this.y -= _y; + this.z -= _z; + return this; + } - public WorldCoord multiple( final int _x, final int _y, final int _z ) - { - this.x *= _x; - this.y *= _y; - this.z *= _z; - return this; - } + public WorldCoord multiple(final int _x, final int _y, final int _z) { + this.x *= _x; + this.y *= _y; + this.z *= _z; + return this; + } - public WorldCoord divide( final int _x, final int _y, final int _z ) - { - this.x /= _x; - this.y /= _y; - this.z /= _z; - return this; - } + public WorldCoord divide(final int _x, final int _y, final int _z) { + this.x /= _x; + this.y /= _y; + this.z /= _z; + return this; + } - public BlockPos getBlockPos() - { - return new BlockPos(x, y, z); - } + public BlockPos getBlockPos() { + return new BlockPos(x, y, z); + } - /** - * Will Return NULL if it's at some diagonal! - */ - public AEPartLocation directionTo( final WorldCoord loc ) - { - final int ox = this.x - loc.x; - final int oy = this.y - loc.y; - final int oz = this.z - loc.z; + /** + * Will Return NULL if it's at some diagonal! + */ + public AEPartLocation directionTo(final WorldCoord loc) { + final int ox = this.x - loc.x; + final int oy = this.y - loc.y; + final int oz = this.z - loc.z; - final int xlen = Math.abs( ox ); - final int ylen = Math.abs( oy ); - final int zlen = Math.abs( oz ); + final int xlen = Math.abs(ox); + final int ylen = Math.abs(oy); + final int zlen = Math.abs(oz); - if( loc.isEqual( this.copy().add( AEPartLocation.EAST, xlen ) ) ) - { - return AEPartLocation.EAST; - } + if (loc.isEqual(this.copy().add(AEPartLocation.EAST, xlen))) { + return AEPartLocation.EAST; + } - if( loc.isEqual( this.copy().add( AEPartLocation.WEST, xlen ) ) ) - { - return AEPartLocation.WEST; - } + if (loc.isEqual(this.copy().add(AEPartLocation.WEST, xlen))) { + return AEPartLocation.WEST; + } - if( loc.isEqual( this.copy().add( AEPartLocation.NORTH, zlen ) ) ) - { - return AEPartLocation.NORTH; - } + if (loc.isEqual(this.copy().add(AEPartLocation.NORTH, zlen))) { + return AEPartLocation.NORTH; + } - if( loc.isEqual( this.copy().add( AEPartLocation.SOUTH, zlen ) ) ) - { - return AEPartLocation.SOUTH; - } + if (loc.isEqual(this.copy().add(AEPartLocation.SOUTH, zlen))) { + return AEPartLocation.SOUTH; + } - if( loc.isEqual( this.copy().add( AEPartLocation.UP, ylen ) ) ) - { - return AEPartLocation.UP; - } + if (loc.isEqual(this.copy().add(AEPartLocation.UP, ylen))) { + return AEPartLocation.UP; + } - if( loc.isEqual( this.copy().add( AEPartLocation.DOWN, ylen ) ) ) - { - return AEPartLocation.DOWN; - } + if (loc.isEqual(this.copy().add(AEPartLocation.DOWN, ylen))) { + return AEPartLocation.DOWN; + } - return null; - } + return null; + } - public boolean isEqual( final WorldCoord c ) - { - return this.x == c.x && this.y == c.y && this.z == c.z; - } + public boolean isEqual(final WorldCoord c) { + return this.x == c.x && this.y == c.y && this.z == c.z; + } - public WorldCoord add( final AEPartLocation direction, final int length ) - { - this.x += direction.xOffset * length; - this.y += direction.yOffset * length; - this.z += direction.zOffset * length; - return this; - } + public WorldCoord add(final AEPartLocation direction, final int length) { + this.x += direction.xOffset * length; + this.y += direction.yOffset * length; + this.z += direction.zOffset * length; + return this; + } - public WorldCoord copy() - { - return new WorldCoord( this.x, this.y, this.z ); - } + public WorldCoord copy() { + return new WorldCoord(this.x, this.y, this.z); + } - @Override - public int hashCode() - { - return ( this.y << 24 ) ^ this.x ^ this.z; - } + @Override + public int hashCode() { + return (this.y << 24) ^ this.x ^ this.z; + } - @Override - public boolean equals( final Object obj ) - { - return obj instanceof WorldCoord && this.isEqual( (WorldCoord) obj ); - } + @Override + public boolean equals(final Object obj) { + return obj instanceof WorldCoord && this.isEqual((WorldCoord) obj); + } - public BlockPos getPos() - { - return new BlockPos( this.x, this.y, this.z ); - } + public BlockPos getPos() { + return new BlockPos(this.x, this.y, this.z); + } - @Override - public String toString() - { - return "x=" + this.x + ", y=" + this.y + ", z=" + this.z; - } + @Override + public String toString() { + return "x=" + this.x + ", y=" + this.y + ", z=" + this.z; + } } diff --git a/src/main/java/appeng/block/AEBaseBlock.java b/src/main/java/appeng/block/AEBaseBlock.java index 95286f8da..501f5f32d 100644 --- a/src/main/java/appeng/block/AEBaseBlock.java +++ b/src/main/java/appeng/block/AEBaseBlock.java @@ -18,11 +18,8 @@ package appeng.block; - import javax.annotation.Nullable; -import appeng.helpers.AEGlassMaterial; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; @@ -40,68 +37,60 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraftforge.common.ToolType; import appeng.api.util.IOrientable; import appeng.api.util.IOrientableBlock; -import net.minecraftforge.common.ToolType; +import appeng.helpers.AEGlassMaterial; +import appeng.util.Platform; +public abstract class AEBaseBlock extends Block { -public abstract class AEBaseBlock extends Block -{ + private boolean isOpaque = true; + private boolean isFullSize = true; + private boolean isInventory = false; - private boolean isOpaque = true; - private boolean isFullSize = true; - private boolean isInventory = false; + protected VoxelShape boundingBox = VoxelShapes.fullCube(); - protected VoxelShape boundingBox = VoxelShapes.fullCube(); + protected AEBaseBlock(final Block.Properties props) { + super(props); + } - protected AEBaseBlock( final Block.Properties props ) - { - super( props ); - } + /** + * Utility function to create block properties with some sensible defaults for + * AE blocks. + */ + public static Block.Properties defaultProps(Material material) { + return defaultProps(material, material.getColor()); + } - /** - * Utility function to create block properties with some sensible defaults for AE blocks. - */ - public static Block.Properties defaultProps(Material material) { - return defaultProps(material, material.getColor()); - } + /** + * Utility function to create block properties with some sensible defaults for + * AE blocks. + */ + public static Block.Properties defaultProps(Material material, MaterialColor color) { + return Block.Properties.create(material, color) + // These values previousls were encoded in AEBaseBlock + .hardnessAndResistance(2.2f, 11.f).harvestTool(ToolType.PICKAXE).harvestLevel(0) + .sound(getDefaultSoundByMaterial(material)); + } - /** - * Utility function to create block properties with some sensible defaults for AE blocks. - */ - public static Block.Properties defaultProps(Material material, MaterialColor color) { - return Block.Properties.create(material, color) - // These values previousls were encoded in AEBaseBlock - .hardnessAndResistance(2.2f, 11.f) - .harvestTool(ToolType.PICKAXE) - .harvestLevel(0) - .sound(getDefaultSoundByMaterial(material)); - } + private static SoundType getDefaultSoundByMaterial(Material mat) { + if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) { + return SoundType.GLASS; + } else if (mat == Material.ROCK) { + return SoundType.STONE; + } else if (mat == Material.WOOD) { + return SoundType.WOOD; + } else { + return SoundType.METAL; + } + } - private static SoundType getDefaultSoundByMaterial(Material mat) { - if( mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS ) - { - return SoundType.GLASS; - } - else if( mat == Material.ROCK ) - { - return SoundType.STONE; - } - else if( mat == Material.WOOD ) - { - return SoundType.WOOD; - } - else - { - return SoundType.METAL; - } - } - - @Override - public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) { - return this.isFullSize() && this.isOpaque(); - } + @Override + public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) { + return this.isFullSize() && this.isOpaque(); + } // FIXME @SuppressWarnings( "deprecation" ) // FIXME @Override @@ -129,7 +118,6 @@ public abstract class AEBaseBlock extends Block // FIXME } // FIXME - // @Override // public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { // final ICustomCollision collisionHandler = this.getCustomCollision( w, pos ); @@ -192,7 +180,7 @@ public abstract class AEBaseBlock extends Block // return super.getShape( state, w, pos, context ); // } - // FIXME: Move to state + // FIXME: Move to state // FIXME @Override // FIXME public final boolean isOpaqueCube( BlockState state ) // { @@ -243,190 +231,159 @@ public abstract class AEBaseBlock extends Block //FIXME return super.collisionRayTrace( state, w, pos, a, b ); //FIXME } //FIXME - @Override - public boolean hasComparatorInputOverride( BlockState state ) - { - return this.isInventory(); - } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return this.isInventory(); + } - @Override - public int getComparatorInputOverride(BlockState state, final World worldIn, final BlockPos pos ) - { - return 0; - } + @Override + public int getComparatorInputOverride(BlockState state, final World worldIn, final BlockPos pos) { + return 0; + } - /** - * Rotates around the given Axis (usually the current up axis). - */ - public boolean rotateAroundFaceAxis(IWorld w, BlockPos pos, Direction face) { - final IOrientable rotatable = this.getOrientable( w, pos ); + /** + * Rotates around the given Axis (usually the current up axis). + */ + public boolean rotateAroundFaceAxis(IWorld w, BlockPos pos, Direction face) { + final IOrientable rotatable = this.getOrientable(w, pos); - if( rotatable != null && rotatable.canBeRotated() ) - { - if( this.hasCustomRotation() ) - { - this.customRotateBlock( rotatable, face ); - return true; - } - else - { - Direction forward = rotatable.getForward(); - Direction up = rotatable.getUp(); + if (rotatable != null && rotatable.canBeRotated()) { + if (this.hasCustomRotation()) { + this.customRotateBlock(rotatable, face); + return true; + } else { + Direction forward = rotatable.getForward(); + Direction up = rotatable.getUp(); - for( int rs = 0; rs < 4; rs++ ) - { - forward = Platform.rotateAround( forward, face ); - up = Platform.rotateAround( up, face ); + for (int rs = 0; rs < 4; rs++) { + forward = Platform.rotateAround(forward, face); + up = Platform.rotateAround(up, face); - if( this.isValidOrientation( w, pos, forward, up ) ) - { - rotatable.setOrientation( forward, up ); - return true; - } - } - } - } + if (this.isValidOrientation(w, pos, forward, up)) { + rotatable.setOrientation(forward, up); + return true; + } + } + } + } - return false; - } + return false; + } - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - return ActionResultType.PASS; - } + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + return ActionResultType.PASS; + } - public final Direction mapRotation(final IOrientable ori, final Direction dir ) - { - // case DOWN: return bottomIcon; - // case UP: return blockIcon; - // case NORTH: return northIcon; - // case SOUTH: return southIcon; - // case WEST: return sideIcon; - // case EAST: return sideIcon; + public final Direction mapRotation(final IOrientable ori, final Direction dir) { + // case DOWN: return bottomIcon; + // case UP: return blockIcon; + // case NORTH: return northIcon; + // case SOUTH: return southIcon; + // case WEST: return sideIcon; + // case EAST: return sideIcon; - final Direction forward = ori.getForward(); - final Direction up = ori.getUp(); + final Direction forward = ori.getForward(); + final Direction up = ori.getUp(); - if( forward == null || up == null ) - { - return dir; - } + if (forward == null || up == null) { + return dir; + } - final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); - final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); - final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); + final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); + final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); + final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); - Direction west = null; - for( final Direction dx : Direction.values() ) - { - if( dx.getXOffset() == west_x && dx.getYOffset() == west_y && dx.getZOffset() == west_z ) - { - west = dx; - } - } + Direction west = null; + for (final Direction dx : Direction.values()) { + if (dx.getXOffset() == west_x && dx.getYOffset() == west_y && dx.getZOffset() == west_z) { + west = dx; + } + } - if( west == null ) - { - return dir; - } + if (west == null) { + return dir; + } - if( dir == forward ) - { - return Direction.SOUTH; - } - if( dir == forward.getOpposite() ) - { - return Direction.NORTH; - } + if (dir == forward) { + return Direction.SOUTH; + } + if (dir == forward.getOpposite()) { + return Direction.NORTH; + } - if( dir == up ) - { - return Direction.UP; - } - if( dir == up.getOpposite() ) - { - return Direction.DOWN; - } + if (dir == up) { + return Direction.UP; + } + if (dir == up.getOpposite()) { + return Direction.DOWN; + } - if( dir == west ) - { - return Direction.WEST; - } - if( dir == west.getOpposite() ) - { - return Direction.EAST; - } + if (dir == west) { + return Direction.WEST; + } + if (dir == west.getOpposite()) { + return Direction.EAST; + } - return null; - } + return null; + } - @Override - public String toString() - { - String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered"; - return this.getClass().getSimpleName() + "[" + regName + "]"; - } + @Override + public String toString() { + String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered"; + return this.getClass().getSimpleName() + "[" + regName + "]"; + } - protected String getUnlocalizedName( final ItemStack is ) - { - return this.getTranslationKey(); - } + protected String getUnlocalizedName(final ItemStack is) { + return this.getTranslationKey(); + } - protected boolean hasCustomRotation() - { - return false; - } + protected boolean hasCustomRotation() { + return false; + } - protected void customRotateBlock( final IOrientable rotatable, final Direction axis ) - { + protected void customRotateBlock(final IOrientable rotatable, final Direction axis) { - } + } - protected IOrientable getOrientable( final IBlockReader w, final BlockPos pos ) - { - if( this instanceof IOrientableBlock ) - { - IOrientableBlock orientable = (IOrientableBlock) this; - return orientable.getOrientable( w, pos ); - } - return null; - } + protected IOrientable getOrientable(final IBlockReader w, final BlockPos pos) { + if (this instanceof IOrientableBlock) { + IOrientableBlock orientable = (IOrientableBlock) this; + return orientable.getOrientable(w, pos); + } + return null; + } - protected boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up ) - { - return true; - } + protected boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, + final Direction up) { + return true; + } - protected boolean isOpaque() - { - return this.isOpaque; - } + protected boolean isOpaque() { + return this.isOpaque; + } - protected boolean setOpaque( final boolean isOpaque ) - { - this.isOpaque = isOpaque; - return isOpaque; - } + protected boolean setOpaque(final boolean isOpaque) { + this.isOpaque = isOpaque; + return isOpaque; + } - protected boolean isFullSize() - { - return this.isFullSize; - } + protected boolean isFullSize() { + return this.isFullSize; + } - protected boolean setFullSize( final boolean isFullSize ) - { - this.isFullSize = isFullSize; - return isFullSize; - } + protected boolean setFullSize(final boolean isFullSize) { + this.isFullSize = isFullSize; + return isFullSize; + } - protected boolean isInventory() - { - return this.isInventory; - } + protected boolean isInventory() { + return this.isInventory; + } - protected void setInventory( final boolean isInventory ) - { - this.isInventory = isInventory; - } + protected void setInventory(final boolean isInventory) { + this.isInventory = isInventory; + } } diff --git a/src/main/java/appeng/block/AEBaseBlockItem.java b/src/main/java/appeng/block/AEBaseBlockItem.java index 84afb42f3..e123bea5f 100644 --- a/src/main/java/appeng/block/AEBaseBlockItem.java +++ b/src/main/java/appeng/block/AEBaseBlockItem.java @@ -18,16 +18,8 @@ package appeng.block; - import java.util.List; -import appeng.api.util.IOrientable; -import appeng.api.util.IOrientableBlock; -import appeng.block.misc.BlockLightDetector; -import appeng.block.misc.BlockSkyCompass; -import appeng.block.networking.BlockWireless; -import appeng.me.helpers.IGridProxyable; -import appeng.tile.AEBaseTile; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; @@ -43,145 +35,128 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.api.util.IOrientable; +import appeng.api.util.IOrientableBlock; +import appeng.block.misc.BlockLightDetector; +import appeng.block.misc.BlockSkyCompass; +import appeng.block.networking.BlockWireless; +import appeng.me.helpers.IGridProxyable; +import appeng.tile.AEBaseTile; -public class AEBaseBlockItem extends BlockItem -{ +public class AEBaseBlockItem extends BlockItem { - private final AEBaseBlock blockType; + private final AEBaseBlock blockType; - public AEBaseBlockItem(final Block id, Item.Properties props ) - { - super( id, props ); - this.blockType = (AEBaseBlock) id; - } + public AEBaseBlockItem(final Block id, Item.Properties props) { + super(id, props); + this.blockType = (AEBaseBlock) id; + } - @Override - @OnlyIn( Dist.CLIENT ) - public final void addInformation( final ItemStack itemStack, final World world, final List toolTip, final ITooltipFlag advancedTooltips ) - { - this.addCheckedInformation( itemStack, world, toolTip, advancedTooltips ); - } + @Override + @OnlyIn(Dist.CLIENT) + public final void addInformation(final ItemStack itemStack, final World world, final List toolTip, + final ITooltipFlag advancedTooltips) { + this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips); + } - @OnlyIn( Dist.CLIENT ) - public void addCheckedInformation(final ItemStack itemStack, final World world, final List toolTip, final ITooltipFlag advancedTooltips ) - { - this.blockType.addInformation( itemStack, world, toolTip, advancedTooltips ); - } + @OnlyIn(Dist.CLIENT) + public void addCheckedInformation(final ItemStack itemStack, final World world, final List toolTip, + final ITooltipFlag advancedTooltips) { + this.blockType.addInformation(itemStack, world, toolTip, advancedTooltips); + } - @Override - public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 ) - { - return false; - } + @Override + public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) { + return false; + } - @Override - public String getTranslationKey( final ItemStack is ) - { - return this.blockType.getTranslationKey(); - } + @Override + public String getTranslationKey(final ItemStack is) { + return this.blockType.getTranslationKey(); + } - @Override - public ActionResultType tryPlace(BlockItemUseContext context) { + @Override + public ActionResultType tryPlace(BlockItemUseContext context) { - Direction up = null; - Direction forward = null; + Direction up = null; + Direction forward = null; - Direction side = context.getFace(); - PlayerEntity player = context.getPlayer(); + Direction side = context.getFace(); + PlayerEntity player = context.getPlayer(); - if( this.blockType instanceof AEBaseTileBlock ) - { - if( this.blockType instanceof BlockLightDetector) - { - up = side; - if( up == Direction.UP || up == Direction.DOWN ) - { - forward = Direction.SOUTH; - } - else - { - forward = Direction.UP; - } - } - else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass) - { - forward = side; - if( forward == Direction.UP || forward == Direction.DOWN ) - { - up = Direction.SOUTH; - } - else - { - up = Direction.UP; - } - } - else - { - up = Direction.UP; - forward = context.getPlacementHorizontalFacing().getOpposite(); + if (this.blockType instanceof AEBaseTileBlock) { + if (this.blockType instanceof BlockLightDetector) { + up = side; + if (up == Direction.UP || up == Direction.DOWN) { + forward = Direction.SOUTH; + } else { + forward = Direction.UP; + } + } else if (this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass) { + forward = side; + if (forward == Direction.UP || forward == Direction.DOWN) { + up = Direction.SOUTH; + } else { + up = Direction.UP; + } + } else { + up = Direction.UP; + forward = context.getPlacementHorizontalFacing().getOpposite(); - if (player != null) { - if (player.rotationPitch > 65) { - up = forward.getOpposite(); - forward = Direction.UP; - } else if (player.rotationPitch < -65) { - up = forward.getOpposite(); - forward = Direction.DOWN; - } - } - } - } + if (player != null) { + if (player.rotationPitch > 65) { + up = forward.getOpposite(); + forward = Direction.UP; + } else if (player.rotationPitch < -65) { + up = forward.getOpposite(); + forward = Direction.DOWN; + } + } + } + } - IOrientable ori = null; - if( this.blockType instanceof IOrientableBlock) - { - ori = ( (IOrientableBlock) this.blockType ).getOrientable( context.getWorld(), context.getPos() ); - up = side; - forward = Direction.SOUTH; - if( up.getYOffset() == 0 ) - { - forward = Direction.UP; - } - } + IOrientable ori = null; + if (this.blockType instanceof IOrientableBlock) { + ori = ((IOrientableBlock) this.blockType).getOrientable(context.getWorld(), context.getPos()); + up = side; + forward = Direction.SOUTH; + if (up.getYOffset() == 0) { + forward = Direction.UP; + } + } - if( !this.blockType.isValidOrientation( context.getWorld(), context.getPos(), forward, up ) ) - { - return ActionResultType.FAIL; - } + if (!this.blockType.isValidOrientation(context.getWorld(), context.getPos(), forward, up)) { + return ActionResultType.FAIL; + } - ActionResultType result = super.tryPlace(context); - if (result != ActionResultType.SUCCESS) { - return result; - } + ActionResultType result = super.tryPlace(context); + if (result != ActionResultType.SUCCESS) { + return result; + } - if( this.blockType instanceof AEBaseTileBlock && !( this.blockType instanceof BlockLightDetector ) ) - { - final AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( context.getWorld(), context.getPos() ); - ori = tile; + if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof BlockLightDetector)) { + final AEBaseTile tile = ((AEBaseTileBlock) this.blockType).getTileEntity(context.getWorld(), + context.getPos()); + ori = tile; - if( tile == null ) - { - return ActionResultType.SUCCESS; - } + if (tile == null) { + return ActionResultType.SUCCESS; + } - if( ori.canBeRotated() && !this.blockType.hasCustomRotation() ) - { - ori.setOrientation( forward, up ); - } + if (ori.canBeRotated() && !this.blockType.hasCustomRotation()) { + ori.setOrientation(forward, up); + } - if( tile instanceof IGridProxyable) - { - ( (IGridProxyable) tile ).getProxy().setOwner( player ); - } + if (tile instanceof IGridProxyable) { + ((IGridProxyable) tile).getProxy().setOwner(player); + } - tile.onPlacement( context ); - } - else if( this.blockType instanceof IOrientableBlock ) - { - ori.setOrientation( forward, up ); - } + tile.onPlacement(context); + } else if (this.blockType instanceof IOrientableBlock) { + ori.setOrientation(forward, up); + } - return ActionResultType.SUCCESS; + return ActionResultType.SUCCESS; - } + } } diff --git a/src/main/java/appeng/block/AEBaseBlockItemChargeable.java b/src/main/java/appeng/block/AEBaseBlockItemChargeable.java index 5641c60e8..010fca5cb 100644 --- a/src/main/java/appeng/block/AEBaseBlockItemChargeable.java +++ b/src/main/java/appeng/block/AEBaseBlockItemChargeable.java @@ -18,14 +18,9 @@ package appeng.block; +import java.text.MessageFormat; +import java.util.List; -import appeng.api.AEApi; -import appeng.api.config.AccessRestriction; -import appeng.api.config.Actionable; -import appeng.api.config.PowerUnits; -import appeng.api.definitions.IBlockDefinition; -import appeng.api.implementations.items.IAEItemPowerStorage; -import appeng.core.localization.GuiText; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; @@ -37,128 +32,116 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.text.MessageFormat; -import java.util.List; +import appeng.api.AEApi; +import appeng.api.config.AccessRestriction; +import appeng.api.config.Actionable; +import appeng.api.config.PowerUnits; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.implementations.items.IAEItemPowerStorage; +import appeng.core.localization.GuiText; +public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage { -public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage -{ + public AEBaseBlockItemChargeable(Block id, Properties props) { + super(id, props); - public AEBaseBlockItemChargeable(Block id, Properties props) { - super(id, props); + addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> { + double curPower = getAECurrentPower(is); + double maxPower = getAEMaxPower(is); - addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> { - double curPower = getAECurrentPower(is); - double maxPower = getAEMaxPower(is); + return (int) Math.round(100 * curPower / maxPower); + }); + } - return (int) Math.round(100 * curPower / maxPower); - }); - } + @Override + @OnlyIn(Dist.CLIENT) + public void addCheckedInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + double internalCurrentPower = 0; + final double internalMaxPower = this.getMaxEnergyCapacity(); - @Override - @OnlyIn( Dist.CLIENT ) - public void addCheckedInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - double internalCurrentPower = 0; - final double internalMaxPower = this.getMaxEnergyCapacity(); + if (internalMaxPower > 0) { + final CompoundNBT tag = stack.getTag(); + if (tag != null) { + internalCurrentPower = tag.getDouble("internalCurrentPower"); + } - if( internalMaxPower > 0 ) - { - final CompoundNBT tag = stack.getTag(); - if( tag != null ) - { - internalCurrentPower = tag.getDouble( "internalCurrentPower" ); - } + final double percent = internalCurrentPower / internalMaxPower; - final double percent = internalCurrentPower / internalMaxPower; + lines.add(GuiText.StoredEnergy.textComponent() + .appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower)) + .appendSibling(new TranslationTextComponent(PowerUnits.AE.unlocalizedName)) + .appendText(" - " + MessageFormat.format("{0,number,#.##%}", percent))); + } + } - lines.add( GuiText.StoredEnergy.textComponent().appendText(':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower )) - .appendSibling(new TranslationTextComponent( PowerUnits.AE.unlocalizedName )) - .appendText(" - " + MessageFormat.format( "{0,number,#.##%}", percent ))); - } - } + @Override + public double injectAEPower(final ItemStack is, double amount, Actionable mode) { + final double internalCurrentPower = this.getInternal(is); + final double internalMaxPower = this.getAEMaxPower(is); + final double required = internalMaxPower - internalCurrentPower; + final double overflow = Math.max(0, amount - required); - @Override - public double injectAEPower( final ItemStack is, double amount, Actionable mode ) - { - final double internalCurrentPower = this.getInternal( is ); - final double internalMaxPower = this.getAEMaxPower( is ); - final double required = internalMaxPower - internalCurrentPower; - final double overflow = Math.max( 0, amount - required ); + if (mode == Actionable.MODULATE) { + final double toAdd = Math.min(required, amount); + final double newPowerStored = internalCurrentPower + toAdd; - if( mode == Actionable.MODULATE ) - { - final double toAdd = Math.min( required, amount ); - final double newPowerStored = internalCurrentPower + toAdd; + this.setInternal(is, newPowerStored); + } - this.setInternal( is, newPowerStored ); - } + return overflow; + } - return overflow; - } + @Override + public double extractAEPower(final ItemStack is, double amount, Actionable mode) { + final double internalCurrentPower = this.getInternal(is); + final double fulfillable = Math.min(amount, internalCurrentPower); - @Override - public double extractAEPower( final ItemStack is, double amount, Actionable mode ) - { - final double internalCurrentPower = this.getInternal( is ); - final double fulfillable = Math.min( amount, internalCurrentPower ); + if (mode == Actionable.MODULATE) { + final double newPowerStored = internalCurrentPower - fulfillable; - if( mode == Actionable.MODULATE ) - { - final double newPowerStored = internalCurrentPower - fulfillable; + this.setInternal(is, newPowerStored); + } - this.setInternal( is, newPowerStored ); - } + return fulfillable; + } - return fulfillable; - } + @Override + public double getAEMaxPower(final ItemStack is) { + return this.getMaxEnergyCapacity(); + } - @Override - public double getAEMaxPower( final ItemStack is ) - { - return this.getMaxEnergyCapacity(); - } + @Override + public double getAECurrentPower(final ItemStack is) { + return this.getInternal(is); + } - @Override - public double getAECurrentPower( final ItemStack is ) - { - return this.getInternal( is ); - } + @Override + public AccessRestriction getPowerFlow(final ItemStack is) { + return AccessRestriction.WRITE; + } - @Override - public AccessRestriction getPowerFlow( final ItemStack is ) - { - return AccessRestriction.WRITE; - } + private double getMaxEnergyCapacity() { + final Block blockID = Block.getBlockFromItem(this); + final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell(); - private double getMaxEnergyCapacity() - { - final Block blockID = Block.getBlockFromItem( this ); - final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell(); + return energyCell.maybeBlock().map(block -> { + if (blockID == block) { + return 200000; + } else { + return 8 * 200000; + } + }).orElse(0); + } - return energyCell.maybeBlock().map( block -> - { - if( blockID == block ) - { - return 200000; - } - else - { - return 8 * 200000; - } - } ).orElse( 0 ); - } + private double getInternal(final ItemStack is) { + final CompoundNBT nbt = is.getOrCreateTag(); + return nbt.getDouble("internalCurrentPower"); + } - private double getInternal( final ItemStack is ) - { - final CompoundNBT nbt = is.getOrCreateTag(); - return nbt.getDouble( "internalCurrentPower" ); - } - - private void setInternal( final ItemStack is, final double amt ) - { - final CompoundNBT nbt = is.getOrCreateTag(); - nbt.putDouble("internalCurrentPower", amt); - } + private void setInternal(final ItemStack is, final double amt) { + final CompoundNBT nbt = is.getOrCreateTag(); + nbt.putDouble("internalCurrentPower", amt); + } } diff --git a/src/main/java/appeng/block/AEBaseTileBlock.java b/src/main/java/appeng/block/AEBaseTileBlock.java index a8023ad0d..3111da7fa 100644 --- a/src/main/java/appeng/block/AEBaseTileBlock.java +++ b/src/main/java/appeng/block/AEBaseTileBlock.java @@ -18,20 +18,15 @@ package appeng.block; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.api.implementations.items.IMemoryCard; -import appeng.api.implementations.items.MemoryCardMessages; -import appeng.api.implementations.tiles.IColorableTile; -import appeng.api.util.AEColor; -import appeng.api.util.IOrientable; -import appeng.block.networking.BlockCableBus; -import appeng.tile.AEBaseInvTile; -import appeng.tile.AEBaseTile; -import appeng.tile.networking.TileCableBus; -import appeng.tile.storage.TileSkyChest; -import appeng.util.Platform; -import appeng.util.SettingsFrom; import com.google.common.collect.Lists; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; @@ -50,292 +45,262 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; +import appeng.api.implementations.items.IMemoryCard; +import appeng.api.implementations.items.MemoryCardMessages; +import appeng.api.implementations.tiles.IColorableTile; +import appeng.api.util.AEColor; +import appeng.api.util.IOrientable; +import appeng.block.networking.BlockCableBus; +import appeng.tile.AEBaseInvTile; +import appeng.tile.AEBaseTile; +import appeng.tile.networking.TileCableBus; +import appeng.tile.storage.TileSkyChest; +import appeng.util.Platform; +import appeng.util.SettingsFrom; -public abstract class AEBaseTileBlock extends AEBaseBlock -{ +public abstract class AEBaseTileBlock extends AEBaseBlock { - @Nonnull - private Class tileEntityClass; - @Nonnull - private Supplier tileEntityFactory; + @Nonnull + private Class tileEntityClass; + @Nonnull + private Supplier tileEntityFactory; - public AEBaseTileBlock( final Block.Properties props ) - { - super( props ); - } + public AEBaseTileBlock(final Block.Properties props) { + super(props); + } - // TODO : Was this change needed? - public void setTileEntity( final Class tileEntityClass, Supplier factory ) - { - this.tileEntityClass = tileEntityClass; - this.tileEntityFactory = factory; - this.setInventory( AEBaseInvTile.class.isAssignableFrom( tileEntityClass ) ); - } + // TODO : Was this change needed? + public void setTileEntity(final Class tileEntityClass, Supplier factory) { + this.tileEntityClass = tileEntityClass; + this.tileEntityFactory = factory; + this.setInventory(AEBaseInvTile.class.isAssignableFrom(tileEntityClass)); + } - @Override - public boolean hasTileEntity( BlockState state ) - { - return this.hasBlockTileEntity(); - } + @Override + public boolean hasTileEntity(BlockState state) { + return this.hasBlockTileEntity(); + } - private boolean hasBlockTileEntity() - { - return true; - } + private boolean hasBlockTileEntity() { + return true; + } - public Class getTileEntityClass() - { - return this.tileEntityClass; - } + public Class getTileEntityClass() { + return this.tileEntityClass; + } - @Nullable - public T getTileEntity( final IBlockReader w, final int x, final int y, final int z ) - { - return this.getTileEntity( w, new BlockPos( x, y, z ) ); - } + @Nullable + public T getTileEntity(final IBlockReader w, final int x, final int y, final int z) { + return this.getTileEntity(w, new BlockPos(x, y, z)); + } - @Nullable - public T getTileEntity( final IBlockReader w, final BlockPos pos ) - { - if( !this.hasBlockTileEntity() ) - { - return null; - } + @Nullable + public T getTileEntity(final IBlockReader w, final BlockPos pos) { + if (!this.hasBlockTileEntity()) { + return null; + } - final TileEntity te = w.getTileEntity( pos ); - // FIXME: This gets called as part of building the block state cache - if( this.tileEntityClass != null && this.tileEntityClass.isInstance( te ) ) - { - return this.tileEntityClass.cast(te); - } + final TileEntity te = w.getTileEntity(pos); + // FIXME: This gets called as part of building the block state cache + if (this.tileEntityClass != null && this.tileEntityClass.isInstance(te)) { + return this.tileEntityClass.cast(te); + } - return null; - } + return null; + } - @Override - public final TileEntity createTileEntity( BlockState state, IBlockReader world ) - { - return this.tileEntityFactory.get(); - } + @Override + public final TileEntity createTileEntity(BlockState state, IBlockReader world) { + return this.tileEntityFactory.get(); + } - @Override - public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) { - super.dropXpOnBlockBreak(worldIn, pos, amount); - } + @Override + public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) { + super.dropXpOnBlockBreak(worldIn, pos, amount); + } - @Override - public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { - if (newState.getBlock() == state.getBlock()) { - return; // Just a block state change - } + @Override + public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() == state.getBlock()) { + return; // Just a block state change + } - final AEBaseTile te = this.getTileEntity( w, pos ); - if( te != null ) - { - final ArrayList drops = new ArrayList<>(); - if( te.dropItems() ) - { - te.getDrops( w, pos, drops ); - } - else - { - te.getNoDrops( w, pos, drops ); - } + final AEBaseTile te = this.getTileEntity(w, pos); + if (te != null) { + final ArrayList drops = new ArrayList<>(); + if (te.dropItems()) { + te.getDrops(w, pos, drops); + } else { + te.getNoDrops(w, pos, drops); + } - // Cry ;_; ... - Platform.spawnDrops( w, pos, drops ); - } + // Cry ;_; ... + Platform.spawnDrops(w, pos, drops); + } - // super will remove the TE, as it is not an instance of BlockContainer - super.onReplaced( state, w, pos, newState, isMoving ); - } + // super will remove the TE, as it is not an instance of BlockContainer + super.onReplaced(state, w, pos, newState, isMoving); + } - @Override - public boolean recolorBlock( BlockState state, final IWorld world, final BlockPos pos, final Direction side, final DyeColor color ) - { - final TileEntity te = this.getTileEntity( world, pos ); + @Override + public boolean recolorBlock(BlockState state, final IWorld world, final BlockPos pos, final Direction side, + final DyeColor color) { + final TileEntity te = this.getTileEntity(world, pos); - if( te instanceof IColorableTile ) - { - final IColorableTile ct = (IColorableTile) te; - final AEColor c = ct.getColor(); - final AEColor newColor = AEColor.values()[color.ordinal()]; + if (te instanceof IColorableTile) { + final IColorableTile ct = (IColorableTile) te; + final AEColor c = ct.getColor(); + final AEColor newColor = AEColor.values()[color.ordinal()]; - if( c != newColor ) - { - ct.recolourBlock( side, newColor, null ); - return true; - } - return false; - } + if (c != newColor) { + ct.recolourBlock(side, newColor, null); + return true; + } + return false; + } - return super.recolorBlock( state, world, pos, side, color ); - } + return super.recolorBlock(state, world, pos, side, color); + } - @Override - public int getComparatorInputOverride( BlockState state, final World w, final BlockPos pos ) - { - final TileEntity te = this.getTileEntity( w, pos ); - if( te instanceof AEBaseInvTile ) - { - AEBaseInvTile invTile = (AEBaseInvTile) te; - if( invTile.getInternalInventory().getSlots() > 0 ) - { - return ItemHandlerHelper.calcRedstoneFromInventory( invTile.getInternalInventory() ); - } - } - return 0; - } + @Override + public int getComparatorInputOverride(BlockState state, final World w, final BlockPos pos) { + final TileEntity te = this.getTileEntity(w, pos); + if (te instanceof AEBaseInvTile) { + AEBaseInvTile invTile = (AEBaseInvTile) te; + if (invTile.getInternalInventory().getSlots() > 0) { + return ItemHandlerHelper.calcRedstoneFromInventory(invTile.getInternalInventory()); + } + } + return 0; + } - @Override - public boolean eventReceived( final BlockState state, final World worldIn, final BlockPos pos, final int eventID, final int eventParam ) - { - super.eventReceived( state, worldIn, pos, eventID, eventParam ); - final TileEntity tileentity = worldIn.getTileEntity( pos ); - return tileentity != null ? tileentity.receiveClientEvent( eventID, eventParam ) : false; - } + @Override + public boolean eventReceived(final BlockState state, final World worldIn, final BlockPos pos, final int eventID, + final int eventParam) { + super.eventReceived(state, worldIn, pos, eventID, eventParam); + final TileEntity tileentity = worldIn.getTileEntity(pos); + return tileentity != null ? tileentity.receiveClientEvent(eventID, eventParam) : false; + } - @Override - public void onBlockPlacedBy( final World w, final BlockPos pos, final BlockState state, final LivingEntity placer, final ItemStack is ) - { - if( is.hasDisplayName() ) - { - final TileEntity te = this.getTileEntity( w, pos ); - if( te instanceof AEBaseTile ) - { - // FIXME: Check if this will make it translated - ( (AEBaseTile) w.getTileEntity( pos ) ).setName( is.getDisplayName().getString() ); - } - } - } + @Override + public void onBlockPlacedBy(final World w, final BlockPos pos, final BlockState state, final LivingEntity placer, + final ItemStack is) { + if (is.hasDisplayName()) { + final TileEntity te = this.getTileEntity(w, pos); + if (te instanceof AEBaseTile) { + // FIXME: Check if this will make it translated + ((AEBaseTile) w.getTileEntity(pos)).setName(is.getDisplayName().getString()); + } + } + } - @Override - public ActionResultType onBlockActivated( BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit ) - { - ItemStack heldItem; - if( player != null && !player.getHeldItem( hand ).isEmpty() ) - { - heldItem = player.getHeldItem( hand ); + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, + Hand hand, BlockRayTraceResult hit) { + ItemStack heldItem; + if (player != null && !player.getHeldItem(hand).isEmpty()) { + heldItem = player.getHeldItem(hand); - if( Platform.isWrench( player, heldItem, pos ) && player.isCrouching() ) - { - final BlockState blockState = world.getBlockState( pos ); - final Block block = blockState.getBlock(); + if (Platform.isWrench(player, heldItem, pos) && player.isCrouching()) { + final BlockState blockState = world.getBlockState(pos); + final Block block = blockState.getBlock(); - final AEBaseTile tile = this.getTileEntity( world, pos ); + final AEBaseTile tile = this.getTileEntity(world, pos); - if( tile == null ) - { - return ActionResultType.FAIL; - } + if (tile == null) { + return ActionResultType.FAIL; + } - if( tile instanceof TileCableBus || tile instanceof TileSkyChest) - { - return ActionResultType.FAIL; - } + if (tile instanceof TileCableBus || tile instanceof TileSkyChest) { + return ActionResultType.FAIL; + } - final ItemStack[] itemDropCandidates = Platform.getBlockDrops( world, pos ); - final ItemStack op = new ItemStack( this ); + final ItemStack[] itemDropCandidates = Platform.getBlockDrops(world, pos); + final ItemStack op = new ItemStack(this); - for( final ItemStack ol : itemDropCandidates ) - { - if( Platform.itemComparisons().isEqualItemType( ol, op ) ) - { - final CompoundNBT tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM ); - if( tag != null ) - { - ol.setTag( tag ); - } - } - } + for (final ItemStack ol : itemDropCandidates) { + if (Platform.itemComparisons().isEqualItemType(ol, op)) { + final CompoundNBT tag = tile.downloadSettings(SettingsFrom.DISMANTLE_ITEM); + if (tag != null) { + ol.setTag(tag); + } + } + } - if( block.removedByPlayer( blockState, world, pos, player, false, world.getFluidState(pos) ) ) - { - final List itemsToDrop = Lists.newArrayList( itemDropCandidates ); - Platform.spawnDrops( world, pos, itemsToDrop ); - world.removeBlock(pos, false); - } + if (block.removedByPlayer(blockState, world, pos, player, false, world.getFluidState(pos))) { + final List itemsToDrop = Lists.newArrayList(itemDropCandidates); + Platform.spawnDrops(world, pos, itemsToDrop); + world.removeBlock(pos, false); + } - return ActionResultType.FAIL; - } + return ActionResultType.FAIL; + } - if( heldItem.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus) ) - { - final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem(); - final AEBaseTile tileEntity = this.getTileEntity( world, pos ); + if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof BlockCableBus)) { + final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem(); + final AEBaseTile tileEntity = this.getTileEntity(world, pos); - if( tileEntity == null ) - { - return ActionResultType.FAIL; - } + if (tileEntity == null) { + return ActionResultType.FAIL; + } - final String name = this.getTranslationKey(); + final String name = this.getTranslationKey(); - if( player.isCrouching() ) - { - final CompoundNBT data = tileEntity.downloadSettings( SettingsFrom.MEMORY_CARD ); - if( data != null ) - { - memoryCard.setMemoryCardContents( heldItem, name, data ); - memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); - } - } - else - { - final String savedName = memoryCard.getSettingsName( heldItem ); - final CompoundNBT data = memoryCard.getData( heldItem ); + if (player.isCrouching()) { + final CompoundNBT data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD); + if (data != null) { + memoryCard.setMemoryCardContents(heldItem, name, data); + memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED); + } + } else { + final String savedName = memoryCard.getSettingsName(heldItem); + final CompoundNBT data = memoryCard.getData(heldItem); - if( this.getTranslationKey().equals( savedName ) ) - { - tileEntity.uploadSettings( SettingsFrom.MEMORY_CARD, data ); - memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); - } - else - { - memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE ); - } - } + if (this.getTranslationKey().equals(savedName)) { + tileEntity.uploadSettings(SettingsFrom.MEMORY_CARD, data); + memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED); + } else { + memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE); + } + } - return ActionResultType.SUCCESS; - } - } + return ActionResultType.SUCCESS; + } + } - return this.onActivated( world, pos, player, hand, player.getHeldItem( hand ), hit ); - } + return this.onActivated(world, pos, player, hand, player.getHeldItem(hand), hit); + } - @Override - public IOrientable getOrientable(final IBlockReader w, final BlockPos pos ) - { - return this.getTileEntity( w, pos ); - } + @Override + public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) { + return this.getTileEntity(w, pos); + } - /** - * Returns the BlockState based on the given BlockState while considering the state of the given TileEntity. - * - * If the given TileEntity is not of the right type for this block, the state is returned unchanged, - * this is also the case if the given block state does not belong to this block. - */ - public final BlockState getTileEntityBlockState(BlockState current, TileEntity te) { - if (current.getBlock() != this || !tileEntityClass.isInstance(te)) { - return current; - } + /** + * Returns the BlockState based on the given BlockState while considering the + * state of the given TileEntity. + * + * If the given TileEntity is not of the right type for this block, the state is + * returned unchanged, this is also the case if the given block state does not + * belong to this block. + */ + public final BlockState getTileEntityBlockState(BlockState current, TileEntity te) { + if (current.getBlock() != this || !tileEntityClass.isInstance(te)) { + return current; + } - return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te)); - } + return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te)); + } - /** - * Reimplement this in subclasses to allow tile-entities to update the state of their block when their own - * state changes. - * - * It is guaranteed that te is not-null and the block of the given block state is this exact block instance. - */ - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, T te) { - return currentState; - } + /** + * Reimplement this in subclasses to allow tile-entities to update the state of + * their block when their own state changes. + * + * It is guaranteed that te is not-null and the block of the given block state + * is this exact block instance. + */ + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, T te) { + return currentState; + } } diff --git a/src/main/java/appeng/block/crafting/AbstractCraftingUnitBlock.java b/src/main/java/appeng/block/crafting/AbstractCraftingUnitBlock.java index 288b78f4d..18ae062b9 100644 --- a/src/main/java/appeng/block/crafting/AbstractCraftingUnitBlock.java +++ b/src/main/java/appeng/block/crafting/AbstractCraftingUnitBlock.java @@ -18,13 +18,10 @@ package appeng.block.crafting; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerCraftingCPU; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; @@ -33,75 +30,71 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerCraftingCPU; import appeng.tile.crafting.TileCraftingTile; +public abstract class AbstractCraftingUnitBlock extends AEBaseTileBlock { + public static final BooleanProperty FORMED = BooleanProperty.create("formed"); + public static final BooleanProperty POWERED = BooleanProperty.create("powered"); -public abstract class AbstractCraftingUnitBlock extends AEBaseTileBlock -{ - public static final BooleanProperty FORMED = BooleanProperty.create( "formed" ); - public static final BooleanProperty POWERED = BooleanProperty.create( "powered" ); + public final CraftingUnitType type; - public final CraftingUnitType type; + public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type) { + super(props); + this.type = type; + this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false)); + } - public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type ) - { - super( props ); - this.type = type; - this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false)); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(POWERED); + builder.add(FORMED); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(POWERED); - builder.add(FORMED); - } + @Override + public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn, + final BlockPos fromPos, boolean isMoving) { + final TileCraftingTile cp = this.getTileEntity(worldIn, pos); + if (cp != null) { + cp.updateMultiBlock(); + } + } - @Override - public void neighborChanged( final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos, boolean isMoving ) - { - final TileCraftingTile cp = this.getTileEntity( worldIn, pos ); - if( cp != null ) - { - cp.updateMultiBlock(); - } - } + @Override + public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() == state.getBlock()) { + return; // Just a block state change + } - @Override - public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) - { - if (newState.getBlock() == state.getBlock()) { - return; // Just a block state change - } + final TileCraftingTile cp = this.getTileEntity(w, pos); + if (cp != null) { + cp.breakCluster(); + } - final TileCraftingTile cp = this.getTileEntity( w, pos ); - if( cp != null ) - { - cp.breakCluster(); - } + super.onReplaced(state, w, pos, newState, isMoving); + } - super.onReplaced( state, w, pos, newState, isMoving ); - } + @Override + public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, + BlockRayTraceResult hit) { + final TileCraftingTile tg = this.getTileEntity(w, pos); - @Override - public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) { - final TileCraftingTile tg = this.getTileEntity( w, pos ); + if (tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive()) { + if (!w.isRemote()) { + ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } - if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() ) - { - if ( !w.isRemote() ) - { - ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } + return super.onBlockActivated(state, w, pos, p, hand, hit); + } - return super.onBlockActivated(state, w, pos, p, hand, hit); - } - - public enum CraftingUnitType - { - UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR - } + public enum CraftingUnitType { + UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR + } } diff --git a/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java b/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java index 08db21c82..f51295bc4 100644 --- a/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java +++ b/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java @@ -18,13 +18,10 @@ package appeng.block.crafting; - import appeng.tile.crafting.TileCraftingMonitorTile; -public class BlockCraftingMonitor extends AbstractCraftingUnitBlock -{ - public BlockCraftingMonitor(Properties props) - { - super( props, CraftingUnitType.MONITOR ); - } +public class BlockCraftingMonitor extends AbstractCraftingUnitBlock { + public BlockCraftingMonitor(Properties props) { + super(props, CraftingUnitType.MONITOR); + } } diff --git a/src/main/java/appeng/block/crafting/BlockCraftingStorage.java b/src/main/java/appeng/block/crafting/BlockCraftingStorage.java index b6ca1d729..7d185d1a7 100644 --- a/src/main/java/appeng/block/crafting/BlockCraftingStorage.java +++ b/src/main/java/appeng/block/crafting/BlockCraftingStorage.java @@ -18,14 +18,12 @@ package appeng.block.crafting; - import appeng.tile.crafting.TileCraftingStorageTile; -public class BlockCraftingStorage extends AbstractCraftingUnitBlock -{ +public class BlockCraftingStorage extends AbstractCraftingUnitBlock { - public BlockCraftingStorage(Properties props, CraftingUnitType type) { - super(props, type); - } + public BlockCraftingStorage(Properties props, CraftingUnitType type) { + super(props, type); + } } diff --git a/src/main/java/appeng/block/crafting/BlockMolecularAssembler.java b/src/main/java/appeng/block/crafting/BlockMolecularAssembler.java index 960bd2065..a2c7a6aa0 100644 --- a/src/main/java/appeng/block/crafting/BlockMolecularAssembler.java +++ b/src/main/java/appeng/block/crafting/BlockMolecularAssembler.java @@ -18,13 +18,6 @@ package appeng.block.crafting; - -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerInscriber; -import appeng.container.implementations.ContainerMAC; -import appeng.tile.crafting.TileMolecularAssembler; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -36,41 +29,46 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerInscriber; +import appeng.container.implementations.ContainerMAC; +import appeng.tile.crafting.TileMolecularAssembler; -public class BlockMolecularAssembler extends AEBaseTileBlock -{ +public class BlockMolecularAssembler extends AEBaseTileBlock { - public static final BooleanProperty POWERED = BooleanProperty.create( "powered" ); + public static final BooleanProperty POWERED = BooleanProperty.create("powered"); - public BlockMolecularAssembler(Block.Properties props) - { - super( props ); - setDefaultState(getDefaultState().with(POWERED, false)); - } + public BlockMolecularAssembler(Block.Properties props) { + super(props); + setDefaultState(getDefaultState().with(POWERED, false)); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(POWERED); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(POWERED); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileMolecularAssembler te) { - return currentState.with(POWERED, te.isPowered()); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileMolecularAssembler te) { + return currentState.with(POWERED, te.isPowered()); + } - @Override - public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) { - final TileMolecularAssembler tg = this.getTileEntity( w, pos ); - if( tg != null && !p.isCrouching() ) - { - if (!tg.isRemote()) { - ContainerOpener.openContainer(ContainerMAC.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } + @Override + public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, + BlockRayTraceResult hit) { + final TileMolecularAssembler tg = this.getTileEntity(w, pos); + if (tg != null && !p.isCrouching()) { + if (!tg.isRemote()) { + ContainerOpener.openContainer(ContainerMAC.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } - return super.onBlockActivated(state, w, pos, p, hand, hit); - } + return super.onBlockActivated(state, w, pos, p, hand, hit); + } } diff --git a/src/main/java/appeng/block/crafting/CraftingUnitBlock.java b/src/main/java/appeng/block/crafting/CraftingUnitBlock.java index 258f1b3de..cf61258a7 100644 --- a/src/main/java/appeng/block/crafting/CraftingUnitBlock.java +++ b/src/main/java/appeng/block/crafting/CraftingUnitBlock.java @@ -18,15 +18,12 @@ package appeng.block.crafting; - import appeng.tile.crafting.TileCraftingTile; +public class CraftingUnitBlock extends AbstractCraftingUnitBlock { -public class CraftingUnitBlock extends AbstractCraftingUnitBlock -{ - - public CraftingUnitBlock(Properties props, CraftingUnitType type) { - super(props, type); - } + public CraftingUnitBlock(Properties props, CraftingUnitType type) { + super(props, type); + } } diff --git a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java index c8b6cd575..4770530e1 100644 --- a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java +++ b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java @@ -18,32 +18,27 @@ package appeng.block.crafting; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import appeng.block.AEBaseBlockItem; -import appeng.core.AEConfig; import appeng.api.AEApi; import appeng.api.features.AEFeature; +import appeng.block.AEBaseBlockItem; +import appeng.core.AEConfig; +public class ItemCraftingStorage extends AEBaseBlockItem { -public class ItemCraftingStorage extends AEBaseBlockItem -{ + public ItemCraftingStorage(Block id, Properties props) { + super(id, props); + } - public ItemCraftingStorage(Block id, Properties props) { - super(id, props); - } + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ItemStack getContainerItem( final ItemStack itemStack ) - { - return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public boolean hasContainerItem( final ItemStack stack ) - { - return AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ); - } + @Override + public boolean hasContainerItem(final ItemStack stack) { + return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING); + } } diff --git a/src/main/java/appeng/block/grindstone/BlockCrank.java b/src/main/java/appeng/block/grindstone/BlockCrank.java index afaf4af87..89d2f795b 100644 --- a/src/main/java/appeng/block/grindstone/BlockCrank.java +++ b/src/main/java/appeng/block/grindstone/BlockCrank.java @@ -18,12 +18,8 @@ package appeng.block.grindstone; +import javax.annotation.Nullable; -import appeng.api.implementations.tiles.ICrankable; -import appeng.block.AEBaseTileBlock; -import appeng.core.stats.AeStats; -import appeng.tile.AEBaseTile; -import appeng.tile.grindstone.TileCrank; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -47,137 +43,122 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; -import javax.annotation.Nullable; +import appeng.api.implementations.tiles.ICrankable; +import appeng.block.AEBaseTileBlock; +import appeng.core.stats.AeStats; +import appeng.tile.AEBaseTile; +import appeng.tile.grindstone.TileCrank; +public class BlockCrank extends AEBaseTileBlock { -public class BlockCrank extends AEBaseTileBlock -{ + public BlockCrank(Properties props) { + super(props); + } - public BlockCrank(Properties props) { - super(props); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (player instanceof FakePlayer || player == null) { + this.dropCrank(w, pos); + return ActionResultType.SUCCESS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( player instanceof FakePlayer || player == null ) - { - this.dropCrank( w, pos ); - return ActionResultType.SUCCESS; - } + final TileCrank tile = this.getTileEntity(w, pos); + if (tile != null) { + if (tile.power()) { + AeStats.TurnedCranks.addToPlayer(player, 1); + } + return ActionResultType.SUCCESS; + } - final TileCrank tile = this.getTileEntity( w, pos ); - if( tile != null ) - { - if( tile.power() ) - { - AeStats.TurnedCranks.addToPlayer( player, 1 ); - } - return ActionResultType.SUCCESS; - } + return ActionResultType.PASS; + } - return ActionResultType.PASS; - } + private void dropCrank(final World world, final BlockPos pos) { + world.destroyBlock(pos, true); + world.notifyBlockUpdate(pos, this.getDefaultState(), world.getBlockState(pos), 3); + } - private void dropCrank( final World world, final BlockPos pos ) - { - world.destroyBlock( pos, true ); - world.notifyBlockUpdate( pos, this.getDefaultState(), world.getBlockState( pos ), 3 ); - } + @Override + public void onBlockPlacedBy(final World world, final BlockPos pos, final BlockState state, + final LivingEntity placer, final ItemStack stack) { + final AEBaseTile tile = this.getTileEntity(world, pos); + if (tile != null) { + final Direction mnt = this.findCrankable(world, pos); + Direction forward = Direction.UP; + if (mnt == Direction.UP || mnt == Direction.DOWN) { + forward = Direction.SOUTH; + } + tile.setOrientation(forward, mnt.getOpposite()); + } else { + this.dropCrank(world, pos); + } + } - @Override - public void onBlockPlacedBy( final World world, final BlockPos pos, final BlockState state, final LivingEntity placer, final ItemStack stack ) - { - final AEBaseTile tile = this.getTileEntity( world, pos ); - if( tile != null ) - { - final Direction mnt = this.findCrankable( world, pos ); - Direction forward = Direction.UP; - if( mnt == Direction.UP || mnt == Direction.DOWN ) - { - forward = Direction.SOUTH; - } - tile.setOrientation( forward, mnt.getOpposite() ); - } - else - { - this.dropCrank( world, pos ); - } - } + @Override + public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) { + final TileEntity te = w.getTileEntity(pos); + return !(te instanceof TileCrank) || this.isCrankable(w, pos, up.getOpposite()); + } - @Override - public boolean isValidOrientation( final IWorld w, final BlockPos pos, final Direction forward, final Direction up ) - { - final TileEntity te = w.getTileEntity( pos ); - return !( te instanceof TileCrank ) || this.isCrankable( w, pos, up.getOpposite() ); - } + private Direction findCrankable(final IBlockReader world, final BlockPos pos) { + for (final Direction dir : Direction.values()) { + if (this.isCrankable(world, pos, dir)) { + return dir; + } + } + return null; + } - private Direction findCrankable( final IBlockReader world, final BlockPos pos ) - { - for( final Direction dir : Direction.values() ) - { - if( this.isCrankable( world, pos, dir ) ) - { - return dir; - } - } - return null; - } + private boolean isCrankable(final IBlockReader world, final BlockPos pos, final Direction offset) { + final BlockPos o = pos.offset(offset); + final TileEntity te = world.getTileEntity(o); - private boolean isCrankable( final IBlockReader world, final BlockPos pos, final Direction offset ) - { - final BlockPos o = pos.offset( offset ); - final TileEntity te = world.getTileEntity( o ); + return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite()); + } - return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() ); - } + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.ENTITYBLOCK_ANIMATED; + } - @Override - public BlockRenderType getRenderType(BlockState state ) - { - return BlockRenderType.ENTITYBLOCK_ANIMATED; - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final AEBaseTile tile = this.getTileEntity(world, pos); + if (tile != null) { + if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) { + this.dropCrank(world, pos); + } + } else { + this.dropCrank(world, pos); + } + } - @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - final AEBaseTile tile = this.getTileEntity( world, pos ); - if( tile != null ) - { - if( !this.isCrankable( world, pos, tile.getUp().getOpposite() ) ) - { - this.dropCrank( world, pos ); - } - } - else - { - this.dropCrank( world, pos ); - } - } + @Override + public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) { + return this.findCrankable(w, pos) != null; + } - @Override - public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) - { - return this.findCrankable( w, pos ) != null; - } + private Direction getUp(IBlockReader world, BlockPos pos) { + TileCrank crank = getTileEntity(world, pos); + return crank != null ? crank.getUp() : null; + } - private Direction getUp(IBlockReader world, BlockPos pos) { - TileCrank crank = getTileEntity(world, pos); - return crank != null ? crank.getUp() : null; - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { + Direction up = getUp(world, pos); - @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { - Direction up = getUp(world, pos); + if (up == null) { + return VoxelShapes.empty(); + } else { + // FIXME: Cache per direction, and build it 'precise', not just from AABB + final double xOff = -0.15 * up.getXOffset(); + final double yOff = -0.15 * up.getYOffset(); + final double zOff = -0.15 * up.getZOffset(); + return VoxelShapes.create( + new AxisAlignedBB(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85)); + } - if (up == null) { - return VoxelShapes.empty(); - } else { - // FIXME: Cache per direction, and build it 'precise', not just from AABB - final double xOff = -0.15 * up.getXOffset(); - final double yOff = -0.15 * up.getYOffset(); - final double zOff = -0.15 * up.getZOffset(); - return VoxelShapes.create(new AxisAlignedBB(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85)); - } - - } + } } diff --git a/src/main/java/appeng/block/grindstone/BlockGrinder.java b/src/main/java/appeng/block/grindstone/BlockGrinder.java index da89a9314..ccc1de7f6 100644 --- a/src/main/java/appeng/block/grindstone/BlockGrinder.java +++ b/src/main/java/appeng/block/grindstone/BlockGrinder.java @@ -18,12 +18,8 @@ package appeng.block.grindstone; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerGrinder; -import appeng.tile.grindstone.TileGrinder; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; @@ -33,27 +29,29 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerGrinder; +import appeng.tile.grindstone.TileGrinder; +public class BlockGrinder extends AEBaseTileBlock { -public class BlockGrinder extends AEBaseTileBlock -{ + public BlockGrinder(Properties props) { + super(props); + } - public BlockGrinder(Properties props) { - super(props); - } - - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - final TileGrinder tg = this.getTileEntity( w, pos ); - if( tg != null && !p.isCrouching() ) - { - if (p instanceof ServerPlayerEntity) { - ContainerOpener.openContainer(ContainerGrinder.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + final TileGrinder tg = this.getTileEntity(w, pos); + if (tg != null && !p.isCrouching()) { + if (p instanceof ServerPlayerEntity) { + ContainerOpener.openContainer(ContainerGrinder.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/misc/BlockCellWorkbench.java b/src/main/java/appeng/block/misc/BlockCellWorkbench.java index 53c703e7d..bcb00a47c 100644 --- a/src/main/java/appeng/block/misc/BlockCellWorkbench.java +++ b/src/main/java/appeng/block/misc/BlockCellWorkbench.java @@ -18,11 +18,8 @@ package appeng.block.misc; - import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerCellWorkbench; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -33,36 +30,31 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; - +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerCellWorkbench; import appeng.tile.misc.TileCellWorkbench; import appeng.util.Platform; +public class BlockCellWorkbench extends AEBaseTileBlock { -public class BlockCellWorkbench extends AEBaseTileBlock -{ + public BlockCellWorkbench() { + super(defaultProps(Material.IRON)); + } - public BlockCellWorkbench() - { - super( defaultProps(Material.IRON) ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } - - final TileCellWorkbench tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerCellWorkbench.open(p, ContainerLocator.forTileEntity(tg)); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + final TileCellWorkbench tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerCellWorkbench.open(p, ContainerLocator.forTileEntity(tg)); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/misc/BlockCharger.java b/src/main/java/appeng/block/misc/BlockCharger.java index 247c3e116..d786ff447 100644 --- a/src/main/java/appeng/block/misc/BlockCharger.java +++ b/src/main/java/appeng/block/misc/BlockCharger.java @@ -18,18 +18,14 @@ package appeng.block.misc; +import java.util.Random; +import java.util.function.Function; + +import javax.annotation.Nullable; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; -import appeng.api.AEApi; -import appeng.api.util.AEAxisAlignedBB; -import appeng.block.AEBaseTileBlock; -import appeng.client.render.effects.ChargedOreFX; -import appeng.client.render.effects.LightningFX; -import appeng.client.render.renderable.ItemRenderable; -import appeng.client.render.tesr.ModularTESR; -import appeng.core.AEConfig; -import appeng.core.AppEng; -import appeng.tile.misc.TileCharger; -import appeng.util.Platform; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -52,156 +48,145 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import javax.annotation.Nullable; -import java.util.Random; -import java.util.function.Function; +import appeng.api.AEApi; +import appeng.api.util.AEAxisAlignedBB; +import appeng.block.AEBaseTileBlock; +import appeng.client.render.effects.ChargedOreFX; +import appeng.client.render.effects.LightningFX; +import appeng.client.render.renderable.ItemRenderable; +import appeng.client.render.tesr.ModularTESR; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import appeng.tile.misc.TileCharger; +import appeng.util.Platform; +public class BlockCharger extends AEBaseTileBlock { -public class BlockCharger extends AEBaseTileBlock -{ + public BlockCharger() { + super(defaultProps(Material.IRON).notSolid()); - public BlockCharger() - { - super( defaultProps(Material.IRON).notSolid() ); + this.setFullSize(this.setOpaque(false)); + } - this.setFullSize( this.setOpaque( false ) ); - } + @Override + public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { + return 2; // FIXME Double check this (esp. value range) + } - @Override - public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { - return 2; // FIXME Double check this (esp. value range) - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (player.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( player.isCrouching() ) - { - return ActionResultType.PASS; - } + if (Platform.isServer()) { + final TileCharger tc = this.getTileEntity(w, pos); + if (tc != null) { + tc.activate(player); + } + } - if( Platform.isServer() ) - { - final TileCharger tc = this.getTileEntity( w, pos ); - if( tc != null ) - { - tc.activate( player ); - } - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + if (r.nextFloat() < 0.98) { + return; + } - if( r.nextFloat() < 0.98 ) - { - return; - } + final TileCharger tile = this.getTileEntity(w, pos); + if (tile != null) { + if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged() + .isSameAs(tile.getInternalInventory().getStackInSlot(0))) { + final double xOff = 0.0; + final double yOff = 0.0; + final double zOff = 0.0; - final TileCharger tile = this.getTileEntity( w, pos ); - if(tile != null) - { - if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tile.getInternalInventory().getStackInSlot( 0 ) ) ) - { - final double xOff = 0.0; - final double yOff = 0.0; - final double zOff = 0.0; + for (int bolts = 0; bolts < 3; bolts++) { + if (AppEng.proxy.shouldAddParticles(r)) { + Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), + yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0, 0.0, 0.0); + } + } + } + } + } - for( int bolts = 0; bolts < 3; bolts++ ) - { - if( AppEng.proxy.shouldAddParticles( r ) ) - { - Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos - .getZ(), 0.0, 0.0, 0.0); - } - } - } - } - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - @Override - public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + final TileCharger tile = this.getTileEntity(w, pos); + if (tile != null) { + final double twoPixels = 2.0 / 16.0; + final Direction up = tile.getUp(); + final Direction forward = tile.getForward(); + final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, + 1.0 - twoPixels, 1.0 - twoPixels); - final TileCharger tile = this.getTileEntity( w, pos ); - if( tile != null ) - { - final double twoPixels = 2.0 / 16.0; - final Direction up = tile.getUp(); - final Direction forward = tile.getForward(); - final AEAxisAlignedBB bb = new AEAxisAlignedBB( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels ); + if (up.getXOffset() != 0) { + bb.minX = 0; + bb.maxX = 1; + } + if (up.getYOffset() != 0) { + bb.minY = 0; + bb.maxY = 1; + } + if (up.getZOffset() != 0) { + bb.minZ = 0; + bb.maxZ = 1; + } - if( up.getXOffset() != 0 ) - { - bb.minX = 0; - bb.maxX = 1; - } - if( up.getYOffset() != 0 ) - { - bb.minY = 0; - bb.maxY = 1; - } - if( up.getZOffset() != 0 ) - { - bb.minZ = 0; - bb.maxZ = 1; - } + switch (forward) { + case DOWN: + bb.maxY = 1; + break; + case UP: + bb.minY = 0; + break; + case NORTH: + bb.maxZ = 1; + break; + case SOUTH: + bb.minZ = 0; + break; + case EAST: + bb.minX = 0; + break; + case WEST: + bb.maxX = 1; + break; + default: + break; + } - switch( forward ) - { - case DOWN: - bb.maxY = 1; - break; - case UP: - bb.minY = 0; - break; - case NORTH: - bb.maxZ = 1; - break; - case SOUTH: - bb.minZ = 0; - break; - case EAST: - bb.minX = 0; - break; - case WEST: - bb.maxX = 1; - break; - default: - break; - } + return VoxelShapes.create(bb.getBoundingBox()); + } + return VoxelShapes.create(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0)); + } - return VoxelShapes.create(bb.getBoundingBox()); - } - return VoxelShapes.create( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) ); - } + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, + ISelectionContext context) { + return VoxelShapes.create(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)); + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.create( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) ); - } + @OnlyIn(Dist.CLIENT) + public static Function> createTesr() { + return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(BlockCharger::getRenderedItem)); + } - @OnlyIn( Dist.CLIENT ) - public static Function> createTesr() - { - return dispatcher -> new ModularTESR<>( dispatcher, new ItemRenderable<>( BlockCharger::getRenderedItem ) ); - } - - @OnlyIn( Dist.CLIENT ) - private static Pair getRenderedItem(TileCharger tile ) - { - TransformationMatrix transform = new TransformationMatrix(new Vector3f( 0.5f, 0.375f, 0.5f ), null, null, null); - return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform ); - } + @OnlyIn(Dist.CLIENT) + private static Pair getRenderedItem(TileCharger tile) { + TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null); + return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform); + } } diff --git a/src/main/java/appeng/block/misc/BlockCondenser.java b/src/main/java/appeng/block/misc/BlockCondenser.java index 68ef53771..c10535468 100644 --- a/src/main/java/appeng/block/misc/BlockCondenser.java +++ b/src/main/java/appeng/block/misc/BlockCondenser.java @@ -18,13 +18,8 @@ package appeng.block.misc; - import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerCondenser; -import appeng.container.implementations.ContainerDrive; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -36,37 +31,35 @@ import net.minecraft.world.World; import appeng.api.util.AEPartLocation; import appeng.block.AEBaseTileBlock; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerCondenser; +import appeng.container.implementations.ContainerDrive; import appeng.tile.misc.TileCondenser; import appeng.util.Platform; +public class BlockCondenser extends AEBaseTileBlock { -public class BlockCondenser extends AEBaseTileBlock -{ + public BlockCondenser() { + super(defaultProps(Material.IRON)); + } - public BlockCondenser() - { - super( defaultProps(Material.IRON) ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (player.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( player.isCrouching() ) - { - return ActionResultType.PASS; - } + if (Platform.isServer()) { + final TileCondenser tc = this.getTileEntity(w, pos); + if (tc != null && !player.isCrouching()) { + ContainerOpener.openContainer(ContainerCondenser.TYPE, player, + ContainerLocator.forTileEntitySide(tc, hit.getFace())); + return ActionResultType.SUCCESS; + } + } - if( Platform.isServer() ) - { - final TileCondenser tc = this.getTileEntity( w, pos ); - if( tc != null && !player.isCrouching() ) - { - ContainerOpener.openContainer(ContainerCondenser.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace())); - return ActionResultType.SUCCESS; - } - } - - return ActionResultType.SUCCESS; - } + return ActionResultType.SUCCESS; + } } diff --git a/src/main/java/appeng/block/misc/BlockInscriber.java b/src/main/java/appeng/block/misc/BlockInscriber.java index df8106480..777c50322 100644 --- a/src/main/java/appeng/block/misc/BlockInscriber.java +++ b/src/main/java/appeng/block/misc/BlockInscriber.java @@ -18,14 +18,8 @@ package appeng.block.misc; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerInscriber; -import appeng.container.implementations.ContainerInterface; -import appeng.fluids.container.ContainerFluidLevelEmitter; -import appeng.tile.misc.TileInscriber; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -36,7 +30,13 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerInscriber; +import appeng.container.implementations.ContainerInterface; +import appeng.fluids.container.ContainerFluidLevelEmitter; +import appeng.tile.misc.TileInscriber; public class BlockInscriber extends AEBaseTileBlock { @@ -46,17 +46,20 @@ public class BlockInscriber extends AEBaseTileBlock { @Override public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { - return 2; // FIXME validate this. a) possibly not required because of getShape b) value range. was 2 in 1.10 + return 2; // FIXME validate this. a) possibly not required because of getShape b) value + // range. was 2 in 1.10 } @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { if (!p.isCrouching()) { final TileInscriber tg = this.getTileEntity(w, pos); if (tg != null) { - if (!tg.isRemote()) { - ContainerOpener.openContainer(ContainerInscriber.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } + if (!tg.isRemote()) { + ContainerOpener.openContainer(ContainerInscriber.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } return ActionResultType.SUCCESS; } } diff --git a/src/main/java/appeng/block/misc/BlockInterface.java b/src/main/java/appeng/block/misc/BlockInterface.java index 5ef98f641..6400af9d1 100644 --- a/src/main/java/appeng/block/misc/BlockInterface.java +++ b/src/main/java/appeng/block/misc/BlockInterface.java @@ -18,15 +18,8 @@ package appeng.block.misc; +import javax.annotation.Nullable; -import appeng.api.util.IOrientable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerDrive; -import appeng.container.implementations.ContainerInterface; -import appeng.tile.misc.TileInterface; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -42,62 +35,61 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IWorld; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.api.util.IOrientable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerDrive; +import appeng.container.implementations.ContainerInterface; +import appeng.tile.misc.TileInterface; +import appeng.util.Platform; +public class BlockInterface extends AEBaseTileBlock { -public class BlockInterface extends AEBaseTileBlock -{ + private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional"); - private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create( "omnidirectional" ); + public BlockInterface() { + super(defaultProps(Material.IRON)); + } - public BlockInterface() - { - super( defaultProps(Material.IRON) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(OMNIDIRECTIONAL); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(OMNIDIRECTIONAL); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileInterface te) { + return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional()); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileInterface te) { - return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional()); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } + final TileInterface tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerInterface.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } - final TileInterface tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerInterface.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + @Override + protected boolean hasCustomRotation() { + return true; + } - @Override - protected boolean hasCustomRotation() - { - return true; - } - - @Override - protected void customRotateBlock( final IOrientable rotatable, final Direction axis ) - { - if( rotatable instanceof TileInterface ) - { - ( (TileInterface) rotatable ).setSide( axis ); - } - } + @Override + protected void customRotateBlock(final IOrientable rotatable, final Direction axis) { + if (rotatable instanceof TileInterface) { + ((TileInterface) rotatable).setSide(axis); + } + } } diff --git a/src/main/java/appeng/block/misc/BlockLightDetector.java b/src/main/java/appeng/block/misc/BlockLightDetector.java index bea9134c8..534c8fc62 100644 --- a/src/main/java/appeng/block/misc/BlockLightDetector.java +++ b/src/main/java/appeng/block/misc/BlockLightDetector.java @@ -18,12 +18,8 @@ package appeng.block.misc; +import java.util.Random; -import appeng.api.util.IOrientable; -import appeng.api.util.IOrientableBlock; -import appeng.block.AEBaseTileBlock; -import appeng.helpers.MetaRotation; -import appeng.tile.misc.TileLightDetector; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -41,122 +37,114 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; -import java.util.Random; +import appeng.api.util.IOrientable; +import appeng.api.util.IOrientableBlock; +import appeng.block.AEBaseTileBlock; +import appeng.helpers.MetaRotation; +import appeng.tile.misc.TileLightDetector; +public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock { -public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock -{ + // Used to alternate between two variants of the fixture on adjacent blocks + public static final BooleanProperty ODD = BooleanProperty.create("odd"); - // Used to alternate between two variants of the fixture on adjacent blocks - public static final BooleanProperty ODD = BooleanProperty.create( "odd" ); + public BlockLightDetector() { + super(defaultProps(Material.MISCELLANEOUS).notSolid()); - public BlockLightDetector() - { - super( defaultProps(Material.MISCELLANEOUS).notSolid() ); + this.setDefaultState(this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP).with(ODD, false)); + } - this.setDefaultState( this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP ).with( ODD, false ) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(BlockStateProperties.FACING); + builder.add(ODD); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(BlockStateProperties.FACING); - builder.add(ODD); - } + @Override + public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) { + if (w instanceof World && this.getTileEntity(w, pos).isReady()) { + // FIXME: This is ... uhm... fishy + return ((World) w).getLight(pos) - 6; + } - @Override - public int getWeakPower( final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side ) - { - if( w instanceof World && this.getTileEntity( w, pos ).isReady() ) - { - // FIXME: This is ... uhm... fishy - return ( (World) w ).getLight( pos ) - 6; - } + return 0; + } - return 0; - } + @Override + public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { + super.onNeighborChange(state, world, pos, neighbor); - @Override - public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { - super.onNeighborChange( state, world, pos, neighbor ); + final TileLightDetector tld = this.getTileEntity(world, pos); + if (tld != null) { + tld.updateLight(); + } + } - final TileLightDetector tld = this.getTileEntity( world, pos ); - if( tld != null ) - { - tld.updateLight(); - } - } + @Override + public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) { + // cancel out lightning + } - @Override - public void animateTick( final BlockState state, final World worldIn, final BlockPos pos, final Random rand ) - { - // cancel out lightning - } + @Override + public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) { + return this.canPlaceAt(w, pos, up.getOpposite()); + } - @Override - public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up ) - { - return this.canPlaceAt( w, pos, up.getOpposite() ); - } + private boolean canPlaceAt(final IBlockReader w, final BlockPos pos, final Direction dir) { + final BlockPos test = pos.offset(dir); + BlockState blockstate = w.getBlockState(test); + return blockstate.isSolidSide(w, test, dir.getOpposite()); + } - private boolean canPlaceAt( final IBlockReader w, final BlockPos pos, final Direction dir ) - { - final BlockPos test = pos.offset( dir ); - BlockState blockstate = w.getBlockState(test); - return blockstate.isSolidSide(w, test, dir.getOpposite()); - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - @Override - public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + // FIXME: We should / rather MUST use state here because at startup, this gets + // called without a world - // FIXME: We should / rather MUST use state here because at startup, this gets called without a world + final Direction up = this.getOrientable(w, pos).getUp(); + final double xOff = -0.3 * up.getXOffset(); + final double yOff = -0.3 * up.getYOffset(); + final double zOff = -0.3 * up.getZOffset(); + return VoxelShapes + .create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7)); + } - final Direction up = this.getOrientable( w, pos ).getUp(); - final double xOff = -0.3 * up.getXOffset(); - final double yOff = -0.3 * up.getYOffset(); - final double zOff = -0.3 * up.getZOffset(); - return VoxelShapes.create( new AxisAlignedBB( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) ); - } + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, + ISelectionContext context) { + return VoxelShapes.empty(); + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.empty(); - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final Direction up = this.getOrientable(world, pos).getUp(); + if (!this.canPlaceAt(world, pos, up.getOpposite())) { + this.dropTorch(world, pos); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final Direction up = this.getOrientable( world, pos ).getUp(); - if( !this.canPlaceAt( world, pos, up.getOpposite() ) ) - { - this.dropTorch( world, pos ); - } - } + private void dropTorch(final World w, final BlockPos pos) { + final BlockState prev = w.getBlockState(pos); + w.destroyBlock(pos, true); + w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); + } - private void dropTorch( final World w, final BlockPos pos ) - { - final BlockState prev = w.getBlockState( pos ); - w.destroyBlock( pos, true ); - w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); - } + @Override + public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) { + for (final Direction dir : Direction.values()) { + if (this.canPlaceAt(w, pos, dir)) { + return true; + } + } + return false; + } - @Override - public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) - { - for( final Direction dir : Direction.values() ) - { - if( this.canPlaceAt( w, pos, dir ) ) - { - return true; - } - } - return false; - } - - @Override - public IOrientable getOrientable( final IBlockReader w, final BlockPos pos ) - { - return new MetaRotation( w, pos, BlockStateProperties.FACING ); - } + @Override + public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) { + return new MetaRotation(w, pos, BlockStateProperties.FACING); + } } diff --git a/src/main/java/appeng/block/misc/BlockQuartzFixture.java b/src/main/java/appeng/block/misc/BlockQuartzFixture.java index b8eeda047..9bd124e59 100644 --- a/src/main/java/appeng/block/misc/BlockQuartzFixture.java +++ b/src/main/java/appeng/block/misc/BlockQuartzFixture.java @@ -18,14 +18,12 @@ package appeng.block.misc; +import java.util.EnumMap; +import java.util.Map; +import java.util.Random; + +import javax.annotation.Nullable; -import appeng.api.util.IOrientable; -import appeng.api.util.IOrientableBlock; -import appeng.block.AEBaseBlock; -import appeng.client.render.effects.LightningFX; -import appeng.core.AEConfig; -import appeng.core.AppEng; -import appeng.helpers.MetaRotation; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -49,170 +47,162 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.EnumMap; -import java.util.Map; -import java.util.Random; +import appeng.api.util.IOrientable; +import appeng.api.util.IOrientableBlock; +import appeng.block.AEBaseBlock; +import appeng.client.render.effects.LightningFX; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import appeng.helpers.MetaRotation; +public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock { -public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock -{ + // Cache VoxelShapes for each facing + private static final Map SHAPES; - // Cache VoxelShapes for each facing - private static final Map SHAPES; + static { + SHAPES = new EnumMap<>(Direction.class); - static { - SHAPES = new EnumMap<>(Direction.class); + for (Direction facing : Direction.values()) { + final double xOff = -0.3 * facing.getXOffset(); + final double yOff = -0.3 * facing.getYOffset(); + final double zOff = -0.3 * facing.getZOffset(); + VoxelShape shape = VoxelShapes + .create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7)); + SHAPES.put(facing, shape); + } + } - for (Direction facing : Direction.values()) { - final double xOff = -0.3 * facing.getXOffset(); - final double yOff = -0.3 * facing.getYOffset(); - final double zOff = -0.3 * facing.getZOffset(); - VoxelShape shape = VoxelShapes.create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7)); - SHAPES.put(facing, shape); - } - } + // Cannot use the vanilla FACING property here because it excludes facing DOWN + public static final DirectionProperty FACING = BlockStateProperties.FACING; - // Cannot use the vanilla FACING property here because it excludes facing DOWN - public static final DirectionProperty FACING = BlockStateProperties.FACING; + // Used to alternate between two variants of the fixture on adjacent blocks + public static final BooleanProperty ODD = BooleanProperty.create("odd"); - // Used to alternate between two variants of the fixture on adjacent blocks - public static final BooleanProperty ODD = BooleanProperty.create( "odd" ); + public BlockQuartzFixture() { + super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14) + .sound(SoundType.GLASS)); - public BlockQuartzFixture() - { - super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14).sound(SoundType.GLASS)); + this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false)); + this.setFullSize(false); + this.setOpaque(false); + } - this.setDefaultState( getDefaultState().with( FACING, Direction.UP ).with( ODD, false ) ); - this.setFullSize( false ); - this.setOpaque( false ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(FACING, ODD); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(FACING, ODD); - } + // For reference, see WallTorchBlock + @Nullable + public BlockState getStateForPlacement(BlockItemUseContext context) { + BlockState blockstate = super.getStateForPlacement(context); + BlockPos pos = context.getPos(); - // For reference, see WallTorchBlock - @Nullable - public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockState blockstate = super.getStateForPlacement(context); - BlockPos pos = context.getPos(); + // Set the even/odd property + boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0; + blockstate = blockstate.with(ODD, oddPlacement); - // Set the even/odd property - boolean oddPlacement = ( ( pos.getX() + pos.getY() + pos.getZ() ) % 2 ) != 0; - blockstate = blockstate.with( ODD, oddPlacement ); + IWorldReader iworldreader = context.getWorld(); + Direction[] adirection = context.getNearestLookingDirections(); - IWorldReader iworldreader = context.getWorld(); - Direction[] adirection = context.getNearestLookingDirections(); + for (Direction direction : adirection) { + if (canPlaceAt(iworldreader, pos, direction)) { + return blockstate.with(FACING, direction.getOpposite()); + } + } - for(Direction direction : adirection) { - if (canPlaceAt(iworldreader, pos, direction)) { - return blockstate.with(FACING, direction.getOpposite()); - } - } + return null; + } - return null; - } + // Break the fixture if the block it is attached to is changed so that it could + // no longer be placed + @Override + public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, + BlockPos pos, BlockPos facingPos) { + Direction fixtureFacing = state.get(FACING); + if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) { + return Blocks.AIR.getDefaultState(); + } + return state; + } - // Break the fixture if the block it is attached to is changed so that it could no longer be placed - @Override - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, BlockPos pos, BlockPos facingPos) { - Direction fixtureFacing = state.get(FACING); - if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) { - return Blocks.AIR.getDefaultState(); - } - return state; - } + @Override + public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) { + // FIXME: I think this entire method -> not required, but not sure... are quartz + // fixtures rotateable??? + return this.canPlaceAt(w, pos, up.getOpposite()); + } - @Override - public boolean isValidOrientation( final IWorld w, final BlockPos pos, final Direction forward, final Direction up ) - { - // FIXME: I think this entire method -> not required, but not sure... are quartz fixtures rotateable??? - return this.canPlaceAt( w, pos, up.getOpposite() ); - } + private boolean canPlaceAt(final IWorldReader w, final BlockPos pos, final Direction dir) { + final BlockPos test = pos.offset(dir); + BlockState blockstate = w.getBlockState(test); + return blockstate.isSolidSide(w, test, dir.getOpposite()); + } - private boolean canPlaceAt( final IWorldReader w, final BlockPos pos, final Direction dir ) - { - final BlockPos test = pos.offset( dir ); - BlockState blockstate = w.getBlockState(test); - return blockstate.isSolidSide(w, test, dir.getOpposite()); - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + Direction facing = state.get(FACING); + return SHAPES.get(facing); + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - Direction facing = state.get(FACING); - return SHAPES.get(facing); - } + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + if (r.nextFloat() < 0.98) { + return; + } - if( r.nextFloat() < 0.98 ) - { - return; - } + final Direction up = this.getOrientable(w, pos).getUp(); + final double xOff = -0.3 * up.getXOffset(); + final double yOff = -0.3 * up.getYOffset(); + final double zOff = -0.3 * up.getZOffset(); + for (int bolts = 0; bolts < 3; bolts++) { + if (AppEng.proxy.shouldAddParticles(r)) { + w.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), + zOff + 0.5 + pos.getZ(), 0, 0, 0); + } + } + } - final Direction up = this.getOrientable( w, pos ).getUp(); - final double xOff = -0.3 * up.getXOffset(); - final double yOff = -0.3 * up.getYOffset(); - final double zOff = -0.3 * up.getZOffset(); - for( int bolts = 0; bolts < 3; bolts++ ) - { - if( AppEng.proxy.shouldAddParticles( r ) ) - { - w.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0, 0, 0); - } - } - } + // FIXME: Replaced by the postPlaceupdate stuff above, but check item drops! + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final Direction up = this.getOrientable(world, pos).getUp(); + if (!this.canPlaceAt(world, pos, up.getOpposite())) { + this.dropTorch(world, pos); + } + } - // FIXME: Replaced by the postPlaceupdate stuff above, but check item drops! - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final Direction up = this.getOrientable( world, pos ).getUp(); - if( !this.canPlaceAt( world, pos, up.getOpposite() ) ) - { - this.dropTorch( world, pos ); - } - } + private void dropTorch(final World w, final BlockPos pos) { + final BlockState prev = w.getBlockState(pos); + w.destroyBlock(pos, true); + w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); + } - private void dropTorch( final World w, final BlockPos pos ) - { - final BlockState prev = w.getBlockState( pos ); - w.destroyBlock( pos, true ); - w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); - } + @Override + public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) { + for (final Direction dir : Direction.values()) { + if (this.canPlaceAt(w, pos, dir)) { + return true; + } + } + return false; + } - @Override - public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) - { - for( final Direction dir : Direction.values() ) - { - if( this.canPlaceAt( w, pos, dir ) ) - { - return true; - } - } - return false; - } + @Override + public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) { + return new MetaRotation(w, pos, FACING); + } - @Override - public IOrientable getOrientable( final IBlockReader w, final BlockPos pos ) - { - return new MetaRotation( w, pos, FACING ); - } - - @Override - public boolean isOpaque() - { - return false; - } + @Override + public boolean isOpaque() { + return false; + } } diff --git a/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java b/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java index 5ff64f469..2652ea24f 100644 --- a/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java +++ b/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java @@ -18,14 +18,8 @@ package appeng.block.misc; +import java.util.Random; -import appeng.api.util.IOrientableBlock; -import appeng.block.AEBaseTileBlock; -import appeng.client.render.effects.LightningFX; -import appeng.core.AEConfig; -import appeng.core.AppEng; -import appeng.tile.misc.TileQuartzGrowthAccelerator; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; @@ -40,110 +34,109 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.Random; +import appeng.api.util.IOrientableBlock; +import appeng.block.AEBaseTileBlock; +import appeng.client.render.effects.LightningFX; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import appeng.tile.misc.TileQuartzGrowthAccelerator; +import appeng.util.Platform; +public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock + implements IOrientableBlock { -public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock -{ + private static final BooleanProperty POWERED = BooleanProperty.create("powered"); - private static final BooleanProperty POWERED = BooleanProperty.create( "powered" ); + public BlockQuartzGrowthAccelerator() { + super(defaultProps(Material.ROCK).sound(SoundType.METAL)); + this.setDefaultState(this.getDefaultState().with(POWERED, false)); + } - public BlockQuartzGrowthAccelerator() - { - super( defaultProps(Material.ROCK).sound(SoundType.METAL) ); - this.setDefaultState( this.getDefaultState().with( POWERED, false ) ); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuartzGrowthAccelerator te) { + return currentState.with(POWERED, te.isPowered()); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuartzGrowthAccelerator te) { - return currentState.with( POWERED, te.isPowered() ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(POWERED); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(POWERED); - } + @OnlyIn(Dist.CLIENT) + @Override + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - @OnlyIn( Dist.CLIENT ) - @Override - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + final TileQuartzGrowthAccelerator cga = this.getTileEntity(w, pos); - final TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos ); + if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) { + final double d0 = r.nextFloat() - 0.5F; + final double d1 = r.nextFloat() - 0.5F; - if( cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles( r ) ) - { - final double d0 = r.nextFloat() - 0.5F; - final double d1 = r.nextFloat() - 0.5F; + final Direction up = cga.getUp(); + final Direction forward = cga.getForward(); + final Direction west = Platform.crossProduct(forward, up); - final Direction up = cga.getUp(); - final Direction forward = cga.getForward(); - final Direction west = Platform.crossProduct( forward, up ); + double rx = 0.5 + pos.getX(); + double ry = 0.5 + pos.getY(); + double rz = 0.5 + pos.getZ(); - double rx = 0.5 + pos.getX(); - double ry = 0.5 + pos.getY(); - double rz = 0.5 + pos.getZ(); + rx += up.getXOffset() * d0; + ry += up.getYOffset() * d0; + rz += up.getZOffset() * d0; - rx += up.getXOffset() * d0; - ry += up.getYOffset() * d0; - rz += up.getZOffset() * d0; + final int x = pos.getX(); + final int y = pos.getY(); + final int z = pos.getZ(); - final int x = pos.getX(); - final int y = pos.getY(); - final int z = pos.getZ(); + double dz = 0; + double dx = 0; + BlockPos pt = null; - double dz = 0; - double dx = 0; - BlockPos pt = null; + switch (r.nextInt(4)) { + case 0: + dx = 0.6; + dz = d1; + pt = new BlockPos(x + west.getXOffset(), y + west.getYOffset(), z + west.getZOffset()); - switch( r.nextInt( 4 ) ) - { - case 0: - dx = 0.6; - dz = d1; - pt = new BlockPos( x + west.getXOffset(), y + west.getYOffset(), z + west.getZOffset() ); + break; + case 1: + dx = d1; + dz += 0.6; + pt = new BlockPos(x + forward.getXOffset(), y + forward.getYOffset(), z + forward.getZOffset()); - break; - case 1: - dx = d1; - dz += 0.6; - pt = new BlockPos( x + forward.getXOffset(), y + forward.getYOffset(), z + forward.getZOffset() ); + break; + case 2: + dx = d1; + dz = -0.6; + pt = new BlockPos(x - forward.getXOffset(), y - forward.getYOffset(), z - forward.getZOffset()); - break; - case 2: - dx = d1; - dz = -0.6; - pt = new BlockPos( x - forward.getXOffset(), y - forward.getYOffset(), z - forward.getZOffset() ); + break; + case 3: + dx = -0.6; + dz = d1; + pt = new BlockPos(x - west.getXOffset(), y - west.getYOffset(), z - west.getZOffset()); - break; - case 3: - dx = -0.6; - dz = d1; - pt = new BlockPos( x - west.getXOffset(), y - west.getYOffset(), z - west.getZOffset() ); + break; + } - break; - } + if (!w.getBlockState(pt).getBlock().isAir(w.getBlockState(pt), w, pt)) { + return; + } - if( !w.getBlockState( pt ).getBlock().isAir( w.getBlockState( pt ), w, pt ) ) - { - return; - } + rx += dx * west.getXOffset(); + ry += dx * west.getYOffset(); + rz += dx * west.getZOffset(); - rx += dx * west.getXOffset(); - ry += dx * west.getYOffset(); - rz += dx * west.getZOffset(); + rx += dz * forward.getXOffset(); + ry += dz * forward.getYOffset(); + rz += dz * forward.getZOffset(); - rx += dz * forward.getXOffset(); - ry += dz * forward.getYOffset(); - rz += dz * forward.getZOffset(); - - Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, rx, ry, rz, 0.0D, 0.0D, 0.0D); - } - } + Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, rx, ry, rz, 0.0D, 0.0D, 0.0D); + } + } } diff --git a/src/main/java/appeng/block/misc/BlockSecurityStation.java b/src/main/java/appeng/block/misc/BlockSecurityStation.java index c1d9dd028..097cb1390 100644 --- a/src/main/java/appeng/block/misc/BlockSecurityStation.java +++ b/src/main/java/appeng/block/misc/BlockSecurityStation.java @@ -18,20 +18,14 @@ package appeng.block.misc; - import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerFormationPlane; -import appeng.container.implementations.ContainerSecurityStation; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; - -import net.minecraft.state.BooleanProperty; import net.minecraft.block.BlockState; +import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; @@ -43,53 +37,51 @@ import net.minecraft.world.World; import appeng.api.util.AEPartLocation; import appeng.block.AEBaseTileBlock; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerFormationPlane; +import appeng.container.implementations.ContainerSecurityStation; import appeng.tile.misc.TileSecurityStation; import appeng.util.Platform; +public class BlockSecurityStation extends AEBaseTileBlock { -public class BlockSecurityStation extends AEBaseTileBlock -{ + private static final BooleanProperty POWERED = BooleanProperty.create("powered"); - private static final BooleanProperty POWERED = BooleanProperty.create( "powered" ); + public BlockSecurityStation() { + super(defaultProps(Material.IRON)); - public BlockSecurityStation() - { - super( defaultProps(Material.IRON) ); + this.setDefaultState(this.getDefaultState().with(POWERED, false)); + } - this.setDefaultState( this.getDefaultState().with( POWERED, false ) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(POWERED); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(POWERED); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileSecurityStation te) { + return currentState.with(POWERED, te.isActive()); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileSecurityStation te) { - return currentState.with( POWERED, te.isActive() ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } + final TileSecurityStation tg = this.getTileEntity(w, pos); + if (tg != null) { + if (w.isRemote()) { + return ActionResultType.SUCCESS; + } - final TileSecurityStation tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( w.isRemote() ) - { - return ActionResultType.SUCCESS; - } - - ContainerOpener.openContainer(ContainerSecurityStation.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + ContainerOpener.openContainer(ContainerSecurityStation.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/misc/BlockSkyCompass.java b/src/main/java/appeng/block/misc/BlockSkyCompass.java index c5c424fa0..32224546f 100644 --- a/src/main/java/appeng/block/misc/BlockSkyCompass.java +++ b/src/main/java/appeng/block/misc/BlockSkyCompass.java @@ -18,8 +18,6 @@ package appeng.block.misc; - - import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -37,137 +35,124 @@ import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; import appeng.tile.misc.TileSkyCompass; +public class BlockSkyCompass extends AEBaseTileBlock { -public class BlockSkyCompass extends AEBaseTileBlock -{ + public BlockSkyCompass(Block.Properties props) { + super(props); + } - public BlockSkyCompass(Block.Properties props) - { - super(props); - } + @Override + public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) { + final TileSkyCompass sc = this.getTileEntity(w, pos); + if (sc != null) { + return false; + } + return this.canPlaceAt(w, pos, forward.getOpposite()); + } - @Override - public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up ) - { - final TileSkyCompass sc = this.getTileEntity( w, pos ); - if( sc != null ) - { - return false; - } - return this.canPlaceAt( w, pos, forward.getOpposite() ); - } + private boolean canPlaceAt(final IBlockReader w, final BlockPos pos, final Direction dir) { + final BlockPos test = pos.offset(dir); + BlockState blockstate = w.getBlockState(test); + return blockstate.isSolidSide(w, test, dir.getOpposite()); + } - private boolean canPlaceAt( final IBlockReader w, final BlockPos pos, final Direction dir ) - { - final BlockPos test = pos.offset( dir ); - BlockState blockstate = w.getBlockState(test); - return blockstate.isSolidSide(w, test, dir.getOpposite()); - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileSkyCompass sc = this.getTileEntity(world, pos); + final Direction forward = sc.getForward(); + if (!this.canPlaceAt(world, pos, forward.getOpposite())) { + this.dropTorch(world, pos); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileSkyCompass sc = this.getTileEntity( world, pos ); - final Direction forward = sc.getForward(); - if( !this.canPlaceAt( world, pos, forward.getOpposite() ) ) - { - this.dropTorch( world, pos ); - } - } + private void dropTorch(final World w, final BlockPos pos) { + final BlockState prev = w.getBlockState(pos); + w.destroyBlock(pos, true); + w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); + } - private void dropTorch( final World w, final BlockPos pos ) - { - final BlockState prev = w.getBlockState( pos ); - w.destroyBlock( pos, true ); - w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); - } + @Override + public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) { + for (final Direction dir : Direction.values()) { + if (this.canPlaceAt(w, pos, dir)) { + return true; + } + } + return false; + } - @Override - public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) - { - for( final Direction dir : Direction.values() ) - { - if( this.canPlaceAt( w, pos, dir ) ) - { - return true; - } - } - return false; - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - @Override - public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + // TODO: This definitely needs to be memoized - // TODO: This definitely needs to be memoized + final TileSkyCompass tile = this.getTileEntity(w, pos); + if (tile != null) { + final Direction forward = tile.getForward(); - final TileSkyCompass tile = this.getTileEntity( w, pos ); - if( tile != null ) - { - final Direction forward = tile.getForward(); + double minX = 0; + double minY = 0; + double minZ = 0; + double maxX = 1; + double maxY = 1; + double maxZ = 1; - double minX = 0; - double minY = 0; - double minZ = 0; - double maxX = 1; - double maxY = 1; - double maxZ = 1; + switch (forward) { + case DOWN: + minZ = minX = 5.0 / 16.0; + maxZ = maxX = 11.0 / 16.0; + maxY = 1.0; + minY = 14.0 / 16.0; + break; + case EAST: + minZ = minY = 5.0 / 16.0; + maxZ = maxY = 11.0 / 16.0; + maxX = 2.0 / 16.0; + minX = 0.0; + break; + case NORTH: + minY = minX = 5.0 / 16.0; + maxY = maxX = 11.0 / 16.0; + maxZ = 1.0; + minZ = 14.0 / 16.0; + break; + case SOUTH: + minY = minX = 5.0 / 16.0; + maxY = maxX = 11.0 / 16.0; + maxZ = 2.0 / 16.0; + minZ = 0.0; + break; + case UP: + minZ = minX = 5.0 / 16.0; + maxZ = maxX = 11.0 / 16.0; + maxY = 2.0 / 16.0; + minY = 0.0; + break; + case WEST: + minZ = minY = 5.0 / 16.0; + maxZ = maxY = 11.0 / 16.0; + maxX = 1.0; + minX = 14.0 / 16.0; + break; + default: + break; + } - switch( forward ) - { - case DOWN: - minZ = minX = 5.0 / 16.0; - maxZ = maxX = 11.0 / 16.0; - maxY = 1.0; - minY = 14.0 / 16.0; - break; - case EAST: - minZ = minY = 5.0 / 16.0; - maxZ = maxY = 11.0 / 16.0; - maxX = 2.0 / 16.0; - minX = 0.0; - break; - case NORTH: - minY = minX = 5.0 / 16.0; - maxY = maxX = 11.0 / 16.0; - maxZ = 1.0; - minZ = 14.0 / 16.0; - break; - case SOUTH: - minY = minX = 5.0 / 16.0; - maxY = maxX = 11.0 / 16.0; - maxZ = 2.0 / 16.0; - minZ = 0.0; - break; - case UP: - minZ = minX = 5.0 / 16.0; - maxZ = maxX = 11.0 / 16.0; - maxY = 2.0 / 16.0; - minY = 0.0; - break; - case WEST: - minZ = minY = 5.0 / 16.0; - maxZ = maxY = 11.0 / 16.0; - maxX = 1.0; - minX = 14.0 / 16.0; - break; - default: - break; - } + return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ)); + } + return VoxelShapes.empty(); + } - return VoxelShapes.create(new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); - } - return VoxelShapes.empty(); - } + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, + ISelectionContext context) { + return VoxelShapes.empty(); + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.empty(); - } - - @Override - public BlockRenderType getRenderType(BlockState state ) - { - return BlockRenderType.ENTITYBLOCK_ANIMATED; - } + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.ENTITYBLOCK_ANIMATED; + } } diff --git a/src/main/java/appeng/block/misc/BlockTinyTNT.java b/src/main/java/appeng/block/misc/BlockTinyTNT.java index 158d45314..2e0f809bd 100644 --- a/src/main/java/appeng/block/misc/BlockTinyTNT.java +++ b/src/main/java/appeng/block/misc/BlockTinyTNT.java @@ -18,19 +18,18 @@ package appeng.block.misc; - import javax.annotation.Nullable; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; -import net.minecraft.item.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; @@ -44,124 +43,111 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import appeng.block.AEBaseBlock; import appeng.entity.EntityTinyTNTPrimed; -import net.minecraft.world.server.ServerWorld; +public class BlockTinyTNT extends AEBaseBlock { -public class BlockTinyTNT extends AEBaseBlock -{ + private static final VoxelShape SHAPE = VoxelShapes + .create(new AxisAlignedBB(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f)); - private static final VoxelShape SHAPE = VoxelShapes.create(new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f )); + public BlockTinyTNT(Block.Properties props) { + super(props); + } - public BlockTinyTNT(Block.Properties props) - { - super(props); - } + @Override + public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { + return 2; // FIXME: Validate that this is the correct value range + } - @Override - public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { - return 2; // FIXME: Validate that this is the correct value range - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return SHAPE; - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) { + this.startFuse(w, pos, player); + w.removeBlock(pos, false); + heldItem.damageItem(1, player, p -> { + p.sendBreakAnimation(hand); + }); // FIXME Check if onBroken is equivalent + return ActionResultType.SUCCESS; + } else { + return super.onActivated(w, pos, player, hand, heldItem, hit); + } + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL ) - { - this.startFuse( w, pos, player ); - w.removeBlock(pos, false); - heldItem.damageItem( 1, player, p -> { - p.sendBreakAnimation(hand); - } ); // FIXME Check if onBroken is equivalent - return ActionResultType.SUCCESS; - } - else - { - return super.onActivated( w, pos, player, hand, heldItem, hit); - } - } + public void startFuse(final World w, final BlockPos pos, final LivingEntity igniter) { + if (!w.isRemote) { + final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F, + pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter); + w.addEntity(primedTinyTNTEntity); + w.playSound(null, primedTinyTNTEntity.getPosX(), primedTinyTNTEntity.getPosY(), + primedTinyTNTEntity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1); + } + } - public void startFuse( final World w, final BlockPos pos, final LivingEntity igniter ) - { - if( !w.isRemote ) - { - final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter ); - w.addEntity( primedTinyTNTEntity ); - w.playSound( null, primedTinyTNTEntity.getPosX(), primedTinyTNTEntity.getPosY(), primedTinyTNTEntity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, - SoundCategory.BLOCKS, 1, 1 ); - } - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + if (world.getRedstonePowerFromNeighbors(pos) > 0) { + this.startFuse(world, pos, null); + world.removeBlock(pos, false); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - if( world.getRedstonePowerFromNeighbors( pos ) > 0 ) - { - this.startFuse( world, pos, null ); - world.removeBlock(pos, false); - } - } + @Override + public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onBlockAdded(state, w, pos, oldState, isMoving); - @Override - public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) { - super.onBlockAdded( state, w, pos, oldState, isMoving ); + if (w.getRedstonePowerFromNeighbors(pos) > 0) { + this.startFuse(w, pos, null); + w.removeBlock(pos, false); + } + } - if( w.getRedstonePowerFromNeighbors( pos ) > 0 ) - { - this.startFuse( w, pos, null ); - w.removeBlock(pos, false); - } - } + @Override + public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) { + if (entity instanceof AbstractArrowEntity && !w.isRemote) { + final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity; - @Override - public void onEntityWalk( final World w, final BlockPos pos, final Entity entity ) - { - if( entity instanceof AbstractArrowEntity && !w.isRemote ) - { - final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity; + if (entityarrow.isBurning()) { + LivingEntity igniter = null; + // Check if the shooter still exists + if (w instanceof ServerWorld) { + ServerWorld serverWorld = (ServerWorld) w; + Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity); + if (shooter instanceof LivingEntity) { + igniter = (LivingEntity) shooter; + } - if( entityarrow.isBurning() ) - { - LivingEntity igniter = null; - // Check if the shooter still exists - if (w instanceof ServerWorld) { - ServerWorld serverWorld = (ServerWorld) w; - Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity); - if (shooter instanceof LivingEntity) { - igniter = (LivingEntity) shooter; - } + } + this.startFuse(w, pos, igniter); + w.removeBlock(pos, false); + } + } + } - } - this.startFuse( w, pos, igniter ); - w.removeBlock(pos, false); - } - } - } + @Override + public boolean canDropFromExplosion(final Explosion exp) { + return false; + } - @Override - public boolean canDropFromExplosion( final Explosion exp ) - { - return false; - } - - @Override - public void onExplosionDestroy( final World w, final BlockPos pos, final Explosion exp ) - { - super.onExplosionDestroy( w, pos, exp ); - if( !w.isRemote ) - { - final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp - .getExplosivePlacedBy() ); - primedTinyTNTEntity.setFuse( w.rand.nextInt( primedTinyTNTEntity.getFuse() / 4 ) + primedTinyTNTEntity.getFuse() / 8 ); - w.addEntity( primedTinyTNTEntity ); - } - } + @Override + public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) { + super.onExplosionDestroy(w, pos, exp); + if (!w.isRemote) { + final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F, + pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy()); + primedTinyTNTEntity + .setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8); + w.addEntity(primedTinyTNTEntity); + } + } } diff --git a/src/main/java/appeng/block/misc/BlockVibrationChamber.java b/src/main/java/appeng/block/misc/BlockVibrationChamber.java index 3f016a5f8..6f55b9548 100644 --- a/src/main/java/appeng/block/misc/BlockVibrationChamber.java +++ b/src/main/java/appeng/block/misc/BlockVibrationChamber.java @@ -18,16 +18,10 @@ package appeng.block.misc; +import java.util.Random; + +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerDrive; -import appeng.container.implementations.ContainerVibrationChamber; -import appeng.core.AEConfig; -import appeng.tile.AEBaseTile; -import appeng.tile.misc.TileVibrationChamber; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -44,97 +38,95 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IWorld; import net.minecraft.world.World; -import javax.annotation.Nullable; -import java.util.Random; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerDrive; +import appeng.container.implementations.ContainerVibrationChamber; +import appeng.core.AEConfig; +import appeng.tile.AEBaseTile; +import appeng.tile.misc.TileVibrationChamber; +import appeng.util.Platform; +public final class BlockVibrationChamber extends AEBaseTileBlock { -public final class BlockVibrationChamber extends AEBaseTileBlock -{ + // Indicates that the vibration chamber is currently working + private static final BooleanProperty ACTIVE = BooleanProperty.create("active"); - // Indicates that the vibration chamber is currently working - private static final BooleanProperty ACTIVE = BooleanProperty.create( "active" ); + public BlockVibrationChamber() { + super(defaultProps(Material.IRON).hardnessAndResistance(4.2F)); + this.setDefaultState(this.getDefaultState().with(ACTIVE, false)); + } - public BlockVibrationChamber() - { - super( defaultProps(Material.IRON).hardnessAndResistance(4.2F) ); - this.setDefaultState( this.getDefaultState().with( ACTIVE, false ) ); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileVibrationChamber te) { + return currentState.with(ACTIVE, te.isOn); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileVibrationChamber te) { - return currentState.with( ACTIVE, te.isOn ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(ACTIVE); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(ACTIVE); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (player.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( player.isCrouching() ) - { - return ActionResultType.PASS; - } + if (Platform.isServer()) { + final TileVibrationChamber tc = this.getTileEntity(w, pos); + if (tc != null && !player.isCrouching()) { + ContainerOpener.openContainer(ContainerVibrationChamber.TYPE, player, + ContainerLocator.forTileEntitySide(tc, hit.getFace())); + return ActionResultType.SUCCESS; + } + } - if( Platform.isServer() ) - { - final TileVibrationChamber tc = this.getTileEntity( w, pos ); - if( tc != null && !player.isCrouching() ) - { - ContainerOpener.openContainer(ContainerVibrationChamber.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace())); - return ActionResultType.SUCCESS; - } - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } + @Override + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - @Override - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + final AEBaseTile tile = this.getTileEntity(w, pos); + if (tile instanceof TileVibrationChamber) { + final TileVibrationChamber tc = (TileVibrationChamber) tile; + if (tc.isOn) { + double f1 = pos.getX() + 0.5F; + double f2 = pos.getY() + 0.5F; + double f3 = pos.getZ() + 0.5F; - final AEBaseTile tile = this.getTileEntity( w, pos ); - if( tile instanceof TileVibrationChamber ) - { - final TileVibrationChamber tc = (TileVibrationChamber) tile; - if( tc.isOn ) - { - double f1 = pos.getX() + 0.5F; - double f2 = pos.getY() + 0.5F; - double f3 = pos.getZ() + 0.5F; + final Direction forward = tc.getForward(); + final Direction up = tc.getUp(); - final Direction forward = tc.getForward(); - final Direction up = tc.getUp(); + final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); + final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); + final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); - final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); - final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); - final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); + f1 += forward.getXOffset() * 0.6; + f2 += forward.getYOffset() * 0.6; + f3 += forward.getZOffset() * 0.6; - f1 += forward.getXOffset() * 0.6; - f2 += forward.getYOffset() * 0.6; - f3 += forward.getZOffset() * 0.6; + final double ox = r.nextDouble(); + final double oy = r.nextDouble() * 0.2f; - final double ox = r.nextDouble(); - final double oy = r.nextDouble() * 0.2f; + f1 += up.getXOffset() * (-0.3 + oy); + f2 += up.getYOffset() * (-0.3 + oy); + f3 += up.getZOffset() * (-0.3 + oy); - f1 += up.getXOffset() * ( -0.3 + oy ); - f2 += up.getYOffset() * ( -0.3 + oy ); - f3 += up.getZOffset() * ( -0.3 + oy ); + f1 += west_x * (0.3 * ox - 0.15); + f2 += west_y * (0.3 * ox - 0.15); + f3 += west_z * (0.3 * ox - 0.15); - f1 += west_x * ( 0.3 * ox - 0.15 ); - f2 += west_y * ( 0.3 * ox - 0.15 ); - f3 += west_z * ( 0.3 * ox - 0.15 ); - - w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D ); - w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D ); - } - } - } + w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D); + w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D); + } + } + } } diff --git a/src/main/java/appeng/block/misc/InscriberRendering.java b/src/main/java/appeng/block/misc/InscriberRendering.java index f91715a3f..3529d8793 100644 --- a/src/main/java/appeng/block/misc/InscriberRendering.java +++ b/src/main/java/appeng/block/misc/InscriberRendering.java @@ -1,22 +1,19 @@ package appeng.block.misc; - -import appeng.bootstrap.*; -import appeng.tile.misc.TileInscriber; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.bootstrap.*; import appeng.client.render.tesr.InscriberTESR; +import appeng.tile.misc.TileInscriber; +public class InscriberRendering extends TileEntityRenderingCustomizer { -public class InscriberRendering extends TileEntityRenderingCustomizer -{ - - @OnlyIn( Dist.CLIENT ) - @Override - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer( InscriberTESR::new ); - } + @OnlyIn(Dist.CLIENT) + @Override + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(InscriberTESR::new); + } } diff --git a/src/main/java/appeng/block/misc/SecurityStationRendering.java b/src/main/java/appeng/block/misc/SecurityStationRendering.java index c7de9f1b6..d2f3af38c 100644 --- a/src/main/java/appeng/block/misc/SecurityStationRendering.java +++ b/src/main/java/appeng/block/misc/SecurityStationRendering.java @@ -18,7 +18,6 @@ package appeng.block.misc; - import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -30,16 +29,13 @@ import appeng.bootstrap.IItemRendering; import appeng.client.render.ColorableTileBlockColor; import appeng.client.render.StaticItemColor; +public class SecurityStationRendering extends BlockRenderingCustomizer { -public class SecurityStationRendering extends BlockRenderingCustomizer -{ - - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - rendering.blockColor( ColorableTileBlockColor.INSTANCE ); - itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + rendering.blockColor(ColorableTileBlockColor.INSTANCE); + itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT)); + } } diff --git a/src/main/java/appeng/block/misc/SkyCompassRendering.java b/src/main/java/appeng/block/misc/SkyCompassRendering.java index 68d5a64dc..a1f0109c6 100644 --- a/src/main/java/appeng/block/misc/SkyCompassRendering.java +++ b/src/main/java/appeng/block/misc/SkyCompassRendering.java @@ -18,22 +18,19 @@ package appeng.block.misc; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import appeng.bootstrap.*; import appeng.client.render.tesr.SkyCompassTESR; import appeng.tile.misc.TileSkyCompass; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +public class SkyCompassRendering extends TileEntityRenderingCustomizer { - -public class SkyCompassRendering extends TileEntityRenderingCustomizer -{ - - @Override - @OnlyIn( Dist.CLIENT ) - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer( SkyCompassTESR::new ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(SkyCompassTESR::new); + } } diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index 88c3ab0cd..cc2704b07 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -18,24 +18,12 @@ package appeng.block.networking; +import java.util.EnumSet; +import java.util.List; +import java.util.Random; + +import javax.annotation.Nullable; -import appeng.api.parts.IFacadeContainer; -import appeng.api.parts.PartItemStack; -import appeng.api.parts.SelectedPart; -import appeng.api.util.AEColor; -import appeng.block.AEBaseTileBlock; -import appeng.client.render.cablebus.CableBusBakedModel; -import appeng.client.render.cablebus.CableBusBreakingParticle; -import appeng.client.render.cablebus.CableBusRenderState; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketClick; -import appeng.helpers.AEGlassMaterial; -import appeng.parts.ICableBusContainer; -import appeng.parts.NullCableBusContainer; -import appeng.tile.AEBaseTile; -import appeng.tile.networking.TileCableBus; -import appeng.tile.networking.TileCableBusTESR; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -66,71 +54,83 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.EnumSet; -import java.util.List; -import java.util.Random; - +import appeng.api.parts.IFacadeContainer; +import appeng.api.parts.PartItemStack; +import appeng.api.parts.SelectedPart; +import appeng.api.util.AEColor; +import appeng.block.AEBaseTileBlock; +import appeng.client.render.cablebus.CableBusBakedModel; +import appeng.client.render.cablebus.CableBusBreakingParticle; +import appeng.client.render.cablebus.CableBusRenderState; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketClick; +import appeng.helpers.AEGlassMaterial; +import appeng.parts.ICableBusContainer; +import appeng.parts.NullCableBusContainer; +import appeng.tile.AEBaseTile; +import appeng.tile.networking.TileCableBus; +import appeng.tile.networking.TileCableBusTESR; +import appeng.util.Platform; public class BlockCableBus extends AEBaseTileBlock /* FIXME implements IAEFacade */ { - private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer(); + private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer(); - public BlockCableBus() { - super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops()); - } + public BlockCableBus() { + super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops()); + } - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { - return true; - } + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { + return true; + } - @Override - public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) { - this.cb(worldIn, pos).animateTick(worldIn, pos, rand); - } + @Override + public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) { + this.cb(worldIn, pos).animateTick(worldIn, pos, rand); + } - @Override - public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) { - this.cb(w, pos).onNeighborChanged(w, pos, neighbor); - } + @Override + public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) { + this.cb(w, pos).onNeighborChanged(w, pos, neighbor); + } - @Override - public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) { - return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO: - // IS - // OPPOSITE!? - } + @Override + public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) { + return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO: + // IS + // OPPOSITE!? + } - @Override - public boolean canProvidePower(final BlockState state) { - return true; - } + @Override + public boolean canProvidePower(final BlockState state) { + return true; + } - @Override - public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) { - this.cb(w, pos).onEntityCollision(entityIn); - } + @Override + public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) { + this.cb(w, pos).onEntityCollision(entityIn); + } - @Override - public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) { - return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO: - // IS - // OPPOSITE!? - } + @Override + public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) { + return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO: + // IS + // OPPOSITE!? + } - @Override - public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) { - if (state.getBlock() != this) { - return state.getBlock().getLightValue(state, world, pos); - } - return this.cb(world, pos).getLightValue(); - } + @Override + public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) { + if (state.getBlock() != this) { + return state.getBlock().getLightValue(state, world, pos); + } + return this.cb(world, pos).getLightValue(); + } - @Override - public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) { - return this.cb(world, pos).isLadder(entity); - } + @Override + public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) { + return this.cb(world, pos).isLadder(entity); + } // FIXME: This is now derived from the collision shape, and cannot be decided programatically anymore. // FIXME: see Block.hasSolidSide. We need to remove isSolidOnSide @@ -140,213 +140,222 @@ public class BlockCableBus extends AEBaseTileBlock /* FIXME implem // FIXME return this.cb( w, pos ).isSolidOnSide( side ); // FIXME } + @Override + public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { + // FIXME: Potentially check the fluid one too + return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty(); + } - @Override - public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { - // FIXME: Potentially check the fluid one too - return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty(); - } + @Override + public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, + boolean willHarvest, IFluidState fluid) { + if (player.abilities.isCreativeMode) { + final AEBaseTile tile = this.getTileEntity(world, pos); + if (tile != null) { + tile.disableDrops(); + } + // maybe ray trace? + } + return super.removedByPlayer(state, world, pos, player, willHarvest, fluid); + } - @Override - public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) { - if (player.abilities.isCreativeMode) { - final AEBaseTile tile = this.getTileEntity(world, pos); - if (tile != null) { - tile.disableDrops(); - } - // maybe ray trace? - } - return super.removedByPlayer(state, world, pos, player, willHarvest, fluid); - } + @Override + public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos, + Direction side) { + if (side == null) { + side = Direction.UP; + } - @Override - public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos, Direction side) { - if (side == null) { - side = Direction.UP; - } + return this.cb(w, pos).canConnectRedstone(EnumSet.of(side)); + } - return this.cb(w, pos).canConnectRedstone(EnumSet.of(side)); - } + @Override + public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, + PlayerEntity player) { + final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ()); + final SelectedPart sp = this.cb(world, pos).selectPart(v3); - @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) { - final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ()); - final SelectedPart sp = this.cb(world, pos).selectPart(v3); + if (sp.part != null) { + return sp.part.getItemStack(PartItemStack.PICK); + } else if (sp.facade != null) { + return sp.facade.getItemStack(); + } - if (sp.part != null) { - return sp.part.getItemStack(PartItemStack.PICK); - } else if (sp.facade != null) { - return sp.facade.getItemStack(); - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + @OnlyIn(Dist.CLIENT) + public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target, + final ParticleManager effectRenderer) { - @Override - @OnlyIn(Dist.CLIENT) - public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer) { + // Half the particle rate. Since we're spawning concentrated on a specific spot, + // our particle effect otherwise looks too strong + if (Platform.getRandom().nextBoolean()) { + return true; + } - // Half the particle rate. Since we're spawning concentrated on a specific spot, - // our particle effect otherwise looks too strong - if (Platform.getRandom().nextBoolean()) { - return true; - } + if (target.getType() != Type.BLOCK) { + return false; + } + BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z); - if (target.getType() != Type.BLOCK) { - return false; - } - BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z); + ICableBusContainer cb = this.cb(world, blockPos); - ICableBusContainer cb = this.cb(world, blockPos); + // Our built-in model has the actual baked sprites we need + IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher() + .getModelForState(this.getDefaultState()); - // Our built-in model has the actual baked sprites we need - IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState()); + // We cannot add the effect if we don't have the model + if (!(model instanceof CableBusBakedModel)) { + return true; + } - // We cannot add the effect if we don't have the model - if (!(model instanceof CableBusBakedModel)) { - return true; - } + CableBusBakedModel cableBusModel = (CableBusBakedModel) model; - CableBusBakedModel cableBusModel = (CableBusBakedModel) model; + CableBusRenderState renderState = cb.getRenderState(); - CableBusRenderState renderState = cb.getRenderState(); + // Spawn a particle for one of the particle textures + TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState)); + if (texture != null) { + double x = target.getHitVec().x; + double y = target.getHitVec().y; + double z = target.getHitVec().z; + // FIXME: Check how this looks, probably like shit, maybe provide parts the + // ability to supply particle textures??? + effectRenderer + .addEffect(new CableBusBreakingParticle(world, x, y, z, texture).multiplyParticleScaleBy(0.8F)); + } - // Spawn a particle for one of the particle textures - TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState)); - if (texture != null) { - double x = target.getHitVec().x; - double y = target.getHitVec().y; - double z = target.getHitVec().z; - // FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures??? - effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture) - .multiplyParticleScaleBy(0.8F)); - } + return true; + } - return true; - } + @Override + public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) { + ICableBusContainer cb = this.cb(world, pos); - @Override - public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) { - ICableBusContainer cb = this.cb(world, pos); + // Our built-in model has the actual baked sprites we need + IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher() + .getModelForState(this.getDefaultState()); - // Our built-in model has the actual baked sprites we need - IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState()); + // We cannot add the effect if we dont have the model + if (!(model instanceof CableBusBakedModel)) { + return true; + } - // We cannot add the effect if we dont have the model - if (!(model instanceof CableBusBakedModel)) { - return true; - } + CableBusBakedModel cableBusModel = (CableBusBakedModel) model; - CableBusBakedModel cableBusModel = (CableBusBakedModel) model; + CableBusRenderState renderState = cb.getRenderState(); - CableBusRenderState renderState = cb.getRenderState(); + List textures = cableBusModel.getParticleTextures(renderState); - List textures = cableBusModel.getParticleTextures(renderState); + if (!textures.isEmpty()) { + // Shamelessly inspired by ParticleManager.addBlockDestroyEffects + for (int j = 0; j < 4; ++j) { + for (int k = 0; k < 4; ++k) { + for (int l = 0; l < 4; ++l) { + // Randomly select one of the textures if the cable bus has more than just one + // possibility here + final TextureAtlasSprite texture = Platform.pickRandom(textures); - if (!textures.isEmpty()) { - // Shamelessly inspired by ParticleManager.addBlockDestroyEffects - for (int j = 0; j < 4; ++j) { - for (int k = 0; k < 4; ++k) { - for (int l = 0; l < 4; ++l) { - // Randomly select one of the textures if the cable bus has more than just one possibility here - final TextureAtlasSprite texture = Platform.pickRandom(textures); + final double x = pos.getX() + (j + 0.5D) / 4.0D; + final double y = pos.getY() + (k + 0.5D) / 4.0D; + final double z = pos.getZ() + (l + 0.5D) / 4.0D; - final double x = pos.getX() + (j + 0.5D) / 4.0D; - final double y = pos.getY() + (k + 0.5D) / 4.0D; - final double z = pos.getZ() + (l + 0.5D) / 4.0D; + // FIXME: Check how this looks, probably like shit, maybe provide parts the + // ability to supply particle textures??? + Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D, + y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture); + effectRenderer.addEffect(effect); + } + } + } + } - // FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures??? - Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D, - y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture); - effectRenderer.addEffect(effect); - } - } - } - } + return true; + } - return true; - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + if (Platform.isServer()) { + this.cb(world, pos).onNeighborChanged(world, pos, fromPos); + } + } - @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (Platform.isServer()) { - this.cb(world, pos).onNeighborChanged(world, pos, fromPos); - } - } + private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) { + final TileEntity te = w.getTileEntity(pos); + ICableBusContainer out = null; - private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) { - final TileEntity te = w.getTileEntity(pos); - ICableBusContainer out = null; + if (te instanceof TileCableBus) { + out = ((TileCableBus) te).getCableBus(); + } - if (te instanceof TileCableBus) { - out = ((TileCableBus) te).getCableBus(); - } + return out == null ? NULL_CABLE_BUS : out; + } - return out == null ? NULL_CABLE_BUS : out; - } + @Nullable + private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) { + final TileEntity te = w.getTileEntity(pos); + IFacadeContainer out = null; - @Nullable - private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) { - final TileEntity te = w.getTileEntity(pos); - IFacadeContainer out = null; + if (te instanceof TileCableBus) { + out = ((TileCableBus) te).getCableBus().getFacadeContainer(); + } - if (te instanceof TileCableBus) { - out = ((TileCableBus) te).getCableBus().getFacadeContainer(); - } + return out; + } - return out; - } + @Override + public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { + if (worldIn.isRemote()) { + final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver; + if (rtr instanceof BlockRayTraceResult) { + BlockRayTraceResult brtr = (BlockRayTraceResult) rtr; + if (brtr.getPos().equals(pos)) { + final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos)); - @Override - public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { - if (worldIn.isRemote()) { - final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver; - if (rtr instanceof BlockRayTraceResult) { - BlockRayTraceResult brtr = (BlockRayTraceResult) rtr; - if (brtr.getPos().equals(pos)) { - final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos)); + if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) { + NetworkHandler.instance().sendToServer(new PacketClick(pos, brtr.getFace(), (float) hitVec.x, + (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true)); + } + } + } + } + } - if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) { - NetworkHandler.instance() - .sendToServer( - new PacketClick(pos, brtr.getFace(), (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true)); - } - } - } - } - } + public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) { + this.cb(worldIn, pos).clicked(playerIn, hand, hitVec); + } - public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) { - this.cb(worldIn, pos).clicked(playerIn, hand, hitVec); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + // Transform from world into block space + Vec3d hitVec = hit.getHitVec(); + Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ()); + return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS : ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { - // Transform from world into block space - Vec3d hitVec = hit.getHitVec(); - Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ()); - return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS - : ActionResultType.PASS; - } + @Override + public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) { + return recolorBlock(world, pos, side, color, null); + } - @Override - public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) { - return recolorBlock(world, pos, side, color, null); - } + public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side, + final DyeColor color, final PlayerEntity who) { + try { + return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who); + } catch (final Throwable ignored) { + } + return false; + } - public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side, final DyeColor color, final PlayerEntity who) { - try { - return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who); - } catch (final Throwable ignored) { - } - return false; - } - - @Override - @OnlyIn(Dist.CLIENT) - public void fillItemGroup(ItemGroup group, NonNullList itemStacks) { - // do nothing - } + @Override + @OnlyIn(Dist.CLIENT) + public void fillItemGroup(ItemGroup group, NonNullList itemStacks) { + // do nothing + } // FIXME FACADES @Override // FIXME FACADES public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side ) @@ -366,40 +375,38 @@ public class BlockCableBus extends AEBaseTileBlock /* FIXME implem // FIXME FACADES return world.getBlockState( pos ); // FIXME FACADES } - @Override - public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + @Override + public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - // FIXME: this has to be cached, optimized, fixed in all kinds of ways - TileCableBus te = getTileEntity(w, pos); - VoxelShape result = VoxelShapes.empty(); - if (te != null) { - for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), true)) { - result = VoxelShapes.or( - result, - VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)) - ); - } - } - return result; + // FIXME: this has to be cached, optimized, fixed in all kinds of ways + TileCableBus te = getTileEntity(w, pos); + VoxelShape result = VoxelShapes.empty(); + if (te != null) { + for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, + context.getEntity(), true)) { + result = VoxelShapes.or(result, + VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))); + } + } + return result; - } + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - // FIXME: this has to be cached, optimized, fixed in all kinds of ways - TileCableBus te = getTileEntity(w, pos); - VoxelShape result = VoxelShapes.empty(); - if (te != null) { - for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), false)) { - result = VoxelShapes.or( - result, - VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)) - ); - } - } - return result; + // FIXME: this has to be cached, optimized, fixed in all kinds of ways + TileCableBus te = getTileEntity(w, pos); + VoxelShape result = VoxelShapes.empty(); + if (te != null) { + for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, + context.getEntity(), false)) { + result = VoxelShapes.or(result, + VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))); + } + } + return result; - } + } } diff --git a/src/main/java/appeng/block/networking/BlockController.java b/src/main/java/appeng/block/networking/BlockController.java index abc88806f..4bfdfc42b 100644 --- a/src/main/java/appeng/block/networking/BlockController.java +++ b/src/main/java/appeng/block/networking/BlockController.java @@ -18,11 +18,9 @@ package appeng.block.networking; - import net.minecraft.block.Block; -import net.minecraft.block.material.Material; - import net.minecraft.block.BlockState; +import net.minecraft.block.material.Material; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.Direction; @@ -35,121 +33,109 @@ import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; import appeng.tile.networking.TileController; +public class BlockController extends AEBaseTileBlock { -public class BlockController extends AEBaseTileBlock -{ + public enum ControllerBlockState implements IStringSerializable { + offline, online, conflicted; - public enum ControllerBlockState implements IStringSerializable - { - offline, online, conflicted; + @Override + public String getName() { + return this.name(); + } - @Override - public String getName() - { - return this.name(); - } + } - } + /** + * Controls the rendering of the controller block (connected texture style). + * inside_a and inside_b are alternating patterns for a controller that is + * enclosed by other controllers, and since they are always offline, they do not + * have the usual sub-states. + */ + public enum ControllerRenderType implements IStringSerializable { + block, column_x, column_y, column_z, inside_a, inside_b; - /** - * Controls the rendering of the controller block (connected texture style). - * inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers, - * and since they are always offline, they do not have the usual sub-states. - */ - public enum ControllerRenderType implements IStringSerializable - { - block, column_x, column_y, column_z, inside_a, inside_b; + @Override + public String getName() { + return this.name(); + } - @Override - public String getName() - { - return this.name(); - } + } - } + public static final EnumProperty CONTROLLER_STATE = EnumProperty.create("state", + ControllerBlockState.class); - public static final EnumProperty CONTROLLER_STATE = EnumProperty.create( "state", ControllerBlockState.class ); + public static final EnumProperty CONTROLLER_TYPE = EnumProperty.create("type", + ControllerRenderType.class); - public static final EnumProperty CONTROLLER_TYPE = EnumProperty.create( "type", ControllerRenderType.class ); + public BlockController() { + super(defaultProps(Material.IRON).hardnessAndResistance(6)); + this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline) + .with(CONTROLLER_TYPE, ControllerRenderType.block)); + } - public BlockController() - { - super( defaultProps(Material.IRON).hardnessAndResistance(6) ); - this.setDefaultState( this.getDefaultState() - .with( CONTROLLER_STATE, ControllerBlockState.offline ) - .with( CONTROLLER_TYPE, ControllerRenderType.block ) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(CONTROLLER_STATE); + builder.add(CONTROLLER_TYPE); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(CONTROLLER_STATE); - builder.add(CONTROLLER_TYPE); - } + /** + * This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block + * states based on adjacent controllers and the network state of this controller + * (offline, online, conflicted). This is used to get a rudimentary connected + * texture feel for the controller based on how it is placed. + */ + @Override + public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, + BlockPos pos, BlockPos facingPos) { - /** - * This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent - * controllers and the network state of this controller (offline, online, conflicted). This is used to - * get a rudimentary connected texture feel for the controller based on how it is placed. - */ - @Override - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) { + // FIXME: this might work, or might _NOT_ work, but needs to be investigated - // FIXME: this might work, or might _NOT_ work, but needs to be investigated + // Only used for columns, really + ControllerRenderType type = ControllerRenderType.block; - // Only used for columns, really - ControllerRenderType type = ControllerRenderType.block; + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); + // Detect whether controllers are on both sides of the x, y, and z axes + final boolean xx = this.getTileEntity(world, x - 1, y, z) != null + && this.getTileEntity(world, x + 1, y, z) != null; + final boolean yy = this.getTileEntity(world, x, y - 1, z) != null + && this.getTileEntity(world, x, y + 1, z) != null; + final boolean zz = this.getTileEntity(world, x, y, z - 1) != null + && this.getTileEntity(world, x, y, z + 1) != null; - // Detect whether controllers are on both sides of the x, y, and z axes - final boolean xx = this.getTileEntity(world, x - 1, y, z) != null - && this.getTileEntity(world, x + 1, y, z) != null; - final boolean yy = this.getTileEntity(world, x, y - 1, z) != null - && this.getTileEntity(world, x, y + 1, z) != null; - final boolean zz = this.getTileEntity(world, x, y, z - 1) != null - && this.getTileEntity(world, x, y, z + 1) != null; + if (xx && !yy && !zz) { + type = ControllerRenderType.column_x; + } else if (!xx && yy && !zz) { + type = ControllerRenderType.column_y; + } else if (!xx && !yy && zz) { + type = ControllerRenderType.column_z; + } else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) { + final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2; - if( xx && !yy && !zz ) - { - type = ControllerRenderType.column_x; - } - else if( !xx && yy && !zz ) - { - type = ControllerRenderType.column_y; - } - else if( !xx && !yy && zz ) - { - type = ControllerRenderType.column_z; - } - else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 ) - { - final int v = ( Math.abs( x ) + Math.abs( y ) + Math.abs( z ) ) % 2; + // While i'd like this to be based on the blockstate randomization feature, this + // generates + // an alternating pattern based on world position, so this is not 100% doable + // with blockstates. + if (v == 0) { + type = ControllerRenderType.inside_a; + } else { + type = ControllerRenderType.inside_b; + } + } - // While i'd like this to be based on the blockstate randomization feature, this generates - // an alternating pattern based on world position, so this is not 100% doable with blockstates. - if( v == 0 ) - { - type = ControllerRenderType.inside_a; - } - else - { - type = ControllerRenderType.inside_b; - } - } + return state.with(CONTROLLER_TYPE, type); + } - return state.with( CONTROLLER_TYPE, type ); - } - - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileController tc = this.getTileEntity( world, pos ); - if( tc != null ) - { - tc.onNeighborChange( false ); - } - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileController tc = this.getTileEntity(world, pos); + if (tc != null) { + tc.onNeighborChange(false); + } + } } diff --git a/src/main/java/appeng/block/networking/BlockCreativeEnergyCell.java b/src/main/java/appeng/block/networking/BlockCreativeEnergyCell.java index ad1dede55..519390c12 100644 --- a/src/main/java/appeng/block/networking/BlockCreativeEnergyCell.java +++ b/src/main/java/appeng/block/networking/BlockCreativeEnergyCell.java @@ -18,17 +18,13 @@ package appeng.block.networking; - import appeng.block.AEBaseTileBlock; import appeng.helpers.AEGlassMaterial; import appeng.tile.networking.TileCreativeEnergyCell; +public class BlockCreativeEnergyCell extends AEBaseTileBlock { -public class BlockCreativeEnergyCell extends AEBaseTileBlock -{ - - public BlockCreativeEnergyCell() - { - super( defaultProps(AEGlassMaterial.INSTANCE) ); - } + public BlockCreativeEnergyCell() { + super(defaultProps(AEGlassMaterial.INSTANCE)); + } } diff --git a/src/main/java/appeng/block/networking/BlockDenseEnergyCell.java b/src/main/java/appeng/block/networking/BlockDenseEnergyCell.java index 7ff50c435..fadeeac3b 100644 --- a/src/main/java/appeng/block/networking/BlockDenseEnergyCell.java +++ b/src/main/java/appeng/block/networking/BlockDenseEnergyCell.java @@ -18,18 +18,14 @@ package appeng.block.networking; +public class BlockDenseEnergyCell extends BlockEnergyCell { -public class BlockDenseEnergyCell extends BlockEnergyCell -{ + public BlockDenseEnergyCell() { - public BlockDenseEnergyCell() - { + } - } - - @Override - public double getMaxPower() - { - return 200000.0 * 8.0; - } + @Override + public double getMaxPower() { + return 200000.0 * 8.0; + } } diff --git a/src/main/java/appeng/block/networking/BlockEnergyAcceptor.java b/src/main/java/appeng/block/networking/BlockEnergyAcceptor.java index 4d36dc85b..170cc364c 100644 --- a/src/main/java/appeng/block/networking/BlockEnergyAcceptor.java +++ b/src/main/java/appeng/block/networking/BlockEnergyAcceptor.java @@ -18,19 +18,15 @@ package appeng.block.networking; - -import appeng.tile.networking.TileEnergyAcceptor; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import appeng.block.AEBaseTileBlock; +import appeng.tile.networking.TileEnergyAcceptor; +public class BlockEnergyAcceptor extends AEBaseTileBlock { -public class BlockEnergyAcceptor extends AEBaseTileBlock -{ - - public BlockEnergyAcceptor() - { - super(defaultProps(Material.IRON) ); - } + public BlockEnergyAcceptor() { + super(defaultProps(Material.IRON)); + } } diff --git a/src/main/java/appeng/block/networking/BlockEnergyCell.java b/src/main/java/appeng/block/networking/BlockEnergyCell.java index 062a050d2..da6e5965b 100644 --- a/src/main/java/appeng/block/networking/BlockEnergyCell.java +++ b/src/main/java/appeng/block/networking/BlockEnergyCell.java @@ -18,8 +18,6 @@ package appeng.block.networking; - -import appeng.tile.networking.TileEnergyCell; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; @@ -33,40 +31,37 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.block.AEBaseTileBlock; import appeng.helpers.AEGlassMaterial; +import appeng.tile.networking.TileEnergyCell; -public class BlockEnergyCell extends AEBaseTileBlock -{ +public class BlockEnergyCell extends AEBaseTileBlock { - public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create( "fullness", 0, 7 ); + public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7); - public BlockEnergyCell() - { - super( defaultProps(AEGlassMaterial.INSTANCE) ); - } + public BlockEnergyCell() { + super(defaultProps(AEGlassMaterial.INSTANCE)); + } - @Override - @OnlyIn( Dist.CLIENT ) - public void fillItemGroup(ItemGroup group, NonNullList itemStacks) - { - super.fillItemGroup( group, itemStacks ); + @Override + @OnlyIn(Dist.CLIENT) + public void fillItemGroup(ItemGroup group, NonNullList itemStacks) { + super.fillItemGroup(group, itemStacks); - final ItemStack charged = new ItemStack(this, 1); - final CompoundNBT tag = charged.getOrCreateTag(); - tag.putDouble("internalCurrentPower", this.getMaxPower()); - tag.putDouble("internalMaxPower", this.getMaxPower()); + final ItemStack charged = new ItemStack(this, 1); + final CompoundNBT tag = charged.getOrCreateTag(); + tag.putDouble("internalCurrentPower", this.getMaxPower()); + tag.putDouble("internalMaxPower", this.getMaxPower()); - itemStacks.add(charged); - } + itemStacks.add(charged); + } - public double getMaxPower() - { - return 200000.0; - } + public double getMaxPower() { + return 200000.0; + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(ENERGY_STORAGE); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(ENERGY_STORAGE); + } } diff --git a/src/main/java/appeng/block/networking/BlockEnergyCellRendering.java b/src/main/java/appeng/block/networking/BlockEnergyCellRendering.java index ea4699881..c2892cb24 100644 --- a/src/main/java/appeng/block/networking/BlockEnergyCellRendering.java +++ b/src/main/java/appeng/block/networking/BlockEnergyCellRendering.java @@ -18,7 +18,6 @@ package appeng.block.networking; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,21 +27,17 @@ import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; - // FIXME REMOVE -public class BlockEnergyCellRendering extends BlockRenderingCustomizer -{ +public class BlockEnergyCellRendering extends BlockRenderingCustomizer { - private final ResourceLocation baseModel; + private final ResourceLocation baseModel; - public BlockEnergyCellRendering( ResourceLocation baseModel ) - { - this.baseModel = baseModel; - } + public BlockEnergyCellRendering(ResourceLocation baseModel) { + this.baseModel = baseModel; + } - @Override - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - // Note: Since we use the block models, we dont need to register custom variants - } + @Override + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + // Note: Since we use the block models, we dont need to register custom variants + } } diff --git a/src/main/java/appeng/block/networking/BlockWireless.java b/src/main/java/appeng/block/networking/BlockWireless.java index a7fe25b35..10c04f04f 100644 --- a/src/main/java/appeng/block/networking/BlockWireless.java +++ b/src/main/java/appeng/block/networking/BlockWireless.java @@ -18,14 +18,6 @@ package appeng.block.networking; - -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerWireless; -import appeng.helpers.AEGlassMaterial; -import appeng.tile.networking.TileWireless; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -46,200 +38,192 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerWireless; +import appeng.helpers.AEGlassMaterial; +import appeng.tile.networking.TileWireless; +import appeng.util.Platform; -public class BlockWireless extends AEBaseTileBlock -{ +public class BlockWireless extends AEBaseTileBlock { - enum State implements IStringSerializable - { - OFF, - ON, - HAS_CHANNEL; + enum State implements IStringSerializable { + OFF, ON, HAS_CHANNEL; - @Override - public String getName() - { - return this.name().toLowerCase(); - } - } + @Override + public String getName() { + return this.name().toLowerCase(); + } + } - public static final EnumProperty STATE = EnumProperty.create( "state", State.class ); + public static final EnumProperty STATE = EnumProperty.create("state", State.class); - public BlockWireless() - { - super( defaultProps(AEGlassMaterial.INSTANCE).notSolid() ); - this.setFullSize( false ); - this.setOpaque( false ); - this.setDefaultState( this.getDefaultState().with( STATE, State.OFF ) ); - } + public BlockWireless() { + super(defaultProps(AEGlassMaterial.INSTANCE).notSolid()); + this.setFullSize(false); + this.setOpaque(false); + this.setDefaultState(this.getDefaultState().with(STATE, State.OFF)); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) { - State teState = State.OFF; + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) { + State teState = State.OFF; - if( te.isActive() ) - { - teState = State.HAS_CHANNEL; - } - else if( te.isPowered() ) - { - teState = State.ON; - } + if (te.isActive()) { + teState = State.HAS_CHANNEL; + } else if (te.isPowered()) { + teState = State.ON; + } - return currentState.with(STATE, teState); - } + return currentState.with(STATE, teState); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(STATE); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(STATE); + } - @Override - public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - final TileWireless tg = this.getTileEntity( w, pos ); + @Override + public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, + BlockRayTraceResult hit) { + final TileWireless tg = this.getTileEntity(w, pos); - if( tg != null && !player.isCrouching() ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerWireless.TYPE, player, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } + if (tg != null && !player.isCrouching()) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerWireless.TYPE, player, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } - return super.onBlockActivated( state, w, pos, player, hand, hit ); - } + return super.onBlockActivated(state, w, pos, player, hand, hit); + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - final TileWireless tile = this.getTileEntity( w, pos ); - if( tile != null ) - { - final Direction forward = tile.getForward(); + @Override + public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + final TileWireless tile = this.getTileEntity(w, pos); + if (tile != null) { + final Direction forward = tile.getForward(); - double minX = 0; - double minY = 0; - double minZ = 0; - double maxX = 1; - double maxY = 1; - double maxZ = 1; + double minX = 0; + double minY = 0; + double minZ = 0; + double maxX = 1; + double maxY = 1; + double maxZ = 1; - switch( forward ) - { - case DOWN: - minZ = minX = 3.0 / 16.0; - maxZ = maxX = 13.0 / 16.0; - maxY = 1.0; - minY = 5.0 / 16.0; - break; - case EAST: - minZ = minY = 3.0 / 16.0; - maxZ = maxY = 13.0 / 16.0; - maxX = 11.0 / 16.0; - minX = 0.0; - break; - case NORTH: - minY = minX = 3.0 / 16.0; - maxY = maxX = 13.0 / 16.0; - maxZ = 1.0; - minZ = 5.0 / 16.0; - break; - case SOUTH: - minY = minX = 3.0 / 16.0; - maxY = maxX = 13.0 / 16.0; - maxZ = 11.0 / 16.0; - minZ = 0.0; - break; - case UP: - minZ = minX = 3.0 / 16.0; - maxZ = maxX = 13.0 / 16.0; - maxY = 11.0 / 16.0; - minY = 0.0; - break; - case WEST: - minZ = minY = 3.0 / 16.0; - maxZ = maxY = 13.0 / 16.0; - maxX = 1.0; - minX = 5.0 / 16.0; - break; - default: - break; - } + switch (forward) { + case DOWN: + minZ = minX = 3.0 / 16.0; + maxZ = maxX = 13.0 / 16.0; + maxY = 1.0; + minY = 5.0 / 16.0; + break; + case EAST: + minZ = minY = 3.0 / 16.0; + maxZ = maxY = 13.0 / 16.0; + maxX = 11.0 / 16.0; + minX = 0.0; + break; + case NORTH: + minY = minX = 3.0 / 16.0; + maxY = maxX = 13.0 / 16.0; + maxZ = 1.0; + minZ = 5.0 / 16.0; + break; + case SOUTH: + minY = minX = 3.0 / 16.0; + maxY = maxX = 13.0 / 16.0; + maxZ = 11.0 / 16.0; + minZ = 0.0; + break; + case UP: + minZ = minX = 3.0 / 16.0; + maxZ = maxX = 13.0 / 16.0; + maxY = 11.0 / 16.0; + minY = 0.0; + break; + case WEST: + minZ = minY = 3.0 / 16.0; + maxZ = maxY = 13.0 / 16.0; + maxX = 1.0; + minX = 5.0 / 16.0; + break; + default: + break; + } - return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); - } - return VoxelShapes.empty(); - } + return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ)); + } + return VoxelShapes.empty(); + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { - final TileWireless tile = this.getTileEntity( w, pos ); - if( tile != null ) - { - final Direction forward = tile.getForward(); + final TileWireless tile = this.getTileEntity(w, pos); + if (tile != null) { + final Direction forward = tile.getForward(); - double minX = 0; - double minY = 0; - double minZ = 0; - double maxX = 1; - double maxY = 1; - double maxZ = 1; + double minX = 0; + double minY = 0; + double minZ = 0; + double maxX = 1; + double maxY = 1; + double maxZ = 1; - switch( forward ) - { - case DOWN: - minZ = minX = 3.0 / 16.0; - maxZ = maxX = 13.0 / 16.0; - maxY = 1.0; - minY = 5.0 / 16.0; - break; - case EAST: - minZ = minY = 3.0 / 16.0; - maxZ = maxY = 13.0 / 16.0; - maxX = 11.0 / 16.0; - minX = 0.0; - break; - case NORTH: - minY = minX = 3.0 / 16.0; - maxY = maxX = 13.0 / 16.0; - maxZ = 1.0; - minZ = 5.0 / 16.0; - break; - case SOUTH: - minY = minX = 3.0 / 16.0; - maxY = maxX = 13.0 / 16.0; - maxZ = 11.0 / 16.0; - minZ = 0.0; - break; - case UP: - minZ = minX = 3.0 / 16.0; - maxZ = maxX = 13.0 / 16.0; - maxY = 11.0 / 16.0; - minY = 0.0; - break; - case WEST: - minZ = minY = 3.0 / 16.0; - maxZ = maxY = 13.0 / 16.0; - maxX = 1.0; - minX = 5.0 / 16.0; - break; - default: - break; - } + switch (forward) { + case DOWN: + minZ = minX = 3.0 / 16.0; + maxZ = maxX = 13.0 / 16.0; + maxY = 1.0; + minY = 5.0 / 16.0; + break; + case EAST: + minZ = minY = 3.0 / 16.0; + maxZ = maxY = 13.0 / 16.0; + maxX = 11.0 / 16.0; + minX = 0.0; + break; + case NORTH: + minY = minX = 3.0 / 16.0; + maxY = maxX = 13.0 / 16.0; + maxZ = 1.0; + minZ = 5.0 / 16.0; + break; + case SOUTH: + minY = minX = 3.0 / 16.0; + maxY = maxX = 13.0 / 16.0; + maxZ = 11.0 / 16.0; + minZ = 0.0; + break; + case UP: + minZ = minX = 3.0 / 16.0; + maxZ = maxX = 13.0 / 16.0; + maxY = 11.0 / 16.0; + minY = 0.0; + break; + case WEST: + minZ = minY = 3.0 / 16.0; + maxZ = maxY = 13.0 / 16.0; + maxX = 1.0; + minX = 5.0 / 16.0; + break; + default: + break; + } - return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); - } - else - { - return VoxelShapes.empty(); - } - } + return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ)); + } else { + return VoxelShapes.empty(); + } + } - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { - return true; - } + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { + return true; + } } diff --git a/src/main/java/appeng/block/networking/CableBusColor.java b/src/main/java/appeng/block/networking/CableBusColor.java index 0c086da8a..aaf0e2417 100644 --- a/src/main/java/appeng/block/networking/CableBusColor.java +++ b/src/main/java/appeng/block/networking/CableBusColor.java @@ -18,9 +18,8 @@ package appeng.block.networking; +import javax.annotation.Nullable; -import appeng.parts.CableBusContainer; -import appeng.tile.networking.TileCableBus; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.tileentity.TileEntity; @@ -32,32 +31,31 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.util.AEColor; import appeng.client.render.cablebus.CableBusRenderState; - -import javax.annotation.Nullable; - +import appeng.parts.CableBusContainer; +import appeng.tile.networking.TileCableBus; /** - * Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant). + * Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium + * variant) and 2 (bright variant). */ -@OnlyIn( Dist.CLIENT ) -public class CableBusColor implements IBlockColor -{ +@OnlyIn(Dist.CLIENT) +public class CableBusColor implements IBlockColor { - @Override - public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) { + @Override + public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) { - // FIXME: Once COLOR becomes part of the block state, change this - AEColor busColor = AEColor.TRANSPARENT; + // FIXME: Once COLOR becomes part of the block state, change this + AEColor busColor = AEColor.TRANSPARENT; - if (worldIn != null && pos != null) { - TileEntity tileEntity = worldIn.getTileEntity(pos); - if (tileEntity instanceof TileCableBus) { - CableBusContainer container = ((TileCableBus) tileEntity).getCableBus(); - busColor = container.getColor(); - } - } + if (worldIn != null && pos != null) { + TileEntity tileEntity = worldIn.getTileEntity(pos); + if (tileEntity instanceof TileCableBus) { + CableBusContainer container = ((TileCableBus) tileEntity).getCableBus(); + busColor = container.getColor(); + } + } - return busColor.getVariantByTintIndex( color ); + return busColor.getVariantByTintIndex(color); - } + } } diff --git a/src/main/java/appeng/block/networking/CableBusRendering.java b/src/main/java/appeng/block/networking/CableBusRendering.java index 9671e63da..2a1023018 100644 --- a/src/main/java/appeng/block/networking/CableBusRendering.java +++ b/src/main/java/appeng/block/networking/CableBusRendering.java @@ -18,7 +18,6 @@ package appeng.block.networking; - import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -28,28 +27,24 @@ import appeng.bootstrap.IItemRendering; import appeng.client.render.cablebus.CableBusModel; import appeng.core.features.registries.PartModels; - /** - * Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2. + * Customizes the rendering behavior for cable busses, which are the biggest + * multipart of AE2. */ -public class CableBusRendering extends BlockRenderingCustomizer -{ +public class CableBusRendering extends BlockRenderingCustomizer { - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - /* FIXME this was previously - * - @Override - public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer ) - { - return true; - } - */ - rendering.renderType(rt -> true); + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + /* + * FIXME this was previously + * + * @Override public boolean canRenderInLayer( BlockState state, BlockRenderLayer + * layer ) { return true; } + */ + rendering.renderType(rt -> true); - rendering.blockColor( new CableBusColor() ); - rendering.modelCustomizer( ( loc, model ) -> model ); - } + rendering.blockColor(new CableBusColor()); + rendering.modelCustomizer((loc, model) -> model); + } } diff --git a/src/main/java/appeng/block/networking/ControllerRendering.java b/src/main/java/appeng/block/networking/ControllerRendering.java index fe4185c9a..22922b97b 100644 --- a/src/main/java/appeng/block/networking/ControllerRendering.java +++ b/src/main/java/appeng/block/networking/ControllerRendering.java @@ -18,20 +18,17 @@ package appeng.block.networking; +import net.minecraft.client.renderer.RenderType; import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; -import net.minecraft.client.renderer.RenderType; - -public class ControllerRendering extends BlockRenderingCustomizer -{ - @Override - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - // Disables the default model rotator - rendering.modelCustomizer( ( loc, model ) -> model ); - rendering.renderType(RenderType.getCutout()); - } +public class ControllerRendering extends BlockRenderingCustomizer { + @Override + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + // Disables the default model rotator + rendering.modelCustomizer((loc, model) -> model); + rendering.renderType(RenderType.getCutout()); + } } diff --git a/src/main/java/appeng/block/networking/WirelessRendering.java b/src/main/java/appeng/block/networking/WirelessRendering.java index f47123dd8..a09789711 100644 --- a/src/main/java/appeng/block/networking/WirelessRendering.java +++ b/src/main/java/appeng/block/networking/WirelessRendering.java @@ -1,7 +1,6 @@ package appeng.block.networking; - import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -12,14 +11,11 @@ import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; import appeng.client.render.StaticBlockColor; - -public class WirelessRendering extends BlockRenderingCustomizer -{ - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) ); - } +public class WirelessRendering extends BlockRenderingCustomizer { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT)); + } } diff --git a/src/main/java/appeng/block/paint/BlockPaint.java b/src/main/java/appeng/block/paint/BlockPaint.java index 06cf8156c..174b6b74d 100644 --- a/src/main/java/appeng/block/paint/BlockPaint.java +++ b/src/main/java/appeng/block/paint/BlockPaint.java @@ -18,10 +18,6 @@ package appeng.block.paint; - -import appeng.block.AEBaseTileBlock; -import appeng.tile.misc.TilePaint; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -40,75 +36,69 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.block.AEBaseTileBlock; +import appeng.tile.misc.TilePaint; +import appeng.util.Platform; -public class BlockPaint extends AEBaseTileBlock -{ - public BlockPaint() - { - super(defaultProps(Material.WATER, MaterialColor.AIR)); - this.setFullSize( false ); - this.setOpaque( false ); - } +public class BlockPaint extends AEBaseTileBlock { + public BlockPaint() { + super(defaultProps(Material.WATER, MaterialColor.AIR)); + this.setFullSize(false); + this.setOpaque(false); + } - @Override - @OnlyIn( Dist.CLIENT ) - public void fillItemGroup(ItemGroup group, NonNullList itemStacks) - { - // do nothing - } + @Override + @OnlyIn(Dist.CLIENT) + public void fillItemGroup(ItemGroup group, NonNullList itemStacks) { + // do nothing + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.empty(); - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return VoxelShapes.empty(); + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TilePaint tp = this.getTileEntity( world, pos ); + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TilePaint tp = this.getTileEntity(world, pos); - if( tp != null ) - { - tp.neighborChanged(); - } - } + if (tp != null) { + tp.neighborChanged(); + } + } - @Override - public void fillWithRain( final World w, final BlockPos pos ) - { - if( Platform.isServer() ) - { - w.removeBlock(pos, false); - } - } + @Override + public void fillWithRain(final World w, final BlockPos pos) { + if (Platform.isServer()) { + w.removeBlock(pos, false); + } + } - @Override - public int getLightValue( final BlockState state, final IBlockReader w, final BlockPos pos ) - { - final TilePaint tp = this.getTileEntity( w, pos ); + @Override + public int getLightValue(final BlockState state, final IBlockReader w, final BlockPos pos) { + final TilePaint tp = this.getTileEntity(w, pos); - if( tp != null ) - { - return tp.getLightLevel(); - } + if (tp != null) { + return tp.getLightLevel(); + } - return 0; - } + return 0; + } - @Override - public boolean isAir( final BlockState state, final IBlockReader world, final BlockPos pos ) - { - return true; - } + @Override + public boolean isAir(final BlockState state, final IBlockReader world, final BlockPos pos) { + return true; + } - @Override - public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { - return true; - } + @Override + public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { + return true; + } - @Override - public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) { - return true; - } + @Override + public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) { + return true; + } } diff --git a/src/main/java/appeng/block/paint/PaintRendering.java b/src/main/java/appeng/block/paint/PaintRendering.java index 3350faf61..e222edf1c 100644 --- a/src/main/java/appeng/block/paint/PaintRendering.java +++ b/src/main/java/appeng/block/paint/PaintRendering.java @@ -1,7 +1,6 @@ package appeng.block.paint; - import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -10,16 +9,13 @@ import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; +public class PaintRendering extends BlockRenderingCustomizer { -public class PaintRendering extends BlockRenderingCustomizer -{ - - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - // Disable auto rotation - rendering.modelCustomizer( ( location, model ) -> model ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + // Disable auto rotation + rendering.modelCustomizer((location, model) -> model); + } } diff --git a/src/main/java/appeng/block/paint/PaintSplotches.java b/src/main/java/appeng/block/paint/PaintSplotches.java index 84bb2b647..12186459b 100644 --- a/src/main/java/appeng/block/paint/PaintSplotches.java +++ b/src/main/java/appeng/block/paint/PaintSplotches.java @@ -1,7 +1,6 @@ package appeng.block.paint; - import java.util.Collection; import java.util.List; @@ -9,23 +8,20 @@ import com.google.common.collect.ImmutableList; import appeng.helpers.Splotch; - /** - * Used to transfer the state about paint splotches from the game thread to the render thread. + * Used to transfer the state about paint splotches from the game thread to the + * render thread. */ -public class PaintSplotches -{ +public class PaintSplotches { - private final List splotches; + private final List splotches; - public PaintSplotches( Collection splotches ) - { - this.splotches = ImmutableList.copyOf( splotches ); - } + public PaintSplotches(Collection splotches) { + this.splotches = ImmutableList.copyOf(splotches); + } - List getSplotches() - { - return this.splotches; - } + List getSplotches() { + return this.splotches; + } } diff --git a/src/main/java/appeng/block/paint/PaintSplotchesBakedModel.java b/src/main/java/appeng/block/paint/PaintSplotchesBakedModel.java index 12e928db4..116b76f16 100644 --- a/src/main/java/appeng/block/paint/PaintSplotchesBakedModel.java +++ b/src/main/java/appeng/block/paint/PaintSplotchesBakedModel.java @@ -1,7 +1,6 @@ package appeng.block.paint; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -11,7 +10,6 @@ import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import appeng.tile.misc.TilePaint; import com.google.common.collect.ImmutableList; import net.minecraft.block.BlockState; @@ -24,172 +22,158 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.data.IDynamicBakedModel; +import net.minecraftforge.client.model.data.IModelData; import appeng.client.render.cablebus.CubeBuilder; import appeng.core.AppEng; import appeng.helpers.Splotch; -import net.minecraftforge.client.model.data.IDynamicBakedModel; -import net.minecraftforge.client.model.data.IModelData; - +import appeng.tile.misc.TilePaint; /** - * Renders paint blocks, which render multiple "splotches" that have been applied to the sides of adjacent blocks using - * a - * matter cannon with paint balls. + * Renders paint blocks, which render multiple "splotches" that have been + * applied to the sides of adjacent blocks using a matter cannon with paint + * balls. */ -class PaintSplotchesBakedModel implements IDynamicBakedModel -{ +class PaintSplotchesBakedModel implements IDynamicBakedModel { - private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/paint1" )); - private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint2" )); - private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint3" )); + private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/paint1")); + private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/paint2")); + private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/paint3")); - private final TextureAtlasSprite[] textures; + private final TextureAtlasSprite[] textures; - PaintSplotchesBakedModel(Function bakedTextureGetter ) - { - this.textures = new TextureAtlasSprite[] { - bakedTextureGetter.apply( TEXTURE_PAINT1 ), - bakedTextureGetter.apply( TEXTURE_PAINT2 ), - bakedTextureGetter.apply( TEXTURE_PAINT3 ) - }; - } + PaintSplotchesBakedModel(Function bakedTextureGetter) { + this.textures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1), + bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) }; + } - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, + @Nonnull IModelData extraData) { - if( side != null ) - { - return Collections.emptyList(); - } + if (side != null) { + return Collections.emptyList(); + } - PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES); + PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES); - if( splotchesState == null ) - { - // This is the inventory model which should usually not be used other than in special cases - List quads = new ArrayList<>( 1 ); - CubeBuilder builder = new CubeBuilder( quads ); - builder.setTexture( this.textures[0] ); - builder.addCube( 0, 0, 0, 16, 16, 16 ); - return quads; - } + if (splotchesState == null) { + // This is the inventory model which should usually not be used other than in + // special cases + List quads = new ArrayList<>(1); + CubeBuilder builder = new CubeBuilder(quads); + builder.setTexture(this.textures[0]); + builder.addCube(0, 0, 0, 16, 16, 16); + return quads; + } - List splotches = splotchesState.getSplotches(); + List splotches = splotchesState.getSplotches(); - CubeBuilder builder = new CubeBuilder( ); + CubeBuilder builder = new CubeBuilder(); - float offsetConstant = 0.001f; - for( final Splotch s : splotches ) - { + float offsetConstant = 0.001f; + for (final Splotch s : splotches) { - if( s.isLumen() ) - { - builder.setColorRGB( s.getColor().whiteVariant ); - builder.setRenderFullBright( true ); - } - else - { - builder.setColorRGB( s.getColor().mediumVariant ); - builder.setRenderFullBright( false ); - } + if (s.isLumen()) { + builder.setColorRGB(s.getColor().whiteVariant); + builder.setRenderFullBright(true); + } else { + builder.setColorRGB(s.getColor().mediumVariant); + builder.setRenderFullBright(false); + } - float offset = offsetConstant; - offsetConstant += 0.001f; + float offset = offsetConstant; + offsetConstant += 0.001f; - final float buffer = 0.1f; + final float buffer = 0.1f; - float pos_x = s.x(); - float pos_y = s.y(); + float pos_x = s.x(); + float pos_y = s.y(); - pos_x = Math.max( buffer, Math.min( 1.0f - buffer, pos_x ) ); - pos_y = Math.max( buffer, Math.min( 1.0f - buffer, pos_y ) ); + pos_x = Math.max(buffer, Math.min(1.0f - buffer, pos_x)); + pos_y = Math.max(buffer, Math.min(1.0f - buffer, pos_y)); - TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length]; - builder.setTexture( ico ); - builder.setCustomUv( s.getSide().getOpposite(), 0, 0, 16, 16 ); + TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length]; + builder.setTexture(ico); + builder.setCustomUv(s.getSide().getOpposite(), 0, 0, 16, 16); - switch( s.getSide() ) - { - case UP: - offset = 1.0f - offset; - builder.addQuad( Direction.DOWN, pos_x - buffer, offset, pos_y - buffer, - pos_x + buffer, offset, pos_y + buffer ); - break; + switch (s.getSide()) { + case UP: + offset = 1.0f - offset; + builder.addQuad(Direction.DOWN, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset, + pos_y + buffer); + break; - case DOWN: - builder.addQuad( Direction.UP, pos_x - buffer, offset, pos_y - buffer, - pos_x + buffer, offset, pos_y + buffer ); - break; + case DOWN: + builder.addQuad(Direction.UP, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset, + pos_y + buffer); + break; - case EAST: - offset = 1.0f - offset; - builder.addQuad( Direction.WEST, offset, pos_x - buffer, pos_y - buffer, - offset, pos_x + buffer, pos_y + buffer ); - break; + case EAST: + offset = 1.0f - offset; + builder.addQuad(Direction.WEST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer, + pos_y + buffer); + break; - case WEST: - builder.addQuad( Direction.EAST, offset, pos_x - buffer, pos_y - buffer, - offset, pos_x + buffer, pos_y + buffer ); - break; + case WEST: + builder.addQuad(Direction.EAST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer, + pos_y + buffer); + break; - case SOUTH: - offset = 1.0f - offset; - builder.addQuad( Direction.NORTH, pos_x - buffer, pos_y - buffer, offset, - pos_x + buffer, pos_y + buffer, offset ); - break; + case SOUTH: + offset = 1.0f - offset; + builder.addQuad(Direction.NORTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer, + pos_y + buffer, offset); + break; - case NORTH: - builder.addQuad( Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset, - pos_x + buffer, pos_y + buffer, offset ); - break; + case NORTH: + builder.addQuad(Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer, + pos_y + buffer, offset); + break; - default: - } - } + default: + } + } - return builder.getOutput(); - } + return builder.getOutput(); + } - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return true; - } + @Override + public boolean isGui3d() { + return true; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.textures[0]; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.textures[0]; + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } - @Override - public boolean func_230044_c_() { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - static List getRequiredTextures() - { - return ImmutableList.of( - TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3 ); - } + static List getRequiredTextures() { + return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3); + } } diff --git a/src/main/java/appeng/block/paint/PaintSplotchesModel.java b/src/main/java/appeng/block/paint/PaintSplotchesModel.java index 7d5f1febe..a77890439 100644 --- a/src/main/java/appeng/block/paint/PaintSplotchesModel.java +++ b/src/main/java/appeng/block/paint/PaintSplotchesModel.java @@ -1,30 +1,31 @@ package appeng.block.paint; +import java.util.Collection; +import java.util.Set; +import java.util.function.Function; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; +public class PaintSplotchesModel implements IModelGeometry { + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + return new PaintSplotchesBakedModel(spriteGetter); + } -public class PaintSplotchesModel implements IModelGeometry -{ - - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - return new PaintSplotchesBakedModel( spriteGetter ); - } - - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return PaintSplotchesBakedModel.getRequiredTextures(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return PaintSplotchesBakedModel.getRequiredTextures(); + } } diff --git a/src/main/java/appeng/block/qnb/BlockQuantumBase.java b/src/main/java/appeng/block/qnb/BlockQuantumBase.java index b019fc964..5004da373 100644 --- a/src/main/java/appeng/block/qnb/BlockQuantumBase.java +++ b/src/main/java/appeng/block/qnb/BlockQuantumBase.java @@ -18,9 +18,6 @@ package appeng.block.qnb; - -import appeng.block.AEBaseTileBlock; -import appeng.tile.qnb.TileQuantumBridge; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.state.BooleanProperty; @@ -35,64 +32,63 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import appeng.block.AEBaseTileBlock; +import appeng.tile.qnb.TileQuantumBridge; -public abstract class BlockQuantumBase extends AEBaseTileBlock -{ +public abstract class BlockQuantumBase extends AEBaseTileBlock { - public static final BooleanProperty FORMED = BooleanProperty.create( "formed" ); + public static final BooleanProperty FORMED = BooleanProperty.create("formed"); - private static final VoxelShape SHAPE; + private static final VoxelShape SHAPE; - static { - final float shave = 2.0f / 16.0f; - SHAPE = VoxelShapes.create(new AxisAlignedBB(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave)); - } + static { + final float shave = 2.0f / 16.0f; + SHAPE = VoxelShapes.create(new AxisAlignedBB(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave)); + } - public BlockQuantumBase(Block.Properties props) { - super(props); - this.setFullSize(this.setOpaque(false)); - this.setDefaultState(this.getDefaultState().with(FORMED, false)); - } + public BlockQuantumBase(Block.Properties props) { + super(props); + this.setFullSize(this.setOpaque(false)); + this.setDefaultState(this.getDefaultState().with(FORMED, false)); + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return SHAPE; - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(FORMED); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(FORMED); + } - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuantumBridge te) { - return currentState.with(FORMED, te.isFormed()); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuantumBridge te) { + return currentState.with(FORMED, te.isFormed()); + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileQuantumBridge bridge = this.getTileEntity( world, pos ); - if( bridge != null ) - { - bridge.neighborUpdate(); - } - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileQuantumBridge bridge = this.getTileEntity(world, pos); + if (bridge != null) { + bridge.neighborUpdate(); + } + } - @Override - public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { - if (newState.getBlock() == state.getBlock()) { - return; // Just a block state change - } + @Override + public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() == state.getBlock()) { + return; // Just a block state change + } - final TileQuantumBridge bridge = this.getTileEntity( w, pos ); - if( bridge != null ) - { - bridge.breakCluster(); - } + final TileQuantumBridge bridge = this.getTileEntity(w, pos); + if (bridge != null) { + bridge.breakCluster(); + } - super.onReplaced( state, w, pos, newState, isMoving ); - } + super.onReplaced(state, w, pos, newState, isMoving); + } } diff --git a/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java b/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java index f4f3a70e5..a267d34d7 100644 --- a/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java +++ b/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java @@ -18,16 +18,12 @@ package appeng.block.qnb; - import java.util.Collections; import java.util.List; import java.util.Random; import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerQNB; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -46,67 +42,61 @@ import net.minecraft.world.World; import appeng.api.util.AEPartLocation; import appeng.client.EffectType; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerQNB; import appeng.core.AppEng; - import appeng.helpers.AEGlassMaterial; import appeng.tile.qnb.TileQuantumBridge; import appeng.util.Platform; +public class BlockQuantumLinkChamber extends BlockQuantumBase { -public class BlockQuantumLinkChamber extends BlockQuantumBase -{ + private static final VoxelShape SHAPE; - private static final VoxelShape SHAPE; + static { + final double onePixel = 2.0 / 16.0; + SHAPE = VoxelShapes.create( + new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel)); + } - static { - final double onePixel = 2.0 / 16.0; - SHAPE = VoxelShapes.create( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) ); - } + public BlockQuantumLinkChamber() { + super(defaultProps(AEGlassMaterial.INSTANCE)); + } - public BlockQuantumLinkChamber() - { - super(defaultProps(AEGlassMaterial.INSTANCE) ); - } + @Override + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random rand) { + final TileQuantumBridge bridge = this.getTileEntity(w, pos); + if (bridge != null) { + if (bridge.hasQES()) { + if (AppEng.proxy.shouldAddParticles(rand)) { + AppEng.proxy.spawnEffect(EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + null); + } + } + } + } - @Override - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random rand ) - { - final TileQuantumBridge bridge = this.getTileEntity( w, pos ); - if( bridge != null ) - { - if( bridge.hasQES() ) - { - if( AppEng.proxy.shouldAddParticles( rand ) ) - { - AppEng.proxy.spawnEffect( EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, null ); - } - } - } - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } + final TileQuantumBridge tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerQNB.TYPE, p, ContainerLocator.forTileEntity(tg)); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } - final TileQuantumBridge tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerQNB.TYPE, p, ContainerLocator.forTileEntity(tg)); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return SHAPE; - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; + } } diff --git a/src/main/java/appeng/block/qnb/BlockQuantumRing.java b/src/main/java/appeng/block/qnb/BlockQuantumRing.java index a01f3821d..00ac5650d 100644 --- a/src/main/java/appeng/block/qnb/BlockQuantumRing.java +++ b/src/main/java/appeng/block/qnb/BlockQuantumRing.java @@ -18,8 +18,6 @@ package appeng.block.qnb; - -import appeng.tile.qnb.TileQuantumBridge; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; @@ -29,6 +27,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; +import appeng.tile.qnb.TileQuantumBridge; public class BlockQuantumRing extends BlockQuantumBase { @@ -52,6 +51,7 @@ public class BlockQuantumRing extends BlockQuantumBase { } private static VoxelShape createShape(double onePixel) { - return VoxelShapes.create(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel)); + return VoxelShapes.create( + new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel)); } } diff --git a/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java b/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java index ae5405a15..b880b6671 100644 --- a/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java +++ b/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java @@ -1,12 +1,13 @@ package appeng.block.qnb; +import java.util.*; +import java.util.function.Function; + +import javax.annotation.Nullable; -import appeng.api.AEApi; -import appeng.client.render.cablebus.CubeBuilder; -import appeng.core.AppEng; -import appeng.tile.qnb.TileQuantumBridge; import com.google.common.collect.ImmutableList; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; @@ -20,219 +21,203 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nullable; -import java.util.*; -import java.util.function.Function; +import appeng.api.AEApi; +import appeng.client.render.cablebus.CubeBuilder; +import appeng.core.AppEng; +import appeng.tile.qnb.TileQuantumBridge; -class QnbFormedBakedModel implements IDynamicBakedModel -{ +class QnbFormedBakedModel implements IDynamicBakedModel { - private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/quantum_link" )); - private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring" )); - private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring_light" )); - private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring_light_corner" )); - private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/glass/transparent" )); - private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/covered/transparent" )); + private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/quantum_link")); + private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring")); + private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light")); + private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light_corner")); + private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "parts/cable/glass/transparent")); + private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "parts/cable/covered/transparent")); - private static final float DEFAULT_RENDER_MIN = 2.0f; - private static final float DEFAULT_RENDER_MAX = 14.0f; + private static final float DEFAULT_RENDER_MIN = 2.0f; + private static final float DEFAULT_RENDER_MAX = 14.0f; - private static final float CORNER_POWERED_RENDER_MIN = 3.9f; - private static final float CORNER_POWERED_RENDER_MAX = 12.1f; + private static final float CORNER_POWERED_RENDER_MIN = 3.9f; + private static final float CORNER_POWERED_RENDER_MAX = 12.1f; - private static final float CENTER_POWERED_RENDER_MIN = -0.01f; - private static final float CENTER_POWERED_RENDER_MAX = 16.01f; + private static final float CENTER_POWERED_RENDER_MIN = -0.01f; + private static final float CENTER_POWERED_RENDER_MAX = 16.01f; - private final IBakedModel baseModel; + private final IBakedModel baseModel; - private final Block linkBlock; + private final Block linkBlock; - private final TextureAtlasSprite linkTexture; - private final TextureAtlasSprite ringTexture; - private final TextureAtlasSprite glassCableTexture; - private final TextureAtlasSprite coveredCableTexture; - private final TextureAtlasSprite lightTexture; - private final TextureAtlasSprite lightCornerTexture; + private final TextureAtlasSprite linkTexture; + private final TextureAtlasSprite ringTexture; + private final TextureAtlasSprite glassCableTexture; + private final TextureAtlasSprite coveredCableTexture; + private final TextureAtlasSprite lightTexture; + private final TextureAtlasSprite lightCornerTexture; - public QnbFormedBakedModel( IBakedModel baseModel, Function bakedTextureGetter ) - { - this.baseModel = baseModel; - this.linkTexture = bakedTextureGetter.apply( TEXTURE_LINK ); - this.ringTexture = bakedTextureGetter.apply( TEXTURE_RING ); - this.glassCableTexture = bakedTextureGetter.apply( TEXTURE_CABLE_GLASS ); - this.coveredCableTexture = bakedTextureGetter.apply( TEXTURE_COVERED_CABLE ); - this.lightTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT ); - this.lightCornerTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT_CORNER ); - this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse( null ); - } + public QnbFormedBakedModel(IBakedModel baseModel, Function bakedTextureGetter) { + this.baseModel = baseModel; + this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK); + this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING); + this.glassCableTexture = bakedTextureGetter.apply(TEXTURE_CABLE_GLASS); + this.coveredCableTexture = bakedTextureGetter.apply(TEXTURE_COVERED_CABLE); + this.lightTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT); + this.lightCornerTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT_CORNER); + this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null); + } - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData) - { - QnbFormedState formedState = modelData.getData(TileQuantumBridge.FORMED_STATE); + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData modelData) { + QnbFormedState formedState = modelData.getData(TileQuantumBridge.FORMED_STATE); - if( formedState == null ) - { - return this.baseModel.getQuads( state, side, rand ); - } + if (formedState == null) { + return this.baseModel.getQuads(state, side, rand); + } - if (side != null) { - return Collections.emptyList(); - } + if (side != null) { + return Collections.emptyList(); + } - return this.getQuads( formedState, state ); - } + return this.getQuads(formedState, state); + } - private List getQuads( QnbFormedState formedState, BlockState state ) - { - CubeBuilder builder = new CubeBuilder( ); + private List getQuads(QnbFormedState formedState, BlockState state) { + CubeBuilder builder = new CubeBuilder(); - if( state.getBlock() == this.linkBlock ) - { - Set sides = formedState.getAdjacentQuantumBridges(); + if (state.getBlock() == this.linkBlock) { + Set sides = formedState.getAdjacentQuantumBridges(); - this.renderCableAt( builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides ); + this.renderCableAt(builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides); - this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides ); + this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides); - builder.setTexture( this.linkTexture ); - builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); - } - else - { - if( formedState.isCorner() ) - { - this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16, formedState.getAdjacentQuantumBridges() ); + builder.setTexture(this.linkTexture); + builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, + DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX); + } else { + if (formedState.isCorner()) { + this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16, + formedState.getAdjacentQuantumBridges()); - builder.setTexture( this.ringTexture ); - builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); + builder.setTexture(this.ringTexture); + builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, + DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX); - if( formedState.isPowered() ) - { - builder.setTexture( this.lightCornerTexture ); - builder.setRenderFullBright( true ); - for( Direction facing : Direction.values() ) - { - // Offset the face by a slight amount so that it is drawn over the already drawn ring texture - // (avoids z-fighting) - float xOffset = Math.abs( facing.getXOffset() * 0.01f ); - float yOffset = Math.abs( facing.getYOffset() * 0.01f ); - float zOffset = Math.abs( facing.getZOffset() * 0.01f ); + if (formedState.isPowered()) { + builder.setTexture(this.lightCornerTexture); + builder.setRenderFullBright(true); + for (Direction facing : Direction.values()) { + // Offset the face by a slight amount so that it is drawn over the already drawn + // ring texture + // (avoids z-fighting) + float xOffset = Math.abs(facing.getXOffset() * 0.01f); + float yOffset = Math.abs(facing.getYOffset() * 0.01f); + float zOffset = Math.abs(facing.getZOffset() * 0.01f); - builder.setDrawFaces( EnumSet.of( facing ) ); - builder.addCube( - DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, DEFAULT_RENDER_MIN - zOffset, - DEFAULT_RENDER_MAX + xOffset, DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset ); - } - } - } - else - { - builder.setTexture( this.ringTexture ); + builder.setDrawFaces(EnumSet.of(facing)); + builder.addCube(DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, + DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MAX + xOffset, + DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset); + } + } + } else { + builder.setTexture(this.ringTexture); - builder.addCube( 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); + builder.addCube(0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX); - builder.addCube( DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX ); + builder.addCube(DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX); - builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16 ); + builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16); - if( formedState.isPowered() ) - { - builder.setTexture( this.lightTexture ); - builder.setRenderFullBright( true ); - for( Direction facing : Direction.values() ) - { - // Offset the face by a slight amount so that it is drawn over the already drawn ring texture - // (avoids z-fighting) - float xOffset = Math.abs( facing.getXOffset() * 0.01f ); - float yOffset = Math.abs( facing.getYOffset() * 0.01f ); - float zOffset = Math.abs( facing.getZOffset() * 0.01f ); + if (formedState.isPowered()) { + builder.setTexture(this.lightTexture); + builder.setRenderFullBright(true); + for (Direction facing : Direction.values()) { + // Offset the face by a slight amount so that it is drawn over the already drawn + // ring texture + // (avoids z-fighting) + float xOffset = Math.abs(facing.getXOffset() * 0.01f); + float yOffset = Math.abs(facing.getYOffset() * 0.01f); + float zOffset = Math.abs(facing.getZOffset() * 0.01f); - builder.setDrawFaces( EnumSet.of( facing ) ); - builder.addCube( - -xOffset, -yOffset, -zOffset, - 16 + xOffset, 16 + yOffset, 16 + zOffset ); - } - } - } - } + builder.setDrawFaces(EnumSet.of(facing)); + builder.addCube(-xOffset, -yOffset, -zOffset, 16 + xOffset, 16 + yOffset, 16 + zOffset); + } + } + } + } - return builder.getOutput(); - } + return builder.getOutput(); + } - private void renderCableAt( CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull, Set connections ) - { - builder.setTexture( texture ); + private void renderCableAt(CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull, + Set connections) { + builder.setTexture(texture); - if( connections.contains( Direction.WEST ) ) - { - builder.addCube( 0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness ); - } + if (connections.contains(Direction.WEST)) { + builder.addCube(0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness); + } - if( connections.contains( Direction.EAST ) ) - { - builder.addCube( 8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness ); - } + if (connections.contains(Direction.EAST)) { + builder.addCube(8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness); + } - if( connections.contains( Direction.NORTH ) ) - { - builder.addCube( 8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull ); - } + if (connections.contains(Direction.NORTH)) { + builder.addCube(8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull); + } - if( connections.contains( Direction.SOUTH ) ) - { - builder.addCube( 8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16 ); - } + if (connections.contains(Direction.SOUTH)) { + builder.addCube(8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16); + } - if( connections.contains( Direction.DOWN ) ) - { - builder.addCube( 8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness ); - } + if (connections.contains(Direction.DOWN)) { + builder.addCube(8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness); + } - if( connections.contains( Direction.UP ) ) - { - builder.addCube( 8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness ); - } - } + if (connections.contains(Direction.UP)) { + builder.addCube(8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness); + } + } - @Override - public boolean isAmbientOcclusion() - { - return this.baseModel.isAmbientOcclusion(); - } + @Override + public boolean isAmbientOcclusion() { + return this.baseModel.isAmbientOcclusion(); + } - @Override - public boolean isGui3d() - { - return true; - } + @Override + public boolean isGui3d() { + return true; + } - @Override - public boolean func_230044_c_() { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.baseModel.getParticleTexture(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.baseModel.getParticleTexture(); + } - @Override - public ItemOverrideList getOverrides() - { - return this.baseModel.getOverrides(); - } + @Override + public ItemOverrideList getOverrides() { + return this.baseModel.getOverrides(); + } - public static List getRequiredTextures() - { - return ImmutableList.of( - TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER ); - } + public static List getRequiredTextures() { + return ImmutableList.of(TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, + TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER); + } } diff --git a/src/main/java/appeng/block/qnb/QnbFormedModel.java b/src/main/java/appeng/block/qnb/QnbFormedModel.java index ed359a6b2..396d23974 100644 --- a/src/main/java/appeng/block/qnb/QnbFormedModel.java +++ b/src/main/java/appeng/block/qnb/QnbFormedModel.java @@ -1,34 +1,36 @@ package appeng.block.qnb; +import java.util.Collection; +import java.util.Set; +import java.util.function.Function; -import appeng.core.AppEng; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; +import appeng.core.AppEng; +public class QnbFormedModel implements IModelGeometry { -public class QnbFormedModel implements IModelGeometry -{ + private static final ResourceLocation MODEL_RING = new ResourceLocation(AppEng.MOD_ID, "block/qnb/ring"); - private static final ResourceLocation MODEL_RING = new ResourceLocation( AppEng.MOD_ID, "block/qnb/ring" ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter); + return new QnbFormedBakedModel(ringModel, spriteGetter); + } - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter); - return new QnbFormedBakedModel( ringModel, spriteGetter ); - } - - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return QnbFormedBakedModel.getRequiredTextures(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return QnbFormedBakedModel.getRequiredTextures(); + } } diff --git a/src/main/java/appeng/block/qnb/QnbFormedState.java b/src/main/java/appeng/block/qnb/QnbFormedState.java index 991254cb2..b061ac25f 100644 --- a/src/main/java/appeng/block/qnb/QnbFormedState.java +++ b/src/main/java/appeng/block/qnb/QnbFormedState.java @@ -1,41 +1,34 @@ package appeng.block.qnb; - import java.util.Set; import net.minecraft.util.Direction; +public class QnbFormedState { -public class QnbFormedState -{ + private final Set adjacentQuantumBridges; - private final Set adjacentQuantumBridges; + private final boolean corner; - private final boolean corner; + private final boolean powered; - private final boolean powered; + public QnbFormedState(Set adjacentQuantumBridges, boolean corner, boolean powered) { + this.adjacentQuantumBridges = adjacentQuantumBridges; + this.corner = corner; + this.powered = powered; + } - public QnbFormedState( Set adjacentQuantumBridges, boolean corner, boolean powered ) - { - this.adjacentQuantumBridges = adjacentQuantumBridges; - this.corner = corner; - this.powered = powered; - } + public Set getAdjacentQuantumBridges() { + return this.adjacentQuantumBridges; + } - public Set getAdjacentQuantumBridges() - { - return this.adjacentQuantumBridges; - } + public boolean isCorner() { + return this.corner; + } - public boolean isCorner() - { - return this.corner; - } - - public boolean isPowered() - { - return this.powered; - } + public boolean isPowered() { + return this.powered; + } } diff --git a/src/main/java/appeng/block/qnb/QuantumBridgeRendering.java b/src/main/java/appeng/block/qnb/QuantumBridgeRendering.java index 1b4ef3bbc..45494f041 100644 --- a/src/main/java/appeng/block/qnb/QuantumBridgeRendering.java +++ b/src/main/java/appeng/block/qnb/QuantumBridgeRendering.java @@ -1,7 +1,6 @@ package appeng.block.qnb; - import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -10,17 +9,15 @@ import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; +public class QuantumBridgeRendering extends BlockRenderingCustomizer { -public class QuantumBridgeRendering extends BlockRenderingCustomizer -{ - - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - // FIXME rendering.builtInModel( "models/block/qnb/qnb_formed", new QnbFormedModel() ); - // Disable auto rotation - rendering.modelCustomizer( ( location, model ) -> model ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + // FIXME rendering.builtInModel( "models/block/qnb/qnb_formed", new + // QnbFormedModel() ); + // Disable auto rotation + rendering.modelCustomizer((location, model) -> model); + } } diff --git a/src/main/java/appeng/block/spatial/BlockMatrixFrame.java b/src/main/java/appeng/block/spatial/BlockMatrixFrame.java index 7ce3a9d3f..50a89e3a1 100644 --- a/src/main/java/appeng/block/spatial/BlockMatrixFrame.java +++ b/src/main/java/appeng/block/spatial/BlockMatrixFrame.java @@ -18,13 +18,12 @@ package appeng.block.spatial; - import java.util.Collections; import java.util.List; import net.minecraft.block.BlockRenderType; -import net.minecraft.block.material.Material; import net.minecraft.block.BlockState; +import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.block.material.PushReaction; import net.minecraft.entity.Entity; @@ -46,66 +45,64 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.block.AEBaseBlock; /** - * This block is used to fill empty space in spatial dimensions - * and delinates the border of a spatial dimensions's usable space. + * This block is used to fill empty space in spatial dimensions and delinates + * the border of a spatial dimensions's usable space. */ -public class BlockMatrixFrame extends AEBaseBlock -{ +public class BlockMatrixFrame extends AEBaseBlock { - private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false, false, PushReaction.PUSH_ONLY); + private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false, + false, PushReaction.PUSH_ONLY); - public BlockMatrixFrame() - { - super( Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops() ); - } + public BlockMatrixFrame() { + super(Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops()); + } - @Override - public BlockRenderType getRenderType(BlockState state) { - return BlockRenderType.INVISIBLE; - } + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.INVISIBLE; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void fillItemGroup(ItemGroup group, NonNullList itemStacks) - { - // do nothing - } + @Override + @OnlyIn(Dist.CLIENT) + public void fillItemGroup(ItemGroup group, NonNullList itemStacks) { + // do nothing + } - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.fullCube(); - } + @Override + public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, + ISelectionContext context) { + return VoxelShapes.fullCube(); + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - // This also prevents any blocks from being placed on this block! - return VoxelShapes.empty(); - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + // This also prevents any blocks from being placed on this block! + return VoxelShapes.empty(); + } - @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - return false; - } + @Override + public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + return false; + } - @Override - public void onExplosionDestroy( final World world, final BlockPos pos, final Explosion explosion ) - { - // Don't explode. - } + @Override + public void onExplosionDestroy(final World world, final BlockPos pos, final Explosion explosion) { + // Don't explode. + } - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { - return true; - } + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { + return true; + } - @Override - public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) { - return 1.0f; - } + @Override + public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) { + return 1.0f; + } - @Override - public boolean canEntityDestroy( final BlockState state, final IBlockReader world, final BlockPos pos, final Entity entity ) - { - return false; - } + @Override + public boolean canEntityDestroy(final BlockState state, final IBlockReader world, final BlockPos pos, + final Entity entity) { + return false; + } } diff --git a/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java b/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java index 169ad3770..125dcae87 100644 --- a/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java +++ b/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java @@ -18,16 +18,11 @@ package appeng.block.spatial; - import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerSpatialIOPort; -import appeng.fluids.container.ContainerFluidLevelEmitter; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; import net.minecraft.block.BlockState; +import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; @@ -38,46 +33,43 @@ import net.minecraft.world.World; import appeng.api.util.AEPartLocation; import appeng.block.AEBaseTileBlock; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerSpatialIOPort; +import appeng.fluids.container.ContainerFluidLevelEmitter; import appeng.tile.spatial.TileSpatialIOPort; import appeng.util.Platform; +public class BlockSpatialIOPort extends AEBaseTileBlock { -public class BlockSpatialIOPort extends AEBaseTileBlock -{ + public BlockSpatialIOPort() { + super(defaultProps(Material.IRON)); + } - public BlockSpatialIOPort() - { - super( defaultProps(Material.IRON) ); - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileSpatialIOPort te = this.getTileEntity(world, pos); + if (te != null) { + te.updateRedstoneState(); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileSpatialIOPort te = this.getTileEntity( world, pos ); - if( te != null ) - { - te.updateRedstoneState(); - } - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } - - final TileSpatialIOPort tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerSpatialIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + final TileSpatialIOPort tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerSpatialIOPort.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/spatial/BlockSpatialPylon.java b/src/main/java/appeng/block/spatial/BlockSpatialPylon.java index 66bfa1641..b2a1094dc 100644 --- a/src/main/java/appeng/block/spatial/BlockSpatialPylon.java +++ b/src/main/java/appeng/block/spatial/BlockSpatialPylon.java @@ -18,45 +18,38 @@ package appeng.block.spatial; - -import appeng.block.AEBaseTileBlock; -import appeng.helpers.AEGlassMaterial; -import appeng.tile.spatial.TileSpatialPylon; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import appeng.block.AEBaseTileBlock; +import appeng.helpers.AEGlassMaterial; +import appeng.tile.spatial.TileSpatialPylon; -public class BlockSpatialPylon extends AEBaseTileBlock -{ +public class BlockSpatialPylon extends AEBaseTileBlock { + public BlockSpatialPylon() { + super(defaultProps(AEGlassMaterial.INSTANCE)); + } - public BlockSpatialPylon() - { - super( defaultProps(AEGlassMaterial.INSTANCE) ); - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileSpatialPylon tsp = this.getTileEntity(world, pos); + if (tsp != null) { + tsp.neighborChanged(); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileSpatialPylon tsp = this.getTileEntity( world, pos ); - if( tsp != null ) - { - tsp.neighborChanged(); - } - } - - @Override - public int getLightValue( final BlockState state, final IBlockReader w, final BlockPos pos ) - { - final TileSpatialPylon tsp = this.getTileEntity( w, pos ); - if( tsp != null ) - { - return tsp.getLightValue(); - } - return super.getLightValue( state, w, pos ); - } + @Override + public int getLightValue(final BlockState state, final IBlockReader w, final BlockPos pos) { + final TileSpatialPylon tsp = this.getTileEntity(w, pos); + if (tsp != null) { + return tsp.getLightValue(); + } + return super.getLightValue(state, w, pos); + } } diff --git a/src/main/java/appeng/block/storage/BlockChest.java b/src/main/java/appeng/block/storage/BlockChest.java index 536acd3cf..f51e8bea9 100644 --- a/src/main/java/appeng/block/storage/BlockChest.java +++ b/src/main/java/appeng/block/storage/BlockChest.java @@ -18,15 +18,8 @@ package appeng.block.storage; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerChest; -import appeng.container.implementations.ContainerQNB; -import appeng.core.localization.PlayerMessages; -import appeng.tile.storage.TileChest; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -42,66 +35,67 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IWorld; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerChest; +import appeng.container.implementations.ContainerQNB; +import appeng.core.localization.PlayerMessages; +import appeng.tile.storage.TileChest; +import appeng.util.Platform; +public class BlockChest extends AEBaseTileBlock { -public class BlockChest extends AEBaseTileBlock -{ + private final static EnumProperty SLOT_STATE = EnumProperty.create("slot_state", + DriveSlotState.class); - private final static EnumProperty SLOT_STATE = EnumProperty.create( "slot_state", DriveSlotState.class ); + public BlockChest() { + super(defaultProps(Material.IRON)); + this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY)); + } - public BlockChest() - { - super( defaultProps(Material.IRON) ); - this.setDefaultState( this.getDefaultState().with( SLOT_STATE, DriveSlotState.EMPTY ) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(SLOT_STATE); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(SLOT_STATE); - } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) { + DriveSlotState slotState = DriveSlotState.EMPTY; - @Override - protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) { - DriveSlotState slotState = DriveSlotState.EMPTY; + if (te.getCellCount() >= 1) { + slotState = DriveSlotState.fromCellStatus(te.getCellStatus(0)); + } + // Power-state has to be checked separately + if (!te.isPowered() && slotState != DriveSlotState.EMPTY) { + slotState = DriveSlotState.OFFLINE; + } - if( te.getCellCount() >= 1 ) - { - slotState = DriveSlotState.fromCellStatus( te.getCellStatus( 0 ) ); - } - // Power-state has to be checked separately - if( !te.isPowered() && slotState != DriveSlotState.EMPTY ) - { - slotState = DriveSlotState.OFFLINE; - } + return currentState.with(SLOT_STATE, slotState); + } - return currentState.with( SLOT_STATE, slotState ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + final TileChest tg = this.getTileEntity(w, pos); + if (tg != null && !p.isCrouching()) { + if (w.isRemote()) { + return ActionResultType.SUCCESS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - final TileChest tg = this.getTileEntity( w, pos ); - if( tg != null && !p.isCrouching() ) - { - if( w.isRemote() ) - { - return ActionResultType.SUCCESS; - } + if (hit.getFace() == tg.getUp()) { + if (!tg.openGui(p)) { + p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get()); + } + } else { + ContainerOpener.openContainer(ContainerChest.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } - if (hit.getFace() == tg.getUp()) { - if( !tg.openGui( p ) ) - { - p.sendMessage( PlayerMessages.ChestCannotReadStorageCell.get() ); - } - } else { - ContainerOpener.openContainer(ContainerChest.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } - - return ActionResultType.PASS; - } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/storage/BlockDrive.java b/src/main/java/appeng/block/storage/BlockDrive.java index da936edb9..4b108143d 100644 --- a/src/main/java/appeng/block/storage/BlockDrive.java +++ b/src/main/java/appeng/block/storage/BlockDrive.java @@ -18,14 +18,8 @@ package appeng.block.storage; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerDrive; -import appeng.container.implementations.ContainerQuartzKnife; -import appeng.tile.storage.TileDrive; -import appeng.util.Platform; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -35,34 +29,34 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerDrive; +import appeng.container.implementations.ContainerQuartzKnife; +import appeng.tile.storage.TileDrive; +import appeng.util.Platform; +public class BlockDrive extends AEBaseTileBlock { -public class BlockDrive extends AEBaseTileBlock -{ + public BlockDrive() { + super(defaultProps(Material.IRON)); + } - public BlockDrive() - { - super( defaultProps(Material.IRON) ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } - - final TileDrive tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg)); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + final TileDrive tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg)); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/storage/BlockIOPort.java b/src/main/java/appeng/block/storage/BlockIOPort.java index 079ab689f..a898189af 100644 --- a/src/main/java/appeng/block/storage/BlockIOPort.java +++ b/src/main/java/appeng/block/storage/BlockIOPort.java @@ -18,14 +18,8 @@ package appeng.block.storage; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerIOPort; -import appeng.fluids.container.ContainerFluidInterface; -import appeng.tile.storage.TileIOPort; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; @@ -37,44 +31,44 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerIOPort; +import appeng.fluids.container.ContainerFluidInterface; +import appeng.tile.storage.TileIOPort; +import appeng.util.Platform; +public class BlockIOPort extends AEBaseTileBlock { -public class BlockIOPort extends AEBaseTileBlock -{ + public BlockIOPort() { + super(defaultProps(Material.IRON)); + } - public BlockIOPort() - { - super( defaultProps(Material.IRON) ); - } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + final TileIOPort te = this.getTileEntity(world, pos); + if (te != null) { + te.updateRedstoneState(); + } + } - @Override - public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving ) - { - final TileIOPort te = this.getTileEntity( world, pos ); - if( te != null ) - { - te.updateRedstoneState(); - } - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } - - final TileIOPort tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + final TileIOPort tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerIOPort.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/block/storage/BlockSkyChest.java b/src/main/java/appeng/block/storage/BlockSkyChest.java index 1cf0e47bb..c46dbf05b 100644 --- a/src/main/java/appeng/block/storage/BlockSkyChest.java +++ b/src/main/java/appeng/block/storage/BlockSkyChest.java @@ -18,13 +18,8 @@ package appeng.block.storage; +import javax.annotation.Nullable; -import appeng.block.AEBaseTileBlock; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerSkyChest; -import appeng.tile.storage.TileSkyChest; -import appeng.util.Platform; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -42,85 +37,89 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.block.AEBaseTileBlock; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerSkyChest; +import appeng.tile.storage.TileSkyChest; +import appeng.util.Platform; +public class BlockSkyChest extends AEBaseTileBlock { -public class BlockSkyChest extends AEBaseTileBlock -{ + private static final double AABB_OFFSET_BOTTOM = 0.00; + private static final double AABB_OFFSET_SIDES = 0.06; + private static final double AABB_OFFSET_TOP = 0.125; - private static final double AABB_OFFSET_BOTTOM = 0.00; - private static final double AABB_OFFSET_SIDES = 0.06; - private static final double AABB_OFFSET_TOP = 0.125; + public enum SkyChestType { + STONE, BLOCK + }; - public enum SkyChestType - { - STONE, BLOCK - }; + public final SkyChestType type; - public final SkyChestType type; + public BlockSkyChest(final SkyChestType type, Properties props) { + super(props); + this.type = type; + } - public BlockSkyChest( final SkyChestType type, Properties props ) - { - super( props ); - this.type = type; - } + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.ENTITYBLOCK_ANIMATED; + } - @Override - public BlockRenderType getRenderType(BlockState state) { - return BlockRenderType.ENTITYBLOCK_ANIMATED; - } + @Override + public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { + return true; + } - @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { - return true; - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (Platform.isServer()) { + TileSkyChest tile = getTileEntity(w, pos); + if (tile == null) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( Platform.isServer() ) - { - TileSkyChest tile = getTileEntity(w, pos); - if (tile == null) { - return ActionResultType.PASS; - } + ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile)); + } - ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile)); - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + // TODO Cache this! It can't be that hard! + AxisAlignedBB aabb = computeAABB(worldIn, pos); + return VoxelShapes.create(aabb); + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - // TODO Cache this! It can't be that hard! - AxisAlignedBB aabb = computeAABB(worldIn, pos); - return VoxelShapes.create(aabb); - } + private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) { + final TileSkyChest sk = this.getTileEntity(w, pos); + Direction o = Direction.UP; - private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos ) - { - final TileSkyChest sk = this.getTileEntity( w, pos ); - Direction o = Direction.UP; + if (sk != null) { + o = sk.getUp(); + } - if( sk != null ) - { - o = sk.getUp(); - } + final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; - final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; - final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; - final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; + // for x/z top and bottom is swapped + final double minX = Math.max(0.0, + offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP))); + final double minY = Math.max(0.0, + offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM))); + final double minZ = Math.max(0.0, + offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP))); - // for x/z top and bottom is swapped - final double minX = Math.max( 0.0, offsetX + ( o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getXOffset() * AABB_OFFSET_TOP ) ) ); - final double minY = Math.max( 0.0, offsetY + ( o.getYOffset() < 0 ? AABB_OFFSET_TOP : ( o.getYOffset() * AABB_OFFSET_BOTTOM ) ) ); - final double minZ = Math.max( 0.0, offsetZ + ( o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getZOffset() * AABB_OFFSET_TOP ) ) ); + final double maxX = Math.min(1.0, + 1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM))); + final double maxY = Math.min(1.0, + 1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP))); + final double maxZ = Math.min(1.0, + 1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM))); - final double maxX = Math.min( 1.0, 1.0 - offsetX - ( o.getXOffset() < 0 ? AABB_OFFSET_TOP : ( o.getXOffset() * AABB_OFFSET_BOTTOM ) ) ); - final double maxY = Math.min( 1.0, 1.0 - offsetY - ( o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getYOffset() * AABB_OFFSET_TOP ) ) ); - final double maxZ = Math.min( 1.0, 1.0 - offsetZ - ( o.getZOffset() < 0 ? AABB_OFFSET_TOP : ( o.getZOffset() * AABB_OFFSET_BOTTOM ) ) ); - - return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); - } + return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); + } } diff --git a/src/main/java/appeng/block/storage/ChestRendering.java b/src/main/java/appeng/block/storage/ChestRendering.java index 675439f31..12cebfc99 100644 --- a/src/main/java/appeng/block/storage/ChestRendering.java +++ b/src/main/java/appeng/block/storage/ChestRendering.java @@ -18,7 +18,6 @@ package appeng.block.storage; - import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -30,19 +29,16 @@ import appeng.bootstrap.IItemRendering; import appeng.client.render.ColorableTileBlockColor; import appeng.client.render.StaticItemColor; +public class ChestRendering extends BlockRenderingCustomizer { -public class ChestRendering extends BlockRenderingCustomizer -{ + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - - // I checked, the ME chest doesn't keep its color in item form - itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) ); - rendering.blockColor( new ColorableTileBlockColor() ); - } + // I checked, the ME chest doesn't keep its color in item form + itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT)); + rendering.blockColor(new ColorableTileBlockColor()); + } } diff --git a/src/main/java/appeng/block/storage/DriveRendering.java b/src/main/java/appeng/block/storage/DriveRendering.java index 5b7a9d5f6..652f6ffdd 100644 --- a/src/main/java/appeng/block/storage/DriveRendering.java +++ b/src/main/java/appeng/block/storage/DriveRendering.java @@ -18,18 +18,15 @@ package appeng.block.storage; +import net.minecraft.client.renderer.RenderType; import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; -import net.minecraft.client.renderer.RenderType; - -public class DriveRendering extends BlockRenderingCustomizer -{ - @Override - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - } +public class DriveRendering extends BlockRenderingCustomizer { + @Override + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } } diff --git a/src/main/java/appeng/block/storage/DriveSlotCellType.java b/src/main/java/appeng/block/storage/DriveSlotCellType.java index c9b09f3ac..c808d614d 100644 --- a/src/main/java/appeng/block/storage/DriveSlotCellType.java +++ b/src/main/java/appeng/block/storage/DriveSlotCellType.java @@ -18,33 +18,28 @@ package appeng.block.storage; - import net.minecraft.util.IStringSerializable; - /** * Describes the type of cell present in a slot. */ -public enum DriveSlotCellType implements IStringSerializable -{ +public enum DriveSlotCellType implements IStringSerializable { - EMPTY("empty"), + EMPTY("empty"), - ITEM("item"), + ITEM("item"), - FLUID("fluid"); + FLUID("fluid"); - private final String name; + private final String name; - DriveSlotCellType(String name ) - { - this.name = name; - } + DriveSlotCellType(String name) { + this.name = name; + } - @Override - public String getName() - { - return this.name; - } + @Override + public String getName() { + return this.name; + } } diff --git a/src/main/java/appeng/block/storage/DriveSlotState.java b/src/main/java/appeng/block/storage/DriveSlotState.java index ffd8b9a2f..e68b48d74 100644 --- a/src/main/java/appeng/block/storage/DriveSlotState.java +++ b/src/main/java/appeng/block/storage/DriveSlotState.java @@ -18,58 +18,52 @@ package appeng.block.storage; - import net.minecraft.util.IStringSerializable; - /** - * Describes the different states a single slot of a BlockDrive can be in in terms of rendering. + * Describes the different states a single slot of a BlockDrive can be in in + * terms of rendering. */ -public enum DriveSlotState implements IStringSerializable -{ +public enum DriveSlotState implements IStringSerializable { - // No cell in slot - EMPTY( "empty" ), + // No cell in slot + EMPTY("empty"), - // Cell in slot, but unpowered - OFFLINE( "offline" ), + // Cell in slot, but unpowered + OFFLINE("offline"), - // Online and free space - ONLINE( "online" ), + // Online and free space + ONLINE("online"), - // Types full, space left - TYPES_FULL( "types_full" ), + // Types full, space left + TYPES_FULL("types_full"), - // Completely full - FULL( "full" ); + // Completely full + FULL("full"); - private final String name; + private final String name; - DriveSlotState( String name ) - { - this.name = name; - } + DriveSlotState(String name) { + this.name = name; + } - @Override - public String getName() - { - return this.name; - } + @Override + public String getName() { + return this.name; + } - public static DriveSlotState fromCellStatus( int cellStatus ) - { - switch( cellStatus ) - { - default: - case 0: - return DriveSlotState.EMPTY; - case 1: - return DriveSlotState.ONLINE; - case 2: - return DriveSlotState.TYPES_FULL; - case 3: - return DriveSlotState.FULL; - } - } + public static DriveSlotState fromCellStatus(int cellStatus) { + switch (cellStatus) { + default: + case 0: + return DriveSlotState.EMPTY; + case 1: + return DriveSlotState.ONLINE; + case 2: + return DriveSlotState.TYPES_FULL; + case 3: + return DriveSlotState.FULL; + } + } } diff --git a/src/main/java/appeng/block/storage/DriveSlotsState.java b/src/main/java/appeng/block/storage/DriveSlotsState.java index 5d4be1501..3768e068f 100644 --- a/src/main/java/appeng/block/storage/DriveSlotsState.java +++ b/src/main/java/appeng/block/storage/DriveSlotsState.java @@ -18,90 +18,76 @@ package appeng.block.storage; - -import appeng.api.implementations.tiles.IChestOrDrive; import com.google.common.base.Preconditions; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import appeng.api.implementations.tiles.IChestOrDrive; /** - * Contains the full information about what the state of the slots in a BlockDrive is. + * Contains the full information about what the state of the slots in a + * BlockDrive is. */ -public class DriveSlotsState -{ +public class DriveSlotsState { - private final Item[] cells; + private final Item[] cells; - private final DriveSlotState[] states; + private final DriveSlotState[] states; - public DriveSlotsState(Item[] cells, DriveSlotState[] states) { - Preconditions.checkArgument(cells.length == states.length); - this.cells = cells; - this.states = states; - } + public DriveSlotsState(Item[] cells, DriveSlotState[] states) { + Preconditions.checkArgument(cells.length == states.length); + this.cells = cells; + this.states = states; + } - public DriveSlotState getState(int index ) - { - if( index >= this.states.length ) - { - return DriveSlotState.EMPTY; - } - return this.states[index]; - } + public DriveSlotState getState(int index) { + if (index >= this.states.length) { + return DriveSlotState.EMPTY; + } + return this.states[index]; + } - public Item getCell(int index ) - { - if( index >= this.cells.length ) - { - return null; - } - return this.cells[index]; - } + public Item getCell(int index) { + if (index >= this.cells.length) { + return null; + } + return this.cells[index]; + } - public int getSlotCount() - { - return this.cells.length; - } + public int getSlotCount() { + return this.cells.length; + } - /** - * Retrieve an array that describes the state of each slot in this drive or chest. - */ - public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive ) - { - DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()]; - Item[] cells = new Item[chestOrDrive.getCellCount()]; - for( int i = 0; i < chestOrDrive.getCellCount(); i++ ) - { - cells[i] = chestOrDrive.getCellItem(i); + /** + * Retrieve an array that describes the state of each slot in this drive or + * chest. + */ + public static DriveSlotsState fromChestOrDrive(IChestOrDrive chestOrDrive) { + DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()]; + Item[] cells = new Item[chestOrDrive.getCellCount()]; + for (int i = 0; i < chestOrDrive.getCellCount(); i++) { + cells[i] = chestOrDrive.getCellItem(i); - if( !chestOrDrive.isPowered() ) - { - if( chestOrDrive.getCellStatus( i ) != 0 ) - { - states[i] = DriveSlotState.OFFLINE; - } - else - { - states[i] = DriveSlotState.EMPTY; - } - } - else - { - states[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) ); - } - } - return new DriveSlotsState( cells, states ); - } + if (!chestOrDrive.isPowered()) { + if (chestOrDrive.getCellStatus(i) != 0) { + states[i] = DriveSlotState.OFFLINE; + } else { + states[i] = DriveSlotState.EMPTY; + } + } else { + states[i] = DriveSlotState.fromCellStatus(chestOrDrive.getCellStatus(i)); + } + } + return new DriveSlotsState(cells, states); + } - public static DriveSlotsState createEmpty( int slotCount ) - { - DriveSlotState[] states = new DriveSlotState[slotCount]; - Item[] cells = new Item[slotCount]; - for( int i = 0; i < slotCount; i++ ) - { - states[i] = DriveSlotState.EMPTY; - } - return new DriveSlotsState( cells, states ); - } + public static DriveSlotsState createEmpty(int slotCount) { + DriveSlotState[] states = new DriveSlotState[slotCount]; + Item[] cells = new Item[slotCount]; + for (int i = 0; i < slotCount; i++) { + states[i] = DriveSlotState.EMPTY; + } + return new DriveSlotsState(cells, states); + } } diff --git a/src/main/java/appeng/bootstrap/BlockDefinitionBuilder.java b/src/main/java/appeng/bootstrap/BlockDefinitionBuilder.java index 913bb0ae0..0779207e1 100644 --- a/src/main/java/appeng/bootstrap/BlockDefinitionBuilder.java +++ b/src/main/java/appeng/bootstrap/BlockDefinitionBuilder.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; @@ -28,7 +27,6 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import appeng.core.AEItemGroup; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -37,203 +35,176 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.definitions.IBlockDefinition; +import appeng.api.features.AEFeature; import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlockItem; import appeng.block.AEBaseTileBlock; import appeng.bootstrap.components.IBlockRegistrationComponent; import appeng.bootstrap.components.IItemRegistrationComponent; import appeng.bootstrap.definitions.TileEntityDefinition; +import appeng.core.AEItemGroup; import appeng.core.AppEng; import appeng.core.CreativeTab; -import appeng.api.features.AEFeature; import appeng.core.features.BlockDefinition; import appeng.core.features.TileDefinition; import appeng.util.Platform; +class BlockDefinitionBuilder implements IBlockBuilder { -class BlockDefinitionBuilder implements IBlockBuilder -{ + private final FeatureFactory factory; - private final FeatureFactory factory; + private final String registryName; - private final String registryName; + private final Supplier blockSupplier; - private final Supplier blockSupplier; + private final List> bootstrapComponents = new ArrayList<>(); - private final List> bootstrapComponents = new ArrayList<>(); + private final EnumSet features = EnumSet.noneOf(AEFeature.class); - private final EnumSet features = EnumSet.noneOf( AEFeature.class ); + private ItemGroup itemGroup = CreativeTab.INSTANCE; - private ItemGroup itemGroup = CreativeTab.INSTANCE; + private TileEntityDefinition tileEntityDefinition; - private TileEntityDefinition tileEntityDefinition; + private boolean disableItem = false; - private boolean disableItem = false; + private BiFunction itemFactory; - private BiFunction itemFactory; + @OnlyIn(Dist.CLIENT) + private BlockRendering blockRendering; - @OnlyIn( Dist.CLIENT ) - private BlockRendering blockRendering; + @OnlyIn(Dist.CLIENT) + private ItemRendering itemRendering; - @OnlyIn( Dist.CLIENT ) - private ItemRendering itemRendering; + BlockDefinitionBuilder(FeatureFactory factory, String id, Supplier blockSupplier) { + this.factory = factory; + this.registryName = id; + this.blockSupplier = blockSupplier; - BlockDefinitionBuilder( FeatureFactory factory, String id, Supplier blockSupplier ) - { - this.factory = factory; - this.registryName = id; - this.blockSupplier = blockSupplier; - - if( Platform.hasClientClasses() ) - { - this.blockRendering = new BlockRendering(); - this.itemRendering = new ItemRendering(); - } - } - - @Override - public BlockDefinitionBuilder bootstrap( BiFunction callback ) - { - this.bootstrapComponents.add( callback ); - return this; - } - - @Override - public IBlockBuilder features( AEFeature... features ) - { - this.features.clear(); - this.addFeatures( features ); - return this; - } - - @Override - public IBlockBuilder addFeatures( AEFeature... features ) - { - Collections.addAll( this.features, features ); - return this; - } + if (Platform.hasClientClasses()) { + this.blockRendering = new BlockRendering(); + this.itemRendering = new ItemRendering(); + } + } @Override - public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback ) - { - if( Platform.hasClientClasses() ) - { - this.customizeForClient( callback ); - } + public BlockDefinitionBuilder bootstrap(BiFunction callback) { + this.bootstrapComponents.add(callback); + return this; + } - return this; - } + @Override + public IBlockBuilder features(AEFeature... features) { + this.features.clear(); + this.addFeatures(features); + return this; + } - @Override - public IBlockBuilder tileEntity( TileEntityDefinition tileEntityDefinition ) - { - this.tileEntityDefinition = tileEntityDefinition; - return this; - } + @Override + public IBlockBuilder addFeatures(AEFeature... features) { + Collections.addAll(this.features, features); + return this; + } - @Override - public IBlockBuilder item( BiFunction factory ) - { - this.itemFactory = factory; - return this; - } + @Override + public BlockDefinitionBuilder rendering(BlockRenderingCustomizer callback) { + if (Platform.hasClientClasses()) { + this.customizeForClient(callback); + } - @Override - public IBlockBuilder disableItem() - { - this.disableItem = true; - return this; - } + return this; + } - @OnlyIn( Dist.CLIENT ) - private void customizeForClient( BlockRenderingCustomizer callback ) - { - callback.customize( this.blockRendering, this.itemRendering ); - } + @Override + public IBlockBuilder tileEntity(TileEntityDefinition tileEntityDefinition) { + this.tileEntityDefinition = tileEntityDefinition; + return this; + } - @SuppressWarnings( "unchecked" ) - @Override - public T build() - { - // Create block and matching item, and set factory name of both - Block block = this.blockSupplier.get(); - block.setRegistryName( AppEng.MOD_ID, this.registryName ); + @Override + public IBlockBuilder item(BiFunction factory) { + this.itemFactory = factory; + return this; + } - BlockItem item = this.constructItemFromBlock( block ); - if( item != null ) - { - item.setRegistryName( AppEng.MOD_ID, this.registryName ); - } + @Override + public IBlockBuilder disableItem() { + this.disableItem = true; + return this; + } - // Register the item and block with the game - this.factory.addBootstrapComponent( (IBlockRegistrationComponent) ( side, registry ) -> registry.register( block ) ); - if( item != null ) - { - this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, registry ) -> registry.register( item ) ); - } + @OnlyIn(Dist.CLIENT) + private void customizeForClient(BlockRenderingCustomizer callback) { + callback.customize(this.blockRendering, this.itemRendering); + } - // Register all extra handlers - this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) ); + @SuppressWarnings("unchecked") + @Override + public T build() { + // Create block and matching item, and set factory name of both + Block block = this.blockSupplier.get(); + block.setRegistryName(AppEng.MOD_ID, this.registryName); - if (this.tileEntityDefinition != null) - { - // Tell the tile entity definition about the block we've registered - this.tileEntityDefinition.addBlock(block); - } + BlockItem item = this.constructItemFromBlock(block); + if (item != null) { + item.setRegistryName(AppEng.MOD_ID, this.registryName); + } - if( Platform.hasClientClasses() ) - { - this.blockRendering.apply( this.factory, block ); + // Register the item and block with the game + this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block)); + if (item != null) { + this.factory + .addBootstrapComponent((IItemRegistrationComponent) (side, registry) -> registry.register(item)); + } - if( item != null ) - { - this.itemRendering.apply( this.factory, item ); - } - } + // Register all extra handlers + this.bootstrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(block, item))); - T definition; - if( block instanceof AEBaseTileBlock ) - { - definition = (T) new TileDefinition( this.registryName, (AEBaseTileBlock) block, item, features ); - } - else - { - definition = (T) new BlockDefinition( this.registryName, block, item, features ); - } + if (this.tileEntityDefinition != null) { + // Tell the tile entity definition about the block we've registered + this.tileEntityDefinition.addBlock(block); + } - if (itemGroup instanceof AEItemGroup) { - ((AEItemGroup) itemGroup).add(definition); - } + if (Platform.hasClientClasses()) { + this.blockRendering.apply(this.factory, block); - return definition; - } + if (item != null) { + this.itemRendering.apply(this.factory, item); + } + } - @Nullable - private BlockItem constructItemFromBlock( Block block ) - { - if( this.disableItem ) - { - return null; - } + T definition; + if (block instanceof AEBaseTileBlock) { + definition = (T) new TileDefinition(this.registryName, (AEBaseTileBlock) block, item, features); + } else { + definition = (T) new BlockDefinition(this.registryName, block, item, features); + } - Item.Properties itemProperties = new Item.Properties(); + if (itemGroup instanceof AEItemGroup) { + ((AEItemGroup) itemGroup).add(definition); + } - if (itemGroup != null) { - itemProperties.group(itemGroup); - } - // FIXME: Allow more/all item properties + return definition; + } - if( this.itemFactory != null ) - { - return this.itemFactory.apply( block, itemProperties ); - } - else if( block instanceof AEBaseBlock ) - { - return new AEBaseBlockItem( block, itemProperties ); - } - else - { - return new BlockItem( block, itemProperties ); - } - } + @Nullable + private BlockItem constructItemFromBlock(Block block) { + if (this.disableItem) { + return null; + } + + Item.Properties itemProperties = new Item.Properties(); + + if (itemGroup != null) { + itemProperties.group(itemGroup); + } + // FIXME: Allow more/all item properties + + if (this.itemFactory != null) { + return this.itemFactory.apply(block, itemProperties); + } else if (block instanceof AEBaseBlock) { + return new AEBaseBlockItem(block, itemProperties); + } else { + return new BlockItem(block, itemProperties); + } + } } diff --git a/src/main/java/appeng/bootstrap/BlockRendering.java b/src/main/java/appeng/bootstrap/BlockRendering.java index 091bc2aa3..9d2b32c96 100644 --- a/src/main/java/appeng/bootstrap/BlockRendering.java +++ b/src/main/java/appeng/bootstrap/BlockRendering.java @@ -18,11 +18,9 @@ package appeng.bootstrap; +import java.util.function.BiFunction; +import java.util.function.Predicate; -import appeng.block.AEBaseTileBlock; -import appeng.bootstrap.components.BlockColorComponent; -import appeng.bootstrap.components.RenderTypeComponent; -import appeng.client.render.model.AutoRotatingBakedModel; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.color.IBlockColor; @@ -35,74 +33,68 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.function.BiFunction; -import java.util.function.Predicate; +import appeng.block.AEBaseTileBlock; +import appeng.bootstrap.components.BlockColorComponent; +import appeng.bootstrap.components.RenderTypeComponent; +import appeng.client.render.model.AutoRotatingBakedModel; +class BlockRendering implements IBlockRendering { -class BlockRendering implements IBlockRendering -{ + @OnlyIn(Dist.CLIENT) + private BiFunction modelCustomizer; - @OnlyIn( Dist.CLIENT ) - private BiFunction modelCustomizer; + @OnlyIn(Dist.CLIENT) + private IBlockColor blockColor; - @OnlyIn( Dist.CLIENT ) - private IBlockColor blockColor; + @OnlyIn(Dist.CLIENT) + private RenderType renderType; - @OnlyIn( Dist.CLIENT ) - private RenderType renderType; + @OnlyIn(Dist.CLIENT) + private Predicate renderTypes; - @OnlyIn( Dist.CLIENT ) - private Predicate renderTypes; + @Override + @OnlyIn(Dist.CLIENT) + public IBlockRendering modelCustomizer(BiFunction customizer) { + this.modelCustomizer = customizer; + return this; + } - @Override - @OnlyIn( Dist.CLIENT ) - public IBlockRendering modelCustomizer( BiFunction customizer ) - { - this.modelCustomizer = customizer; - return this; - } + @OnlyIn(Dist.CLIENT) + @Override + public IBlockRendering blockColor(IBlockColor blockColor) { + this.blockColor = blockColor; + return this; + } - @OnlyIn( Dist.CLIENT ) - @Override - public IBlockRendering blockColor( IBlockColor blockColor ) - { - this.blockColor = blockColor; - return this; - } + @Override + public IBlockRendering renderType(RenderType type) { + this.renderType = type; + return this; + } - @Override - public IBlockRendering renderType(RenderType type) { - this.renderType = type; - return this; - } + @Override + public IBlockRendering renderType(Predicate typePredicate) { + this.renderTypes = typePredicate; + return this; + } - @Override - public IBlockRendering renderType(Predicate typePredicate) { - this.renderTypes = typePredicate; - return this; - } + void apply(FeatureFactory factory, Block block) { + if (this.modelCustomizer != null) { + factory.addModelOverride(block.getRegistryName().getPath(), this.modelCustomizer); + } else if (block instanceof AEBaseTileBlock) { + // This is a default rotating model if the base-block uses an AE tile entity + // which exposes UP/FRONT as + // extended props + factory.addModelOverride(block.getRegistryName().getPath(), (l, m) -> new AutoRotatingBakedModel(m)); + } - void apply( FeatureFactory factory, Block block ) - { - if( this.modelCustomizer != null ) - { - factory.addModelOverride( block.getRegistryName().getPath(), this.modelCustomizer ); - } - else if( block instanceof AEBaseTileBlock ) - { - // This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as - // extended props - factory.addModelOverride( block.getRegistryName().getPath(), ( l, m ) -> new AutoRotatingBakedModel( m ) ); - } + // TODO : 1.12 + if (this.blockColor != null) { + factory.addBootstrapComponent(new BlockColorComponent(block, this.blockColor)); + } - // TODO : 1.12 - if( this.blockColor != null ) - { - factory.addBootstrapComponent( new BlockColorComponent( block, this.blockColor ) ); - } - - if (this.renderType != null || this.renderTypes != null) { - factory.addBootstrapComponent( new RenderTypeComponent( block, this.renderType, this.renderTypes)); - } - } + if (this.renderType != null || this.renderTypes != null) { + factory.addBootstrapComponent(new RenderTypeComponent(block, this.renderType, this.renderTypes)); + } + } } diff --git a/src/main/java/appeng/bootstrap/BlockRenderingCustomizer.java b/src/main/java/appeng/bootstrap/BlockRenderingCustomizer.java index 4d1c69030..90ebb6ce9 100644 --- a/src/main/java/appeng/bootstrap/BlockRenderingCustomizer.java +++ b/src/main/java/appeng/bootstrap/BlockRenderingCustomizer.java @@ -18,20 +18,17 @@ package appeng.bootstrap; - import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - /** - * A callback that allows the rendering of a block to be customized. Sadly this class is required and no lambdas can be - * used - * due to them not being able to be annotated with @OnlyIn(CLIENT). + * A callback that allows the rendering of a block to be customized. Sadly this + * class is required and no lambdas can be used due to them not being able to be + * annotated with @OnlyIn(CLIENT). */ -public abstract class BlockRenderingCustomizer -{ +public abstract class BlockRenderingCustomizer { - @OnlyIn( Dist.CLIENT ) - public abstract void customize( IBlockRendering rendering, IItemRendering itemRendering ); + @OnlyIn(Dist.CLIENT) + public abstract void customize(IBlockRendering rendering, IItemRendering itemRendering); } diff --git a/src/main/java/appeng/bootstrap/EntityBuilder.java b/src/main/java/appeng/bootstrap/EntityBuilder.java index 8e2cefcbe..1ad4fa0b9 100644 --- a/src/main/java/appeng/bootstrap/EntityBuilder.java +++ b/src/main/java/appeng/bootstrap/EntityBuilder.java @@ -1,5 +1,16 @@ package appeng.bootstrap; +import java.util.Collections; +import java.util.EnumSet; +import java.util.function.Consumer; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.registry.RenderingRegistry; + import appeng.api.features.AEFeature; import appeng.bootstrap.components.IClientSetupComponent; import appeng.bootstrap.components.IEntityRegistrationComponent; @@ -8,16 +19,6 @@ import appeng.entity.EntityFloatingItem; import appeng.entity.EntityTinyTNTPrimed; import appeng.entity.RenderFloatingItem; import appeng.entity.RenderTinyTNTPrimed; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.registry.RenderingRegistry; - -import java.util.Collections; -import java.util.EnumSet; -import java.util.function.Consumer; /** * Helper to register a custom Entity with Minecraft. @@ -32,7 +33,8 @@ public class EntityBuilder { private final EnumSet features = EnumSet.noneOf(AEFeature.class); - public EntityBuilder(FeatureFactory factory, String id, EntityType.IFactory entityFactory, EntityClassification classification) { + public EntityBuilder(FeatureFactory factory, String id, EntityType.IFactory entityFactory, + EntityClassification classification) { this.factory = factory; this.id = id; this.builder = EntityType.Builder.create(entityFactory, classification); diff --git a/src/main/java/appeng/bootstrap/FeatureFactory.java b/src/main/java/appeng/bootstrap/FeatureFactory.java index ec38add83..097a277f0 100644 --- a/src/main/java/appeng/bootstrap/FeatureFactory.java +++ b/src/main/java/appeng/bootstrap/FeatureFactory.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -30,8 +29,6 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -import appeng.bootstrap.components.ModelOverrideComponent; -import appeng.tile.AEBaseTile; import net.minecraft.block.Block; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IUnbakedModel; @@ -45,86 +42,75 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.features.AEFeature; +import appeng.bootstrap.components.ModelOverrideComponent; +import appeng.tile.AEBaseTile; import appeng.util.Platform; +public class FeatureFactory { -public class FeatureFactory -{ + private final AEFeature[] defaultFeatures; - private final AEFeature[] defaultFeatures; + private final Map, List> bootstrapComponents; - private final Map, List> bootstrapComponents; + @OnlyIn(Dist.CLIENT) + private ModelOverrideComponent modelOverrideComponent; - @OnlyIn( Dist.CLIENT ) - private ModelOverrideComponent modelOverrideComponent; + public FeatureFactory() { + this.defaultFeatures = new AEFeature[] { AEFeature.CORE }; + this.bootstrapComponents = new HashMap<>(); - public FeatureFactory() - { - this.defaultFeatures = new AEFeature[] { AEFeature.CORE }; - this.bootstrapComponents = new HashMap<>(); + if (Platform.hasClientClasses()) { + this.modelOverrideComponent = new ModelOverrideComponent(); + this.addBootstrapComponent(this.modelOverrideComponent); + } + } - if( Platform.hasClientClasses() ) - { - this.modelOverrideComponent = new ModelOverrideComponent(); - this.addBootstrapComponent( this.modelOverrideComponent ); - } - } + private FeatureFactory(FeatureFactory parent, AEFeature... defaultFeatures) { + this.defaultFeatures = defaultFeatures.clone(); + this.bootstrapComponents = parent.bootstrapComponents; + if (Platform.hasClientClasses()) { + this.modelOverrideComponent = parent.modelOverrideComponent; + } + } - private FeatureFactory( FeatureFactory parent, AEFeature... defaultFeatures ) - { - this.defaultFeatures = defaultFeatures.clone(); - this.bootstrapComponents = parent.bootstrapComponents; - if( Platform.hasClientClasses() ) - { - this.modelOverrideComponent = parent.modelOverrideComponent; - } - } + public IBlockBuilder block(String id, Supplier block) { + return new BlockDefinitionBuilder(this, id, block).features(this.defaultFeatures); + } - public IBlockBuilder block( String id, Supplier block ) - { - return new BlockDefinitionBuilder( this, id, block ).features( this.defaultFeatures ); - } + public IItemBuilder item(String id, Function itemFactory) { + return new ItemDefinitionBuilder(this, id, itemFactory).features(this.defaultFeatures); + } - public IItemBuilder item( String id, Function itemFactory ) - { - return new ItemDefinitionBuilder( this, id, itemFactory ).features( this.defaultFeatures ); - } + public EntityBuilder entity(String id, EntityType.IFactory factory, + EntityClassification classification) { + return new EntityBuilder(this, id, factory, classification).features(this.defaultFeatures); + } - public EntityBuilder entity(String id, EntityType.IFactory factory, EntityClassification classification) - { - return new EntityBuilder( this, id, factory, classification ).features( this.defaultFeatures ); - } + public TileEntityBuilder tileEntity(String id, Class teClass, + Function, T> factory) { + return new TileEntityBuilder<>(this, id, teClass, factory).features(this.defaultFeatures); + } - public TileEntityBuilder tileEntity(String id, Class teClass, Function, T> factory) - { - return new TileEntityBuilder<>( this, id, teClass, factory ).features( this.defaultFeatures ); - } + public FeatureFactory features(AEFeature... features) { + return new FeatureFactory(this, features); + } - public FeatureFactory features( AEFeature... features ) - { - return new FeatureFactory( this, features ); - } + public void addBootstrapComponent(IBootstrapComponent component) { + Arrays.stream(component.getClass().getInterfaces()).filter(i -> IBootstrapComponent.class.isAssignableFrom(i)) + .forEach(i -> this.addBootstrapComponent((Class) i, component)); + } - public void addBootstrapComponent( IBootstrapComponent component ) - { - Arrays.stream( component.getClass().getInterfaces() ) - .filter( i -> IBootstrapComponent.class.isAssignableFrom( i ) ) - .forEach( i -> this.addBootstrapComponent( (Class) i, component ) ); - } + private void addBootstrapComponent(Class eventType, + T component) { + this.bootstrapComponents.computeIfAbsent(eventType, c -> new ArrayList()).add(component); + } - private void addBootstrapComponent( Class eventType, T component ) - { - this.bootstrapComponents.computeIfAbsent( eventType, c -> new ArrayList() ).add( component ); - } + @OnlyIn(Dist.CLIENT) + void addModelOverride(String resourcePath, BiFunction customizer) { + this.modelOverrideComponent.addOverride(resourcePath, customizer); + } - @OnlyIn( Dist.CLIENT ) - void addModelOverride( String resourcePath, BiFunction customizer ) - { - this.modelOverrideComponent.addOverride( resourcePath, customizer ); - } - - public Iterator getBootstrapComponents( Class eventType ) - { - return (Iterator) this.bootstrapComponents.getOrDefault( eventType, Collections.emptyList() ).iterator(); - } + public Iterator getBootstrapComponents(Class eventType) { + return (Iterator) this.bootstrapComponents.getOrDefault(eventType, Collections.emptyList()).iterator(); + } } diff --git a/src/main/java/appeng/bootstrap/IBlockBuilder.java b/src/main/java/appeng/bootstrap/IBlockBuilder.java index c5a08cfd1..e32864522 100644 --- a/src/main/java/appeng/bootstrap/IBlockBuilder.java +++ b/src/main/java/appeng/bootstrap/IBlockBuilder.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.function.BiFunction; import net.minecraft.block.Block; @@ -26,28 +25,26 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import appeng.api.definitions.IBlockDefinition; -import appeng.bootstrap.definitions.TileEntityDefinition; import appeng.api.features.AEFeature; +import appeng.bootstrap.definitions.TileEntityDefinition; +public interface IBlockBuilder { + IBlockBuilder bootstrap(BiFunction component); -public interface IBlockBuilder -{ - IBlockBuilder bootstrap( BiFunction component ); + IBlockBuilder features(AEFeature... features); - IBlockBuilder features( AEFeature... features ); + IBlockBuilder addFeatures(AEFeature... features); - IBlockBuilder addFeatures( AEFeature... features ); + IBlockBuilder rendering(BlockRenderingCustomizer callback); - IBlockBuilder rendering( BlockRenderingCustomizer callback ); + IBlockBuilder tileEntity(TileEntityDefinition tileEntityDefinition); - IBlockBuilder tileEntity( TileEntityDefinition tileEntityDefinition ); + /** + * Don't register an item for this block. + */ + IBlockBuilder disableItem(); - /** - * Don't register an item for this block. - */ - IBlockBuilder disableItem(); + IBlockBuilder item(BiFunction factory); - IBlockBuilder item( BiFunction factory ); - - T build(); + T build(); } diff --git a/src/main/java/appeng/bootstrap/IBlockRendering.java b/src/main/java/appeng/bootstrap/IBlockRendering.java index dc7332ab9..58cc3ba38 100644 --- a/src/main/java/appeng/bootstrap/IBlockRendering.java +++ b/src/main/java/appeng/bootstrap/IBlockRendering.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; @@ -34,23 +33,22 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - /** - * Allows for client-side rendering to be customized in the context of block/item registration. + * Allows for client-side rendering to be customized in the context of + * block/item registration. */ -public interface IBlockRendering -{ +public interface IBlockRendering { - @OnlyIn( Dist.CLIENT ) - IBlockRendering modelCustomizer( BiFunction customizer ); + @OnlyIn(Dist.CLIENT) + IBlockRendering modelCustomizer(BiFunction customizer); - @OnlyIn( Dist.CLIENT ) - IBlockRendering blockColor( IBlockColor blockColor ); + @OnlyIn(Dist.CLIENT) + IBlockRendering blockColor(IBlockColor blockColor); - @OnlyIn( Dist.CLIENT ) - IBlockRendering renderType(RenderType type); + @OnlyIn(Dist.CLIENT) + IBlockRendering renderType(RenderType type); - @OnlyIn( Dist.CLIENT ) - IBlockRendering renderType(Predicate type); + @OnlyIn(Dist.CLIENT) + IBlockRendering renderType(Predicate type); } diff --git a/src/main/java/appeng/bootstrap/IBootstrapComponent.java b/src/main/java/appeng/bootstrap/IBootstrapComponent.java index 717271d55..c395dcb7e 100644 --- a/src/main/java/appeng/bootstrap/IBootstrapComponent.java +++ b/src/main/java/appeng/bootstrap/IBootstrapComponent.java @@ -18,11 +18,10 @@ package appeng.bootstrap; - /** - * Bootstrap components can be registered to take part in the various initialization phases of Forge. - * See the individual subclasses for a specific forge initalization event. + * Bootstrap components can be registered to take part in the various + * initialization phases of Forge. See the individual subclasses for a specific + * forge initalization event. */ -public interface IBootstrapComponent -{ +public interface IBootstrapComponent { } diff --git a/src/main/java/appeng/bootstrap/ICriterionTriggerRegistry.java b/src/main/java/appeng/bootstrap/ICriterionTriggerRegistry.java index c62ab00fd..888c266d0 100644 --- a/src/main/java/appeng/bootstrap/ICriterionTriggerRegistry.java +++ b/src/main/java/appeng/bootstrap/ICriterionTriggerRegistry.java @@ -18,13 +18,10 @@ package appeng.bootstrap; - import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancements.ICriterionTrigger; - @FunctionalInterface -public interface ICriterionTriggerRegistry -{ - void register( ICriterionTrigger trigger ); +public interface ICriterionTriggerRegistry { + void register(ICriterionTrigger trigger); } diff --git a/src/main/java/appeng/bootstrap/IItemBuilder.java b/src/main/java/appeng/bootstrap/IItemBuilder.java index 8b53e3d64..dd289aa3b 100644 --- a/src/main/java/appeng/bootstrap/IItemBuilder.java +++ b/src/main/java/appeng/bootstrap/IItemBuilder.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -30,29 +29,27 @@ import net.minecraft.item.ItemGroup; import appeng.api.features.AEFeature; import appeng.core.features.ItemDefinition; - /** - * Allows an item to be defined and registered with the game. - * The item is only registered once build is called. + * Allows an item to be defined and registered with the game. The item is only + * registered once build is called. */ -public interface IItemBuilder -{ - IItemBuilder bootstrap( Function component ); +public interface IItemBuilder { + IItemBuilder bootstrap(Function component); - IItemBuilder features( AEFeature... features ); + IItemBuilder features(AEFeature... features); - IItemBuilder addFeatures( AEFeature... features ); + IItemBuilder addFeatures(AEFeature... features); - IItemBuilder itemGroup( ItemGroup tab ); + IItemBuilder itemGroup(ItemGroup tab); - IItemBuilder props(Consumer customizer); + IItemBuilder props(Consumer customizer); - IItemBuilder rendering( ItemRenderingCustomizer callback ); + IItemBuilder rendering(ItemRenderingCustomizer callback); - /** - * Registers a custom dispenser behavior for this item. - */ - IItemBuilder dispenserBehavior( Supplier behavior ); + /** + * Registers a custom dispenser behavior for this item. + */ + IItemBuilder dispenserBehavior(Supplier behavior); - ItemDefinition build(); + ItemDefinition build(); } diff --git a/src/main/java/appeng/bootstrap/IItemRendering.java b/src/main/java/appeng/bootstrap/IItemRendering.java index 8492e01e4..545ee3c5b 100644 --- a/src/main/java/appeng/bootstrap/IItemRendering.java +++ b/src/main/java/appeng/bootstrap/IItemRendering.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.Arrays; import java.util.Collection; @@ -27,35 +26,32 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - /** * Allows the rendering of an item to be customized. */ -public interface IItemRendering -{ +public interface IItemRendering { - /** - * Convenient override for {@link #variants(Collection)}. - */ - @OnlyIn( Dist.CLIENT ) - default IItemRendering variants( ResourceLocation... resources ) - { - return this.variants( Arrays.asList( resources ) ); - } + /** + * Convenient override for {@link #variants(Collection)}. + */ + @OnlyIn(Dist.CLIENT) + default IItemRendering variants(ResourceLocation... resources) { + return this.variants(Arrays.asList(resources)); + } - /** - * Registers the item variants of this item. This are all models that need to be loaded for this item. - * This has no direct effect on rendering, but is used to load models that are used for example by - * the ItemMeshDefinition. - */ - @OnlyIn( Dist.CLIENT ) - IItemRendering variants( Collection resources ); + /** + * Registers the item variants of this item. This are all models that need to be + * loaded for this item. This has no direct effect on rendering, but is used to + * load models that are used for example by the ItemMeshDefinition. + */ + @OnlyIn(Dist.CLIENT) + IItemRendering variants(Collection resources); - /** - * Registers a custom item color definition that inspects an item stack and tint and - * returns a color multiplier. - */ - @OnlyIn( Dist.CLIENT ) - IItemRendering color( IItemColor itemColor ); + /** + * Registers a custom item color definition that inspects an item stack and tint + * and returns a color multiplier. + */ + @OnlyIn(Dist.CLIENT) + IItemRendering color(IItemColor itemColor); } diff --git a/src/main/java/appeng/bootstrap/IModelRegistry.java b/src/main/java/appeng/bootstrap/IModelRegistry.java index e4750833f..b1c2eb0ec 100644 --- a/src/main/java/appeng/bootstrap/IModelRegistry.java +++ b/src/main/java/appeng/bootstrap/IModelRegistry.java @@ -18,15 +18,12 @@ package appeng.bootstrap; - import net.minecraft.block.Block; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; - -public interface IModelRegistry -{ - void registerItemVariants( Item item, ResourceLocation... names ); +public interface IModelRegistry { + void registerItemVariants(Item item, ResourceLocation... names); } diff --git a/src/main/java/appeng/bootstrap/ItemDefinitionBuilder.java b/src/main/java/appeng/bootstrap/ItemDefinitionBuilder.java index 67017161e..cd4f37a6d 100644 --- a/src/main/java/appeng/bootstrap/ItemDefinitionBuilder.java +++ b/src/main/java/appeng/bootstrap/ItemDefinitionBuilder.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; @@ -27,151 +26,134 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; -import appeng.bootstrap.components.IInitComponent; -import appeng.core.AEItemGroup; import net.minecraft.block.DispenserBlock; import net.minecraft.dispenser.IDispenseItemBehavior; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; - -import appeng.bootstrap.components.IItemRegistrationComponent; -import appeng.core.AppEng; -import appeng.core.CreativeTab; -import appeng.api.features.AEFeature; -import appeng.core.features.ItemDefinition; -import appeng.util.Platform; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.api.features.AEFeature; +import appeng.bootstrap.components.IInitComponent; +import appeng.bootstrap.components.IItemRegistrationComponent; +import appeng.core.AEItemGroup; +import appeng.core.AppEng; +import appeng.core.CreativeTab; +import appeng.core.features.ItemDefinition; +import appeng.util.Platform; -class ItemDefinitionBuilder implements IItemBuilder -{ +class ItemDefinitionBuilder implements IItemBuilder { - private final FeatureFactory factory; + private final FeatureFactory factory; - private final String registryName; + private final String registryName; - private final Function itemFactory; + private final Function itemFactory; - private final EnumSet features = EnumSet.noneOf( AEFeature.class ); + private final EnumSet features = EnumSet.noneOf(AEFeature.class); - private final List> boostrapComponents = new ArrayList<>(); + private final List> boostrapComponents = new ArrayList<>(); - private final Item.Properties props = new Item.Properties(); + private final Item.Properties props = new Item.Properties(); - private Supplier dispenserBehaviorSupplier; + private Supplier dispenserBehaviorSupplier; - @OnlyIn( Dist.CLIENT ) - private ItemRendering itemRendering; + @OnlyIn(Dist.CLIENT) + private ItemRendering itemRendering; - private ItemGroup itemGroup = CreativeTab.INSTANCE; + private ItemGroup itemGroup = CreativeTab.INSTANCE; - ItemDefinitionBuilder( FeatureFactory factory, String registryName, Function itemFactory ) - { - this.factory = factory; - this.registryName = registryName; - this.itemFactory = itemFactory; - if( Platform.hasClientClasses() ) - { - this.itemRendering = new ItemRendering(); - } - } + ItemDefinitionBuilder(FeatureFactory factory, String registryName, Function itemFactory) { + this.factory = factory; + this.registryName = registryName; + this.itemFactory = itemFactory; + if (Platform.hasClientClasses()) { + this.itemRendering = new ItemRendering(); + } + } - @Override - public IItemBuilder bootstrap( Function component ) - { - this.boostrapComponents.add( component ); - return this; - } + @Override + public IItemBuilder bootstrap(Function component) { + this.boostrapComponents.add(component); + return this; + } - @Override - public IItemBuilder features( AEFeature... features ) - { - this.features.clear(); - this.addFeatures( features ); - return this; - } + @Override + public IItemBuilder features(AEFeature... features) { + this.features.clear(); + this.addFeatures(features); + return this; + } - @Override - public IItemBuilder addFeatures( AEFeature... features ) - { - Collections.addAll( this.features, features ); - return this; - } + @Override + public IItemBuilder addFeatures(AEFeature... features) { + Collections.addAll(this.features, features); + return this; + } - @Override - public IItemBuilder itemGroup( ItemGroup itemGroup ) - { - this.itemGroup = itemGroup; - return this; - } + @Override + public IItemBuilder itemGroup(ItemGroup itemGroup) { + this.itemGroup = itemGroup; + return this; + } - @Override - public IItemBuilder props( Consumer consumer ) - { - consumer.accept(props); - return this; - } + @Override + public IItemBuilder props(Consumer consumer) { + consumer.accept(props); + return this; + } - @Override - public IItemBuilder rendering( ItemRenderingCustomizer callback ) - { - if( Platform.hasClientClasses() ) - { - this.customizeForClient( callback ); - } + @Override + public IItemBuilder rendering(ItemRenderingCustomizer callback) { + if (Platform.hasClientClasses()) { + this.customizeForClient(callback); + } - return this; - } + return this; + } - @Override - public IItemBuilder dispenserBehavior( Supplier behavior ) - { - this.dispenserBehaviorSupplier = behavior; - return this; - } + @Override + public IItemBuilder dispenserBehavior(Supplier behavior) { + this.dispenserBehaviorSupplier = behavior; + return this; + } - @OnlyIn( Dist.CLIENT ) - private void customizeForClient( ItemRenderingCustomizer callback ) - { - callback.customize( this.itemRendering ); - } + @OnlyIn(Dist.CLIENT) + private void customizeForClient(ItemRenderingCustomizer callback) { + callback.customize(this.itemRendering); + } - @Override - public ItemDefinition build() - { - props.group(itemGroup); + @Override + public ItemDefinition build() { + props.group(itemGroup); - Item item = this.itemFactory.apply(props); - item.setRegistryName( AppEng.MOD_ID, this.registryName ); + Item item = this.itemFactory.apply(props); + item.setRegistryName(AppEng.MOD_ID, this.registryName); - ItemDefinition definition = new ItemDefinition( this.registryName, item, features ); + ItemDefinition definition = new ItemDefinition(this.registryName, item, features); - // Register all extra handlers - this.boostrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( item ) ) ); + // Register all extra handlers + this.boostrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(item))); - // Register custom dispenser behavior if requested - if( this.dispenserBehaviorSupplier != null ) - { - this.factory.addBootstrapComponent( (IInitComponent) () -> - { - IDispenseItemBehavior behavior = this.dispenserBehaviorSupplier.get(); - DispenserBlock.registerDispenseBehavior( item, behavior ); - } ); - } + // Register custom dispenser behavior if requested + if (this.dispenserBehaviorSupplier != null) { + this.factory.addBootstrapComponent((IInitComponent) () -> { + IDispenseItemBehavior behavior = this.dispenserBehaviorSupplier.get(); + DispenserBlock.registerDispenseBehavior(item, behavior); + }); + } - this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) ); + this.factory.addBootstrapComponent((IItemRegistrationComponent) (side, reg) -> reg.register(item)); - if( Platform.hasClientClasses() ) - { - this.itemRendering.apply( this.factory, item ); - } + if (Platform.hasClientClasses()) { + this.itemRendering.apply(this.factory, item); + } - if (itemGroup instanceof AEItemGroup) { - ((AEItemGroup) itemGroup).add(definition); - } + if (itemGroup instanceof AEItemGroup) { + ((AEItemGroup) itemGroup).add(definition); + } - return definition; - } + return definition; + } } diff --git a/src/main/java/appeng/bootstrap/ItemRendering.java b/src/main/java/appeng/bootstrap/ItemRendering.java index fcd4dc0b2..38638fe00 100644 --- a/src/main/java/appeng/bootstrap/ItemRendering.java +++ b/src/main/java/appeng/bootstrap/ItemRendering.java @@ -18,7 +18,6 @@ package appeng.bootstrap; - import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -32,44 +31,37 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.bootstrap.components.ItemColorComponent; import appeng.bootstrap.components.ItemVariantsComponent; +class ItemRendering implements IItemRendering { -class ItemRendering implements IItemRendering -{ + @OnlyIn(Dist.CLIENT) + private IItemColor itemColor; - @OnlyIn( Dist.CLIENT ) - private IItemColor itemColor; + @OnlyIn(Dist.CLIENT) + private Set variants = new HashSet<>(); - @OnlyIn( Dist.CLIENT ) - private Set variants = new HashSet<>(); + @Override + public IItemRendering variants(Collection resources) { + this.variants.addAll(resources); + return this; + } - @Override - public IItemRendering variants( Collection resources ) - { - this.variants.addAll( resources ); - return this; - } + @Override + @OnlyIn(Dist.CLIENT) + public IItemRendering color(IItemColor itemColor) { + this.itemColor = itemColor; + return this; + } - @Override - @OnlyIn( Dist.CLIENT ) - public IItemRendering color( IItemColor itemColor ) - { - this.itemColor = itemColor; - return this; - } + void apply(FeatureFactory factory, Item item) { + Set resources = new HashSet<>(this.variants); - void apply( FeatureFactory factory, Item item ) - { - Set resources = new HashSet<>( this.variants ); + if (!resources.isEmpty()) { + factory.addBootstrapComponent(new ItemVariantsComponent(item, resources)); + } - if( !resources.isEmpty() ) - { - factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) ); - } - - if( this.itemColor != null ) - { - factory.addBootstrapComponent( new ItemColorComponent( item, this.itemColor ) ); - } - } + if (this.itemColor != null) { + factory.addBootstrapComponent(new ItemColorComponent(item, this.itemColor)); + } + } } diff --git a/src/main/java/appeng/bootstrap/ItemRenderingCustomizer.java b/src/main/java/appeng/bootstrap/ItemRenderingCustomizer.java index bc820802b..e8167ad85 100644 --- a/src/main/java/appeng/bootstrap/ItemRenderingCustomizer.java +++ b/src/main/java/appeng/bootstrap/ItemRenderingCustomizer.java @@ -18,19 +18,16 @@ package appeng.bootstrap; - import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - /** - * A callback that allows the rendering of a item to be customized. Sadly this class is required and no lambdas can be - * used - * due to them not being able to be annotated with @OnlyIn(CLIENT). + * A callback that allows the rendering of a item to be customized. Sadly this + * class is required and no lambdas can be used due to them not being able to be + * annotated with @OnlyIn(CLIENT). */ -public abstract class ItemRenderingCustomizer -{ +public abstract class ItemRenderingCustomizer { - @OnlyIn( Dist.CLIENT ) - public abstract void customize( IItemRendering rendering ); + @OnlyIn(Dist.CLIENT) + public abstract void customize(IItemRendering rendering); } diff --git a/src/main/java/appeng/bootstrap/TileEntityBuilder.java b/src/main/java/appeng/bootstrap/TileEntityBuilder.java index 4b7b548db..a0877fd1b 100644 --- a/src/main/java/appeng/bootstrap/TileEntityBuilder.java +++ b/src/main/java/appeng/bootstrap/TileEntityBuilder.java @@ -1,23 +1,5 @@ package appeng.bootstrap; -import appeng.block.AEBaseTileBlock; -import appeng.bootstrap.components.IClientSetupComponent; -import appeng.bootstrap.components.ITileEntityRegistrationComponent; -import appeng.bootstrap.definitions.TileEntityDefinition; -import appeng.core.AppEng; -import appeng.api.features.AEFeature; -import appeng.core.features.ActivityState; -import appeng.core.features.BlockStackSrc; -import appeng.tile.AEBaseTile; - -import com.google.common.base.Preconditions; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntityType; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.client.registry.ClientRegistry; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; @@ -25,8 +7,28 @@ import java.util.List; import java.util.function.Function; import java.util.function.Supplier; +import com.google.common.base.Preconditions; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntityType; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.client.registry.ClientRegistry; + +import appeng.api.features.AEFeature; +import appeng.block.AEBaseTileBlock; +import appeng.bootstrap.components.IClientSetupComponent; +import appeng.bootstrap.components.ITileEntityRegistrationComponent; +import appeng.bootstrap.definitions.TileEntityDefinition; +import appeng.core.AppEng; +import appeng.core.features.ActivityState; +import appeng.core.features.BlockStackSrc; +import appeng.tile.AEBaseTile; + /** - * Used to define our tile entities and all of their properties that are relevant to registering them. + * Used to define our tile entities and all of their properties that are + * relevant to registering them. * * @param */ @@ -51,7 +53,8 @@ public class TileEntityBuilder { private final EnumSet features = EnumSet.noneOf(AEFeature.class); - public TileEntityBuilder(FeatureFactory factory, String registryName, Class tileClass, Function, T> supplier) { + public TileEntityBuilder(FeatureFactory factory, String registryName, Class tileClass, + Function, T> supplier) { this.factory = factory; this.registryName = registryName; this.tileClass = tileClass; @@ -77,21 +80,17 @@ public class TileEntityBuilder { @SuppressWarnings("unchecked") public TileEntityDefinition build() { - this.factory.addBootstrapComponent((ITileEntityRegistrationComponent) registry -> - { + this.factory.addBootstrapComponent((ITileEntityRegistrationComponent) registry -> { if (blocks.isEmpty()) { throw new IllegalStateException("No blocks make use of this tile entity: " + tileClass); } Supplier factory = () -> supplier.apply(type); - type = TileEntityType.Builder.create(factory, blocks.toArray(new Block[0])) - .build(null); + type = TileEntityType.Builder.create(factory, blocks.toArray(new Block[0])).build(null); type.setRegistryName(AppEng.MOD_ID, registryName); registry.register(type); - AEBaseTile.registerTileItem( - tileClass, - new BlockStackSrc(blocks.get(0), ActivityState.Enabled)); + AEBaseTile.registerTileItem(tileClass, new BlockStackSrc(blocks.get(0), ActivityState.Enabled)); for (Block block : blocks) { if (block instanceof AEBaseTileBlock) { @@ -101,7 +100,7 @@ public class TileEntityBuilder { } }); - DistExecutor.runWhenOn( Dist.CLIENT, () -> this::buildClient ); + DistExecutor.runWhenOn(Dist.CLIENT, () -> this::buildClient); return new TileEntityDefinition(this::addBlock); @@ -109,7 +108,7 @@ public class TileEntityBuilder { @OnlyIn(Dist.CLIENT) private void buildClient() { - this.factory.addBootstrapComponent( (IClientSetupComponent) ()-> { + this.factory.addBootstrapComponent((IClientSetupComponent) () -> { if (tileEntityRendering.tileEntityRenderer != null) { ClientRegistry.bindTileEntityRenderer(type, tileEntityRendering.tileEntityRenderer); } diff --git a/src/main/java/appeng/bootstrap/TileEntityRendering.java b/src/main/java/appeng/bootstrap/TileEntityRendering.java index eb62f9241..9fa585454 100644 --- a/src/main/java/appeng/bootstrap/TileEntityRendering.java +++ b/src/main/java/appeng/bootstrap/TileEntityRendering.java @@ -18,14 +18,14 @@ package appeng.bootstrap; +import java.util.function.Function; -import appeng.tile.AEBaseTile; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.function.Function; +import appeng.tile.AEBaseTile; public class TileEntityRendering { @@ -33,7 +33,8 @@ public class TileEntityRendering { Function> tileEntityRenderer; @OnlyIn(Dist.CLIENT) - public TileEntityRendering tileEntityRenderer(Function> tileEntityRenderer) { + public TileEntityRendering tileEntityRenderer( + Function> tileEntityRenderer) { this.tileEntityRenderer = tileEntityRenderer; return this; } diff --git a/src/main/java/appeng/bootstrap/TileEntityRenderingCustomizer.java b/src/main/java/appeng/bootstrap/TileEntityRenderingCustomizer.java index 85202781b..3ebb7899c 100644 --- a/src/main/java/appeng/bootstrap/TileEntityRenderingCustomizer.java +++ b/src/main/java/appeng/bootstrap/TileEntityRenderingCustomizer.java @@ -18,20 +18,19 @@ package appeng.bootstrap; - -import appeng.tile.AEBaseTile; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.tile.AEBaseTile; /** - * A callback that allows the rendering of a tile entity to be customized. Sadly this class is required and no lambdas - * can be used due to them not being able to be annotated with @OnlyIn(CLIENT). + * A callback that allows the rendering of a tile entity to be customized. Sadly + * this class is required and no lambdas can be used due to them not being able + * to be annotated with @OnlyIn(CLIENT). */ -public abstract class TileEntityRenderingCustomizer -{ +public abstract class TileEntityRenderingCustomizer { - @OnlyIn( Dist.CLIENT ) - public abstract void customize( TileEntityRendering rendering ); + @OnlyIn(Dist.CLIENT) + public abstract void customize(TileEntityRendering rendering); } diff --git a/src/main/java/appeng/bootstrap/components/BlockColorComponent.java b/src/main/java/appeng/bootstrap/components/BlockColorComponent.java index f03dd5ca7..e1b66c241 100644 --- a/src/main/java/appeng/bootstrap/components/BlockColorComponent.java +++ b/src/main/java/appeng/bootstrap/components/BlockColorComponent.java @@ -18,30 +18,25 @@ package appeng.bootstrap.components; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraftforge.api.distmarker.Dist; +public class BlockColorComponent implements IInitComponent { -public class BlockColorComponent implements IInitComponent -{ + private final Block block; - private final Block block; + private final IBlockColor blockColor; - private final IBlockColor blockColor; + public BlockColorComponent(Block block, IBlockColor blockColor) { + this.block = block; + this.blockColor = blockColor; + } - public BlockColorComponent( Block block, IBlockColor blockColor ) - { - this.block = block; - this.blockColor = blockColor; - } - - @Override - public void initialize() - { - Minecraft.getInstance().getBlockColors().register( this.blockColor, this.block ); - } + @Override + public void initialize() { + Minecraft.getInstance().getBlockColors().register(this.blockColor, this.block); + } } diff --git a/src/main/java/appeng/bootstrap/components/IBlockRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IBlockRegistrationComponent.java index fabf01b25..8418465f4 100644 --- a/src/main/java/appeng/bootstrap/components/IBlockRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IBlockRegistrationComponent.java @@ -1,16 +1,13 @@ package appeng.bootstrap.components; - import net.minecraft.block.Block; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.registries.IForgeRegistry; import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IBlockRegistrationComponent extends IBootstrapComponent -{ - void blockRegistration( Dist dist, IForgeRegistry blockRegistry ); +public interface IBlockRegistrationComponent extends IBootstrapComponent { + void blockRegistration(Dist dist, IForgeRegistry blockRegistry); } diff --git a/src/main/java/appeng/bootstrap/components/IClientSetupComponent.java b/src/main/java/appeng/bootstrap/components/IClientSetupComponent.java index 6c7e138bf..6f37e9989 100644 --- a/src/main/java/appeng/bootstrap/components/IClientSetupComponent.java +++ b/src/main/java/appeng/bootstrap/components/IClientSetupComponent.java @@ -3,7 +3,8 @@ package appeng.bootstrap.components; import appeng.bootstrap.IBootstrapComponent; /** - * Will be run during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. + * Will be run during + * {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. */ public interface IClientSetupComponent extends IBootstrapComponent { diff --git a/src/main/java/appeng/bootstrap/components/IEntityRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IEntityRegistrationComponent.java index cd6fb8832..a19ddff17 100644 --- a/src/main/java/appeng/bootstrap/components/IEntityRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IEntityRegistrationComponent.java @@ -1,16 +1,13 @@ package appeng.bootstrap.components; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraftforge.registries.IForgeRegistry; import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IEntityRegistrationComponent extends IBootstrapComponent -{ - void entityRegistration( IForgeRegistry> entityRegistry ); +public interface IEntityRegistrationComponent extends IBootstrapComponent { + void entityRegistration(IForgeRegistry> entityRegistry); } diff --git a/src/main/java/appeng/bootstrap/components/IInitComponent.java b/src/main/java/appeng/bootstrap/components/IInitComponent.java index bafb239bb..ee1a365bf 100644 --- a/src/main/java/appeng/bootstrap/components/IInitComponent.java +++ b/src/main/java/appeng/bootstrap/components/IInitComponent.java @@ -18,14 +18,11 @@ package appeng.bootstrap.components; - import net.minecraftforge.api.distmarker.Dist; import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IInitComponent extends IBootstrapComponent -{ - void initialize(); +public interface IInitComponent extends IBootstrapComponent { + void initialize(); } diff --git a/src/main/java/appeng/bootstrap/components/IItemColorRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IItemColorRegistrationComponent.java index 1f3fc5d40..7d7d003b8 100644 --- a/src/main/java/appeng/bootstrap/components/IItemColorRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IItemColorRegistrationComponent.java @@ -1,9 +1,10 @@ package appeng.bootstrap.components; -import appeng.bootstrap.IBootstrapComponent; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; +import appeng.bootstrap.IBootstrapComponent; + public interface IItemColorRegistrationComponent extends IBootstrapComponent { void register(ItemColors itemColors, BlockColors blockColors); diff --git a/src/main/java/appeng/bootstrap/components/IItemRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IItemRegistrationComponent.java index 05921badd..ffb82b25f 100644 --- a/src/main/java/appeng/bootstrap/components/IItemRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IItemRegistrationComponent.java @@ -1,16 +1,13 @@ package appeng.bootstrap.components; - import net.minecraft.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.registries.IForgeRegistry; import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IItemRegistrationComponent extends IBootstrapComponent -{ - void itemRegistration( Dist dist, IForgeRegistry itemRegistry ); +public interface IItemRegistrationComponent extends IBootstrapComponent { + void itemRegistration(Dist dist, IForgeRegistry itemRegistry); } diff --git a/src/main/java/appeng/bootstrap/components/IModelBakeComponent.java b/src/main/java/appeng/bootstrap/components/IModelBakeComponent.java index 54a2a314a..5190f74be 100644 --- a/src/main/java/appeng/bootstrap/components/IModelBakeComponent.java +++ b/src/main/java/appeng/bootstrap/components/IModelBakeComponent.java @@ -1,8 +1,9 @@ package appeng.bootstrap.components; -import appeng.bootstrap.IBootstrapComponent; import net.minecraftforge.client.event.ModelBakeEvent; +import appeng.bootstrap.IBootstrapComponent; + public interface IModelBakeComponent extends IBootstrapComponent { void onModelBakeEvent(ModelBakeEvent event); diff --git a/src/main/java/appeng/bootstrap/components/IModelRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IModelRegistrationComponent.java index 92dc19370..258134a53 100644 --- a/src/main/java/appeng/bootstrap/components/IModelRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IModelRegistrationComponent.java @@ -18,19 +18,16 @@ package appeng.bootstrap.components; - import net.minecraftforge.api.distmarker.Dist; import appeng.bootstrap.IBootstrapComponent; import appeng.bootstrap.IModelRegistry; - /** * @author GuntherDW */ @FunctionalInterface -public interface IModelRegistrationComponent extends IBootstrapComponent -{ - void modelRegistration( Dist dist, IModelRegistry registry ); +public interface IModelRegistrationComponent extends IBootstrapComponent { + void modelRegistration(Dist dist, IModelRegistry registry); } diff --git a/src/main/java/appeng/bootstrap/components/IPostInitComponent.java b/src/main/java/appeng/bootstrap/components/IPostInitComponent.java index bfa520926..c9b7a3a1a 100644 --- a/src/main/java/appeng/bootstrap/components/IPostInitComponent.java +++ b/src/main/java/appeng/bootstrap/components/IPostInitComponent.java @@ -18,12 +18,9 @@ package appeng.bootstrap.components; - import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IPostInitComponent extends IBootstrapComponent -{ - void postInitialize(); +public interface IPostInitComponent extends IBootstrapComponent { + void postInitialize(); } diff --git a/src/main/java/appeng/bootstrap/components/IRecipeRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/IRecipeRegistrationComponent.java index 1ba39158b..9ea405877 100644 --- a/src/main/java/appeng/bootstrap/components/IRecipeRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/IRecipeRegistrationComponent.java @@ -1,7 +1,6 @@ package appeng.bootstrap.components; - import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraftforge.api.distmarker.Dist; @@ -9,9 +8,7 @@ import net.minecraftforge.registries.IForgeRegistry; import appeng.bootstrap.IBootstrapComponent; - @FunctionalInterface -public interface IRecipeRegistrationComponent extends IBootstrapComponent -{ - void recipeRegistration( Dist dist, IForgeRegistry> recipeRegistry ); +public interface IRecipeRegistrationComponent extends IBootstrapComponent { + void recipeRegistration(Dist dist, IForgeRegistry> recipeRegistry); } diff --git a/src/main/java/appeng/bootstrap/components/ITileEntityRegistrationComponent.java b/src/main/java/appeng/bootstrap/components/ITileEntityRegistrationComponent.java index eae8d36e4..29f20e8bb 100644 --- a/src/main/java/appeng/bootstrap/components/ITileEntityRegistrationComponent.java +++ b/src/main/java/appeng/bootstrap/components/ITileEntityRegistrationComponent.java @@ -1,9 +1,10 @@ package appeng.bootstrap.components; -import appeng.bootstrap.IBootstrapComponent; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.IForgeRegistry; +import appeng.bootstrap.IBootstrapComponent; + @FunctionalInterface public interface ITileEntityRegistrationComponent extends IBootstrapComponent { void register(IForgeRegistry> registry); diff --git a/src/main/java/appeng/bootstrap/components/ItemColorComponent.java b/src/main/java/appeng/bootstrap/components/ItemColorComponent.java index 3a6d1cf58..a340ecfeb 100644 --- a/src/main/java/appeng/bootstrap/components/ItemColorComponent.java +++ b/src/main/java/appeng/bootstrap/components/ItemColorComponent.java @@ -18,28 +18,23 @@ package appeng.bootstrap.components; - import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.item.Item; +public class ItemColorComponent implements IItemColorRegistrationComponent { + private final Item item; -public class ItemColorComponent implements IItemColorRegistrationComponent -{ - private final Item item; + private final IItemColor itemColor; - private final IItemColor itemColor; + public ItemColorComponent(Item item, IItemColor itemColor) { + this.item = item; + this.itemColor = itemColor; + } - public ItemColorComponent( Item item, IItemColor itemColor ) - { - this.item = item; - this.itemColor = itemColor; - } - - @Override - public void register(ItemColors itemColors, BlockColors blockColors) - { - itemColors.register( this.itemColor, this.item ); - } + @Override + public void register(ItemColors itemColors, BlockColors blockColors) { + itemColors.register(this.itemColor, this.item); + } } diff --git a/src/main/java/appeng/bootstrap/components/ItemMeshDefinitionComponent.java b/src/main/java/appeng/bootstrap/components/ItemMeshDefinitionComponent.java index 468211b10..f7bfe7afc 100644 --- a/src/main/java/appeng/bootstrap/components/ItemMeshDefinitionComponent.java +++ b/src/main/java/appeng/bootstrap/components/ItemMeshDefinitionComponent.java @@ -18,19 +18,15 @@ package appeng.bootstrap.components; - - import net.minecraftforge.api.distmarker.Dist; import appeng.bootstrap.IModelRegistry; - /** - * Registers a custom item mesh definition that can be used to dynamically determine the item model based on - * item stack properties. + * Registers a custom item mesh definition that can be used to dynamically + * determine the item model based on item stack properties. */ -public class ItemMeshDefinitionComponent implements IModelRegistrationComponent -{ +public class ItemMeshDefinitionComponent implements IModelRegistrationComponent { // FIXME private final Item item; // FIXME @@ -42,9 +38,8 @@ public class ItemMeshDefinitionComponent implements IModelRegistrationComponent // FIXME this.meshDefinition = meshDefinition; // FIXME } - @Override - public void modelRegistration( Dist dist, IModelRegistry registry ) - { - // FIXME registry.setCustomMeshDefinition( this.item, this.meshDefinition ); - } + @Override + public void modelRegistration(Dist dist, IModelRegistry registry) { + // FIXME registry.setCustomMeshDefinition( this.item, this.meshDefinition ); + } } diff --git a/src/main/java/appeng/bootstrap/components/ItemVariantsComponent.java b/src/main/java/appeng/bootstrap/components/ItemVariantsComponent.java index f2421b0c7..d3ac34198 100644 --- a/src/main/java/appeng/bootstrap/components/ItemVariantsComponent.java +++ b/src/main/java/appeng/bootstrap/components/ItemVariantsComponent.java @@ -18,7 +18,6 @@ package appeng.bootstrap.components; - import java.util.Collection; import net.minecraft.item.Item; @@ -27,24 +26,20 @@ import net.minecraftforge.api.distmarker.Dist; import appeng.bootstrap.IModelRegistry; +public class ItemVariantsComponent implements IModelRegistrationComponent { -public class ItemVariantsComponent implements IModelRegistrationComponent -{ + private final Item item; - private final Item item; + private final Collection resources; - private final Collection resources; + public ItemVariantsComponent(Item item, Collection resources) { + this.item = item; + this.resources = resources; + } - public ItemVariantsComponent( Item item, Collection resources ) - { - this.item = item; - this.resources = resources; - } - - @Override - public void modelRegistration( Dist dist, IModelRegistry registry ) - { - ResourceLocation[] resourceArr = this.resources.toArray( new ResourceLocation[0] ); - registry.registerItemVariants( this.item, resourceArr ); - } + @Override + public void modelRegistration(Dist dist, IModelRegistry registry) { + ResourceLocation[] resourceArr = this.resources.toArray(new ResourceLocation[0]); + registry.registerItemVariants(this.item, resourceArr); + } } diff --git a/src/main/java/appeng/bootstrap/components/ModelOverrideComponent.java b/src/main/java/appeng/bootstrap/components/ModelOverrideComponent.java index 72b0d05cb..b9d27054b 100644 --- a/src/main/java/appeng/bootstrap/components/ModelOverrideComponent.java +++ b/src/main/java/appeng/bootstrap/components/ModelOverrideComponent.java @@ -18,7 +18,6 @@ package appeng.bootstrap.components; - import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -33,49 +32,40 @@ import net.minecraftforge.client.event.ModelBakeEvent; import appeng.core.AppEng; +public class ModelOverrideComponent implements IModelBakeComponent { -public class ModelOverrideComponent implements IModelBakeComponent -{ + // Maps from resource path to customizer + private final Map> customizer = new HashMap<>(); - // Maps from resource path to customizer - private final Map> customizer = new HashMap<>(); + public void addOverride(String resourcePath, BiFunction customizer) { + this.customizer.put(resourcePath, customizer); + } - public void addOverride( String resourcePath, BiFunction customizer ) - { - this.customizer.put( resourcePath, customizer ); - } + public void onModelBakeEvent(final ModelBakeEvent event) { + Map modelRegistry = event.getModelRegistry(); + Set keys = Sets.newHashSet(modelRegistry.keySet()); + IBakedModel missingModel = modelRegistry.get(ModelBakery.MODEL_MISSING); - public void onModelBakeEvent( final ModelBakeEvent event ) - { - Map modelRegistry = event.getModelRegistry(); - Set keys = Sets.newHashSet( modelRegistry.keySet() ); - IBakedModel missingModel = modelRegistry.get(ModelBakery.MODEL_MISSING); + for (ResourceLocation location : keys) { + if (!location.getNamespace().equals(AppEng.MOD_ID)) { + continue; + } - for( ResourceLocation location : keys ) - { - if( !location.getNamespace().equals( AppEng.MOD_ID ) ) - { - continue; - } + IBakedModel orgModel = modelRegistry.get(location); - IBakedModel orgModel = modelRegistry.get( location ); + // Don't customize the missing model. This causes Forge to swallow exceptions + if (orgModel == missingModel) { + continue; + } - // Don't customize the missing model. This causes Forge to swallow exceptions - if( orgModel == missingModel ) - { - continue; - } + BiFunction customizer = this.customizer.get(location.getPath()); + if (customizer != null) { + IBakedModel newModel = customizer.apply(location, orgModel); - BiFunction customizer = this.customizer.get( location.getPath() ); - if( customizer != null ) - { - IBakedModel newModel = customizer.apply( location, orgModel ); - - if( newModel != orgModel ) - { - modelRegistry.put( location, newModel ); - } - } - } - } + if (newModel != orgModel) { + modelRegistry.put(location, newModel); + } + } + } + } } diff --git a/src/main/java/appeng/bootstrap/components/RenderTypeComponent.java b/src/main/java/appeng/bootstrap/components/RenderTypeComponent.java index aceb2e0f4..01ecdb6b8 100644 --- a/src/main/java/appeng/bootstrap/components/RenderTypeComponent.java +++ b/src/main/java/appeng/bootstrap/components/RenderTypeComponent.java @@ -1,11 +1,11 @@ package appeng.bootstrap.components; +import java.util.function.Predicate; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import java.util.function.Predicate; - /** * Sets the rendering type for a block. */ diff --git a/src/main/java/appeng/bootstrap/components/StateMapperComponent.java b/src/main/java/appeng/bootstrap/components/StateMapperComponent.java index 3375ca8a0..478b7e77a 100644 --- a/src/main/java/appeng/bootstrap/components/StateMapperComponent.java +++ b/src/main/java/appeng/bootstrap/components/StateMapperComponent.java @@ -18,19 +18,16 @@ package appeng.bootstrap.components; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import appeng.bootstrap.IModelRegistry; - /** * Registers a custom state mapper for a given block. */ -public class StateMapperComponent implements IModelRegistrationComponent -{ +public class StateMapperComponent implements IModelRegistrationComponent { // FIXME private final Block block; @@ -42,14 +39,15 @@ public class StateMapperComponent implements IModelRegistrationComponent // FIXME this.stateMapper = stateMapper; // FIXME } - @Override - public void modelRegistration( Dist dist, IModelRegistry registry ) - { - // FIXME registry.setCustomStateMapper( this.block, this.stateMapper ); - // FIXME if( this.stateMapper instanceof IResourceManagerReloadListener ) - // FIXME { - // FIXME ( (IReloadableResourceManager) Minecraft.getInstance().getResourceManager() ) - // FIXME .registerReloadListener( (IResourceManagerReloadListener) this.stateMapper ); - // FIXME } - } + @Override + public void modelRegistration(Dist dist, IModelRegistry registry) { + // FIXME registry.setCustomStateMapper( this.block, this.stateMapper ); + // FIXME if( this.stateMapper instanceof IResourceManagerReloadListener ) + // FIXME { + // FIXME ( (IReloadableResourceManager) + // Minecraft.getInstance().getResourceManager() ) + // FIXME .registerReloadListener( (IResourceManagerReloadListener) + // this.stateMapper ); + // FIXME } + } } diff --git a/src/main/java/appeng/bootstrap/definitions/TileEntityDefinition.java b/src/main/java/appeng/bootstrap/definitions/TileEntityDefinition.java index 9229a6e8f..ef1c3b1a6 100644 --- a/src/main/java/appeng/bootstrap/definitions/TileEntityDefinition.java +++ b/src/main/java/appeng/bootstrap/definitions/TileEntityDefinition.java @@ -18,12 +18,11 @@ package appeng.bootstrap.definitions; - -import appeng.tile.AEBaseTile; -import net.minecraft.block.Block; - import java.util.function.Consumer; +import net.minecraft.block.Block; + +import appeng.tile.AEBaseTile; /** * @author GuntherDW @@ -34,7 +33,7 @@ public class TileEntityDefinition { private final Consumer addBlockListener; public TileEntityDefinition(Consumer addBlockListener) { - this.addBlockListener = addBlockListener; + this.addBlockListener = addBlockListener; } public void addBlock(Block block) { diff --git a/src/main/java/appeng/capabilities/Capabilities.java b/src/main/java/appeng/capabilities/Capabilities.java index 293803b19..58a9b477b 100644 --- a/src/main/java/appeng/capabilities/Capabilities.java +++ b/src/main/java/appeng/capabilities/Capabilities.java @@ -18,7 +18,6 @@ package appeng.capabilities; - import net.minecraft.nbt.INBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; @@ -29,66 +28,56 @@ import net.minecraftforge.energy.IEnergyStorage; import appeng.api.storage.ISpatialDimension; import appeng.api.storage.IStorageMonitorableAccessor; - /** * Utility class that holds various capabilities, both by AE2 and other Mods. */ -public final class Capabilities -{ +public final class Capabilities { - private Capabilities() - { - } + private Capabilities() { + } - public static Capability STORAGE_MONITORABLE_ACCESSOR; + public static Capability STORAGE_MONITORABLE_ACCESSOR; - public static Capability SPATIAL_DIMENSION; + public static Capability SPATIAL_DIMENSION; - public static Capability FORGE_ENERGY; + public static Capability FORGE_ENERGY; - /** - * Register AE2 provided capabilities. - */ - public static void register() - { - CapabilityManager.INSTANCE.register( IStorageMonitorableAccessor.class, createNullStorage(), NullMENetworkAccessor::new ); - CapabilityManager.INSTANCE.register( ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new ); - } + /** + * Register AE2 provided capabilities. + */ + public static void register() { + CapabilityManager.INSTANCE.register(IStorageMonitorableAccessor.class, createNullStorage(), + NullMENetworkAccessor::new); + CapabilityManager.INSTANCE.register(ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new); + } - @CapabilityInject( IStorageMonitorableAccessor.class ) - private static void capIStorageMonitorableAccessorRegistered( Capability cap ) - { - STORAGE_MONITORABLE_ACCESSOR = cap; - } + @CapabilityInject(IStorageMonitorableAccessor.class) + private static void capIStorageMonitorableAccessorRegistered(Capability cap) { + STORAGE_MONITORABLE_ACCESSOR = cap; + } - @CapabilityInject( ISpatialDimension.class ) - private static void capISpatialDimensionRegistered( Capability cap ) - { - SPATIAL_DIMENSION = cap; - } + @CapabilityInject(ISpatialDimension.class) + private static void capISpatialDimensionRegistered(Capability cap) { + SPATIAL_DIMENSION = cap; + } - @CapabilityInject( IEnergyStorage.class ) - private static void capIEnergyStorageRegistered( Capability cap ) - { - FORGE_ENERGY = cap; - } + @CapabilityInject(IEnergyStorage.class) + private static void capIEnergyStorageRegistered(Capability cap) { + FORGE_ENERGY = cap; + } - // Create a storage implementation that does not do anything - private static Capability.IStorage createNullStorage() - { - return new Capability.IStorage() - { - @Override - public INBT writeNBT( Capability capability, T instance, Direction side ) - { - return null; - } + // Create a storage implementation that does not do anything + private static Capability.IStorage createNullStorage() { + return new Capability.IStorage() { + @Override + public INBT writeNBT(Capability capability, T instance, Direction side) { + return null; + } - @Override - public void readNBT( Capability capability, T instance, Direction side, INBT nbt ) - { + @Override + public void readNBT(Capability capability, T instance, Direction side, INBT nbt) { - } - }; - } + } + }; + } } diff --git a/src/main/java/appeng/capabilities/NullMENetworkAccessor.java b/src/main/java/appeng/capabilities/NullMENetworkAccessor.java index c4b67f000..bc8488410 100644 --- a/src/main/java/appeng/capabilities/NullMENetworkAccessor.java +++ b/src/main/java/appeng/capabilities/NullMENetworkAccessor.java @@ -18,19 +18,15 @@ package appeng.capabilities; - import appeng.api.networking.security.IActionSource; import appeng.api.storage.IStorageMonitorable; import appeng.api.storage.IStorageMonitorableAccessor; +class NullMENetworkAccessor implements IStorageMonitorableAccessor { -class NullMENetworkAccessor implements IStorageMonitorableAccessor -{ - - @Override - public IStorageMonitorable getInventory( IActionSource src ) - { - return null; - } + @Override + public IStorageMonitorable getInventory(IActionSource src) { + return null; + } } diff --git a/src/main/java/appeng/capabilities/NullSpatialDimension.java b/src/main/java/appeng/capabilities/NullSpatialDimension.java index 73734be6e..fd43550a6 100644 --- a/src/main/java/appeng/capabilities/NullSpatialDimension.java +++ b/src/main/java/appeng/capabilities/NullSpatialDimension.java @@ -18,55 +18,47 @@ package appeng.capabilities; +import java.util.List; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; - -import appeng.api.storage.ISpatialDimension; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; -import java.util.List; +import appeng.api.storage.ISpatialDimension; +class NullSpatialDimension implements ISpatialDimension { + @Override + public DimensionType createNewCellDimension(BlockPos size) { + return null; + } -class NullSpatialDimension implements ISpatialDimension -{ - @Override - public DimensionType createNewCellDimension(BlockPos size) - { - return null; - } + @Override + public void deleteCellDimension(DimensionType cellStorageId) { + } - @Override - public void deleteCellDimension( DimensionType cellStorageId ) - { - } + @Override + public BlockPos getCellDimensionOrigin(DimensionType cellStorageId) { + return null; + } - @Override - public BlockPos getCellDimensionOrigin( DimensionType cellStorageId ) - { - return null; - } - - @Override - public BlockPos getCellDimensionSize(DimensionType cellDim) { - return BlockPos.ZERO; - } + @Override + public BlockPos getCellDimensionSize(DimensionType cellDim) { + return BlockPos.ZERO; + } @Override public void addCellDimensionTooltip(DimensionType cellDim, List tooltip) { } @Override - public ServerWorld getWorld(DimensionType cellStorageId ) - { - return null; - } + public ServerWorld getWorld(DimensionType cellStorageId) { + return null; + } - @Override - public boolean isCellDimension( DimensionType cellDimID ) - { - return false; - } + @Override + public boolean isCellDimension(DimensionType cellDimID) { + return false; + } } diff --git a/src/main/java/appeng/client/ActionKey.java b/src/main/java/appeng/client/ActionKey.java index 052cb0e10..fab4b96a6 100644 --- a/src/main/java/appeng/client/ActionKey.java +++ b/src/main/java/appeng/client/ActionKey.java @@ -1,27 +1,22 @@ package appeng.client; - import org.lwjgl.glfw.GLFW; -public enum ActionKey -{ - TOGGLE_FOCUS( GLFW.GLFW_KEY_TAB ); +public enum ActionKey { + TOGGLE_FOCUS(GLFW.GLFW_KEY_TAB); - private final int defaultKey; + private final int defaultKey; - private ActionKey( int defaultKey ) - { - this.defaultKey = defaultKey; - } + private ActionKey(int defaultKey) { + this.defaultKey = defaultKey; + } - public String getTranslationKey() - { - return "key." + this.name().toLowerCase() + ".desc"; - } + public String getTranslationKey() { + return "key." + this.name().toLowerCase() + ".desc"; + } - public int getDefaultKey() - { - return this.defaultKey; - } + public int getDefaultKey() { + return this.defaultKey; + } } diff --git a/src/main/java/appeng/client/ClientHelper.java b/src/main/java/appeng/client/ClientHelper.java index 8f868e178..c1a913493 100644 --- a/src/main/java/appeng/client/ClientHelper.java +++ b/src/main/java/appeng/client/ClientHelper.java @@ -18,14 +18,8 @@ package appeng.client; - import java.util.*; -import appeng.client.render.effects.*; -import appeng.core.AEConfig; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketAssemblerAnimation; -import appeng.core.sync.packets.PacketValueConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.util.InputMappings; @@ -39,160 +33,144 @@ import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; - -import appeng.api.parts.CableRenderMode; -import appeng.block.AEBaseBlock; -import appeng.core.AppEng; -import appeng.helpers.IMouseWheelItem; -import appeng.server.ServerHelper; -import appeng.util.Platform; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import appeng.api.parts.CableRenderMode; +import appeng.block.AEBaseBlock; +import appeng.client.render.effects.*; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketAssemblerAnimation; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.helpers.IMouseWheelItem; +import appeng.server.ServerHelper; +import appeng.util.Platform; -public class ClientHelper extends ServerHelper -{ - private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; +public class ClientHelper extends ServerHelper { + private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; - private final EnumMap bindings = new EnumMap<>( ActionKey.class ); + private final EnumMap bindings = new EnumMap<>(ActionKey.class); - public void clientInit() - { - MinecraftForge.EVENT_BUS.addListener(this::postPlayerRender); - MinecraftForge.EVENT_BUS.addListener(this::wheelEvent); + public void clientInit() { + MinecraftForge.EVENT_BUS.addListener(this::postPlayerRender); + MinecraftForge.EVENT_BUS.addListener(this::wheelEvent); - for( ActionKey key : ActionKey.values() ) - { - final KeyBinding binding = new KeyBinding( key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY ); - ClientRegistry.registerKeyBinding( binding ); - this.bindings.put( key, binding ); - } - } + for (ActionKey key : ActionKey.values()) { + final KeyBinding binding = new KeyBinding(key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY); + ClientRegistry.registerKeyBinding(binding); + this.bindings.put(key, binding); + } + } - @Override - public World getWorld() - { - if( Platform.isClient() ) - { - return Minecraft.getInstance().world; - } - else - { - return super.getWorld(); - } - } + @Override + public World getWorld() { + if (Platform.isClient()) { + return Minecraft.getInstance().world; + } else { + return super.getWorld(); + } + } - @Override - public void bindTileEntitySpecialRenderer( final Class tile, final AEBaseBlock blk ) - { + @Override + public void bindTileEntitySpecialRenderer(final Class tile, final AEBaseBlock blk) { - } + } - @Override - public List getPlayers() - { - if( Platform.isClient() ) - { - return Collections.singletonList(Minecraft.getInstance().player); - } - else - { - return super.getPlayers(); - } - } + @Override + public List getPlayers() { + if (Platform.isClient()) { + return Collections.singletonList(Minecraft.getInstance().player); + } else { + return super.getPlayers(); + } + } - // FIXME: Instead of doing a custom packet and this dispatcher, we can use the vanilla particle system - @Override - public void spawnEffect( final EffectType effect, final World world, final double posX, final double posY, final double posZ, final Object o ) - { - if( AEConfig.instance().isEnableEffects() ) - { - switch( effect ) - { - case Assembler: - this.spawnAssembler( world, posX, posY, posZ, o ); - return; - case Vibrant: - this.spawnVibrant( world, posX, posY, posZ ); - return; - case Crafting: - this.spawnCrafting( world, posX, posY, posZ ); - return; - case Energy: - this.spawnEnergy( world, posX, posY, posZ ); - return; - case Lightning: - this.spawnLightning( world, posX, posY, posZ ); - return; - case LightningArc: - this.spawnLightningArc( world, posX, posY, posZ, (Vec3d) o ); - return; - default: - } - } - } + // FIXME: Instead of doing a custom packet and this dispatcher, we can use the + // vanilla particle system + @Override + public void spawnEffect(final EffectType effect, final World world, final double posX, final double posY, + final double posZ, final Object o) { + if (AEConfig.instance().isEnableEffects()) { + switch (effect) { + case Assembler: + this.spawnAssembler(world, posX, posY, posZ, o); + return; + case Vibrant: + this.spawnVibrant(world, posX, posY, posZ); + return; + case Crafting: + this.spawnCrafting(world, posX, posY, posZ); + return; + case Energy: + this.spawnEnergy(world, posX, posY, posZ); + return; + case Lightning: + this.spawnLightning(world, posX, posY, posZ); + return; + case LightningArc: + this.spawnLightningArc(world, posX, posY, posZ, (Vec3d) o); + return; + default: + } + } + } - @Override - public boolean shouldAddParticles( final Random r ) - { - switch (Minecraft.getInstance().gameSettings.particles) { - default: - case ALL: - return true; - case DECREASED: - return r.nextBoolean(); - case MINIMAL: - return false; - } - } + @Override + public boolean shouldAddParticles(final Random r) { + switch (Minecraft.getInstance().gameSettings.particles) { + default: + case ALL: + return true; + case DECREASED: + return r.nextBoolean(); + case MINIMAL: + return false; + } + } - @Override - public RayTraceResult getRTR() - { - return Minecraft.getInstance().objectMouseOver; - } + @Override + public RayTraceResult getRTR() { + return Minecraft.getInstance().objectMouseOver; + } - @Override - public void postInit() - { - } + @Override + public void postInit() { + } - @Override - public CableRenderMode getRenderMode() - { - if( Platform.isServer() ) - { - return super.getRenderMode(); - } + @Override + public CableRenderMode getRenderMode() { + if (Platform.isServer()) { + return super.getRenderMode(); + } - final Minecraft mc = Minecraft.getInstance(); - final PlayerEntity player = mc.player; + final Minecraft mc = Minecraft.getInstance(); + final PlayerEntity player = mc.player; - return this.renderModeForPlayer( player ); - } + return this.renderModeForPlayer(player); + } - @Override - public void triggerUpdates() - { - final Minecraft mc = Minecraft.getInstance(); - if( mc.player == null || mc.world == null ) - { - return; - } + @Override + public void triggerUpdates() { + final Minecraft mc = Minecraft.getInstance(); + if (mc.player == null || mc.world == null) { + return; + } - final PlayerEntity player = mc.player; + final PlayerEntity player = mc.player; - final int x = (int) player.getPosX(); - final int y = (int) player.getPosY(); - final int z = (int) player.getPosZ(); + final int x = (int) player.getPosX(); + final int y = (int) player.getPosY(); + final int z = (int) player.getPosZ(); - final int range = 16 * 16; + final int range = 16 * 16; - mc.worldRenderer.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range ); - } + mc.worldRenderer.markBlockRangeForRenderUpdate(x - range, y - range, z - range, x + range, y + range, + z + range); + } - private void postPlayerRender( final RenderLivingEvent.Pre p ) - { + private void postPlayerRender(final RenderLivingEvent.Pre p) { // FIXME final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() ); // FIXME if( player != null ) // FIXME { @@ -203,83 +181,80 @@ public class ClientHelper extends ServerHelper // FIXME // FIXME: This is most certainly not going to work! // FIXME GlStateManager.color4f( r / 255.0f, g / 255.0f, b / 255.0f, 1.0f ); // FIXME } - } + } - // FIXME: double check all of these particle spawns, also move any of these that are triggered as part of a packet to the vanilla way of spawning particles from the server directly - private void spawnAssembler( final World world, final double posX, final double posY, final double posZ, final Object o ) - { - final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o; + // FIXME: double check all of these particle spawns, also move any of these that + // are triggered as part of a packet to the vanilla way of spawning particles + // from the server directly + private void spawnAssembler(final World world, final double posX, final double posY, final double posZ, + final Object o) { + final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o; - final AssemblerFX fx = new AssemblerFX( world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is.asItemStackRepresentation() ); - Minecraft.getInstance().particles.addEffect( fx ); - } + final AssemblerFX fx = new AssemblerFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, + paa.is.asItemStackRepresentation()); + Minecraft.getInstance().particles.addEffect(fx); + } - private void spawnVibrant( final World w, final double x, final double y, final double z ) - { - if( AppEng.proxy.shouldAddParticles( Platform.getRandom() ) ) - { - final double d0 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D; - final double d1 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D; - final double d2 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D; + private void spawnVibrant(final World w, final double x, final double y, final double z) { + if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) { + final double d0 = (Platform.getRandomFloat() - 0.5F) * 0.26D; + final double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D; + final double d2 = (Platform.getRandomFloat() - 0.5F) * 0.26D; - Minecraft.getInstance().particles.addParticle(VibrantFX.TYPE, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D); - } - } + Minecraft.getInstance().particles.addParticle(VibrantFX.TYPE, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D); + } + } - private void spawnCrafting( final World w, final double posX, final double posY, final double posZ ) - { - final float x = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; - final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; - final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; + private void spawnCrafting(final World w, final double posX, final double posY, final double posZ) { + final float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; + final float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; + final float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; - Minecraft.getInstance().particles.addParticle(CraftingFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.2, -y * 0.2, -z * 0.2); - } + Minecraft.getInstance().particles.addParticle(CraftingFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.2, -y * 0.2, + -z * 0.2); + } - private void spawnEnergy( final World w, final double posX, final double posY, final double posZ ) - { - final float x = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; - final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; - final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f; + private void spawnEnergy(final World w, final double posX, final double posY, final double posZ) { + final float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; + final float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; + final float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f; - Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.1, -y * 0.1, -z * 0.1); - } + Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.1, -y * 0.1, + -z * 0.1); + } - private void spawnLightning( final World world, final double posX, final double posY, final double posZ ) - { - Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f); - } + private void spawnLightning(final World world, final double posX, final double posY, final double posZ) { + Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f); + } - private void spawnLightningArc( final World world, final double posX, final double posY, final double posZ, final Vec3d second ) - { - final LightningFX fx = new LightningArcFX( world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, 0.0f ); - Minecraft.getInstance().particles.addEffect( fx ); - } + private void spawnLightningArc(final World world, final double posX, final double posY, final double posZ, + final Vec3d second) { + final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, + 0.0f); + Minecraft.getInstance().particles.addEffect(fx); + } - private void wheelEvent( final InputEvent.MouseScrollEvent me ) - { - if( me.getScrollDelta() == 0 ) - { - return; - } + private void wheelEvent(final InputEvent.MouseScrollEvent me) { + if (me.getScrollDelta() == 0) { + return; + } - final Minecraft mc = Minecraft.getInstance(); - final PlayerEntity player = mc.player; - if( player.isCrouching() ) - { - final boolean mainHand = player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem; - final boolean offHand = player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem; + final Minecraft mc = Minecraft.getInstance(); + final PlayerEntity player = mc.player; + if (player.isCrouching()) { + final boolean mainHand = player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem; + final boolean offHand = player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem; - if( mainHand || offHand ) - { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getScrollDelta() > 0 ? "WheelUp" : "WheelDown" ) ); - me.setCanceled( true ); - } - } - } + if (mainHand || offHand) { + NetworkHandler.instance() + .sendToServer(new PacketValueConfig("Item", me.getScrollDelta() > 0 ? "WheelUp" : "WheelDown")); + me.setCanceled(true); + } + } + } - @Override - public boolean isActionKey( ActionKey key, InputMappings.Input pressedKey ) - { - return this.bindings.get( key ).isActiveAndMatches( pressedKey ); - } + @Override + public boolean isActionKey(ActionKey key, InputMappings.Input pressedKey) { + return this.bindings.get(key).isActiveAndMatches(pressedKey); + } } \ No newline at end of file diff --git a/src/main/java/appeng/client/EffectType.java b/src/main/java/appeng/client/EffectType.java index 8929909e5..474a67a10 100644 --- a/src/main/java/appeng/client/EffectType.java +++ b/src/main/java/appeng/client/EffectType.java @@ -18,8 +18,6 @@ package appeng.client; - -public enum EffectType -{ - Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc +public enum EffectType { + Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc } diff --git a/src/main/java/appeng/client/gui/AEBaseGui.java b/src/main/java/appeng/client/gui/AEBaseGui.java index 9fdb6cd8a..5dc7e33d1 100644 --- a/src/main/java/appeng/client/gui/AEBaseGui.java +++ b/src/main/java/appeng/client/gui/AEBaseGui.java @@ -18,31 +18,17 @@ package appeng.client.gui; +import java.util.*; +import java.util.concurrent.TimeUnit; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IAEItemStack; -import appeng.client.gui.widgets.GuiCustomSlot; -import appeng.client.gui.widgets.GuiScrollbar; -import appeng.client.gui.widgets.ITooltip; -import appeng.client.me.InternalSlotME; -import appeng.client.me.SlotDisconnected; -import appeng.client.me.SlotME; -import appeng.client.render.StackSizeRenderer; -import appeng.container.AEBaseContainer; -import appeng.container.slot.*; -import appeng.container.slot.AppEngSlot.hasCalculatedValidness; -import appeng.core.AELog; -import appeng.core.AppEng; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketInventoryAction; -import appeng.core.sync.packets.PacketSwapSlots; -import appeng.fluids.client.render.FluidStackSizeRenderer; -import appeng.fluids.container.slots.IMEFluidSlot; -import appeng.helpers.InventoryAction; import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; + +import org.lwjgl.glfw.GLFW; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.gui.screen.inventory.ContainerScreen; @@ -66,847 +52,720 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fml.client.gui.GuiUtils; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL11; - -import java.util.*; -import java.util.concurrent.TimeUnit; - - -public abstract class AEBaseGui extends ContainerScreen -{ - private final List meSlots = new ArrayList<>(); - // drag y - private final Set drag_click = new HashSet<>(); - private final StackSizeRenderer stackSizeRenderer = new StackSizeRenderer(); - private final FluidStackSizeRenderer fluidStackSizeRenderer = new FluidStackSizeRenderer(); - private GuiScrollbar myScrollBar = null; - private boolean disableShiftClick = false; - private Stopwatch dbl_clickTimer = Stopwatch.createStarted(); - private ItemStack dbl_whichItem = ItemStack.EMPTY; - private Slot bl_clicked; - protected final List guiSlots = new ArrayList<>(); - - public AEBaseGui(T container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } - - @Override - public void init() - { - super.init(); - - final List slots = this.getInventorySlots(); - slots.removeIf(slot -> slot instanceof SlotME); - - for( final InternalSlotME me : this.meSlots ) - { - slots.add( new SlotME( me ) ); - } - } - - private List getInventorySlots() - { - return this.container.inventorySlots; - } - - @Override - public void render(final int mouseX, final int mouseY, final float partialTicks ) - { - super.renderBackground(); - super.render( mouseX, mouseY, partialTicks ); - - RenderSystem.pushMatrix(); - RenderSystem.translatef( this.guiLeft, this.guiTop, 0.0F ); - RenderSystem.enableDepthTest(); - for( final GuiCustomSlot c : this.guiSlots ) - { - this.drawGuiSlot( c, mouseX, mouseY, partialTicks ); - } - RenderSystem.disableDepthTest(); - for( final GuiCustomSlot c : this.guiSlots ) - { - this.drawTooltip( c, mouseX - this.guiLeft, mouseY - this.guiTop ); - } - RenderSystem.popMatrix(); - RenderSystem.enableDepthTest(); - - this.renderHoveredToolTip( mouseX, mouseY ); - - for( final Object c : this.buttons ) - { - if( c instanceof ITooltip ) - { - this.drawTooltip( (ITooltip) c, mouseX, mouseY ); - } - } - } - - protected void drawGuiSlot( GuiCustomSlot slot, int mouseX, int mouseY, float partialTicks ) - { - if( slot.isSlotEnabled() ) - { - final int left = slot.xPos(); - final int top = slot.yPos(); - final int right = left + slot.getWidth(); - final int bottom = top + slot.getHeight(); - - slot.drawContent( getMinecraft(), mouseX, mouseY, partialTicks ); - - if( this.isPointInRegion( left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY ) && slot.canClick( getPlayer() ) ) - { - RenderSystem.colorMask( true, true, true, false ); - this.fillGradient( left, top, right, bottom, -2130706433, -2130706433 ); - RenderSystem.colorMask( true, true, true, true ); - } - } - } - - private void drawTooltip( ITooltip tooltip, int mouseX, int mouseY ) - { - final int x = tooltip.xPos(); // ((GuiImgButton) c).x; - int y = tooltip.yPos(); // ((GuiImgButton) c).y; - - if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() ) - { - if( y < mouseY && y + tooltip.getHeight() > mouseY ) - { - if( y < 15 ) - { - y = 15; - } - - final String msg = tooltip.getMessage(); - if( msg != null ) - { - this.drawTooltip( x + 11, y + 4, msg ); - } - } - } - } - - protected void drawTooltip( int x, int y, String message ) - { - String[] lines = message.split( "\n" ); - this.drawTooltip( x, y, Arrays.asList( lines ) ); - } - - protected void drawTooltip( int x, int y, List lines ) - { - if( lines.isEmpty() ) - { - return; - } - - // For an explanation of the formatting codes, see http://minecraft.gamepedia.com/Formatting_codes - lines = Lists.newArrayList( lines ); // Make a copy - - // Make the first line white - lines.set( 0, TextFormatting.WHITE + lines.get( 0 ) ); - - // All lines after the first are colored gray - for( int i = 1; i < lines.size(); i++ ) - { - lines.set( i, TextFormatting.GRAY + lines.get( i ) ); - } - - this.renderTooltip( lines, x, y, this.font ); - } - - @Override - protected final void drawGuiContainerForegroundLayer( final int x, final int y ) - { - final int ox = this.guiLeft; // (width - xSize) / 2; - final int oy = this.guiTop; // (height - ySize) / 2; - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - - if( this.getScrollBar() != null ) - { - this.getScrollBar().draw( this ); - } - - this.drawFG( ox, oy, x, y ); - } - - public abstract void drawFG( int offsetX, int offsetY, int mouseX, int mouseY ); - - @Override - protected final void drawGuiContainerBackgroundLayer( final float f, final int x, final int y ) - { - final int ox = this.guiLeft; // (width - xSize) / 2; - final int oy = this.guiTop; // (height - ySize) / 2; - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - this.drawBG( ox, oy, x, y, f ); - - final List slots = this.getInventorySlots(); - for( final Slot slot : slots ) - { - if( slot instanceof IOptionalSlot ) - { - final IOptionalSlot optionalSlot = (IOptionalSlot) slot; - if( optionalSlot.isRenderDisabled() ) - { - final AppEngSlot aeSlot = (AppEngSlot) slot; - if( aeSlot.isSlotEnabled() ) - { - GuiUtils.drawTexturedModalRect( ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, - 18, - 18, - getBlitOffset()); - } - else - { - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 0.4F ); - RenderSystem.enableBlend(); - GuiUtils.drawTexturedModalRect( ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, - 18, - 18, - getBlitOffset()); - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - } - } - } - } - - for( final GuiCustomSlot slot : this.guiSlots ) - { - slot.drawBackground( ox, oy, getBlitOffset() ); - } - - } - - @Override - public boolean mouseClicked( final double xCoord, final double yCoord, final int btn ) - { - this.drag_click.clear(); - - if( btn == 1 ) - { - for( final Object o : this.buttons ) - { - final Widget widget = (Widget) o; - if( widget.isMouseOver( xCoord, yCoord ) ) - { - return super.mouseClicked( xCoord, yCoord, 0 ); - } - } - } - - for( GuiCustomSlot slot : this.guiSlots ) - { - if( this.isPointInRegion( slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord ) && slot.canClick( getPlayer() ) ) - { - slot.slotClicked( getPlayer().inventory.getItemStack(), btn ); - } - } - - if( this.getScrollBar() != null ) - { - this.getScrollBar().click(xCoord - this.guiLeft, yCoord - this.guiTop ); - } - - return super.mouseClicked( xCoord, yCoord, btn ); - } - - @Override - public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - - final Slot slot = this.getSlot( (int) mouseX, (int) mouseY ); - final ItemStack itemstack = getPlayer().inventory.getItemStack(); - - if( this.getScrollBar() != null ) - { - // FIXME: Coordinate system of mouseX/mouseY is unclear - this.getScrollBar().click((int) mouseX - this.guiLeft, (int) mouseY - this.guiTop ); - } - - if( slot instanceof SlotFake && !itemstack.isEmpty() ) - { - this.drag_click.add( slot ); - if( this.drag_click.size() > 1 ) - { - for( final Slot dr : this.drag_click ) - { - final PacketInventoryAction p = new PacketInventoryAction( mouseButton == 0 ? InventoryAction.PICKUP_OR_SET_DOWN : InventoryAction.PLACE_SINGLE, dr.slotNumber, 0 ); - NetworkHandler.instance().sendToServer( p ); - } - } - - return true; - } - else - { - return super.mouseDragged( mouseX, mouseY, mouseButton, dragX, dragY ); - } - } - - // TODO 1.9.4 aftermath - Whole ClickType thing, to be checked. - @Override - protected void handleMouseClick( final Slot slot, final int slotIdx, final int mouseButton, final ClickType clickType ) - { - final PlayerEntity player = getPlayer(); - - if( slot instanceof SlotFake ) - { - final InventoryAction action = mouseButton == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; - - if( this.drag_click.size() > 1 ) - { - return; - } - - final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); - NetworkHandler.instance().sendToServer( p ); - - return; - } - - if( slot instanceof SlotPatternTerm ) - { - if( mouseButton == 6 ) - { - return; // prevent weird double clicks.. - } - - NetworkHandler.instance().sendToServer( ( (SlotPatternTerm) slot ).getRequest( hasShiftDown() ) ); - } - else if( slot instanceof SlotCraftingTerm ) - { - if( mouseButton == 6 ) - { - return; // prevent weird double clicks.. - } - - InventoryAction action; - if( hasShiftDown() ) - { - action = InventoryAction.CRAFT_SHIFT; - } - else - { - // Craft stack on right-click, craft single on left-click - action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM; - } - - final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); - NetworkHandler.instance().sendToServer( p ); - - return; - } - - if( InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE) ) - { - if( this.enableSpaceClicking() ) - { - IAEItemStack stack = null; - if( slot instanceof SlotME ) - { - stack = ( (SlotME) slot ).getAEStack(); - } - - int slotNum = this.getInventorySlots().size(); - - if( !( slot instanceof SlotME ) && slot != null ) - { - slotNum = slot.slotNumber; - } - - ( (AEBaseContainer) this.container ).setTargetStack( stack ); - final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 ); - NetworkHandler.instance().sendToServer( p ); - return; - } - } - - if( slot instanceof SlotDisconnected ) - { - InventoryAction action = null; - - switch( clickType ) - { - case PICKUP: // pickup / set-down. - action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; - break; - case QUICK_MOVE: - action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; - break; - - case CLONE: // creative dupe: - - if( player.abilities.isCreativeMode ) - { - action = InventoryAction.CREATIVE_DUPLICATE; - } - - break; - - default: - case THROW: // drop item: - } - - if( action != null ) - { - final PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() ); - NetworkHandler.instance().sendToServer( p ); - } - - return; - } - - if( slot instanceof SlotME ) - { - InventoryAction action = null; - IAEItemStack stack = null; - - switch( clickType ) - { - case PICKUP: // pickup / set-down. - action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; - stack = ( (SlotME) slot ).getAEStack(); - - if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() - .isEmpty() ) - { - action = InventoryAction.AUTO_CRAFT; - } - - break; - case QUICK_MOVE: - action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; - stack = ( (SlotME) slot ).getAEStack(); - break; - - case CLONE: // creative dupe: - - stack = ( (SlotME) slot ).getAEStack(); - if( stack != null && stack.isCraftable() ) - { - action = InventoryAction.AUTO_CRAFT; - } - else if( player.abilities.isCreativeMode ) - { - final IAEItemStack slotItem = ( (SlotME) slot ).getAEStack(); - if( slotItem != null ) - { - action = InventoryAction.CREATIVE_DUPLICATE; - } - } - break; - - default: - case THROW: // drop item: - } - - if( action != null ) - { - this.container.setTargetStack( stack ); - final PacketInventoryAction p = new PacketInventoryAction( action, this.getInventorySlots().size(), 0 ); - NetworkHandler.instance().sendToServer( p ); - } - - return; - } - - if( !this.disableShiftClick && hasShiftDown() && mouseButton == 0 ) - { - this.disableShiftClick = true; - - if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 250 ) - { - // some simple double click logic. - this.bl_clicked = slot; - this.dbl_clickTimer = Stopwatch.createStarted(); - if( slot != null ) - { - this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY; - } - else - { - this.dbl_whichItem = ItemStack.EMPTY; - } - } - else if( !this.dbl_whichItem.isEmpty() ) - { - // a replica of the weird broken vanilla feature. - - final List slots = this.getInventorySlots(); - for( final Slot inventorySlot : slots ) - { - if( inventorySlot != null && inventorySlot.canTakeStack( - getPlayer() ) && inventorySlot.getHasStack() && inventorySlot.isSameInventory( slot ) && Container.canAddItemToSlot( - inventorySlot, this.dbl_whichItem, true ) ) - { - this.handleMouseClick( inventorySlot, inventorySlot.slotNumber, 0, ClickType.QUICK_MOVE ); - } - } - this.dbl_whichItem = ItemStack.EMPTY; - } - - this.disableShiftClick = false; - } - - super.handleMouseClick( slot, slotIdx, mouseButton, clickType ); - } - - protected boolean func_195363_d(int keyCode, int scanCode) { - return checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode)); - } - - protected ClientPlayerEntity getPlayer() { - // Our UIs are usually not opened when not in-game, so this should not be a problem - return Preconditions.checkNotNull(getMinecraft().player); - } - - protected boolean checkHotbarKeys( final InputMappings.Input input ) - { - final Slot theSlot = this.getSlotUnderMouse(); - - if( getPlayer().inventory.getItemStack().isEmpty() && theSlot != null ) - { - for( int j = 0; j < 9; ++j ) - { - if( getMinecraft().gameSettings.keyBindsHotbar[j].isActiveAndMatches(input) ) - { - final List slots = this.getInventorySlots(); - for( final Slot s : slots ) - { - if( s.getSlotIndex() == j && s.inventory == ( (AEBaseContainer) this.container ).getPlayerInv() ) - { - if( !s.canTakeStack( ( (AEBaseContainer) this.container ).getPlayerInv().player ) ) - { - return false; - } - } - } - - if( theSlot.getSlotStackLimit() == 64 ) - { - this.handleMouseClick( theSlot, theSlot.slotNumber, j, ClickType.SWAP ); - return true; - } - else - { - for( final Slot s : slots ) - { - if( s.getSlotIndex() == j && s.inventory == ( (AEBaseContainer) this.container ).getPlayerInv() ) - { - NetworkHandler.instance().sendToServer( new PacketSwapSlots( s.slotNumber, theSlot.slotNumber ) ); - return true; - } - } - } - } - } - } - - return false; - } - - @Override - public void removed() - { - super.removed(); - } - - protected Slot getSlot( final int mouseX, final int mouseY ) - { - final List slots = this.getInventorySlots(); - for( final Slot slot : slots ) - { - // isPointInRegion - if( this.isPointInRegion( slot.xPos, slot.yPos, 16, 16, mouseX, mouseY ) ) - { - return slot; - } - } - - return null; - } - - public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks); - - @Override - public boolean mouseScrolled(double x, double y, double wheelDelta) { - if( wheelDelta != 0 && hasShiftDown() ) - { - this.mouseWheelEvent( x, y, wheelDelta / Math.abs( wheelDelta ) ); - return true; - } - else if( wheelDelta != 0 && this.getScrollBar() != null ) - { - this.getScrollBar().wheel( wheelDelta ); - return true; - } - return false; - } - - private void mouseWheelEvent( final double x, final double y, final double wheel ) - { - final Slot slot = this.getSlot( (int) x, (int) y ); - if( slot instanceof SlotME ) - { - final IAEItemStack item = ( (SlotME) slot ).getAEStack(); - if( item != null ) - { - ( (AEBaseContainer) this.container ).setTargetStack( item ); - final InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP; - final int times = (int) Math.abs( wheel ); - final int inventorySize = this.getInventorySlots().size(); - for( int h = 0; h < times; h++ ) - { - final PacketInventoryAction p = new PacketInventoryAction( direction, inventorySize, 0 ); - NetworkHandler.instance().sendToServer( p ); - } - } - } - } - - protected boolean enableSpaceClicking() - { - return true; - } - - public void bindTexture( final String base, final String file ) - { - final ResourceLocation loc = new ResourceLocation( base, "textures/" + file ); - getMinecraft().getTextureManager().bindTexture( loc ); - } - - protected void drawItem( final int x, final int y, final ItemStack is ) - { - this.itemRenderer.zLevel = 100.0F; - - // FIXME I dont think this is needed anymore... - RenderHelper.enableStandardItemLighting(); - this.itemRenderer.renderItemAndEffectIntoGUI( is, x, y ); - RenderHelper.disableStandardItemLighting(); - - this.itemRenderer.zLevel = 0.0F; - } - - protected String getGuiDisplayName( final String in ) - { - return this.hasCustomInventoryName() ? this.getInventoryName() : in; - } - - private boolean hasCustomInventoryName() - { - return this.container.getCustomName() != null; - } - - private String getInventoryName() - { - return this.container.getCustomName(); - } - - /** - * This overrides the base-class method through some access transformer hackery... - */ - @Override - public void drawSlot( Slot s ) - { - if( s instanceof SlotME ) - { - - try - { - if( !this.isPowered() ) - { - fill( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111 ); - } - - // Annoying but easier than trying to splice into render item - super.drawSlot( new Size1Slot( (SlotME) s ) ); - - this.stackSizeRenderer.renderStackSize( this.font, ( (SlotME) s ).getAEStack(), s.xPos, s.yPos ); - - } - catch( final Exception err ) - { - AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() ); - } - - return; - } - else if( s instanceof IMEFluidSlot && ( (IMEFluidSlot) s ).shouldRenderAsFluid() ) - { - final IMEFluidSlot slot = (IMEFluidSlot) s; - final IAEFluidStack fs = slot.getAEFluidStack(); - - if( fs != null && this.isPowered() ) - { - RenderSystem.disableBlend(); - final Fluid fluid = fs.getFluid(); - FluidAttributes fluidAttributes = fluid.getAttributes(); - bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE ); - ResourceLocation fluidStillTexture = fluidAttributes.getStillTexture(fs.getFluidStack()); - final TextureAtlasSprite sprite = getMinecraft().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStillTexture); - - // Set color for dynamic fluids - // Convert int color to RGB - float red = ( fluidAttributes.getColor() >> 16 & 255 ) / 255.0F; - float green = ( fluidAttributes.getColor() >> 8 & 255 ) / 255.0F; - float blue = ( fluidAttributes.getColor() & 255 ) / 255.0F; - RenderSystem.color3f( red, green, blue ); - - blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite); - RenderSystem.enableBlend(); - - this.fluidStackSizeRenderer.renderStackSize( this.font, fs, s.xPos, s.yPos ); - } - else if( !this.isPowered() ) - { - fill( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111 ); - } - - return; - } - else - { - try - { - final ItemStack is = s.getStack(); - if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is.isEmpty() ) && ( ( (AppEngSlot) s ).shouldDisplay() ) ) - { - final AppEngSlot aes = (AppEngSlot) s; - if( aes.getIcon() >= 0 ) - { - this.bindTexture( "guis/states.png" ); - - try - { - final int uv_y = aes.getIcon() / 16; - final int uv_x = aes.getIcon() - uv_y * 16; - - RenderSystem.enableBlend(); - RenderSystem.enableTexture(); - RenderSystem.blendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - final float par1 = aes.xPos; - final float par2 = aes.yPos; - final float par3 = uv_x * 16; - final float par4 = uv_y * 16; - - final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder vb = tessellator.getBuffer(); - - vb.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR ); - - final float f1 = 0.00390625F; - final float f = 0.00390625F; - final float par6 = 16; - vb.pos( par1 + 0, par2 + par6, getBlitOffset() ) - .tex( ( par3 + 0 ) * f, ( par4 + par6 ) * f1 ) - .color( 1.0f, 1.0f, 1.0f, - aes.getOpacityOfIcon() ) - .endVertex(); - final float par5 = 16; - vb.pos( par1 + par5, par2 + par6, getBlitOffset() ) - .tex( ( par3 + par5 ) * f, ( par4 + par6 ) * f1 ) - .color( 1.0f, 1.0f, 1.0f, - aes.getOpacityOfIcon() ) - .endVertex(); - vb.pos( par1 + par5, par2 + 0, getBlitOffset() ) - .tex( ( par3 + par5 ) * f, ( par4 + 0 ) * f1 ) - .color( 1.0f, 1.0f, 1.0f, - aes.getOpacityOfIcon() ) - .endVertex(); - vb.pos( par1 + 0, par2 + 0, getBlitOffset() ) - .tex( ( par3 + 0 ) * f, ( par4 + 0 ) * f1 ) - .color( 1.0f, 1.0f, 1.0f, - aes.getOpacityOfIcon() ) - .endVertex(); - tessellator.draw(); - - } - catch( final Exception err ) - { - err.printStackTrace(); - } - } - } - - if( !is.isEmpty() && s instanceof AppEngSlot ) - { - if( ( (AppEngSlot) s ).getIsValid() == hasCalculatedValidness.NotAvailable ) - { - boolean isValid = s.isItemValid( - is ) || s instanceof SlotOutput || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled || s instanceof SlotInaccessible || s instanceof SlotFake || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected; - if( isValid && s instanceof SlotRestrictedInput ) - { - try - { - isValid = ( (SlotRestrictedInput) s ).isValid( is, getMinecraft().world ); - } - catch( final Exception err ) - { - AELog.debug( err ); - } - } - ( (AppEngSlot) s ).setIsValid( isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid ); - } - - if( ( (AppEngSlot) s ).getIsValid() == hasCalculatedValidness.Invalid ) - { - setBlitOffset(100); - this.itemRenderer.zLevel = 100.0F; - - fill( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666 ); - - setBlitOffset(0); - this.itemRenderer.zLevel = 0.0F; - } - } - - if( s instanceof AppEngSlot ) - { - ( (AppEngSlot) s ).setDisplay( true ); - super.drawSlot( s ); - } - else - { - super.drawSlot( s ); - } - - return; - } - catch( final Exception err ) - { - AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() ); - } - } - // do the usual for non-ME Slots. - super.drawSlot( s ); - } - - protected boolean isPowered() - { - return true; - } - - public void bindTexture( final String file ) - { - final ResourceLocation loc = new ResourceLocation( AppEng.MOD_ID, "textures/" + file ); - getMinecraft().getTextureManager().bindTexture( loc ); - } - - public void bindTexture( final ResourceLocation loc ) - { - getMinecraft().getTextureManager().bindTexture( loc ); - } - - protected GuiScrollbar getScrollBar() - { - return this.myScrollBar; - } - - protected void setScrollBar( final GuiScrollbar myScrollBar ) - { - this.myScrollBar = myScrollBar; - } - - protected List getMeSlots() - { - return this.meSlots; - } + +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; +import appeng.client.gui.widgets.GuiCustomSlot; +import appeng.client.gui.widgets.GuiScrollbar; +import appeng.client.gui.widgets.ITooltip; +import appeng.client.me.InternalSlotME; +import appeng.client.me.SlotDisconnected; +import appeng.client.me.SlotME; +import appeng.client.render.StackSizeRenderer; +import appeng.container.AEBaseContainer; +import appeng.container.slot.*; +import appeng.container.slot.AppEngSlot.hasCalculatedValidness; +import appeng.core.AELog; +import appeng.core.AppEng; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketInventoryAction; +import appeng.core.sync.packets.PacketSwapSlots; +import appeng.fluids.client.render.FluidStackSizeRenderer; +import appeng.fluids.container.slots.IMEFluidSlot; +import appeng.helpers.InventoryAction; + +public abstract class AEBaseGui extends ContainerScreen { + private final List meSlots = new ArrayList<>(); + // drag y + private final Set drag_click = new HashSet<>(); + private final StackSizeRenderer stackSizeRenderer = new StackSizeRenderer(); + private final FluidStackSizeRenderer fluidStackSizeRenderer = new FluidStackSizeRenderer(); + private GuiScrollbar myScrollBar = null; + private boolean disableShiftClick = false; + private Stopwatch dbl_clickTimer = Stopwatch.createStarted(); + private ItemStack dbl_whichItem = ItemStack.EMPTY; + private Slot bl_clicked; + protected final List guiSlots = new ArrayList<>(); + + public AEBaseGui(T container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } + + @Override + public void init() { + super.init(); + + final List slots = this.getInventorySlots(); + slots.removeIf(slot -> slot instanceof SlotME); + + for (final InternalSlotME me : this.meSlots) { + slots.add(new SlotME(me)); + } + } + + private List getInventorySlots() { + return this.container.inventorySlots; + } + + @Override + public void render(final int mouseX, final int mouseY, final float partialTicks) { + super.renderBackground(); + super.render(mouseX, mouseY, partialTicks); + + RenderSystem.pushMatrix(); + RenderSystem.translatef(this.guiLeft, this.guiTop, 0.0F); + RenderSystem.enableDepthTest(); + for (final GuiCustomSlot c : this.guiSlots) { + this.drawGuiSlot(c, mouseX, mouseY, partialTicks); + } + RenderSystem.disableDepthTest(); + for (final GuiCustomSlot c : this.guiSlots) { + this.drawTooltip(c, mouseX - this.guiLeft, mouseY - this.guiTop); + } + RenderSystem.popMatrix(); + RenderSystem.enableDepthTest(); + + this.renderHoveredToolTip(mouseX, mouseY); + + for (final Object c : this.buttons) { + if (c instanceof ITooltip) { + this.drawTooltip((ITooltip) c, mouseX, mouseY); + } + } + } + + protected void drawGuiSlot(GuiCustomSlot slot, int mouseX, int mouseY, float partialTicks) { + if (slot.isSlotEnabled()) { + final int left = slot.xPos(); + final int top = slot.yPos(); + final int right = left + slot.getWidth(); + final int bottom = top + slot.getHeight(); + + slot.drawContent(getMinecraft(), mouseX, mouseY, partialTicks); + + if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY) + && slot.canClick(getPlayer())) { + RenderSystem.colorMask(true, true, true, false); + this.fillGradient(left, top, right, bottom, -2130706433, -2130706433); + RenderSystem.colorMask(true, true, true, true); + } + } + } + + private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) { + final int x = tooltip.xPos(); // ((GuiImgButton) c).x; + int y = tooltip.yPos(); // ((GuiImgButton) c).y; + + if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) { + if (y < mouseY && y + tooltip.getHeight() > mouseY) { + if (y < 15) { + y = 15; + } + + final String msg = tooltip.getMessage(); + if (msg != null) { + this.drawTooltip(x + 11, y + 4, msg); + } + } + } + } + + protected void drawTooltip(int x, int y, String message) { + String[] lines = message.split("\n"); + this.drawTooltip(x, y, Arrays.asList(lines)); + } + + protected void drawTooltip(int x, int y, List lines) { + if (lines.isEmpty()) { + return; + } + + // For an explanation of the formatting codes, see + // http://minecraft.gamepedia.com/Formatting_codes + lines = Lists.newArrayList(lines); // Make a copy + + // Make the first line white + lines.set(0, TextFormatting.WHITE + lines.get(0)); + + // All lines after the first are colored gray + for (int i = 1; i < lines.size(); i++) { + lines.set(i, TextFormatting.GRAY + lines.get(i)); + } + + this.renderTooltip(lines, x, y, this.font); + } + + @Override + protected final void drawGuiContainerForegroundLayer(final int x, final int y) { + final int ox = this.guiLeft; // (width - xSize) / 2; + final int oy = this.guiTop; // (height - ySize) / 2; + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + + if (this.getScrollBar() != null) { + this.getScrollBar().draw(this); + } + + this.drawFG(ox, oy, x, y); + } + + public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY); + + @Override + protected final void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) { + final int ox = this.guiLeft; // (width - xSize) / 2; + final int oy = this.guiTop; // (height - ySize) / 2; + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + this.drawBG(ox, oy, x, y, f); + + final List slots = this.getInventorySlots(); + for (final Slot slot : slots) { + if (slot instanceof IOptionalSlot) { + final IOptionalSlot optionalSlot = (IOptionalSlot) slot; + if (optionalSlot.isRenderDisabled()) { + final AppEngSlot aeSlot = (AppEngSlot) slot; + if (aeSlot.isSlotEnabled()) { + GuiUtils.drawTexturedModalRect(ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, + optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18, getBlitOffset()); + } else { + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F); + RenderSystem.enableBlend(); + GuiUtils.drawTexturedModalRect(ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, + optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18, 18, getBlitOffset()); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + } + + for (final GuiCustomSlot slot : this.guiSlots) { + slot.drawBackground(ox, oy, getBlitOffset()); + } + + } + + @Override + public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) { + this.drag_click.clear(); + + if (btn == 1) { + for (final Object o : this.buttons) { + final Widget widget = (Widget) o; + if (widget.isMouseOver(xCoord, yCoord)) { + return super.mouseClicked(xCoord, yCoord, 0); + } + } + } + + for (GuiCustomSlot slot : this.guiSlots) { + if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord) + && slot.canClick(getPlayer())) { + slot.slotClicked(getPlayer().inventory.getItemStack(), btn); + } + } + + if (this.getScrollBar() != null) { + this.getScrollBar().click(xCoord - this.guiLeft, yCoord - this.guiTop); + } + + return super.mouseClicked(xCoord, yCoord, btn); + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { + + final Slot slot = this.getSlot((int) mouseX, (int) mouseY); + final ItemStack itemstack = getPlayer().inventory.getItemStack(); + + if (this.getScrollBar() != null) { + // FIXME: Coordinate system of mouseX/mouseY is unclear + this.getScrollBar().click((int) mouseX - this.guiLeft, (int) mouseY - this.guiTop); + } + + if (slot instanceof SlotFake && !itemstack.isEmpty()) { + this.drag_click.add(slot); + if (this.drag_click.size() > 1) { + for (final Slot dr : this.drag_click) { + final PacketInventoryAction p = new PacketInventoryAction( + mouseButton == 0 ? InventoryAction.PICKUP_OR_SET_DOWN : InventoryAction.PLACE_SINGLE, + dr.slotNumber, 0); + NetworkHandler.instance().sendToServer(p); + } + } + + return true; + } else { + return super.mouseDragged(mouseX, mouseY, mouseButton, dragX, dragY); + } + } + + // TODO 1.9.4 aftermath - Whole ClickType thing, to be checked. + @Override + protected void handleMouseClick(final Slot slot, final int slotIdx, final int mouseButton, + final ClickType clickType) { + final PlayerEntity player = getPlayer(); + + if (slot instanceof SlotFake) { + final InventoryAction action = mouseButton == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE + : InventoryAction.PICKUP_OR_SET_DOWN; + + if (this.drag_click.size() > 1) { + return; + } + + final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0); + NetworkHandler.instance().sendToServer(p); + + return; + } + + if (slot instanceof SlotPatternTerm) { + if (mouseButton == 6) { + return; // prevent weird double clicks.. + } + + NetworkHandler.instance().sendToServer(((SlotPatternTerm) slot).getRequest(hasShiftDown())); + } else if (slot instanceof SlotCraftingTerm) { + if (mouseButton == 6) { + return; // prevent weird double clicks.. + } + + InventoryAction action; + if (hasShiftDown()) { + action = InventoryAction.CRAFT_SHIFT; + } else { + // Craft stack on right-click, craft single on left-click + action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM; + } + + final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0); + NetworkHandler.instance().sendToServer(p); + + return; + } + + if (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE)) { + if (this.enableSpaceClicking()) { + IAEItemStack stack = null; + if (slot instanceof SlotME) { + stack = ((SlotME) slot).getAEStack(); + } + + int slotNum = this.getInventorySlots().size(); + + if (!(slot instanceof SlotME) && slot != null) { + slotNum = slot.slotNumber; + } + + ((AEBaseContainer) this.container).setTargetStack(stack); + final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0); + NetworkHandler.instance().sendToServer(p); + return; + } + } + + if (slot instanceof SlotDisconnected) { + InventoryAction action = null; + + switch (clickType) { + case PICKUP: // pickup / set-down. + action = (mouseButton == 1) ? InventoryAction.SPLIT_OR_PLACE_SINGLE + : InventoryAction.PICKUP_OR_SET_DOWN; + break; + case QUICK_MOVE: + action = (mouseButton == 1) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; + break; + + case CLONE: // creative dupe: + + if (player.abilities.isCreativeMode) { + action = InventoryAction.CREATIVE_DUPLICATE; + } + + break; + + default: + case THROW: // drop item: + } + + if (action != null) { + final PacketInventoryAction p = new PacketInventoryAction(action, slot.getSlotIndex(), + ((SlotDisconnected) slot).getSlot().getId()); + NetworkHandler.instance().sendToServer(p); + } + + return; + } + + if (slot instanceof SlotME) { + InventoryAction action = null; + IAEItemStack stack = null; + + switch (clickType) { + case PICKUP: // pickup / set-down. + action = (mouseButton == 1) ? InventoryAction.SPLIT_OR_PLACE_SINGLE + : InventoryAction.PICKUP_OR_SET_DOWN; + stack = ((SlotME) slot).getAEStack(); + + if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 + && player.inventory.getItemStack().isEmpty()) { + action = InventoryAction.AUTO_CRAFT; + } + + break; + case QUICK_MOVE: + action = (mouseButton == 1) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; + stack = ((SlotME) slot).getAEStack(); + break; + + case CLONE: // creative dupe: + + stack = ((SlotME) slot).getAEStack(); + if (stack != null && stack.isCraftable()) { + action = InventoryAction.AUTO_CRAFT; + } else if (player.abilities.isCreativeMode) { + final IAEItemStack slotItem = ((SlotME) slot).getAEStack(); + if (slotItem != null) { + action = InventoryAction.CREATIVE_DUPLICATE; + } + } + break; + + default: + case THROW: // drop item: + } + + if (action != null) { + this.container.setTargetStack(stack); + final PacketInventoryAction p = new PacketInventoryAction(action, this.getInventorySlots().size(), 0); + NetworkHandler.instance().sendToServer(p); + } + + return; + } + + if (!this.disableShiftClick && hasShiftDown() && mouseButton == 0) { + this.disableShiftClick = true; + + if (this.dbl_whichItem.isEmpty() || this.bl_clicked != slot + || this.dbl_clickTimer.elapsed(TimeUnit.MILLISECONDS) > 250) { + // some simple double click logic. + this.bl_clicked = slot; + this.dbl_clickTimer = Stopwatch.createStarted(); + if (slot != null) { + this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY; + } else { + this.dbl_whichItem = ItemStack.EMPTY; + } + } else if (!this.dbl_whichItem.isEmpty()) { + // a replica of the weird broken vanilla feature. + + final List slots = this.getInventorySlots(); + for (final Slot inventorySlot : slots) { + if (inventorySlot != null && inventorySlot.canTakeStack(getPlayer()) && inventorySlot.getHasStack() + && inventorySlot.isSameInventory(slot) + && Container.canAddItemToSlot(inventorySlot, this.dbl_whichItem, true)) { + this.handleMouseClick(inventorySlot, inventorySlot.slotNumber, 0, ClickType.QUICK_MOVE); + } + } + this.dbl_whichItem = ItemStack.EMPTY; + } + + this.disableShiftClick = false; + } + + super.handleMouseClick(slot, slotIdx, mouseButton, clickType); + } + + protected boolean func_195363_d(int keyCode, int scanCode) { + return checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode)); + } + + protected ClientPlayerEntity getPlayer() { + // Our UIs are usually not opened when not in-game, so this should not be a + // problem + return Preconditions.checkNotNull(getMinecraft().player); + } + + protected boolean checkHotbarKeys(final InputMappings.Input input) { + final Slot theSlot = this.getSlotUnderMouse(); + + if (getPlayer().inventory.getItemStack().isEmpty() && theSlot != null) { + for (int j = 0; j < 9; ++j) { + if (getMinecraft().gameSettings.keyBindsHotbar[j].isActiveAndMatches(input)) { + final List slots = this.getInventorySlots(); + for (final Slot s : slots) { + if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) { + if (!s.canTakeStack(((AEBaseContainer) this.container).getPlayerInv().player)) { + return false; + } + } + } + + if (theSlot.getSlotStackLimit() == 64) { + this.handleMouseClick(theSlot, theSlot.slotNumber, j, ClickType.SWAP); + return true; + } else { + for (final Slot s : slots) { + if (s.getSlotIndex() == j + && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) { + NetworkHandler.instance() + .sendToServer(new PacketSwapSlots(s.slotNumber, theSlot.slotNumber)); + return true; + } + } + } + } + } + } + + return false; + } + + @Override + public void removed() { + super.removed(); + } + + protected Slot getSlot(final int mouseX, final int mouseY) { + final List slots = this.getInventorySlots(); + for (final Slot slot : slots) { + // isPointInRegion + if (this.isPointInRegion(slot.xPos, slot.yPos, 16, 16, mouseX, mouseY)) { + return slot; + } + } + + return null; + } + + public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks); + + @Override + public boolean mouseScrolled(double x, double y, double wheelDelta) { + if (wheelDelta != 0 && hasShiftDown()) { + this.mouseWheelEvent(x, y, wheelDelta / Math.abs(wheelDelta)); + return true; + } else if (wheelDelta != 0 && this.getScrollBar() != null) { + this.getScrollBar().wheel(wheelDelta); + return true; + } + return false; + } + + private void mouseWheelEvent(final double x, final double y, final double wheel) { + final Slot slot = this.getSlot((int) x, (int) y); + if (slot instanceof SlotME) { + final IAEItemStack item = ((SlotME) slot).getAEStack(); + if (item != null) { + ((AEBaseContainer) this.container).setTargetStack(item); + final InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP; + final int times = (int) Math.abs(wheel); + final int inventorySize = this.getInventorySlots().size(); + for (int h = 0; h < times; h++) { + final PacketInventoryAction p = new PacketInventoryAction(direction, inventorySize, 0); + NetworkHandler.instance().sendToServer(p); + } + } + } + } + + protected boolean enableSpaceClicking() { + return true; + } + + public void bindTexture(final String base, final String file) { + final ResourceLocation loc = new ResourceLocation(base, "textures/" + file); + getMinecraft().getTextureManager().bindTexture(loc); + } + + protected void drawItem(final int x, final int y, final ItemStack is) { + this.itemRenderer.zLevel = 100.0F; + + // FIXME I dont think this is needed anymore... + RenderHelper.enableStandardItemLighting(); + this.itemRenderer.renderItemAndEffectIntoGUI(is, x, y); + RenderHelper.disableStandardItemLighting(); + + this.itemRenderer.zLevel = 0.0F; + } + + protected String getGuiDisplayName(final String in) { + return this.hasCustomInventoryName() ? this.getInventoryName() : in; + } + + private boolean hasCustomInventoryName() { + return this.container.getCustomName() != null; + } + + private String getInventoryName() { + return this.container.getCustomName(); + } + + /** + * This overrides the base-class method through some access transformer + * hackery... + */ + @Override + public void drawSlot(Slot s) { + if (s instanceof SlotME) { + + try { + if (!this.isPowered()) { + fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111); + } + + // Annoying but easier than trying to splice into render item + super.drawSlot(new Size1Slot((SlotME) s)); + + this.stackSizeRenderer.renderStackSize(this.font, ((SlotME) s).getAEStack(), s.xPos, s.yPos); + + } catch (final Exception err) { + AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err.toString()); + } + + return; + } else if (s instanceof IMEFluidSlot && ((IMEFluidSlot) s).shouldRenderAsFluid()) { + final IMEFluidSlot slot = (IMEFluidSlot) s; + final IAEFluidStack fs = slot.getAEFluidStack(); + + if (fs != null && this.isPowered()) { + RenderSystem.disableBlend(); + final Fluid fluid = fs.getFluid(); + FluidAttributes fluidAttributes = fluid.getAttributes(); + bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + ResourceLocation fluidStillTexture = fluidAttributes.getStillTexture(fs.getFluidStack()); + final TextureAtlasSprite sprite = getMinecraft() + .getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStillTexture); + + // Set color for dynamic fluids + // Convert int color to RGB + float red = (fluidAttributes.getColor() >> 16 & 255) / 255.0F; + float green = (fluidAttributes.getColor() >> 8 & 255) / 255.0F; + float blue = (fluidAttributes.getColor() & 255) / 255.0F; + RenderSystem.color3f(red, green, blue); + + blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite); + RenderSystem.enableBlend(); + + this.fluidStackSizeRenderer.renderStackSize(this.font, fs, s.xPos, s.yPos); + } else if (!this.isPowered()) { + fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111); + } + + return; + } else { + try { + final ItemStack is = s.getStack(); + if (s instanceof AppEngSlot && (((AppEngSlot) s).renderIconWithItem() || is.isEmpty()) + && (((AppEngSlot) s).shouldDisplay())) { + final AppEngSlot aes = (AppEngSlot) s; + if (aes.getIcon() >= 0) { + this.bindTexture("guis/states.png"); + + try { + final int uv_y = aes.getIcon() / 16; + final int uv_x = aes.getIcon() - uv_y * 16; + + RenderSystem.enableBlend(); + RenderSystem.enableTexture(); + RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + final float par1 = aes.xPos; + final float par2 = aes.yPos; + final float par3 = uv_x * 16; + final float par4 = uv_y * 16; + + final Tessellator tessellator = Tessellator.getInstance(); + final BufferBuilder vb = tessellator.getBuffer(); + + vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); + + final float f1 = 0.00390625F; + final float f = 0.00390625F; + final float par6 = 16; + vb.pos(par1 + 0, par2 + par6, getBlitOffset()).tex((par3 + 0) * f, (par4 + par6) * f1) + .color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex(); + final float par5 = 16; + vb.pos(par1 + par5, par2 + par6, getBlitOffset()).tex((par3 + par5) * f, (par4 + par6) * f1) + .color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex(); + vb.pos(par1 + par5, par2 + 0, getBlitOffset()).tex((par3 + par5) * f, (par4 + 0) * f1) + .color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex(); + vb.pos(par1 + 0, par2 + 0, getBlitOffset()).tex((par3 + 0) * f, (par4 + 0) * f1) + .color(1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon()).endVertex(); + tessellator.draw(); + + } catch (final Exception err) { + err.printStackTrace(); + } + } + } + + if (!is.isEmpty() && s instanceof AppEngSlot) { + if (((AppEngSlot) s).getIsValid() == hasCalculatedValidness.NotAvailable) { + boolean isValid = s.isItemValid(is) || s instanceof SlotOutput + || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled + || s instanceof SlotInaccessible || s instanceof SlotFake + || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected; + if (isValid && s instanceof SlotRestrictedInput) { + try { + isValid = ((SlotRestrictedInput) s).isValid(is, getMinecraft().world); + } catch (final Exception err) { + AELog.debug(err); + } + } + ((AppEngSlot) s) + .setIsValid(isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid); + } + + if (((AppEngSlot) s).getIsValid() == hasCalculatedValidness.Invalid) { + setBlitOffset(100); + this.itemRenderer.zLevel = 100.0F; + + fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666); + + setBlitOffset(0); + this.itemRenderer.zLevel = 0.0F; + } + } + + if (s instanceof AppEngSlot) { + ((AppEngSlot) s).setDisplay(true); + super.drawSlot(s); + } else { + super.drawSlot(s); + } + + return; + } catch (final Exception err) { + AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err.toString()); + } + } + // do the usual for non-ME Slots. + super.drawSlot(s); + } + + protected boolean isPowered() { + return true; + } + + public void bindTexture(final String file) { + final ResourceLocation loc = new ResourceLocation(AppEng.MOD_ID, "textures/" + file); + getMinecraft().getTextureManager().bindTexture(loc); + } + + public void bindTexture(final ResourceLocation loc) { + getMinecraft().getTextureManager().bindTexture(loc); + } + + protected GuiScrollbar getScrollBar() { + return this.myScrollBar; + } + + protected void setScrollBar(final GuiScrollbar myScrollBar) { + this.myScrollBar = myScrollBar; + } + + protected List getMeSlots() { + return this.meSlots; + } } diff --git a/src/main/java/appeng/client/gui/AEBaseMEGui.java b/src/main/java/appeng/client/gui/AEBaseMEGui.java index 59a25a776..f50a24c71 100644 --- a/src/main/java/appeng/client/gui/AEBaseMEGui.java +++ b/src/main/java/appeng/client/gui/AEBaseMEGui.java @@ -18,12 +18,10 @@ package appeng.client.gui; - import java.text.NumberFormat; import java.util.List; import java.util.Locale; -import appeng.container.AEBaseContainer; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; @@ -33,75 +31,66 @@ import net.minecraft.util.text.TextFormatting; import appeng.api.storage.data.IAEItemStack; import appeng.client.me.SlotME; +import appeng.container.AEBaseContainer; import appeng.core.AEConfig; import appeng.core.localization.ButtonToolTips; +public abstract class AEBaseMEGui extends AEBaseGui { -public abstract class AEBaseMEGui extends AEBaseGui -{ + public AEBaseMEGui(T container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } - public AEBaseMEGui(T container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } + @Override + protected void renderTooltip(final ItemStack stack, final int x, final int y) { + final Slot s = this.getSlot(x, y); - @Override - protected void renderTooltip( final ItemStack stack, final int x, final int y ) - { - final Slot s = this.getSlot( x, y ); + if (s instanceof SlotME && !stack.isEmpty()) { + final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999; - if( s instanceof SlotME && !stack.isEmpty() ) - { - final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999; + IAEItemStack myStack = null; + final List currentToolTip = this.getTooltipFromItem(stack); - IAEItemStack myStack = null; - final List currentToolTip = this.getTooltipFromItem( stack ); + try { + final SlotME theSlotField = (SlotME) s; + myStack = theSlotField.getAEStack(); + } catch (final Throwable ignore) { + } - try - { - final SlotME theSlotField = (SlotME) s; - myStack = theSlotField.getAEStack(); - } - catch( final Throwable ignore ) - { - } + if (myStack != null) { + if (myStack.getStackSize() > bigNumber || (myStack.getStackSize() > 1 && stack.isDamaged())) { + final String local = ButtonToolTips.ItemsStored.getLocal(); + final String formattedAmount = NumberFormat.getNumberInstance(Locale.US) + .format(myStack.getStackSize()); + final String format = String.format(local, formattedAmount); - if( myStack != null ) - { - if( myStack.getStackSize() > bigNumber || ( myStack.getStackSize() > 1 && stack.isDamaged() ) ) - { - final String local = ButtonToolTips.ItemsStored.getLocal(); - final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ); - final String format = String.format( local, formattedAmount ); + currentToolTip.add(TextFormatting.GRAY + format); + } - currentToolTip.add( TextFormatting.GRAY + format ); - } + if (myStack.getCountRequestable() > 0) { + final String local = ButtonToolTips.ItemsRequestable.getLocal(); + final String formattedAmount = NumberFormat.getNumberInstance(Locale.US) + .format(myStack.getCountRequestable()); + final String format = String.format(local, formattedAmount); - if( myStack.getCountRequestable() > 0 ) - { - final String local = ButtonToolTips.ItemsRequestable.getLocal(); - final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ); - final String format = String.format( local, formattedAmount ); + currentToolTip.add(format); + } + this.renderTooltip(currentToolTip, x, y, this.font); - currentToolTip.add( format ); - } - this.renderTooltip( currentToolTip, x, y, this.font ); + return; + } else if (stack.getCount() > bigNumber) { + final String local = ButtonToolTips.ItemsStored.getLocal(); + final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount()); + final String format = String.format(local, formattedAmount); - return; - } - else if( stack.getCount() > bigNumber ) - { - final String local = ButtonToolTips.ItemsStored.getLocal(); - final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.getCount() ); - final String format = String.format( local, formattedAmount ); + currentToolTip.add(TextFormatting.GRAY + format); - currentToolTip.add( TextFormatting.GRAY + format ); + this.renderTooltip(currentToolTip, x, y, this.font); - this.renderTooltip( currentToolTip, x, y, this.font ); + return; + } + } - return; - } - } - - super.renderTooltip( stack, x, y ); - } + super.renderTooltip(stack, x, y); + } } \ No newline at end of file diff --git a/src/main/java/appeng/client/gui/Size1Slot.java b/src/main/java/appeng/client/gui/Size1Slot.java index 320e6c896..47934052d 100644 --- a/src/main/java/appeng/client/gui/Size1Slot.java +++ b/src/main/java/appeng/client/gui/Size1Slot.java @@ -1,7 +1,6 @@ package appeng.client.gui; - import javax.annotation.Nonnull; import net.minecraft.entity.player.PlayerEntity; @@ -11,77 +10,66 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.SlotItemHandler; - /** - * A proxy for a slot that will always return an itemstack with size 1, if there is an item in the slot. - * Used to prevent the default item count from rendering. + * A proxy for a slot that will always return an itemstack with size 1, if there + * is an item in the slot. Used to prevent the default item count from + * rendering. */ -class Size1Slot extends SlotItemHandler -{ +class Size1Slot extends SlotItemHandler { - private final SlotItemHandler delegate; + private final SlotItemHandler delegate; - public Size1Slot( SlotItemHandler delegate ) - { - super( delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos ); - this.delegate = delegate; - } + public Size1Slot(SlotItemHandler delegate) { + super(delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos); + this.delegate = delegate; + } - @Override - @Nonnull - public ItemStack getStack() - { - ItemStack orgStack = this.delegate.getStack(); - if( !orgStack.isEmpty() ) - { - ItemStack modifiedStack = orgStack.copy(); - modifiedStack.setCount( 1 ); - return modifiedStack; - } + @Override + @Nonnull + public ItemStack getStack() { + ItemStack orgStack = this.delegate.getStack(); + if (!orgStack.isEmpty()) { + ItemStack modifiedStack = orgStack.copy(); + modifiedStack.setCount(1); + return modifiedStack; + } - return ItemStack.EMPTY; - } + return ItemStack.EMPTY; + } - @Override - public boolean getHasStack() - { - return this.delegate.getHasStack(); - } + @Override + public boolean getHasStack() { + return this.delegate.getHasStack(); + } - @Override - public int getSlotStackLimit() - { - return this.delegate.getSlotStackLimit(); - } + @Override + public int getSlotStackLimit() { + return this.delegate.getSlotStackLimit(); + } - @Override - public int getItemStackLimit( ItemStack stack ) - { - return this.delegate.getItemStackLimit( stack ); - } + @Override + public int getItemStackLimit(ItemStack stack) { + return this.delegate.getItemStackLimit(stack); + } - @Override - public boolean canTakeStack( PlayerEntity playerIn ) - { - return this.delegate.canTakeStack( playerIn ); - } + @Override + public boolean canTakeStack(PlayerEntity playerIn) { + return this.delegate.canTakeStack(playerIn); + } - @Override - @OnlyIn( Dist.CLIENT ) - public boolean isEnabled() - { - return this.delegate.isEnabled(); - } + @Override + @OnlyIn(Dist.CLIENT) + public boolean isEnabled() { + return this.delegate.isEnabled(); + } - @Override - public int getSlotIndex() - { - return this.delegate.getSlotIndex(); - } + @Override + public int getSlotIndex() { + return this.delegate.getSlotIndex(); + } - @Override - public boolean isSameInventory( Slot other ) - { - return this.delegate.isSameInventory( other ); - } + @Override + public boolean isSameInventory(Slot other) { + return this.delegate.isSameInventory(other); + } } diff --git a/src/main/java/appeng/client/gui/implementations/AESubGui.java b/src/main/java/appeng/client/gui/implementations/AESubGui.java index 4da7a1c5a..e1809f9d8 100644 --- a/src/main/java/appeng/client/gui/implementations/AESubGui.java +++ b/src/main/java/appeng/client/gui/implementations/AESubGui.java @@ -1,5 +1,13 @@ package appeng.client.gui.implementations; +import java.util.function.Consumer; + +import javax.annotation.Nullable; + +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.item.ItemStack; + import appeng.api.AEApi; import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IParts; @@ -14,15 +22,10 @@ import appeng.parts.reporting.PartCraftingTerminal; import appeng.parts.reporting.PartPatternTerminal; import appeng.parts.reporting.PartTerminal; import appeng.tile.storage.TileChest; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.ItemStack; - -import javax.annotation.Nullable; -import java.util.function.Consumer; /** - * Utility class for sub-screens of other containers that allow returning to the primary container UI. + * Utility class for sub-screens of other containers that allow returning to the + * primary container UI. */ final class AESubGui { @@ -31,8 +34,8 @@ final class AESubGui { private final ItemStack previousContainerIcon; /** - * Based on the container we're opening for, try to determine what it's "primary" GUI would be - * so that we can go back to it. + * Based on the container we're opening for, try to determine what it's + * "primary" GUI would be so that we can go back to it. */ public AESubGui(AEBaseGui gui, Object containerTarget) { this.gui = gui; @@ -41,7 +44,8 @@ final class AESubGui { final IParts parts = definitions.parts(); if (containerTarget instanceof TileChest) { - // A chest is also a priority host, but the priority _interface_ can only be opened from the + // A chest is also a priority host, but the priority _interface_ can only be + // opened from the // chest ui that doesn't actually show the contents of the inserted cell. IPriorityHost priorityHost = (IPriorityHost) containerTarget; this.previousContainerIcon = priorityHost.getItemStackRepresentation(); @@ -54,31 +58,27 @@ final class AESubGui { this.previousContainerType = priorityHost.getContainerType(); } - else if( containerTarget instanceof WirelessTerminalGuiObject) - { - this.previousContainerIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + else if (containerTarget instanceof WirelessTerminalGuiObject) { + this.previousContainerIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY); this.previousContainerType = ContainerWirelessTerm.TYPE; } - else if( containerTarget instanceof PartTerminal) - { - this.previousContainerIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + else if (containerTarget instanceof PartTerminal) { + this.previousContainerIcon = parts.terminal().maybeStack(1).orElse(ItemStack.EMPTY); this.previousContainerType = ContainerMEMonitorable.TYPE; } - else if( containerTarget instanceof PartCraftingTerminal) - { - this.previousContainerIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + else if (containerTarget instanceof PartCraftingTerminal) { + this.previousContainerIcon = parts.craftingTerminal().maybeStack(1).orElse(ItemStack.EMPTY); this.previousContainerType = ContainerCraftingTerm.TYPE; } - else if( containerTarget instanceof PartPatternTerminal) - { - this.previousContainerIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + else if (containerTarget instanceof PartPatternTerminal) { + this.previousContainerIcon = parts.patternTerminal().maybeStack(1).orElse(ItemStack.EMPTY); this.previousContainerType = ContainerPatternTerm.TYPE; } - else { + else { this.previousContainerIcon = null; this.previousContainerType = null; } @@ -89,13 +89,13 @@ final class AESubGui { } public final GuiTabButton addBackButton(Consumer buttonAdder, int x, int y, @Nullable String label) { - if( this.previousContainerType != null && !previousContainerIcon.isEmpty() ) - { + if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) { if (label == null) { label = previousContainerIcon.getDisplayName().getString(); } ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer(); - GuiTabButton button = new GuiTabButton( gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label, itemRenderer, btn -> goBack() ); + GuiTabButton button = new GuiTabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, + label, itemRenderer, btn -> goBack()); buttonAdder.accept(button); return button; } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java index ab857db6b..943e7ac88 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java @@ -18,13 +18,10 @@ package appeng.client.gui.implementations; - -import appeng.client.gui.widgets.GuiActionButton; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; - import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.items.IItemHandler; import appeng.api.config.ActionItems; @@ -33,6 +30,7 @@ import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.implementations.items.IUpgradeModule; +import appeng.client.gui.widgets.GuiActionButton; import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.client.gui.widgets.GuiToggleButton; import appeng.container.implementations.ContainerCellWorkbench; @@ -40,129 +38,120 @@ import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; +public class GuiCellWorkbench extends GuiUpgradeable { -public class GuiCellWorkbench extends GuiUpgradeable -{ + private GuiToggleButton copyMode; - private GuiToggleButton copyMode; + public GuiCellWorkbench(ContainerCellWorkbench container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 251; + } - public GuiCellWorkbench(ContainerCellWorkbench container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 251; - } + @Override + protected void addButtons() { + this.fuzzyMode = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, + Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode)); + this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, + act1 -> action("Partition"))); + this.addButton( + new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, act -> action("Clear"))); + this.copyMode = this.addButton(new GuiToggleButton(this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, + 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal(), act -> action("CopyMode"))); + } - @Override - protected void addButtons() - { - this.fuzzyMode = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode ) ); - this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, act1 -> action("Partition"))); - this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, act -> action("Clear"))); - this.copyMode = this.addButton( new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc - .getLocal(), act -> action("CopyMode") ) ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.handleButtonVisibility(); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.handleButtonVisibility(); + this.bindTexture(this.getBackground()); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset()); + if (this.drawUpgrades()) { + if (this.container.availableUpgrades() <= 8) { + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, + 7 + this.container.availableUpgrades() * 18, getBlitOffset()); + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (this.container.availableUpgrades()) * 18), + 177, 151, 35, 7, getBlitOffset()); + } else if (this.container.availableUpgrades() <= 16) { + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset()); + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7, + getBlitOffset()); - this.bindTexture( this.getBackground() ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() ); - if( this.drawUpgrades() ) - { - if( this.container.availableUpgrades() <= 8 ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.container.availableUpgrades() * 18, getBlitOffset() ); - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.container.availableUpgrades() ) * 18 ), 177, 151, 35, 7, getBlitOffset() ); - } - else if( this.container.availableUpgrades() <= 16 ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset() ); - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7, getBlitOffset() ); + final int dx = this.container.availableUpgrades() - 8; + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18, + getBlitOffset()); + if (dx == 8) { + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7, + getBlitOffset()); + } else { + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, + 35 - 8, 7, getBlitOffset()); + } + } else { + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset()); + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7, + getBlitOffset()); - final int dx = this.container.availableUpgrades() - 8; - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18, getBlitOffset() ); - if( dx == 8 ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() ); - } - else - { - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7, getBlitOffset() ); - } - } - else - { - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset() ); - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7, getBlitOffset() ); + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18, + getBlitOffset()); + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7, + getBlitOffset()); - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18, getBlitOffset() ); - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( 8 ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() ); + final int dx = this.container.availableUpgrades() - 16; + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18, + getBlitOffset()); + if (dx == 8) { + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, + 7, getBlitOffset()); + } else { + GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, + 35 - 8, 7, getBlitOffset()); + } + } + } + if (this.hasToolbox()) { + GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68, getBlitOffset()); + } + } - final int dx = this.container.availableUpgrades() - 16; - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18, getBlitOffset() ); - if( dx == 8 ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() ); - } - else - { - GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7, getBlitOffset() ); - } - } - } - if( this.hasToolbox() ) - { - GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68, getBlitOffset() ); - } - } + @Override + protected void handleButtonVisibility() { + this.copyMode.setState(this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE); - @Override - protected void handleButtonVisibility() - { - this.copyMode.setState( this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE ); + boolean hasFuzzy = false; + final IItemHandler inv = this.container.getCellUpgradeInventory(); + for (int x = 0; x < inv.getSlots(); x++) { + final ItemStack is = inv.getStackInSlot(x); + if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) { + if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) { + hasFuzzy = true; + } + } + } + this.fuzzyMode.setVisibility(hasFuzzy); + } - boolean hasFuzzy = false; - final IItemHandler inv = this.container.getCellUpgradeInventory(); - for( int x = 0; x < inv.getSlots(); x++ ) - { - final ItemStack is = inv.getStackInSlot( x ); - if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) - { - if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY ) - { - hasFuzzy = true; - } - } - } - this.fuzzyMode.setVisibility( hasFuzzy ); - } + @Override + protected String getBackground() { + return "guis/cellworkbench.png"; + } - @Override - protected String getBackground() - { - return "guis/cellworkbench.png"; - } + @Override + protected boolean drawUpgrades() { + return this.container.availableUpgrades() > 0; + } - @Override - protected boolean drawUpgrades() - { - return this.container.availableUpgrades() > 0; - } + @Override + protected GuiText getName() { + return GuiText.CellWorkbench; + } - @Override - protected GuiText getName() - { - return GuiText.CellWorkbench; - } + private void action(String type) { + NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Action", type)); + } - private void action(String type) { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", type ) ); - } - - private void toggleFuzzyMode(GuiSettingToggleButton button, boolean backwards) { - FuzzyMode fz = button.getNextValue(backwards); - NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) ); - } + private void toggleFuzzyMode(GuiSettingToggleButton button, boolean backwards) { + FuzzyMode fz = button.getNextValue(backwards); + NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Fuzzy", fz.name())); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiChest.java b/src/main/java/appeng/client/gui/implementations/GuiChest.java index 0574829ae..6285a34a1 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiChest.java +++ b/src/main/java/appeng/client/gui/implementations/GuiChest.java @@ -18,53 +18,47 @@ package appeng.client.gui.implementations; - -import appeng.container.implementations.ContainerPriority; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiTabButton; import appeng.container.implementations.ContainerChest; +import appeng.container.implementations.ContainerPriority; import appeng.core.localization.GuiText; - import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketSwitchGuis; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiChest extends AEBaseGui { -public class GuiChest extends AEBaseGui -{ + public GuiChest(ContainerChest container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiChest(ContainerChest container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriority())); + } - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriority() ) ); - } + private void openPriority() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } - private void openPriority() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/chest.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/chest.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCondenser.java b/src/main/java/appeng/client/gui/implementations/GuiCondenser.java index 2ce82006c..309736d1c 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCondenser.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCondenser.java @@ -18,60 +18,54 @@ package appeng.client.gui.implementations; - -import appeng.api.config.CondenserOutput; -import appeng.client.gui.widgets.GuiServerSettingToggleButton; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; -import net.minecraft.entity.player.PlayerInventory; - +import appeng.api.config.CondenserOutput; import appeng.api.config.Settings; import appeng.client.gui.AEBaseGui; -import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.client.gui.widgets.GuiProgressBar; import appeng.client.gui.widgets.GuiProgressBar.Direction; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; +import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.container.implementations.ContainerCondenser; import appeng.core.localization.GuiText; +public class GuiCondenser extends AEBaseGui { -public class GuiCondenser extends AEBaseGui -{ + private GuiSettingToggleButton mode; - private GuiSettingToggleButton mode; + public GuiCondenser(ContainerCondenser container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 197; + } - public GuiCondenser(ContainerCondenser container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 197; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.mode = new GuiServerSettingToggleButton<>(128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, + this.container.getOutput()); - this.mode = new GuiServerSettingToggleButton<>( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput()); + this.addButton(new GuiProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, + 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.getLocal())); + this.addButton(this.mode); + } - this.addButton(new GuiProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy - .getLocal())); - this.addButton( this.mode ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.Condenser.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + this.mode.set(this.container.getOutput()); + this.mode.setFillVar(String.valueOf(this.container.getOutput().requiredPower)); + } - this.mode.set( this.container.getOutput() ); - this.mode.setFillVar( String.valueOf( this.container.getOutput().requiredPower ) ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/condenser.png"); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/condenser.png" ); - - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java index 8e76df3e5..a58be6b00 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java @@ -18,6 +18,11 @@ package appeng.client.gui.implementations; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiNumberBox; @@ -26,193 +31,163 @@ import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketCraftRequest; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.util.InputMappings; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiCraftAmount extends AEBaseGui { + private final AESubGui subGui; -public class GuiCraftAmount extends AEBaseGui -{ - private final AESubGui subGui; + private GuiNumberBox amountToCraft; - private GuiNumberBox amountToCraft; + private Button next; - private Button next; + public GuiCraftAmount(ContainerCraftAmount container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.subGui = new AESubGui(this, container.getTarget()); + } - public GuiCraftAmount(ContainerCraftAmount container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.subGui = new AESubGui(this, container.getTarget()); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + final int a = AEConfig.instance().craftItemsByStackAmounts(0); + final int b = AEConfig.instance().craftItemsByStackAmounts(1); + final int c = AEConfig.instance().craftItemsByStackAmounts(2); + final int d = AEConfig.instance().craftItemsByStackAmounts(3); - final int a = AEConfig.instance().craftItemsByStackAmounts( 0 ); - final int b = AEConfig.instance().craftItemsByStackAmounts( 1 ); - final int c = AEConfig.instance().craftItemsByStackAmounts( 2 ); - final int d = AEConfig.instance().craftItemsByStackAmounts( 3 ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d) ) ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d) ) ); + this.next = this.addButton( + new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm)); - this.next = this.addButton(new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm )); + subGui.addBackButton(this::addButton, 154, 0); - subGui.addBackButton(this::addButton, 154, 0); + this.amountToCraft = new GuiNumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, + Integer.class); + this.amountToCraft.setEnableBackgroundDrawing(false); + this.amountToCraft.setMaxStringLength(16); + this.amountToCraft.setTextColor(0xFFFFFF); + this.amountToCraft.setVisible(true); + this.amountToCraft.setFocused2(true); + this.amountToCraft.setText("1"); + } - this.amountToCraft = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Integer.class ); - this.amountToCraft.setEnableBackgroundDrawing( false ); - this.amountToCraft.setMaxStringLength( 16 ); - this.amountToCraft.setTextColor( 0xFFFFFF ); - this.amountToCraft.setVisible( true ); - this.amountToCraft.setFocused2( true ); - this.amountToCraft.setText( "1" ); - } + private void confirm(Button button) { + NetworkHandler.instance() + .sendToServer(new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), hasShiftDown())); + } - private void confirm(Button button) { - NetworkHandler.instance().sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), hasShiftDown() ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal()); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal()); + this.bindTexture("guis/craft_amt.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); - this.bindTexture( "guis/craft_amt.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); + try { + Long.parseLong(this.amountToCraft.getText()); + this.next.active = !this.amountToCraft.getText().isEmpty(); + } catch (final NumberFormatException e) { + this.next.active = false; + } - try - { - Long.parseLong( this.amountToCraft.getText() ); - this.next.active = !this.amountToCraft.getText().isEmpty(); - } - catch( final NumberFormatException e ) - { - this.next.active = false; - } + this.amountToCraft.render(offsetX, offsetY, partialTicks); + } - this.amountToCraft.render(offsetX, offsetY, partialTicks); - } + @Override + public boolean charTyped(char ch, int p_charTyped_2_) { + // Forward entered text to the craft amount text-field + return this.amountToCraft.charTyped(ch, p_charTyped_2_); + } - @Override - public boolean charTyped(char ch, int p_charTyped_2_) { - // Forward entered text to the craft amount text-field - return this.amountToCraft.charTyped(ch, p_charTyped_2_); - } + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) { + if (keyCode == 28) { + this.next.onPress(); + } + if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) + && this.amountToCraft.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + try { + String out = this.amountToCraft.getText(); - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { - if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) ) - { - if( keyCode == 28 ) - { - this.next.onPress(); - } - if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) - && this.amountToCraft.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) ) - { - try - { - String out = this.amountToCraft.getText(); + boolean fixed = false; + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); + fixed = true; + } - boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); - fixed = true; - } + if (fixed) { + this.amountToCraft.setText(out); + } - if( fixed ) - { - this.amountToCraft.setText( out ); - } + if (out.isEmpty()) { + out = "0"; + } - if( out.isEmpty() ) - { - out = "0"; - } + final long result = Long.parseLong(out); + if (result < 0) { + this.amountToCraft.setText("1"); + } + } catch (final NumberFormatException e) { + // :P + } + return true; + } + } - final long result = Long.parseLong( out ); - if( result < 0 ) - { - this.amountToCraft.setText( "1" ); - } - } - catch( final NumberFormatException e ) - { - // :P - } - return true; - } - } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } - return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ ); - } + private void addQty(final int i) { + try { + String out = this.amountToCraft.getText(); - private void addQty( final int i ) - { - try - { - String out = this.amountToCraft.getText(); + boolean fixed = false; + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); + fixed = true; + } - boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); - fixed = true; - } + if (fixed) { + this.amountToCraft.setText(out); + } - if( fixed ) - { - this.amountToCraft.setText( out ); - } + if (out.isEmpty()) { + out = "0"; + } - if( out.isEmpty() ) - { - out = "0"; - } + long result = Integer.parseInt(out); - long result = Integer.parseInt( out ); + if (result == 1 && i > 1) { + result = 0; + } - if( result == 1 && i > 1 ) - { - result = 0; - } + result += i; + if (result < 1) { + result = 1; + } - result += i; - if( result < 1 ) - { - result = 1; - } + out = Long.toString(result); + Integer.parseInt(out); + this.amountToCraft.setText(out); + } catch (final NumberFormatException e) { + // :P + } + } - out = Long.toString( result ); - Integer.parseInt( out ); - this.amountToCraft.setText( out ); - } - catch( final NumberFormatException e ) - { - // :P - } - } - - protected String getBackground() - { - return "guis/craftAmt.png"; - } + protected String getBackground() { + return "guis/craftAmt.png"; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java index 77e994b20..d37652048 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java @@ -18,6 +18,21 @@ package appeng.client.gui.implementations; +import java.io.IOException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.google.common.base.Joiner; +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.AEApi; import appeng.api.storage.channels.IItemStorageChannel; @@ -31,493 +46,420 @@ import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; import appeng.util.Platform; -import com.google.common.base.Joiner; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.util.InputMappings; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; - -import java.io.IOException; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - - -public class GuiCraftConfirm extends AEBaseGui -{ - - private final AESubGui subGui; - - private final int rows = 5; - - private final IItemList storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final IItemList pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final IItemList missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - - private final List visual = new ArrayList<>(); - - private Button cancel; - private Button start; - private Button selectCPU; - private int tooltip = -1; - - public GuiCraftConfirm(ContainerCraftConfirm container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.subGui = new AESubGui(this, container.getTarget()); - this.xSize = 238; - this.ySize = 206; - - final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - } - - boolean isAutoStart() - { - return this.container.isAutoStart(); - } - - @Override - public void init() - { - super.init(); - - this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(), btn -> start() ); - this.start.active = false; - this.addButton( this.start ); - - this.selectCPU = new Button(this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU - .getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu() ); - this.selectCPU.active = false; - this.addButton( this.selectCPU ); - - subGui.addBackButton(this::addButton, 6, this.ySize - 25, GuiText.Cancel.getLocal()); - - this.addButton( this.cancel ); - } - @Override - public void render(final int mouseX, final int mouseY, final float btn ) - { - this.updateCPUButtonText(); - - this.start.active = !( this.container.hasNoCPU() || this.isSimulation() ); - this.selectCPU.active = !this.isSimulation(); - - final int gx = ( this.width - this.xSize ) / 2; - final int gy = ( this.height - this.ySize ) / 2; - - this.tooltip = -1; - - final int offY = 23; - int y = 0; - int x = 0; - for( int z = 0; z <= 4 * 5; z++ ) - { - final int minX = gx + 9 + x * 67; - final int minY = gy + 22 + y * offY; - - if( minX < mouseX && minX + 67 > mouseX ) - { - if( minY < mouseY && minY + offY - 2 > mouseY ) - { - this.tooltip = z; - break; - } - } - - x++; - - if( x > 2 ) - { - y++; - x = 0; - } - } - - super.render( mouseX, mouseY, btn ); - } - - private void updateCPUButtonText() - { - String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal(); - if( this.container.getSelectedCpu() >= 0 )// && status.selectedCpu < status.cpus.size() ) - { - if( this.container.getName().length() > 0 ) - { - final String name = this.container.getName().substring( 0, Math.min( 20, this.container.getName().length() ) ); - btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; - } - else - { - btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.container.getSelectedCpu(); - } - } - - if( this.container.hasNoCPU() ) - { - btnTextText = GuiText.NoCraftingCPUs.getLocal(); - } - - this.selectCPU.setMessage(btnTextText); - } - - private boolean isSimulation() - { - return this.container.isSimulation(); - } - - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - final long BytesUsed = this.container.getUsedBytes(); - final String byteUsed = NumberFormat.getInstance().format( BytesUsed ); - final String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal(); - this.font.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 ); - - String dsp = null; - - if( this.isSimulation() ) - { - dsp = GuiText.Simulation.getLocal(); - } - else - { - dsp = this.container.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.container.getCpuAvailableBytes() + " : " + GuiText.CoProcessors - .getLocal() + ": " + this.container.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; - } - - final int offset = ( 219 - this.font.getStringWidth( dsp ) ) / 2; - this.font.drawString( dsp, offset, 165, 4210752 ); - - final int sectionLength = 67; - - int x = 0; - int y = 0; - final int xo = 9; - final int yo = 22; - final int viewStart = this.getScrollBar().getCurrentScroll() * 3; - final int viewEnd = viewStart + 3 * this.rows; - - String dspToolTip = ""; - final List lineList = new ArrayList<>(); - int toolPosX = 0; - int toolPosY = 0; - - final int offY = 23; - - for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ ) - { - final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z ); - if( refStack != null ) - { - RenderSystem.pushMatrix(); - RenderSystem.scalef( 0.5f, 0.5f, 0.5f ); - - final IAEItemStack stored = this.storage.findPrecise( refStack ); - final IAEItemStack pendingStack = this.pending.findPrecise( refStack ); - final IAEItemStack missingStack = this.missing.findPrecise( refStack ); - - int lines = 0; - - if( stored != null && stored.getStackSize() > 0 ) - { - lines++; - } - if( missingStack != null && missingStack.getStackSize() > 0 ) - { - lines++; - } - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { - lines++; - } - - final int negY = ( ( lines - 1 ) * 5 ) / 2; - int downY = 0; - - if( stored != null && stored.getStackSize() > 0 ) - { - String str = Long.toString( stored.getStackSize() ); - if( stored.getStackSize() >= 10000 ) - { - str = Long.toString( stored.getStackSize() / 1000 ) + 'k'; - } - if( stored.getStackSize() >= 10000000 ) - { - str = Long.toString( stored.getStackSize() / 1000000 ) + 'm'; - } - - str = GuiText.FromStorage.getLocal() + ": " + str; - final int w = 4 + this.font.getStringWidth( str ); - this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); - } - - downY += 5; - } - - boolean red = false; - if( missingStack != null && missingStack.getStackSize() > 0 ) - { - String str = Long.toString( missingStack.getStackSize() ); - if( missingStack.getStackSize() >= 10000 ) - { - str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k'; - } - if( missingStack.getStackSize() >= 10000000 ) - { - str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm'; - } - - str = GuiText.Missing.getLocal() + ": " + str; - final int w = 4 + this.font.getStringWidth( str ); - this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) ); - } - - red = true; - downY += 5; - } - - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { - String str = Long.toString( pendingStack.getStackSize() ); - if( pendingStack.getStackSize() >= 10000 ) - { - str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k'; - } - if( pendingStack.getStackSize() >= 10000000 ) - { - str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm'; - } - - str = GuiText.ToCraft.getLocal() + ": " + str; - final int w = 4 + this.font.getStringWidth( str ); - this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); - } - } - - RenderSystem.popMatrix(); - final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19; - final int posY = y * offY + yo; - - final ItemStack is = refStack.asItemStackRepresentation(); - - if( this.tooltip == z - viewStart ) - { - dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText(); - - if( lineList.size() > 0 ) - { - dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList ); - } - - toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8; - toolPosY = y * offY + yo; - } - - this.drawItem( posX, posY, is ); - - if( red ) - { - final int startX = x * ( 1 + sectionLength ) + xo; - final int startY = posY - 4; - fill( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 ); - } - - x++; - - if( x > 2 ) - { - y++; - x = 0; - } - } - } - - if( this.tooltip >= 0 && !dspToolTip.isEmpty() ) - { - this.drawTooltip( toolPosX, toolPosY + 10, dspToolTip ); - } - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.setScrollBar(); - this.bindTexture( "guis/craftingreport.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } - - private void setScrollBar() - { - final int size = this.visual.size(); - - this.getScrollBar().setTop( 19 ).setLeft( 218 ).setHeight( 114 ); - this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - this.rows, 1 ); - } - - public void postUpdate( final List list, final byte ref ) - { - switch( ref ) - { - case 0: - for( final IAEItemStack l : list ) - { - this.handleInput( this.storage, l ); - } - break; - - case 1: - for( final IAEItemStack l : list ) - { - this.handleInput( this.pending, l ); - } - break; - - case 2: - for( final IAEItemStack l : list ) - { - this.handleInput( this.missing, l ); - } - break; - } - - for( final IAEItemStack l : list ) - { - final long amt = this.getTotal( l ); - - if( amt <= 0 ) - { - this.deleteVisualStack( l ); - } - else - { - final IAEItemStack is = this.findVisualStack( l ); - is.setStackSize( amt ); - } - } - - this.setScrollBar(); - } - - private void handleInput( final IItemList s, final IAEItemStack l ) - { - IAEItemStack a = s.findPrecise( l ); - - if( l.getStackSize() <= 0 ) - { - if( a != null ) - { - a.reset(); - } - } - else - { - if( a == null ) - { - s.add( l.copy() ); - a = s.findPrecise( l ); - } - - if( a != null ) - { - a.setStackSize( l.getStackSize() ); - } - } - } - - private long getTotal( final IAEItemStack is ) - { - final IAEItemStack a = this.storage.findPrecise( is ); - final IAEItemStack c = this.pending.findPrecise( is ); - final IAEItemStack m = this.missing.findPrecise( is ); - - long total = 0; - - if( a != null ) - { - total += a.getStackSize(); - } - - if( c != null ) - { - total += c.getStackSize(); - } - - if( m != null ) - { - total += m.getStackSize(); - } - - return total; - } - - private void deleteVisualStack( final IAEItemStack l ) - { - final Iterator i = this.visual.iterator(); - while( i.hasNext() ) - { - final IAEItemStack o = i.next(); - if( o.equals( l ) ) - { - i.remove(); - return; - } - } - } - - private IAEItemStack findVisualStack( final IAEItemStack l ) - { - for( final IAEItemStack o : this.visual ) - { - if( o.equals( l ) ) - { - return o; - } - } - - final IAEItemStack stack = l.copy(); - this.visual.add( stack ); - return stack; - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { - if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) ) - { - if( keyCode == 28 ) - { - this.start(); - return true; - } - } - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } - - private void selectNextCpu() { - final boolean backwards = minecraft.mouseHelper.isRightDown(); - NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) ); - } - - private void start() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) ); - } + +public class GuiCraftConfirm extends AEBaseGui { + + private final AESubGui subGui; + + private final int rows = 5; + + private final IItemList storage = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final IItemList pending = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final IItemList missing = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + + private final List visual = new ArrayList<>(); + + private Button cancel; + private Button start; + private Button selectCPU; + private int tooltip = -1; + + public GuiCraftConfirm(ContainerCraftConfirm container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.subGui = new AESubGui(this, container.getTarget()); + this.xSize = 238; + this.ySize = 206; + + final GuiScrollbar scrollbar = new GuiScrollbar(); + this.setScrollBar(scrollbar); + } + + boolean isAutoStart() { + return this.container.isAutoStart(); + } + + @Override + public void init() { + super.init(); + + this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(), + btn -> start()); + this.start.active = false; + this.addButton(this.start); + + this.selectCPU = new Button(this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20, + GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu()); + this.selectCPU.active = false; + this.addButton(this.selectCPU); + + subGui.addBackButton(this::addButton, 6, this.ySize - 25, GuiText.Cancel.getLocal()); + + this.addButton(this.cancel); + } + + @Override + public void render(final int mouseX, final int mouseY, final float btn) { + this.updateCPUButtonText(); + + this.start.active = !(this.container.hasNoCPU() || this.isSimulation()); + this.selectCPU.active = !this.isSimulation(); + + final int gx = (this.width - this.xSize) / 2; + final int gy = (this.height - this.ySize) / 2; + + this.tooltip = -1; + + final int offY = 23; + int y = 0; + int x = 0; + for (int z = 0; z <= 4 * 5; z++) { + final int minX = gx + 9 + x * 67; + final int minY = gy + 22 + y * offY; + + if (minX < mouseX && minX + 67 > mouseX) { + if (minY < mouseY && minY + offY - 2 > mouseY) { + this.tooltip = z; + break; + } + } + + x++; + + if (x > 2) { + y++; + x = 0; + } + } + + super.render(mouseX, mouseY, btn); + } + + private void updateCPUButtonText() { + String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal(); + if (this.container.getSelectedCpu() >= 0)// && status.selectedCpu < status.cpus.size() ) + { + if (this.container.getName().length() > 0) { + final String name = this.container.getName().substring(0, + Math.min(20, this.container.getName().length())); + btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; + } else { + btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.container.getSelectedCpu(); + } + } + + if (this.container.hasNoCPU()) { + btnTextText = GuiText.NoCraftingCPUs.getLocal(); + } + + this.selectCPU.setMessage(btnTextText); + } + + private boolean isSimulation() { + return this.container.isSimulation(); + } + + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + final long BytesUsed = this.container.getUsedBytes(); + final String byteUsed = NumberFormat.getInstance().format(BytesUsed); + final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) + : GuiText.CalculatingWait.getLocal(); + this.font.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752); + + String dsp = null; + + if (this.isSimulation()) { + dsp = GuiText.Simulation.getLocal(); + } else { + dsp = this.container.getCpuAvailableBytes() > 0 + ? (GuiText.Bytes.getLocal() + ": " + this.container.getCpuAvailableBytes() + " : " + + GuiText.CoProcessors.getLocal() + ": " + this.container.getCpuCoProcessors()) + : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + } + + final int offset = (219 - this.font.getStringWidth(dsp)) / 2; + this.font.drawString(dsp, offset, 165, 4210752); + + final int sectionLength = 67; + + int x = 0; + int y = 0; + final int xo = 9; + final int yo = 22; + final int viewStart = this.getScrollBar().getCurrentScroll() * 3; + final int viewEnd = viewStart + 3 * this.rows; + + String dspToolTip = ""; + final List lineList = new ArrayList<>(); + int toolPosX = 0; + int toolPosY = 0; + + final int offY = 23; + + for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) { + final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z ); + if (refStack != null) { + RenderSystem.pushMatrix(); + RenderSystem.scalef(0.5f, 0.5f, 0.5f); + + final IAEItemStack stored = this.storage.findPrecise(refStack); + final IAEItemStack pendingStack = this.pending.findPrecise(refStack); + final IAEItemStack missingStack = this.missing.findPrecise(refStack); + + int lines = 0; + + if (stored != null && stored.getStackSize() > 0) { + lines++; + } + if (missingStack != null && missingStack.getStackSize() > 0) { + lines++; + } + if (pendingStack != null && pendingStack.getStackSize() > 0) { + lines++; + } + + final int negY = ((lines - 1) * 5) / 2; + int downY = 0; + + if (stored != null && stored.getStackSize() > 0) { + String str = Long.toString(stored.getStackSize()); + if (stored.getStackSize() >= 10000) { + str = Long.toString(stored.getStackSize() / 1000) + 'k'; + } + if (stored.getStackSize() >= 10000000) { + str = Long.toString(stored.getStackSize() / 1000000) + 'm'; + } + + str = GuiText.FromStorage.getLocal() + ": " + str; + final int w = 4 + this.font.getStringWidth(str); + this.font.drawString(str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, 4210752); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize())); + } + + downY += 5; + } + + boolean red = false; + if (missingStack != null && missingStack.getStackSize() > 0) { + String str = Long.toString(missingStack.getStackSize()); + if (missingStack.getStackSize() >= 10000) { + str = Long.toString(missingStack.getStackSize() / 1000) + 'k'; + } + if (missingStack.getStackSize() >= 10000000) { + str = Long.toString(missingStack.getStackSize() / 1000000) + 'm'; + } + + str = GuiText.Missing.getLocal() + ": " + str; + final int w = 4 + this.font.getStringWidth(str); + this.font.drawString(str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, 4210752); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize())); + } + + red = true; + downY += 5; + } + + if (pendingStack != null && pendingStack.getStackSize() > 0) { + String str = Long.toString(pendingStack.getStackSize()); + if (pendingStack.getStackSize() >= 10000) { + str = Long.toString(pendingStack.getStackSize() / 1000) + 'k'; + } + if (pendingStack.getStackSize() >= 10000000) { + str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm'; + } + + str = GuiText.ToCraft.getLocal() + ": " + str; + final int w = 4 + this.font.getStringWidth(str); + this.font.drawString(str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, 4210752); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); + } + } + + RenderSystem.popMatrix(); + final int posX = x * (1 + sectionLength) + xo + sectionLength - 19; + final int posY = y * offY + yo; + + final ItemStack is = refStack.asItemStackRepresentation(); + + if (this.tooltip == z - viewStart) { + dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText(); + + if (lineList.size() > 0) { + dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList); + } + + toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8; + toolPosY = y * offY + yo; + } + + this.drawItem(posX, posY, is); + + if (red) { + final int startX = x * (1 + sectionLength) + xo; + final int startY = posY - 4; + fill(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000); + } + + x++; + + if (x > 2) { + y++; + x = 0; + } + } + } + + if (this.tooltip >= 0 && !dspToolTip.isEmpty()) { + this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip); + } + } + + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.setScrollBar(); + this.bindTexture("guis/craftingreport.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } + + private void setScrollBar() { + final int size = this.visual.size(); + + this.getScrollBar().setTop(19).setLeft(218).setHeight(114); + this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1); + } + + public void postUpdate(final List list, final byte ref) { + switch (ref) { + case 0: + for (final IAEItemStack l : list) { + this.handleInput(this.storage, l); + } + break; + + case 1: + for (final IAEItemStack l : list) { + this.handleInput(this.pending, l); + } + break; + + case 2: + for (final IAEItemStack l : list) { + this.handleInput(this.missing, l); + } + break; + } + + for (final IAEItemStack l : list) { + final long amt = this.getTotal(l); + + if (amt <= 0) { + this.deleteVisualStack(l); + } else { + final IAEItemStack is = this.findVisualStack(l); + is.setStackSize(amt); + } + } + + this.setScrollBar(); + } + + private void handleInput(final IItemList s, final IAEItemStack l) { + IAEItemStack a = s.findPrecise(l); + + if (l.getStackSize() <= 0) { + if (a != null) { + a.reset(); + } + } else { + if (a == null) { + s.add(l.copy()); + a = s.findPrecise(l); + } + + if (a != null) { + a.setStackSize(l.getStackSize()); + } + } + } + + private long getTotal(final IAEItemStack is) { + final IAEItemStack a = this.storage.findPrecise(is); + final IAEItemStack c = this.pending.findPrecise(is); + final IAEItemStack m = this.missing.findPrecise(is); + + long total = 0; + + if (a != null) { + total += a.getStackSize(); + } + + if (c != null) { + total += c.getStackSize(); + } + + if (m != null) { + total += m.getStackSize(); + } + + return total; + } + + private void deleteVisualStack(final IAEItemStack l) { + final Iterator i = this.visual.iterator(); + while (i.hasNext()) { + final IAEItemStack o = i.next(); + if (o.equals(l)) { + i.remove(); + return; + } + } + } + + private IAEItemStack findVisualStack(final IAEItemStack l) { + for (final IAEItemStack o : this.visual) { + if (o.equals(l)) { + return o; + } + } + + final IAEItemStack stack = l.copy(); + this.visual.add(stack); + return stack; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) { + if (keyCode == 28) { + this.start(); + return true; + } + } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } + + private void selectNextCpu() { + final boolean backwards = minecraft.mouseHelper.isRightDown(); + NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next")); + } + + private void start() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Start", "Start")); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java index 1128d0535..97465eebf 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java @@ -18,6 +18,21 @@ package appeng.client.gui.implementations; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import com.google.common.base.Joiner; +import com.mojang.blaze3d.systems.RenderSystem; + +import org.apache.commons.lang3.time.DurationFormatUtils; + +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.AEApi; import appeng.api.config.SortDir; @@ -37,434 +52,378 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; import appeng.util.Platform; import appeng.util.ReadableNumberConverter; -import com.google.common.base.Joiner; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; -import org.apache.commons.lang3.time.DurationFormatUtils; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.TimeUnit; - - -public class GuiCraftingCPU extends AEBaseGui implements ISortSource -{ - private static final int GUI_HEIGHT = 184; - private static final int GUI_WIDTH = 238; - - private static final int DISPLAYED_ROWS = 6; - - private static final int TEXT_COLOR = 0x404040; - private static final int BACKGROUND_ALPHA = 0x5A000000; - - private static final int SECTION_LENGTH = 67; - - private static final int SCROLLBAR_TOP = 19; - private static final int SCROLLBAR_LEFT = 218; - private static final int SCROLLBAR_HEIGHT = 137; - - private static final int CANCEL_LEFT_OFFSET = 163; - private static final int CANCEL_TOP_OFFSET = 25; - private static final int CANCEL_HEIGHT = 20; - private static final int CANCEL_WIDTH = 50; - - private static final int TITLE_TOP_OFFSET = 7; - private static final int TITLE_LEFT_OFFSET = 8; - - private static final int ITEMSTACK_LEFT_OFFSET = 9; - private static final int ITEMSTACK_TOP_OFFSET = 22; - - private IItemList storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private IItemList active = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private IItemList pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - - private List visual = new ArrayList<>(); - private Button cancel; - private int tooltip = -1; - - public GuiCraftingCPU(T container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = GUI_HEIGHT; - this.xSize = GUI_WIDTH; - - final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - } - - public void clearItems() - { - this.storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - this.active = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - this.pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - this.visual = new ArrayList<>(); - } - - private void cancel() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) ); - } - - @Override - public void init() - { - super.init(); - this.setScrollBar(); - this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel - .getLocal(), btn -> cancel() ); - this.addButton( this.cancel ); - } - - private void setScrollBar() - { - final int size = this.visual.size(); - - this.getScrollBar().setTop( SCROLLBAR_TOP ).setLeft( SCROLLBAR_LEFT ).setHeight( SCROLLBAR_HEIGHT ); - this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - DISPLAYED_ROWS, 1 ); - } - - @Override - public void render(final int mouseX, final int mouseY, final float btn ) - { - this.cancel.active = !this.visual.isEmpty(); - - final int gx = ( this.width - this.xSize ) / 2; - final int gy = ( this.height - this.ySize ) / 2; - - this.tooltip = -1; - - final int offY = 23; - int y = 0; - int x = 0; - for( int z = 0; z <= 4 * 5; z++ ) - { - final int minX = gx + 9 + x * 67; - final int minY = gy + 22 + y * offY; - - if( minX < mouseX && minX + 67 > mouseX ) - { - if( minY < mouseY && minY + offY - 2 > mouseY ) - { - this.tooltip = z; - break; - } - } - - x++; - - if( x > 2 ) - { - y++; - x = 0; - } - } - - super.render( mouseX, mouseY, btn ); - } - - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - String title = this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() ); - - if( this.container.getEstimatedTime() > 0 && !this.visual.isEmpty() ) - { - final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.container.getEstimatedTime(), TimeUnit.NANOSECONDS ); - final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, GuiText.ETAFormat.getLocal() ); - title += " - " + etaTimeText; - } - - this.font.drawString( title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR ); - - int x = 0; - int y = 0; - final int viewStart = this.getScrollBar().getCurrentScroll() * 3; - final int viewEnd = viewStart + 3 * 6; - - String dspToolTip = ""; - final List lineList = new ArrayList<>(); - int toolPosX = 0; - int toolPosY = 0; - - final int offY = 23; - - final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; - for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ ) - { - final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z ); - if( refStack != null ) - { - RenderSystem.pushMatrix(); - RenderSystem.scalef( 0.5f, 0.5f, 0.5f ); - - final IAEItemStack stored = this.storage.findPrecise( refStack ); - final IAEItemStack activeStack = this.active.findPrecise( refStack ); - final IAEItemStack pendingStack = this.pending.findPrecise( refStack ); - - int lines = 0; - - if( stored != null && stored.getStackSize() > 0 ) - { - lines++; - } - boolean active = false; - if( activeStack != null && activeStack.getStackSize() > 0 ) - { - lines++; - active = true; - } - boolean scheduled = false; - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { - lines++; - scheduled = true; - } - - if( AEConfig.instance().isUseColoredCraftingStatus() && ( active || scheduled ) ) - { - final int bgColor = ( active ? AEColor.GREEN.blackVariant : AEColor.YELLOW.blackVariant ) | BACKGROUND_ALPHA; - final int startX = ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET ) * 2; - final int startY = ( ( y * offY + ITEMSTACK_TOP_OFFSET ) - 3 ) * 2; - fill( startX, startY, startX + ( SECTION_LENGTH * 2 ), startY + ( offY * 2 ) - 2, bgColor ); - } - - final int negY = ( ( lines - 1 ) * 5 ) / 2; - int downY = 0; - - if( stored != null && stored.getStackSize() > 0 ) - { - final String str = GuiText.Stored.getLocal() + ": " + converter.toWideReadableForm( stored.getStackSize() ); - final int w = 4 + this.font.getStringWidth( str ); - this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); - } - - downY += 5; - } - - if( activeStack != null && activeStack.getStackSize() > 0 ) - { - final String str = GuiText.Crafting.getLocal() + ": " + converter.toWideReadableForm( activeStack.getStackSize() ); - final int w = 4 + this.font.getStringWidth( str ); - - this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) ); - } - - downY += 5; - } - - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { - final String str = GuiText.Scheduled.getLocal() + ": " + converter.toWideReadableForm( pendingStack.getStackSize() ); - final int w = 4 + this.font.getStringWidth( str ); - - this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), - ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR ); - - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); - } - } - - RenderSystem.popMatrix(); - final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19; - final int posY = y * offY + ITEMSTACK_TOP_OFFSET; - - final ItemStack is = refStack.asItemStackRepresentation(); - - if( this.tooltip == z - viewStart ) - { - dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText(); - - if( lineList.size() > 0 ) - { - dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList ); - } - - toolPosX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8; - toolPosY = y * offY + ITEMSTACK_TOP_OFFSET; - } - - this.drawItem( posX, posY, is ); - - x++; - - if( x > 2 ) - { - y++; - x = 0; - } - } - } - - if( this.tooltip >= 0 && !dspToolTip.isEmpty() ) - { - this.drawTooltip( toolPosX, toolPosY + 10, dspToolTip ); - } - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/craftingcpu.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } - - public void postUpdate( final List list, final byte ref ) - { - switch( ref ) - { - case 0: - for( final IAEItemStack l : list ) - { - this.handleInput( this.storage, l ); - } - break; - - case 1: - for( final IAEItemStack l : list ) - { - this.handleInput( this.active, l ); - } - break; - - case 2: - for( final IAEItemStack l : list ) - { - this.handleInput( this.pending, l ); - } - break; - } - - for( final IAEItemStack l : list ) - { - final long amt = this.getTotal( l ); - - if( amt <= 0 ) - { - this.deleteVisualStack( l ); - } - else - { - final IAEItemStack is = this.findVisualStack( l ); - is.setStackSize( amt ); - } - } - - this.setScrollBar(); - } - - private void handleInput( final IItemList s, final IAEItemStack l ) - { - IAEItemStack a = s.findPrecise( l ); - - if( l.getStackSize() <= 0 ) - { - if( a != null ) - { - a.reset(); - } - } - else - { - if( a == null ) - { - s.add( l.copy() ); - a = s.findPrecise( l ); - } - - if( a != null ) - { - a.setStackSize( l.getStackSize() ); - } - } - } - - private long getTotal( final IAEItemStack is ) - { - final IAEItemStack a = this.storage.findPrecise( is ); - final IAEItemStack b = this.active.findPrecise( is ); - final IAEItemStack c = this.pending.findPrecise( is ); - - long total = 0; - - if( a != null ) - { - total += a.getStackSize(); - } - - if( b != null ) - { - total += b.getStackSize(); - } - - if( c != null ) - { - total += c.getStackSize(); - } - - return total; - } - - private void deleteVisualStack( final IAEItemStack l ) - { - final Iterator i = this.visual.iterator(); - - while( i.hasNext() ) - { - final IAEItemStack o = i.next(); - if( o.equals( l ) ) - { - i.remove(); - return; - } - } - } - - private IAEItemStack findVisualStack( final IAEItemStack l ) - { - for( final IAEItemStack o : this.visual ) - { - if( o.equals( l ) ) - { - return o; - } - } - - final IAEItemStack stack = l.copy(); - this.visual.add( stack ); - - return stack; - } - - @Override - public SortOrder getSortBy() - { - return SortOrder.NAME; - } - - @Override - public SortDir getSortDir() - { - return SortDir.ASCENDING; - } - - @Override - public ViewItems getSortDisplay() - { - return ViewItems.ALL; - } + +public class GuiCraftingCPU extends AEBaseGui implements ISortSource { + private static final int GUI_HEIGHT = 184; + private static final int GUI_WIDTH = 238; + + private static final int DISPLAYED_ROWS = 6; + + private static final int TEXT_COLOR = 0x404040; + private static final int BACKGROUND_ALPHA = 0x5A000000; + + private static final int SECTION_LENGTH = 67; + + private static final int SCROLLBAR_TOP = 19; + private static final int SCROLLBAR_LEFT = 218; + private static final int SCROLLBAR_HEIGHT = 137; + + private static final int CANCEL_LEFT_OFFSET = 163; + private static final int CANCEL_TOP_OFFSET = 25; + private static final int CANCEL_HEIGHT = 20; + private static final int CANCEL_WIDTH = 50; + + private static final int TITLE_TOP_OFFSET = 7; + private static final int TITLE_LEFT_OFFSET = 8; + + private static final int ITEMSTACK_LEFT_OFFSET = 9; + private static final int ITEMSTACK_TOP_OFFSET = 22; + + private IItemList storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private IItemList active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private IItemList pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + + private List visual = new ArrayList<>(); + private Button cancel; + private int tooltip = -1; + + public GuiCraftingCPU(T container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = GUI_HEIGHT; + this.xSize = GUI_WIDTH; + + final GuiScrollbar scrollbar = new GuiScrollbar(); + this.setScrollBar(scrollbar); + } + + public void clearItems() { + this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + this.visual = new ArrayList<>(); + } + + private void cancel() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("TileCrafting.Cancel", "Cancel")); + } + + @Override + public void init() { + super.init(); + this.setScrollBar(); + this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, + CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal(), btn -> cancel()); + this.addButton(this.cancel); + } + + private void setScrollBar() { + final int size = this.visual.size(); + + this.getScrollBar().setTop(SCROLLBAR_TOP).setLeft(SCROLLBAR_LEFT).setHeight(SCROLLBAR_HEIGHT); + this.getScrollBar().setRange(0, (size + 2) / 3 - DISPLAYED_ROWS, 1); + } + + @Override + public void render(final int mouseX, final int mouseY, final float btn) { + this.cancel.active = !this.visual.isEmpty(); + + final int gx = (this.width - this.xSize) / 2; + final int gy = (this.height - this.ySize) / 2; + + this.tooltip = -1; + + final int offY = 23; + int y = 0; + int x = 0; + for (int z = 0; z <= 4 * 5; z++) { + final int minX = gx + 9 + x * 67; + final int minY = gy + 22 + y * offY; + + if (minX < mouseX && minX + 67 > mouseX) { + if (minY < mouseY && minY + offY - 2 > mouseY) { + this.tooltip = z; + break; + } + } + + x++; + + if (x > 2) { + y++; + x = 0; + } + } + + super.render(mouseX, mouseY, btn); + } + + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal()); + + if (this.container.getEstimatedTime() > 0 && !this.visual.isEmpty()) { + final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.container.getEstimatedTime(), + TimeUnit.NANOSECONDS); + final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds, + GuiText.ETAFormat.getLocal()); + title += " - " + etaTimeText; + } + + this.font.drawString(title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR); + + int x = 0; + int y = 0; + final int viewStart = this.getScrollBar().getCurrentScroll() * 3; + final int viewEnd = viewStart + 3 * 6; + + String dspToolTip = ""; + final List lineList = new ArrayList<>(); + int toolPosX = 0; + int toolPosY = 0; + + final int offY = 23; + + final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; + for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) { + final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z ); + if (refStack != null) { + RenderSystem.pushMatrix(); + RenderSystem.scalef(0.5f, 0.5f, 0.5f); + + final IAEItemStack stored = this.storage.findPrecise(refStack); + final IAEItemStack activeStack = this.active.findPrecise(refStack); + final IAEItemStack pendingStack = this.pending.findPrecise(refStack); + + int lines = 0; + + if (stored != null && stored.getStackSize() > 0) { + lines++; + } + boolean active = false; + if (activeStack != null && activeStack.getStackSize() > 0) { + lines++; + active = true; + } + boolean scheduled = false; + if (pendingStack != null && pendingStack.getStackSize() > 0) { + lines++; + scheduled = true; + } + + if (AEConfig.instance().isUseColoredCraftingStatus() && (active || scheduled)) { + final int bgColor = (active ? AEColor.GREEN.blackVariant : AEColor.YELLOW.blackVariant) + | BACKGROUND_ALPHA; + final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2; + final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2; + fill(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor); + } + + final int negY = ((lines - 1) * 5) / 2; + int downY = 0; + + if (stored != null && stored.getStackSize() > 0) { + final String str = GuiText.Stored.getLocal() + ": " + + converter.toWideReadableForm(stored.getStackSize()); + final int w = 4 + this.font.getStringWidth(str); + this.font.drawString(str, + (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5)) + * 2), + (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.Stored.getLocal() + ": " + Long.toString(stored.getStackSize())); + } + + downY += 5; + } + + if (activeStack != null && activeStack.getStackSize() > 0) { + final String str = GuiText.Crafting.getLocal() + ": " + + converter.toWideReadableForm(activeStack.getStackSize()); + final int w = 4 + this.font.getStringWidth(str); + + this.font.drawString(str, + (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5)) + * 2), + (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.Crafting.getLocal() + ": " + Long.toString(activeStack.getStackSize())); + } + + downY += 5; + } + + if (pendingStack != null && pendingStack.getStackSize() > 0) { + final String str = GuiText.Scheduled.getLocal() + ": " + + converter.toWideReadableForm(pendingStack.getStackSize()); + final int w = 4 + this.font.getStringWidth(str); + + this.font.drawString(str, + (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5)) + * 2), + (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); + + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.Scheduled.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); + } + } + + RenderSystem.popMatrix(); + final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19; + final int posY = y * offY + ITEMSTACK_TOP_OFFSET; + + final ItemStack is = refStack.asItemStackRepresentation(); + + if (this.tooltip == z - viewStart) { + dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText(); + + if (lineList.size() > 0) { + dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList); + } + + toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8; + toolPosY = y * offY + ITEMSTACK_TOP_OFFSET; + } + + this.drawItem(posX, posY, is); + + x++; + + if (x > 2) { + y++; + x = 0; + } + } + } + + if (this.tooltip >= 0 && !dspToolTip.isEmpty()) { + this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip); + } + } + + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/craftingcpu.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } + + public void postUpdate(final List list, final byte ref) { + switch (ref) { + case 0: + for (final IAEItemStack l : list) { + this.handleInput(this.storage, l); + } + break; + + case 1: + for (final IAEItemStack l : list) { + this.handleInput(this.active, l); + } + break; + + case 2: + for (final IAEItemStack l : list) { + this.handleInput(this.pending, l); + } + break; + } + + for (final IAEItemStack l : list) { + final long amt = this.getTotal(l); + + if (amt <= 0) { + this.deleteVisualStack(l); + } else { + final IAEItemStack is = this.findVisualStack(l); + is.setStackSize(amt); + } + } + + this.setScrollBar(); + } + + private void handleInput(final IItemList s, final IAEItemStack l) { + IAEItemStack a = s.findPrecise(l); + + if (l.getStackSize() <= 0) { + if (a != null) { + a.reset(); + } + } else { + if (a == null) { + s.add(l.copy()); + a = s.findPrecise(l); + } + + if (a != null) { + a.setStackSize(l.getStackSize()); + } + } + } + + private long getTotal(final IAEItemStack is) { + final IAEItemStack a = this.storage.findPrecise(is); + final IAEItemStack b = this.active.findPrecise(is); + final IAEItemStack c = this.pending.findPrecise(is); + + long total = 0; + + if (a != null) { + total += a.getStackSize(); + } + + if (b != null) { + total += b.getStackSize(); + } + + if (c != null) { + total += c.getStackSize(); + } + + return total; + } + + private void deleteVisualStack(final IAEItemStack l) { + final Iterator i = this.visual.iterator(); + + while (i.hasNext()) { + final IAEItemStack o = i.next(); + if (o.equals(l)) { + i.remove(); + return; + } + } + } + + private IAEItemStack findVisualStack(final IAEItemStack l) { + for (final IAEItemStack o : this.visual) { + if (o.equals(l)) { + return o; + } + } + + final IAEItemStack stack = l.copy(); + this.visual.add(stack); + + return stack; + } + + @Override + public SortOrder getSortBy() { + return SortOrder.NAME; + } + + @Override + public SortDir getSortDir() { + return SortDir.ASCENDING; + } + + @Override + public ViewItems getSortDisplay() { + return ViewItems.ALL; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index 958588201..2a2bd0dae 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -22,88 +22,78 @@ package appeng.client.gui.implementations; +import java.io.IOException; + +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.container.implementations.ContainerCraftingStatus; import appeng.core.AELog; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import java.io.IOException; +public class GuiCraftingStatus extends GuiCraftingCPU { + private final AESubGui subGui; -public class GuiCraftingStatus extends GuiCraftingCPU -{ + private Button selectCPU; - private final AESubGui subGui; + public GuiCraftingStatus(ContainerCraftingStatus container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.subGui = new AESubGui(this, container.getTarget()); + } - private Button selectCPU; + @Override + public void init() { + super.init(); - public GuiCraftingStatus(ContainerCraftingStatus container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.subGui = new AESubGui(this, container.getTarget()); - } + this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, + GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu()); + this.addButton(this.selectCPU); - @Override - public void init() - { - super.init(); + subGui.addBackButton(btn -> { + addButton(btn); + btn.setHideEdge(13); + }, 213, -4); + } - this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU - .getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu() ); - this.addButton( this.selectCPU ); + @Override + public void render(final int mouseX, final int mouseY, final float btn) { + this.updateCPUButtonText(); + super.render(mouseX, mouseY, btn); + } - subGui.addBackButton(btn -> { - addButton(btn); - btn.setHideEdge( 13 ); - }, 213, -4); - } + private void updateCPUButtonText() { + String btnTextText = GuiText.NoCraftingJobs.getLocal(); - @Override - public void render(final int mouseX, final int mouseY, final float btn ) - { - this.updateCPUButtonText(); - super.render( mouseX, mouseY, btn ); - } + if (this.container.selectedCpu >= 0)// && status.selectedCpu < status.cpus.size() ) + { + if (this.container.myName.length() > 0) { + final String name = this.container.myName.substring(0, Math.min(20, this.container.myName.length())); + btnTextText = GuiText.CPUs.getLocal() + ": " + name; + } else { + btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu; + } + } - private void updateCPUButtonText() - { - String btnTextText = GuiText.NoCraftingJobs.getLocal(); + if (this.container.noCPU) { + btnTextText = GuiText.NoCraftingJobs.getLocal(); + } - if( this.container.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() ) - { - if( this.container.myName.length() > 0 ) - { - final String name = this.container.myName.substring( 0, Math.min( 20, this.container.myName.length() ) ); - btnTextText = GuiText.CPUs.getLocal() + ": " + name; - } - else - { - btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu; - } - } + this.selectCPU.setMessage(btnTextText); + } - if( this.container.noCPU ) - { - btnTextText = GuiText.NoCraftingJobs.getLocal(); - } + @Override + protected String getGuiDisplayName(final String in) { + return in; // the cup name is on the button + } - this.selectCPU.setMessage(btnTextText); - } - - @Override - protected String getGuiDisplayName( final String in ) - { - return in; // the cup name is on the button - } - - // FIXME: Extract to separate class? Shared with GuiCraftConfirm - private void selectNextCpu() { - final boolean backwards = minecraft.mouseHelper.isRightDown(); - NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) ); - } + // FIXME: Extract to separate class? Shared with GuiCraftConfirm + private void selectNextCpu() { + final boolean backwards = minecraft.mouseHelper.isRightDown(); + NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next")); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java index 2a2c11323..6d3a85383 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java @@ -18,12 +18,13 @@ package appeng.client.gui.implementations; - -import appeng.client.gui.widgets.GuiActionButton; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Slot; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.ActionItems; import appeng.api.config.Settings; +import appeng.client.gui.widgets.GuiActionButton; import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.slot.SlotCraftingMatrix; @@ -31,53 +32,45 @@ import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketInventoryAction; import appeng.helpers.InventoryAction; -import net.minecraft.inventory.container.Slot; -import net.minecraft.util.text.ITextComponent; +public class GuiCraftingTerm extends GuiMEMonitorable { -public class GuiCraftingTerm extends GuiMEMonitorable -{ + public GuiCraftingTerm(ContainerCraftingTerm container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.setReservedSpace(73); + } - public GuiCraftingTerm(ContainerCraftingTerm container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.setReservedSpace( 73 ); - } + private void clear() { + Slot s = null; + for (final Object j : this.container.inventorySlots) { + if (j instanceof SlotCraftingMatrix) { + s = (Slot) j; + } + } - private void clear() { - Slot s = null; - for( final Object j : this.container.inventorySlots ) - { - if( j instanceof SlotCraftingMatrix ) - { - s = (Slot) j; - } - } + if (s != null) { + final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0); + NetworkHandler.instance().sendToServer(p); + } + } - if( s != null ) - { - final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 ); - NetworkHandler.instance().sendToServer( p ); - } - } + @Override + public void init() { + super.init(); + GuiActionButton clearBtn = this.addButton(new GuiActionButton(this.guiLeft + 92, this.guiTop + this.ySize - 156, + ActionItems.STASH, btn -> clear())); + clearBtn.setHalfSize(true); + } - @Override - public void init() - { - super.init(); - GuiActionButton clearBtn = this.addButton( new GuiActionButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, ActionItems.STASH, btn -> clear() )); - clearBtn.setHalfSize( true ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.font.drawString(GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), + 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.font.drawString( GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752 ); - } - - @Override - protected String getBackground() - { - return "guis/crafting.png"; - } + @Override + protected String getBackground() { + return "guis/crafting.png"; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiDrive.java b/src/main/java/appeng/client/gui/implementations/GuiDrive.java index c3a12f2c4..07a4c45e6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiDrive.java +++ b/src/main/java/appeng/client/gui/implementations/GuiDrive.java @@ -18,6 +18,9 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiTabButton; @@ -26,42 +29,35 @@ import appeng.container.implementations.ContainerPriority; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketSwitchGuis; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiDrive extends AEBaseGui { -public class GuiDrive extends AEBaseGui -{ + public GuiDrive(ContainerDrive container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 199; + } - public GuiDrive(ContainerDrive container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 199; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriorityGui())); + } - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.Drive.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/drive.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/drive.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java b/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java index 23ac13217..4e3d549a0 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java +++ b/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java @@ -18,6 +18,8 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; @@ -30,57 +32,51 @@ import appeng.container.implementations.ContainerPriority; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketSwitchGuis; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiFormationPlane extends GuiUpgradeable { -public class GuiFormationPlane extends GuiUpgradeable -{ + private GuiSettingToggleButton placeMode; - private GuiSettingToggleButton placeMode; + public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 251; + } - public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 251; - } + @Override + protected void addButtons() { + this.placeMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, + YesNo.YES); + this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, + FuzzyMode.IGNORE_ALL); - @Override - protected void addButtons() - { - this.placeMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES ); - this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriorityGui())); - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); + this.addButton(this.placeMode); + this.addButton(this.fuzzyMode); + } - this.addButton( this.placeMode ); - this.addButton( this.fuzzyMode ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.FormationPlane.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + if (this.fuzzyMode != null) { + this.fuzzyMode.set(this.cvb.getFuzzyMode()); + } - if( this.fuzzyMode != null ) - { - this.fuzzyMode.set( this.cvb.getFuzzyMode() ); - } + if (this.placeMode != null) { + this.placeMode.set(((ContainerFormationPlane) this.cvb).getPlaceMode()); + } + } - if( this.placeMode != null ) - { - this.placeMode.set( ( (ContainerFormationPlane) this.cvb ).getPlaceMode() ); - } - } + @Override + protected String getBackground() { + return "guis/storagebus.png"; + } - @Override - protected String getBackground() - { - return "guis/storagebus.png"; - } - - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiGrinder.java b/src/main/java/appeng/client/gui/implementations/GuiGrinder.java index a00d114be..e95301c8c 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiGrinder.java +++ b/src/main/java/appeng/client/gui/implementations/GuiGrinder.java @@ -18,35 +18,30 @@ package appeng.client.gui.implementations; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.container.implementations.ContainerGrinder; import appeng.core.localization.GuiText; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiGrinder extends AEBaseGui { -public class GuiGrinder extends AEBaseGui -{ + public GuiGrinder(ContainerGrinder container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 176; + } - public GuiGrinder(ContainerGrinder container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 176; - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/grinder.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/grinder.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java index 0835ce6aa..b4d41b2ee 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java +++ b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java @@ -18,6 +18,8 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.AEApi; import appeng.api.config.FullnessMode; @@ -29,71 +31,65 @@ import appeng.client.gui.widgets.GuiServerSettingToggleButton; import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.container.implementations.ContainerIOPort; import appeng.core.localization.GuiText; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiIOPort extends GuiUpgradeable { -public class GuiIOPort extends GuiUpgradeable -{ + private GuiSettingToggleButton fullMode; + private GuiSettingToggleButton operationMode; - private GuiSettingToggleButton fullMode; - private GuiSettingToggleButton operationMode; + public GuiIOPort(ContainerIOPort container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiIOPort(ContainerIOPort container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + protected void addButtons() { + this.fullMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, + FullnessMode.EMPTY); + this.operationMode = new GuiServerSettingToggleButton<>(this.guiLeft + 80, this.guiTop + 17, + Settings.OPERATION_MODE, OperationMode.EMPTY); - @Override - protected void addButtons() - { - this.fullMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY ); - this.operationMode = new GuiServerSettingToggleButton<>( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY ); + this.addButton(this.operationMode); + this.addButton(this.fullMode); + this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, + Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + addButton(this.redstoneMode); + } - this.addButton( this.operationMode ); - this.addButton( this.fullMode ); - this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - addButton(this.redstoneMode); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.IOPort.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + if (this.redstoneMode != null) { + this.redstoneMode.set(this.cvb.getRedStoneMode()); + } - if( this.redstoneMode != null ) - { - this.redstoneMode.set( this.cvb.getRedStoneMode() ); - } + if (this.operationMode != null) { + this.operationMode.set(((ContainerIOPort) this.cvb).getOperationMode()); + } - if( this.operationMode != null ) - { - this.operationMode.set( ( (ContainerIOPort) this.cvb ).getOperationMode() ); - } + if (this.fullMode != null) { + this.fullMode.set(((ContainerIOPort) this.cvb).getFullMode()); + } + } - if( this.fullMode != null ) - { - this.fullMode.set( ( (ContainerIOPort) this.cvb ).getFullMode() ); - } - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks); + final IDefinitions definitions = AEApi.instance().definitions(); - final IDefinitions definitions = AEApi.instance().definitions(); + definitions.items().cell1k().maybeStack(1) + .ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack)); - definitions.items().cell1k().maybeStack( 1 ).ifPresent( cell1kStack -> this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack ) ); + definitions.blocks().drive().maybeStack(1) + .ifPresent(driveStack -> this.drawItem(offsetX + 94 + 8, offsetY + 17, driveStack)); + } - definitions.blocks().drive().maybeStack( 1 ).ifPresent( driveStack -> this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack ) ); - } - - @Override - protected String getBackground() - { - return "guis/io_port.png"; - } + @Override + protected String getBackground() { + return "guis/io_port.png"; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java index 2e71bebff..2fd185f26 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java @@ -18,73 +18,66 @@ package appeng.client.gui.implementations; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiProgressBar; import appeng.client.gui.widgets.GuiProgressBar.Direction; import appeng.container.implementations.ContainerInscriber; import appeng.core.localization.GuiText; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiInscriber extends AEBaseGui { -public class GuiInscriber extends AEBaseGui -{ + private GuiProgressBar pb; - private GuiProgressBar pb; + public GuiInscriber(ContainerInscriber container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 176; + this.xSize = this.hasToolbox() ? 246 : 211; + } - public GuiInscriber(ContainerInscriber container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 176; - this.xSize = this.hasToolbox() ? 246 : 211; - } + private boolean hasToolbox() { + return this.container.hasToolbox(); + } - private boolean hasToolbox() - { - return this.container.hasToolbox(); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.pb = new GuiProgressBar(this.container, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, + Direction.VERTICAL); + this.addButton(this.pb); + } - this.pb = new GuiProgressBar( this.container, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL ); - this.addButton( this.pb ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.pb.setFullMsg(this.container.getCurrentProgress() * 100 / this.container.getMaxProgress() + "%"); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.pb.setFullMsg( this.container.getCurrentProgress() * 100 / this.container.getMaxProgress() + "%" ); + this.font.drawString(this.getGuiDisplayName(GuiText.Inscriber.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - this.font.drawString( this.getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/inscriber.png"); + this.pb.x = 135 + this.guiLeft; + this.pb.y = 39 + this.guiTop; - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/inscriber.png" ); - this.pb.x = 135 + this.guiLeft; - this.pb.y = 39 + this.guiTop; + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset()); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() ); + if (this.drawUpgrades()) { + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, + 14 + this.container.availableUpgrades() * 18, getBlitOffset()); + } + if (this.hasToolbox()) { + GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, + getBlitOffset()); + } + } - if( this.drawUpgrades() ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.container.availableUpgrades() * 18, getBlitOffset() ); - } - if( this.hasToolbox() ) - { - GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, getBlitOffset() ); - } - } - - private boolean drawUpgrades() - { - return true; - } + private boolean drawUpgrades() { + return true; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterface.java b/src/main/java/appeng/client/gui/implementations/GuiInterface.java index 77cc1f35a..54ace0c4d 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterface.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterface.java @@ -18,6 +18,8 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.Settings; import appeng.api.config.YesNo; @@ -31,69 +33,63 @@ import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketConfigButton; import appeng.core.sync.packets.PacketSwitchGuis; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiInterface extends GuiUpgradeable { -public class GuiInterface extends GuiUpgradeable -{ + private GuiSettingToggleButton blockMode; + private GuiToggleButton interfaceMode; - private GuiSettingToggleButton blockMode; - private GuiToggleButton interfaceMode; + public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 211; + } - public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 211; - } + @Override + protected void addButtons() { + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriorityGui())); - @Override - protected void addButtons() - { - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); + this.blockMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, + YesNo.NO); + this.addButton(this.blockMode); - this.blockMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO ); - this.addButton( this.blockMode); + this.interfaceMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 26, 84, 85, + GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal(), + btn -> selectNextInterfaceMode()); + this.addButton(this.interfaceMode); + } - this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal - .getLocal(), GuiText.InterfaceTerminalHint.getLocal(), btn -> selectNextInterfaceMode() ); - this.addButton( this.interfaceMode ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (this.blockMode != null) { + this.blockMode.set(((ContainerInterface) this.cvb).getBlockingMode()); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if( this.blockMode != null ) - { - this.blockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() ); - } + if (this.interfaceMode != null) { + this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES); + } - if( this.interfaceMode != null ) - { - this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES ); - } + this.font.drawString(this.getGuiDisplayName(GuiText.Interface.getLocal()), 8, 6, 4210752); - this.font.drawString( this.getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 ); + this.font.drawString(GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752); + this.font.drawString(GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752); + this.font.drawString(GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752); - this.font.drawString( GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752 ); - this.font.drawString( GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752 ); - this.font.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 ); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } + @Override + protected String getBackground() { + return "guis/interface.png"; + } - @Override - protected String getBackground() - { - return "guis/interface.png"; - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } - - private void selectNextInterfaceMode() { - final boolean backwards = getMinecraft().mouseHelper.isRightDown(); - NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) ); - } + private void selectNextInterfaceMode() { + final boolean backwards = getMinecraft().mouseHelper.isRightDown(); + NetworkHandler.instance().sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards)); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java index d743f6e58..8de92fce6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java @@ -18,6 +18,18 @@ package appeng.client.gui.implementations; +import java.util.*; + +import com.google.common.collect.HashMultimap; +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.AEApi; import appeng.api.storage.channels.IItemStorageChannel; @@ -29,368 +41,310 @@ import appeng.client.me.SlotDisconnected; import appeng.container.implementations.ContainerInterfaceTerminal; import appeng.core.localization.GuiText; import appeng.util.Platform; -import com.google.common.collect.HashMultimap; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; -import java.util.*; +public class GuiInterfaceTerminal extends AEBaseGui { + private static final int LINES_ON_PAGE = 6; -public class GuiInterfaceTerminal extends AEBaseGui -{ + // TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded? + private final int offsetX = 9; - private static final int LINES_ON_PAGE = 6; + private final HashMap byId = new HashMap<>(); + private final HashMultimap byName = HashMultimap.create(); + private final ArrayList names = new ArrayList<>(); + private final ArrayList lines = new ArrayList<>(); - // TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded? - private final int offsetX = 9; + private final Map> cachedSearches = new WeakHashMap<>(); - private final HashMap byId = new HashMap<>(); - private final HashMultimap byName = HashMultimap.create(); - private final ArrayList names = new ArrayList<>(); - private final ArrayList lines = new ArrayList<>(); + private boolean refreshList = false; + private MEGuiTextField searchField; - private final Map> cachedSearches = new WeakHashMap<>(); + public GuiInterfaceTerminal(ContainerInterfaceTerminal container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + final GuiScrollbar scrollbar = new GuiScrollbar(); + this.setScrollBar(scrollbar); + this.xSize = 195; + this.ySize = 222; + } - private boolean refreshList = false; - private MEGuiTextField searchField; + @Override + public void init() { + super.init(); - public GuiInterfaceTerminal(ContainerInterfaceTerminal container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - this.xSize = 195; - this.ySize = 222; - } + this.getScrollBar().setLeft(175); + this.getScrollBar().setHeight(106); + this.getScrollBar().setTop(18); - @Override - public void init() - { - super.init(); + this.searchField = new MEGuiTextField(this.font, this.guiLeft + Math.max(104, this.offsetX), this.guiTop + 4, + 65, 12); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setMaxStringLength(25); + this.searchField.setTextColor(0xFFFFFF); + this.searchField.setVisible(true); + this.searchField.setFocused2(true); + } - this.getScrollBar().setLeft( 175 ); - this.getScrollBar().setHeight( 106 ); - this.getScrollBar().setTop( 18 ); + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 ); - this.searchField.setEnableBackgroundDrawing( false ); - this.searchField.setMaxStringLength( 25 ); - this.searchField.setTextColor( 0xFFFFFF ); - this.searchField.setVisible( true ); - this.searchField.setFocused2( true ); - } + final int ex = this.getScrollBar().getCurrentScroll(); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + final Iterator o = this.container.inventorySlots.iterator(); + while (o.hasNext()) { + if (o.next() instanceof SlotDisconnected) { + o.remove(); + } + } - final int ex = this.getScrollBar().getCurrentScroll(); + int offset = 17; + for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) { + final Object lineObj = this.lines.get(ex + x); + if (lineObj instanceof ClientDCInternalInv) { + final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; + for (int z = 0; z < inv.getInventory().getSlots(); z++) { + this.container.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 8, 1 + offset)); + } + } else if (lineObj instanceof String) { + String name = (String) lineObj; + final int rows = this.byName.get(name).size(); + if (rows > 1) { + name = name + " (" + rows + ')'; + } - final Iterator o = this.container.inventorySlots.iterator(); - while( o.hasNext() ) - { - if( o.next() instanceof SlotDisconnected ) - { - o.remove(); - } - } + while (name.length() > 2 && this.font.getStringWidth(name) > 155) { + name = name.substring(0, name.length() - 1); + } - int offset = 17; - for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ ) - { - final Object lineObj = this.lines.get( ex + x ); - if( lineObj instanceof ClientDCInternalInv ) - { - final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; - for( int z = 0; z < inv.getInventory().getSlots(); z++ ) - { - this.container.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) ); - } - } - else if( lineObj instanceof String ) - { - String name = (String) lineObj; - final int rows = this.byName.get( name ).size(); - if( rows > 1 ) - { - name = name + " (" + rows + ')'; - } + this.font.drawString(name, 10, 6 + offset, 4210752); + } + offset += 18; + } + } - while( name.length() > 2 && this.font.getStringWidth( name ) > 155 ) - { - name = name.substring( 0, name.length() - 1 ); - } + @Override + public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) { + if (this.searchField.mouseClicked(xCoord, yCoord, btn)) { + if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { + this.searchField.setText(""); + this.refreshList(); + } + return true; + } - this.font.drawString( name, 10, 6 + offset, 4210752 ); - } - offset += 18; - } - } + return super.mouseClicked(xCoord, yCoord, btn); + } - @Override - public boolean mouseClicked( final double xCoord, final double yCoord, final int btn ) - { - if (this.searchField.mouseClicked( xCoord, yCoord, btn )) { - if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { - this.searchField.setText(""); - this.refreshList(); - } - return true; - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/interfaceterminal.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); - return super.mouseClicked( xCoord, yCoord, btn ); - } + int offset = 17; + final int ex = this.getScrollBar().getCurrentScroll(); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/interfaceterminal.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); + for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) { + final Object lineObj = this.lines.get(ex + x); + if (lineObj instanceof ClientDCInternalInv) { + final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; - int offset = 17; - final int ex = this.getScrollBar().getCurrentScroll(); + RenderSystem.color4f(1, 1, 1, 1); + final int width = inv.getInventory().getSlots() * 18; + GuiUtils.drawTexturedModalRect(offsetX + 7, offsetY + offset, 7, 139, width, 18, getBlitOffset()); + } + offset += 18; + } - for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ ) - { - final Object lineObj = this.lines.get( ex + x ); - if( lineObj instanceof ClientDCInternalInv ) - { - final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; + if (this.searchField != null) { + this.searchField.render(mouseX, mouseY, partialTicks); + } + } - RenderSystem.color4f( 1, 1, 1, 1 ); - final int width = inv.getInventory().getSlots() * 18; - GuiUtils.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 139, width, 18, getBlitOffset() ); - } - offset += 18; - } + @Override + public boolean charTyped(char character, int key) { + if (character == ' ' && this.searchField.getText().isEmpty()) { + return true; + } + if (this.searchField.charTyped(character, key)) { + this.refreshList(); + return true; + } + return false; + } - if( this.searchField != null ) - { - this.searchField.render(mouseX, mouseY, partialTicks); - } - } + public void postUpdate(final CompoundNBT in) { + if (in.getBoolean("clear")) { + this.byId.clear(); + this.refreshList = true; + } - @Override - public boolean charTyped(char character, int key) { - if( character == ' ' && this.searchField.getText().isEmpty() ) - { - return true; - } - if( this.searchField.charTyped( character, key ) ) - { - this.refreshList(); - return true; - } - return false; - } + for (final Object oKey : in.keySet()) { + final String key = (String) oKey; + if (key.startsWith("=")) { + try { + final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX); + final CompoundNBT invData = in.getCompound(key); + final ClientDCInternalInv current = this.getById(id, invData.getLong("sortBy"), + invData.getString("un")); - public void postUpdate( final CompoundNBT in ) - { - if( in.getBoolean( "clear" ) ) - { - this.byId.clear(); - this.refreshList = true; - } + for (int x = 0; x < current.getInventory().getSlots(); x++) { + final String which = Integer.toString(x); + if (invData.contains(which)) { + current.getInventory().setStackInSlot(x, ItemStack.read(invData.getCompound(which))); + } + } + } catch (final NumberFormatException ignored) { + } + } + } - for( final Object oKey : in.keySet() ) - { - final String key = (String) oKey; - if( key.startsWith( "=" ) ) - { - try - { - final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX ); - final CompoundNBT invData = in.getCompound( key ); - final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) ); + if (this.refreshList) { + this.refreshList = false; + // invalid caches on refresh + this.cachedSearches.clear(); + this.refreshList(); + } + } - for( int x = 0; x < current.getInventory().getSlots(); x++ ) - { - final String which = Integer.toString( x ); - if( invData.contains(which) ) - { - current.getInventory().setStackInSlot( x, ItemStack.read( invData.getCompound( which ) ) ); - } - } - } - catch( final NumberFormatException ignored ) - { - } - } - } + /** + * Rebuilds the list of interfaces. + * + * Respects a search term if present (ignores case) and adding only matching + * patterns. + */ + private void refreshList() { + this.byName.clear(); - if( this.refreshList ) - { - this.refreshList = false; - // invalid caches on refresh - this.cachedSearches.clear(); - this.refreshList(); - } - } + final String searchFilterLowerCase = this.searchField.getText().toLowerCase(); - /** - * Rebuilds the list of interfaces. - * - * Respects a search term if present (ignores case) and adding only matching patterns. - */ - private void refreshList() - { - this.byName.clear(); + final Set cachedSearch = this.getCacheForSearchTerm(searchFilterLowerCase); + final boolean rebuild = cachedSearch.isEmpty(); - final String searchFilterLowerCase = this.searchField.getText().toLowerCase(); + for (final ClientDCInternalInv entry : this.byId.values()) { + // ignore inventory if not doing a full rebuild or cache already marks it as + // miss. + if (!rebuild && !cachedSearch.contains(entry)) { + continue; + } - final Set cachedSearch = this.getCacheForSearchTerm( searchFilterLowerCase ); - final boolean rebuild = cachedSearch.isEmpty(); + // Shortcut to skip any filter if search term is ""/empty + boolean found = searchFilterLowerCase.isEmpty(); - for( final ClientDCInternalInv entry : this.byId.values() ) - { - // ignore inventory if not doing a full rebuild or cache already marks it as miss. - if( !rebuild && !cachedSearch.contains( entry ) ) - { - continue; - } + // Search if the current inventory holds a pattern containing the search term. + if (!found && !searchFilterLowerCase.isEmpty()) { + for (final ItemStack itemStack : entry.getInventory()) { + found = this.itemStackMatchesSearchTerm(itemStack, searchFilterLowerCase); + if (found) { + break; + } + } + } - // Shortcut to skip any filter if search term is ""/empty - boolean found = searchFilterLowerCase.isEmpty(); + // if found, filter skipped or machine name matching the search term, add it + if (found || entry.getName().toLowerCase().contains(searchFilterLowerCase)) { + this.byName.put(entry.getName(), entry); + cachedSearch.add(entry); + } else { + cachedSearch.remove(entry); + } + } - // Search if the current inventory holds a pattern containing the search term. - if( !found && !searchFilterLowerCase.isEmpty() ) - { - for( final ItemStack itemStack : entry.getInventory() ) - { - found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase ); - if( found ) - { - break; - } - } - } + this.names.clear(); + this.names.addAll(this.byName.keySet()); - // if found, filter skipped or machine name matching the search term, add it - if( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) ) - { - this.byName.put( entry.getName(), entry ); - cachedSearch.add( entry ); - } - else - { - cachedSearch.remove( entry ); - } - } + Collections.sort(this.names); - this.names.clear(); - this.names.addAll( this.byName.keySet() ); + this.lines.clear(); + this.lines.ensureCapacity(this.getMaxRows()); - Collections.sort( this.names ); + for (final String n : this.names) { + this.lines.add(n); - this.lines.clear(); - this.lines.ensureCapacity( this.getMaxRows() ); + final ArrayList clientInventories = new ArrayList<>(); + clientInventories.addAll(this.byName.get(n)); - for( final String n : this.names ) - { - this.lines.add( n ); + Collections.sort(clientInventories); + this.lines.addAll(clientInventories); + } - final ArrayList clientInventories = new ArrayList<>(); - clientInventories.addAll( this.byName.get( n ) ); + this.getScrollBar().setRange(0, this.lines.size() - LINES_ON_PAGE, 2); + } - Collections.sort( clientInventories ); - this.lines.addAll( clientInventories ); - } + private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm) { + if (itemStack.isEmpty()) { + return false; + } - this.getScrollBar().setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 ); - } + final CompoundNBT encodedValue = itemStack.getTag(); - private boolean itemStackMatchesSearchTerm( final ItemStack itemStack, final String searchTerm ) - { - if( itemStack.isEmpty() ) - { - return false; - } + if (encodedValue == null) { + return false; + } - final CompoundNBT encodedValue = itemStack.getTag(); + // Potential later use to filter by input + // ListNBT inTag = encodedValue.getTagList( "in", 10 ); + final ListNBT outTag = encodedValue.getList("out", 10); - if( encodedValue == null ) - { - return false; - } + for (int i = 0; i < outTag.size(); i++) { - // Potential later use to filter by input - // ListNBT inTag = encodedValue.getTagList( "in", 10 ); - final ListNBT outTag = encodedValue.getList( "out", 10 ); + final ItemStack parsedItemStack = ItemStack.read(outTag.getCompound(i)); + if (!parsedItemStack.isEmpty()) { + final String displayName = Platform.getItemDisplayName(AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString() + .toLowerCase(); + if (displayName.contains(searchTerm)) { + return true; + } + } + } + return false; + } - for( int i = 0; i < outTag.size(); i++ ) - { + /** + * Tries to retrieve a cache for a with search term as keyword. + * + * If this cache should be empty, it will populate it with an earlier cache if + * available or at least the cache for the empty string. + * + * @param searchTerm the corresponding search + * + * @return a Set matching a superset of the search term + */ + private Set getCacheForSearchTerm(final String searchTerm) { + if (!this.cachedSearches.containsKey(searchTerm)) { + this.cachedSearches.put(searchTerm, new HashSet<>()); + } - final ItemStack parsedItemStack = ItemStack.read( outTag.getCompound( i ) ); - if( !parsedItemStack.isEmpty() ) - { - final String displayName = Platform - .getItemDisplayName( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( parsedItemStack ) ) - .getString() - .toLowerCase(); - if( displayName.contains( searchTerm ) ) - { - return true; - } - } - } - return false; - } + final Set cache = this.cachedSearches.get(searchTerm); - /** - * Tries to retrieve a cache for a with search term as keyword. - * - * If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for - * the empty string. - * - * @param searchTerm the corresponding search - * - * @return a Set matching a superset of the search term - */ - private Set getCacheForSearchTerm( final String searchTerm ) - { - if( !this.cachedSearches.containsKey( searchTerm ) ) - { - this.cachedSearches.put( searchTerm, new HashSet<>() ); - } + if (cache.isEmpty() && searchTerm.length() > 1) { + cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1))); + return cache; + } - final Set cache = this.cachedSearches.get( searchTerm ); + return cache; + } - if( cache.isEmpty() && searchTerm.length() > 1 ) - { - cache.addAll( this.getCacheForSearchTerm( searchTerm.substring( 0, searchTerm.length() - 1 ) ) ); - return cache; - } + /** + * The max amount of unique names and each inv row. Not affected by the + * filtering. + * + * @return max amount of unique names and each inv row + */ + private int getMaxRows() { + return this.names.size() + this.byId.size(); + } - return cache; - } + private ClientDCInternalInv getById(final long id, final long sortBy, final String string) { + ClientDCInternalInv o = this.byId.get(id); - /** - * The max amount of unique names and each inv row. Not affected by the filtering. - * - * @return max amount of unique names and each inv row - */ - private int getMaxRows() - { - return this.names.size() + this.byId.size(); - } + if (o == null) { + this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, string)); + this.refreshList = true; + } - private ClientDCInternalInv getById( final long id, final long sortBy, final String string ) - { - ClientDCInternalInv o = this.byId.get( id ); - - if( o == null ) - { - this.byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) ); - this.refreshList = true; - } - - return o; - } + return o; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java b/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java index 4995bf1aa..0dbd3cfe0 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java +++ b/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java @@ -18,13 +18,10 @@ package appeng.client.gui.implementations; - -import appeng.client.gui.widgets.GuiServerSettingToggleButton; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.util.InputMappings; -import net.minecraft.util.text.ITextComponent; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.FuzzyMode; import appeng.api.config.LevelType; @@ -32,213 +29,201 @@ import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.config.YesNo; -import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.client.gui.widgets.GuiNumberBox; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; +import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.container.implementations.ContainerLevelEmitter; import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; +public class GuiLevelEmitter extends GuiUpgradeable { -public class GuiLevelEmitter extends GuiUpgradeable -{ + private GuiNumberBox level; - private GuiNumberBox level; + private Button plus1; + private Button plus10; + private Button plus100; + private Button plus1000; + private Button minus1; + private Button minus10; + private Button minus100; + private Button minus1000; - private Button plus1; - private Button plus10; - private Button plus100; - private Button plus1000; - private Button minus1; - private Button minus10; - private Button minus100; - private Button minus1000; + private GuiSettingToggleButton levelMode; + private GuiSettingToggleButton craftingMode; - private GuiSettingToggleButton levelMode; - private GuiSettingToggleButton craftingMode; + public GuiLevelEmitter(ContainerLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } - public GuiLevelEmitter(ContainerLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.level = new GuiNumberBox(this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, + Long.class); + this.level.setEnableBackgroundDrawing(false); + this.level.setMaxStringLength(16); + this.level.setTextColor(0xFFFFFF); + this.level.setVisible(true); + this.level.setFocused2(true); + container.setTextField(this.level); + } - this.level = new GuiNumberBox( this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, Long.class ); - this.level.setEnableBackgroundDrawing( false ); - this.level.setMaxStringLength( 16 ); - this.level.setTextColor( 0xFFFFFF ); - this.level.setVisible( true ); - this.level.setFocused2( true ); - container.setTextField( this.level ); - } + @Override + protected void addButtons() { + this.levelMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, + LevelType.ITEM_LEVEL); + this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, + Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL); + this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, + FuzzyMode.IGNORE_ALL); + this.craftingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, + Settings.CRAFT_VIA_REDSTONE, YesNo.NO); - @Override - protected void addButtons() - { - this.levelMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL ); - this.redstoneMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL ); - this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.craftingMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO ); + final int a = AEConfig.instance().levelByStackAmounts(0); + final int b = AEConfig.instance().levelByStackAmounts(1); + final int c = AEConfig.instance().levelByStackAmounts(2); + final int d = AEConfig.instance().levelByStackAmounts(3); - final int a = AEConfig.instance().levelByStackAmounts( 0 ); - final int b = AEConfig.instance().levelByStackAmounts( 1 ); - final int c = AEConfig.instance().levelByStackAmounts( 2 ); - final int d = AEConfig.instance().levelByStackAmounts( 3 ); + this.addButton(this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a))); + this.addButton( + this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b))); + this.addButton( + this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c))); + this.addButton( + this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d))); - this.addButton( this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) ); - this.addButton( this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) ); - this.addButton( this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) ); - this.addButton( this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) ); + this.addButton( + this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a))); + this.addButton( + this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b))); + this.addButton( + this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c))); + this.addButton( + this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d))); - this.addButton( this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) ); - this.addButton( this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) ); - this.addButton( this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) ); - this.addButton( this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) ); + this.addButton(this.levelMode); + this.addButton(this.redstoneMode); + this.addButton(this.craftingMode); + } - this.addButton( this.levelMode ); - this.addButton( this.redstoneMode ); - this.addButton( this.craftingMode ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + final boolean notCraftingMode = this.bc.getInstalledUpgrades(Upgrades.CRAFTING) == 0; - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - final boolean notCraftingMode = this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0; + // configure enabled status... + this.level.setEnabled(notCraftingMode); + this.plus1.active = notCraftingMode; + this.plus10.active = notCraftingMode; + this.plus100.active = notCraftingMode; + this.plus1000.active = notCraftingMode; + this.minus1.active = notCraftingMode; + this.minus10.active = notCraftingMode; + this.minus100.active = notCraftingMode; + this.minus1000.active = notCraftingMode; + this.levelMode.active = notCraftingMode; + this.redstoneMode.active = notCraftingMode; - // configure enabled status... - this.level.setEnabled( notCraftingMode ); - this.plus1.active = notCraftingMode; - this.plus10.active = notCraftingMode; - this.plus100.active = notCraftingMode; - this.plus1000.active = notCraftingMode; - this.minus1.active = notCraftingMode; - this.minus10.active = notCraftingMode; - this.minus100.active = notCraftingMode; - this.minus1000.active = notCraftingMode; - this.levelMode.active = notCraftingMode; - this.redstoneMode.active = notCraftingMode; + super.drawFG(offsetX, offsetY, mouseX, mouseY); - super.drawFG( offsetX, offsetY, mouseX, mouseY ); + if (this.craftingMode != null) { + this.craftingMode.set(this.cvb.getCraftingMode()); + } - if( this.craftingMode != null ) - { - this.craftingMode.set( this.cvb.getCraftingMode() ); - } + if (this.levelMode != null) { + this.levelMode.set(((ContainerLevelEmitter) this.cvb).getLevelMode()); + } + } - if( this.levelMode != null ) - { - this.levelMode.set( ( (ContainerLevelEmitter) this.cvb ).getLevelMode() ); - } - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks); + this.level.render(mouseX, mouseY, partialTicks); + } - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks); - this.level.render(mouseX, mouseY, partialTicks); - } + @Override + protected void handleButtonVisibility() { + this.craftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0); + this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0); + } - @Override - protected void handleButtonVisibility() - { - this.craftingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ); - this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ); - } + @Override + protected String getBackground() { + return "guis/lvlemitter.png"; + } - @Override - protected String getBackground() - { - return "guis/lvlemitter.png"; - } + @Override + protected GuiText getName() { + return GuiText.LevelEmitter; + } - @Override - protected GuiText getName() - { - return GuiText.LevelEmitter; - } + private void addQty(final long i) { + try { + String Out = this.level.getText(); - private void addQty( final long i ) - { - try - { - String Out = this.level.getText(); + boolean Fixed = false; + while (Out.startsWith("0") && Out.length() > 1) { + Out = Out.substring(1); + Fixed = true; + } - boolean Fixed = false; - while( Out.startsWith( "0" ) && Out.length() > 1 ) - { - Out = Out.substring( 1 ); - Fixed = true; - } + if (Fixed) { + this.level.setText(Out); + } - if( Fixed ) - { - this.level.setText( Out ); - } + if (Out.isEmpty()) { + Out = "0"; + } - if( Out.isEmpty() ) - { - Out = "0"; - } + long result = Long.parseLong(Out); + result += i; + if (result < 0) { + result = 0; + } - long result = Long.parseLong( Out ); - result += i; - if( result < 0 ) - { - result = 0; - } + this.level.setText(Out = Long.toString(result)); - this.level.setText( Out = Long.toString( result ) ); + NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out)); + } catch (final NumberFormatException e) { + // nope.. + this.level.setText("0"); + } + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) ); - } - catch( final NumberFormatException e ) - { - // nope.. - this.level.setText( "0" ); - } - } + @Override + public boolean charTyped(char character, int key) { + // Forward entered characters to the number-text-field + return level.charTyped(character, key); + } - @Override - public boolean charTyped(char character, int key) { - // Forward entered characters to the number-text-field - return level.charTyped(character, key); - } + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) { + if (keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) { + String Out = this.level.getText(); - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) ) - { - if( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) - { - String Out = this.level.getText(); + boolean Fixed = false; + while (Out.startsWith("0") && Out.length() > 1) { + Out = Out.substring(1); + Fixed = true; + } - boolean Fixed = false; - while( Out.startsWith( "0" ) && Out.length() > 1 ) - { - Out = Out.substring( 1 ); - Fixed = true; - } + if (Fixed) { + this.level.setText(Out); + } - if( Fixed ) - { - this.level.setText( Out ); - } + if (Out.isEmpty()) { + Out = "0"; + } - if( Out.isEmpty() ) - { - Out = "0"; - } + NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out)); + return true; + } + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) ); - return true; - } - } - - return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ ); - } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiMAC.java b/src/main/java/appeng/client/gui/implementations/GuiMAC.java index 053d06409..d22a6b1c1 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiMAC.java +++ b/src/main/java/appeng/client/gui/implementations/GuiMAC.java @@ -18,69 +18,61 @@ package appeng.client.gui.implementations; - -import appeng.client.gui.widgets.GuiServerSettingToggleButton; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; import appeng.client.gui.widgets.GuiProgressBar; import appeng.client.gui.widgets.GuiProgressBar.Direction; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; import appeng.container.implementations.ContainerMAC; import appeng.core.localization.GuiText; -import net.minecraft.util.text.ITextComponent; +public class GuiMAC extends GuiUpgradeable { -public class GuiMAC extends GuiUpgradeable -{ + private GuiProgressBar pb; - private GuiProgressBar pb; + public GuiMAC(ContainerMAC container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 197; + } - public GuiMAC(ContainerMAC container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 197; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.pb = new GuiProgressBar(this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL); + this.addButton(this.pb); + } - this.pb = new GuiProgressBar( this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL ); - this.addButton( this.pb ); - } + @Override + protected void addButtons() { + this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, + Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + addButton(this.redstoneMode); + } - @Override - protected void addButtons() - { - this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - addButton(this.redstoneMode); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.pb.setFullMsg(this.container.getCurrentProgress() + "%"); + super.drawFG(offsetX, offsetY, mouseX, mouseY); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.pb.setFullMsg( this.container.getCurrentProgress() + "%" ); - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.pb.x = 148 + this.guiLeft; + this.pb.y = 48 + this.guiTop; + super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks); + } - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.pb.x = 148 + this.guiLeft; - this.pb.y = 48 + this.guiTop; - super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks); - } + @Override + protected String getBackground() { + return "guis/mac.png"; + } - @Override - protected String getBackground() - { - return "guis/mac.png"; - } - - @Override - protected GuiText getName() - { - return GuiText.MolecularAssembler; - } + @Override + protected GuiText getName() { + return GuiText.MolecularAssembler; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java index 96d6e3753..edb30a112 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java @@ -18,21 +18,18 @@ package appeng.client.gui.implementations; - import java.util.List; -import appeng.api.config.*; -import appeng.container.implementations.ContainerCraftingStatus; -import appeng.integration.abstraction.JEIFacade; -import appeng.util.Platform; +import org.lwjgl.glfw.GLFW; + import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; - +import appeng.api.config.*; import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.tiles.IMEChest; import appeng.api.implementations.tiles.IViewCellStorage; @@ -41,13 +38,14 @@ import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.client.ActionKey; import appeng.client.gui.AEBaseMEGui; -import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.client.gui.widgets.GuiScrollbar; +import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.client.gui.widgets.GuiTabButton; import appeng.client.gui.widgets.ISortSource; import appeng.client.gui.widgets.MEGuiTextField; import appeng.client.me.InternalSlotME; import appeng.client.me.ItemRepo; +import appeng.container.implementations.ContainerCraftingStatus; import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.slot.AppEngSlot; import appeng.container.slot.SlotCraftingMatrix; @@ -55,515 +53,460 @@ import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.core.AEConfig; import appeng.core.AppEng; import appeng.core.localization.GuiText; - import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketSwitchGuis; import appeng.core.sync.packets.PacketValueConfig; import appeng.helpers.WirelessTerminalGuiObject; +import appeng.integration.abstraction.JEIFacade; import appeng.parts.reporting.AbstractPartTerminal; import appeng.tile.misc.TileSecurityStation; import appeng.util.IConfigManagerHost; -import org.lwjgl.glfw.GLFW; - - -public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost -{ - - private static int craftingGridOffsetX; - private static int craftingGridOffsetY; - - private static String memoryText = ""; - private final ItemRepo repo; - private final int offsetX = 9; - private final int lowerTextureOffset = 0; - private final IConfigManager configSrc; - private final boolean viewCell; - private final ItemStack[] myCurrentViewCells = new ItemStack[5]; - private GuiTabButton craftingStatusBtn; - private MEGuiTextField searchField; - private GuiText myName; - private int perRow = 9; - private int reservedSpace = 0; - private boolean customSortOrder = true; - private int rows = 0; - private int maxRows = Integer.MAX_VALUE; - private int standardSize; - private GuiSettingToggleButton viewModeToggle; - private GuiSettingToggleButton sortByToggle; - private GuiSettingToggleButton sortDirToggle; - private boolean isAutoFocus = false; - private int currentMouseX = 0; - private int currentMouseY = 0; - - public GuiMEMonitorable(T container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - - final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - this.repo = new ItemRepo( scrollbar, this ); - setScrollBar(); - - this.xSize = 185; - this.ySize = 204; - - Object te = container.getTarget(); - if( te instanceof IViewCellStorage ) - { - this.xSize += 33; - } - - this.standardSize = this.xSize; - - this.configSrc = ( (IConfigurableObject) this.container ).getConfigManager(); - this.container.setGui( this ); - - this.viewCell = te instanceof IViewCellStorage; - - if( te instanceof TileSecurityStation ) - { - this.myName = GuiText.Security; - } - else if( te instanceof WirelessTerminalGuiObject ) - { - this.myName = GuiText.WirelessTerminal; - } - else if( te instanceof IPortableCell ) - { - this.myName = GuiText.PortableCell; - } - else if( te instanceof IMEChest ) - { - this.myName = GuiText.Chest; - } - else if( te instanceof AbstractPartTerminal ) - { - this.myName = GuiText.Terminal; - } - else - { - throw new IllegalArgumentException("Invalid GUI target given: " + te); - } - } - - public void postUpdate( final List list ) - { - for( final IAEItemStack is : list ) - { - this.repo.postUpdate( is ); - } - - this.repo.updateView(); - this.setScrollBar(); - } - - private void setScrollBar() - { - this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 ); - this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) ); - } - - private void showCraftingStatus() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis(ContainerCraftingStatus.TYPE) ); - } - - @Override - public void init() - { - getMinecraft().keyboardListener.enableRepeatEvents( true ); - - this.maxRows = this.getMaxRows(); - TerminalStyle terminalStyle = (TerminalStyle) AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE); - - if( terminalStyle != TerminalStyle.FULL ) - { - this.perRow = 9; - } - else - { - this.perRow = 9 + ( ( this.width - this.standardSize ) / 18 ); - } - this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 ); - - final int magicNumber = 114 + 1; - final int extraSpace = this.height - magicNumber - this.reservedSpace; - - this.rows = extraSpace / 18; - if( this.rows > this.maxRows ) - { - this.rows = this.maxRows; - } - - if( this.rows < 3 ) - { - this.rows = 3; - } - - // Size the container according to the number of rows we decided to have - this.ySize = magicNumber + this.rows * 18 + this.reservedSpace; - - this.getMeSlots().clear(); - for( int y = 0; y < this.rows; y++ ) - { - for( int x = 0; x < this.perRow; x++ ) - { - this.getMeSlots().add( new InternalSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) ); - } - } - - - super.init(); - // full size : 204 - // extra slots : 72 - // slot 18 - - int offset = this.guiTop + 8; - - if( this.customSortOrder ) - { - this.sortByToggle = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_BY, getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting ) ); - offset += 20; - } - - if( this.viewCell || this instanceof GuiWirelessTerm ) - { - this.viewModeToggle = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.VIEW_MODE, getSortDisplay(), this::toggleServerSetting ) ); - offset += 20; - } - - this.addButton( this.sortDirToggle = new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting ) ); - offset += 20; - - SearchBoxMode searchMode = (SearchBoxMode) AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE); - this.addButton(new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SEARCH_MODE, searchMode, Platform::isSearchModeAvailable, this::toggleClientSetting)); - - offset += 20; - - if( !( this instanceof GuiMEPortableCell ) || this instanceof GuiWirelessTerm ) - { - this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, terminalStyle, this::toggleClientSetting) ); - } - - this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 ); - this.searchField.setEnableBackgroundDrawing( false ); - this.searchField.setMaxStringLength( 25 ); - this.searchField.setTextColor( 0xFFFFFF ); - this.searchField.setSelectionColor( 0xFF008000 ); - this.searchField.setVisible( true ); - - if( this.viewCell || this instanceof GuiWirelessTerm ) - { - this.craftingStatusBtn = this.addButton( new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus - .getLocal(), this.itemRenderer, btn -> showCraftingStatus() ) ); - this.craftingStatusBtn.setHideEdge( 13 ); - } - - this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.JEI_AUTOSEARCH == searchMode || SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode; - final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode || SearchBoxMode.MANUAL_SEARCH_KEEP == searchMode || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchMode; - final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchMode || SearchBoxMode.JEI_MANUAL_SEARCH == searchMode; - - this.searchField.setFocused2( this.isAutoFocus ); - - if( isJEIEnabled ) - { - memoryText = JEIFacade.instance().getSearchText(); - } - - if( isKeepFilter && memoryText != null && !memoryText.isEmpty() ) - { - this.searchField.setText( memoryText ); - this.searchField.selectAll(); - this.repo.setSearchString( memoryText ); - this.repo.updateView(); - this.setScrollBar(); - } - - craftingGridOffsetX = Integer.MAX_VALUE; - craftingGridOffsetY = Integer.MAX_VALUE; - - for( final Slot s : this.container.inventorySlots ) - { - if( s instanceof AppEngSlot ) - { - if( s.xPos < 197 ) - { - this.repositionSlot( (AppEngSlot) s ); - } - } - - if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix ) - { - if( s.xPos > 0 && s.yPos > 0 ) - { - craftingGridOffsetX = Math.min( craftingGridOffsetX, s.xPos ); - craftingGridOffsetY = Math.min( craftingGridOffsetY, s.yPos ); - } - } - } - - craftingGridOffsetX -= 25; - craftingGridOffsetY -= 6; - - } - - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( this.myName.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - - this.currentMouseX = mouseX; - this.currentMouseY = mouseY; - } - - @Override - public boolean mouseClicked( final double xCoord, final double yCoord, final int btn ) - { - if (this.searchField.mouseClicked( xCoord, yCoord, btn )) { - if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { - this.searchField.setText(""); - this.repo.setSearchString(""); - this.repo.updateView(); - this.setScrollBar(); - } - return true; - } - - return super.mouseClicked( xCoord, yCoord, btn ); - } - - @Override - public void removed() - { - super.removed(); - getMinecraft().keyboardListener.enableRepeatEvents( false ); - memoryText = this.searchField.getText(); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - - this.bindTexture( this.getBackground() ); - final int x_width = 197; - blit( offsetX, offsetY, 0, 0, x_width, 18 ); - - if( this.viewCell || ( this instanceof GuiSecurityStation ) ) - { - blit( offsetX + x_width, offsetY, x_width, 0, 46, 128 ); - } - - for( int x = 0; x < this.rows; x++ ) - { - blit( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 ); - } - - blit( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, - 99 + this.reservedSpace - this.lowerTextureOffset ); - - if( this.viewCell ) - { - boolean update = false; - - for( int i = 0; i < 5; i++ ) - { - if( this.myCurrentViewCells[i] != this.container.getCellViewSlot( i ).getStack() ) - { - update = true; - this.myCurrentViewCells[i] = this.container.getCellViewSlot( i ).getStack(); - } - } - - if( update ) - { - this.repo.setViewCell( this.myCurrentViewCells ); - } - } - - if( this.searchField != null ) - { - this.searchField.render(mouseX, mouseY, partialTicks); - } - } - - protected String getBackground() - { - return "guis/terminal.png"; - } - - @Override - protected boolean isPowered() - { - return this.repo.hasPower(); - } - - int getMaxRows() - { - return AEConfig.instance().getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE; - } - - protected void repositionSlot( final AppEngSlot s ) - { - s.yPos = s.getY() + this.ySize - 78 - 5; - } - - @Override - public boolean charTyped(char character, int p_charTyped_2_) { - if( character == ' ' && this.searchField.getText().isEmpty() ) - { - return true; - } - - if( this.isAutoFocus && !this.searchField.isFocused() && isHovered() ) - { - this.searchField.setFocused2( true ); - } - - if (this.searchField.isFocused() && this.searchField.charTyped(character, p_charTyped_2_)) { - this.repo.setSearchString( this.searchField.getText() ); - this.repo.updateView(); - this.setScrollBar(); - return true; - } - - return false; - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - - InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode); - - if( keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input) ) - { - if( AppEng.proxy.isActionKey( ActionKey.TOGGLE_FOCUS, input ) ) - { - this.searchField.setFocused2( !this.searchField.isFocused() ); - return true; - } - if (!this.searchField.isFocused() && this.isAutoFocus && isHovered()) { - this.searchField.setFocused2(true); - } - - if (this.searchField.isFocused()) { - if (keyCode == GLFW.GLFW_KEY_ENTER) { - this.searchField.setFocused2(false); - return true; - } - - if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { - this.repo.setSearchString(this.searchField.getText()); - this.repo.updateView(); - this.setScrollBar(); - } - - // We need to swallow key presses if the field is focused because typing 'e' would otherwise close - // the screen - return true; - } - } - - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } - - private boolean isHovered() { - return isPointInRegion(0, 0, this.xSize, this.ySize, currentMouseX, currentMouseY); - } - - @Override - public void tick() - { - this.repo.setPower( this.container.isPowered() ); - super.tick(); - } - - @Override - public SortOrder getSortBy() - { - return (SortOrder) this.configSrc.getSetting( Settings.SORT_BY ); - } - - @Override - public SortDir getSortDir() - { - return (SortDir) this.configSrc.getSetting( Settings.SORT_DIRECTION ); - } - - @Override - public ViewItems getSortDisplay() - { - return (ViewItems) this.configSrc.getSetting( Settings.VIEW_MODE ); - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - if( this.sortByToggle != null ) - { - this.sortByToggle.set( getSortBy() ); - } - - if( this.sortDirToggle != null ) - { - this.sortDirToggle.set( getSortDir() ); - } - - if( this.viewModeToggle != null ) - { - this.viewModeToggle.set( getSortDisplay() ); - } - - this.repo.updateView(); - } - - int getReservedSpace() - { - return this.reservedSpace; - } - - void setReservedSpace( final int reservedSpace ) - { - this.reservedSpace = reservedSpace; - } - - public boolean isCustomSortOrder() - { - return this.customSortOrder; - } - - void setCustomSortOrder( final boolean customSortOrder ) - { - this.customSortOrder = customSortOrder; - } - - public int getStandardSize() - { - return this.standardSize; - } - - void setStandardSize( final int standardSize ) - { - this.standardSize = standardSize; - } - - private > void toggleClientSetting(GuiSettingToggleButton btn, boolean backwards) { - S next = btn.getNextValue(backwards); - AEConfig.instance().getConfigManager().putSetting( btn.getSetting(), next ); - btn.set( next ); - this.reinitalize(); - } - - private > void toggleServerSetting(GuiSettingToggleButton btn, boolean backwards) { - S next = btn.getNextValue(backwards); - NetworkHandler.instance().sendToServer( new PacketValueConfig( btn.getSetting().name(), next.name() ) ); - btn.set( next ); - } - - private void reinitalize() - { - this.children.removeAll(this.buttons); - this.buttons.clear(); - this.init(); - } +import appeng.util.Platform; + +public class GuiMEMonitorable extends AEBaseMEGui + implements ISortSource, IConfigManagerHost { + + private static int craftingGridOffsetX; + private static int craftingGridOffsetY; + + private static String memoryText = ""; + private final ItemRepo repo; + private final int offsetX = 9; + private final int lowerTextureOffset = 0; + private final IConfigManager configSrc; + private final boolean viewCell; + private final ItemStack[] myCurrentViewCells = new ItemStack[5]; + private GuiTabButton craftingStatusBtn; + private MEGuiTextField searchField; + private GuiText myName; + private int perRow = 9; + private int reservedSpace = 0; + private boolean customSortOrder = true; + private int rows = 0; + private int maxRows = Integer.MAX_VALUE; + private int standardSize; + private GuiSettingToggleButton viewModeToggle; + private GuiSettingToggleButton sortByToggle; + private GuiSettingToggleButton sortDirToggle; + private boolean isAutoFocus = false; + private int currentMouseX = 0; + private int currentMouseY = 0; + + public GuiMEMonitorable(T container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + + final GuiScrollbar scrollbar = new GuiScrollbar(); + this.setScrollBar(scrollbar); + this.repo = new ItemRepo(scrollbar, this); + setScrollBar(); + + this.xSize = 185; + this.ySize = 204; + + Object te = container.getTarget(); + if (te instanceof IViewCellStorage) { + this.xSize += 33; + } + + this.standardSize = this.xSize; + + this.configSrc = ((IConfigurableObject) this.container).getConfigManager(); + this.container.setGui(this); + + this.viewCell = te instanceof IViewCellStorage; + + if (te instanceof TileSecurityStation) { + this.myName = GuiText.Security; + } else if (te instanceof WirelessTerminalGuiObject) { + this.myName = GuiText.WirelessTerminal; + } else if (te instanceof IPortableCell) { + this.myName = GuiText.PortableCell; + } else if (te instanceof IMEChest) { + this.myName = GuiText.Chest; + } else if (te instanceof AbstractPartTerminal) { + this.myName = GuiText.Terminal; + } else { + throw new IllegalArgumentException("Invalid GUI target given: " + te); + } + } + + public void postUpdate(final List list) { + for (final IAEItemStack is : list) { + this.repo.postUpdate(is); + } + + this.repo.updateView(); + this.setScrollBar(); + } + + private void setScrollBar() { + this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2); + this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, + Math.max(1, this.rows / 6)); + } + + private void showCraftingStatus() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerCraftingStatus.TYPE)); + } + + @Override + public void init() { + getMinecraft().keyboardListener.enableRepeatEvents(true); + + this.maxRows = this.getMaxRows(); + TerminalStyle terminalStyle = (TerminalStyle) AEConfig.instance().getConfigManager() + .getSetting(Settings.TERMINAL_STYLE); + + if (terminalStyle != TerminalStyle.FULL) { + this.perRow = 9; + } else { + this.perRow = 9 + ((this.width - this.standardSize) / 18); + } + this.xSize = this.standardSize + ((this.perRow - 9) * 18); + + final int magicNumber = 114 + 1; + final int extraSpace = this.height - magicNumber - this.reservedSpace; + + this.rows = extraSpace / 18; + if (this.rows > this.maxRows) { + this.rows = this.maxRows; + } + + if (this.rows < 3) { + this.rows = 3; + } + + // Size the container according to the number of rows we decided to have + this.ySize = magicNumber + this.rows * 18 + this.reservedSpace; + + this.getMeSlots().clear(); + for (int y = 0; y < this.rows; y++) { + for (int x = 0; x < this.perRow; x++) { + this.getMeSlots() + .add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); + } + } + + super.init(); + // full size : 204 + // extra slots : 72 + // slot 18 + + int offset = this.guiTop + 8; + + if (this.customSortOrder) { + this.sortByToggle = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, Settings.SORT_BY, + getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting)); + offset += 20; + } + + if (this.viewCell || this instanceof GuiWirelessTerm) { + this.viewModeToggle = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, + Settings.VIEW_MODE, getSortDisplay(), this::toggleServerSetting)); + offset += 20; + } + + this.addButton(this.sortDirToggle = new GuiSettingToggleButton<>(this.guiLeft - 18, offset, + Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting)); + offset += 20; + + SearchBoxMode searchMode = (SearchBoxMode) AEConfig.instance().getConfigManager() + .getSetting(Settings.SEARCH_MODE); + this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, Settings.SEARCH_MODE, searchMode, + Platform::isSearchModeAvailable, this::toggleClientSetting)); + + offset += 20; + + if (!(this instanceof GuiMEPortableCell) || this instanceof GuiWirelessTerm) { + this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, + terminalStyle, this::toggleClientSetting)); + } + + this.searchField = new MEGuiTextField(this.font, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, + 12); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setMaxStringLength(25); + this.searchField.setTextColor(0xFFFFFF); + this.searchField.setSelectionColor(0xFF008000); + this.searchField.setVisible(true); + + if (this.viewCell || this instanceof GuiWirelessTerm) { + this.craftingStatusBtn = this.addButton(new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, + GuiText.CraftingStatus.getLocal(), this.itemRenderer, btn -> showCraftingStatus())); + this.craftingStatusBtn.setHideEdge(13); + } + + this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.JEI_AUTOSEARCH == searchMode + || SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode; + final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchMode + || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode || SearchBoxMode.MANUAL_SEARCH_KEEP == searchMode + || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchMode; + final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchMode + || SearchBoxMode.JEI_MANUAL_SEARCH == searchMode; + + this.searchField.setFocused2(this.isAutoFocus); + + if (isJEIEnabled) { + memoryText = JEIFacade.instance().getSearchText(); + } + + if (isKeepFilter && memoryText != null && !memoryText.isEmpty()) { + this.searchField.setText(memoryText); + this.searchField.selectAll(); + this.repo.setSearchString(memoryText); + this.repo.updateView(); + this.setScrollBar(); + } + + craftingGridOffsetX = Integer.MAX_VALUE; + craftingGridOffsetY = Integer.MAX_VALUE; + + for (final Slot s : this.container.inventorySlots) { + if (s instanceof AppEngSlot) { + if (s.xPos < 197) { + this.repositionSlot((AppEngSlot) s); + } + } + + if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) { + if (s.xPos > 0 && s.yPos > 0) { + craftingGridOffsetX = Math.min(craftingGridOffsetX, s.xPos); + craftingGridOffsetY = Math.min(craftingGridOffsetY, s.yPos); + } + } + } + + craftingGridOffsetX -= 25; + craftingGridOffsetY -= 6; + + } + + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(this.myName.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + + this.currentMouseX = mouseX; + this.currentMouseY = mouseY; + } + + @Override + public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) { + if (this.searchField.mouseClicked(xCoord, yCoord, btn)) { + if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { + this.searchField.setText(""); + this.repo.setSearchString(""); + this.repo.updateView(); + this.setScrollBar(); + } + return true; + } + + return super.mouseClicked(xCoord, yCoord, btn); + } + + @Override + public void removed() { + super.removed(); + getMinecraft().keyboardListener.enableRepeatEvents(false); + memoryText = this.searchField.getText(); + } + + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + + this.bindTexture(this.getBackground()); + final int x_width = 197; + blit(offsetX, offsetY, 0, 0, x_width, 18); + + if (this.viewCell || (this instanceof GuiSecurityStation)) { + blit(offsetX + x_width, offsetY, x_width, 0, 46, 128); + } + + for (int x = 0; x < this.rows; x++) { + blit(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18); + } + + blit(offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, + 99 + this.reservedSpace - this.lowerTextureOffset); + + if (this.viewCell) { + boolean update = false; + + for (int i = 0; i < 5; i++) { + if (this.myCurrentViewCells[i] != this.container.getCellViewSlot(i).getStack()) { + update = true; + this.myCurrentViewCells[i] = this.container.getCellViewSlot(i).getStack(); + } + } + + if (update) { + this.repo.setViewCell(this.myCurrentViewCells); + } + } + + if (this.searchField != null) { + this.searchField.render(mouseX, mouseY, partialTicks); + } + } + + protected String getBackground() { + return "guis/terminal.png"; + } + + @Override + protected boolean isPowered() { + return this.repo.hasPower(); + } + + int getMaxRows() { + return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 + : Integer.MAX_VALUE; + } + + protected void repositionSlot(final AppEngSlot s) { + s.yPos = s.getY() + this.ySize - 78 - 5; + } + + @Override + public boolean charTyped(char character, int p_charTyped_2_) { + if (character == ' ' && this.searchField.getText().isEmpty()) { + return true; + } + + if (this.isAutoFocus && !this.searchField.isFocused() && isHovered()) { + this.searchField.setFocused2(true); + } + + if (this.searchField.isFocused() && this.searchField.charTyped(character, p_charTyped_2_)) { + this.repo.setSearchString(this.searchField.getText()); + this.repo.updateView(); + this.setScrollBar(); + return true; + } + + return false; + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + + InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode); + + if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input)) { + if (AppEng.proxy.isActionKey(ActionKey.TOGGLE_FOCUS, input)) { + this.searchField.setFocused2(!this.searchField.isFocused()); + return true; + } + if (!this.searchField.isFocused() && this.isAutoFocus && isHovered()) { + this.searchField.setFocused2(true); + } + + if (this.searchField.isFocused()) { + if (keyCode == GLFW.GLFW_KEY_ENTER) { + this.searchField.setFocused2(false); + return true; + } + + if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + this.repo.setSearchString(this.searchField.getText()); + this.repo.updateView(); + this.setScrollBar(); + } + + // We need to swallow key presses if the field is focused because typing 'e' + // would otherwise close + // the screen + return true; + } + } + + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } + + private boolean isHovered() { + return isPointInRegion(0, 0, this.xSize, this.ySize, currentMouseX, currentMouseY); + } + + @Override + public void tick() { + this.repo.setPower(this.container.isPowered()); + super.tick(); + } + + @Override + public SortOrder getSortBy() { + return (SortOrder) this.configSrc.getSetting(Settings.SORT_BY); + } + + @Override + public SortDir getSortDir() { + return (SortDir) this.configSrc.getSetting(Settings.SORT_DIRECTION); + } + + @Override + public ViewItems getSortDisplay() { + return (ViewItems) this.configSrc.getSetting(Settings.VIEW_MODE); + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + if (this.sortByToggle != null) { + this.sortByToggle.set(getSortBy()); + } + + if (this.sortDirToggle != null) { + this.sortDirToggle.set(getSortDir()); + } + + if (this.viewModeToggle != null) { + this.viewModeToggle.set(getSortDisplay()); + } + + this.repo.updateView(); + } + + int getReservedSpace() { + return this.reservedSpace; + } + + void setReservedSpace(final int reservedSpace) { + this.reservedSpace = reservedSpace; + } + + public boolean isCustomSortOrder() { + return this.customSortOrder; + } + + void setCustomSortOrder(final boolean customSortOrder) { + this.customSortOrder = customSortOrder; + } + + public int getStandardSize() { + return this.standardSize; + } + + void setStandardSize(final int standardSize) { + this.standardSize = standardSize; + } + + private > void toggleClientSetting(GuiSettingToggleButton btn, boolean backwards) { + S next = btn.getNextValue(backwards); + AEConfig.instance().getConfigManager().putSetting(btn.getSetting(), next); + btn.set(next); + this.reinitalize(); + } + + private > void toggleServerSetting(GuiSettingToggleButton btn, boolean backwards) { + S next = btn.getNextValue(backwards); + NetworkHandler.instance().sendToServer(new PacketValueConfig(btn.getSetting().name(), next.name())); + btn.set(next); + } + + private void reinitalize() { + this.children.removeAll(this.buttons); + this.buttons.clear(); + this.init(); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiMEPortableCell.java b/src/main/java/appeng/client/gui/implementations/GuiMEPortableCell.java index 2e1260cd4..b37c89174 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiMEPortableCell.java +++ b/src/main/java/appeng/client/gui/implementations/GuiMEPortableCell.java @@ -18,24 +18,20 @@ package appeng.client.gui.implementations; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.implementations.guiobjects.IPortableCell; import appeng.container.implementations.ContainerMEPortableCell; -import net.minecraft.util.text.ITextComponent; +public class GuiMEPortableCell extends GuiMEMonitorable { -public class GuiMEPortableCell extends GuiMEMonitorable -{ + public GuiMEPortableCell(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } - public GuiMEPortableCell(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } - - @Override - int getMaxRows() - { - return 3; - } + @Override + int getMaxRows() { + return 3; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java index 5222f0967..ac1671577 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java @@ -18,6 +18,15 @@ package appeng.client.gui.implementations; +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.config.SortDir; import appeng.api.config.SortOrder; @@ -32,237 +41,207 @@ import appeng.client.me.SlotME; import appeng.container.implementations.ContainerNetworkStatus; import appeng.core.localization.GuiText; import appeng.util.Platform; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; -import java.util.List; +public class GuiNetworkStatus extends AEBaseGui implements ISortSource { + private final ItemRepo repo; + private final int rows = 4; + private int tooltip = -1; -public class GuiNetworkStatus extends AEBaseGui implements ISortSource -{ + public GuiNetworkStatus(ContainerNetworkStatus container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + final GuiScrollbar scrollbar = new GuiScrollbar(); - private final ItemRepo repo; - private final int rows = 4; - private int tooltip = -1; + this.setScrollBar(scrollbar); + this.repo = new ItemRepo(scrollbar, this); + this.ySize = 153; + this.xSize = 195; + this.repo.setRowSize(5); + } - public GuiNetworkStatus(ContainerNetworkStatus container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - final GuiScrollbar scrollbar = new GuiScrollbar(); + @Override + public void init() { + super.init(); - this.setScrollBar( scrollbar ); - this.repo = new ItemRepo( scrollbar, this ); - this.ySize = 153; - this.xSize = 195; - this.repo.setRowSize( 5 ); - } + this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8)); + } - @Override - public void init() - { - super.init(); + @Override + public void render(final int mouseX, final int mouseY, final float btn) { - this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) ); - } + final int gx = (this.width - this.xSize) / 2; + final int gy = (this.height - this.ySize) / 2; - @Override - public void render(final int mouseX, final int mouseY, final float btn ) - { + this.tooltip = -1; - final int gx = ( this.width - this.xSize ) / 2; - final int gy = ( this.height - this.ySize ) / 2; + int y = 0; + int x = 0; + for (int z = 0; z <= 4 * 5; z++) { + final int minX = gx + 14 + x * 31; + final int minY = gy + 41 + y * 18; - this.tooltip = -1; + if (minX < mouseX && minX + 28 > mouseX) { + if (minY < mouseY && minY + 20 > mouseY) { + this.tooltip = z; + break; + } + } - int y = 0; - int x = 0; - for( int z = 0; z <= 4 * 5; z++ ) - { - final int minX = gx + 14 + x * 31; - final int minY = gy + 41 + y * 18; + x++; - if( minX < mouseX && minX + 28 > mouseX ) - { - if( minY < mouseY && minY + 20 > mouseY ) - { - this.tooltip = z; - break; - } - } + if (x > 4) { + y++; + x = 0; + } + } - x++; + super.render(mouseX, mouseY, btn); + } - if( x > 4 ) - { - y++; - x = 0; - } - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, 4210752); - super.render( mouseX, mouseY, btn ); - } + this.font.drawString( + GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(container.getCurrentPower(), false), + 13, 16, 4210752); + this.font.drawString( + GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(container.getMaxPower(), false), 13, 26, + 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 ); + this.font.drawString(GuiText.PowerInputRate.getLocal() + ": " + + Platform.formatPowerLong(container.getAverageAddition(), true), 13, 143 - 10, 4210752); + this.font.drawString( + GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(container.getPowerUsage(), true), + 13, 143 - 20, 4210752); - this.font.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( container.getCurrentPower(), false ), 13, 16, 4210752 ); - this.font.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( container.getMaxPower(), false ), 13, 26, 4210752 ); + final int sectionLength = 30; - this.font.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( container.getAverageAddition(), true ), 13, 143 - 10, - 4210752 ); - this.font.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( container.getPowerUsage(), true ), 13, 143 - 20, 4210752 ); + int x = 0; + int y = 0; + final int xo = 12; + final int yo = 42; + final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5; + final int viewEnd = viewStart + 5 * 4; - final int sectionLength = 30; + String toolTip = ""; + int toolPosX = 0; + int toolPosY = 0; - int x = 0; - int y = 0; - final int xo = 12; - final int yo = 42; - final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5; - final int viewEnd = viewStart + 5 * 4; + for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) { + final IAEItemStack refStack = this.repo.getReferenceItem(z); + if (refStack != null) { + RenderSystem.pushMatrix(); + RenderSystem.scalef(0.5f, 0.5f, 0.5f); - String toolTip = ""; - int toolPosX = 0; - int toolPosY = 0; + String str = Long.toString(refStack.getStackSize()); + if (refStack.getStackSize() >= 10000) { + str = Long.toString(refStack.getStackSize() / 1000) + 'k'; + } - for( int z = viewStart; z < Math.min( viewEnd, this.repo.size() ); z++ ) - { - final IAEItemStack refStack = this.repo.getReferenceItem( z ); - if( refStack != null ) - { - RenderSystem.pushMatrix(); - RenderSystem.scalef( 0.5f, 0.5f, 0.5f ); + final int w = this.font.getStringWidth(str); + this.font.drawString(str, (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * 18 + yo + 6) * 2, 4210752); - String str = Long.toString( refStack.getStackSize() ); - if( refStack.getStackSize() >= 10000 ) - { - str = Long.toString( refStack.getStackSize() / 1000 ) + 'k'; - } + RenderSystem.popMatrix(); + final int posX = x * sectionLength + xo + sectionLength - 18; + final int posY = y * 18 + yo; - final int w = this.font.getStringWidth( str ); - this.font.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2, - 4210752 ); + if (this.tooltip == z - viewStart) { + toolTip = Platform.getItemDisplayName(refStack).getFormattedText(); - RenderSystem.popMatrix(); - final int posX = x * sectionLength + xo + sectionLength - 18; - final int posY = y * 18 + yo; + toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize())); + if (refStack.getCountRequestable() > 0) { + toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": " + + Platform.formatPowerLong(refStack.getCountRequestable(), true)); + } - if( this.tooltip == z - viewStart ) - { - toolTip = Platform.getItemDisplayName( refStack ).getFormattedText(); + toolPosX = x * sectionLength + xo + sectionLength - 8; + toolPosY = y * 18 + yo; + } - toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) ); - if( refStack.getCountRequestable() > 0 ) - { - toolTip += ( '\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ) ); - } + this.drawItem(posX, posY, refStack.asItemStackRepresentation()); - toolPosX = x * sectionLength + xo + sectionLength - 8; - toolPosY = y * 18 + yo; - } + x++; - this.drawItem( posX, posY, refStack.asItemStackRepresentation() ); + if (x > 4) { + y++; + x = 0; + } + } + } - x++; + if (this.tooltip >= 0 && toolTip.length() > 0) { + this.drawTooltip(toolPosX, toolPosY + 10, toolTip); + } + } - if( x > 4 ) - { - y++; - x = 0; - } - } - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/networkstatus.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } - if( this.tooltip >= 0 && toolTip.length() > 0 ) - { - this.drawTooltip( toolPosX, toolPosY + 10, toolTip ); - } - } + public void postUpdate(final List list) { + this.repo.clear(); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/networkstatus.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + for (final IAEItemStack is : list) { + this.repo.postUpdate(is); + } - public void postUpdate( final List list ) - { - this.repo.clear(); + this.repo.updateView(); + this.setScrollBar(); + } - for( final IAEItemStack is : list ) - { - this.repo.postUpdate( is ); - } + private void setScrollBar() { + final int size = this.repo.size(); + this.getScrollBar().setTop(39).setLeft(175).setHeight(78); + this.getScrollBar().setRange(0, (size + 4) / 5 - this.rows, 1); + } - this.repo.updateView(); - this.setScrollBar(); - } + @Override + protected void renderTooltip(final ItemStack stack, final int x, final int y) { + final Slot s = this.getSlot(x, y); - private void setScrollBar() - { - final int size = this.repo.size(); - this.getScrollBar().setTop( 39 ).setLeft( 175 ).setHeight( 78 ); - this.getScrollBar().setRange( 0, ( size + 4 ) / 5 - this.rows, 1 ); - } + if (s instanceof SlotME && !stack.isEmpty()) { + IAEItemStack myStack = null; - @Override - protected void renderTooltip( final ItemStack stack, final int x, final int y ) - { - final Slot s = this.getSlot( x, y ); + try { + final SlotME theSlotField = (SlotME) s; + myStack = theSlotField.getAEStack(); + } catch (final Throwable ignore) { + } - if( s instanceof SlotME && !stack.isEmpty() ) - { - IAEItemStack myStack = null; + if (myStack != null) { + List currentToolTip = getTooltipFromItem(stack); - try - { - final SlotME theSlotField = (SlotME) s; - myStack = theSlotField.getAEStack(); - } - catch( final Throwable ignore ) - { - } + while (currentToolTip.size() > 1) { + currentToolTip.remove(1); + } - if( myStack != null ) - { - List currentToolTip = getTooltipFromItem(stack); + currentToolTip.add(GuiText.Installed.getLocal() + ": " + (myStack.getStackSize())); + currentToolTip.add(GuiText.EnergyDrain.getLocal() + ": " + + Platform.formatPowerLong(myStack.getCountRequestable(), true)); - while( currentToolTip.size() > 1 ) - { - currentToolTip.remove( 1 ); - } + this.drawTooltip(x, y, currentToolTip); + } + } - currentToolTip.add( GuiText.Installed.getLocal() + ": " + ( myStack.getStackSize() ) ); - currentToolTip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) ); + super.renderTooltip(stack, x, y); + } - this.drawTooltip( x, y, currentToolTip ); - } - } + @Override + public SortOrder getSortBy() { + return SortOrder.NAME; + } - super.renderTooltip( stack, x, y ); - } + @Override + public SortDir getSortDir() { + return SortDir.ASCENDING; + } - @Override - public SortOrder getSortBy() - { - return SortOrder.NAME; - } - - @Override - public SortDir getSortDir() - { - return SortDir.ASCENDING; - } - - @Override - public ViewItems getSortDisplay() - { - return ViewItems.ALL; - } + @Override + public ViewItems getSortDisplay() { + return ViewItems.ALL; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java b/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java index 3e2b66d5d..4688e5487 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java +++ b/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java @@ -18,6 +18,9 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiToggleButton; @@ -25,52 +28,44 @@ import appeng.container.implementations.ContainerNetworkTool; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiNetworkTool extends AEBaseGui { -public class GuiNetworkTool extends AEBaseGui -{ + private GuiToggleButton tFacades; - private GuiToggleButton tFacades; + public GuiNetworkTool(ContainerNetworkTool container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiNetworkTool(ContainerNetworkTool container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.tFacades = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 8, 23, 22, + GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal(), + btn -> toggleFacades()); - this.tFacades = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint - .getLocal(), btn -> toggleFacades() ); + this.addButton(this.tFacades); + } - this.addButton( this.tFacades ); - } + private void toggleFacades() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("NetworkTool", "Toggle")); + } - private void toggleFacades() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (this.tFacades != null) { + this.tFacades.setState(container.isFacadeMode()); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if( this.tFacades != null ) - { - this.tFacades.setState( container.isFacadeMode() ); - } + this.font.drawString(this.getGuiDisplayName(GuiText.NetworkTool.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - this.font.drawString( this.getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/toolbox.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/toolbox.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java index f38762ccc..53e55be50 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java @@ -18,6 +18,10 @@ package appeng.client.gui.implementations; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.ActionItems; import appeng.client.gui.widgets.GuiActionButton; @@ -27,127 +31,117 @@ import appeng.container.slot.AppEngSlot; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; +public class GuiPatternTerm extends GuiMEMonitorable { -public class GuiPatternTerm extends GuiMEMonitorable -{ + private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png"; + private static final String BACKGROUND_PROCESSING_MODE = "guis/pattern2.png"; - private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png"; - private static final String BACKGROUND_PROCESSING_MODE = "guis/pattern2.png"; + private static final String SUBSITUTION_DISABLE = "0"; + private static final String SUBSITUTION_ENABLE = "1"; - private static final String SUBSITUTION_DISABLE = "0"; - private static final String SUBSITUTION_ENABLE = "1"; + private static final String CRAFTMODE_CRFTING = "1"; + private static final String CRAFTMODE_PROCESSING = "0"; - private static final String CRAFTMODE_CRFTING = "1"; - private static final String CRAFTMODE_PROCESSING = "0"; + private GuiTabButton tabCraftButton; + private GuiTabButton tabProcessButton; + private GuiActionButton substitutionsEnabledBtn; + private GuiActionButton substitutionsDisabledBtn; - private GuiTabButton tabCraftButton; - private GuiTabButton tabProcessButton; - private GuiActionButton substitutionsEnabledBtn; - private GuiActionButton substitutionsDisabledBtn; + public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.setReservedSpace(81); + } - public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.setReservedSpace( 81 ); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.tabCraftButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, + new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.getLocal(), this.itemRenderer, + btn -> toggleCraftMode(CRAFTMODE_PROCESSING)); + this.addButton(this.tabCraftButton); - this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern - .getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_PROCESSING) ); - this.addButton( this.tabCraftButton ); + this.tabProcessButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, + new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.getLocal(), this.itemRenderer, + btn -> toggleCraftMode(CRAFTMODE_CRFTING)); + this.addButton(this.tabProcessButton); - this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern - .getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_CRFTING) ); - this.addButton( this.tabProcessButton ); + this.substitutionsEnabledBtn = new GuiActionButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, + ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE)); + this.substitutionsEnabledBtn.setHalfSize(true); + this.addButton(this.substitutionsEnabledBtn); - this.substitutionsEnabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE) ); - this.substitutionsEnabledBtn.setHalfSize( true ); - this.addButton( this.substitutionsEnabledBtn ); + this.substitutionsDisabledBtn = new GuiActionButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, + ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE)); + this.substitutionsDisabledBtn.setHalfSize(true); + this.addButton(this.substitutionsDisabledBtn); - this.substitutionsDisabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE) ); - this.substitutionsDisabledBtn.setHalfSize( true ); - this.addButton( this.substitutionsDisabledBtn ); + GuiActionButton clearBtn = new GuiActionButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, + ActionItems.CLOSE, act -> clear()); + clearBtn.setHalfSize(true); + this.addButton(clearBtn); - GuiActionButton clearBtn = new GuiActionButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, ActionItems.CLOSE, act -> clear()); - clearBtn.setHalfSize( true ); - this.addButton(clearBtn); + GuiActionButton encodeBtn = new GuiActionButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, + ActionItems.ENCODE, act -> encode()); + this.addButton(encodeBtn); + } - GuiActionButton encodeBtn = new GuiActionButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, ActionItems.ENCODE, act -> encode()); - this.addButton(encodeBtn); - } + private void toggleCraftMode(String mode) { + NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", mode)); + } - private void toggleCraftMode(String mode) { - NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.CraftMode", mode ) ); - } + private void toggleSubstitutions(String mode) { + NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Substitute", mode)); + } - private void toggleSubstitutions(String mode) { - NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.Substitute", mode ) ); - } + private void encode() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "1")); + } - private void encode() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) ); - } + private void clear() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Clear", "1")); + } - private void clear() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (this.container.isCraftingMode()) { + this.tabCraftButton.visible = true; + this.tabProcessButton.visible = false; - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if( this.container.isCraftingMode() ) - { - this.tabCraftButton.visible = true; - this.tabProcessButton.visible = false; + if (this.container.substitute) { + this.substitutionsEnabledBtn.visible = true; + this.substitutionsDisabledBtn.visible = false; + } else { + this.substitutionsEnabledBtn.visible = false; + this.substitutionsDisabledBtn.visible = true; + } + } else { + this.tabCraftButton.visible = false; + this.tabProcessButton.visible = true; + this.substitutionsEnabledBtn.visible = false; + this.substitutionsDisabledBtn.visible = false; + } - if( this.container.substitute ) - { - this.substitutionsEnabledBtn.visible = true; - this.substitutionsDisabledBtn.visible = false; - } - else - { - this.substitutionsEnabledBtn.visible = false; - this.substitutionsDisabledBtn.visible = true; - } - } - else - { - this.tabCraftButton.visible = false; - this.tabProcessButton.visible = true; - this.substitutionsEnabledBtn.visible = false; - this.substitutionsDisabledBtn.visible = false; - } + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.font.drawString(GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), + 4210752); + } - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.font.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752 ); - } + @Override + protected String getBackground() { + if (this.container.isCraftingMode()) { + return BACKGROUND_CRAFTING_MODE; + } - @Override - protected String getBackground() - { - if( this.container.isCraftingMode() ) - { - return BACKGROUND_CRAFTING_MODE; - } + return BACKGROUND_PROCESSING_MODE; + } - return BACKGROUND_PROCESSING_MODE; - } + @Override + protected void repositionSlot(final AppEngSlot s) { + final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3; - @Override - protected void repositionSlot( final AppEngSlot s ) - { - final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3; - - s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide; - } + s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiPriority.java b/src/main/java/appeng/client/gui/implementations/GuiPriority.java index 3e25e65b1..82c74259f 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPriority.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPriority.java @@ -18,6 +18,10 @@ package appeng.client.gui.implementations; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiNumberBox; @@ -26,172 +30,147 @@ import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.util.InputMappings; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiPriority extends AEBaseGui { -public class GuiPriority extends AEBaseGui -{ + private final AESubGui subGui; - private final AESubGui subGui; + private GuiNumberBox priority; - private GuiNumberBox priority; + public GuiPriority(ContainerPriority container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.subGui = new AESubGui(this, container.getPriorityHost()); + } - public GuiPriority(ContainerPriority container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.subGui = new AESubGui(this, container.getPriorityHost()); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + final int a = AEConfig.instance().priorityByStacksAmounts(0); + final int b = AEConfig.instance().priorityByStacksAmounts(1); + final int c = AEConfig.instance().priorityByStacksAmounts(2); + final int d = AEConfig.instance().priorityByStacksAmounts(3); - final int a = AEConfig.instance().priorityByStacksAmounts( 0 ); - final int b = AEConfig.instance().priorityByStacksAmounts( 1 ); - final int c = AEConfig.instance().priorityByStacksAmounts( 2 ); - final int d = AEConfig.instance().priorityByStacksAmounts( 3 ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d) ) ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d) ) ); + this.subGui.addBackButton(this::addButton, 154, 0); - this.subGui.addBackButton(this::addButton, 154, 0); + this.priority = new GuiNumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, + Long.class); + this.priority.setEnableBackgroundDrawing(false); + this.priority.setMaxStringLength(16); + this.priority.setTextColor(0xFFFFFF); + this.priority.setVisible(true); + this.priority.setFocused2(true); + container.setTextField(this.priority); + } - this.priority = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Long.class ); - this.priority.setEnableBackgroundDrawing( false ); - this.priority.setMaxStringLength( 16 ); - this.priority.setTextColor( 0xFFFFFF ); - this.priority.setVisible( true ); - this.priority.setFocused2( true ); - container.setTextField( this.priority ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture(getBackground()); + blit(offsetX, offsetY, 0, 0, this.xSize, this.ySize); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( getBackground() ); - blit( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); + this.priority.render(mouseX, mouseY, partialTicks); + } - this.priority.render(mouseX, mouseY, partialTicks); - } + private void addQty(final int i) { + try { + String out = this.priority.getText(); - private void addQty( final int i ) - { - try - { - String out = this.priority.getText(); + boolean fixed = false; + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); + fixed = true; + } - boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); - fixed = true; - } + if (fixed) { + this.priority.setText(out); + } - if( fixed ) - { - this.priority.setText( out ); - } + if (out.isEmpty()) { + out = "0"; + } - if( out.isEmpty() ) - { - out = "0"; - } + long result = Long.parseLong(out); + result += i; - 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)); + } catch (final NumberFormatException e) { + // nope.. + this.priority.setText("0"); + } + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); - } - catch( final NumberFormatException e ) - { - // nope.. - this.priority.setText( "0" ); - } - } + @Override + public boolean charTyped(char character, int key) { + if (priority.charTyped(character, key)) { + String out = this.priority.getText(); - @Override - public boolean charTyped(char character, int key) { - if (priority.charTyped(character, key)) { - String out = this.priority.getText(); + boolean fixed = false; + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); + fixed = true; + } - boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); - fixed = true; - } + if (fixed) { + this.priority.setText(out); + } - if( fixed ) - { - this.priority.setText( out ); - } + if (out.isEmpty()) { + out = "0"; + } - if( out.isEmpty() ) - { - out = "0"; - } + NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out)); + return true; + } + return false; + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); - return true; - } - return false; - } + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) { + if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) + && this.priority.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + String out = this.priority.getText(); - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) ) - { - if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.priority - .keyPressed( keyCode, scanCode, p_keyPressed_3_ ) ) - { - String out = this.priority.getText(); + boolean fixed = false; + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); + fixed = true; + } - boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); - fixed = true; - } + if (fixed) { + this.priority.setText(out); + } - if( fixed ) - { - this.priority.setText( out ); - } + if (out.isEmpty()) { + out = "0"; + } - if( out.isEmpty() ) - { - out = "0"; - } + NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out)); + return true; + } + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); - return true; - } - } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } - - protected String getBackground() - { - return "guis/priority.png"; - } + protected String getBackground() { + return "guis/priority.png"; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiQNB.java b/src/main/java/appeng/client/gui/implementations/GuiQNB.java index e52f606f6..a047b59b4 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiQNB.java +++ b/src/main/java/appeng/client/gui/implementations/GuiQNB.java @@ -18,35 +18,30 @@ package appeng.client.gui.implementations; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.container.implementations.ContainerQNB; import appeng.core.localization.GuiText; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiQNB extends AEBaseGui { -public class GuiQNB extends AEBaseGui -{ + public GuiQNB(ContainerQNB container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiQNB(ContainerQNB container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/chest.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/chest.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiQuartzKnife.java b/src/main/java/appeng/client/gui/implementations/GuiQuartzKnife.java index 1c822f3d4..0540b8b18 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiQuartzKnife.java +++ b/src/main/java/appeng/client/gui/implementations/GuiQuartzKnife.java @@ -18,11 +18,12 @@ package appeng.client.gui.implementations; - import java.io.IOException; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.container.implementations.ContainerQuartzKnife; @@ -30,72 +31,62 @@ import appeng.core.AELog; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiQuartzKnife extends AEBaseGui { -public class GuiQuartzKnife extends AEBaseGui -{ + private TextFieldWidget name; - private TextFieldWidget name; + public GuiQuartzKnife(ContainerQuartzKnife container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 184; + } - public GuiQuartzKnife(ContainerQuartzKnife container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 184; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.name = new TextFieldWidget(this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT, ""); + this.name.setEnableBackgroundDrawing(false); + this.name.setMaxStringLength(32); + this.name.setTextColor(0xFFFFFF); + this.name.setVisible(true); + this.name.setFocused2(true); + } - this.name = new TextFieldWidget( this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT, "" ); - this.name.setEnableBackgroundDrawing( false ); - this.name.setMaxStringLength( 32 ); - this.name.setTextColor( 0xFFFFFF ); - this.name.setVisible( true ); - this.name.setFocused2( true ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.QuartzCuttingKnife.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/quartzknife.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + this.name.render(mouseX, mouseY, partialTicks); + } - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/quartzknife.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - this.name.render(mouseX, mouseY, partialTicks); - } + @Override + public boolean charTyped(char character, int key) { + if (this.name.charTyped(character, key)) { + final String Out = this.name.getText(); + container.setName(Out); + NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out)); + return true; + } - @Override - public boolean charTyped(char character, int key) { - if( this.name.charTyped( character, key ) ) - { - final String Out = this.name.getText(); - container.setName( Out ); - NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) ); - return true; - } + return super.charTyped(character, key); + } - return super.charTyped(character, key); - } + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + final String Out = this.name.getText(); + container.setName(Out); + NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out)); + return true; + } - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - if( this.name.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) ) - { - final String Out = this.name.getText(); - container.setName( Out ); - NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) ); - return true; - } - - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiSecurityStation.java b/src/main/java/appeng/client/gui/implementations/GuiSecurityStation.java index 20e4f3be9..f864160fb 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiSecurityStation.java +++ b/src/main/java/appeng/client/gui/implementations/GuiSecurityStation.java @@ -18,8 +18,8 @@ package appeng.client.gui.implementations; - import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.SecurityPermissions; import appeng.api.config.SortOrder; @@ -28,76 +28,77 @@ import appeng.container.implementations.ContainerSecurityStation; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.util.text.ITextComponent; +public class GuiSecurityStation extends GuiMEMonitorable { -public class GuiSecurityStation extends GuiMEMonitorable -{ + private GuiToggleButton inject; + private GuiToggleButton extract; + private GuiToggleButton craft; + private GuiToggleButton build; + private GuiToggleButton security; - private GuiToggleButton inject; - private GuiToggleButton extract; - private GuiToggleButton craft; - private GuiToggleButton build; - private GuiToggleButton security; + public GuiSecurityStation(ContainerSecurityStation container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + this.setCustomSortOrder(false); + this.setReservedSpace(33); - public GuiSecurityStation(ContainerSecurityStation container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.setCustomSortOrder( false ); - this.setReservedSpace( 33 ); + // increase size so that the slot is over the gui. + this.xSize += 56; + this.setStandardSize(this.xSize); + } - // increase size so that the slot is over the gui. - this.xSize += 56; - this.setStandardSize( this.xSize ); - } + private void toggleOption(SecurityPermissions permission) { + NetworkHandler.instance() + .sendToServer(new PacketValueConfig("TileSecurityStation.ToggleOption", permission.name())); + } - private void toggleOption(SecurityPermissions permission) { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileSecurityStation.ToggleOption", permission.name() ) ); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + final int top = this.guiTop + this.ySize - 116; + this.inject = this.addButton(new GuiToggleButton(this.guiLeft + 56, top, 11 * 16, 12 * 16, + SecurityPermissions.INJECT.getTranslatedName(), SecurityPermissions.INJECT.getTranslatedTip(), + btn -> toggleOption(SecurityPermissions.INJECT))); - final int top = this.guiTop + this.ySize - 116; - this.inject = this.addButton( new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT - .getTranslatedName(), SecurityPermissions.INJECT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.INJECT) ) ); + this.extract = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, + SecurityPermissions.EXTRACT.getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(), + btn -> toggleOption(SecurityPermissions.EXTRACT))); - this.extract = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT - .getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.EXTRACT ) ) ); + this.craft = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, + SecurityPermissions.CRAFT.getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(), + btn -> toggleOption(SecurityPermissions.CRAFT))); - this.craft = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT - .getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.CRAFT ) ) ); + this.build = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, + SecurityPermissions.BUILD.getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(), + btn -> toggleOption(SecurityPermissions.BUILD))); - this.build = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD - .getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.BUILD ) ) ); + this.security = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, + SecurityPermissions.SECURITY.getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(), + btn -> toggleOption(SecurityPermissions.SECURITY))); + } - this.security = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY - .getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.SECURITY ) ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.font.drawString(GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), + 4210752); + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.font.drawString( GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752 ); - } + @Override + protected String getBackground() { + this.inject.setState((container.getPermissionMode() & (1 << SecurityPermissions.INJECT.ordinal())) > 0); + this.extract.setState((container.getPermissionMode() & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0); + this.craft.setState((container.getPermissionMode() & (1 << SecurityPermissions.CRAFT.ordinal())) > 0); + this.build.setState((container.getPermissionMode() & (1 << SecurityPermissions.BUILD.ordinal())) > 0); + this.security.setState((container.getPermissionMode() & (1 << SecurityPermissions.SECURITY.ordinal())) > 0); - @Override - protected String getBackground() - { - this.inject.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.INJECT.ordinal() ) ) > 0 ); - this.extract.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.EXTRACT.ordinal() ) ) > 0 ); - this.craft.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.CRAFT.ordinal() ) ) > 0 ); - this.build.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.BUILD.ordinal() ) ) > 0 ); - this.security.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.SECURITY.ordinal() ) ) > 0 ); + return "guis/security_station.png"; + } - return "guis/security_station.png"; - } - - @Override - public SortOrder getSortBy() - { - return SortOrder.NAME; - } + @Override + public SortOrder getSortBy() { + return SortOrder.NAME; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiSkyChest.java b/src/main/java/appeng/client/gui/implementations/GuiSkyChest.java index 64e8090ff..57c368069 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiSkyChest.java +++ b/src/main/java/appeng/client/gui/implementations/GuiSkyChest.java @@ -18,47 +18,40 @@ package appeng.client.gui.implementations; - -import appeng.core.AppEng; import net.minecraft.entity.player.PlayerInventory; - -import appeng.client.gui.AEBaseGui; -import appeng.container.implementations.ContainerSkyChest; -import appeng.core.localization.GuiText; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; +import appeng.client.gui.AEBaseGui; +import appeng.container.implementations.ContainerSkyChest; +import appeng.core.AppEng; +import appeng.core.localization.GuiText; -public class GuiSkyChest extends AEBaseGui -{ +public class GuiSkyChest extends AEBaseGui { - private static final ResourceLocation TEXTURE = new ResourceLocation(AppEng.MOD_ID, "textures/guis/skychest.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(AppEng.MOD_ID, "textures/guis/skychest.png"); - public GuiSkyChest( ContainerSkyChest container, PlayerInventory playerInv, ITextComponent title ) - { - super( container, playerInv, title ); - this.ySize = 195; - } + public GuiSkyChest(ContainerSkyChest container, PlayerInventory playerInv, ITextComponent title) { + super(container, playerInv, title); + this.ySize = 195; + } - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752 ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752); + } - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - bindTexture(TEXTURE); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + bindTexture(TEXTURE); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0); + } - @Override - protected boolean enableSpaceClicking() - { - // FIXME return !Integrations.invTweaks().isEnabled(); - return true; - } + @Override + protected boolean enableSpaceClicking() { + // FIXME return !Integrations.invTweaks().isEnabled(); + return true; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiSpatialIOPort.java b/src/main/java/appeng/client/gui/implementations/GuiSpatialIOPort.java index 4caf42983..e09d8508b 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiSpatialIOPort.java +++ b/src/main/java/appeng/client/gui/implementations/GuiSpatialIOPort.java @@ -18,61 +18,58 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.CommonButtons; import appeng.container.implementations.ContainerSpatialIOPort; import appeng.core.localization.GuiText; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiSpatialIOPort extends AEBaseGui { -public class GuiSpatialIOPort extends AEBaseGui -{ + public GuiSpatialIOPort(ContainerSpatialIOPort container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 199; + } - public GuiSpatialIOPort(ContainerSpatialIOPort container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 199; - } + @Override + public void init() { + super.init(); + this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8)); + } - @Override - public void init() - { - super.init(); - this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(GuiText.StoredPower.getLocal() + ": " + + Platform.formatPowerLong(this.container.getCurrentPower(), false), 13, 21, 4210752); + this.font.drawString( + GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(this.container.getMaxPower(), false), 13, + 31, 4210752); + this.font.drawString(GuiText.RequiredPower.getLocal() + ": " + + Platform.formatPowerLong(this.container.getRequiredPower(), false), 13, 73, 4210752); + this.font.drawString( + GuiText.Efficiency.getLocal() + ": " + (((float) this.container.getEfficency()) / 100) + '%', 13, 83, + 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getCurrentPower(), false ), 13, 21, - 4210752 ); - this.font.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getMaxPower(), false ), 13, 31, 4210752 ); - this.font.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 73, - 4210752 ); - this.font.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 83, 4210752 ); + this.font.drawString(this.getGuiDisplayName(GuiText.SpatialIOPort.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752); - this.font.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 ); + if (this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0) { + final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize + + "x" + this.container.zSize; + this.font.drawString(text, 13, 93, 4210752); + } else { + this.font.drawString(GuiText.SCSSize.getLocal() + ": " + GuiText.SCSInvalid.getLocal(), 13, 93, 4210752); + } - if( this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0 ) - { - final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize + "x" + this.container.zSize; - this.font.drawString( text, 13, 93, 4210752 ); - } - else - { - this.font.drawString( GuiText.SCSSize.getLocal() + ": " + GuiText.SCSInvalid.getLocal(), 13, 93, 4210752 ); - } + } - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/spatialio.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/spatialio.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java b/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java index b26d3b8a9..1af9af749 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java @@ -18,6 +18,8 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.*; import appeng.client.gui.widgets.GuiActionButton; @@ -30,75 +32,69 @@ import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketSwitchGuis; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiStorageBus extends GuiUpgradeable { -public class GuiStorageBus extends GuiUpgradeable -{ + private GuiSettingToggleButton rwMode; + private GuiSettingToggleButton storageFilter; - private GuiSettingToggleButton rwMode; - private GuiSettingToggleButton storageFilter; + public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 251; + } - public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 251; - } + @Override + protected void addButtons() { + addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear())); + addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition())); + this.rwMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, + AccessRestriction.READ_WRITE); + this.storageFilter = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, + Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY); + this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, + FuzzyMode.IGNORE_ALL); - @Override - protected void addButtons() - { - addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear() ) ); - addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition() ) ); - this.rwMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE ); - this.storageFilter = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY ); - this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriorityGui())); - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); + this.addButton(this.storageFilter); + this.addButton(this.fuzzyMode); + this.addButton(this.rwMode); + } - this.addButton( this.storageFilter ); - this.addButton( this.fuzzyMode ); - this.addButton( this.rwMode ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.StorageBus.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + if (this.fuzzyMode != null) { + this.fuzzyMode.set(this.cvb.getFuzzyMode()); + } - if( this.fuzzyMode != null ) - { - this.fuzzyMode.set( this.cvb.getFuzzyMode() ); - } + if (this.storageFilter != null) { + this.storageFilter.set(((ContainerStorageBus) this.cvb).getStorageFilter()); + } - if( this.storageFilter != null ) - { - this.storageFilter.set( ( (ContainerStorageBus) this.cvb ).getStorageFilter() ); - } + if (this.rwMode != null) { + this.rwMode.set(((ContainerStorageBus) this.cvb).getReadWriteMode()); + } + } - if( this.rwMode != null ) - { - this.rwMode.set( ( (ContainerStorageBus) this.cvb ).getReadWriteMode() ); - } - } + @Override + protected String getBackground() { + return "guis/storagebus.png"; + } - @Override - protected String getBackground() - { - return "guis/storagebus.png"; - } + private void partition() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition")); + } - private void partition() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) ); - } + private void clear() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Clear")); + } - private void clear() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) ); - } - - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java index 8d0804bc2..988dd427b 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java @@ -18,9 +18,9 @@ package appeng.client.gui.implementations; - -import appeng.client.gui.widgets.GuiServerSettingToggleButton; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.config.FuzzyMode; import appeng.api.config.RedstoneMode; @@ -30,136 +30,121 @@ import appeng.api.config.Upgrades; import appeng.api.config.YesNo; import appeng.api.implementations.IUpgradeableHost; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; import appeng.client.gui.widgets.GuiSettingToggleButton; import appeng.container.implementations.ContainerUpgradeable; import appeng.core.localization.GuiText; import appeng.parts.automation.PartExportBus; import appeng.parts.automation.PartImportBus; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiUpgradeable extends AEBaseGui { -public class GuiUpgradeable extends AEBaseGui -{ + protected final ContainerUpgradeable cvb; + protected final IUpgradeableHost bc; - protected final ContainerUpgradeable cvb; - protected final IUpgradeableHost bc; + protected GuiSettingToggleButton redstoneMode; + protected GuiSettingToggleButton fuzzyMode; + protected GuiSettingToggleButton craftMode; + protected GuiSettingToggleButton schedulingMode; - protected GuiSettingToggleButton redstoneMode; - protected GuiSettingToggleButton fuzzyMode; - protected GuiSettingToggleButton craftMode; - protected GuiSettingToggleButton schedulingMode; + public GuiUpgradeable(T container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.cvb = container; - public GuiUpgradeable(T container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.cvb = container; + this.bc = (IUpgradeableHost) container.getTarget(); + this.xSize = this.hasToolbox() ? 246 : 211; + this.ySize = 184; + } - this.bc = (IUpgradeableHost) container.getTarget(); - this.xSize = this.hasToolbox() ? 246 : 211; - this.ySize = 184; - } + protected boolean hasToolbox() { + return (this.container).hasToolbox(); + } - protected boolean hasToolbox() - { - return ( this.container ).hasToolbox(); - } + @Override + public void init() { + super.init(); + this.addButtons(); + } - @Override - public void init() - { - super.init(); - this.addButtons(); - } + protected void addButtons() { + this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, + Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + addButton(this.redstoneMode); + this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, + FuzzyMode.IGNORE_ALL); + addButton(this.fuzzyMode); + this.craftMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, + YesNo.NO); + addButton(this.craftMode); + this.schedulingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, + Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + addButton(this.schedulingMode); + } - protected void addButtons() - { - this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - addButton(this.redstoneMode); - this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - addButton(this.fuzzyMode); - this.craftMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO ); - addButton(this.craftMode); - this.schedulingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - addButton(this.schedulingMode); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + if (this.redstoneMode != null) { + this.redstoneMode.set(this.cvb.getRedStoneMode()); + } - if( this.redstoneMode != null ) - { - this.redstoneMode.set( this.cvb.getRedStoneMode() ); - } + if (this.fuzzyMode != null) { + this.fuzzyMode.set(this.cvb.getFuzzyMode()); + } - if( this.fuzzyMode != null ) - { - this.fuzzyMode.set( this.cvb.getFuzzyMode() ); - } + if (this.craftMode != null) { + this.craftMode.set(this.cvb.getCraftingMode()); + } - if( this.craftMode != null ) - { - this.craftMode.set( this.cvb.getCraftingMode() ); - } + if (this.schedulingMode != null) { + this.schedulingMode.set(this.cvb.getSchedulingMode()); + } + } - if( this.schedulingMode != null ) - { - this.schedulingMode.set( this.cvb.getSchedulingMode() ); - } - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.handleButtonVisibility(); - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.handleButtonVisibility(); + this.bindTexture(this.getBackground()); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset()); + if (this.drawUpgrades()) { + GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18, + getBlitOffset()); + } + if (this.hasToolbox()) { + GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, + getBlitOffset()); + } + } - this.bindTexture( this.getBackground() ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() ); - if( this.drawUpgrades() ) - { - GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18, getBlitOffset() ); - } - if( this.hasToolbox() ) - { - GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, getBlitOffset() ); - } - } + protected void handleButtonVisibility() { + if (this.redstoneMode != null) { + this.redstoneMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.REDSTONE) > 0); + } + if (this.fuzzyMode != null) { + this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0); + } + if (this.craftMode != null) { + this.craftMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0); + } + if (this.schedulingMode != null) { + this.schedulingMode.setVisibility( + this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof PartExportBus); + } + } - protected void handleButtonVisibility() - { - if( this.redstoneMode != null ) - { - this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 ); - } - if( this.fuzzyMode != null ) - { - this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ); - } - if( this.craftMode != null ) - { - this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ); - } - if( this.schedulingMode != null ) - { - this.schedulingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CAPACITY ) > 0 && this.bc instanceof PartExportBus ); - } - } + protected String getBackground() { + return "guis/bus.png"; + } - protected String getBackground() - { - return "guis/bus.png"; - } + protected boolean drawUpgrades() { + return true; + } - protected boolean drawUpgrades() - { - return true; - } - - protected GuiText getName() - { - return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus; - } + protected GuiText getName() { + return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus; + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiVibrationChamber.java b/src/main/java/appeng/client/gui/implementations/GuiVibrationChamber.java index 71fb43eca..bdd1aadf9 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiVibrationChamber.java +++ b/src/main/java/appeng/client/gui/implementations/GuiVibrationChamber.java @@ -18,9 +18,11 @@ package appeng.client.gui.implementations; - import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiProgressBar; @@ -28,54 +30,48 @@ import appeng.client.gui.widgets.GuiProgressBar.Direction; import appeng.container.implementations.ContainerVibrationChamber; import appeng.core.localization.GuiText; import appeng.tile.misc.TileVibrationChamber; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiVibrationChamber extends AEBaseGui { -public class GuiVibrationChamber extends AEBaseGui -{ + private GuiProgressBar pb; - private GuiProgressBar pb; + public GuiVibrationChamber(ContainerVibrationChamber container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiVibrationChamber(ContainerVibrationChamber container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.pb = new GuiProgressBar(this.container, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL); + this.addButton(this.pb); + } - this.pb = new GuiProgressBar( this.container, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL ); - this.addButton( this.pb ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + this.pb.setFullMsg(TileVibrationChamber.POWER_PER_TICK * this.container.getCurrentProgress() + / TileVibrationChamber.DILATION_SCALING + " AE/t"); - this.pb.setFullMsg( TileVibrationChamber.POWER_PER_TICK * this.container.getCurrentProgress() / TileVibrationChamber.DILATION_SCALING + " AE/t" ); + if (this.container.getRemainingBurnTime() > 0) { + final int i1 = this.container.getRemainingBurnTime() * 12 / 100; + this.bindTexture("guis/vibchamber.png"); + RenderSystem.color3f(1, 1, 1); + final int l = -15; + final int k = 25; + GuiUtils.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2, getBlitOffset()); + } + } - if( this.container.getRemainingBurnTime() > 0 ) - { - final int i1 = this.container.getRemainingBurnTime() * 12 / 100; - this.bindTexture( "guis/vibchamber.png" ); - RenderSystem.color3f( 1, 1, 1 ); - final int l = -15; - final int k = 25; - GuiUtils.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2, getBlitOffset() ); - } - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/vibchamber.png" ); - this.pb.x = 99 + this.guiLeft; - this.pb.y = 36 + this.guiTop; - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/vibchamber.png"); + this.pb.x = 99 + this.guiLeft; + this.pb.y = 36 + this.guiTop; + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiWireless.java b/src/main/java/appeng/client/gui/implementations/GuiWireless.java index be267130b..9e65cf512 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiWireless.java +++ b/src/main/java/appeng/client/gui/implementations/GuiWireless.java @@ -18,6 +18,9 @@ package appeng.client.gui.implementations; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.config.Settings; import appeng.client.gui.AEBaseGui; @@ -27,49 +30,42 @@ import appeng.container.implementations.ContainerWireless; import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiWireless extends AEBaseGui { -public class GuiWireless extends AEBaseGui -{ + public GuiWireless(ContainerWireless container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 166; + } - public GuiWireless(ContainerWireless container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 166; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8)); + } - this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) ); - } + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + if (container.getRange() > 0) { + final String firstMessage = GuiText.Range.getLocal() + ": " + (container.getRange() / 10.0) + " m"; + final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + + Platform.formatPowerLong(container.getDrain(), true); - if( container.getRange() > 0 ) - { - final String firstMessage = GuiText.Range.getLocal() + ": " + ( container.getRange() / 10.0 ) + " m"; - final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( container.getDrain(), true ); + final int strWidth = Math.max(this.font.getStringWidth(firstMessage), + this.font.getStringWidth(secondMessage)); + final int cOffset = (this.xSize / 2) - (strWidth / 2); + this.font.drawString(firstMessage, cOffset, 20, 4210752); + this.font.drawString(secondMessage, cOffset, 20 + 12, 4210752); + } + } - final int strWidth = Math.max( this.font.getStringWidth( firstMessage ), this.font.getStringWidth( secondMessage ) ); - final int cOffset = ( this.xSize / 2 ) - ( strWidth / 2 ); - this.font.drawString( firstMessage, cOffset, 20, 4210752 ); - this.font.drawString( secondMessage, cOffset, 20 + 12, 4210752 ); - } - } - - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - this.bindTexture( "guis/wireless.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + this.bindTexture("guis/wireless.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset()); + } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiWirelessTerm.java b/src/main/java/appeng/client/gui/implementations/GuiWirelessTerm.java index d38ff2b6d..c3b4ec11e 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiWirelessTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiWirelessTerm.java @@ -18,18 +18,16 @@ package appeng.client.gui.implementations; - -import appeng.container.implementations.ContainerMEPortableCell; import net.minecraft.entity.player.PlayerInventory; - import net.minecraft.util.text.ITextComponent; -// FIXME: Extended from GuiPortableCell before... Why? -public class GuiWirelessTerm extends GuiMEMonitorable -{ +import appeng.container.implementations.ContainerMEPortableCell; - public GuiWirelessTerm(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } +// FIXME: Extended from GuiPortableCell before... Why? +public class GuiWirelessTerm extends GuiMEMonitorable { + + public GuiWirelessTerm(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } } diff --git a/src/main/java/appeng/client/gui/widgets/CommonButtons.java b/src/main/java/appeng/client/gui/widgets/CommonButtons.java index e1a2ccef8..04279da44 100644 --- a/src/main/java/appeng/client/gui/widgets/CommonButtons.java +++ b/src/main/java/appeng/client/gui/widgets/CommonButtons.java @@ -12,12 +12,13 @@ public final class CommonButtons { } public static GuiSettingToggleButton togglePowerUnit(int x, int y) { - return new GuiSettingToggleButton<>( x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), CommonButtons::togglePowerUnit ); + return new GuiSettingToggleButton<>(x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), + CommonButtons::togglePowerUnit); } private static void togglePowerUnit(GuiSettingToggleButton button, boolean backwards) { - AEConfig.instance().nextPowerUnit( backwards ); - button.set( AEConfig.instance().selectedPowerUnit() ); + AEConfig.instance().nextPowerUnit(backwards); + button.set(AEConfig.instance().selectedPowerUnit()); } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiActionButton.java b/src/main/java/appeng/client/gui/widgets/GuiActionButton.java index 919a855fb..434e3bb46 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiActionButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiActionButton.java @@ -18,10 +18,14 @@ package appeng.client.gui.widgets; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.regex.Pattern; -import appeng.api.config.*; -import appeng.core.localization.ButtonToolTips; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.texture.TextureManager; @@ -29,87 +33,77 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; -import java.util.regex.Pattern; +import appeng.api.config.*; +import appeng.core.localization.ButtonToolTips; +public class GuiActionButton extends GuiIconButton implements ITooltip { + private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL); + private final int iconIndex; -public class GuiActionButton extends GuiIconButton implements ITooltip -{ - private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL ); - private final int iconIndex; + public GuiActionButton(final int x, final int y, final ActionItems action, Consumer onPress) { + super(x, y, btn -> onPress.accept(action)); - public GuiActionButton(final int x, final int y, final ActionItems action, Consumer onPress ) - { - super( x, y, btn -> onPress.accept(action) ); + ButtonToolTips displayName; + ButtonToolTips displayValue; + switch (action) { + case WRENCH: + iconIndex = 66; + displayName = ButtonToolTips.PartitionStorage; + displayValue = ButtonToolTips.PartitionStorageHint; + break; + case CLOSE: + iconIndex = 6; + displayName = ButtonToolTips.Clear; + displayValue = ButtonToolTips.ClearSettings; + break; + case STASH: + iconIndex = 6; + displayName = ButtonToolTips.Stash; + displayValue = ButtonToolTips.StashDesc; + break; + case ENCODE: + iconIndex = 8; + displayName = ButtonToolTips.Encode; + displayValue = ButtonToolTips.EncodeDescription; + break; + case ENABLE_SUBSTITUTION: + iconIndex = 4 + 3 * 16; + displayName = ButtonToolTips.Substitutions; + displayValue = ButtonToolTips.SubstitutionsDescEnabled; + break; + case DISABLE_SUBSTITUTION: + iconIndex = 7 + 3 * 16; + displayName = ButtonToolTips.Substitutions; + displayValue = ButtonToolTips.SubstitutionsDescDisabled; + break; + default: + throw new IllegalArgumentException("Unknown ActionItem: " + action); + } - ButtonToolTips displayName; - ButtonToolTips displayValue; - switch (action) { - case WRENCH: - iconIndex = 66; - displayName = ButtonToolTips.PartitionStorage; - displayValue = ButtonToolTips.PartitionStorageHint; - break; - case CLOSE: - iconIndex = 6; - displayName = ButtonToolTips.Clear; - displayValue = ButtonToolTips.ClearSettings; - break; - case STASH: - iconIndex = 6; - displayName = ButtonToolTips.Stash; - displayValue = ButtonToolTips.StashDesc; - break; - case ENCODE: - iconIndex = 8; - displayName = ButtonToolTips.Encode; - displayValue = ButtonToolTips.EncodeDescription; - break; - case ENABLE_SUBSTITUTION: - iconIndex = 4 + 3 * 16; - displayName = ButtonToolTips.Substitutions; - displayValue = ButtonToolTips.SubstitutionsDescEnabled; - break; - case DISABLE_SUBSTITUTION: - iconIndex = 7 + 3 * 16; - displayName = ButtonToolTips.Substitutions; - displayValue = ButtonToolTips.SubstitutionsDescDisabled; - break; - default: - throw new IllegalArgumentException("Unknown ActionItem: " + action); - } + setMessage(buildMessage(displayName, displayValue)); + } - setMessage(buildMessage(displayName, displayValue)); - } + @Override + protected int getIconIndex() { + return iconIndex; + } - @Override - protected int getIconIndex() - { - return iconIndex; - } + private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) { + String name = displayName.getTranslationKey().getString(); + String value = displayValue.getTranslationKey().getString(); - private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) - { - String name = displayName.getTranslationKey().getString(); - String value = displayValue.getTranslationKey().getString(); + value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n"); + final StringBuilder sb = new StringBuilder(value); - value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); - final StringBuilder sb = new StringBuilder( value ); + int i = sb.lastIndexOf("\n"); + if (i <= 0) { + i = 0; + } + while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) { + sb.replace(i, i + 1, "\n"); + } - int i = sb.lastIndexOf( "\n" ); - if( i <= 0 ) - { - i = 0; - } - while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) - { - sb.replace( i, i + 1, "\n" ); - } - - return name + '\n' + sb; - } + return name + '\n' + sb; + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiCustomSlot.java b/src/main/java/appeng/client/gui/widgets/GuiCustomSlot.java index 830a69c9d..b55b4d28b 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiCustomSlot.java +++ b/src/main/java/appeng/client/gui/widgets/GuiCustomSlot.java @@ -1,85 +1,70 @@ package appeng.client.gui.widgets; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +public abstract class GuiCustomSlot extends AbstractGui implements ITooltip { + private final int x; + private final int y; + private final int id; -public abstract class GuiCustomSlot extends AbstractGui implements ITooltip -{ - private final int x; - private final int y; - private final int id; + public GuiCustomSlot(final int id, final int x, final int y) { + this.x = x; + this.y = y; + this.id = id; + } - public GuiCustomSlot( final int id, final int x, final int y ) - { - this.x = x; - this.y = y; - this.id = id; - } + public int getId() { + return this.id; + } - public int getId() - { - return this.id; - } + public boolean canClick(final PlayerEntity player) { + return true; + } - public boolean canClick( final PlayerEntity player ) - { - return true; - } + public void slotClicked(final ItemStack clickStack, final int mouseButton) { + } - public void slotClicked( final ItemStack clickStack, final int mouseButton ) - { - } + public abstract void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks); - public abstract void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ); + public void drawBackground(int guileft, int guitop, int currentZIndex) { + } - public void drawBackground( int guileft, int guitop, int currentZIndex ) - { - } + @Override + public String getMessage() { + return null; + } - @Override - public String getMessage() - { - return null; - } + @Override + public int xPos() { + return this.x; + } - @Override - public int xPos() - { - return this.x; - } + @Override + public int yPos() { + return this.y; + } - @Override - public int yPos() - { - return this.y; - } + @Override + public int getWidth() { + return 16; + } - @Override - public int getWidth() - { - return 16; - } + @Override + public int getHeight() { + return 16; + } - @Override - public int getHeight() - { - return 16; - } + @Override + public boolean isVisible() { + return false; + } - @Override - public boolean isVisible() - { - return false; - } - - public boolean isSlotEnabled() - { - return true; - } + public boolean isSlotEnabled() { + return true; + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiIconButton.java b/src/main/java/appeng/client/gui/widgets/GuiIconButton.java index a6ec9162f..088f98a94 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiIconButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiIconButton.java @@ -18,10 +18,12 @@ package appeng.client.gui.widgets; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; -import appeng.api.config.*; -import appeng.core.localization.ButtonToolTips; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.texture.TextureManager; @@ -29,128 +31,108 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; +import appeng.api.config.*; +import appeng.core.localization.ButtonToolTips; +public abstract class GuiIconButton extends Button implements ITooltip { + public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", + "textures/guis/states.png"); -public abstract class GuiIconButton extends Button implements ITooltip -{ - public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png"); + private boolean halfSize = false; - private boolean halfSize = false; + public GuiIconButton(final int x, final int y, IPressable onPress) { + super(x, y, 16, 16, "", onPress); + } - public GuiIconButton(final int x, final int y, IPressable onPress ) - { - super( x, y, 16, 16, "", onPress ); - } + public void setVisibility(final boolean vis) { + this.visible = vis; + this.active = vis; + } - public void setVisibility( final boolean vis ) - { - this.visible = vis; - this.active = vis; - } + @Override + public void renderButton(final int mouseX, final int mouseY, float partial) { - @Override - public void renderButton(final int mouseX, final int mouseY, float partial) { + Minecraft minecraft = Minecraft.getInstance(); - Minecraft minecraft = Minecraft.getInstance(); + if (this.visible) { + final int iconIndex = this.getIconIndex(); - if( this.visible ) - { - final int iconIndex = this.getIconIndex(); + TextureManager textureManager = minecraft.getTextureManager(); + textureManager.bindTexture(TEXTURE_STATES); + RenderSystem.disableDepthTest(); + RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables + // it :| + if (this.halfSize) { + this.width = 8; + this.height = 8; - TextureManager textureManager = minecraft.getTextureManager(); - textureManager.bindTexture(TEXTURE_STATES); - RenderSystem.disableDepthTest(); - RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables it :| - if( this.halfSize ) - { - this.width = 8; - this.height = 8; + RenderSystem.pushMatrix(); + RenderSystem.translatef(this.x, this.y, 0.0F); + RenderSystem.scalef(0.5f, 0.5f, 0.5f); - RenderSystem.pushMatrix(); - RenderSystem.translatef( this.x, this.y, 0.0F ); - RenderSystem.scalef( 0.5f, 0.5f, 0.5f ); + if (this.active) { + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + } else { + RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f); + } - if( this.active ) - { - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } - else - { - RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f ); - } + final int uv_y = iconIndex / 16; + final int uv_x = iconIndex - uv_y * 16; - final int uv_y = iconIndex / 16; - final int uv_x = iconIndex - uv_y * 16; + GuiUtils.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16, 0); + GuiUtils.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16, 0); + RenderSystem.popMatrix(); + } else { + if (this.active) { + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + } else { + RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f); + } - GuiUtils.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16, 0 ); - GuiUtils.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16, 0 ); - RenderSystem.popMatrix(); - } - else - { - if( this.active ) - { - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } - else - { - RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f ); - } + final int uv_y = iconIndex / 16; + final int uv_x = iconIndex - uv_y * 16; - final int uv_y = iconIndex / 16; - final int uv_x = iconIndex - uv_y * 16; + GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0); + GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0); + } + RenderSystem.enableDepthTest(); + } + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + } - GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 ); - GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 ); - } - RenderSystem.enableDepthTest(); - } - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } + protected abstract int getIconIndex(); - protected abstract int getIconIndex(); + @Override + public int xPos() { + return this.x; + } - @Override - public int xPos() - { - return this.x; - } + @Override + public int yPos() { + return this.y; + } - @Override - public int yPos() - { - return this.y; - } + @Override + public int getWidth() { + return this.halfSize ? 8 : 16; + } - @Override - public int getWidth() - { - return this.halfSize ? 8 : 16; - } + @Override + public int getHeight() { + return this.halfSize ? 8 : 16; + } - @Override - public int getHeight() - { - return this.halfSize ? 8 : 16; - } + @Override + public boolean isVisible() { + return this.visible; + } - @Override - public boolean isVisible() - { - return this.visible; - } + public boolean isHalfSize() { + return this.halfSize; + } - public boolean isHalfSize() - { - return this.halfSize; - } - - public void setHalfSize( final boolean halfSize ) - { - this.halfSize = halfSize; - } + public void setHalfSize(final boolean halfSize) { + this.halfSize = halfSize; + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java b/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java index f9126bd44..8bf2aaf61 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java +++ b/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java @@ -18,46 +18,35 @@ package appeng.client.gui.widgets; - import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.widget.TextFieldWidget; // FIXME: Fix this piece of crap (i.e. onChange listener) -public class GuiNumberBox extends TextFieldWidget -{ +public class GuiNumberBox extends TextFieldWidget { - private final Class type; + private final Class type; - public GuiNumberBox( final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type ) - { - super( fontRenderer, x, y, width, height, "0" ); - this.type = type; - } + public GuiNumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, + final Class type) { + super(fontRenderer, x, y, width, height, "0"); + this.type = type; + } - @Override - public void writeText( final String selectedText ) - { - final String original = this.getText(); - super.writeText( selectedText ); + @Override + public void writeText(final String selectedText) { + final String original = this.getText(); + super.writeText(selectedText); - try - { - if( this.type == int.class || this.type == Integer.class ) - { - Integer.parseInt( this.getText() ); - } - else if( this.type == long.class || this.type == Long.class ) - { - Long.parseLong( this.getText() ); - } - else if( this.type == double.class || this.type == Double.class ) - { - Double.parseDouble( this.getText() ); - } - } - catch( final NumberFormatException e ) - { - this.setText( original ); - } - } + try { + if (this.type == int.class || this.type == Integer.class) { + Integer.parseInt(this.getText()); + } else if (this.type == long.class || this.type == Long.class) { + Long.parseLong(this.getText()); + } else if (this.type == double.class || this.type == Double.class) { + Double.parseDouble(this.getText()); + } + } catch (final NumberFormatException e) { + this.setText(original); + } + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java b/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java index 331daaa1b..9634984e6 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java +++ b/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java @@ -18,115 +18,100 @@ package appeng.client.gui.widgets; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.container.interfaces.IProgressProvider; import appeng.core.localization.GuiText; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiProgressBar extends Widget implements ITooltip { -public class GuiProgressBar extends Widget implements ITooltip -{ + private final IProgressProvider source; + private final ResourceLocation texture; + private final int fill_u; + private final int fill_v; + private final Direction layout; + private final String titleName; + private String fullMsg; - private final IProgressProvider source; - private final ResourceLocation texture; - private final int fill_u; - private final int fill_v; - private final Direction layout; - private final String titleName; - private String fullMsg; + public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY, + final int u, final int y, final int width, final int height, final Direction dir) { + this(source, texture, posX, posY, u, y, width, height, dir, null); + } - public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir ) - { - this( source, texture, posX, posY, u, y, width, height, dir, null ); - } + public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY, + final int u, final int y, final int width, final int height, final Direction dir, final String title) { + super(posX, posY, width, height, ""); + this.source = source; + this.texture = new ResourceLocation("appliedenergistics2", "textures/" + texture); + this.fill_u = u; + this.fill_v = y; + this.layout = dir; + this.titleName = title; + } - public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir, final String title ) - { - super( posX, posY, width, height, "" ); - this.source = source; - this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture ); - this.fill_u = u; - this.fill_v = y; - this.layout = dir; - this.titleName = title; - } + @Override + public void renderButton(final int par2, final int par3, final float partial) { + if (this.visible) { + Minecraft.getInstance().getTextureManager().bindTexture(this.texture); + final int max = this.source.getMaxProgress(); + final int current = this.source.getCurrentProgress(); - @Override - public void renderButton( final int par2, final int par3, final float partial ) - { - if( this.visible ) - { - Minecraft.getInstance().getTextureManager().bindTexture( this.texture ); - final int max = this.source.getMaxProgress(); - final int current = this.source.getCurrentProgress(); + if (this.layout == Direction.VERTICAL) { + final int diff = this.height - (max > 0 ? (this.height * current) / max : 0); + GuiUtils.drawTexturedModalRect(this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, + this.height - diff, 0); + } else { + final int diff = this.width - (max > 0 ? (this.width * current) / max : 0); + GuiUtils.drawTexturedModalRect(this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, + this.height, 0); + } + } + } - if( this.layout == Direction.VERTICAL ) - { - final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 ); - GuiUtils.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff, 0 ); - } - else - { - final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 ); - GuiUtils.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height, 0 ); - } - } - } + public void setFullMsg(final String msg) { + this.fullMsg = msg; + } - public void setFullMsg( final String msg ) - { - this.fullMsg = msg; - } + @Override + public String getMessage() { + if (this.fullMsg != null) { + return this.fullMsg; + } - @Override - public String getMessage() - { - if( this.fullMsg != null ) - { - return this.fullMsg; - } + return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' ' + + GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress(); + } - return ( this.titleName != null ? this.titleName : "" ) + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source - .getMaxProgress(); - } + @Override + public int xPos() { + return this.x - 2; + } - @Override - public int xPos() - { - return this.x - 2; - } + @Override + public int yPos() { + return this.y - 2; + } - @Override - public int yPos() - { - return this.y - 2; - } + @Override + public int getWidth() { + return this.width + 4; + } - @Override - public int getWidth() - { - return this.width + 4; - } + @Override + public int getHeight() { + return this.height + 4; + } - @Override - public int getHeight() - { - return this.height + 4; - } + @Override + public boolean isVisible() { + return true; + } - @Override - public boolean isVisible() - { - return true; - } - - public enum Direction - { - HORIZONTAL, VERTICAL - } + public enum Direction { + HORIZONTAL, VERTICAL + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java b/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java index 238efd713..6a883a21a 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java +++ b/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java @@ -18,139 +18,117 @@ package appeng.client.gui.widgets; - import com.mojang.blaze3d.systems.RenderSystem; -import appeng.client.gui.AEBaseGui; import net.minecraftforge.fml.client.gui.GuiUtils; +import appeng.client.gui.AEBaseGui; -public class GuiScrollbar implements IScrollSource -{ +public class GuiScrollbar implements IScrollSource { - private int displayX = 0; - private int displayY = 0; - private int width = 12; - private int height = 16; - private int pageSize = 1; + private int displayX = 0; + private int displayY = 0; + private int width = 12; + private int height = 16; + private int pageSize = 1; - private int maxScroll = 0; - private int minScroll = 0; - private int currentScroll = 0; + private int maxScroll = 0; + private int minScroll = 0; + private int currentScroll = 0; - public void draw( final AEBaseGui g ) - { - g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" ); - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); + public void draw(final AEBaseGui g) { + g.bindTexture("minecraft", "gui/container/creative_inventory/tabs.png"); + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); - if( this.getRange() == 0 ) - { - GuiUtils.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ ); - } - else - { - final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange(); - GuiUtils.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ ); - } - } + if (this.getRange() == 0) { + GuiUtils.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15, + 0 /* FIXME: this used the GUI's zIndex before */ ); + } else { + final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange(); + GuiUtils.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15, + 0 /* FIXME: this used the GUI's zIndex before */ ); + } + } - private int getRange() - { - return this.maxScroll - this.minScroll; - } + private int getRange() { + return this.maxScroll - this.minScroll; + } - public int getLeft() - { - return this.displayX; - } + public int getLeft() { + return this.displayX; + } - public GuiScrollbar setLeft( final int v ) - { - this.displayX = v; - return this; - } + public GuiScrollbar setLeft(final int v) { + this.displayX = v; + return this; + } - public int getTop() - { - return this.displayY; - } + public int getTop() { + return this.displayY; + } - public GuiScrollbar setTop( final int v ) - { - this.displayY = v; - return this; - } + public GuiScrollbar setTop(final int v) { + this.displayY = v; + return this; + } - public int getWidth() - { - return this.width; - } + public int getWidth() { + return this.width; + } - public GuiScrollbar setWidth( final int v ) - { - this.width = v; - return this; - } + public GuiScrollbar setWidth(final int v) { + this.width = v; + return this; + } - public int getHeight() - { - return this.height; - } + public int getHeight() { + return this.height; + } - public GuiScrollbar setHeight( final int v ) - { - this.height = v; - return this; - } + public GuiScrollbar setHeight(final int v) { + this.height = v; + return this; + } - public void setRange( final int min, final int max, final int pageSize ) - { - this.minScroll = min; - this.maxScroll = max; - this.pageSize = pageSize; + public void setRange(final int min, final int max, final int pageSize) { + this.minScroll = min; + this.maxScroll = max; + this.pageSize = pageSize; - if( this.minScroll > this.maxScroll ) - { - this.maxScroll = this.minScroll; - } + if (this.minScroll > this.maxScroll) { + this.maxScroll = this.minScroll; + } - this.applyRange(); - } + this.applyRange(); + } - private void applyRange() - { - this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll ); - } + private void applyRange() { + this.currentScroll = Math.max(Math.min(this.currentScroll, this.maxScroll), this.minScroll); + } - @Override - public int getCurrentScroll() - { - return this.currentScroll; - } + @Override + public int getCurrentScroll() { + return this.currentScroll; + } - public void click(final double x, final double y) - { - if( this.getRange() == 0 ) - { - return; - } + public void click(final double x, final double y) { + if (this.getRange() == 0) { + return; + } - if( x > this.displayX && x <= this.displayX + this.width ) - { - if( y > this.displayY && y <= this.displayY + this.height ) - { - this.currentScroll = (int) ( y - this.displayY ); - this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) ); - this.currentScroll = ( this.currentScroll + 1 ) >> 1; - this.applyRange(); - } - } - } + if (x > this.displayX && x <= this.displayX + this.width) { + if (y > this.displayY && y <= this.displayY + this.height) { + this.currentScroll = (int) (y - this.displayY); + this.currentScroll = this.minScroll + ((this.currentScroll * 2 * this.getRange() / this.height)); + this.currentScroll = (this.currentScroll + 1) >> 1; + this.applyRange(); + } + } + } - public void wheel( double delta ) - { - delta = Math.max( Math.min( -delta, 1 ), -1 ); - this.currentScroll += delta * this.pageSize; - this.applyRange(); - } + public void wheel(double delta) { + delta = Math.max(Math.min(-delta, 1), -1); + this.currentScroll += delta * this.pageSize; + this.applyRange(); + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiServerSettingToggleButton.java b/src/main/java/appeng/client/gui/widgets/GuiServerSettingToggleButton.java index 4a68c7803..e1af945fc 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiServerSettingToggleButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiServerSettingToggleButton.java @@ -18,32 +18,30 @@ package appeng.client.gui.widgets; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.*; import appeng.core.localization.ButtonToolTips; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketConfigButton; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.text.ITextComponent; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; /** * Convenience button that automatically sends settings changes to the server. */ -public class GuiServerSettingToggleButton> extends GuiSettingToggleButton -{ +public class GuiServerSettingToggleButton> extends GuiSettingToggleButton { - public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val ) - { - super( x, y, setting, val, GuiServerSettingToggleButton::sendToServer ); - } + public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val) { + super(x, y, setting, val, GuiServerSettingToggleButton::sendToServer); + } - private static > void sendToServer(GuiSettingToggleButton button, boolean backwards) { - NetworkHandler.instance().sendToServer( new PacketConfigButton( button.getSetting(), backwards ) ); - } + private static > void sendToServer(GuiSettingToggleButton button, boolean backwards) { + NetworkHandler.instance().sendToServer(new PacketConfigButton(button.getSetting(), backwards)); + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiSettingToggleButton.java b/src/main/java/appeng/client/gui/widgets/GuiSettingToggleButton.java index 5cd10771c..52483fbc1 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiSettingToggleButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiSettingToggleButton.java @@ -18,308 +18,328 @@ package appeng.client.gui.widgets; - -import appeng.api.config.*; -import appeng.core.localization.ButtonToolTips; -import appeng.util.EnumCycler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.text.ITextComponent; - import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; import java.util.regex.Pattern; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.util.text.ITextComponent; -public class GuiSettingToggleButton> extends GuiIconButton -{ - private static final Pattern COMPILE = Pattern.compile( "%s" ); - private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL ); - private static Map appearances; - private final Settings buttonSetting; - private final IHandler> onPress; - private final EnumSet validValues; - private String fillVar; - private T currentValue; +import appeng.api.config.*; +import appeng.core.localization.ButtonToolTips; +import appeng.util.EnumCycler; - @FunctionalInterface - public interface IHandler> { - void handle(T button, boolean backwards); - } +public class GuiSettingToggleButton> extends GuiIconButton { + private static final Pattern COMPILE = Pattern.compile("%s"); + private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL); + private static Map appearances; + private final Settings buttonSetting; + private final IHandler> onPress; + private final EnumSet validValues; + private String fillVar; + private T currentValue; - public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, IHandler> onPress ) - { - this(x, y, setting, val, t -> true, onPress); - } + @FunctionalInterface + public interface IHandler> { + void handle(T button, boolean backwards); + } - public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, Predicate isValidValue, IHandler> onPress ) - { - super( x, y, GuiSettingToggleButton::onPress ); - this.onPress = onPress; + public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, + IHandler> onPress) { + this(x, y, setting, val, t -> true, onPress); + } - // Build a list of values (in order) that are valid w.r.t. the given predicate - EnumSet validValues = EnumSet.allOf(val.getDeclaringClass()); - validValues.removeIf(isValidValue.negate()); - validValues.removeIf(s -> !setting.getPossibleValues().contains(s)); - this.validValues = validValues; + public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, + Predicate isValidValue, IHandler> onPress) { + super(x, y, GuiSettingToggleButton::onPress); + this.onPress = onPress; - this.buttonSetting = setting; - this.currentValue = val; + // Build a list of values (in order) that are valid w.r.t. the given predicate + EnumSet validValues = EnumSet.allOf(val.getDeclaringClass()); + validValues.removeIf(isValidValue.negate()); + validValues.removeIf(s -> !setting.getPossibleValues().contains(s)); + this.validValues = validValues; - if( appearances == null ) - { - appearances = new HashMap<>(); - registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash ); - registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls ); - registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity ); + this.buttonSetting = setting; + this.currentValue = val; - registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read ); - registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write ); - registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite ); + if (appearances == null) { + appearances = new HashMap<>(); + registerApp(16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, + ButtonToolTips.Trash); + registerApp(16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, + ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls); + registerApp(16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, + ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity); - registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.textComponent() ); - registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.textComponent() ); - registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.textComponent() ); + registerApp(16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, + ButtonToolTips.Read); + registerApp(16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write); + registerApp(16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, + ButtonToolTips.ReadWrite); - registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive ); - registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal ); - registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal ); - registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse ); + registerApp(16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, + PowerUnits.AE.textComponent()); + registerApp(16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, + PowerUnits.EU.textComponent()); + registerApp(16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, + PowerUnits.RF.textComponent()); - registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow ); - registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove ); + registerApp(3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, + ButtonToolTips.AlwaysActive); + registerApp(0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, + ButtonToolTips.ActiveWithoutSignal); + registerApp(1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, + ButtonToolTips.ActiveWithSignal); + registerApp(2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, + ButtonToolTips.ActiveOnPulse); - registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell ); - registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork ); + registerApp(0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, + ButtonToolTips.EmitLevelsBelow); + registerApp(1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, + ButtonToolTips.EmitLevelAbove); - registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell ); - registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork ); + registerApp(51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, + ButtonToolTips.TransferToStorageCell); + registerApp(50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, + ButtonToolTips.TransferToNetwork); - registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection ); - registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection ); + registerApp(51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, + ButtonToolTips.TransferToStorageCell); + registerApp(50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, + ButtonToolTips.TransferToNetwork); - registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto ); - registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard ); - registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto ); - registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, - ButtonToolTips.SearchMode_JEIStandard ); - registerApp( 16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep ); - registerApp( 16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, - ButtonToolTips.SearchMode_StandardKeep ); - registerApp( 16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, - ButtonToolTips.SearchMode_JEIAutoKeep ); - registerApp( 16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, - ButtonToolTips.SearchMode_JEIStandardKeep ); + registerApp(48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, + ButtonToolTips.ToggleSortDirection); + registerApp(49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, + ButtonToolTips.ToggleSortDirection); - registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy ); - registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item ); + registerApp(16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_Auto); + registerApp(16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_Standard); + registerApp(16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_JEIAuto); + registerApp(16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_JEIStandard); + registerApp(16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_AutoKeep); + registerApp(16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_StandardKeep); + registerApp(16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, + ButtonToolTips.SearchMode_JEIAutoKeep); + registerApp(16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, + ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandardKeep); - registerApp( 16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall ); - registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small ); - registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full ); + registerApp(16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, + ButtonToolTips.LevelType_Energy); + registerApp(16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, + ButtonToolTips.LevelType_Item); - registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName ); - registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems ); - registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks ); - registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod ); + registerApp(16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, + ButtonToolTips.TerminalStyle_Tall); + registerApp(16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, + ButtonToolTips.TerminalStyle_Small); + registerApp(16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, + ButtonToolTips.TerminalStyle_Full); - registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems ); - registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable ); - registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable ); + registerApp(64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName); + registerApp(65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems); + registerApp(68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, + ButtonToolTips.InventoryTweaks); + registerApp(69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod); - registerApp( 16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 ); - registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 ); - registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 ); - registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 ); - registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll ); + registerApp(16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems); + registerApp(18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable); + registerApp(19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable); - registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty ); - registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone ); - registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull ); + registerApp(16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, + ButtonToolTips.FZPercent_25); + registerApp(16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, + ButtonToolTips.FZPercent_50); + registerApp(16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, + ButtonToolTips.FZPercent_75); + registerApp(16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, + ButtonToolTips.FZPercent_99); + registerApp(16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, + ButtonToolTips.FZIgnoreAll); - registerApp( 16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking ); - registerApp( 16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking ); + registerApp(80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, + ButtonToolTips.MoveWhenEmpty); + registerApp(81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, + ButtonToolTips.MoveWhenWorkIsDone); + registerApp(82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, + ButtonToolTips.MoveWhenFull); - registerApp( 16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly ); - registerApp( 16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither ); + registerApp(16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, + ButtonToolTips.Blocking); + registerApp(16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, + ButtonToolTips.NonBlocking); - registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone ); - registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting ); + registerApp(16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly); + registerApp(16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither); - registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems, - ButtonToolTips.ReportInaccessibleItemsNo ); - registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems, - ButtonToolTips.ReportInaccessibleItemsYes ); + registerApp(16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, + ButtonToolTips.CraftViaRedstone); + registerApp(16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, + ButtonToolTips.EmitWhenCrafting); - registerApp( 16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes ); - registerApp( 16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo ); + registerApp(16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, + ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsNo); + registerApp(16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems, + ButtonToolTips.ReportInaccessibleItemsYes); - registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault ); - registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, - ButtonToolTips.SchedulingModeRoundRobin ); - registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, - ButtonToolTips.SchedulingModeRandom ); - } - } + registerApp(16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, + ButtonToolTips.BlockPlacementYes); + registerApp(16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, + ButtonToolTips.BlockPlacementNo); - private static void onPress(Button btn) { - if (btn instanceof GuiSettingToggleButton) { - ((GuiSettingToggleButton) btn).triggerPress(); - } - } + registerApp(16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, + ButtonToolTips.SchedulingModeDefault); + registerApp(16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, + ButtonToolTips.SchedulingModeRoundRobin); + registerApp(16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, + ButtonToolTips.SchedulingModeRandom); + } + } - private void triggerPress() { - boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown(); - onPress.handle(this, backwards); - } + private static void onPress(Button btn) { + if (btn instanceof GuiSettingToggleButton) { + ((GuiSettingToggleButton) btn).triggerPress(); + } + } - private static void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ITextComponent hint ) - { - final ButtonAppearance a = new ButtonAppearance(); - a.displayName = title.getTranslationKey(); - a.displayValue = hint; - a.index = iconIndex; - appearances.put( new EnumPair( setting, val ), a ); - } + private void triggerPress() { + boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown(); + onPress.handle(this, backwards); + } - private static void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ButtonToolTips hint ) - { - registerApp(iconIndex, setting, val, title, hint.getTranslationKey()); - } + private static void registerApp(final int iconIndex, final Settings setting, final Enum val, + final ButtonToolTips title, final ITextComponent hint) { + final ButtonAppearance a = new ButtonAppearance(); + a.displayName = title.getTranslationKey(); + a.displayValue = hint; + a.index = iconIndex; + appearances.put(new EnumPair(setting, val), a); + } - @Override - protected int getIconIndex() - { - if( this.buttonSetting != null && this.currentValue != null ) - { - final ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) ); - if( app == null ) - { - return 256 - 1; - } - return app.index; - } - return 256 - 1; - } + private static void registerApp(final int iconIndex, final Settings setting, final Enum val, + final ButtonToolTips title, final ButtonToolTips hint) { + registerApp(iconIndex, setting, val, title, hint.getTranslationKey()); + } - public Settings getSetting() - { - return this.buttonSetting; - } + @Override + protected int getIconIndex() { + if (this.buttonSetting != null && this.currentValue != null) { + final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue)); + if (app == null) { + return 256 - 1; + } + return app.index; + } + return 256 - 1; + } - public T getCurrentValue() - { - return this.currentValue; - } + public Settings getSetting() { + return this.buttonSetting; + } - public void set( final T e ) - { - if( this.currentValue != e ) - { - this.currentValue = e; - } - } + public T getCurrentValue() { + return this.currentValue; + } - public T getNextValue(boolean backwards) { - return EnumCycler.rotateEnum(currentValue, backwards, validValues); - } + public void set(final T e) { + if (this.currentValue != e) { + this.currentValue = e; + } + } - @Override - public String getMessage() - { - ITextComponent displayName = null; - ITextComponent displayValue = null; + public T getNextValue(boolean backwards) { + return EnumCycler.rotateEnum(currentValue, backwards, validValues); + } - if( this.buttonSetting != null && this.currentValue != null ) - { - final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) ); - if( buttonAppearance == null ) - { - return "No Such Message"; - } + @Override + public String getMessage() { + ITextComponent displayName = null; + ITextComponent displayValue = null; - displayName = buttonAppearance.displayName; - displayValue = buttonAppearance.displayValue; - } + if (this.buttonSetting != null && this.currentValue != null) { + final ButtonAppearance buttonAppearance = appearances + .get(new EnumPair(this.buttonSetting, this.currentValue)); + if (buttonAppearance == null) { + return "No Such Message"; + } - if( displayName != null ) - { - String name = displayName.getString(); - String value = displayValue.getString(); + displayName = buttonAppearance.displayName; + displayValue = buttonAppearance.displayValue; + } - if( this.fillVar != null ) - { - value = COMPILE.matcher( value ).replaceFirst( this.fillVar ); - } + if (displayName != null) { + String name = displayName.getString(); + String value = displayValue.getString(); - value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); - final StringBuilder sb = new StringBuilder( value ); + if (this.fillVar != null) { + value = COMPILE.matcher(value).replaceFirst(this.fillVar); + } - int i = sb.lastIndexOf( "\n" ); - if( i <= 0 ) - { - i = 0; - } - while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) - { - sb.replace( i, i + 1, "\n" ); - } + value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n"); + final StringBuilder sb = new StringBuilder(value); - return name + '\n' + sb; - } - return null; - } + int i = sb.lastIndexOf("\n"); + if (i <= 0) { + i = 0; + } + while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) { + sb.replace(i, i + 1, "\n"); + } - public String getFillVar() - { - return this.fillVar; - } + return name + '\n' + sb; + } + return null; + } - public void setFillVar( final String fillVar ) - { - this.fillVar = fillVar; - } + public String getFillVar() { + return this.fillVar; + } - private static final class EnumPair - { + public void setFillVar(final String fillVar) { + this.fillVar = fillVar; + } - final Settings setting; - final Enum value; + private static final class EnumPair { - EnumPair( final Settings a, final Enum b ) - { - this.setting = a; - this.value = b; - } + final Settings setting; + final Enum value; - @Override - public int hashCode() - { - return this.setting.hashCode() ^ this.value.hashCode(); - } + EnumPair(final Settings a, final Enum b) { + this.setting = a; + this.value = b; + } - @Override - public boolean equals( final Object obj ) - { - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } - final EnumPair other = (EnumPair) obj; - return other.setting == this.setting && other.value == this.value; - } - } + @Override + public int hashCode() { + return this.setting.hashCode() ^ this.value.hashCode(); + } - private static class ButtonAppearance - { - public int index; - public ITextComponent displayName; - public ITextComponent displayValue; - } + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final EnumPair other = (EnumPair) obj; + return other.setting == this.setting && other.value == this.value; + } + } + + private static class ButtonAppearance { + public int index; + public ITextComponent displayName; + public ITextComponent displayValue; + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiTabButton.java b/src/main/java/appeng/client/gui/widgets/GuiTabButton.java index 21680a72b..34f44da37 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiTabButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiTabButton.java @@ -18,8 +18,8 @@ package appeng.client.gui.widgets; - import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; @@ -30,117 +30,105 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiTabButton extends Button implements ITooltip { + public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", + "textures/guis/states.png"); + private final ItemRenderer itemRenderer; + private int hideEdge = 0; + private int myIcon = -1; + private ItemStack myItem; -public class GuiTabButton extends Button implements ITooltip -{ - public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png"); - private final ItemRenderer itemRenderer; - private int hideEdge = 0; - private int myIcon = -1; - private ItemStack myItem; + public GuiTabButton(final int x, final int y, final int ico, final String message, final ItemRenderer ir, + IPressable onPress) { + super(x, y, 22, 22, message, onPress); - public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir, IPressable onPress ) - { - super( x, y, 22, 22, message, onPress ); + this.myIcon = ico; + this.itemRenderer = ir; + } - this.myIcon = ico; - this.itemRenderer = ir; - } + /** + * Using itemstack as an icon + * + * @param x x pos of button + * @param y y pos of button + * @param ico used icon + * @param message mouse over message + * @param ir renderer + */ + public GuiTabButton(final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, + IPressable onPress) { + super(x, y, 22, 22, message, onPress); + this.myItem = ico; + this.itemRenderer = ir; + } - /** - * Using itemstack as an icon - * - * @param x x pos of button - * @param y y pos of button - * @param ico used icon - * @param message mouse over message - * @param ir renderer - */ - public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, IPressable onPress ) - { - super( x, y, 22, 22, message, onPress ); - this.myItem = ico; - this.itemRenderer = ir; - } + @Override + public void renderButton(final int x, final int y, float partial) { + final Minecraft minecraft = Minecraft.getInstance(); - @Override - public void renderButton( final int x, final int y, float partial ) - { - final Minecraft minecraft = Minecraft.getInstance(); + if (this.visible) { + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + minecraft.textureManager.bindTexture(TEXTURE_STATES); - if( this.visible ) - { - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - minecraft.textureManager.bindTexture(TEXTURE_STATES); + RenderSystem.enableAlphaTest(); - RenderSystem.enableAlphaTest(); + int uv_x = (this.hideEdge > 0 ? 11 : 13); - int uv_x = ( this.hideEdge > 0 ? 11 : 13 ); + final int offsetX = this.hideEdge > 0 ? 1 : 0; - final int offsetX = this.hideEdge > 0 ? 1 : 0; + blit(this.x, this.y, uv_x * 16, 0, 25, 22); - blit( this.x, this.y, uv_x * 16, 0, 25, 22 ); + if (this.myIcon >= 0) { + final int uv_y = this.myIcon / 16; + uv_x = this.myIcon - uv_y * 16; - if( this.myIcon >= 0 ) - { - final int uv_y = this.myIcon / 16; - uv_x = this.myIcon - uv_y * 16; + blit(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16); + } - blit( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 ); - } + RenderSystem.disableAlphaTest(); - RenderSystem.disableAlphaTest(); + if (this.myItem != null) { + this.itemRenderer.zLevel = 100.0F; - if( this.myItem != null ) - { - this.itemRenderer.zLevel = 100.0F; + RenderHelper.enableStandardItemLighting(); + this.itemRenderer.renderItemAndEffectIntoGUI(this.myItem, offsetX + this.x + 3, this.y + 3); + RenderHelper.disableStandardItemLighting(); - RenderHelper.enableStandardItemLighting(); - this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 ); - RenderHelper.disableStandardItemLighting(); + this.itemRenderer.zLevel = 0.0F; + } + } + } - this.itemRenderer.zLevel = 0.0F; - } - } - } + @Override + public int xPos() { + return this.x; + } - @Override - public int xPos() - { - return this.x; - } + @Override + public int yPos() { + return this.y; + } - @Override - public int yPos() - { - return this.y; - } + @Override + public int getWidth() { + return 22; + } - @Override - public int getWidth() - { - return 22; - } + @Override + public int getHeight() { + return 22; + } - @Override - public int getHeight() - { - return 22; - } + @Override + public boolean isVisible() { + return this.visible; + } - @Override - public boolean isVisible() - { - return this.visible; - } + public int getHideEdge() { + return this.hideEdge; + } - public int getHideEdge() - { - return this.hideEdge; - } - - public void setHideEdge( final int hideEdge ) - { - this.hideEdge = hideEdge; - } + public void setHideEdge(final int hideEdge) { + this.hideEdge = hideEdge; + } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java b/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java index 8e685a0f1..746f7c23b 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java @@ -18,128 +18,112 @@ package appeng.client.gui.widgets; - import java.util.regex.Pattern; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.util.ResourceLocation; import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiToggleButton extends Button implements ITooltip { + public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", + "textures/guis/states.png"); + private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL); + private final int iconIdxOn; + private final int iconIdxOff; -public class GuiToggleButton extends Button implements ITooltip -{ - public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png"); - private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL ); - private final int iconIdxOn; - private final int iconIdxOff; + private final String displayName; + private final String displayHint; - private final String displayName; - private final String displayHint; + private boolean isActive; - private boolean isActive; + public GuiToggleButton(final int x, final int y, final int on, final int off, final String displayName, + final String displayHint, IPressable onPress) { + super(x, y, 16, 16, "", onPress); + this.iconIdxOn = on; + this.iconIdxOff = off; + this.displayName = displayName; + this.displayHint = displayHint; + } - public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint, IPressable onPress ) - { - super( x, y, 16, 16, "", onPress ); - this.iconIdxOn = on; - this.iconIdxOff = off; - this.displayName = displayName; - this.displayHint = displayHint; - } + public void setState(final boolean isOn) { + this.isActive = isOn; + } - public void setState( final boolean isOn ) - { - this.isActive = isOn; - } + @Override + public void renderButton(final int mouseX, final int mouseY, final float partial) { + if (this.visible) { + final int iconIndex = this.getIconIndex(); - @Override - public void renderButton( final int mouseX, final int mouseY, final float partial ) - { - if( this.visible ) - { - final int iconIndex = this.getIconIndex(); + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + Minecraft.getInstance().textureManager.bindTexture(TEXTURE_STATES); - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - Minecraft.getInstance().textureManager.bindTexture( TEXTURE_STATES ); + final int uv_y = iconIndex / 16; + final int uv_x = iconIndex - uv_y * 16; - final int uv_y = iconIndex / 16; - final int uv_x = iconIndex - uv_y * 16; + GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0); + GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0); + } + } - GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 ); - GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 ); - } - } + private int getIconIndex() { + return this.isActive ? this.iconIdxOn : this.iconIdxOff; + } - private int getIconIndex() - { - return this.isActive ? this.iconIdxOn : this.iconIdxOff; - } + @Override + public String getMessage() { + if (this.displayName != null) { + String name = I18n.format(this.displayName); + String value = I18n.format(this.displayHint); - @Override - public String getMessage() - { - if( this.displayName != null ) - { - String name = I18n.format( this.displayName ); - String value = I18n.format( this.displayHint ); + if (name == null || name.isEmpty()) { + name = this.displayName; + } + if (value == null || value.isEmpty()) { + value = this.displayHint; + } - if( name == null || name.isEmpty() ) - { - name = this.displayName; - } - if( value == null || value.isEmpty() ) - { - value = this.displayHint; - } + value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n"); + final StringBuilder sb = new StringBuilder(value); - value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); - final StringBuilder sb = new StringBuilder( value ); + int i = sb.lastIndexOf("\n"); + if (i <= 0) { + i = 0; + } + while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) { + sb.replace(i, i + 1, "\n"); + } - int i = sb.lastIndexOf( "\n" ); - if( i <= 0 ) - { - i = 0; - } - while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) - { - sb.replace( i, i + 1, "\n" ); - } + return name + '\n' + sb; + } + return null; + } - return name + '\n' + sb; - } - return null; - } + @Override + public int xPos() { + return this.x; + } - @Override - public int xPos() - { - return this.x; - } + @Override + public int yPos() { + return this.y; + } - @Override - public int yPos() - { - return this.y; - } + @Override + public int getWidth() { + return 16; + } - @Override - public int getWidth() - { - return 16; - } + @Override + public int getHeight() { + return 16; + } - @Override - public int getHeight() - { - return 16; - } - - @Override - public boolean isVisible() - { - return this.visible; - } + @Override + public boolean isVisible() { + return this.visible; + } } diff --git a/src/main/java/appeng/client/gui/widgets/IScrollSource.java b/src/main/java/appeng/client/gui/widgets/IScrollSource.java index 10829091b..8dc1ddf24 100644 --- a/src/main/java/appeng/client/gui/widgets/IScrollSource.java +++ b/src/main/java/appeng/client/gui/widgets/IScrollSource.java @@ -18,9 +18,7 @@ package appeng.client.gui.widgets; +public interface IScrollSource { -public interface IScrollSource -{ - - int getCurrentScroll(); + int getCurrentScroll(); } diff --git a/src/main/java/appeng/client/gui/widgets/ISortSource.java b/src/main/java/appeng/client/gui/widgets/ISortSource.java index 5a1c14665..d18d77216 100644 --- a/src/main/java/appeng/client/gui/widgets/ISortSource.java +++ b/src/main/java/appeng/client/gui/widgets/ISortSource.java @@ -18,15 +18,14 @@ package appeng.client.gui.widgets; - import appeng.api.config.SortDir; import appeng.api.config.SortOrder; import appeng.api.config.ViewItems; +public interface ISortSource { + SortOrder getSortBy(); -public interface ISortSource -{ - SortOrder getSortBy(); - SortDir getSortDir(); - ViewItems getSortDisplay(); + SortDir getSortDir(); + + ViewItems getSortDisplay(); } diff --git a/src/main/java/appeng/client/gui/widgets/ITooltip.java b/src/main/java/appeng/client/gui/widgets/ITooltip.java index 232992ac6..73ef0821c 100644 --- a/src/main/java/appeng/client/gui/widgets/ITooltip.java +++ b/src/main/java/appeng/client/gui/widgets/ITooltip.java @@ -18,50 +18,48 @@ package appeng.client.gui.widgets; - /** * AEBaseGui controlled Tooltip Interface. */ -public interface ITooltip -{ +public interface ITooltip { - /** - * returns the tooltip message. - * - * @return tooltip message - */ - String getMessage(); + /** + * returns the tooltip message. + * + * @return tooltip message + */ + String getMessage(); - /** - * x Location for the object that triggers the tooltip. - * - * @return xPosition - */ - int xPos(); + /** + * x Location for the object that triggers the tooltip. + * + * @return xPosition + */ + int xPos(); - /** - * y Location for the object that triggers the tooltip. - * - * @return yPosition - */ - int yPos(); + /** + * y Location for the object that triggers the tooltip. + * + * @return yPosition + */ + int yPos(); - /** - * Width of the object that triggers the tooltip. - * - * @return width - */ - int getWidth(); + /** + * Width of the object that triggers the tooltip. + * + * @return width + */ + int getWidth(); - /** - * Height for the object that triggers the tooltip. - * - * @return height - */ - int getHeight(); + /** + * Height for the object that triggers the tooltip. + * + * @return height + */ + int getHeight(); - /** - * @return true if button being drawn - */ - boolean isVisible(); + /** + * @return true if button being drawn + */ + boolean isVisible(); } diff --git a/src/main/java/appeng/client/gui/widgets/MEGuiTextField.java b/src/main/java/appeng/client/gui/widgets/MEGuiTextField.java index cd2147175..618aa3870 100644 --- a/src/main/java/appeng/client/gui/widgets/MEGuiTextField.java +++ b/src/main/java/appeng/client/gui/widgets/MEGuiTextField.java @@ -18,152 +18,135 @@ package appeng.client.gui.widgets; - import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; - /** - * A modified version of the Minecraft text field. - * You can initialize it over the full element span. - * The mouse click area is increased to the full element + * A modified version of the Minecraft text field. You can initialize it over + * the full element span. The mouse click area is increased to the full element * subtracted with the defined padding. * * The rendering does pay attention to the size of the '_' caret. */ -public class MEGuiTextField extends TextFieldWidget -{ - private static final int PADDING = 2; +public class MEGuiTextField extends TextFieldWidget { + private static final int PADDING = 2; - private final int _fontPad; - private int selectionColor = 0xFF00FF00; + private final int _fontPad; + private int selectionColor = 0xFF00FF00; - /** - * Uses the values to instantiate a padded version of a text field. - * Pays attention to the '_' caret. - * - * @param fontRenderer renderer for the strings - * @param xPos absolute left position - * @param yPos absolute top position - * @param width absolute width - * @param height absolute height - */ - public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height ) - { - super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth( '_' ), height - 2 * PADDING, "" ); + /** + * Uses the values to instantiate a padded version of a text field. Pays + * attention to the '_' caret. + * + * @param fontRenderer renderer for the strings + * @param xPos absolute left position + * @param yPos absolute top position + * @param width absolute width + * @param height absolute height + */ + public MEGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, + final int height) { + super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth('_'), + height - 2 * PADDING, ""); - this._fontPad = (int) fontRenderer.getCharWidth( '_' ); - } + this._fontPad = (int) fontRenderer.getCharWidth('_'); + } - @Override - public boolean mouseClicked( final double xPos, final double yPos, final int button ) - { - if (!super.mouseClicked( xPos, yPos, button )) { - return false; - } + @Override + public boolean mouseClicked(final double xPos, final double yPos, final int button) { + if (!super.mouseClicked(xPos, yPos, button)) { + return false; + } - final boolean requiresFocus = this.isMouseOver( xPos, yPos ); - if( !this.isFocused() ) - { - this.setFocused2( requiresFocus ); - } + final boolean requiresFocus = this.isMouseOver(xPos, yPos); + if (!this.isFocused()) { + this.setFocused2(requiresFocus); + } - return true; - } + return true; + } - public void selectAll() - { - this.setCursorPosition( 0 ); - this.setSelectionPos( this.getMaxStringLength() ); - } + public void selectAll() { + this.setCursorPosition(0); + this.setSelectionPos(this.getMaxStringLength()); + } - public void setSelectionColor( int color ) - { - this.selectionColor = color; - } + public void setSelectionColor(int color) { + this.selectionColor = color; + } - @Override - public void renderButton(int mouseX, int mouseY, float partial) - { - if( this.getVisible() ) - { - if( this.isFocused() ) - { - fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1, - 0xFF606060 ); - } - else - { - fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1, - 0xFFA8A8A8 ); - } - super.renderButton(mouseX, mouseY, partial); - } - } + @Override + public void renderButton(int mouseX, int mouseY, float partial) { + if (this.getVisible()) { + if (this.isFocused()) { + fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, + this.y + this.height + PADDING - 1, 0xFF606060); + } else { + fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, + this.y + this.height + PADDING - 1, 0xFFA8A8A8); + } + super.renderButton(mouseX, mouseY, partial); + } + } - @Override - public void drawSelectionBox( int startX, int startY, int endX, int endY ) - { - if( !this.isFocused() ) - { - return; - } + @Override + public void drawSelectionBox(int startX, int startY, int endX, int endY) { + if (!this.isFocused()) { + return; + } - if( startX < endX ) - { - int i = startX; - startX = endX; - endX = i; - } + if (startX < endX) { + int i = startX; + startX = endX; + endX = i; + } - startX += 1; - endX -= 1; + startX += 1; + endX -= 1; - if( startY < endY ) - { - int j = startY; - startY = endY; - endY = j; - } + if (startY < endY) { + int j = startY; + startY = endY; + endY = j; + } - startY -= PADDING; + startY -= PADDING; - if( endX > this.x + this.width ) - { - endX = this.x + this.width; - } + if (endX > this.x + this.width) { + endX = this.x + this.width; + } - if( startX > this.x + this.width ) - { - startX = this.x + this.width; - } + if (startX > this.x + this.width) { + startX = this.x + this.width; + } - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferbuilder = tessellator.getBuffer(); - float red = ( this.selectionColor >> 16 & 255 ) / 255.0F; - float blue = ( this.selectionColor >> 8 & 255 ) / 255.0F; - float green = ( this.selectionColor & 255 ) / 255.0F; - float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F; + float red = (this.selectionColor >> 16 & 255) / 255.0F; + float blue = (this.selectionColor >> 8 & 255) / 255.0F; + float green = (this.selectionColor & 255) / 255.0F; + float alpha = (this.selectionColor >> 24 & 255) / 255.0F; - RenderSystem.color4f( red, green, blue, alpha ); - RenderSystem.disableTexture(); - RenderSystem.enableColorLogicOp(); - RenderSystem.logicOp( GlStateManager.LogicOp.OR_REVERSE ); - bufferbuilder.begin( 7, DefaultVertexFormats.POSITION ); - bufferbuilder.pos( startX, endY, 0.0D ).endVertex(); - bufferbuilder.pos( endX, endY, 0.0D ).endVertex(); - bufferbuilder.pos( endX, startY, 0.0D ).endVertex(); - bufferbuilder.pos( startX, startY, 0.0D ).endVertex(); - tessellator.draw(); - RenderSystem.disableColorLogicOp(); - RenderSystem.enableTexture(); - RenderSystem.color4f( 1, 1, 1, 1 ); - } + RenderSystem.color4f(red, green, blue, alpha); + RenderSystem.disableTexture(); + RenderSystem.enableColorLogicOp(); + RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE); + bufferbuilder.begin(7, DefaultVertexFormats.POSITION); + bufferbuilder.pos(startX, endY, 0.0D).endVertex(); + bufferbuilder.pos(endX, endY, 0.0D).endVertex(); + bufferbuilder.pos(endX, startY, 0.0D).endVertex(); + bufferbuilder.pos(startX, startY, 0.0D).endVertex(); + tessellator.draw(); + RenderSystem.disableColorLogicOp(); + RenderSystem.enableTexture(); + RenderSystem.color4f(1, 1, 1, 1); + } } diff --git a/src/main/java/appeng/client/me/ClientDCInternalInv.java b/src/main/java/appeng/client/me/ClientDCInternalInv.java index 3ffa9d8b5..3562e11d1 100644 --- a/src/main/java/appeng/client/me/ClientDCInternalInv.java +++ b/src/main/java/appeng/client/me/ClientDCInternalInv.java @@ -18,54 +18,45 @@ package appeng.client.me; - import javax.annotation.Nonnull; import net.minecraft.client.resources.I18n; import appeng.tile.inventory.AppEngInternalInventory; +public class ClientDCInternalInv implements Comparable { -public class ClientDCInternalInv implements Comparable -{ + private final String unlocalizedName; + private final AppEngInternalInventory inventory; - private final String unlocalizedName; - private final AppEngInternalInventory inventory; + private final long id; + private final long sortBy; - private final long id; - private final long sortBy; + public ClientDCInternalInv(final int size, final long id, final long sortBy, final String unlocalizedName) { + this.inventory = new AppEngInternalInventory(null, size); + this.unlocalizedName = unlocalizedName; + this.id = id; + this.sortBy = sortBy; + } - public ClientDCInternalInv( final int size, final long id, final long sortBy, final String unlocalizedName ) - { - this.inventory = new AppEngInternalInventory( null, size ); - this.unlocalizedName = unlocalizedName; - this.id = id; - this.sortBy = sortBy; - } + public String getName() { + final String s = I18n.format(this.unlocalizedName + ".name"); + if (s.equals(this.unlocalizedName + ".name")) { + return I18n.format(this.unlocalizedName); + } + return s; + } - public String getName() - { - final String s = I18n.format( this.unlocalizedName + ".name" ); - if( s.equals( this.unlocalizedName + ".name" ) ) - { - return I18n.format( this.unlocalizedName ); - } - return s; - } + @Override + public int compareTo(@Nonnull final ClientDCInternalInv o) { + return Long.compare(this.sortBy, o.sortBy); + } - @Override - public int compareTo( @Nonnull final ClientDCInternalInv o ) - { - return Long.compare( this.sortBy, o.sortBy ); - } + public AppEngInternalInventory getInventory() { + return this.inventory; + } - public AppEngInternalInventory getInventory() - { - return this.inventory; - } - - public long getId() - { - return this.id; - } + public long getId() { + return this.id; + } } diff --git a/src/main/java/appeng/client/me/FluidRepo.java b/src/main/java/appeng/client/me/FluidRepo.java index 40bfdec15..48933cf0c 100644 --- a/src/main/java/appeng/client/me/FluidRepo.java +++ b/src/main/java/appeng/client/me/FluidRepo.java @@ -18,7 +18,6 @@ package appeng.client.me; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -26,6 +25,8 @@ import java.util.regex.Pattern; import javax.annotation.Nonnull; +import net.minecraft.util.text.ITextComponent; + import appeng.api.AEApi; import appeng.api.config.Settings; import appeng.api.config.SortOrder; @@ -40,205 +41,166 @@ import appeng.core.AEConfig; import appeng.fluids.util.FluidSorters; import appeng.util.Platform; import appeng.util.prioritylist.IPartitionList; -import net.minecraft.util.text.ITextComponent; - /** * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class FluidRepo -{ - private final IItemList list = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); - private final ArrayList view = new ArrayList<>(); - private final IScrollSource src; - private final ISortSource sortSrc; +public class FluidRepo { + private final IItemList list = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createList(); + private final ArrayList view = new ArrayList<>(); + private final IScrollSource src; + private final ISortSource sortSrc; - private int rowSize = 9; + private int rowSize = 9; - private String searchString = ""; - private IPartitionList myPartitionList; - private boolean hasPower; + private String searchString = ""; + private IPartitionList myPartitionList; + private boolean hasPower; - public FluidRepo( final IScrollSource src, final ISortSource sortSrc ) - { - this.src = src; - this.sortSrc = sortSrc; - } + public FluidRepo(final IScrollSource src, final ISortSource sortSrc) { + this.src = src; + this.sortSrc = sortSrc; + } - public void updateView() - { - this.view.clear(); + public void updateView() { + this.view.clear(); - this.view.ensureCapacity( this.list.size() ); + this.view.ensureCapacity(this.list.size()); - String innerSearch = this.searchString; + String innerSearch = this.searchString; - boolean searchMod = false; - if( innerSearch.startsWith( "@" ) ) - { - searchMod = true; - innerSearch = innerSearch.substring( 1 ); - } + boolean searchMod = false; + if (innerSearch.startsWith("@")) { + searchMod = true; + innerSearch = innerSearch.substring(1); + } - Pattern m; - try - { - m = Pattern.compile( innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE ); - } - catch( final Exception ignore1 ) - { - try - { - m = Pattern.compile( Pattern.quote( innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE ); - } - catch( final Exception ignore2 ) - { - return; - } - } + Pattern m; + try { + m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE); + } catch (final Exception ignore1) { + try { + m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE); + } catch (final Exception ignore2) { + return; + } + } - final Enum viewMode = this.sortSrc.getSortDisplay(); - final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE; - final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO; + final Enum viewMode = this.sortSrc.getSortDisplay(); + final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE; + final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager() + .getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO; - boolean notDone = false; - for( IAEFluidStack fs : this.list ) - { - if( this.myPartitionList != null && !this.myPartitionList.isListed( fs ) ) - { - continue; - } + boolean notDone = false; + for (IAEFluidStack fs : this.list) { + if (this.myPartitionList != null && !this.myPartitionList.isListed(fs)) { + continue; + } - if( viewMode == ViewItems.CRAFTABLE && !fs.isCraftable() ) - { - continue; - } + if (viewMode == ViewItems.CRAFTABLE && !fs.isCraftable()) { + continue; + } - if( viewMode == ViewItems.STORED && fs.getStackSize() == 0 ) - { - continue; - } + if (viewMode == ViewItems.STORED && fs.getStackSize() == 0) { + continue; + } - final String dspName = searchMod ? Platform.getModId( fs ) : Platform.getFluidDisplayName( fs ).getString(); - boolean foundMatchingFluidStack = false; - notDone = true; + final String dspName = searchMod ? Platform.getModId(fs) : Platform.getFluidDisplayName(fs).getString(); + boolean foundMatchingFluidStack = false; + notDone = true; - if( m.matcher( dspName.toLowerCase() ).find() ) - { - notDone = false; - foundMatchingFluidStack = true; - } + if (m.matcher(dspName.toLowerCase()).find()) { + notDone = false; + foundMatchingFluidStack = true; + } - if( terminalSearchToolTips && notDone && !searchMod ) - { - final List tooltip = Platform.getTooltip( fs ); + if (terminalSearchToolTips && notDone && !searchMod) { + final List tooltip = Platform.getTooltip(fs); - for( final ITextComponent line : tooltip ) - { - if( m.matcher( line.getString() ).find() ) - { - foundMatchingFluidStack = true; - break; - } - } - } + for (final ITextComponent line : tooltip) { + if (m.matcher(line.getString()).find()) { + foundMatchingFluidStack = true; + break; + } + } + } - if( foundMatchingFluidStack ) - { - if( needsZeroCopy ) - { - fs = fs.copy(); - fs.setStackSize( 0 ); - } + if (foundMatchingFluidStack) { + if (needsZeroCopy) { + fs = fs.copy(); + fs.setStackSize(0); + } - this.view.add( fs ); - } - } + this.view.add(fs); + } + } - final Enum sortBy = this.sortSrc.getSortBy(); - final Enum sortDir = this.sortSrc.getSortDir(); + final Enum sortBy = this.sortSrc.getSortBy(); + final Enum sortDir = this.sortSrc.getSortDir(); - FluidSorters.setDirection( (appeng.api.config.SortDir) sortDir ); + FluidSorters.setDirection((appeng.api.config.SortDir) sortDir); - if( sortBy == SortOrder.MOD ) - { - Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD ); - } - else if( sortBy == SortOrder.AMOUNT ) - { - Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE ); - } - else - { - Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME ); - } - } + if (sortBy == SortOrder.MOD) { + Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD); + } else if (sortBy == SortOrder.AMOUNT) { + Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE); + } else { + Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME); + } + } - public void postUpdate( final IAEFluidStack is ) - { - final IAEFluidStack st = this.list.findPrecise( is ); + public void postUpdate(final IAEFluidStack is) { + final IAEFluidStack st = this.list.findPrecise(is); - if( st != null ) - { - st.reset(); - st.add( is ); - } - else - { - this.list.add( is ); - } - } + if (st != null) { + st.reset(); + st.add(is); + } else { + this.list.add(is); + } + } - public IAEFluidStack getReferenceFluid( int idx ) - { - idx += this.src.getCurrentScroll() * this.rowSize; + public IAEFluidStack getReferenceFluid(int idx) { + idx += this.src.getCurrentScroll() * this.rowSize; - if( idx >= this.view.size() ) - { - return null; - } - return this.view.get( idx ); - } + if (idx >= this.view.size()) { + return null; + } + return this.view.get(idx); + } - public int size() - { - return this.view.size(); - } + public int size() { + return this.view.size(); + } - public void clear() - { - this.list.resetStatus(); - } + public void clear() { + this.list.resetStatus(); + } - public boolean hasPower() - { - return this.hasPower; - } + public boolean hasPower() { + return this.hasPower; + } - public void setPower( final boolean hasPower ) - { - this.hasPower = hasPower; - } + public void setPower(final boolean hasPower) { + this.hasPower = hasPower; + } - public int getRowSize() - { - return this.rowSize; - } + public int getRowSize() { + return this.rowSize; + } - public void setRowSize( final int rowSize ) - { - this.rowSize = rowSize; - } + public void setRowSize(final int rowSize) { + this.rowSize = rowSize; + } - public String getSearchString() - { - return this.searchString; - } + public String getSearchString() { + return this.searchString; + } - public void setSearchString( @Nonnull final String searchString ) - { - this.searchString = searchString; - } + public void setSearchString(@Nonnull final String searchString) { + this.searchString = searchString; + } } diff --git a/src/main/java/appeng/client/me/InternalFluidSlotME.java b/src/main/java/appeng/client/me/InternalFluidSlotME.java index eeec2b53a..531c18f7c 100644 --- a/src/main/java/appeng/client/me/InternalFluidSlotME.java +++ b/src/main/java/appeng/client/me/InternalFluidSlotME.java @@ -18,48 +18,40 @@ package appeng.client.me; - import appeng.api.storage.data.IAEFluidStack; - /** * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class InternalFluidSlotME -{ +public class InternalFluidSlotME { - private final int offset; - private final int xPos; - private final int yPos; - private final FluidRepo repo; + private final int offset; + private final int xPos; + private final int yPos; + private final FluidRepo repo; - public InternalFluidSlotME( final FluidRepo def, final int offset, final int displayX, final int displayY ) - { - this.repo = def; - this.offset = offset; - this.xPos = displayX; - this.yPos = displayY; - } + public InternalFluidSlotME(final FluidRepo def, final int offset, final int displayX, final int displayY) { + this.repo = def; + this.offset = offset; + this.xPos = displayX; + this.yPos = displayY; + } - IAEFluidStack getAEStack() - { - return this.repo.getReferenceFluid( this.offset ); - } + IAEFluidStack getAEStack() { + return this.repo.getReferenceFluid(this.offset); + } - boolean hasPower() - { - return this.repo.hasPower(); - } + boolean hasPower() { + return this.repo.hasPower(); + } - int getxPosition() - { - return this.xPos; - } + int getxPosition() { + return this.xPos; + } - int getyPosition() - { - return this.yPos; - } + int getyPosition() { + return this.yPos; + } } diff --git a/src/main/java/appeng/client/me/InternalSlotME.java b/src/main/java/appeng/client/me/InternalSlotME.java index efbfb8448..a2a6c5980 100644 --- a/src/main/java/appeng/client/me/InternalSlotME.java +++ b/src/main/java/appeng/client/me/InternalSlotME.java @@ -18,50 +18,41 @@ package appeng.client.me; - import net.minecraft.item.ItemStack; import appeng.api.storage.data.IAEItemStack; +public class InternalSlotME { -public class InternalSlotME -{ + private final int offset; + private final int xPos; + private final int yPos; + private final ItemRepo repo; - private final int offset; - private final int xPos; - private final int yPos; - private final ItemRepo repo; + public InternalSlotME(final ItemRepo def, final int offset, final int displayX, final int displayY) { + this.repo = def; + this.offset = offset; + this.xPos = displayX; + this.yPos = displayY; + } - public InternalSlotME( final ItemRepo def, final int offset, final int displayX, final int displayY ) - { - this.repo = def; - this.offset = offset; - this.xPos = displayX; - this.yPos = displayY; - } + ItemStack getStack() { + return this.getAEStack() == null ? ItemStack.EMPTY : this.getAEStack().asItemStackRepresentation(); + } - ItemStack getStack() - { - return this.getAEStack() == null ? ItemStack.EMPTY : this.getAEStack().asItemStackRepresentation(); - } + IAEItemStack getAEStack() { + return this.repo.getReferenceItem(this.offset); + } - IAEItemStack getAEStack() - { - return this.repo.getReferenceItem( this.offset ); - } + boolean hasPower() { + return this.repo.hasPower(); + } - boolean hasPower() - { - return this.repo.hasPower(); - } + int getxPosition() { + return this.xPos; + } - int getxPosition() - { - return this.xPos; - } - - int getyPosition() - { - return this.yPos; - } + int getyPosition() { + return this.yPos; + } } diff --git a/src/main/java/appeng/client/me/ItemRepo.java b/src/main/java/appeng/client/me/ItemRepo.java index 12b949e07..ca44663fd 100644 --- a/src/main/java/appeng/client/me/ItemRepo.java +++ b/src/main/java/appeng/client/me/ItemRepo.java @@ -18,7 +18,6 @@ package appeng.client.me; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -26,8 +25,8 @@ import java.util.regex.Pattern; import javax.annotation.Nonnull; -import appeng.integration.abstraction.JEIFacade; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; import appeng.api.AEApi; import appeng.api.config.SearchBoxMode; @@ -41,237 +40,194 @@ import appeng.api.storage.data.IItemList; import appeng.client.gui.widgets.IScrollSource; import appeng.client.gui.widgets.ISortSource; import appeng.core.AEConfig; +import appeng.integration.abstraction.JEIFacade; import appeng.items.storage.ItemViewCell; import appeng.util.ItemSorters; import appeng.util.Platform; import appeng.util.prioritylist.IPartitionList; -import net.minecraft.util.text.ITextComponent; +public class ItemRepo { -public class ItemRepo -{ + private final IItemList list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private final ArrayList view = new ArrayList<>(); + private final IScrollSource src; + private final ISortSource sortSrc; - private final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final ArrayList view = new ArrayList<>(); - private final IScrollSource src; - private final ISortSource sortSrc; + private int rowSize = 9; - private int rowSize = 9; + private String searchString = ""; + private IPartitionList myPartitionList; + private String innerSearch = ""; + private boolean hasPower; - private String searchString = ""; - private IPartitionList myPartitionList; - private String innerSearch = ""; - private boolean hasPower; + public ItemRepo(final IScrollSource src, final ISortSource sortSrc) { + this.src = src; + this.sortSrc = sortSrc; + } - public ItemRepo( final IScrollSource src, final ISortSource sortSrc ) - { - this.src = src; - this.sortSrc = sortSrc; - } + public IAEItemStack getReferenceItem(int idx) { + idx += this.src.getCurrentScroll() * this.rowSize; - public IAEItemStack getReferenceItem( int idx ) - { - idx += this.src.getCurrentScroll() * this.rowSize; + if (idx >= this.view.size()) { + return null; + } + return this.view.get(idx); + } - if( idx >= this.view.size() ) - { - return null; - } - return this.view.get( idx ); - } + void setSearch(final String search) { + this.searchString = search == null ? "" : search; + } - void setSearch( final String search ) - { - this.searchString = search == null ? "" : search; - } + public void postUpdate(final IAEItemStack is) { + final IAEItemStack st = this.list.findPrecise(is); - public void postUpdate( final IAEItemStack is ) - { - final IAEItemStack st = this.list.findPrecise( is ); + if (st != null) { + st.reset(); + st.add(is); + } else { + this.list.add(is); + } + } - if( st != null ) - { - st.reset(); - st.add( is ); - } - else - { - this.list.add( is ); - } - } + public void setViewCell(final ItemStack[] list) { + this.myPartitionList = ItemViewCell.createFilter(list); + this.updateView(); + } - public void setViewCell( final ItemStack[] list ) - { - this.myPartitionList = ItemViewCell.createFilter( list ); - this.updateView(); - } + public void updateView() { + this.view.clear(); - public void updateView() - { - this.view.clear(); + this.view.ensureCapacity(this.list.size()); - this.view.ensureCapacity( this.list.size() ); + final Enum viewMode = this.sortSrc.getSortDisplay(); + final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE); + final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE; - final Enum viewMode = this.sortSrc.getSortDisplay(); - final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE ); - final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE; + if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH + || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP + || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) { + this.updateJEI(this.searchString); + } - if( searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP ) - { - this.updateJEI( this.searchString ); - } + this.innerSearch = this.searchString; + final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager() + .getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO; - this.innerSearch = this.searchString; - final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO; + boolean searchMod = false; + if (this.innerSearch.startsWith("@")) { + searchMod = true; + this.innerSearch = this.innerSearch.substring(1); + } - boolean searchMod = false; - if( this.innerSearch.startsWith( "@" ) ) - { - searchMod = true; - this.innerSearch = this.innerSearch.substring( 1 ); - } + Pattern m = null; + try { + m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE); + } catch (final Throwable ignore) { + try { + m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE); + } catch (final Throwable __) { + return; + } + } - Pattern m = null; - try - { - m = Pattern.compile( this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE ); - } - catch( final Throwable ignore ) - { - try - { - m = Pattern.compile( Pattern.quote( this.innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE ); - } - catch( final Throwable __ ) - { - return; - } - } + boolean notDone = false; + for (IAEItemStack is : this.list) { + if (this.myPartitionList != null) { + if (!this.myPartitionList.isListed(is)) { + continue; + } + } - boolean notDone = false; - for( IAEItemStack is : this.list ) - { - if( this.myPartitionList != null ) - { - if( !this.myPartitionList.isListed( is ) ) - { - continue; - } - } + if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) { + continue; + } - if( viewMode == ViewItems.CRAFTABLE && !is.isCraftable() ) - { - continue; - } + if (viewMode == ViewItems.STORED && is.getStackSize() == 0) { + continue; + } - if( viewMode == ViewItems.STORED && is.getStackSize() == 0 ) - { - continue; - } + final String dspName = searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is).getString(); + boolean foundMatchingItemStack = false; + notDone = true; - final String dspName = searchMod ? Platform.getModId( is ) : Platform.getItemDisplayName( is ).getString(); - boolean foundMatchingItemStack = false; - notDone = true; + if (m.matcher(dspName.toLowerCase()).find()) { + notDone = false; + foundMatchingItemStack = true; + } - if( m.matcher( dspName.toLowerCase() ).find() ) - { - notDone = false; - foundMatchingItemStack = true; - } + if (terminalSearchToolTips && notDone && !searchMod) { + final List tooltip = Platform.getTooltip(is); - if( terminalSearchToolTips && notDone && !searchMod ) - { - final List tooltip = Platform.getTooltip( is ); + for (final ITextComponent line : tooltip) { + if (m.matcher(line.getString()).find()) { + foundMatchingItemStack = true; + notDone = false; + break; + } + } + } - for( final ITextComponent line : tooltip ) - { - if( m.matcher( line.getString() ).find() ) - { - foundMatchingItemStack = true; - notDone = false; - break; - } - } - } + if (foundMatchingItemStack) { + if (needsZeroCopy) { + is = is.copy(); + is.setStackSize(0); + } - if( foundMatchingItemStack ) - { - if( needsZeroCopy ) - { - is = is.copy(); - is.setStackSize( 0 ); - } + this.view.add(is); + } + } - this.view.add( is ); - } - } + final Enum SortBy = this.sortSrc.getSortBy(); + final Enum SortDir = this.sortSrc.getSortDir(); - final Enum SortBy = this.sortSrc.getSortBy(); - final Enum SortDir = this.sortSrc.getSortDir(); + ItemSorters.setDirection((appeng.api.config.SortDir) SortDir); + ItemSorters.init(); - ItemSorters.setDirection( (appeng.api.config.SortDir) SortDir ); - ItemSorters.init(); + if (SortBy == SortOrder.MOD) { + Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD); + } else if (SortBy == SortOrder.AMOUNT) { + Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE); + } else if (SortBy == SortOrder.INVTWEAKS) { + Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS); + } else { + Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME); + } + } - if( SortBy == SortOrder.MOD ) - { - Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD ); - } - else if( SortBy == SortOrder.AMOUNT ) - { - Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE ); - } - else if( SortBy == SortOrder.INVTWEAKS ) - { - Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS ); - } - else - { - Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME ); - } - } + private void updateJEI(String filter) { + JEIFacade.instance().setSearchText(filter); + } - private void updateJEI( String filter ) - { - JEIFacade.instance().setSearchText( filter ); - } + public int size() { + return this.view.size(); + } - public int size() - { - return this.view.size(); - } + public void clear() { + this.list.resetStatus(); + } - public void clear() - { - this.list.resetStatus(); - } + public boolean hasPower() { + return this.hasPower; + } - public boolean hasPower() - { - return this.hasPower; - } + public void setPower(final boolean hasPower) { + this.hasPower = hasPower; + } - public void setPower( final boolean hasPower ) - { - this.hasPower = hasPower; - } + public int getRowSize() { + return this.rowSize; + } - public int getRowSize() - { - return this.rowSize; - } + public void setRowSize(final int rowSize) { + this.rowSize = rowSize; + } - public void setRowSize( final int rowSize ) - { - this.rowSize = rowSize; - } + public String getSearchString() { + return this.searchString; + } - public String getSearchString() - { - return this.searchString; - } - - public void setSearchString( @Nonnull final String searchString ) - { - this.searchString = searchString; - } + public void setSearchString(@Nonnull final String searchString) { + this.searchString = searchString; + } } diff --git a/src/main/java/appeng/client/me/SlotDisconnected.java b/src/main/java/appeng/client/me/SlotDisconnected.java index 96cde88e6..25d3896ba 100644 --- a/src/main/java/appeng/client/me/SlotDisconnected.java +++ b/src/main/java/appeng/client/me/SlotDisconnected.java @@ -18,84 +18,69 @@ package appeng.client.me; - -import appeng.items.misc.ItemEncodedPattern; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import appeng.container.slot.AppEngSlot; +import appeng.items.misc.ItemEncodedPattern; import appeng.util.Platform; +public class SlotDisconnected extends AppEngSlot { -public class SlotDisconnected extends AppEngSlot -{ + private final ClientDCInternalInv mySlot; - private final ClientDCInternalInv mySlot; + public SlotDisconnected(final ClientDCInternalInv me, final int which, final int x, final int y) { + super(me.getInventory(), which, x, y); + this.mySlot = me; + } - public SlotDisconnected( final ClientDCInternalInv me, final int which, final int x, final int y ) - { - super( me.getInventory(), which, x, y ); - this.mySlot = me; - } + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } + @Override + public void putStack(final ItemStack par1ItemStack) { - @Override - public void putStack( final ItemStack par1ItemStack ) - { + } - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public ItemStack getDisplayStack() { + if (Platform.isClient()) { + final ItemStack is = super.getStack(); + if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) { + final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); + final ItemStack out = iep.getOutput(is); + if (!out.isEmpty()) { + return out; + } + } + } + return super.getStack(); + } - @Override - public ItemStack getDisplayStack() - { - if( Platform.isClient() ) - { - final ItemStack is = super.getStack(); - if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) - { - final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - final ItemStack out = iep.getOutput( is ); - if( !out.isEmpty() ) - { - return out; - } - } - } - return super.getStack(); - } + @Override + public boolean getHasStack() { + return !this.getStack().isEmpty(); + } - @Override - public boolean getHasStack() - { - return !this.getStack().isEmpty(); - } + @Override + public int getSlotStackLimit() { + return 0; + } - @Override - public int getSlotStackLimit() - { - return 0; - } + @Override + public ItemStack decrStackSize(final int par1) { + return ItemStack.EMPTY; + } - @Override - public ItemStack decrStackSize( final int par1 ) - { - return ItemStack.EMPTY; - } - - public ClientDCInternalInv getSlot() - { - return this.mySlot; - } + public ClientDCInternalInv getSlot() { + return this.mySlot; + } } diff --git a/src/main/java/appeng/client/me/SlotFluidME.java b/src/main/java/appeng/client/me/SlotFluidME.java index ca86fc80c..d771d8700 100644 --- a/src/main/java/appeng/client/me/SlotFluidME.java +++ b/src/main/java/appeng/client/me/SlotFluidME.java @@ -1,106 +1,92 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.client.me; - - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraftforge.items.SlotItemHandler; - -import appeng.api.storage.data.IAEFluidStack; -import appeng.fluids.container.slots.IMEFluidSlot; - - -/** - * @author BrockWS - * @version rv6 - 22/05/2018 - * @since rv6 22/05/2018 - */ -public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot -{ - - private InternalFluidSlotME slot; - - public SlotFluidME( InternalFluidSlotME slot ) - { - super( null, 0, slot.getxPosition(), slot.getyPosition() ); - this.slot = slot; - } - - @Override - public IAEFluidStack getAEFluidStack() - { - if( this.slot.hasPower() ) - { - return this.slot.getAEStack(); - } - return null; - } - - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } - - @Nonnull - @Override - public ItemStack getStack() - { - return ItemStack.EMPTY; - } - - @Override - public boolean getHasStack() - { - if( this.slot.hasPower() ) - { - return this.getAEFluidStack() != null; - } - return false; - } - - @Override - public void putStack( final ItemStack par1ItemStack ) - { - - } - - @Override - public int getSlotStackLimit() - { - return 0; - } - - @Nonnull - @Override - public ItemStack decrStackSize( final int par1 ) - { - return ItemStack.EMPTY; - } - - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.client.me; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.SlotItemHandler; + +import appeng.api.storage.data.IAEFluidStack; +import appeng.fluids.container.slots.IMEFluidSlot; + +/** + * @author BrockWS + * @version rv6 - 22/05/2018 + * @since rv6 22/05/2018 + */ +public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot { + + private InternalFluidSlotME slot; + + public SlotFluidME(InternalFluidSlotME slot) { + super(null, 0, slot.getxPosition(), slot.getyPosition()); + this.slot = slot; + } + + @Override + public IAEFluidStack getAEFluidStack() { + if (this.slot.hasPower()) { + return this.slot.getAEStack(); + } + return null; + } + + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } + + @Nonnull + @Override + public ItemStack getStack() { + return ItemStack.EMPTY; + } + + @Override + public boolean getHasStack() { + if (this.slot.hasPower()) { + return this.getAEFluidStack() != null; + } + return false; + } + + @Override + public void putStack(final ItemStack par1ItemStack) { + + } + + @Override + public int getSlotStackLimit() { + return 0; + } + + @Nonnull + @Override + public ItemStack decrStackSize(final int par1) { + return ItemStack.EMPTY; + } + + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } +} diff --git a/src/main/java/appeng/client/me/SlotME.java b/src/main/java/appeng/client/me/SlotME.java index 15c6cfcb7..b8beaa302 100644 --- a/src/main/java/appeng/client/me/SlotME.java +++ b/src/main/java/appeng/client/me/SlotME.java @@ -18,7 +18,6 @@ package appeng.client.me; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -26,74 +25,60 @@ import net.minecraftforge.items.SlotItemHandler; import appeng.api.storage.data.IAEItemStack; +public class SlotME extends SlotItemHandler { -public class SlotME extends SlotItemHandler -{ + private final InternalSlotME mySlot; - private final InternalSlotME mySlot; + public SlotME(final InternalSlotME me) { + super(null, 0, me.getxPosition(), me.getyPosition()); + this.mySlot = me; + } - public SlotME( final InternalSlotME me ) - { - super( null, 0, me.getxPosition(), me.getyPosition() ); - this.mySlot = me; - } + public IAEItemStack getAEStack() { + if (this.mySlot.hasPower()) { + return this.mySlot.getAEStack(); + } + return null; + } - public IAEItemStack getAEStack() - { - if( this.mySlot.hasPower() ) - { - return this.mySlot.getAEStack(); - } - return null; - } + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } + @Override + public ItemStack getStack() { + if (this.mySlot.hasPower()) { + return this.mySlot.getStack(); + } + return ItemStack.EMPTY; + } - @Override - public ItemStack getStack() - { - if( this.mySlot.hasPower() ) - { - return this.mySlot.getStack(); - } - return ItemStack.EMPTY; - } + @Override + public boolean getHasStack() { + if (this.mySlot.hasPower()) { + return !this.getStack().isEmpty(); + } + return false; + } - @Override - public boolean getHasStack() - { - if( this.mySlot.hasPower() ) - { - return !this.getStack().isEmpty(); - } - return false; - } + @Override + public void putStack(final ItemStack par1ItemStack) { - @Override - public void putStack( final ItemStack par1ItemStack ) - { + } - } + @Override + public int getSlotStackLimit() { + return 0; + } - @Override - public int getSlotStackLimit() - { - return 0; - } + @Override + public ItemStack decrStackSize(final int par1) { + return ItemStack.EMPTY; + } - @Override - public ItemStack decrStackSize( final int par1 ) - { - return ItemStack.EMPTY; - } - - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } } diff --git a/src/main/java/appeng/client/render/ColorableTileBlockColor.java b/src/main/java/appeng/client/render/ColorableTileBlockColor.java index 992833f04..04a386cc3 100644 --- a/src/main/java/appeng/client/render/ColorableTileBlockColor.java +++ b/src/main/java/appeng/client/render/ColorableTileBlockColor.java @@ -18,7 +18,6 @@ package appeng.client.render; - import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -31,29 +30,24 @@ import net.minecraft.world.ILightReader; import appeng.api.implementations.tiles.IColorableTile; import appeng.api.util.AEColor; - /** * Automatically exposes the color of a colorable tile using tint indices 0-2 */ -public class ColorableTileBlockColor implements IBlockColor -{ +public class ColorableTileBlockColor implements IBlockColor { - public static final ColorableTileBlockColor INSTANCE = new ColorableTileBlockColor(); + public static final ColorableTileBlockColor INSTANCE = new ColorableTileBlockColor(); - @Override - public int getColor( BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex ) - { - AEColor color = AEColor.TRANSPARENT; // Default to a neutral color + @Override + public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex) { + AEColor color = AEColor.TRANSPARENT; // Default to a neutral color - if( worldIn != null && pos != null ) - { - TileEntity te = worldIn.getTileEntity( pos ); - if( te instanceof IColorableTile ) - { - color = ( (IColorableTile) te ).getColor(); - } - } + if (worldIn != null && pos != null) { + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof IColorableTile) { + color = ((IColorableTile) te).getColor(); + } + } - return color.getVariantByTintIndex( tintIndex ); - } + return color.getVariantByTintIndex(tintIndex); + } } diff --git a/src/main/java/appeng/client/render/DelegateBakedModel.java b/src/main/java/appeng/client/render/DelegateBakedModel.java index f4a4dc803..3648d8b88 100644 --- a/src/main/java/appeng/client/render/DelegateBakedModel.java +++ b/src/main/java/appeng/client/render/DelegateBakedModel.java @@ -18,89 +18,78 @@ package appeng.client.render; - -import com.mojang.blaze3d.matrix.MatrixStack; - -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.ItemOverrideList; -import net.minecraft.util.Direction; -import org.apache.commons.lang3.tuple.Pair; - -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; - -import javax.annotation.Nullable; import java.util.List; import java.util.Random; +import javax.annotation.Nullable; -public abstract class DelegateBakedModel implements IBakedModel -{ - private final IBakedModel baseModel; +import com.mojang.blaze3d.matrix.MatrixStack; - protected DelegateBakedModel( IBakedModel base ) - { - this.baseModel = base; - } +import org.apache.commons.lang3.tuple.Pair; - @Override - @Deprecated - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - return baseModel.getQuads(state, side, rand); - } +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.renderer.model.ItemOverrideList; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.Direction; - @Override - public boolean func_230044_c_() { - return baseModel.func_230044_c_(); - } +public abstract class DelegateBakedModel implements IBakedModel { + private final IBakedModel baseModel; - @Override - public ItemOverrideList getOverrides() { - return baseModel.getOverrides(); - } + protected DelegateBakedModel(IBakedModel base) { + this.baseModel = base; + } - @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { - baseModel.handlePerspective( cameraTransformType, mat ); - return this; - } + @Override + @Deprecated + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return baseModel.getQuads(state, side, rand); + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.baseModel.getParticleTexture(); - } + @Override + public boolean func_230044_c_() { + return baseModel.func_230044_c_(); + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return this.baseModel.getItemCameraTransforms(); - } + @Override + public ItemOverrideList getOverrides() { + return baseModel.getOverrides(); + } - @Override - public boolean isAmbientOcclusion() - { - return this.baseModel.isAmbientOcclusion(); - } + @Override + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { + baseModel.handlePerspective(cameraTransformType, mat); + return this; + } - @Override - public boolean isGui3d() - { - return this.baseModel.isGui3d(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.baseModel.getParticleTexture(); + } - @Override - public boolean isBuiltInRenderer() - { - return this.baseModel.isBuiltInRenderer(); - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return this.baseModel.getItemCameraTransforms(); + } + @Override + public boolean isAmbientOcclusion() { + return this.baseModel.isAmbientOcclusion(); + } - public IBakedModel getBaseModel() - { - return this.baseModel; - } + @Override + public boolean isGui3d() { + return this.baseModel.isGui3d(); + } + + @Override + public boolean isBuiltInRenderer() { + return this.baseModel.isBuiltInRenderer(); + } + + public IBakedModel getBaseModel() { + return this.baseModel; + } } diff --git a/src/main/java/appeng/client/render/DummyFluidBakedModel.java b/src/main/java/appeng/client/render/DummyFluidBakedModel.java index d7f7eaeaa..c14825ab8 100644 --- a/src/main/java/appeng/client/render/DummyFluidBakedModel.java +++ b/src/main/java/appeng/client/render/DummyFluidBakedModel.java @@ -18,7 +18,6 @@ package appeng.client.render; - import java.util.List; import java.util.Random; @@ -33,60 +32,50 @@ import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; - /** * @author DrummerMC * @version rv6 - 2018-01-22 * @since rv6 2018-01-22 */ -public class DummyFluidBakedModel implements IBakedModel -{ - private final ImmutableList quads; +public class DummyFluidBakedModel implements IBakedModel { + private final ImmutableList quads; - public DummyFluidBakedModel( ImmutableList quads ) - { - this.quads = quads; - } + public DummyFluidBakedModel(ImmutableList quads) { + this.quads = quads; + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - return this.quads; - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return this.quads; + } - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean func_230044_c_() - { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return null; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return null; + } - @Override - public ItemOverrideList getOverrides() - { - return null; - } + @Override + public ItemOverrideList getOverrides() { + return null; + } } diff --git a/src/main/java/appeng/client/render/DummyFluidDispatcherBakedModel.java b/src/main/java/appeng/client/render/DummyFluidDispatcherBakedModel.java index 2440cde46..aaddaf6d4 100644 --- a/src/main/java/appeng/client/render/DummyFluidDispatcherBakedModel.java +++ b/src/main/java/appeng/client/render/DummyFluidDispatcherBakedModel.java @@ -18,11 +18,11 @@ package appeng.client.render; - import java.util.Collections; import java.util.List; import java.util.Random; import java.util.function.Function; + import javax.annotation.Nullable; import com.google.common.collect.ImmutableList; @@ -47,79 +47,69 @@ import net.minecraftforge.fluids.FluidStack; import appeng.fluids.items.FluidDummyItem; - /** - * This baked model class is used as a dispatcher to redirect the renderer to the *real* model that should be used based - * on the item stack. - * A custom Item Override List is used to accomplish this. + * This baked model class is used as a dispatcher to redirect the renderer to + * the *real* model that should be used based on the item stack. A custom Item + * Override List is used to accomplish this. */ -public class DummyFluidDispatcherBakedModel extends DelegateBakedModel -{ - private final Function bakedTextureGetter; +public class DummyFluidDispatcherBakedModel extends DelegateBakedModel { + private final Function bakedTextureGetter; - public DummyFluidDispatcherBakedModel( IBakedModel baseModel, Function bakedTextureGetter ) - { - super( baseModel ); - this.bakedTextureGetter = bakedTextureGetter; - } + public DummyFluidDispatcherBakedModel(IBakedModel baseModel, + Function bakedTextureGetter) { + super(baseModel); + this.bakedTextureGetter = bakedTextureGetter; + } - // This is never used. See the item override list below. - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - return Collections.emptyList(); - } + // This is never used. See the item override list below. + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return Collections.emptyList(); + } - @Override - public boolean isGui3d() - { - return this.getBaseModel().isGui3d(); - } + @Override + public boolean isGui3d() { + return this.getBaseModel().isGui3d(); + } - @Override - public boolean func_230044_c_() - { - return getBaseModel().func_230044_c_(); - } + @Override + public boolean func_230044_c_() { + return getBaseModel().func_230044_c_(); + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public ItemOverrideList getOverrides() - { - return new ItemOverrideList() - { - @Override - public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) - { - if( !( stack.getItem() instanceof FluidDummyItem ) ) - { - return originalModel; - } + @Override + public ItemOverrideList getOverrides() { + return new ItemOverrideList() { + @Override + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, + LivingEntity entity) { + if (!(stack.getItem() instanceof FluidDummyItem)) { + return originalModel; + } - FluidDummyItem itemFacade = (FluidDummyItem) stack.getItem(); + FluidDummyItem itemFacade = (FluidDummyItem) stack.getItem(); - FluidStack fluidStack = itemFacade.getFluidStack( stack ); - if( fluidStack == null ) - { - fluidStack = new FluidStack( Fluids.WATER, FluidAttributes.BUCKET_VOLUME ); - } + FluidStack fluidStack = itemFacade.getFluidStack(stack); + if (fluidStack == null) { + fluidStack = new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME); + } - FluidAttributes attributes = fluidStack.getFluid().getAttributes(); - ResourceLocation stillTexture = attributes.getStillTexture(fluidStack); - Material stillMaterial = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, stillTexture); - TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial); - if( sprite == null ) - { - return new DummyFluidBakedModel( ImmutableList.of() ); - } + FluidAttributes attributes = fluidStack.getFluid().getAttributes(); + ResourceLocation stillTexture = attributes.getStillTexture(fluidStack); + Material stillMaterial = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, stillTexture); + TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial); + if (sprite == null) { + return new DummyFluidBakedModel(ImmutableList.of()); + } - return new DummyFluidBakedModel( ItemLayerModel.getQuadsForSprite( 0, sprite, TransformationMatrix.identity() ) ); - } - }; - } + return new DummyFluidBakedModel( + ItemLayerModel.getQuadsForSprite(0, sprite, TransformationMatrix.identity())); + } + }; + } } diff --git a/src/main/java/appeng/client/render/DummyFluidItemModel.java b/src/main/java/appeng/client/render/DummyFluidItemModel.java index e3869f82c..3de3294c5 100644 --- a/src/main/java/appeng/client/render/DummyFluidItemModel.java +++ b/src/main/java/appeng/client/render/DummyFluidItemModel.java @@ -18,40 +18,43 @@ package appeng.client.render; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.function.Function; -import appeng.core.AppEng; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import java.util.function.Function; - +import appeng.core.AppEng; /** - * The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other - * than the cable anchor. + * The model class for facades. Since facades wrap existing models, they don't + * declare any dependencies here other than the cable anchor. */ -public class DummyFluidItemModel implements IModelGeometry -{ - // We use this to get the default item transforms and make our lives easier - private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/dummy_fluid_item_base" ); +public class DummyFluidItemModel implements IModelGeometry { + // We use this to get the default item transforms and make our lives easier + private static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, + "item/dummy_fluid_item_base"); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); - return new DummyFluidDispatcherBakedModel( bakedBaseModel, spriteGetter ); - } + return new DummyFluidDispatcherBakedModel(bakedBaseModel, spriteGetter); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Collections.emptyList(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.emptyList(); + } } diff --git a/src/main/java/appeng/client/render/FacadeBakedItemModel.java b/src/main/java/appeng/client/render/FacadeBakedItemModel.java index 8ef147e08..3b9c6bafe 100644 --- a/src/main/java/appeng/client/render/FacadeBakedItemModel.java +++ b/src/main/java/appeng/client/render/FacadeBakedItemModel.java @@ -18,7 +18,6 @@ package appeng.client.render; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -37,70 +36,61 @@ import net.minecraftforge.client.model.data.IModelData; import appeng.client.render.cablebus.FacadeBuilder; - /** - * This model used the provided FacadeBuilder to "slice" the item quads for the facade provided. + * This model used the provided FacadeBuilder to "slice" the item quads for the + * facade provided. * * @author covers1624 */ -public class FacadeBakedItemModel extends DelegateBakedModel -{ +public class FacadeBakedItemModel extends DelegateBakedModel { - private final ItemStack textureStack; - private final FacadeBuilder facadeBuilder; - private List quads = null; + private final ItemStack textureStack; + private final FacadeBuilder facadeBuilder; + private List quads = null; - protected FacadeBakedItemModel( IBakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder ) - { - super( base ); - this.textureStack = textureStack; - this.facadeBuilder = facadeBuilder; - } + protected FacadeBakedItemModel(IBakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) { + super(base); + this.textureStack = textureStack; + this.facadeBuilder = facadeBuilder; + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - return getQuads( state, side, rand, EmptyModelData.INSTANCE ); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return getQuads(state, side, rand, EmptyModelData.INSTANCE); + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data ) - { - if( side != null ) - { - return Collections.emptyList(); - } - if( quads == null ) - { - quads = new ArrayList<>(); - quads.addAll( this.facadeBuilder.buildFacadeItemQuads( this.textureStack, Direction.NORTH ) ); - quads.addAll( this.getBaseModel().getQuads( state, side, rand, data ) ); - quads = Collections.unmodifiableList( quads ); + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData data) { + if (side != null) { + return Collections.emptyList(); } - return quads; - } + if (quads == null) { + quads = new ArrayList<>(); + quads.addAll(this.facadeBuilder.buildFacadeItemQuads(this.textureStack, Direction.NORTH)); + quads.addAll(this.getBaseModel().getQuads(state, side, rand, data)); + quads = Collections.unmodifiableList(quads); + } + return quads; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean func_230044_c_() - { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } } diff --git a/src/main/java/appeng/client/render/FacadeDispatcherBakedModel.java b/src/main/java/appeng/client/render/FacadeDispatcherBakedModel.java index 4dee1a29c..2c1e20bcf 100644 --- a/src/main/java/appeng/client/render/FacadeDispatcherBakedModel.java +++ b/src/main/java/appeng/client/render/FacadeDispatcherBakedModel.java @@ -18,11 +18,11 @@ package appeng.client.render; - import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Random; + import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -40,75 +40,65 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import appeng.client.render.cablebus.FacadeBuilder; import appeng.items.parts.ItemFacade; - /** - * This baked model class is used as a dispatcher to redirect the renderer to the *real* model that should be used based - * on the item stack. - * A custom Item Override List is used to accomplish this. + * This baked model class is used as a dispatcher to redirect the renderer to + * the *real* model that should be used based on the item stack. A custom Item + * Override List is used to accomplish this. */ -public class FacadeDispatcherBakedModel extends DelegateBakedModel -{ - private final FacadeBuilder facadeBuilder; - private final Int2ObjectMap cache = new Int2ObjectArrayMap<>(); +public class FacadeDispatcherBakedModel extends DelegateBakedModel { + private final FacadeBuilder facadeBuilder; + private final Int2ObjectMap cache = new Int2ObjectArrayMap<>(); - public FacadeDispatcherBakedModel( IBakedModel baseModel, FacadeBuilder facadeBuilder ) - { - super( baseModel ); - this.facadeBuilder = facadeBuilder; - } + public FacadeDispatcherBakedModel(IBakedModel baseModel, FacadeBuilder facadeBuilder) { + super(baseModel); + this.facadeBuilder = facadeBuilder; + } - // This is never used. See the item override list below. - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - return Collections.emptyList(); - } + // This is never used. See the item override list below. + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return Collections.emptyList(); + } - @Override - public boolean isGui3d() - { - return this.getBaseModel().isGui3d(); - } + @Override + public boolean isGui3d() { + return this.getBaseModel().isGui3d(); + } - @Override - public boolean func_230044_c_() - { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public ItemOverrideList getOverrides() - { - return new ItemOverrideList() - { - @Override - public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) - { - if( !( stack.getItem() instanceof ItemFacade ) ) - { - return originalModel; - } + @Override + public ItemOverrideList getOverrides() { + return new ItemOverrideList() { + @Override + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, + LivingEntity entity) { + if (!(stack.getItem() instanceof ItemFacade)) { + return originalModel; + } - ItemFacade itemFacade = (ItemFacade) stack.getItem(); + ItemFacade itemFacade = (ItemFacade) stack.getItem(); - ItemStack textureItem = itemFacade.getTextureItem( stack ); + ItemStack textureItem = itemFacade.getTextureItem(stack); - int hash = Objects.hash( textureItem.getItem().getRegistryName(), textureItem.getTag() ); - FacadeBakedItemModel model = FacadeDispatcherBakedModel.this.cache.get( hash ); - if( model == null ) - { - model = new FacadeBakedItemModel( FacadeDispatcherBakedModel.this.getBaseModel(), textureItem, FacadeDispatcherBakedModel.this.facadeBuilder ); - FacadeDispatcherBakedModel.this.cache.put( hash, model ); - } + int hash = Objects.hash(textureItem.getItem().getRegistryName(), textureItem.getTag()); + FacadeBakedItemModel model = FacadeDispatcherBakedModel.this.cache.get(hash); + if (model == null) { + model = new FacadeBakedItemModel(FacadeDispatcherBakedModel.this.getBaseModel(), textureItem, + FacadeDispatcherBakedModel.this.facadeBuilder); + FacadeDispatcherBakedModel.this.cache.put(hash, model); + } - return model; - } - }; - } + return model; + } + }; + } } diff --git a/src/main/java/appeng/client/render/FacadeItemModel.java b/src/main/java/appeng/client/render/FacadeItemModel.java index 3a4c9a0f1..aa2d15b59 100644 --- a/src/main/java/appeng/client/render/FacadeItemModel.java +++ b/src/main/java/appeng/client/render/FacadeItemModel.java @@ -18,7 +18,6 @@ package appeng.client.render; - import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -37,34 +36,31 @@ import net.minecraft.util.ResourceLocation; import appeng.client.render.cablebus.FacadeBuilder; import appeng.core.AppEng; - /** - * The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other - * than the cable anchor. + * The model class for facades. Since facades wrap existing models, they don't + * declare any dependencies here other than the cable anchor. */ -public class FacadeItemModel implements IUnbakedModel -{ - // We use this to get the default item transforms and make our lives easier - private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/facade_base" ); +public class FacadeItemModel implements IUnbakedModel { + // We use this to get the default item transforms and make our lives easier + private static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "item/facade_base"); - @Override - public Collection getDependencies() - { - return Collections.singleton( MODEL_BASE ); - } + @Override + public Collection getDependencies() { + return Collections.singleton(MODEL_BASE); + } - @Override - public Collection getTextures( Function modelGetter, Set> missingTextureErrors ) - { - return Collections.emptyList(); - } + @Override + public Collection getTextures(Function modelGetter, + Set> missingTextureErrors) { + return Collections.emptyList(); + } - @Override - public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn ) - { - IBakedModel bakedBaseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn ); - FacadeBuilder facadeBuilder = new FacadeBuilder(); + @Override + public IBakedModel bakeModel(ModelBakery modelBakeryIn, Function spriteGetterIn, + IModelTransform transformIn, ResourceLocation locationIn) { + IBakedModel bakedBaseModel = modelBakeryIn.getBakedModel(MODEL_BASE, transformIn, spriteGetterIn); + FacadeBuilder facadeBuilder = new FacadeBuilder(); - return new FacadeDispatcherBakedModel( bakedBaseModel, facadeBuilder ); - } + return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder); + } } diff --git a/src/main/java/appeng/client/render/FacingToRotation.java b/src/main/java/appeng/client/render/FacingToRotation.java index 630885b0f..889f9d1d8 100644 --- a/src/main/java/appeng/client/render/FacingToRotation.java +++ b/src/main/java/appeng/client/render/FacingToRotation.java @@ -18,7 +18,6 @@ package appeng.client.render; - import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.*; @@ -26,118 +25,89 @@ import net.minecraft.util.Direction; import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.Vec3i; - /** * TODO: Removed useless stuff. */ -public enum FacingToRotation implements IStringSerializable -{ +public enum FacingToRotation implements IStringSerializable { - // DUNSWE - // @formatter:off - DOWN_DOWN( new Vector3f( 0, 0, 0 ) ), // NOOP - DOWN_UP( new Vector3f( 0, 0, 0 ) ), // NOOP - DOWN_NORTH( new Vector3f( -90, 0, 0 ) ), - DOWN_SOUTH( new Vector3f( -90, 0, 180 ) ), - DOWN_WEST( new Vector3f( -90, 0, 90 ) ), - DOWN_EAST( new Vector3f( -90, 0, -90 ) ), - UP_DOWN( new Vector3f( 0, 0, 0 ) ), // NOOP - UP_UP( new Vector3f( 0, 0, 0 ) ), // NOOP - UP_NORTH( new Vector3f( 90, 0, 180 ) ), - UP_SOUTH( new Vector3f( 90, 0, 0 ) ), - UP_WEST( new Vector3f( 90, 0, 90 ) ), - UP_EAST( new Vector3f( 90, 0, -90 ) ), - NORTH_DOWN( new Vector3f( 0, 0, 180 ) ), - NORTH_UP( new Vector3f( 0, 0, 0 ) ), - NORTH_NORTH( new Vector3f( 0, 0, 0 ) ), // NOOP - NORTH_SOUTH( new Vector3f( 0, 0, 0 ) ), // NOOP - NORTH_WEST( new Vector3f( 0, 0, 90 ) ), - NORTH_EAST( new Vector3f( 0, 0, -90 ) ), - SOUTH_DOWN( new Vector3f( 0, 180, 180 ) ), - SOUTH_UP( new Vector3f( 0, 180, 0 ) ), - SOUTH_NORTH( new Vector3f( 0, 0, 0 ) ), // NOOP - SOUTH_SOUTH( new Vector3f( 0, 0, 0 ) ), // NOOP - SOUTH_WEST( new Vector3f( 0, 180, -90 ) ), - SOUTH_EAST( new Vector3f( 0, 180, 90 ) ), - WEST_DOWN( new Vector3f( 0, 90, 180 ) ), - WEST_UP( new Vector3f( 0, 90, 0 ) ), - WEST_NORTH( new Vector3f( 0, 90, -90 ) ), - WEST_SOUTH( new Vector3f( 0, 90, 90 ) ), - WEST_WEST( new Vector3f( 0, 0, 0 ) ), // NOOP - WEST_EAST( new Vector3f( 0, 0, 0 ) ), // NOOP - EAST_DOWN( new Vector3f( 0, -90, 180 ) ), - EAST_UP( new Vector3f( 0, -90, 0 ) ), - EAST_NORTH( new Vector3f( 0, -90, 90 ) ), - EAST_SOUTH( new Vector3f( 0, -90, -90 ) ), - EAST_WEST( new Vector3f( 0, 0, 0 ) ), // NOOP - EAST_EAST( new Vector3f( 0, 0, 0 ) ); // NOOP - // @formatter:on + // DUNSWE + // @formatter:off + DOWN_DOWN(new Vector3f(0, 0, 0)), // NOOP + DOWN_UP(new Vector3f(0, 0, 0)), // NOOP + DOWN_NORTH(new Vector3f(-90, 0, 0)), DOWN_SOUTH(new Vector3f(-90, 0, 180)), DOWN_WEST(new Vector3f(-90, 0, 90)), + DOWN_EAST(new Vector3f(-90, 0, -90)), UP_DOWN(new Vector3f(0, 0, 0)), // NOOP + UP_UP(new Vector3f(0, 0, 0)), // NOOP + UP_NORTH(new Vector3f(90, 0, 180)), UP_SOUTH(new Vector3f(90, 0, 0)), UP_WEST(new Vector3f(90, 0, 90)), + UP_EAST(new Vector3f(90, 0, -90)), NORTH_DOWN(new Vector3f(0, 0, 180)), NORTH_UP(new Vector3f(0, 0, 0)), + NORTH_NORTH(new Vector3f(0, 0, 0)), // NOOP + NORTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP + NORTH_WEST(new Vector3f(0, 0, 90)), NORTH_EAST(new Vector3f(0, 0, -90)), SOUTH_DOWN(new Vector3f(0, 180, 180)), + SOUTH_UP(new Vector3f(0, 180, 0)), SOUTH_NORTH(new Vector3f(0, 0, 0)), // NOOP + SOUTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP + SOUTH_WEST(new Vector3f(0, 180, -90)), SOUTH_EAST(new Vector3f(0, 180, 90)), WEST_DOWN(new Vector3f(0, 90, 180)), + WEST_UP(new Vector3f(0, 90, 0)), WEST_NORTH(new Vector3f(0, 90, -90)), WEST_SOUTH(new Vector3f(0, 90, 90)), + WEST_WEST(new Vector3f(0, 0, 0)), // NOOP + WEST_EAST(new Vector3f(0, 0, 0)), // NOOP + EAST_DOWN(new Vector3f(0, -90, 180)), EAST_UP(new Vector3f(0, -90, 0)), EAST_NORTH(new Vector3f(0, -90, 90)), + EAST_SOUTH(new Vector3f(0, -90, -90)), EAST_WEST(new Vector3f(0, 0, 0)), // NOOP + EAST_EAST(new Vector3f(0, 0, 0)); // NOOP + // @formatter:on - private final Vector3f rot; - private final Quaternion xRot; - private final Quaternion yRot; - private final Quaternion zRot; - private final Matrix4f mat; + private final Vector3f rot; + private final Quaternion xRot; + private final Quaternion yRot; + private final Quaternion zRot; + private final Matrix4f mat; - private FacingToRotation( Vector3f rot ) - { - this.rot = rot; - this.mat = new Matrix4f(); - this.mat.setIdentity(); - this.mat.mul( xRot = Vector3f.XP.rotationDegrees( rot.getX() ) ); - this.mat.mul( yRot = Vector3f.YP.rotationDegrees( rot.getY() ) ); - this.mat.mul( zRot = Vector3f.ZP.rotationDegrees( rot.getZ() ) ); - } + private FacingToRotation(Vector3f rot) { + this.rot = rot; + this.mat = new Matrix4f(); + this.mat.setIdentity(); + this.mat.mul(xRot = Vector3f.XP.rotationDegrees(rot.getX())); + this.mat.mul(yRot = Vector3f.YP.rotationDegrees(rot.getY())); + this.mat.mul(zRot = Vector3f.ZP.rotationDegrees(rot.getZ())); + } - public boolean isRedundant() - { - return rot.getX() == 0 && rot.getY() == 0 && rot.getZ() == 0; - } + public boolean isRedundant() { + return rot.getX() == 0 && rot.getY() == 0 && rot.getZ() == 0; + } - public Vector3f getRot() - { - return this.rot; - } + public Vector3f getRot() { + return this.rot; + } - public Matrix4f getMat() - { - return new Matrix4f( this.mat ); - } + public Matrix4f getMat() { + return new Matrix4f(this.mat); + } - public void push( MatrixStack mStack ) - { - mStack.rotate( xRot ); - mStack.rotate( yRot ); - mStack.rotate( zRot ); - } + public void push(MatrixStack mStack) { + mStack.rotate(xRot); + mStack.rotate(yRot); + mStack.rotate(zRot); + } - public Direction rotate( Direction facing ) - { - Vec3i dir = facing.getDirectionVec(); - Vector4f vec = new Vector4f( dir.getX(), dir.getY(), dir.getZ(), 1 ); - vec.transform( mat ); - return Direction.getFacingFromVector( vec.getX(), vec.getY(), vec.getZ() ); - } + public Direction rotate(Direction facing) { + Vec3i dir = facing.getDirectionVec(); + Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 1); + vec.transform(mat); + return Direction.getFacingFromVector(vec.getX(), vec.getY(), vec.getZ()); + } - public Direction resultingRotate( Direction facing ) - { - for( Direction face : Direction.values() ) - { - if( this.rotate( face ) == facing ) - { - return face; - } - } - return null; - } + public Direction resultingRotate(Direction facing) { + for (Direction face : Direction.values()) { + if (this.rotate(face) == facing) { + return face; + } + } + return null; + } - public static FacingToRotation get( Direction forward, Direction up ) - { - return values()[forward.ordinal() * 6 + up.ordinal()]; - } + public static FacingToRotation get(Direction forward, Direction up) { + return values()[forward.ordinal() * 6 + up.ordinal()]; + } - @Override - public String getName() { - return name().toLowerCase(); - } + @Override + public String getName() { + return name().toLowerCase(); + } } diff --git a/src/main/java/appeng/client/render/SimpleModelLoader.java b/src/main/java/appeng/client/render/SimpleModelLoader.java index 8e873946d..62a900cea 100644 --- a/src/main/java/appeng/client/render/SimpleModelLoader.java +++ b/src/main/java/appeng/client/render/SimpleModelLoader.java @@ -1,13 +1,14 @@ package appeng.client.render; +import java.util.function.Supplier; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.resources.IResourceManager; import net.minecraftforge.client.model.IModelLoader; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.function.Supplier; - /** * A quaint model loader that does not accept any additional parameters in JSON. */ diff --git a/src/main/java/appeng/client/render/SpatialSkyRender.java b/src/main/java/appeng/client/render/SpatialSkyRender.java index 2f7ac1704..cb1edbacc 100644 --- a/src/main/java/appeng/client/render/SpatialSkyRender.java +++ b/src/main/java/appeng/client/render/SpatialSkyRender.java @@ -18,170 +18,153 @@ package appeng.client.render; - import java.util.Random; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.renderer.Quaternion; -import net.minecraftforge.client.SkyRenderHandler; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.Quaternion; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.world.ClientWorld; import net.minecraftforge.client.IRenderHandler; - +import net.minecraftforge.client.SkyRenderHandler; //TODO https://github.com/MinecraftForge/MinecraftForge/pull/6537 -public class SpatialSkyRender implements SkyRenderHandler -{ +public class SpatialSkyRender implements SkyRenderHandler { - private static final SpatialSkyRender INSTANCE = new SpatialSkyRender(); + private static final SpatialSkyRender INSTANCE = new SpatialSkyRender(); - private final Random random = new Random(); - private final int dspList; - private long cycle = 0; + private final Random random = new Random(); + private final int dspList; + private long cycle = 0; - public SpatialSkyRender() - { - this.dspList = GL11.glGenLists( 1 ); - } + public SpatialSkyRender() { + this.dspList = GL11.glGenLists(1); + } - public static IRenderHandler getInstance() - { - return INSTANCE; - } + public static IRenderHandler getInstance() { + return INSTANCE; + } - private static final Quaternion[] SKYBOX_SIDE_ROTATIONS = { - Quaternion.ONE, - new Quaternion( 90.0F, 0.0F, 0.0F, true ), - new Quaternion( -90.0F, 0.0F, 0.0F, true ), - new Quaternion( 180.0F, 0.0F, 0.0F, true ), - new Quaternion( 0.0F, 0.0F, 90.0F, true ), - new Quaternion( 0.0F, 0.0F, -90.0F, true ), - }; + private static final Quaternion[] SKYBOX_SIDE_ROTATIONS = { Quaternion.ONE, new Quaternion(90.0F, 0.0F, 0.0F, true), + new Quaternion(-90.0F, 0.0F, 0.0F, true), new Quaternion(180.0F, 0.0F, 0.0F, true), + new Quaternion(0.0F, 0.0F, 90.0F, true), new Quaternion(0.0F, 0.0F, -90.0F, true), }; - @Override - public void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc) { - final long now = System.currentTimeMillis(); - if( now - this.cycle > 2000 ) - { - this.cycle = now; - GL11.glNewList( this.dspList, GL11.GL_COMPILE ); - this.renderTwinkles(); - GL11.glEndList(); - } + @Override + public void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc) { + final long now = System.currentTimeMillis(); + if (now - this.cycle > 2000) { + this.cycle = now; + GL11.glNewList(this.dspList, GL11.GL_COMPILE); + this.renderTwinkles(); + GL11.glEndList(); + } - float fade = now - this.cycle; - fade /= 1000; - fade = 0.15f * ( 1.0f - Math.abs( ( fade - 1.0f ) * ( fade - 1.0f ) ) ); + float fade = now - this.cycle; + fade /= 1000; + fade = 0.15f * (1.0f - Math.abs((fade - 1.0f) * (fade - 1.0f))); - RenderSystem.disableFog(); - RenderSystem.disableAlphaTest(); - RenderSystem.disableBlend(); - RenderSystem.depthMask( false ); - RenderSystem.color4f( 0.0f, 0.0f, 0.0f, 1.0f ); - final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder VertexBuffer = tessellator.getBuffer(); + RenderSystem.disableFog(); + RenderSystem.disableAlphaTest(); + RenderSystem.disableBlend(); + RenderSystem.depthMask(false); + RenderSystem.color4f(0.0f, 0.0f, 0.0f, 1.0f); + final Tessellator tessellator = Tessellator.getInstance(); + final BufferBuilder VertexBuffer = tessellator.getBuffer(); - // This renders a skybox around the player at a far, fixed distance from them. - // The skybox is pitch black and untextured - for (Quaternion rotation : SKYBOX_SIDE_ROTATIONS) - { - matrixStack.push(); - matrixStack.rotate(rotation); + // This renders a skybox around the player at a far, fixed distance from them. + // The skybox is pitch black and untextured + for (Quaternion rotation : SKYBOX_SIDE_ROTATIONS) { + matrixStack.push(); + matrixStack.rotate(rotation); - RenderSystem.disableTexture(); - VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); - VertexBuffer.pos( -100.0D, -100.0D, -100.0D ).endVertex(); - VertexBuffer.pos( -100.0D, -100.0D, 100.0D ).endVertex(); - VertexBuffer.pos( 100.0D, -100.0D, 100.0D ).endVertex(); - VertexBuffer.pos( 100.0D, -100.0D, -100.0D ).endVertex(); - tessellator.draw(); - RenderSystem.enableTexture(); - matrixStack.pop(); - } + RenderSystem.disableTexture(); + VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + VertexBuffer.pos(-100.0D, -100.0D, -100.0D).endVertex(); + VertexBuffer.pos(-100.0D, -100.0D, 100.0D).endVertex(); + VertexBuffer.pos(100.0D, -100.0D, 100.0D).endVertex(); + VertexBuffer.pos(100.0D, -100.0D, -100.0D).endVertex(); + tessellator.draw(); + RenderSystem.enableTexture(); + matrixStack.pop(); + } - RenderSystem.depthMask( true ); + RenderSystem.depthMask(true); - if( fade > 0.0f ) - { - RenderSystem.disableFog(); - RenderSystem.disableAlphaTest(); - RenderSystem.enableBlend(); - RenderSystem.disableTexture(); - RenderSystem.depthMask( false ); - RenderSystem.blendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0 ); + if (fade > 0.0f) { + RenderSystem.disableFog(); + RenderSystem.disableAlphaTest(); + RenderSystem.enableBlend(); + RenderSystem.disableTexture(); + RenderSystem.depthMask(false); + RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - RenderHelper.disableStandardItemLighting(); + RenderHelper.disableStandardItemLighting(); - RenderSystem.color4f( fade, fade, fade, 1.0f ); - GL11.glCallList( this.dspList ); - } + RenderSystem.color4f(fade, fade, fade, 1.0f); + GL11.glCallList(this.dspList); + } - RenderSystem.depthMask( true ); - RenderSystem.enableBlend(); - RenderSystem.enableAlphaTest(); - RenderSystem.enableTexture(); - RenderSystem.enableFog(); + RenderSystem.depthMask(true); + RenderSystem.enableBlend(); + RenderSystem.enableAlphaTest(); + RenderSystem.enableTexture(); + RenderSystem.enableFog(); - RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } + RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); + } - private void renderTwinkles() - { - final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder vb = tessellator.getBuffer(); - vb.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); + private void renderTwinkles() { + final Tessellator tessellator = Tessellator.getInstance(); + final BufferBuilder vb = tessellator.getBuffer(); + vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - for( int i = 0; i < 50; ++i ) - { - double iX = this.random.nextFloat() * 2.0F - 1.0F; - double iY = this.random.nextFloat() * 2.0F - 1.0F; - double iZ = this.random.nextFloat() * 2.0F - 1.0F; - final double d3 = 0.05F + this.random.nextFloat() * 0.1F; - double dist = iX * iX + iY * iY + iZ * iZ; + for (int i = 0; i < 50; ++i) { + double iX = this.random.nextFloat() * 2.0F - 1.0F; + double iY = this.random.nextFloat() * 2.0F - 1.0F; + double iZ = this.random.nextFloat() * 2.0F - 1.0F; + final double d3 = 0.05F + this.random.nextFloat() * 0.1F; + double dist = iX * iX + iY * iY + iZ * iZ; - if( dist < 1.0D && dist > 0.01D ) - { - dist = 1.0D / Math.sqrt( dist ); - iX *= dist; - iY *= dist; - iZ *= dist; - final double x = iX * 100.0D; - final double y = iY * 100.0D; - final double z = iZ * 100.0D; - final double d8 = Math.atan2( iX, iZ ); - final double d9 = Math.sin( d8 ); - final double d10 = Math.cos( d8 ); - final double d11 = Math.atan2( Math.sqrt( iX * iX + iZ * iZ ), iY ); - final double d12 = Math.sin( d11 ); - final double d13 = Math.cos( d11 ); - final double d14 = this.random.nextDouble() * Math.PI * 2.0D; - final double d15 = Math.sin( d14 ); - final double d16 = Math.cos( d14 ); + if (dist < 1.0D && dist > 0.01D) { + dist = 1.0D / Math.sqrt(dist); + iX *= dist; + iY *= dist; + iZ *= dist; + final double x = iX * 100.0D; + final double y = iY * 100.0D; + final double z = iZ * 100.0D; + final double d8 = Math.atan2(iX, iZ); + final double d9 = Math.sin(d8); + final double d10 = Math.cos(d8); + final double d11 = Math.atan2(Math.sqrt(iX * iX + iZ * iZ), iY); + final double d12 = Math.sin(d11); + final double d13 = Math.cos(d11); + final double d14 = this.random.nextDouble() * Math.PI * 2.0D; + final double d15 = Math.sin(d14); + final double d16 = Math.cos(d14); - for( int j = 0; j < 4; ++j ) - { - final double d17 = 0.0D; - final double d18 = ( ( j & 2 ) - 1 ) * d3; - final double d19 = ( ( j + 1 & 2 ) - 1 ) * d3; - final double d20 = d18 * d16 - d19 * d15; - final double d21 = d19 * d16 + d18 * d15; - final double d22 = d20 * d12 + d17 * d13; - final double d23 = d17 * d12 - d20 * d13; - final double d24 = d23 * d9 - d21 * d10; - final double d25 = d21 * d9 + d23 * d10; - vb.pos( x + d24, y + d22, z + d25 ).endVertex(); - } - } - } + for (int j = 0; j < 4; ++j) { + final double d17 = 0.0D; + final double d18 = ((j & 2) - 1) * d3; + final double d19 = ((j + 1 & 2) - 1) * d3; + final double d20 = d18 * d16 - d19 * d15; + final double d21 = d19 * d16 + d18 * d15; + final double d22 = d20 * d12 + d17 * d13; + final double d23 = d17 * d12 - d20 * d13; + final double d24 = d23 * d9 - d21 * d10; + final double d25 = d21 * d9 + d23 * d10; + vb.pos(x + d24, y + d22, z + d25).endVertex(); + } + } + } - tessellator.draw(); - } + tessellator.draw(); + } } diff --git a/src/main/java/appeng/client/render/StackSizeRenderer.java b/src/main/java/appeng/client/render/StackSizeRenderer.java index 4c0c303cf..55eddb7b8 100644 --- a/src/main/java/appeng/client/render/StackSizeRenderer.java +++ b/src/main/java/appeng/client/render/StackSizeRenderer.java @@ -18,10 +18,11 @@ package appeng.client.render; - import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.*; import appeng.api.storage.data.IAEItemStack; import appeng.core.AEConfig; @@ -29,8 +30,6 @@ import appeng.core.localization.GuiText; import appeng.util.ISlimReadableNumberConverter; import appeng.util.IWideReadableNumberConverter; import appeng.util.ReadableNumberConverter; -import net.minecraft.client.renderer.*; - /** * @author AlgorithmX2 @@ -38,65 +37,55 @@ import net.minecraft.client.renderer.*; * @version rv2 * @since rv0 */ -public class StackSizeRenderer -{ - private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE; - private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE; +public class StackSizeRenderer { + private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE; + private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE; - public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, int xPos, int yPos ) - { - if( aeStack != null ) - { - if( aeStack.getStackSize() == 0 && aeStack.isCraftable() ) - { - final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft - .getLocal(); + public void renderStackSize(FontRenderer fontRenderer, IAEItemStack aeStack, int xPos, int yPos) { + if (aeStack != null) { + if (aeStack.getStackSize() == 0 && aeStack.isCraftable()) { + final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() + ? GuiText.LargeFontCraft.getLocal() + : GuiText.SmallFontCraft.getLocal(); - renderSizeLabel(fontRenderer, xPos, yPos, craftLabelText); - } + renderSizeLabel(fontRenderer, xPos, yPos, craftLabelText); + } - if( aeStack.getStackSize() > 0 ) - { - final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() ); + if (aeStack.getStackSize() > 0) { + final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize()); - renderSizeLabel(fontRenderer, xPos, yPos, stackSize); - } + renderSizeLabel(fontRenderer, xPos, yPos, stackSize); + } - } - } + } + } - public static void renderSizeLabel(FontRenderer fontRenderer, float xPos, float yPos, String text) { + public static void renderSizeLabel(FontRenderer fontRenderer, float xPos, float yPos, String text) { - final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f; - final float inverseScaleFactor = 1.0f / scaleFactor; - final int offset = AEConfig.instance().useTerminalUseLargeFont() ? 0 : -1; + final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f; + final float inverseScaleFactor = 1.0f / scaleFactor; + final int offset = AEConfig.instance().useTerminalUseLargeFont() ? 0 : -1; - TransformationMatrix tm = new TransformationMatrix( - new Vector3f(0, 0, 300), // Taken from ItemRenderer.renderItemOverlayIntoGUI - null, - new Vector3f(scaleFactor, scaleFactor, scaleFactor), - null - ); + TransformationMatrix tm = new TransformationMatrix(new Vector3f(0, 0, 300), // Taken from + // ItemRenderer.renderItemOverlayIntoGUI + null, new Vector3f(scaleFactor, scaleFactor, scaleFactor), null); - RenderSystem.disableBlend(); - final int X = (int) ( ( xPos + offset + 16.0f - fontRenderer.getStringWidth(text) * scaleFactor ) * inverseScaleFactor ); - final int Y = (int) ( ( yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor ); - IRenderTypeBuffer.Impl buffer = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer()); - fontRenderer.renderString(text, X, Y, 16777215, true, tm.getMatrix(), buffer, false, 0, 15728880 ); - buffer.finish(); - RenderSystem.enableBlend(); - } + RenderSystem.disableBlend(); + final int X = (int) ((xPos + offset + 16.0f - fontRenderer.getStringWidth(text) * scaleFactor) + * inverseScaleFactor); + final int Y = (int) ((yPos + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); + IRenderTypeBuffer.Impl buffer = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer()); + fontRenderer.renderString(text, X, Y, 16777215, true, tm.getMatrix(), buffer, false, 0, 15728880); + buffer.finish(); + RenderSystem.enableBlend(); + } - private String getToBeRenderedStackSize( final long originalSize ) - { - if( AEConfig.instance().useTerminalUseLargeFont() ) - { - return SLIM_CONVERTER.toSlimReadableForm( originalSize ); - } - else - { - return WIDE_CONVERTER.toWideReadableForm( originalSize ); - } - } + private String getToBeRenderedStackSize(final long originalSize) { + if (AEConfig.instance().useTerminalUseLargeFont()) { + return SLIM_CONVERTER.toSlimReadableForm(originalSize); + } else { + return WIDE_CONVERTER.toWideReadableForm(originalSize); + } + } } diff --git a/src/main/java/appeng/client/render/StaticBlockColor.java b/src/main/java/appeng/client/render/StaticBlockColor.java index 5c8a76320..8fd85ca9f 100644 --- a/src/main/java/appeng/client/render/StaticBlockColor.java +++ b/src/main/java/appeng/client/render/StaticBlockColor.java @@ -18,35 +18,30 @@ package appeng.client.render; - import javax.annotation.Nullable; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; - -import appeng.api.util.AEColor; import net.minecraft.world.ILightReader; +import appeng.api.util.AEColor; /** * Returns the shades of a single AE color for tint indices 0, 1, and 2. */ -public class StaticBlockColor implements IBlockColor -{ +public class StaticBlockColor implements IBlockColor { - private final AEColor color; + private final AEColor color; - public StaticBlockColor( AEColor color ) - { - this.color = color; - } + public StaticBlockColor(AEColor color) { + this.color = color; + } - @Override - public int getColor( BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex ) - { - return this.color.getVariantByTintIndex( tintIndex ); - } + @Override + public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex) { + return this.color.getVariantByTintIndex(tintIndex); + } } diff --git a/src/main/java/appeng/client/render/StaticItemColor.java b/src/main/java/appeng/client/render/StaticItemColor.java index 9b7ec9b3d..d73113a98 100644 --- a/src/main/java/appeng/client/render/StaticItemColor.java +++ b/src/main/java/appeng/client/render/StaticItemColor.java @@ -18,30 +18,25 @@ package appeng.client.render; - import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.item.ItemStack; import appeng.api.util.AEColor; - /** * Returns the shades of a single AE color for tint indices 0, 1, and 2. */ -public class StaticItemColor implements IItemColor -{ +public class StaticItemColor implements IItemColor { - private final AEColor color; + private final AEColor color; - public StaticItemColor( AEColor color ) - { - this.color = color; - } + public StaticItemColor(AEColor color) { + this.color = color; + } - @Override - public int getColor( ItemStack stack, int tintIndex ) - { - return this.color.getVariantByTintIndex( tintIndex ); - } + @Override + public int getColor(ItemStack stack, int tintIndex) { + return this.color.getVariantByTintIndex(tintIndex); + } } diff --git a/src/main/java/appeng/client/render/TesrRenderHelper.java b/src/main/java/appeng/client/render/TesrRenderHelper.java index 710bdf5f8..4dc177037 100644 --- a/src/main/java/appeng/client/render/TesrRenderHelper.java +++ b/src/main/java/appeng/client/render/TesrRenderHelper.java @@ -18,8 +18,6 @@ package appeng.client.render; - -import appeng.api.storage.data.IAEItemStack; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; @@ -31,108 +29,107 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; +import appeng.api.storage.data.IAEItemStack; import appeng.util.IWideReadableNumberConverter; import appeng.util.ReadableNumberConverter; - /** * Helper methods for rendering TESRs. */ -public class TesrRenderHelper -{ +public class TesrRenderHelper { - private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE; + private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE; - /** - * Rotate the current coordinate system so it is on the face of the given block side. This can be used to render on - * the given face as if it was - * a 2D canvas. - */ - public static void rotateToFace( MatrixStack mStack, Direction face, byte spin ) - { - switch( face ) - { - case UP: - mStack.rotate( Vector3f.XP.rotationDegrees( 90.0F ) ); - mStack.rotate( Vector3f.ZP.rotationDegrees( spin * 90.0F ) ); - break; + /** + * Rotate the current coordinate system so it is on the face of the given block + * side. This can be used to render on the given face as if it was a 2D canvas. + */ + public static void rotateToFace(MatrixStack mStack, Direction face, byte spin) { + switch (face) { + case UP: + mStack.rotate(Vector3f.XP.rotationDegrees(90.0F)); + mStack.rotate(Vector3f.ZP.rotationDegrees(spin * 90.0F)); + break; - case DOWN: - mStack.rotate( Vector3f.XP.rotationDegrees( -90.0F ) ); - mStack.rotate( Vector3f.ZP.rotationDegrees( spin * -90.0F ) ); - break; + case DOWN: + mStack.rotate(Vector3f.XP.rotationDegrees(-90.0F)); + mStack.rotate(Vector3f.ZP.rotationDegrees(spin * -90.0F)); + break; - case EAST: - mStack.rotate( Vector3f.YP.rotationDegrees( 90.0F ) ); - break; + case EAST: + mStack.rotate(Vector3f.YP.rotationDegrees(90.0F)); + break; - case WEST: - mStack.rotate( Vector3f.YP.rotationDegrees( -90.0F ) ); - break; + case WEST: + mStack.rotate(Vector3f.YP.rotationDegrees(-90.0F)); + break; - case NORTH: - mStack.rotate( Vector3f.YP.rotationDegrees( 180.0F ) ); - break; + case NORTH: + mStack.rotate(Vector3f.YP.rotationDegrees(180.0F)); + break; - case SOUTH: - break; + case SOUTH: + break; - default: - break; - } - } + default: + break; + } + } - //TODO, A different approach will have to be used for this from TESRs, -covers, i have ideas. - /** - * Render an item in 2D. - */ - public static void renderItem2d(MatrixStack matrixStack, IRenderTypeBuffer buffers, ItemStack itemStack, float scale, int combinedLightIn, int combinedOverlayIn) - { - if( !itemStack.isEmpty() ) - { - matrixStack.push(); - // Push it out of the block face a bit to avoid z-fighting - matrixStack.translate(0, 0, 0.01f); - // The Z-scaling by 0.0002 causes the model to be visually "flattened" - // This cannot replace a proper projection, but it's cheap and gives the desired - // effect at least from head-on - matrixStack.scale( scale, scale, 0.0002f ); + // TODO, A different approach will have to be used for this from TESRs, -covers, + // i have ideas. + /** + * Render an item in 2D. + */ + public static void renderItem2d(MatrixStack matrixStack, IRenderTypeBuffer buffers, ItemStack itemStack, + float scale, int combinedLightIn, int combinedOverlayIn) { + if (!itemStack.isEmpty()) { + matrixStack.push(); + // Push it out of the block face a bit to avoid z-fighting + matrixStack.translate(0, 0, 0.01f); + // The Z-scaling by 0.0002 causes the model to be visually "flattened" + // This cannot replace a proper projection, but it's cheap and gives the desired + // effect at least from head-on + matrixStack.scale(scale, scale, 0.0002f); - Minecraft.getInstance().getItemRenderer().renderItem(itemStack, ItemCameraTransforms.TransformType.GUI, combinedLightIn, OverlayTexture.NO_OVERLAY, matrixStack, buffers); + Minecraft.getInstance().getItemRenderer().renderItem(itemStack, ItemCameraTransforms.TransformType.GUI, + combinedLightIn, OverlayTexture.NO_OVERLAY, matrixStack, buffers); - matrixStack.pop(); + matrixStack.pop(); - } - } + } + } - /** - * Render an item in 2D and the given text below it. - * @param matrixStack - * @param buffers - * @param spacing Specifies how far apart the item and the item stack amount are rendered. - * @param combinedLightIn - * @param combinedOverlayIn - */ - public static void renderItem2dWithAmount(MatrixStack matrixStack, IRenderTypeBuffer buffers, IAEItemStack itemStack, float itemScale, float spacing, int combinedLightIn, int combinedOverlayIn) - { - final ItemStack renderStack = itemStack.asItemStackRepresentation(); + /** + * Render an item in 2D and the given text below it. + * + * @param matrixStack + * @param buffers + * @param spacing Specifies how far apart the item and the item stack + * amount are rendered. + * @param combinedLightIn + * @param combinedOverlayIn + */ + public static void renderItem2dWithAmount(MatrixStack matrixStack, IRenderTypeBuffer buffers, + IAEItemStack itemStack, float itemScale, float spacing, int combinedLightIn, int combinedOverlayIn) { + final ItemStack renderStack = itemStack.asItemStackRepresentation(); - TesrRenderHelper.renderItem2d( matrixStack, buffers, renderStack, itemScale, combinedLightIn, combinedOverlayIn ); + TesrRenderHelper.renderItem2d(matrixStack, buffers, renderStack, itemScale, combinedLightIn, combinedOverlayIn); - final long stackSize = itemStack.getStackSize(); - final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ); + final long stackSize = itemStack.getStackSize(); + final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize); - // Render the item count - final FontRenderer fr = Minecraft.getInstance().fontRenderer; - final int width = fr.getStringWidth( renderedStackSize ); - matrixStack.push(); - matrixStack.translate( 0.0f, spacing, 0.02f ); - matrixStack.scale( 1.0f / 62.0f, - 1.0f / 62.0f, 1.0f / 62.0f ); - matrixStack.scale(0.5f, 0.5f, 0); - matrixStack.translate( -0.5f * width, 0.0f, 0.5f ); - fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.getLast().getMatrix(), buffers, false, 0, 15728880); - matrixStack.pop(); + // Render the item count + final FontRenderer fr = Minecraft.getInstance().fontRenderer; + final int width = fr.getStringWidth(renderedStackSize); + matrixStack.push(); + matrixStack.translate(0.0f, spacing, 0.02f); + matrixStack.scale(1.0f / 62.0f, -1.0f / 62.0f, 1.0f / 62.0f); + matrixStack.scale(0.5f, 0.5f, 0); + matrixStack.translate(-0.5f * width, 0.0f, 0.5f); + fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.getLast().getMatrix(), buffers, false, 0, + 15728880); + matrixStack.pop(); - - } + } } diff --git a/src/main/java/appeng/client/render/cablebus/CableBuilder.java b/src/main/java/appeng/client/render/cablebus/CableBuilder.java index 548f16e3c..dff5d8897 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBuilder.java +++ b/src/main/java/appeng/client/render/cablebus/CableBuilder.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; @@ -37,735 +36,692 @@ import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.core.AppEng; - /** * A helper class that builds quads for cable connections. */ -class CableBuilder -{ - - // Textures for the cable core types, one per type/color pair - private final EnumMap> coreTextures; - - // Textures for rendering the actual connection cubes, one per type/color pair - private final EnumMap> connectionTextures; - - private final SmartCableTextures smartCableTextures; - - CableBuilder( Function bakedTextureGetter ) - { - this.coreTextures = new EnumMap<>( CableCoreType.class ); - - for( CableCoreType type : CableCoreType.values() ) - { - EnumMap colorTextures = new EnumMap<>( AEColor.class ); - - for( AEColor color : AEColor.values() ) - { - colorTextures.put( color, bakedTextureGetter.apply( type.getTexture( color ) ) ); - } - - this.coreTextures.put( type, colorTextures ); - } - - this.connectionTextures = new EnumMap<>( AECableType.class ); - - for( AECableType type : AECableType.VALIDCABLES ) - { - EnumMap colorTextures = new EnumMap<>( AEColor.class ); - - for( AEColor color : AEColor.values() ) - { - colorTextures.put( color, bakedTextureGetter.apply( getConnectionTexture( type, color ) ) ); - } - - this.connectionTextures.put( type, colorTextures ); - } - - this.smartCableTextures = new SmartCableTextures( bakedTextureGetter ); - } - - static Material getConnectionTexture( AECableType cableType, AEColor color ) - { - String textureFolder; - switch( cableType ) - { - case GLASS: - textureFolder = "parts/cable/glass/"; - break; - case COVERED: - textureFolder = "parts/cable/covered/"; - break; - case SMART: - textureFolder = "parts/cable/smart/"; - break; - case DENSE_COVERED: - textureFolder = "parts/cable/dense_covered/"; - break; - case DENSE_SMART: - textureFolder = "parts/cable/dense_smart/"; - break; - default: - throw new IllegalStateException( "Cable type " + cableType + " does not support connections." ); - } - - return new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, textureFolder + color.name().toLowerCase() ) ); - } - - /** - * Adds the core of a cable to the given list of quads. - * - * The type of cable core is automatically deduced from the given cable type. - */ - public void addCableCore( AECableType cableType, AEColor color, List quadsOut ) - { - switch( cableType ) - { - case GLASS: - this.addCableCore( CableCoreType.GLASS, color, quadsOut ); - break; - case COVERED: - case SMART: - this.addCableCore( CableCoreType.COVERED, color, quadsOut ); - break; - case DENSE_COVERED: - case DENSE_SMART: - this.addCableCore( CableCoreType.DENSE, color, quadsOut ); - break; - default: - } - } - - public void addCableCore( CableCoreType coreType, AEColor color, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.coreTextures.get( coreType ).get( color ); - cubeBuilder.setTexture( texture ); - - switch( coreType ) - { - case GLASS: - cubeBuilder.addCube( 6, 6, 6, 10, 10, 10 ); - break; - case COVERED: - cubeBuilder.addCube( 5, 5, 5, 11, 11, 11 ); - break; - case DENSE: - cubeBuilder.addCube( 3, 3, 3, 13, 13, 13 ); - break; - } - } - - public void addGlassConnection( Direction facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - // We render all faces except the one on the connection side - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) ); - - // For to-machine connections, use a thicker end-cap for the connection - if( connectionType != AECableType.GLASS && !cableBusAdjacent ) - { - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - this.addBigCoveredCableSizedCube( facing, cubeBuilder ); - } - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.GLASS ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 6, 0, 6, 10, 6, 10 ); - break; - case EAST: - cubeBuilder.addCube( 10, 6, 6, 16, 10, 10 ); - break; - case NORTH: - cubeBuilder.addCube( 6, 6, 0, 10, 10, 6 ); - break; - case SOUTH: - cubeBuilder.addCube( 6, 6, 10, 10, 10, 16 ); - break; - case UP: - cubeBuilder.addCube( 6, 10, 6, 10, 16, 10 ); - break; - case WEST: - cubeBuilder.addCube( 0, 6, 6, 6, 10, 10 ); - break; - } - } - - public void addStraightGlassConnection( Direction facing, AEColor cableColor, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - // We render all faces except the connection caps. We can do this because the glass cable is the smallest one - // and its ends will always be covered by something - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing, facing.getOpposite() ) ) ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.GLASS ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - switch( facing ) - { - case DOWN: - case UP: - cubeBuilder.addCube( 6, 0, 6, 10, 16, 10 ); - break; - case NORTH: - case SOUTH: - cubeBuilder.addCube( 6, 6, 0, 10, 10, 16 ); - break; - case EAST: - case WEST: - cubeBuilder.addCube( 0, 6, 6, 16, 10, 10 ); - break; - } - } - - public void addConstrainedGlassConnection( Direction facing, AEColor cableColor, int distanceFromEdge, List quadsOut ) - { - - // Glass connections reach only 6 voxels from the edge - if( distanceFromEdge >= 6 ) - { - return; - } - - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.GLASS ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 6, distanceFromEdge, 6, 10, 6, 10 ); - break; - case EAST: - cubeBuilder.addCube( 10, 6, 6, 16 - distanceFromEdge, 10, 10 ); - break; - case NORTH: - cubeBuilder.addCube( 6, 6, distanceFromEdge, 10, 10, 6 ); - break; - case SOUTH: - cubeBuilder.addCube( 6, 6, 10, 10, 10, 16 - distanceFromEdge ); - break; - case UP: - cubeBuilder.addCube( 6, 10, 6, 10, 16 - distanceFromEdge, 10 ); - break; - case WEST: - cubeBuilder.addCube( distanceFromEdge, 6, 6, 6, 10, 10 ); - break; - } - } - - public void addCoveredConnection( Direction facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List quadsOut ) - { - - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - // We render all faces except the one on the connection side - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - // Draw a covered connection, if anything but glass is requested - if( connectionType != AECableType.GLASS && !cableBusAdjacent ) - { - this.addBigCoveredCableSizedCube( facing, cubeBuilder ); - } - - addCoveredCableSizedCube( facing, cubeBuilder ); - } - - public void addStraightCoveredConnection( Direction facing, AEColor cableColor, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - setStraightCableUVs( cubeBuilder, facing, 5, 11 ); - - addStraightCoveredCableSizedCube( facing, cubeBuilder ); - } - - private static void setStraightCableUVs( CubeBuilder cubeBuilder, Direction facing, int x, int y ) - { - switch( facing ) - { - case DOWN: - case UP: - cubeBuilder.setCustomUv( Direction.NORTH, x, 0, y, x ); - cubeBuilder.setCustomUv( Direction.EAST, x, 0, y, x ); - cubeBuilder.setCustomUv( Direction.SOUTH, x, 0, y, x ); - cubeBuilder.setCustomUv( Direction.WEST, x, 0, y, x ); - break; - case EAST: - case WEST: - cubeBuilder.setCustomUv( Direction.UP, 0, x, x, y ); - cubeBuilder.setCustomUv( Direction.DOWN, 0, x, x, y ); - cubeBuilder.setCustomUv( Direction.NORTH, 0, x, x, y ); - cubeBuilder.setCustomUv( Direction.SOUTH, 0, x, x, y ); - break; - case NORTH: - case SOUTH: - cubeBuilder.setCustomUv( Direction.UP, x, 0, y, x ); - cubeBuilder.setCustomUv( Direction.DOWN, x, 0, y, x ); - cubeBuilder.setCustomUv( Direction.EAST, 0, x, x, y ); - cubeBuilder.setCustomUv( Direction.WEST, 0, x, x, y ); - break; - } - } - - public void addConstrainedCoveredConnection( Direction facing, AEColor cableColor, int distanceFromEdge, List quadsOut ) - { - // The core of a covered cable reaches up to 5 voxels from the block edge, so - // drawing a connection can only occur from there onwards - if( distanceFromEdge >= 5 ) - { - return; - } - - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder ); - } - - public void addSmartConnection( Direction facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List quadsOut ) - { - if( connectionType == AECableType.COVERED || connectionType == AECableType.GLASS ) - { - this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - return; - } - - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - // We render all faces except the one on the connection side - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.SMART ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels( channels ); - TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels( channels ); - - // For to-machine connections, use a thicker end-cap for the connection - if( connectionType != AECableType.GLASS && !cableBusAdjacent ) - { - this.addBigCoveredCableSizedCube( facing, cubeBuilder ); - - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); - - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - this.addBigCoveredCableSizedCube( facing, cubeBuilder ); - - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - this.addBigCoveredCableSizedCube( facing, cubeBuilder ); - - // Reset back to normal rendering for the rest - cubeBuilder.setRenderFullBright( false ); - cubeBuilder.setTexture( texture ); - } - - addCoveredCableSizedCube( facing, cubeBuilder ); - - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); - - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - addCoveredCableSizedCube( facing, cubeBuilder ); - - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - addCoveredCableSizedCube( facing, cubeBuilder ); - } - - public void addStraightSmartConnection( Direction facing, AEColor cableColor, int channels, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.SMART ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - setStraightCableUVs( cubeBuilder, facing, 5, 11 ); - - addStraightCoveredCableSizedCube( facing, cubeBuilder ); - - TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels( channels ); - TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels( channels ); - - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); - - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - addStraightCoveredCableSizedCube( facing, cubeBuilder ); - - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - addStraightCoveredCableSizedCube( facing, cubeBuilder ); - } +class CableBuilder { + + // Textures for the cable core types, one per type/color pair + private final EnumMap> coreTextures; + + // Textures for rendering the actual connection cubes, one per type/color pair + private final EnumMap> connectionTextures; + + private final SmartCableTextures smartCableTextures; + + CableBuilder(Function bakedTextureGetter) { + this.coreTextures = new EnumMap<>(CableCoreType.class); + + for (CableCoreType type : CableCoreType.values()) { + EnumMap colorTextures = new EnumMap<>(AEColor.class); + + for (AEColor color : AEColor.values()) { + colorTextures.put(color, bakedTextureGetter.apply(type.getTexture(color))); + } + + this.coreTextures.put(type, colorTextures); + } + + this.connectionTextures = new EnumMap<>(AECableType.class); + + for (AECableType type : AECableType.VALIDCABLES) { + EnumMap colorTextures = new EnumMap<>(AEColor.class); + + for (AEColor color : AEColor.values()) { + colorTextures.put(color, bakedTextureGetter.apply(getConnectionTexture(type, color))); + } + + this.connectionTextures.put(type, colorTextures); + } + + this.smartCableTextures = new SmartCableTextures(bakedTextureGetter); + } + + static Material getConnectionTexture(AECableType cableType, AEColor color) { + String textureFolder; + switch (cableType) { + case GLASS: + textureFolder = "parts/cable/glass/"; + break; + case COVERED: + textureFolder = "parts/cable/covered/"; + break; + case SMART: + textureFolder = "parts/cable/smart/"; + break; + case DENSE_COVERED: + textureFolder = "parts/cable/dense_covered/"; + break; + case DENSE_SMART: + textureFolder = "parts/cable/dense_smart/"; + break; + default: + throw new IllegalStateException("Cable type " + cableType + " does not support connections."); + } + + return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, textureFolder + color.name().toLowerCase())); + } + + /** + * Adds the core of a cable to the given list of quads. + * + * The type of cable core is automatically deduced from the given cable type. + */ + public void addCableCore(AECableType cableType, AEColor color, List quadsOut) { + switch (cableType) { + case GLASS: + this.addCableCore(CableCoreType.GLASS, color, quadsOut); + break; + case COVERED: + case SMART: + this.addCableCore(CableCoreType.COVERED, color, quadsOut); + break; + case DENSE_COVERED: + case DENSE_SMART: + this.addCableCore(CableCoreType.DENSE, color, quadsOut); + break; + default: + } + } + + public void addCableCore(CableCoreType coreType, AEColor color, List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.coreTextures.get(coreType).get(color); + cubeBuilder.setTexture(texture); + + switch (coreType) { + case GLASS: + cubeBuilder.addCube(6, 6, 6, 10, 10, 10); + break; + case COVERED: + cubeBuilder.addCube(5, 5, 5, 11, 11, 11); + break; + case DENSE: + cubeBuilder.addCube(3, 3, 3, 13, 13, 13); + break; + } + } + + public void addGlassConnection(Direction facing, AEColor cableColor, AECableType connectionType, + boolean cableBusAdjacent, List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + // We render all faces except the one on the connection side + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing))); + + // For to-machine connections, use a thicker end-cap for the connection + if (connectionType != AECableType.GLASS && !cableBusAdjacent) { + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor); + cubeBuilder.setTexture(texture); + + this.addBigCoveredCableSizedCube(facing, cubeBuilder); + } + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor); + cubeBuilder.setTexture(texture); + + switch (facing) { + case DOWN: + cubeBuilder.addCube(6, 0, 6, 10, 6, 10); + break; + case EAST: + cubeBuilder.addCube(10, 6, 6, 16, 10, 10); + break; + case NORTH: + cubeBuilder.addCube(6, 6, 0, 10, 10, 6); + break; + case SOUTH: + cubeBuilder.addCube(6, 6, 10, 10, 10, 16); + break; + case UP: + cubeBuilder.addCube(6, 10, 6, 10, 16, 10); + break; + case WEST: + cubeBuilder.addCube(0, 6, 6, 6, 10, 10); + break; + } + } + + public void addStraightGlassConnection(Direction facing, AEColor cableColor, List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + // We render all faces except the connection caps. We can do this because the + // glass cable is the smallest one + // and its ends will always be covered by something + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing, facing.getOpposite()))); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor); + cubeBuilder.setTexture(texture); + + switch (facing) { + case DOWN: + case UP: + cubeBuilder.addCube(6, 0, 6, 10, 16, 10); + break; + case NORTH: + case SOUTH: + cubeBuilder.addCube(6, 6, 0, 10, 10, 16); + break; + case EAST: + case WEST: + cubeBuilder.addCube(0, 6, 6, 16, 10, 10); + break; + } + } + + public void addConstrainedGlassConnection(Direction facing, AEColor cableColor, int distanceFromEdge, + List quadsOut) { + + // Glass connections reach only 6 voxels from the edge + if (distanceFromEdge >= 6) { + return; + } + + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor); + cubeBuilder.setTexture(texture); + + switch (facing) { + case DOWN: + cubeBuilder.addCube(6, distanceFromEdge, 6, 10, 6, 10); + break; + case EAST: + cubeBuilder.addCube(10, 6, 6, 16 - distanceFromEdge, 10, 10); + break; + case NORTH: + cubeBuilder.addCube(6, 6, distanceFromEdge, 10, 10, 6); + break; + case SOUTH: + cubeBuilder.addCube(6, 6, 10, 10, 10, 16 - distanceFromEdge); + break; + case UP: + cubeBuilder.addCube(6, 10, 6, 10, 16 - distanceFromEdge, 10); + break; + case WEST: + cubeBuilder.addCube(distanceFromEdge, 6, 6, 6, 10, 10); + break; + } + } + + public void addCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType, + boolean cableBusAdjacent, List quadsOut) { + + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + // We render all faces except the one on the connection side + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing))); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor); + cubeBuilder.setTexture(texture); + + // Draw a covered connection, if anything but glass is requested + if (connectionType != AECableType.GLASS && !cableBusAdjacent) { + this.addBigCoveredCableSizedCube(facing, cubeBuilder); + } + + addCoveredCableSizedCube(facing, cubeBuilder); + } + + public void addStraightCoveredConnection(Direction facing, AEColor cableColor, List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor); + cubeBuilder.setTexture(texture); + + setStraightCableUVs(cubeBuilder, facing, 5, 11); + + addStraightCoveredCableSizedCube(facing, cubeBuilder); + } + + private static void setStraightCableUVs(CubeBuilder cubeBuilder, Direction facing, int x, int y) { + switch (facing) { + case DOWN: + case UP: + cubeBuilder.setCustomUv(Direction.NORTH, x, 0, y, x); + cubeBuilder.setCustomUv(Direction.EAST, x, 0, y, x); + cubeBuilder.setCustomUv(Direction.SOUTH, x, 0, y, x); + cubeBuilder.setCustomUv(Direction.WEST, x, 0, y, x); + break; + case EAST: + case WEST: + cubeBuilder.setCustomUv(Direction.UP, 0, x, x, y); + cubeBuilder.setCustomUv(Direction.DOWN, 0, x, x, y); + cubeBuilder.setCustomUv(Direction.NORTH, 0, x, x, y); + cubeBuilder.setCustomUv(Direction.SOUTH, 0, x, x, y); + break; + case NORTH: + case SOUTH: + cubeBuilder.setCustomUv(Direction.UP, x, 0, y, x); + cubeBuilder.setCustomUv(Direction.DOWN, x, 0, y, x); + cubeBuilder.setCustomUv(Direction.EAST, 0, x, x, y); + cubeBuilder.setCustomUv(Direction.WEST, 0, x, x, y); + break; + } + } + + public void addConstrainedCoveredConnection(Direction facing, AEColor cableColor, int distanceFromEdge, + List quadsOut) { + // The core of a covered cable reaches up to 5 voxels from the block edge, so + // drawing a connection can only occur from there onwards + if (distanceFromEdge >= 5) { + return; + } + + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor); + cubeBuilder.setTexture(texture); + + addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder); + } + + public void addSmartConnection(Direction facing, AEColor cableColor, AECableType connectionType, + boolean cableBusAdjacent, int channels, List quadsOut) { + if (connectionType == AECableType.COVERED || connectionType == AECableType.GLASS) { + this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut); + return; + } + + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + // We render all faces except the one on the connection side + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing))); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor); + cubeBuilder.setTexture(texture); + + TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels); + TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels); + + // For to-machine connections, use a thicker end-cap for the connection + if (connectionType != AECableType.GLASS && !cableBusAdjacent) { + this.addBigCoveredCableSizedCube(facing, cubeBuilder); + + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); + + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + this.addBigCoveredCableSizedCube(facing, cubeBuilder); - public void addConstrainedSmartConnection( Direction facing, AEColor cableColor, int distanceFromEdge, int channels, List quadsOut ) - { - // Same as with covered cables, the smart cable's core extends up to 5 voxels away from the edge. - // Drawing a connection to any point before that point is fruitless - if( distanceFromEdge >= 5 ) - { - return; - } + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + this.addBigCoveredCableSizedCube(facing, cubeBuilder); + + // Reset back to normal rendering for the rest + cubeBuilder.setRenderFullBright(false); + cubeBuilder.setTexture(texture); + } + + addCoveredCableSizedCube(facing, cubeBuilder); + + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); + + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + addCoveredCableSizedCube(facing, cubeBuilder); + + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + addCoveredCableSizedCube(facing, cubeBuilder); + } + + public void addStraightSmartConnection(Direction facing, AEColor cableColor, int channels, + List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor); + cubeBuilder.setTexture(texture); + + setStraightCableUVs(cubeBuilder, facing, 5, 11); + + addStraightCoveredCableSizedCube(facing, cubeBuilder); + + TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels); + TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels); + + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); + + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + addStraightCoveredCableSizedCube(facing, cubeBuilder); - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + addStraightCoveredCableSizedCube(facing, cubeBuilder); + } - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.SMART ).get( cableColor ); - cubeBuilder.setTexture( texture ); + public void addConstrainedSmartConnection(Direction facing, AEColor cableColor, int distanceFromEdge, int channels, + List quadsOut) { + // Same as with covered cables, the smart cable's core extends up to 5 voxels + // away from the edge. + // Drawing a connection to any point before that point is fruitless + if (distanceFromEdge >= 5) { + return; + } - addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder ); + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); - TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels( channels ); - TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels( channels ); + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor); + cubeBuilder.setTexture(texture); - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); + addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder); - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder ); + TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels); + TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels); - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder ); - } + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); - public void addDenseCoveredConnection( Direction facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List quadsOut ) - { - // Dense cables only render their connections as dense if the adjacent blocks actually wants that - if( connectionType == AECableType.COVERED || connectionType == AECableType.SMART || connectionType == AECableType.GLASS ) - { - this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - return; - } + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder); - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder); + } - // We render all faces except the one on the connection side - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) ); + public void addDenseCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType, + boolean cableBusAdjacent, List quadsOut) { + // Dense cables only render their connections as dense if the adjacent blocks + // actually wants that + if (connectionType == AECableType.COVERED || connectionType == AECableType.SMART + || connectionType == AECableType.GLASS) { + this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut); + return; + } - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); - addDenseCableSizedCube( facing, cubeBuilder ); + // We render all faces except the one on the connection side + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing))); - // Reset back to normal rendering for the rest - cubeBuilder.setRenderFullBright( false ); - cubeBuilder.setTexture( texture ); - } + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.DENSE_COVERED).get(cableColor); + cubeBuilder.setTexture(texture); - public void addDenseSmartConnection( Direction facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List quadsOut ) - { - // Dense cables only render their connections as dense if the adjacent blocks actually wants that - if( connectionType == AECableType.SMART ) - { - this.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut ); - return; - } - else if( connectionType == AECableType.COVERED || connectionType == AECableType.GLASS ) - { - this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - return; - } - else if( connectionType == AECableType.DENSE_COVERED ) - { - this.addDenseCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - return; - } - - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - // We render all faces except the one on the connection side - cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_SMART ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - addDenseCableSizedCube( facing, cubeBuilder ); - - // Dense cables show used channels in groups of 4, rounded up - channels = ( channels + 3 ) / 4; - - TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels( channels ); - TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels( channels ); - - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); - - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - addDenseCableSizedCube( facing, cubeBuilder ); - - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - addDenseCableSizedCube( facing, cubeBuilder ); - - // Reset back to normal rendering for the rest - cubeBuilder.setRenderFullBright( false ); - cubeBuilder.setTexture( texture ); - } - - public void addStraightDenseCoveredConnection( Direction facing, AEColor cableColor, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - setStraightCableUVs( cubeBuilder, facing, 5, 11 ); - - addStraightDenseCableSizedCube( facing, cubeBuilder ); - } - - public void addStraightDenseSmartConnection( Direction facing, AEColor cableColor, int channels, List quadsOut ) - { - CubeBuilder cubeBuilder = new CubeBuilder( quadsOut ); - - TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_SMART ).get( cableColor ); - cubeBuilder.setTexture( texture ); - - setStraightCableUVs( cubeBuilder, facing, 5, 11 ); - - addStraightDenseCableSizedCube( facing, cubeBuilder ); - - // Dense cables show used channels in groups of 4, rounded up - channels = ( channels + 3 ) / 4; - - TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels( channels ); - TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels( channels ); - - // Render the channel indicators brightly lit at night - cubeBuilder.setRenderFullBright( true ); - - cubeBuilder.setTexture( oddChannel ); - cubeBuilder.setColorRGB( cableColor.blackVariant ); - addStraightDenseCableSizedCube( facing, cubeBuilder ); - - cubeBuilder.setTexture( evenChannel ); - cubeBuilder.setColorRGB( cableColor.whiteVariant ); - addStraightDenseCableSizedCube( facing, cubeBuilder ); - } - - private static void addDenseCableSizedCube( Direction facing, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 4, 0, 4, 12, 5, 12 ); - break; - case EAST: - cubeBuilder.addCube( 11, 4, 4, 16, 12, 12 ); - break; - case NORTH: - cubeBuilder.addCube( 4, 4, 0, 12, 12, 5 ); - break; - case SOUTH: - cubeBuilder.addCube( 4, 4, 11, 12, 12, 16 ); - break; - case UP: - cubeBuilder.addCube( 4, 11, 4, 12, 16, 12 ); - break; - case WEST: - cubeBuilder.addCube( 0, 4, 4, 5, 12, 12 ); - break; - } - } - - // Adds a cube to the given cube builder that has the size of a dense cable connection and spans the entire block - // for the given direction - private static void addStraightDenseCableSizedCube( Direction facing, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - case UP: - cubeBuilder.setUvRotation( Direction.EAST, 3 ); - cubeBuilder.addCube( 3, 0, 3, 13, 16, 13 ); - cubeBuilder.setUvRotation( Direction.EAST, 0 ); - break; - case EAST: - case WEST: - cubeBuilder.setUvRotation( Direction.SOUTH, 3 ); - cubeBuilder.setUvRotation( Direction.NORTH, 3 ); - cubeBuilder.addCube( 0, 3, 3, 16, 13, 13 ); - cubeBuilder.setUvRotation( Direction.SOUTH, 0 ); - cubeBuilder.setUvRotation( Direction.NORTH, 0 ); - break; - case NORTH: - case SOUTH: - cubeBuilder.setUvRotation( Direction.EAST, 3 ); - cubeBuilder.setUvRotation( Direction.WEST, 3 ); - cubeBuilder.addCube( 3, 3, 0, 13, 13, 16 ); - cubeBuilder.setUvRotation( Direction.EAST, 0 ); - cubeBuilder.setUvRotation( Direction.WEST, 0 ); - break; - } - } - - // Adds a cube to the given cube builder that has the size of a covered cable connection from the core of the cable - // to the given face - private static void addCoveredCableSizedCube( Direction facing, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 6, 0, 6, 10, 5, 10 ); - break; - case EAST: - cubeBuilder.addCube( 11, 6, 6, 16, 10, 10 ); - break; - case NORTH: - cubeBuilder.addCube( 6, 6, 0, 10, 10, 5 ); - break; - case SOUTH: - cubeBuilder.addCube( 6, 6, 11, 10, 10, 16 ); - break; - case UP: - cubeBuilder.addCube( 6, 11, 6, 10, 16, 10 ); - break; - case WEST: - cubeBuilder.addCube( 0, 6, 6, 5, 10, 10 ); - break; - } - } - - // Adds a cube to the given cube builder that has the size of a covered cable connection and spans the entire block - // for the given direction - private static void addStraightCoveredCableSizedCube( Direction facing, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - case UP: - cubeBuilder.setUvRotation( Direction.EAST, 3 ); - cubeBuilder.addCube( 5, 0, 5, 11, 16, 11 ); - cubeBuilder.setUvRotation( Direction.EAST, 0 ); - break; - case EAST: - case WEST: - cubeBuilder.setUvRotation( Direction.SOUTH, 3 ); - cubeBuilder.setUvRotation( Direction.NORTH, 3 ); - cubeBuilder.addCube( 0, 5, 5, 16, 11, 11 ); - cubeBuilder.setUvRotation( Direction.SOUTH, 0 ); - cubeBuilder.setUvRotation( Direction.NORTH, 0 ); - break; - case NORTH: - case SOUTH: - cubeBuilder.setUvRotation( Direction.EAST, 3 ); - cubeBuilder.setUvRotation( Direction.WEST, 3 ); - cubeBuilder.addCube( 5, 5, 0, 11, 11, 16 ); - cubeBuilder.setUvRotation( Direction.EAST, 0 ); - cubeBuilder.setUvRotation( Direction.WEST, 0 ); - break; - } - } - - private static void addCoveredCableSizedCube( Direction facing, int distanceFromEdge, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 6, distanceFromEdge, 6, 10, 5, 10 ); - break; - case EAST: - cubeBuilder.addCube( 11, 6, 6, 16 - distanceFromEdge, 10, 10 ); - break; - case NORTH: - cubeBuilder.addCube( 6, 6, distanceFromEdge, 10, 10, 5 ); - break; - case SOUTH: - cubeBuilder.addCube( 6, 6, 11, 10, 10, 16 - distanceFromEdge ); - break; - case UP: - cubeBuilder.addCube( 6, 11, 6, 10, 16 - distanceFromEdge, 10 ); - break; - case WEST: - cubeBuilder.addCube( distanceFromEdge, 6, 6, 5, 10, 10 ); - break; - } - } - - /** - * This renders a slightly bigger covered cable connection to the specified side. This is used to connect cable - * cores with adjacent machines - * that do not want to be connected to using a glass cable connection. This applies to most machines (interfaces, - * etc.) - */ - private void addBigCoveredCableSizedCube( Direction facing, CubeBuilder cubeBuilder ) - { - switch( facing ) - { - case DOWN: - cubeBuilder.addCube( 5, 0, 5, 11, 4, 11 ); - break; - case EAST: - cubeBuilder.addCube( 12, 5, 5, 16, 11, 11 ); - break; - case NORTH: - cubeBuilder.addCube( 5, 5, 0, 11, 11, 4 ); - break; - case SOUTH: - cubeBuilder.addCube( 5, 5, 12, 11, 11, 16 ); - break; - case UP: - cubeBuilder.addCube( 5, 12, 5, 11, 16, 11 ); - break; - case WEST: - cubeBuilder.addCube( 0, 5, 5, 4, 11, 11 ); - break; - } - } - - // Get all textures needed for building the actual cable quads - public static List getTextures() - { - List locations = new ArrayList<>(); - - for( CableCoreType coreType : CableCoreType.values() ) - { - for( AEColor color : AEColor.values() ) - { - locations.add( coreType.getTexture( color ) ); - } - } - - for( AECableType cableType : AECableType.VALIDCABLES ) - { - for( AEColor color : AEColor.values() ) - { - locations.add( getConnectionTexture( cableType, color ) ); - } - } - - Collections.addAll( locations, SmartCableTextures.SMART_CHANNELS_TEXTURES ); - - return locations; - } - - public TextureAtlasSprite getCoreTexture( CableCoreType coreType, AEColor color ) - { - return this.coreTextures.get( coreType ).get( color ); - } + addDenseCableSizedCube(facing, cubeBuilder); + + // Reset back to normal rendering for the rest + cubeBuilder.setRenderFullBright(false); + cubeBuilder.setTexture(texture); + } + + public void addDenseSmartConnection(Direction facing, AEColor cableColor, AECableType connectionType, + boolean cableBusAdjacent, int channels, List quadsOut) { + // Dense cables only render their connections as dense if the adjacent blocks + // actually wants that + if (connectionType == AECableType.SMART) { + this.addSmartConnection(facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut); + return; + } else if (connectionType == AECableType.COVERED || connectionType == AECableType.GLASS) { + this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut); + return; + } else if (connectionType == AECableType.DENSE_COVERED) { + this.addDenseCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut); + return; + } + + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + // We render all faces except the one on the connection side + cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing))); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.DENSE_SMART).get(cableColor); + cubeBuilder.setTexture(texture); + + addDenseCableSizedCube(facing, cubeBuilder); + + // Dense cables show used channels in groups of 4, rounded up + channels = (channels + 3) / 4; + + TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels); + TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels); + + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); + + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + addDenseCableSizedCube(facing, cubeBuilder); + + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + addDenseCableSizedCube(facing, cubeBuilder); + + // Reset back to normal rendering for the rest + cubeBuilder.setRenderFullBright(false); + cubeBuilder.setTexture(texture); + } + + public void addStraightDenseCoveredConnection(Direction facing, AEColor cableColor, List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.DENSE_COVERED).get(cableColor); + cubeBuilder.setTexture(texture); + + setStraightCableUVs(cubeBuilder, facing, 5, 11); + + addStraightDenseCableSizedCube(facing, cubeBuilder); + } + + public void addStraightDenseSmartConnection(Direction facing, AEColor cableColor, int channels, + List quadsOut) { + CubeBuilder cubeBuilder = new CubeBuilder(quadsOut); + + TextureAtlasSprite texture = this.connectionTextures.get(AECableType.DENSE_SMART).get(cableColor); + cubeBuilder.setTexture(texture); + + setStraightCableUVs(cubeBuilder, facing, 5, 11); + + addStraightDenseCableSizedCube(facing, cubeBuilder); + + // Dense cables show used channels in groups of 4, rounded up + channels = (channels + 3) / 4; + + TextureAtlasSprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels); + TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels); + + // Render the channel indicators brightly lit at night + cubeBuilder.setRenderFullBright(true); + + cubeBuilder.setTexture(oddChannel); + cubeBuilder.setColorRGB(cableColor.blackVariant); + addStraightDenseCableSizedCube(facing, cubeBuilder); + + cubeBuilder.setTexture(evenChannel); + cubeBuilder.setColorRGB(cableColor.whiteVariant); + addStraightDenseCableSizedCube(facing, cubeBuilder); + } + + private static void addDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + cubeBuilder.addCube(4, 0, 4, 12, 5, 12); + break; + case EAST: + cubeBuilder.addCube(11, 4, 4, 16, 12, 12); + break; + case NORTH: + cubeBuilder.addCube(4, 4, 0, 12, 12, 5); + break; + case SOUTH: + cubeBuilder.addCube(4, 4, 11, 12, 12, 16); + break; + case UP: + cubeBuilder.addCube(4, 11, 4, 12, 16, 12); + break; + case WEST: + cubeBuilder.addCube(0, 4, 4, 5, 12, 12); + break; + } + } + + // Adds a cube to the given cube builder that has the size of a dense cable + // connection and spans the entire block + // for the given direction + private static void addStraightDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + case UP: + cubeBuilder.setUvRotation(Direction.EAST, 3); + cubeBuilder.addCube(3, 0, 3, 13, 16, 13); + cubeBuilder.setUvRotation(Direction.EAST, 0); + break; + case EAST: + case WEST: + cubeBuilder.setUvRotation(Direction.SOUTH, 3); + cubeBuilder.setUvRotation(Direction.NORTH, 3); + cubeBuilder.addCube(0, 3, 3, 16, 13, 13); + cubeBuilder.setUvRotation(Direction.SOUTH, 0); + cubeBuilder.setUvRotation(Direction.NORTH, 0); + break; + case NORTH: + case SOUTH: + cubeBuilder.setUvRotation(Direction.EAST, 3); + cubeBuilder.setUvRotation(Direction.WEST, 3); + cubeBuilder.addCube(3, 3, 0, 13, 13, 16); + cubeBuilder.setUvRotation(Direction.EAST, 0); + cubeBuilder.setUvRotation(Direction.WEST, 0); + break; + } + } + + // Adds a cube to the given cube builder that has the size of a covered cable + // connection from the core of the cable + // to the given face + private static void addCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + cubeBuilder.addCube(6, 0, 6, 10, 5, 10); + break; + case EAST: + cubeBuilder.addCube(11, 6, 6, 16, 10, 10); + break; + case NORTH: + cubeBuilder.addCube(6, 6, 0, 10, 10, 5); + break; + case SOUTH: + cubeBuilder.addCube(6, 6, 11, 10, 10, 16); + break; + case UP: + cubeBuilder.addCube(6, 11, 6, 10, 16, 10); + break; + case WEST: + cubeBuilder.addCube(0, 6, 6, 5, 10, 10); + break; + } + } + + // Adds a cube to the given cube builder that has the size of a covered cable + // connection and spans the entire block + // for the given direction + private static void addStraightCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + case UP: + cubeBuilder.setUvRotation(Direction.EAST, 3); + cubeBuilder.addCube(5, 0, 5, 11, 16, 11); + cubeBuilder.setUvRotation(Direction.EAST, 0); + break; + case EAST: + case WEST: + cubeBuilder.setUvRotation(Direction.SOUTH, 3); + cubeBuilder.setUvRotation(Direction.NORTH, 3); + cubeBuilder.addCube(0, 5, 5, 16, 11, 11); + cubeBuilder.setUvRotation(Direction.SOUTH, 0); + cubeBuilder.setUvRotation(Direction.NORTH, 0); + break; + case NORTH: + case SOUTH: + cubeBuilder.setUvRotation(Direction.EAST, 3); + cubeBuilder.setUvRotation(Direction.WEST, 3); + cubeBuilder.addCube(5, 5, 0, 11, 11, 16); + cubeBuilder.setUvRotation(Direction.EAST, 0); + cubeBuilder.setUvRotation(Direction.WEST, 0); + break; + } + } + + private static void addCoveredCableSizedCube(Direction facing, int distanceFromEdge, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + cubeBuilder.addCube(6, distanceFromEdge, 6, 10, 5, 10); + break; + case EAST: + cubeBuilder.addCube(11, 6, 6, 16 - distanceFromEdge, 10, 10); + break; + case NORTH: + cubeBuilder.addCube(6, 6, distanceFromEdge, 10, 10, 5); + break; + case SOUTH: + cubeBuilder.addCube(6, 6, 11, 10, 10, 16 - distanceFromEdge); + break; + case UP: + cubeBuilder.addCube(6, 11, 6, 10, 16 - distanceFromEdge, 10); + break; + case WEST: + cubeBuilder.addCube(distanceFromEdge, 6, 6, 5, 10, 10); + break; + } + } + + /** + * This renders a slightly bigger covered cable connection to the specified + * side. This is used to connect cable cores with adjacent machines that do not + * want to be connected to using a glass cable connection. This applies to most + * machines (interfaces, etc.) + */ + private void addBigCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) { + switch (facing) { + case DOWN: + cubeBuilder.addCube(5, 0, 5, 11, 4, 11); + break; + case EAST: + cubeBuilder.addCube(12, 5, 5, 16, 11, 11); + break; + case NORTH: + cubeBuilder.addCube(5, 5, 0, 11, 11, 4); + break; + case SOUTH: + cubeBuilder.addCube(5, 5, 12, 11, 11, 16); + break; + case UP: + cubeBuilder.addCube(5, 12, 5, 11, 16, 11); + break; + case WEST: + cubeBuilder.addCube(0, 5, 5, 4, 11, 11); + break; + } + } + + // Get all textures needed for building the actual cable quads + public static List getTextures() { + List locations = new ArrayList<>(); + + for (CableCoreType coreType : CableCoreType.values()) { + for (AEColor color : AEColor.values()) { + locations.add(coreType.getTexture(color)); + } + } + + for (AECableType cableType : AECableType.VALIDCABLES) { + for (AEColor color : AEColor.values()) { + locations.add(getConnectionTexture(cableType, color)); + } + } + + Collections.addAll(locations, SmartCableTextures.SMART_CHANNELS_TEXTURES); + + return locations; + } + + public TextureAtlasSprite getCoreTexture(CableCoreType coreType, AEColor color) { + return this.coreTextures.get(coreType).get(color); + } } diff --git a/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java b/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java index e6a218364..cdde27b7f 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; @@ -28,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Random; + import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -48,324 +48,301 @@ import appeng.api.parts.IPartModel; import appeng.api.util.AECableType; import appeng.api.util.AEColor; +public class CableBusBakedModel implements IBakedModel { -public class CableBusBakedModel implements IBakedModel -{ + private static final Map> CABLE_MODEL_CACHE = new HashMap<>(); - private static final Map> CABLE_MODEL_CACHE = new HashMap<>(); + private final CableBuilder cableBuilder; - private final CableBuilder cableBuilder; + private final FacadeBuilder facadeBuilder; - private final FacadeBuilder facadeBuilder; + private final Map partModels; - private final Map partModels; + private final TextureAtlasSprite particleTexture; - private final TextureAtlasSprite particleTexture; + CableBusBakedModel(CableBuilder cableBuilder, FacadeBuilder facadeBuilder, + Map partModels, TextureAtlasSprite particleTexture) { + this.cableBuilder = cableBuilder; + this.facadeBuilder = facadeBuilder; + this.partModels = partModels; + this.particleTexture = particleTexture; + } - CableBusBakedModel( CableBuilder cableBuilder, FacadeBuilder facadeBuilder, Map partModels, TextureAtlasSprite particleTexture ) - { - this.cableBuilder = cableBuilder; - this.facadeBuilder = facadeBuilder; - this.partModels = partModels; - this.particleTexture = particleTexture; - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return getQuads(state, side, rand, EmptyModelData.INSTANCE); + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - return getQuads( state, side, rand, EmptyModelData.INSTANCE ); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData data) { + CableBusRenderState renderState = data.getData(CableBusRenderState.PROPERTY); - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data ) - { - CableBusRenderState renderState = data.getData( CableBusRenderState.PROPERTY ); + if (renderState == null || side != null) { + return Collections.emptyList(); + } - if( renderState == null || side != null ) - { - return Collections.emptyList(); - } + RenderType layer = MinecraftForgeClient.getRenderLayer(); - RenderType layer = MinecraftForgeClient.getRenderLayer(); + List quads = new ArrayList<>(); - List quads = new ArrayList<>(); + // The core parts of the cable will only be rendered in the CUTOUT layer. + // Facades will add them selves to what ever the block would be rendered with, + // except when transparent facades are enabled, they are forced to TRANSPARENT. + if (layer == RenderType.getCutout()) { - // The core parts of the cable will only be rendered in the CUTOUT layer. - // Facades will add them selves to what ever the block would be rendered with, - // except when transparent facades are enabled, they are forced to TRANSPARENT. - if( layer == RenderType.getCutout() ) - { + // First, handle the cable at the center of the cable bus + final List cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k -> { + final List model = new ArrayList<>(); + this.addCableQuads(renderState, model); + return model; + }); + quads.addAll(cableModel); - // First, handle the cable at the center of the cable bus - final List cableModel = CABLE_MODEL_CACHE.computeIfAbsent( renderState, k -> { - final List model = new ArrayList<>(); - this.addCableQuads( renderState, model ); - return model; - } ); - quads.addAll( cableModel ); + // Then handle attachments + for (Direction facing : Direction.values()) { + final IPartModel partModel = renderState.getAttachments().get(facing); + if (partModel == null) { + continue; + } - // Then handle attachments - for( Direction facing : Direction.values() ) - { - final IPartModel partModel = renderState.getAttachments().get( facing ); - if( partModel == null ) - { - continue; - } + IModelData partModelData = renderState.getPartModelData().get(facing); + if (partModelData == null) { + partModelData = EmptyModelData.INSTANCE; + } - IModelData partModelData = renderState.getPartModelData().get(facing); - if (partModelData == null) { - partModelData = EmptyModelData.INSTANCE; - } + for (ResourceLocation model : partModel.getModels()) { + IBakedModel bakedModel = this.partModels.get(model); - for( ResourceLocation model : partModel.getModels() ) - { - IBakedModel bakedModel = this.partModels.get( model ); + if (bakedModel == null) { + throw new IllegalStateException("Trying to use an unregistered part model: " + model); + } - if( bakedModel == null ) - { - throw new IllegalStateException( "Trying to use an unregistered part model: " + model ); - } + List partQuads = bakedModel.getQuads(state, null, rand, partModelData); - List partQuads = bakedModel.getQuads(state, null, rand, partModelData); + // Rotate quads accordingly + QuadRotator rotator = new QuadRotator(); + partQuads = rotator.rotateQuads(partQuads, facing, Direction.UP); - // Rotate quads accordingly - QuadRotator rotator = new QuadRotator(); - partQuads = rotator.rotateQuads( partQuads, facing, Direction.UP ); + quads.addAll(partQuads); + } + } + } + this.facadeBuilder.buildFacadeQuads(layer, renderState, rand, quads, this.partModels::get); - quads.addAll( partQuads ); - } - } - } - this.facadeBuilder.buildFacadeQuads( layer, renderState, rand, quads, this.partModels::get ); + return quads; + } - return quads; - } + // Determines whether a cable is connected to exactly two sides that are + // opposite each other + private static boolean isStraightLine(AECableType cableType, EnumMap sides) { + final Iterator> it = sides.entrySet().iterator(); + if (!it.hasNext()) { + return false; // No connections + } - // Determines whether a cable is connected to exactly two sides that are opposite each other - private static boolean isStraightLine( AECableType cableType, EnumMap sides ) - { - final Iterator> it = sides.entrySet().iterator(); - if( !it.hasNext() ) - { - return false; // No connections - } + final Entry nextConnection = it.next(); + final Direction firstSide = nextConnection.getKey(); + final AECableType firstType = nextConnection.getValue(); - final Entry nextConnection = it.next(); - final Direction firstSide = nextConnection.getKey(); - final AECableType firstType = nextConnection.getValue(); + if (!it.hasNext()) { + return false; // Only a single connection + } + if (firstSide.getOpposite() != it.next().getKey()) { + return false; // Connected to two sides that are not opposite each other + } + if (it.hasNext()) { + return false; // Must not have any other connection points + } - if( !it.hasNext() ) - { - return false; // Only a single connection - } - if( firstSide.getOpposite() != it.next().getKey() ) - { - return false; // Connected to two sides that are not opposite each other - } - if( it.hasNext() ) - { - return false; // Must not have any other connection points - } + final AECableType secondType = sides.get(firstSide.getOpposite()); - final AECableType secondType = sides.get( firstSide.getOpposite() ); + return firstType == secondType && cableType == firstType && cableType == secondType; + } - return firstType == secondType && cableType == firstType && cableType == secondType; - } + private void addCableQuads(CableBusRenderState renderState, List quadsOut) { + AECableType cableType = renderState.getCableType(); + if (cableType == AECableType.NONE) { + return; + } - private void addCableQuads( CableBusRenderState renderState, List quadsOut ) - { - AECableType cableType = renderState.getCableType(); - if( cableType == AECableType.NONE ) - { - return; - } + AEColor cableColor = renderState.getCableColor(); + EnumMap connectionTypes = renderState.getConnectionTypes(); - AEColor cableColor = renderState.getCableColor(); - EnumMap connectionTypes = renderState.getConnectionTypes(); + // If the connection is straight, no busses are attached, and no covered core + // has been forced (in case of glass + // cables), then render the cable as a simplified straight line. + boolean noAttachments = !renderState.getAttachments().values().stream() + .anyMatch(IPartModel::requireCableConnection); + if (noAttachments && isStraightLine(cableType, connectionTypes)) { + Direction facing = connectionTypes.keySet().iterator().next(); - // If the connection is straight, no busses are attached, and no covered core has been forced (in case of glass - // cables), then render the cable as a simplified straight line. - boolean noAttachments = !renderState.getAttachments().values().stream().anyMatch( IPartModel::requireCableConnection ); - if( noAttachments && isStraightLine( cableType, connectionTypes ) ) - { - Direction facing = connectionTypes.keySet().iterator().next(); + switch (cableType) { + case GLASS: + this.cableBuilder.addStraightGlassConnection(facing, cableColor, quadsOut); + break; + case COVERED: + this.cableBuilder.addStraightCoveredConnection(facing, cableColor, quadsOut); + break; + case SMART: + this.cableBuilder.addStraightSmartConnection(facing, cableColor, + renderState.getChannelsOnSide().get(facing), quadsOut); + break; + case DENSE_COVERED: + this.cableBuilder.addStraightDenseCoveredConnection(facing, cableColor, quadsOut); + break; + case DENSE_SMART: + this.cableBuilder.addStraightDenseSmartConnection(facing, cableColor, + renderState.getChannelsOnSide().get(facing), quadsOut); + break; + default: + break; + } - switch( cableType ) - { - case GLASS: - this.cableBuilder.addStraightGlassConnection( facing, cableColor, quadsOut ); - break; - case COVERED: - this.cableBuilder.addStraightCoveredConnection( facing, cableColor, quadsOut ); - break; - case SMART: - this.cableBuilder.addStraightSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut ); - break; - case DENSE_COVERED: - this.cableBuilder.addStraightDenseCoveredConnection( facing, cableColor, quadsOut ); - break; - case DENSE_SMART: - this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut ); - break; - default: - break; - } + return; // Don't render the other form of connection + } - return; // Don't render the other form of connection - } + this.cableBuilder.addCableCore(renderState.getCoreType(), cableColor, quadsOut); - this.cableBuilder.addCableCore( renderState.getCoreType(), cableColor, quadsOut ); + // Render all internal connections to attachments + EnumMap attachmentConnections = renderState.getAttachmentConnections(); + for (Direction facing : attachmentConnections.keySet()) { + int distance = attachmentConnections.get(facing); + int channels = renderState.getChannelsOnSide().get(facing); - // Render all internal connections to attachments - EnumMap attachmentConnections = renderState.getAttachmentConnections(); - for( Direction facing : attachmentConnections.keySet() ) - { - int distance = attachmentConnections.get( facing ); - int channels = renderState.getChannelsOnSide().get( facing ); + switch (cableType) { + case GLASS: + this.cableBuilder.addConstrainedGlassConnection(facing, cableColor, distance, quadsOut); + break; + case COVERED: + this.cableBuilder.addConstrainedCoveredConnection(facing, cableColor, distance, quadsOut); + break; + case SMART: + this.cableBuilder.addConstrainedSmartConnection(facing, cableColor, distance, channels, quadsOut); + break; + case DENSE_COVERED: + case DENSE_SMART: + // Dense cables do not render connections to parts since none can be attached + break; + default: + break; + } + } - switch( cableType ) - { - case GLASS: - this.cableBuilder.addConstrainedGlassConnection( facing, cableColor, distance, quadsOut ); - break; - case COVERED: - this.cableBuilder.addConstrainedCoveredConnection( facing, cableColor, distance, quadsOut ); - break; - case SMART: - this.cableBuilder.addConstrainedSmartConnection( facing, cableColor, distance, channels, quadsOut ); - break; - case DENSE_COVERED: - case DENSE_SMART: - // Dense cables do not render connections to parts since none can be attached - break; - default: - break; - } - } + // Render all outgoing connections using the appropriate type + for (final Entry connection : connectionTypes.entrySet()) { + final Direction facing = connection.getKey(); + final AECableType connectionType = connection.getValue(); + final boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains(facing); + final int channels = renderState.getChannelsOnSide().get(facing); - // Render all outgoing connections using the appropriate type - for( final Entry connection : connectionTypes.entrySet() ) - { - final Direction facing = connection.getKey(); - final AECableType connectionType = connection.getValue(); - final boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing ); - final int channels = renderState.getChannelsOnSide().get( facing ); + switch (cableType) { + case GLASS: + this.cableBuilder.addGlassConnection(facing, cableColor, connectionType, cableBusAdjacent, + quadsOut); + break; + case COVERED: + this.cableBuilder.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, + quadsOut); + break; + case SMART: + this.cableBuilder.addSmartConnection(facing, cableColor, connectionType, cableBusAdjacent, channels, + quadsOut); + break; + case DENSE_COVERED: + this.cableBuilder.addDenseCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, + quadsOut); + break; + case DENSE_SMART: + this.cableBuilder.addDenseSmartConnection(facing, cableColor, connectionType, cableBusAdjacent, + channels, quadsOut); + break; + default: + break; + } + } + } - switch( cableType ) - { - case GLASS: - this.cableBuilder.addGlassConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - break; - case COVERED: - this.cableBuilder.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - break; - case SMART: - this.cableBuilder.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut ); - break; - case DENSE_COVERED: - this.cableBuilder.addDenseCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut ); - break; - case DENSE_SMART: - this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut ); - break; - default: - break; - } - } - } + /** + * Gets a list of texture sprites appropriate for particles (digging, etc.) + * given the render state for a cable bus. + */ + public List getParticleTextures(CableBusRenderState renderState) { + CableCoreType coreType = CableCoreType.fromCableType(renderState.getCableType()); + AEColor cableColor = renderState.getCableColor(); - /** - * Gets a list of texture sprites appropriate for particles (digging, etc.) given the render state for a cable bus. - */ - public List getParticleTextures( CableBusRenderState renderState ) - { - CableCoreType coreType = CableCoreType.fromCableType( renderState.getCableType() ); - AEColor cableColor = renderState.getCableColor(); + List result = new ArrayList<>(); - List result = new ArrayList<>(); + if (coreType != null) { + result.add(this.cableBuilder.getCoreTexture(coreType, cableColor)); + } - if( coreType != null ) - { - result.add( this.cableBuilder.getCoreTexture( coreType, cableColor ) ); - } + // If no core is present, just use the first part that comes into play + for (Direction side : renderState.getAttachments().keySet()) { + IPartModel partModel = renderState.getAttachments().get(side); - // If no core is present, just use the first part that comes into play - for( Direction side : renderState.getAttachments().keySet() ) - { - IPartModel partModel = renderState.getAttachments().get( side ); + for (ResourceLocation model : partModel.getModels()) { + IBakedModel bakedModel = this.partModels.get(model); - for( ResourceLocation model : partModel.getModels() ) - { - IBakedModel bakedModel = this.partModels.get( model ); + if (bakedModel == null) { + throw new IllegalStateException("Trying to use an unregistered part model: " + model); + } - if( bakedModel == null ) - { - throw new IllegalStateException( "Trying to use an unregistered part model: " + model ); - } + TextureAtlasSprite particleTexture = bakedModel.getParticleTexture(); - TextureAtlasSprite particleTexture = bakedModel.getParticleTexture(); + // If a part sub-model has no particle texture (indicated by it being the + // missing texture), + // don't add it, so we don't get ugly missing texture break particles. + if (!isMissingTexture(particleTexture)) { + result.add(particleTexture); + } + } + } - // If a part sub-model has no particle texture (indicated by it being the missing texture), - // don't add it, so we don't get ugly missing texture break particles. - if( !isMissingTexture(particleTexture) ) - { - result.add( particleTexture ); - } - } - } + return result; + } - return result; - } + private boolean isMissingTexture(TextureAtlasSprite particleTexture) { + return particleTexture instanceof MissingTextureSprite; + } - private boolean isMissingTexture(TextureAtlasSprite particleTexture) { - return particleTexture instanceof MissingTextureSprite; - } + @Override + public boolean isAmbientOcclusion() { + return true; + } - @Override - public boolean isAmbientOcclusion() - { - return true; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.particleTexture; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.particleTexture; - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return ItemCameraTransforms.DEFAULT; + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } - - public static void clearCache() { - CABLE_MODEL_CACHE.clear(); - } + public static void clearCache() { + CABLE_MODEL_CACHE.clear(); + } } diff --git a/src/main/java/appeng/client/render/cablebus/CableBusBreakingParticle.java b/src/main/java/appeng/client/render/cablebus/CableBusBreakingParticle.java index 389da9ec4..389155470 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusBreakingParticle.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusBreakingParticle.java @@ -15,7 +15,8 @@ public class CableBusBreakingParticle extends SpriteTexturedParticle { private final float field_217571_C; private final float field_217572_F; - public CableBusBreakingParticle(World world, double x, double y, double z, double speedX, double speedY, double speedZ, TextureAtlasSprite sprite) { + public CableBusBreakingParticle(World world, double x, double y, double z, double speedX, double speedY, + double speedZ, TextureAtlasSprite sprite) { super(world, x, y, z, speedX, speedY, speedZ); this.setSprite(sprite); this.particleGravity = 1.0F; diff --git a/src/main/java/appeng/client/render/cablebus/CableBusModel.java b/src/main/java/appeng/client/render/cablebus/CableBusModel.java index 1a8968863..1a7e341bc 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusModel.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusModel.java @@ -18,73 +18,72 @@ package appeng.client.render.cablebus; - import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.function.Function; -import appeng.core.AELog; import com.google.common.collect.ImmutableMap; import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; - -import appeng.api.util.AEColor; -import appeng.core.features.registries.PartModels; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; +import appeng.api.util.AEColor; +import appeng.core.AELog; +import appeng.core.features.registries.PartModels; /** * The built-in model for the cable bus block. */ -public class CableBusModel implements IModelGeometry -{ +public class CableBusModel implements IModelGeometry { - private final PartModels partModels; + private final PartModels partModels; - public CableBusModel( PartModels partModels ) - { - this.partModels = partModels; - } + public CableBusModel(PartModels partModels) { + this.partModels = partModels; + } - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - Map partModels = this.loadPartModels( bakery, spriteGetter, modelTransform ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + Map partModels = this.loadPartModels(bakery, spriteGetter, modelTransform); - CableBuilder cableBuilder = new CableBuilder( spriteGetter ); - FacadeBuilder facadeBuilder = new FacadeBuilder(); + CableBuilder cableBuilder = new CableBuilder(spriteGetter); + FacadeBuilder facadeBuilder = new FacadeBuilder(); - // This should normally not be used, but we *have* to provide a particle texture or otherwise damage models will - // crash - TextureAtlasSprite particleTexture = cableBuilder.getCoreTexture( CableCoreType.GLASS, AEColor.TRANSPARENT ); + // This should normally not be used, but we *have* to provide a particle texture + // or otherwise damage models will + // crash + TextureAtlasSprite particleTexture = cableBuilder.getCoreTexture(CableCoreType.GLASS, AEColor.TRANSPARENT); - return new CableBusBakedModel( cableBuilder, facadeBuilder, partModels, particleTexture ); - } + return new CableBusBakedModel(cableBuilder, facadeBuilder, partModels, particleTexture); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Collections.unmodifiableList( CableBuilder.getTextures() ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.unmodifiableList(CableBuilder.getTextures()); + } - private Map loadPartModels( ModelBakery bakery, Function spriteGetterIn, IModelTransform transformIn ) - { - ImmutableMap.Builder result = ImmutableMap.builder(); + private Map loadPartModels(ModelBakery bakery, + Function spriteGetterIn, IModelTransform transformIn) { + ImmutableMap.Builder result = ImmutableMap.builder(); - for( ResourceLocation location : this.partModels.getModels() ) - { - IBakedModel bakedModel = bakery.getBakedModel(location, transformIn, spriteGetterIn); - if (bakedModel == null) { - AELog.warn("Failed to bake part model {}", location); - } else { - result.put(location, bakedModel); - } - } + for (ResourceLocation location : this.partModels.getModels()) { + IBakedModel bakedModel = bakery.getBakedModel(location, transformIn, spriteGetterIn); + if (bakedModel == null) { + AELog.warn("Failed to bake part model {}", location); + } else { + result.put(location, bakedModel); + } + } - return result.build(); - } + return result.build(); + } } diff --git a/src/main/java/appeng/client/render/cablebus/CableBusModelLoader.java b/src/main/java/appeng/client/render/cablebus/CableBusModelLoader.java index 324597606..cdf2cd9d2 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusModelLoader.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusModelLoader.java @@ -1,11 +1,13 @@ package appeng.client.render.cablebus; -import appeng.core.features.registries.PartModels; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.resources.IResourceManager; import net.minecraftforge.client.model.IModelLoader; +import appeng.core.features.registries.PartModels; + public class CableBusModelLoader implements IModelLoader { private final PartModels partModels; diff --git a/src/main/java/appeng/client/render/cablebus/CableBusRenderState.java b/src/main/java/appeng/client/render/cablebus/CableBusRenderState.java index de485bd8e..b0e1c4d64 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusRenderState.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusRenderState.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.EnumMap; @@ -37,199 +36,181 @@ import appeng.api.parts.IPartModel; import appeng.api.util.AECableType; import appeng.api.util.AEColor; - /** - * This class captures the entire rendering state needed for a cable bus and transports it to the rendering thread - * for processing. + * This class captures the entire rendering state needed for a cable bus and + * transports it to the rendering thread for processing. */ -public class CableBusRenderState -{ +public class CableBusRenderState { - public static final ModelProperty PROPERTY = new ModelProperty<>(); + public static final ModelProperty PROPERTY = new ModelProperty<>(); - // The cable type used for rendering the outgoing connections to other blocks and attached parts - private AECableType cableType = AECableType.NONE; + // The cable type used for rendering the outgoing connections to other blocks + // and attached parts + private AECableType cableType = AECableType.NONE; - // The type to use for rendering the core of the cable. - private CableCoreType coreType; + // The type to use for rendering the core of the cable. + private CableCoreType coreType; - private AEColor cableColor = AEColor.TRANSPARENT; + private AEColor cableColor = AEColor.TRANSPARENT; - // Describes the outgoing connections of this cable bus to other blocks, and how they should be rendered - private EnumMap connectionTypes = new EnumMap<>( Direction.class ); + // Describes the outgoing connections of this cable bus to other blocks, and how + // they should be rendered + private EnumMap connectionTypes = new EnumMap<>(Direction.class); - // Indicate on which sides signified by connectionTypes above, there is another cable bus. If a side is connected, - // but it is absent from this - // set, then it means that there is a Grid host, but not a cable bus on that side (i.e. an interface, a controller, - // etc.) - private EnumSet cableBusAdjacent = EnumSet.noneOf( Direction.class ); + // Indicate on which sides signified by connectionTypes above, there is another + // cable bus. If a side is connected, + // but it is absent from this + // set, then it means that there is a Grid host, but not a cable bus on that + // side (i.e. an interface, a controller, + // etc.) + private EnumSet cableBusAdjacent = EnumSet.noneOf(Direction.class); - // Specifies the number of channels used for the connection to a given side. Only contains entries if - // connections contains a corresponding entry. - private EnumMap channelsOnSide = new EnumMap<>( Direction.class ); + // Specifies the number of channels used for the connection to a given side. + // Only contains entries if + // connections contains a corresponding entry. + private EnumMap channelsOnSide = new EnumMap<>(Direction.class); - private EnumMap attachments = new EnumMap<>( Direction.class ); + private EnumMap attachments = new EnumMap<>(Direction.class); - // For each attachment, this contains the distance from the edge until which a cable connection should be drawn - private EnumMap attachmentConnections = new EnumMap<>( Direction.class ); + // For each attachment, this contains the distance from the edge until which a + // cable connection should be drawn + private EnumMap attachmentConnections = new EnumMap<>(Direction.class); - // Contains the facade to use for each side that has a facade attached - private EnumMap facades = new EnumMap<>( Direction.class ); + // Contains the facade to use for each side that has a facade attached + private EnumMap facades = new EnumMap<>(Direction.class); - // Used for Facades. - private WeakReference world; - private BlockPos pos; + // Used for Facades. + private WeakReference world; + private BlockPos pos; - // Contains the bounding boxes of all parts on the cable bus to allow facades to cut out holes for the parts. This - // list is only populated if there are - // facades on this cable bus - private List boundingBoxes = new ArrayList<>(); + // Contains the bounding boxes of all parts on the cable bus to allow facades to + // cut out holes for the parts. This + // list is only populated if there are + // facades on this cable bus + private List boundingBoxes = new ArrayList<>(); - // Additional model data passed to the part models - private EnumMap partModelData = new EnumMap<>( Direction.class ); + // Additional model data passed to the part models + private EnumMap partModelData = new EnumMap<>(Direction.class); - public CableCoreType getCoreType() - { - return this.coreType; - } + public CableCoreType getCoreType() { + return this.coreType; + } - public void setCoreType( CableCoreType coreType ) - { - this.coreType = coreType; - } + public void setCoreType(CableCoreType coreType) { + this.coreType = coreType; + } - public AECableType getCableType() - { - return this.cableType; - } + public AECableType getCableType() { + return this.cableType; + } - public void setCableType( AECableType cableType ) - { - this.cableType = cableType; - } + public void setCableType(AECableType cableType) { + this.cableType = cableType; + } - public AEColor getCableColor() - { - return this.cableColor; - } + public AEColor getCableColor() { + return this.cableColor; + } - public void setCableColor( AEColor cableColor ) - { - this.cableColor = cableColor; - } + public void setCableColor(AEColor cableColor) { + this.cableColor = cableColor; + } - public EnumMap getChannelsOnSide() - { - return this.channelsOnSide; - } + public EnumMap getChannelsOnSide() { + return this.channelsOnSide; + } - public EnumMap getConnectionTypes() - { - return this.connectionTypes; - } + public EnumMap getConnectionTypes() { + return this.connectionTypes; + } - public void setConnectionTypes( EnumMap connectionTypes ) - { - this.connectionTypes = connectionTypes; - } + public void setConnectionTypes(EnumMap connectionTypes) { + this.connectionTypes = connectionTypes; + } - public void setChannelsOnSide( EnumMap channelsOnSide ) - { - this.channelsOnSide = channelsOnSide; - } + public void setChannelsOnSide(EnumMap channelsOnSide) { + this.channelsOnSide = channelsOnSide; + } - public EnumSet getCableBusAdjacent() - { - return this.cableBusAdjacent; - } + public EnumSet getCableBusAdjacent() { + return this.cableBusAdjacent; + } - public void setCableBusAdjacent( EnumSet cableBusAdjacent ) - { - this.cableBusAdjacent = cableBusAdjacent; - } + public void setCableBusAdjacent(EnumSet cableBusAdjacent) { + this.cableBusAdjacent = cableBusAdjacent; + } - public EnumMap getAttachments() - { - return this.attachments; - } + public EnumMap getAttachments() { + return this.attachments; + } - public EnumMap getAttachmentConnections() - { - return this.attachmentConnections; - } + public EnumMap getAttachmentConnections() { + return this.attachmentConnections; + } - public EnumMap getFacades() - { - return this.facades; - } + public EnumMap getFacades() { + return this.facades; + } - public ILightReader getWorld() - { - return this.world.get(); - } + public ILightReader getWorld() { + return this.world.get(); + } - public void setWorld( ILightReader world ) - { - this.world = new WeakReference<>( world ); - } + public void setWorld(ILightReader world) { + this.world = new WeakReference<>(world); + } - public BlockPos getPos() - { - return this.pos; - } + public BlockPos getPos() { + return this.pos; + } - public void setPos( BlockPos pos ) - { - this.pos = pos; - } + public void setPos(BlockPos pos) { + this.pos = pos; + } - public List getBoundingBoxes() - { - return this.boundingBoxes; - } + public List getBoundingBoxes() { + return this.boundingBoxes; + } - public EnumMap getPartModelData() - { - return this.partModelData; - } + public EnumMap getPartModelData() { + return this.partModelData; + } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( this.attachmentConnections == null ) ? 0 : this.attachmentConnections.hashCode() ); - result = prime * result + ( ( this.cableBusAdjacent == null ) ? 0 : this.cableBusAdjacent.hashCode() ); - result = prime * result + ( ( this.cableColor == null ) ? 0 : this.cableColor.hashCode() ); - result = prime * result + ( ( this.cableType == null ) ? 0 : this.cableType.hashCode() ); - result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() ); - result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() ); - result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() ); - result = prime * result + ( ( this.partModelData == null ) ? 0 : this.partModelData.hashCode() ); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.attachmentConnections == null) ? 0 : this.attachmentConnections.hashCode()); + result = prime * result + ((this.cableBusAdjacent == null) ? 0 : this.cableBusAdjacent.hashCode()); + result = prime * result + ((this.cableColor == null) ? 0 : this.cableColor.hashCode()); + result = prime * result + ((this.cableType == null) ? 0 : this.cableType.hashCode()); + result = prime * result + ((this.channelsOnSide == null) ? 0 : this.channelsOnSide.hashCode()); + result = prime * result + ((this.connectionTypes == null) ? 0 : this.connectionTypes.hashCode()); + result = prime * result + ((this.coreType == null) ? 0 : this.coreType.hashCode()); + result = prime * result + ((this.partModelData == null) ? 0 : this.partModelData.hashCode()); + return result; + } - @Override - public boolean equals( Object obj ) - { - if( this == obj ) - { - return true; - } - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } - final CableBusRenderState other = (CableBusRenderState) obj; + final CableBusRenderState other = (CableBusRenderState) obj; - return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects - .equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent, other.cableBusAdjacent ) && Objects - .equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes, other.connectionTypes ) && Objects - .equals( this.partModelData, other.partModelData); - } + return this.cableColor == other.cableColor && this.cableType == other.cableType + && this.coreType == other.coreType + && Objects.equals(this.attachmentConnections, other.attachmentConnections) + && Objects.equals(this.cableBusAdjacent, other.cableBusAdjacent) + && Objects.equals(this.channelsOnSide, other.channelsOnSide) + && Objects.equals(this.connectionTypes, other.connectionTypes) + && Objects.equals(this.partModelData, other.partModelData); + } } diff --git a/src/main/java/appeng/client/render/cablebus/CableCoreType.java b/src/main/java/appeng/client/render/cablebus/CableCoreType.java index 63b4b2a3a..4cdb6aefe 100644 --- a/src/main/java/appeng/client/render/cablebus/CableCoreType.java +++ b/src/main/java/appeng/client/render/cablebus/CableCoreType.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.EnumMap; import java.util.Map; @@ -32,57 +31,50 @@ import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.core.AppEng; - /** - * AE can render the core of a cable (the core that connections are made to, in case the cable is not a straight line) - * in three different ways: - * - Glass - * - Covered (also used by the Smart Cable) - * - Dense + * AE can render the core of a cable (the core that connections are made to, in + * case the cable is not a straight line) in three different ways: - Glass - + * Covered (also used by the Smart Cable) - Dense */ -public enum CableCoreType -{ - GLASS( "parts/cable/core/glass" ), COVERED( "parts/cable/core/covered" ), DENSE( "parts/cable/core/dense_smart" ); +public enum CableCoreType { + GLASS("parts/cable/core/glass"), COVERED("parts/cable/core/covered"), DENSE("parts/cable/core/dense_smart"); - private static final Map cableMapping = generateCableMapping(); + private static final Map cableMapping = generateCableMapping(); - /** - * Creates the mapping that assigns a cable core type to an AE cable type. - */ - private static Map generateCableMapping() - { + /** + * Creates the mapping that assigns a cable core type to an AE cable type. + */ + private static Map generateCableMapping() { - Map result = new EnumMap<>( AECableType.class ); + Map result = new EnumMap<>(AECableType.class); - result.put( AECableType.GLASS, CableCoreType.GLASS ); - result.put( AECableType.COVERED, CableCoreType.COVERED ); - result.put( AECableType.SMART, CableCoreType.COVERED ); - result.put( AECableType.DENSE_COVERED, CableCoreType.DENSE ); - result.put( AECableType.DENSE_SMART, CableCoreType.DENSE ); + result.put(AECableType.GLASS, CableCoreType.GLASS); + result.put(AECableType.COVERED, CableCoreType.COVERED); + result.put(AECableType.SMART, CableCoreType.COVERED); + result.put(AECableType.DENSE_COVERED, CableCoreType.DENSE); + result.put(AECableType.DENSE_SMART, CableCoreType.DENSE); - return ImmutableMap.copyOf( result ); - } + return ImmutableMap.copyOf(result); + } - private final String textureFolder; + private final String textureFolder; - CableCoreType( String textureFolder ) - { - this.textureFolder = textureFolder; - } + CableCoreType(String textureFolder) { + this.textureFolder = textureFolder; + } - /** - * @return The type of core that should be rendered when the given cable isn't straight and needs to have a core to - * attach connections to. - * Is null for the NULL cable. - */ - public static CableCoreType fromCableType( AECableType cableType ) - { - return cableMapping.get( cableType ); - } + /** + * @return The type of core that should be rendered when the given cable isn't + * straight and needs to have a core to attach connections to. Is null + * for the NULL cable. + */ + public static CableCoreType fromCableType(AECableType cableType) { + return cableMapping.get(cableType); + } - public Material getTexture( AEColor color ) - { - return new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase() ) ); - } + public Material getTexture(AEColor color) { + return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase())); + } } diff --git a/src/main/java/appeng/client/render/cablebus/CubeBuilder.java b/src/main/java/appeng/client/render/cablebus/CubeBuilder.java index 3128ffaa1..59b0bbe91 100644 --- a/src/main/java/appeng/client/render/cablebus/CubeBuilder.java +++ b/src/main/java/appeng/client/render/cablebus/CubeBuilder.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.ArrayList; import java.util.EnumMap; import java.util.EnumSet; @@ -34,479 +33,434 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.util.Direction; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; - /** * Builds the quads for a cube. */ -public class CubeBuilder -{ +public class CubeBuilder { - private final List output; + private final List output; - private final EnumMap textures = new EnumMap<>( Direction.class ); + private final EnumMap textures = new EnumMap<>(Direction.class); - private EnumSet drawFaces = EnumSet.allOf( Direction.class ); + private EnumSet drawFaces = EnumSet.allOf(Direction.class); - private final EnumMap customUv = new EnumMap<>( Direction.class ); + private final EnumMap customUv = new EnumMap<>(Direction.class); - private byte[] uvRotations = new byte[Direction.values().length]; + private byte[] uvRotations = new byte[Direction.values().length]; - private int color = 0xFFFFFFFF; + private int color = 0xFFFFFFFF; - private boolean useStandardUV = false; + private boolean useStandardUV = false; - private boolean renderFullBright; + private boolean renderFullBright; - public CubeBuilder( List output ) - { - this.output = output; - } + public CubeBuilder(List output) { + this.output = output; + } - public CubeBuilder() - { - this( new ArrayList<>( 6 ) ); - } + public CubeBuilder() { + this(new ArrayList<>(6)); + } - public void addCube( float x1, float y1, float z1, float x2, float y2, float z2 ) - { - x1 /= 16.0f; - y1 /= 16.0f; - z1 /= 16.0f; - x2 /= 16.0f; - y2 /= 16.0f; - z2 /= 16.0f; + public void addCube(float x1, float y1, float z1, float x2, float y2, float z2) { + x1 /= 16.0f; + y1 /= 16.0f; + z1 /= 16.0f; + x2 /= 16.0f; + y2 /= 16.0f; + z2 /= 16.0f; - for( Direction face : this.drawFaces ) - { - this.putFace( face, x1, y1, z1, x2, y2, z2 ); - } - } + for (Direction face : this.drawFaces) { + this.putFace(face, x1, y1, z1, x2, y2, z2); + } + } - public void addQuad( Direction face, float x1, float y1, float z1, float x2, float y2, float z2 ) - { - this.putFace( face, x1, y1, z1, x2, y2, z2 ); - } + public void addQuad(Direction face, float x1, float y1, float z1, float x2, float y2, float z2) { + this.putFace(face, x1, y1, z1, x2, y2, z2); + } - private static final class UvVector - { - float u1; - float u2; - float v1; - float v2; - } + private static final class UvVector { + float u1; + float u2; + float v1; + float v2; + } - private void putFace( Direction face, float x1, float y1, float z1, float x2, float y2, float z2 ) - { + private void putFace(Direction face, float x1, float y1, float z1, float x2, float y2, float z2) { - TextureAtlasSprite texture = this.textures.get( face ); + TextureAtlasSprite texture = this.textures.get(face); - BakedQuadBuilder builder = new BakedQuadBuilder( texture ); - builder.setQuadOrientation( face ); - builder.setQuadTint( -1 ); - builder.setApplyDiffuseLighting( true ); + BakedQuadBuilder builder = new BakedQuadBuilder(texture); + builder.setQuadOrientation(face); + builder.setQuadTint(-1); + builder.setApplyDiffuseLighting(true); - UvVector uv = new UvVector(); + UvVector uv = new UvVector(); - // The user might have set specific UV coordinates for this face - Vector4f customUv = this.customUv.get( face ); - if( customUv != null ) - { - uv.u1 = texture.getInterpolatedU( customUv.getX() ); - uv.v1 = texture.getInterpolatedV( customUv.getY() ); - uv.u2 = texture.getInterpolatedU( customUv.getZ() ); - uv.v2 = texture.getInterpolatedV( customUv.getW() ); - } - else if( this.useStandardUV ) - { - uv = this.getStandardUv( face, texture, x1, y1, z1, x2, y2, z2 ); - } - else - { - uv = this.getDefaultUv( face, texture, x1, y1, z1, x2, y2, z2 ); - } + // The user might have set specific UV coordinates for this face + Vector4f customUv = this.customUv.get(face); + if (customUv != null) { + uv.u1 = texture.getInterpolatedU(customUv.getX()); + uv.v1 = texture.getInterpolatedV(customUv.getY()); + uv.u2 = texture.getInterpolatedU(customUv.getZ()); + uv.v2 = texture.getInterpolatedV(customUv.getW()); + } else if (this.useStandardUV) { + uv = this.getStandardUv(face, texture, x1, y1, z1, x2, y2, z2); + } else { + uv = this.getDefaultUv(face, texture, x1, y1, z1, x2, y2, z2); + } - switch( face ) - { - case DOWN: - this.putVertexTR( builder, face, x2, y1, z1, uv ); - this.putVertexBR( builder, face, x2, y1, z2, uv ); - this.putVertexBL( builder, face, x1, y1, z2, uv ); - this.putVertexTL( builder, face, x1, y1, z1, uv ); - break; - case UP: - this.putVertexTL( builder, face, x1, y2, z1, uv ); - this.putVertexBL( builder, face, x1, y2, z2, uv ); - this.putVertexBR( builder, face, x2, y2, z2, uv ); - this.putVertexTR( builder, face, x2, y2, z1, uv ); - break; - case NORTH: - this.putVertexBR( builder, face, x2, y2, z1, uv ); - this.putVertexTR( builder, face, x2, y1, z1, uv ); - this.putVertexTL( builder, face, x1, y1, z1, uv ); - this.putVertexBL( builder, face, x1, y2, z1, uv ); - break; - case SOUTH: - this.putVertexBL( builder, face, x1, y2, z2, uv ); - this.putVertexTL( builder, face, x1, y1, z2, uv ); - this.putVertexTR( builder, face, x2, y1, z2, uv ); - this.putVertexBR( builder, face, x2, y2, z2, uv ); - break; - case WEST: - this.putVertexTL( builder, face, x1, y1, z1, uv ); - this.putVertexTR( builder, face, x1, y1, z2, uv ); - this.putVertexBR( builder, face, x1, y2, z2, uv ); - this.putVertexBL( builder, face, x1, y2, z1, uv ); - break; - case EAST: - this.putVertexBR( builder, face, x2, y2, z1, uv ); - this.putVertexBL( builder, face, x2, y2, z2, uv ); - this.putVertexTL( builder, face, x2, y1, z2, uv ); - this.putVertexTR( builder, face, x2, y1, z1, uv ); - break; - } + switch (face) { + case DOWN: + this.putVertexTR(builder, face, x2, y1, z1, uv); + this.putVertexBR(builder, face, x2, y1, z2, uv); + this.putVertexBL(builder, face, x1, y1, z2, uv); + this.putVertexTL(builder, face, x1, y1, z1, uv); + break; + case UP: + this.putVertexTL(builder, face, x1, y2, z1, uv); + this.putVertexBL(builder, face, x1, y2, z2, uv); + this.putVertexBR(builder, face, x2, y2, z2, uv); + this.putVertexTR(builder, face, x2, y2, z1, uv); + break; + case NORTH: + this.putVertexBR(builder, face, x2, y2, z1, uv); + this.putVertexTR(builder, face, x2, y1, z1, uv); + this.putVertexTL(builder, face, x1, y1, z1, uv); + this.putVertexBL(builder, face, x1, y2, z1, uv); + break; + case SOUTH: + this.putVertexBL(builder, face, x1, y2, z2, uv); + this.putVertexTL(builder, face, x1, y1, z2, uv); + this.putVertexTR(builder, face, x2, y1, z2, uv); + this.putVertexBR(builder, face, x2, y2, z2, uv); + break; + case WEST: + this.putVertexTL(builder, face, x1, y1, z1, uv); + this.putVertexTR(builder, face, x1, y1, z2, uv); + this.putVertexBR(builder, face, x1, y2, z2, uv); + this.putVertexBL(builder, face, x1, y2, z1, uv); + break; + case EAST: + this.putVertexBR(builder, face, x2, y2, z1, uv); + this.putVertexBL(builder, face, x2, y2, z2, uv); + this.putVertexTL(builder, face, x2, y1, z2, uv); + this.putVertexTR(builder, face, x2, y1, z1, uv); + break; + } - this.output.add( builder.build() ); - } + this.output.add(builder.build()); + } - private UvVector getDefaultUv( Direction face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, float y2, float z2 ) - { + private UvVector getDefaultUv(Direction face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, + float y2, float z2) { - UvVector uv = new UvVector(); + UvVector uv = new UvVector(); - switch( face ) - { - case DOWN: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( z1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( z2 * 16 ); - break; - case UP: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( z1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( z2 * 16 ); - break; - case NORTH: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case SOUTH: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case WEST: - uv.u1 = texture.getInterpolatedU( z1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( z2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case EAST: - uv.u1 = texture.getInterpolatedU( z2 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( z1 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - } + switch (face) { + case DOWN: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(z1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(z2 * 16); + break; + case UP: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(z1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(z2 * 16); + break; + case NORTH: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case SOUTH: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case WEST: + uv.u1 = texture.getInterpolatedU(z1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(z2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case EAST: + uv.u1 = texture.getInterpolatedU(z2 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(z1 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + } - return uv; - } + return uv; + } - private UvVector getStandardUv( Direction face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, float y2, float z2 ) - { - UvVector uv = new UvVector(); - switch( face ) - { - case DOWN: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - z1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - z2 * 16 ); - break; - case UP: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( z1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( z2 * 16 ); - break; - case NORTH: - uv.u1 = texture.getInterpolatedU( 16 - x1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( 16 - x2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case SOUTH: - uv.u1 = texture.getInterpolatedU( x1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( x2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case WEST: - uv.u1 = texture.getInterpolatedU( z1 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( z2 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - case EAST: - uv.u1 = texture.getInterpolatedU( 16 - z2 * 16 ); - uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); - uv.u2 = texture.getInterpolatedU( 16 - z1 * 16 ); - uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); - break; - } - return uv; - } + private UvVector getStandardUv(Direction face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, + float y2, float z2) { + UvVector uv = new UvVector(); + switch (face) { + case DOWN: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(16 - z1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(16 - z2 * 16); + break; + case UP: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(z1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(z2 * 16); + break; + case NORTH: + uv.u1 = texture.getInterpolatedU(16 - x1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(16 - x2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case SOUTH: + uv.u1 = texture.getInterpolatedU(x1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(x2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case WEST: + uv.u1 = texture.getInterpolatedU(z1 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(z2 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + case EAST: + uv.u1 = texture.getInterpolatedU(16 - z2 * 16); + uv.v1 = texture.getInterpolatedV(16 - y1 * 16); + uv.u2 = texture.getInterpolatedU(16 - z1 * 16); + uv.v2 = texture.getInterpolatedV(16 - y2 * 16); + break; + } + return uv; + } - // uv.u1, uv.v1 - private void putVertexTL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv ) - { - float u, v; + // uv.u1, uv.v1 + private void putVertexTL(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) { + float u, v; - switch( this.uvRotations[face.ordinal()] ) - { - default: - case 0: - u = uv.u1; - v = uv.v1; - break; - case 1: // 90° clockwise - u = uv.u1; - v = uv.v2; - break; - case 2: // 180° clockwise - u = uv.u2; - v = uv.v2; - break; - case 3: // 270° clockwise - u = uv.u2; - v = uv.v1; - break; - } + switch (this.uvRotations[face.ordinal()]) { + default: + case 0: + u = uv.u1; + v = uv.v1; + break; + case 1: // 90° clockwise + u = uv.u1; + v = uv.v2; + break; + case 2: // 180° clockwise + u = uv.u2; + v = uv.v2; + break; + case 3: // 270° clockwise + u = uv.u2; + v = uv.v1; + break; + } - this.putVertex( builder, face, x, y, z, u, v ); - } + this.putVertex(builder, face, x, y, z, u, v); + } - // uv.u2, uv.v1 - private void putVertexTR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv ) - { - float u, v; + // uv.u2, uv.v1 + private void putVertexTR(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) { + float u, v; - switch( this.uvRotations[face.ordinal()] ) - { - default: - case 0: - u = uv.u2; - v = uv.v1; - break; - case 1: // 90° clockwise - u = uv.u1; - v = uv.v1; - break; - case 2: // 180° clockwise - u = uv.u1; - v = uv.v2; - break; - case 3: // 270° clockwise - u = uv.u2; - v = uv.v2; - break; - } - this.putVertex( builder, face, x, y, z, u, v ); - } + switch (this.uvRotations[face.ordinal()]) { + default: + case 0: + u = uv.u2; + v = uv.v1; + break; + case 1: // 90° clockwise + u = uv.u1; + v = uv.v1; + break; + case 2: // 180° clockwise + u = uv.u1; + v = uv.v2; + break; + case 3: // 270° clockwise + u = uv.u2; + v = uv.v2; + break; + } + this.putVertex(builder, face, x, y, z, u, v); + } - // uv.u2, uv.v2 - private void putVertexBR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv ) - { + // uv.u2, uv.v2 + private void putVertexBR(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) { - float u; - float v; + float u; + float v; - switch( this.uvRotations[face.ordinal()] ) - { - default: - case 0: - u = uv.u2; - v = uv.v2; - break; - case 1: // 90° clockwise - u = uv.u2; - v = uv.v1; - break; - case 2: // 180° clockwise - u = uv.u1; - v = uv.v1; - break; - case 3: // 270° clockwise - u = uv.u1; - v = uv.v2; - break; - } + switch (this.uvRotations[face.ordinal()]) { + default: + case 0: + u = uv.u2; + v = uv.v2; + break; + case 1: // 90° clockwise + u = uv.u2; + v = uv.v1; + break; + case 2: // 180° clockwise + u = uv.u1; + v = uv.v1; + break; + case 3: // 270° clockwise + u = uv.u1; + v = uv.v2; + break; + } - this.putVertex( builder, face, x, y, z, u, v ); - } + this.putVertex(builder, face, x, y, z, u, v); + } - // uv.u1, uv.v2 - private void putVertexBL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv ) - { + // uv.u1, uv.v2 + private void putVertexBL(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) { - float u; - float v; + float u; + float v; - switch( this.uvRotations[face.ordinal()] ) - { - default: - case 0: - u = uv.u1; - v = uv.v2; - break; - case 1: // 90° clockwise - u = uv.u2; - v = uv.v2; - break; - case 2: // 180° clockwise - u = uv.u2; - v = uv.v1; - break; - case 3: // 270° clockwise - u = uv.u1; - v = uv.v1; - break; - } + switch (this.uvRotations[face.ordinal()]) { + default: + case 0: + u = uv.u1; + v = uv.v2; + break; + case 1: // 90° clockwise + u = uv.u2; + v = uv.v2; + break; + case 2: // 180° clockwise + u = uv.u2; + v = uv.v1; + break; + case 3: // 270° clockwise + u = uv.u1; + v = uv.v1; + break; + } - this.putVertex( builder, face, x, y, z, u, v ); - } + this.putVertex(builder, face, x, y, z, u, v); + } - private void putVertex( BakedQuadBuilder builder, Direction face, float x, float y, float z, float u, float v ) - { - VertexFormat format = builder.getVertexFormat(); + private void putVertex(BakedQuadBuilder builder, Direction face, float x, float y, float z, float u, float v) { + VertexFormat format = builder.getVertexFormat(); - List elements = format.getElements(); - for( int i = 0; i < elements.size(); i++ ) - { - VertexFormatElement e = elements.get( i ); - switch( e.getUsage() ) - { - case POSITION: - builder.put( i, x, y, z ); - break; - case NORMAL: - builder.put( i, face.getXOffset(), face.getYOffset(), face.getZOffset() ); - break; - case COLOR: - // Color format is RGBA - float r = ( this.color >> 16 & 0xFF ) / 255f; - float g = ( this.color >> 8 & 0xFF ) / 255f; - float b = ( this.color & 0xFF ) / 255f; - float a = ( this.color >> 24 & 0xFF ) / 255f; - builder.put( i, r, g, b, a ); - break; - case UV: - if( e.getIndex() == 0 ) - { - builder.put( i, u, v ); - break; - } - else if( e.getIndex() == 2 && renderFullBright ) - { - // Force Brightness to 15, this is for full bright mode - // this vertex element will only be present in that case - final float lightMapU = (float) ( 15 * 0x20 ) / 0xFFFF; - final float lightMapV = (float) ( 15 * 0x20 ) / 0xFFFF; - builder.put( i, lightMapU, lightMapV ); - break; - } - default: - builder.put( i ); - break; - } - } - } + List elements = format.getElements(); + for (int i = 0; i < elements.size(); i++) { + VertexFormatElement e = elements.get(i); + switch (e.getUsage()) { + case POSITION: + builder.put(i, x, y, z); + break; + case NORMAL: + builder.put(i, face.getXOffset(), face.getYOffset(), face.getZOffset()); + break; + case COLOR: + // Color format is RGBA + float r = (this.color >> 16 & 0xFF) / 255f; + float g = (this.color >> 8 & 0xFF) / 255f; + float b = (this.color & 0xFF) / 255f; + float a = (this.color >> 24 & 0xFF) / 255f; + builder.put(i, r, g, b, a); + break; + case UV: + if (e.getIndex() == 0) { + builder.put(i, u, v); + break; + } else if (e.getIndex() == 2 && renderFullBright) { + // Force Brightness to 15, this is for full bright mode + // this vertex element will only be present in that case + final float lightMapU = (float) (15 * 0x20) / 0xFFFF; + final float lightMapV = (float) (15 * 0x20) / 0xFFFF; + builder.put(i, lightMapU, lightMapV); + break; + } + default: + builder.put(i); + break; + } + } + } - public void setTexture( TextureAtlasSprite texture ) - { - for( Direction face : Direction.values() ) - { - this.textures.put( face, texture ); - } - } + public void setTexture(TextureAtlasSprite texture) { + for (Direction face : Direction.values()) { + this.textures.put(face, texture); + } + } - public void setTextures( TextureAtlasSprite up, TextureAtlasSprite down, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite east, TextureAtlasSprite west ) - { - this.textures.put( Direction.UP, up ); - this.textures.put( Direction.DOWN, down ); - this.textures.put( Direction.NORTH, north ); - this.textures.put( Direction.SOUTH, south ); - this.textures.put( Direction.EAST, east ); - this.textures.put( Direction.WEST, west ); - } + public void setTextures(TextureAtlasSprite up, TextureAtlasSprite down, TextureAtlasSprite north, + TextureAtlasSprite south, TextureAtlasSprite east, TextureAtlasSprite west) { + this.textures.put(Direction.UP, up); + this.textures.put(Direction.DOWN, down); + this.textures.put(Direction.NORTH, north); + this.textures.put(Direction.SOUTH, south); + this.textures.put(Direction.EAST, east); + this.textures.put(Direction.WEST, west); + } - public void setTexture( Direction facing, TextureAtlasSprite sprite ) - { - this.textures.put( facing, sprite ); - } + public void setTexture(Direction facing, TextureAtlasSprite sprite) { + this.textures.put(facing, sprite); + } - public void setDrawFaces( EnumSet drawFaces ) - { - this.drawFaces = drawFaces; - } + public void setDrawFaces(EnumSet drawFaces) { + this.drawFaces = drawFaces; + } - public void setColor( int color ) - { - this.color = color; - } + public void setColor(int color) { + this.color = color; + } - /** - * Sets the vertex color for future vertices to the given RGB value, and forces the alpha component to 255. - */ - public void setColorRGB( int color ) - { - this.setColor( color | 0xFF000000 ); - } + /** + * Sets the vertex color for future vertices to the given RGB value, and forces + * the alpha component to 255. + */ + public void setColorRGB(int color) { + this.setColor(color | 0xFF000000); + } - public void setColorRGB( float r, float g, float b ) - { - this.setColorRGB( (int) ( r * 255 ) << 16 | (int) ( g * 255 ) << 8 | (int) ( b * 255 ) ); - } + public void setColorRGB(float r, float g, float b) { + this.setColorRGB((int) (r * 255) << 16 | (int) (g * 255) << 8 | (int) (b * 255)); + } - public void setRenderFullBright( boolean renderFullBright ) - { - this.renderFullBright = renderFullBright; - } + public void setRenderFullBright(boolean renderFullBright) { + this.renderFullBright = renderFullBright; + } - public void setCustomUv( Direction facing, float u1, float v1, float u2, float v2 ) - { - this.customUv.put( facing, new Vector4f( u1, v1, u2, v2 ) ); - } + public void setCustomUv(Direction facing, float u1, float v1, float u2, float v2) { + this.customUv.put(facing, new Vector4f(u1, v1, u2, v2)); + } - public void setUvRotation( Direction facing, int rotation ) - { - if( rotation == 2 ) - { - rotation = 3; - } - else if( rotation == 3 ) - { - rotation = 2; - } - Preconditions.checkArgument( rotation >= 0 && rotation <= 3, "rotation" ); - this.uvRotations[facing.ordinal()] = (byte) rotation; - } + public void setUvRotation(Direction facing, int rotation) { + if (rotation == 2) { + rotation = 3; + } else if (rotation == 3) { + rotation = 2; + } + Preconditions.checkArgument(rotation >= 0 && rotation <= 3, "rotation"); + this.uvRotations[facing.ordinal()] = (byte) rotation; + } - /** - * CubeBuilder uses UV optimized for cables by default. - * This switches to standard UV coordinates. - */ - public void useStandardUV() - { - this.useStandardUV = true; - } + /** + * CubeBuilder uses UV optimized for cables by default. This switches to + * standard UV coordinates. + */ + public void useStandardUV() { + this.useStandardUV = true; + } - public List getOutput() - { - return this.output; - } + public List getOutput() { + return this.output; + } } diff --git a/src/main/java/appeng/client/render/cablebus/FacadeBlockAccess.java b/src/main/java/appeng/client/render/cablebus/FacadeBlockAccess.java index 3b2775890..7318d82a3 100644 --- a/src/main/java/appeng/client/render/cablebus/FacadeBlockAccess.java +++ b/src/main/java/appeng/client/render/cablebus/FacadeBlockAccess.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -30,61 +29,52 @@ import net.minecraft.world.ILightReader; import net.minecraft.world.level.ColorResolver; import net.minecraft.world.lighting.WorldLightManager; - /** * This is used to retrieve the ExtendedState of a block for facade rendering. * It fakes the block at BlockPos provided as the BlockState provided. * * @author covers1624 */ -public class FacadeBlockAccess implements ILightReader -{ +public class FacadeBlockAccess implements ILightReader { - private final ILightReader world; - private final BlockPos pos; - private final Direction side; - private final BlockState state; + private final ILightReader world; + private final BlockPos pos; + private final Direction side; + private final BlockState state; - public FacadeBlockAccess( ILightReader world, BlockPos pos, Direction side, BlockState state ) - { - this.world = world; - this.pos = pos; - this.side = side; - this.state = state; - } + public FacadeBlockAccess(ILightReader world, BlockPos pos, Direction side, BlockState state) { + this.world = world; + this.pos = pos; + this.side = side; + this.state = state; + } - @Nullable - @Override - public TileEntity getTileEntity( BlockPos pos ) - { - return this.world.getTileEntity( pos ); - } + @Nullable + @Override + public TileEntity getTileEntity(BlockPos pos) { + return this.world.getTileEntity(pos); + } - @Override - public BlockState getBlockState( BlockPos pos ) - { - if( this.pos == pos ) - { - return this.state; - } - return this.world.getBlockState( pos ); - } + @Override + public BlockState getBlockState(BlockPos pos) { + if (this.pos == pos) { + return this.state; + } + return this.world.getBlockState(pos); + } - @Override - public IFluidState getFluidState( BlockPos pos ) - { - return world.getFluidState( pos ); - } + @Override + public IFluidState getFluidState(BlockPos pos) { + return world.getFluidState(pos); + } - @Override - public WorldLightManager getLightManager() - { - return world.getLightManager(); - } + @Override + public WorldLightManager getLightManager() { + return world.getLightManager(); + } - @Override - public int getBlockColor( BlockPos blockPosIn, ColorResolver colorResolverIn ) - { - return world.getBlockColor( blockPosIn, colorResolverIn ); - } + @Override + public int getBlockColor(BlockPos blockPosIn, ColorResolver colorResolverIn) { + return world.getBlockColor(blockPosIn, colorResolverIn); + } } diff --git a/src/main/java/appeng/client/render/cablebus/FacadeBuilder.java b/src/main/java/appeng/client/render/cablebus/FacadeBuilder.java index 403507565..6b7871397 100644 --- a/src/main/java/appeng/client/render/cablebus/FacadeBuilder.java +++ b/src/main/java/appeng/client/render/cablebus/FacadeBuilder.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -35,8 +34,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; @@ -64,420 +63,374 @@ import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadFaceStr import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadReInterpolator; import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadTinter; - /** * The FacadeBuilder builds for facades.. * * @author covers1624 */ -public class FacadeBuilder -{ +public class FacadeBuilder { - public static final double THICK_THICKNESS = 2D / 16D; - public static final double THIN_THICKNESS = 1D / 16D; + public static final double THICK_THICKNESS = 2D / 16D; + public static final double THIN_THICKNESS = 1D / 16D; - public static final AxisAlignedBB[] THICK_FACADE_BOXES = new AxisAlignedBB[] { - new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, THICK_THICKNESS, 1.0 ), - new AxisAlignedBB( 0.0, 1.0 - THICK_THICKNESS, 0.0, 1.0, 1.0, 1.0 ), - new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, THICK_THICKNESS ), - new AxisAlignedBB( 0.0, 0.0, 1.0 - THICK_THICKNESS, 1.0, 1.0, 1.0 ), - new AxisAlignedBB( 0.0, 0.0, 0.0, THICK_THICKNESS, 1.0, 1.0 ), - new AxisAlignedBB( 1.0 - THICK_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0 ) - }; + public static final AxisAlignedBB[] THICK_FACADE_BOXES = new AxisAlignedBB[] { + new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, THICK_THICKNESS, 1.0), + new AxisAlignedBB(0.0, 1.0 - THICK_THICKNESS, 0.0, 1.0, 1.0, 1.0), + new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, THICK_THICKNESS), + new AxisAlignedBB(0.0, 0.0, 1.0 - THICK_THICKNESS, 1.0, 1.0, 1.0), + new AxisAlignedBB(0.0, 0.0, 0.0, THICK_THICKNESS, 1.0, 1.0), + new AxisAlignedBB(1.0 - THICK_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0) }; - public static final AxisAlignedBB[] THIN_FACADE_BOXES = new AxisAlignedBB[] { - new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, THIN_THICKNESS, 1.0 ), - new AxisAlignedBB( 0.0, 1.0 - THIN_THICKNESS, 0.0, 1.0, 1.0, 1.0 ), - new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, THIN_THICKNESS ), - new AxisAlignedBB( 0.0, 0.0, 1.0 - THIN_THICKNESS, 1.0, 1.0, 1.0 ), - new AxisAlignedBB( 0.0, 0.0, 0.0, THIN_THICKNESS, 1.0, 1.0 ), - new AxisAlignedBB( 1.0 - THIN_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0 ) - }; + public static final AxisAlignedBB[] THIN_FACADE_BOXES = new AxisAlignedBB[] { + new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, THIN_THICKNESS, 1.0), + new AxisAlignedBB(0.0, 1.0 - THIN_THICKNESS, 0.0, 1.0, 1.0, 1.0), + new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, THIN_THICKNESS), + new AxisAlignedBB(0.0, 0.0, 1.0 - THIN_THICKNESS, 1.0, 1.0, 1.0), + new AxisAlignedBB(0.0, 0.0, 0.0, THIN_THICKNESS, 1.0, 1.0), + new AxisAlignedBB(1.0 - THIN_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0) }; - private final ThreadLocal pipelines = ThreadLocal.withInitial( () -> BakedPipeline.builder() - // Clamper is responsible for clamping the vertex to the bounds specified. - .addElement( "clamper", QuadClamper.FACTORY ) - // Strips faces if they match a mask. - .addElement( "face_stripper", QuadFaceStripper.FACTORY ) - // Kicks the edge inner corners in, solves Z fighting - .addElement( "corner_kicker", QuadCornerKicker.FACTORY ) - // Re-Interpolates the UV's for the quad. - .addElement( "interp", QuadReInterpolator.FACTORY ) - // Tints the quad if we need it to. Disabled by default. - .addElement( "tinter", QuadTinter.FACTORY, false ) - // Overrides the quad's alpha if we are forcing transparent facades. - .addElement( "transparent", QuadAlphaOverride.FACTORY, false, e -> e.setAlphaOverride( 0x4C / 255F ) ) - .build()// - ); - private final ThreadLocal collectors = ThreadLocal.withInitial( Quad::new ); + private final ThreadLocal pipelines = ThreadLocal.withInitial(() -> BakedPipeline.builder() + // Clamper is responsible for clamping the vertex to the bounds specified. + .addElement("clamper", QuadClamper.FACTORY) + // Strips faces if they match a mask. + .addElement("face_stripper", QuadFaceStripper.FACTORY) + // Kicks the edge inner corners in, solves Z fighting + .addElement("corner_kicker", QuadCornerKicker.FACTORY) + // Re-Interpolates the UV's for the quad. + .addElement("interp", QuadReInterpolator.FACTORY) + // Tints the quad if we need it to. Disabled by default. + .addElement("tinter", QuadTinter.FACTORY, false) + // Overrides the quad's alpha if we are forcing transparent facades. + .addElement("transparent", QuadAlphaOverride.FACTORY, false, e -> e.setAlphaOverride(0x4C / 255F)).build()// + ); + private final ThreadLocal collectors = ThreadLocal.withInitial(Quad::new); - public void buildFacadeQuads( RenderType layer, CableBusRenderState renderState, Random rand, List quads, Function modelLookup ) - { - BakedPipeline pipeline = this.pipelines.get(); - Quad collectorQuad = this.collectors.get(); - boolean transparent = AEApi.instance().partHelper().getCableRenderMode().transparentFacades; - Map facadeStates = renderState.getFacades(); - List partBoxes = renderState.getBoundingBoxes(); - Set sidesWithParts = renderState.getAttachments().keySet(); - ILightReader parentWorld = renderState.getWorld(); - BlockPos pos = renderState.getPos(); - BlockColors blockColors = Minecraft.getInstance().getBlockColors(); - boolean thinFacades = isUseThinFacades( partBoxes ); + public void buildFacadeQuads(RenderType layer, CableBusRenderState renderState, Random rand, List quads, + Function modelLookup) { + BakedPipeline pipeline = this.pipelines.get(); + Quad collectorQuad = this.collectors.get(); + boolean transparent = AEApi.instance().partHelper().getCableRenderMode().transparentFacades; + Map facadeStates = renderState.getFacades(); + List partBoxes = renderState.getBoundingBoxes(); + Set sidesWithParts = renderState.getAttachments().keySet(); + ILightReader parentWorld = renderState.getWorld(); + BlockPos pos = renderState.getPos(); + BlockColors blockColors = Minecraft.getInstance().getBlockColors(); + boolean thinFacades = isUseThinFacades(partBoxes); - for( Entry entry : facadeStates.entrySet() ) - { - Direction side = entry.getKey(); - int sideIndex = side.ordinal(); - FacadeRenderState facadeRenderState = entry.getValue(); - boolean renderStilt = !sidesWithParts.contains( side ); - if( layer == RenderType.getCutout() && renderStilt ) - { - for( ResourceLocation part : PartCableAnchor.FACADE_MODELS.getModels() ) - { - IBakedModel partModel = modelLookup.apply( part ); - QuadRotator rotator = new QuadRotator(); - quads.addAll( rotator.rotateQuads( gatherQuads( partModel, null, rand, EmptyModelData.INSTANCE ), side, Direction.UP ) ); - } - } - // If we are forcing transparency and this isn't the Translucent layer. - if( transparent && layer != RenderType.getTranslucent() ) - { - continue; - } + for (Entry entry : facadeStates.entrySet()) { + Direction side = entry.getKey(); + int sideIndex = side.ordinal(); + FacadeRenderState facadeRenderState = entry.getValue(); + boolean renderStilt = !sidesWithParts.contains(side); + if (layer == RenderType.getCutout() && renderStilt) { + for (ResourceLocation part : PartCableAnchor.FACADE_MODELS.getModels()) { + IBakedModel partModel = modelLookup.apply(part); + QuadRotator rotator = new QuadRotator(); + quads.addAll(rotator.rotateQuads(gatherQuads(partModel, null, rand, EmptyModelData.INSTANCE), side, + Direction.UP)); + } + } + // If we are forcing transparency and this isn't the Translucent layer. + if (transparent && layer != RenderType.getTranslucent()) { + continue; + } - BlockState blockState = facadeRenderState.getSourceBlock(); - // If we aren't forcing transparency let the block decide if it should render. - if( !transparent && layer != null ) - { - if( !RenderTypeLookup.canRenderInLayer( blockState, layer ) ) - { - continue; - } - } + BlockState blockState = facadeRenderState.getSourceBlock(); + // If we aren't forcing transparency let the block decide if it should render. + if (!transparent && layer != null) { + if (!RenderTypeLookup.canRenderInLayer(blockState, layer)) { + continue; + } + } - AxisAlignedBB fullBounds = thinFacades ? THIN_FACADE_BOXES[sideIndex] : THICK_FACADE_BOXES[sideIndex]; - AxisAlignedBB facadeBox = fullBounds; - // If we are a transparent facade, we need to modify out BB. - if( facadeRenderState.isTransparent() ) - { - double offset = thinFacades ? THIN_THICKNESS : THICK_THICKNESS; - AEAxisAlignedBB tmpBB = null; - for( Direction face : Direction.values() ) - { - // Only faces that aren't on our axis - if( face.getAxis() != side.getAxis() ) - { - FacadeRenderState otherState = facadeStates.get( face ); - if( otherState != null && !otherState.isTransparent() ) - { - if( tmpBB == null ) - { - tmpBB = AEAxisAlignedBB.fromBounds( facadeBox ); - } - switch( face ) - { - case DOWN: - tmpBB.minY += offset; - break; - case UP: - tmpBB.maxY -= offset; - break; - case NORTH: - tmpBB.minZ += offset; - break; - case SOUTH: - tmpBB.maxZ -= offset; - break; - case WEST: - tmpBB.minX += offset; - break; - case EAST: - tmpBB.maxX -= offset; - break; - default: - throw new RuntimeException( "Switch falloff. " + String.valueOf( face ) ); - } - } - } - } - if( tmpBB != null ) - { - facadeBox = tmpBB.getBoundingBox(); - } - } + AxisAlignedBB fullBounds = thinFacades ? THIN_FACADE_BOXES[sideIndex] : THICK_FACADE_BOXES[sideIndex]; + AxisAlignedBB facadeBox = fullBounds; + // If we are a transparent facade, we need to modify out BB. + if (facadeRenderState.isTransparent()) { + double offset = thinFacades ? THIN_THICKNESS : THICK_THICKNESS; + AEAxisAlignedBB tmpBB = null; + for (Direction face : Direction.values()) { + // Only faces that aren't on our axis + if (face.getAxis() != side.getAxis()) { + FacadeRenderState otherState = facadeStates.get(face); + if (otherState != null && !otherState.isTransparent()) { + if (tmpBB == null) { + tmpBB = AEAxisAlignedBB.fromBounds(facadeBox); + } + switch (face) { + case DOWN: + tmpBB.minY += offset; + break; + case UP: + tmpBB.maxY -= offset; + break; + case NORTH: + tmpBB.minZ += offset; + break; + case SOUTH: + tmpBB.maxZ -= offset; + break; + case WEST: + tmpBB.minX += offset; + break; + case EAST: + tmpBB.maxX -= offset; + break; + default: + throw new RuntimeException("Switch falloff. " + String.valueOf(face)); + } + } + } + } + if (tmpBB != null) { + facadeBox = tmpBB.getBoundingBox(); + } + } - AEAxisAlignedBB cutOutBox = getCutOutBox( facadeBox, partBoxes ); - List holeStrips = getBoxes( facadeBox, cutOutBox, side.getAxis() ); - ILightReader facadeAccess = new FacadeBlockAccess( parentWorld, pos, side, blockState ); + AEAxisAlignedBB cutOutBox = getCutOutBox(facadeBox, partBoxes); + List holeStrips = getBoxes(facadeBox, cutOutBox, side.getAxis()); + ILightReader facadeAccess = new FacadeBlockAccess(parentWorld, pos, side, blockState); - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); - IBakedModel model = dispatcher.getModelForState( blockState ); - IModelData modelData = model.getModelData( facadeAccess, pos, blockState, EmptyModelData.INSTANCE ); + BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + IBakedModel model = dispatcher.getModelForState(blockState); + IModelData modelData = model.getModelData(facadeAccess, pos, blockState, EmptyModelData.INSTANCE); - List modelQuads = new ArrayList<>(); - // If we are forcing transparent facades, fake the render layer, and grab all quads. - if( transparent || layer == null ) - { - for( RenderType forcedLayer : RenderType.getBlockRenderTypes() ) - { - // Check if the block renders on the layer we want to force. - if( RenderTypeLookup.canRenderInLayer( blockState, forcedLayer ) ) - { - // Force the layer and gather quads. - ForgeHooksClient.setRenderLayer( forcedLayer ); - modelQuads.addAll( gatherQuads( model, blockState, rand, modelData) ); - } - } + List modelQuads = new ArrayList<>(); + // If we are forcing transparent facades, fake the render layer, and grab all + // quads. + if (transparent || layer == null) { + for (RenderType forcedLayer : RenderType.getBlockRenderTypes()) { + // Check if the block renders on the layer we want to force. + if (RenderTypeLookup.canRenderInLayer(blockState, forcedLayer)) { + // Force the layer and gather quads. + ForgeHooksClient.setRenderLayer(forcedLayer); + modelQuads.addAll(gatherQuads(model, blockState, rand, modelData)); + } + } - // Reset. - ForgeHooksClient.setRenderLayer( layer ); - } - else - { - modelQuads.addAll( gatherQuads( model, blockState, rand, modelData ) ); - } + // Reset. + ForgeHooksClient.setRenderLayer(layer); + } else { + modelQuads.addAll(gatherQuads(model, blockState, rand, modelData)); + } - // No quads.. Cool, next! - if( modelQuads.isEmpty() ) - { - continue; - } + // No quads.. Cool, next! + if (modelQuads.isEmpty()) { + continue; + } - // Grab out pipeline elements. - QuadClamper clamper = pipeline.getElement( "clamper", QuadClamper.class ); - QuadFaceStripper edgeStripper = pipeline.getElement( "face_stripper", QuadFaceStripper.class ); - QuadTinter tinter = pipeline.getElement( "tinter", QuadTinter.class ); - QuadCornerKicker kicker = pipeline.getElement( "corner_kicker", QuadCornerKicker.class ); + // Grab out pipeline elements. + QuadClamper clamper = pipeline.getElement("clamper", QuadClamper.class); + QuadFaceStripper edgeStripper = pipeline.getElement("face_stripper", QuadFaceStripper.class); + QuadTinter tinter = pipeline.getElement("tinter", QuadTinter.class); + QuadCornerKicker kicker = pipeline.getElement("corner_kicker", QuadCornerKicker.class); - // Set global element states. + // Set global element states. - // calculate the side mask. - int facadeMask = 0; - for( Entry ent : facadeStates.entrySet() ) - { - Direction s = ent.getKey(); - if( s.getAxis() != side.getAxis() ) - { - FacadeRenderState otherState = ent.getValue(); - if( !otherState.isTransparent() ) - { - facadeMask |= 1 << s.ordinal(); - } - } - } - // Setup the edge stripper. - edgeStripper.setBounds( fullBounds ); - edgeStripper.setMask( facadeMask ); + // calculate the side mask. + int facadeMask = 0; + for (Entry ent : facadeStates.entrySet()) { + Direction s = ent.getKey(); + if (s.getAxis() != side.getAxis()) { + FacadeRenderState otherState = ent.getValue(); + if (!otherState.isTransparent()) { + facadeMask |= 1 << s.ordinal(); + } + } + } + // Setup the edge stripper. + edgeStripper.setBounds(fullBounds); + edgeStripper.setMask(facadeMask); - // Setup the kicker. - kicker.setSide( sideIndex ); - kicker.setFacadeMask( facadeMask ); - kicker.setBox( fullBounds ); - kicker.setThickness( thinFacades ? THIN_THICKNESS : THICK_THICKNESS ); + // Setup the kicker. + kicker.setSide(sideIndex); + kicker.setFacadeMask(facadeMask); + kicker.setBox(fullBounds); + kicker.setThickness(thinFacades ? THIN_THICKNESS : THICK_THICKNESS); - for( BakedQuad quad : modelQuads ) - { - // lookup the format in CachedFormat. - CachedFormat format = CachedFormat.lookup( DefaultVertexFormats.BLOCK ); - // If this quad has a tint index, setup the tinter. - if( quad.hasTintIndex() ) - { - tinter.setTint( blockColors.getColor( blockState, facadeAccess, pos, quad.getTintIndex() ) ); - } - for( AxisAlignedBB box : holeStrips ) - { - // setup the clamper for this box - clamper.setClampBounds( box ); - // Reset the pipeline, clears all enabled/disabled states. - pipeline.reset( format ); - // Reset out collector. - collectorQuad.reset( format ); - // Enable / disable the optional elements - pipeline.setElementState( "tinter", quad.hasTintIndex() ); - pipeline.setElementState( "transparent", transparent ); - // Prepare the pipeline for a quad. - pipeline.prepare( collectorQuad ); + for (BakedQuad quad : modelQuads) { + // lookup the format in CachedFormat. + CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK); + // If this quad has a tint index, setup the tinter. + if (quad.hasTintIndex()) { + tinter.setTint(blockColors.getColor(blockState, facadeAccess, pos, quad.getTintIndex())); + } + for (AxisAlignedBB box : holeStrips) { + // setup the clamper for this box + clamper.setClampBounds(box); + // Reset the pipeline, clears all enabled/disabled states. + pipeline.reset(format); + // Reset out collector. + collectorQuad.reset(format); + // Enable / disable the optional elements + pipeline.setElementState("tinter", quad.hasTintIndex()); + pipeline.setElementState("transparent", transparent); + // Prepare the pipeline for a quad. + pipeline.prepare(collectorQuad); - // Pipe our quad into the pipeline. - quad.pipe( pipeline ); - // Check if the collector got any data. - if( collectorQuad.full ) - { - // Add the result. - quads.add( collectorQuad.bake() ); - } - } - } - } - } + // Pipe our quad into the pipeline. + quad.pipe(pipeline); + // Check if the collector got any data. + if (collectorQuad.full) { + // Add the result. + quads.add(collectorQuad.bake()); + } + } + } + } + } - /** - * This is slow, so should be cached. - * - * @return The model. - */ - public List buildFacadeItemQuads( ItemStack textureItem, Direction side ) - { - List facadeQuads = new ArrayList<>(); - IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides( textureItem, null, null ); - List modelQuads = gatherQuads( model, null, new Random(), EmptyModelData.INSTANCE ); + /** + * This is slow, so should be cached. + * + * @return The model. + */ + public List buildFacadeItemQuads(ItemStack textureItem, Direction side) { + List facadeQuads = new ArrayList<>(); + IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(textureItem, null, + null); + List modelQuads = gatherQuads(model, null, new Random(), EmptyModelData.INSTANCE); - BakedPipeline pipeline = this.pipelines.get(); - Quad collectorQuad = this.collectors.get(); + BakedPipeline pipeline = this.pipelines.get(); + Quad collectorQuad = this.collectors.get(); - // Grab pipeline elements. - QuadClamper clamper = pipeline.getElement( "clamper", QuadClamper.class ); - QuadTinter tinter = pipeline.getElement( "tinter", QuadTinter.class ); + // Grab pipeline elements. + QuadClamper clamper = pipeline.getElement("clamper", QuadClamper.class); + QuadTinter tinter = pipeline.getElement("tinter", QuadTinter.class); - for( BakedQuad quad : modelQuads ) - { - // Lookup the CachedFormat for this quads format. - CachedFormat format = CachedFormat.lookup( DefaultVertexFormats.BLOCK ); - // Reset the pipeline. - pipeline.reset( format ); - // Reset the collector. - collectorQuad.reset( format ); - // If we have a tint index, setup the tinter and enable it. - if( quad.hasTintIndex() ) - { - tinter.setTint( Minecraft.getInstance().getItemColors().getColor( textureItem, quad.getTintIndex() ) ); - pipeline.enableElement( "tinter" ); - } - // Disable elements we don't need for items. - pipeline.disableElement( "face_stripper" ); - pipeline.disableElement( "corner_kicker" ); - // Setup the clamper - clamper.setClampBounds( THICK_FACADE_BOXES[side.ordinal()] ); - // Prepare the pipeline. - pipeline.prepare( collectorQuad ); - // Pipe our quad into the pipeline. - quad.pipe( pipeline ); - // Check the collector for data and add the quad if there was. - if( collectorQuad.full ) - { - facadeQuads.add( collectorQuad.bake() ); - } - } - return facadeQuads; - } + for (BakedQuad quad : modelQuads) { + // Lookup the CachedFormat for this quads format. + CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK); + // Reset the pipeline. + pipeline.reset(format); + // Reset the collector. + collectorQuad.reset(format); + // If we have a tint index, setup the tinter and enable it. + if (quad.hasTintIndex()) { + tinter.setTint(Minecraft.getInstance().getItemColors().getColor(textureItem, quad.getTintIndex())); + pipeline.enableElement("tinter"); + } + // Disable elements we don't need for items. + pipeline.disableElement("face_stripper"); + pipeline.disableElement("corner_kicker"); + // Setup the clamper + clamper.setClampBounds(THICK_FACADE_BOXES[side.ordinal()]); + // Prepare the pipeline. + pipeline.prepare(collectorQuad); + // Pipe our quad into the pipeline. + quad.pipe(pipeline); + // Check the collector for data and add the quad if there was. + if (collectorQuad.full) { + facadeQuads.add(collectorQuad.bake()); + } + } + return facadeQuads; + } - // Helper to gather all quads from a model into a list. - private static List gatherQuads( IBakedModel model, BlockState state, Random rand, IModelData data ) - { - List modelQuads = new ArrayList<>(); - for( Direction face : Direction.values() ) - { - modelQuads.addAll( model.getQuads( state, face, rand, data) ); - } - modelQuads.addAll( model.getQuads( state, null, rand, data ) ); - return modelQuads; - } + // Helper to gather all quads from a model into a list. + private static List gatherQuads(IBakedModel model, BlockState state, Random rand, IModelData data) { + List modelQuads = new ArrayList<>(); + for (Direction face : Direction.values()) { + modelQuads.addAll(model.getQuads(state, face, rand, data)); + } + modelQuads.addAll(model.getQuads(state, null, rand, data)); + return modelQuads; + } - /** - * Given the actual facade bounding box, and the bounding boxes of all parts, determine the biggest union of AABB - * that intersect with the facade's bounding - * box. This AABB will need to be "cut out" when the facade is rendered. - */ - @Nullable - private static AEAxisAlignedBB getCutOutBox( AxisAlignedBB facadeBox, List partBoxes ) - { - AEAxisAlignedBB b = null; - for( AxisAlignedBB bb : partBoxes ) - { - if( bb.intersects( facadeBox ) ) - { - if( b == null ) - { - b = AEAxisAlignedBB.fromBounds( bb ); - } - else - { - b.maxX = Math.max( b.maxX, bb.maxX ); - b.maxY = Math.max( b.maxY, bb.maxY ); - b.maxZ = Math.max( b.maxZ, bb.maxZ ); - b.minX = Math.min( b.minX, bb.minX ); - b.minY = Math.min( b.minY, bb.minY ); - b.minZ = Math.min( b.minZ, bb.minZ ); - } - } - } - return b; - } + /** + * Given the actual facade bounding box, and the bounding boxes of all parts, + * determine the biggest union of AABB that intersect with the facade's bounding + * box. This AABB will need to be "cut out" when the facade is rendered. + */ + @Nullable + private static AEAxisAlignedBB getCutOutBox(AxisAlignedBB facadeBox, List partBoxes) { + AEAxisAlignedBB b = null; + for (AxisAlignedBB bb : partBoxes) { + if (bb.intersects(facadeBox)) { + if (b == null) { + b = AEAxisAlignedBB.fromBounds(bb); + } else { + b.maxX = Math.max(b.maxX, bb.maxX); + b.maxY = Math.max(b.maxY, bb.maxY); + b.maxZ = Math.max(b.maxZ, bb.maxZ); + b.minX = Math.min(b.minX, bb.minX); + b.minY = Math.min(b.minY, bb.minY); + b.minZ = Math.min(b.minZ, bb.minZ); + } + } + } + return b; + } - /** - * Generates the box segments around the specified hole. If the specified hole is null, a Singleton of the Facade - * box is returned. - * - * @param fb The Facade's box. - * @param hole The hole to 'cut'. - * @param axis The axis the facade is on. - * - * @return The box segments. - */ - private static List getBoxes( AxisAlignedBB fb, AEAxisAlignedBB hole, Axis axis ) - { - if( hole == null ) - { - return Collections.singletonList( fb ); - } - List boxes = new ArrayList<>(); - switch( axis ) - { - case Y: - boxes.add( new AxisAlignedBB( fb.minX, fb.minY, fb.minZ, hole.minX, fb.maxY, fb.maxZ ) ); - boxes.add( new AxisAlignedBB( hole.maxX, fb.minY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ ) ); + /** + * Generates the box segments around the specified hole. If the specified hole + * is null, a Singleton of the Facade box is returned. + * + * @param fb The Facade's box. + * @param hole The hole to 'cut'. + * @param axis The axis the facade is on. + * + * @return The box segments. + */ + private static List getBoxes(AxisAlignedBB fb, AEAxisAlignedBB hole, Axis axis) { + if (hole == null) { + return Collections.singletonList(fb); + } + List boxes = new ArrayList<>(); + switch (axis) { + case Y: + boxes.add(new AxisAlignedBB(fb.minX, fb.minY, fb.minZ, hole.minX, fb.maxY, fb.maxZ)); + boxes.add(new AxisAlignedBB(hole.maxX, fb.minY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ)); - boxes.add( new AxisAlignedBB( hole.minX, fb.minY, fb.minZ, hole.maxX, fb.maxY, hole.minZ ) ); - boxes.add( new AxisAlignedBB( hole.minX, fb.minY, hole.maxZ, hole.maxX, fb.maxY, fb.maxZ ) ); + boxes.add(new AxisAlignedBB(hole.minX, fb.minY, fb.minZ, hole.maxX, fb.maxY, hole.minZ)); + boxes.add(new AxisAlignedBB(hole.minX, fb.minY, hole.maxZ, hole.maxX, fb.maxY, fb.maxZ)); - break; - case Z: - boxes.add( new AxisAlignedBB( fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ ) ); - boxes.add( new AxisAlignedBB( fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ ) ); + break; + case Z: + boxes.add(new AxisAlignedBB(fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ)); + boxes.add(new AxisAlignedBB(fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ)); - boxes.add( new AxisAlignedBB( fb.minX, hole.minY, fb.minZ, hole.minX, hole.maxY, fb.maxZ ) ); - boxes.add( new AxisAlignedBB( hole.maxX, hole.minY, fb.minZ, fb.maxX, hole.maxY, fb.maxZ ) ); + boxes.add(new AxisAlignedBB(fb.minX, hole.minY, fb.minZ, hole.minX, hole.maxY, fb.maxZ)); + boxes.add(new AxisAlignedBB(hole.maxX, hole.minY, fb.minZ, fb.maxX, hole.maxY, fb.maxZ)); - break; - case X: - boxes.add( new AxisAlignedBB( fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ ) ); - boxes.add( new AxisAlignedBB( fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ ) ); + break; + case X: + boxes.add(new AxisAlignedBB(fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ)); + boxes.add(new AxisAlignedBB(fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ)); - boxes.add( new AxisAlignedBB( fb.minX, hole.minY, fb.minZ, fb.maxX, hole.maxY, hole.minZ ) ); - boxes.add( new AxisAlignedBB( fb.minX, hole.minY, hole.maxZ, fb.maxX, hole.maxY, fb.maxZ ) ); - break; - default: - // should never happen. - throw new RuntimeException( "switch falloff. " + String.valueOf( axis ) ); - } + boxes.add(new AxisAlignedBB(fb.minX, hole.minY, fb.minZ, fb.maxX, hole.maxY, hole.minZ)); + boxes.add(new AxisAlignedBB(fb.minX, hole.minY, hole.maxZ, fb.maxX, hole.maxY, fb.maxZ)); + break; + default: + // should never happen. + throw new RuntimeException("switch falloff. " + String.valueOf(axis)); + } - return boxes; - } + return boxes; + } - /** - * Determines if any of the part's bounding boxes intersects with the outside 2 voxel wide layer. If so, we should - * use thinner facades (1 voxel deep). - */ - private static boolean isUseThinFacades( List partBoxes ) - { - final double min = 2.0 / 16.0; - final double max = 14.0 / 16.0; + /** + * Determines if any of the part's bounding boxes intersects with the outside 2 + * voxel wide layer. If so, we should use thinner facades (1 voxel deep). + */ + private static boolean isUseThinFacades(List partBoxes) { + final double min = 2.0 / 16.0; + final double max = 14.0 / 16.0; - for( AxisAlignedBB bb : partBoxes ) - { - int o = 0; - o += bb.maxX > max ? 1 : 0; - o += bb.maxY > max ? 1 : 0; - o += bb.maxZ > max ? 1 : 0; - o += bb.minX < min ? 1 : 0; - o += bb.minY < min ? 1 : 0; - o += bb.minZ < min ? 1 : 0; + for (AxisAlignedBB bb : partBoxes) { + int o = 0; + o += bb.maxX > max ? 1 : 0; + o += bb.maxY > max ? 1 : 0; + o += bb.maxZ > max ? 1 : 0; + o += bb.minX < min ? 1 : 0; + o += bb.minY < min ? 1 : 0; + o += bb.minZ < min ? 1 : 0; - if( o >= 2 ) - { - return true; - } - } - return false; - } + if (o >= 2) { + return true; + } + } + return false; + } } diff --git a/src/main/java/appeng/client/render/cablebus/FacadeRenderState.java b/src/main/java/appeng/client/render/cablebus/FacadeRenderState.java index d5b2df16a..32b978bc3 100644 --- a/src/main/java/appeng/client/render/cablebus/FacadeRenderState.java +++ b/src/main/java/appeng/client/render/cablebus/FacadeRenderState.java @@ -1,34 +1,28 @@ package appeng.client.render.cablebus; - import net.minecraft.block.BlockState; - /** * Captures the state required to render a facade properly. */ -public class FacadeRenderState -{ +public class FacadeRenderState { - // The block state to use for rendering this facade - private final BlockState sourceBlock; + // The block state to use for rendering this facade + private final BlockState sourceBlock; - private final boolean transparent; + private final boolean transparent; - public FacadeRenderState( BlockState sourceBlock, boolean transparent ) - { - this.sourceBlock = sourceBlock; - this.transparent = transparent; - } + public FacadeRenderState(BlockState sourceBlock, boolean transparent) { + this.sourceBlock = sourceBlock; + this.transparent = transparent; + } - public BlockState getSourceBlock() - { - return this.sourceBlock; - } + public BlockState getSourceBlock() { + return this.sourceBlock; + } - public boolean isTransparent() - { - return this.transparent; - } + public boolean isTransparent() { + return this.transparent; + } } diff --git a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyBakedModel.java b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyBakedModel.java index 5b1318bf2..30aa73ab1 100644 --- a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyBakedModel.java +++ b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyBakedModel.java @@ -1,7 +1,6 @@ package appeng.client.render.cablebus; - import java.util.Collections; import java.util.List; import java.util.Random; @@ -15,130 +14,104 @@ import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; - -import appeng.api.util.AEColor; -import appeng.util.Platform; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; +import appeng.api.util.AEColor; +import appeng.util.Platform; -public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel -{ +public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel { - private final TextureAtlasSprite texture; + private final TextureAtlasSprite texture; - private final static Cache> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build(); + private final static Cache> modelCache = CacheBuilder.newBuilder().maximumSize(100).build(); - private static final int[][] QUAD_OFFSETS = new int[][] { - { 4, 10, 2 }, - { 10, 10, 2 }, - { 4, 4, 2 }, - { 10, 4, 2 } - }; + private static final int[][] QUAD_OFFSETS = new int[][] { { 4, 10, 2 }, { 10, 10, 2 }, { 4, 4, 2 }, { 10, 4, 2 } }; - public P2PTunnelFrequencyBakedModel( final TextureAtlasSprite texture ) - { - this.texture = texture; - } + public P2PTunnelFrequencyBakedModel(final TextureAtlasSprite texture) { + this.texture = texture; + } - @Override - public List getQuads( BlockState state, Direction side, Random rand, IModelData modelData ) - { - if( side != null || !(modelData instanceof P2PTunnelFrequencyModelData) ) - { - return Collections.emptyList(); - } + @Override + public List getQuads(BlockState state, Direction side, Random rand, IModelData modelData) { + if (side != null || !(modelData instanceof P2PTunnelFrequencyModelData)) { + return Collections.emptyList(); + } - P2PTunnelFrequencyModelData freqModelData = (P2PTunnelFrequencyModelData) modelData; + P2PTunnelFrequencyModelData freqModelData = (P2PTunnelFrequencyModelData) modelData; - return this.getPartQuads( freqModelData.getFrequency()); - } + return this.getPartQuads(freqModelData.getFrequency()); + } - private List getQuadsForFrequency( final short frequency, final boolean active ) - { - final AEColor[] colors = Platform.p2p().toColors( frequency ); - final CubeBuilder cb = new CubeBuilder(); + private List getQuadsForFrequency(final short frequency, final boolean active) { + final AEColor[] colors = Platform.p2p().toColors(frequency); + final CubeBuilder cb = new CubeBuilder(); - cb.setTexture( this.texture ); - cb.useStandardUV(); - cb.setRenderFullBright( active ); + cb.setTexture(this.texture); + cb.useStandardUV(); + cb.setRenderFullBright(active); - for( int i = 0; i < 4; ++i ) - { - final int[] offs = QUAD_OFFSETS[i]; - for( int j = 0; j < 4; ++j ) - { - final AEColor c = colors[j]; - if( active ) - { - cb.setColorRGB( c.dye.getColorValue() ); - } - else - { - final float[] cv = c.dye.getColorComponentValues(); - cb.setColorRGB( cv[0] * 0.5f, cv[1] * 0.5f, cv[2] * 0.5f ); - } + for (int i = 0; i < 4; ++i) { + final int[] offs = QUAD_OFFSETS[i]; + for (int j = 0; j < 4; ++j) { + final AEColor c = colors[j]; + if (active) { + cb.setColorRGB(c.dye.getColorValue()); + } else { + final float[] cv = c.dye.getColorComponentValues(); + cb.setColorRGB(cv[0] * 0.5f, cv[1] * 0.5f, cv[2] * 0.5f); + } - final int startx = j % 2; - final int starty = 1 - j / 2; + final int startx = j % 2; + final int starty = 1 - j / 2; - cb.addCube( offs[0] + startx, offs[1] + starty, offs[2], offs[0] + startx + 1, offs[1] + starty + 1, offs[2] + 1 ); - } + cb.addCube(offs[0] + startx, offs[1] + starty, offs[2], offs[0] + startx + 1, offs[1] + starty + 1, + offs[2] + 1); + } - } - return cb.getOutput(); - } + } + return cb.getOutput(); + } - private List getPartQuads(long partFlags) - { - try - { - return modelCache.get( partFlags, () -> - { - short frequency = (short) ( partFlags & 0xffffL ); - boolean active = ( partFlags & 0x10000L ) != 0; - return this.getQuadsForFrequency( frequency, active ); - } ); - } - catch( ExecutionException e ) - { - return Collections.emptyList(); - } - } + private List getPartQuads(long partFlags) { + try { + return modelCache.get(partFlags, () -> { + short frequency = (short) (partFlags & 0xffffL); + boolean active = (partFlags & 0x10000L) != 0; + return this.getQuadsForFrequency(frequency, active); + }); + } catch (ExecutionException e) { + return Collections.emptyList(); + } + } - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean isBuiltInRenderer() - { - return true; - } + @Override + public boolean isBuiltInRenderer() { + return true; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.texture; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.texture; + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } } diff --git a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModel.java b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModel.java index fc133b6c7..1329ae697 100644 --- a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModel.java +++ b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModel.java @@ -1,10 +1,10 @@ package appeng.client.render.cablebus; - import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; + import javax.annotation.Nullable; import com.mojang.datafixers.util.Pair; @@ -13,32 +13,31 @@ import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; - -import appeng.core.AppEng; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; +import appeng.core.AppEng; -public class P2PTunnelFrequencyModel implements IModelGeometry -{ - private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" ) ); +public class P2PTunnelFrequencyModel implements IModelGeometry { + private static final Material TEXTURE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "parts/p2p_tunnel_frequency")); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - try - { - final TextureAtlasSprite texture = spriteGetter.apply( TEXTURE ); - return new P2PTunnelFrequencyBakedModel( texture ); - } - catch( Exception e ) - { - throw new RuntimeException( e ); - } - } + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + try { + final TextureAtlasSprite texture = spriteGetter.apply(TEXTURE); + return new P2PTunnelFrequencyBakedModel(texture); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Collections.singleton( TEXTURE ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.singleton(TEXTURE); + } } diff --git a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModelData.java b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModelData.java index f6acb8f93..2bc7d0ece 100644 --- a/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModelData.java +++ b/src/main/java/appeng/client/render/cablebus/P2PTunnelFrequencyModelData.java @@ -1,10 +1,11 @@ package appeng.client.render.cablebus; -import appeng.client.render.model.AEInternalModelData; +import javax.annotation.Nullable; + import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nullable; +import appeng.client.render.model.AEInternalModelData; public final class P2PTunnelFrequencyModelData extends AEInternalModelData { diff --git a/src/main/java/appeng/client/render/cablebus/QuadRotator.java b/src/main/java/appeng/client/render/cablebus/QuadRotator.java index 79b1438dc..963cad75a 100644 --- a/src/main/java/appeng/client/render/cablebus/QuadRotator.java +++ b/src/main/java/appeng/client/render/cablebus/QuadRotator.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.ArrayList; import java.util.List; @@ -34,73 +33,62 @@ import appeng.thirdparty.codechicken.lib.model.Quad; import appeng.thirdparty.codechicken.lib.model.pipeline.BakedPipeline; import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadMatrixTransformer; - /** - * Assuming a default-orientation of forward=NORTH and up=UP, this class rotates a given list of quads to the desired - * facing + * Assuming a default-orientation of forward=NORTH and up=UP, this class rotates + * a given list of quads to the desired facing */ -public class QuadRotator -{ - private static final ThreadLocal pipelines = ThreadLocal.withInitial( () -> // - BakedPipeline.builder()// - .addElement( "transformer", QuadMatrixTransformer.FACTORY )// - .build() ); - private static final ThreadLocal collectors = ThreadLocal.withInitial( Quad::new ); +public class QuadRotator { + private static final ThreadLocal pipelines = ThreadLocal.withInitial(() -> // + BakedPipeline.builder()// + .addElement("transformer", QuadMatrixTransformer.FACTORY)// + .build()); + private static final ThreadLocal collectors = ThreadLocal.withInitial(Quad::new); - public List rotateQuads( List quads, Direction newForward, Direction newUp ) - { - if( newForward == Direction.NORTH && newUp == Direction.UP ) - { - return quads; // This is the default orientation - } - FacingToRotation rotation = getRotation( newForward, newUp ); - if( rotation.isRedundant() ) - { - return quads; - } + public List rotateQuads(List quads, Direction newForward, Direction newUp) { + if (newForward == Direction.NORTH && newUp == Direction.UP) { + return quads; // This is the default orientation + } + FacingToRotation rotation = getRotation(newForward, newUp); + if (rotation.isRedundant()) { + return quads; + } - List result = new ArrayList<>( quads.size() ); + List result = new ArrayList<>(quads.size()); - CachedFormat format = CachedFormat.lookup( DefaultVertexFormats.BLOCK ); - BakedPipeline pipeline = pipelines.get(); - Quad collector = collectors.get(); - QuadMatrixTransformer transformer = pipeline.getElement( "transformer", QuadMatrixTransformer.class ); + CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK); + BakedPipeline pipeline = pipelines.get(); + Quad collector = collectors.get(); + QuadMatrixTransformer transformer = pipeline.getElement("transformer", QuadMatrixTransformer.class); - // FIXME: Temporary rotation fix - Matrix4f mat = new Matrix4f(); - mat.setTranslation(-0.5f, -0.5f, -0.5f); - mat.multiplyBackward(rotation.getMat()); - mat.translate(new Vector3f(0.5f, 0.5f, 0.5f)); + // FIXME: Temporary rotation fix + Matrix4f mat = new Matrix4f(); + mat.setTranslation(-0.5f, -0.5f, -0.5f); + mat.multiplyBackward(rotation.getMat()); + mat.translate(new Vector3f(0.5f, 0.5f, 0.5f)); - for( BakedQuad quad : quads ) - { - pipeline.reset( format ); - collector.reset( format ); + for (BakedQuad quad : quads) { + pipeline.reset(format); + collector.reset(format); - transformer.setMatrix( mat ); - pipeline.prepare( collector ); - quad.pipe( pipeline ); - result.add( collector.bake() ); - } + transformer.setMatrix(mat); + pipeline.prepare(collector); + quad.pipe(pipeline); + result.add(collector.bake()); + } - return result; - } + return result; + } - private FacingToRotation getRotation( Direction forward, Direction up ) - { - // Sanitize forward/up - if( forward.getAxis() == up.getAxis() ) - { - if( up.getAxis() == Direction.Axis.Y ) - { - up = Direction.NORTH; - } - else - { - up = Direction.UP; - } - } + private FacingToRotation getRotation(Direction forward, Direction up) { + // Sanitize forward/up + if (forward.getAxis() == up.getAxis()) { + if (up.getAxis() == Direction.Axis.Y) { + up = Direction.NORTH; + } else { + up = Direction.UP; + } + } - return FacingToRotation.get( forward, up ); - } + return FacingToRotation.get(forward, up); + } } diff --git a/src/main/java/appeng/client/render/cablebus/SmartCableTextures.java b/src/main/java/appeng/client/render/cablebus/SmartCableTextures.java index c9c2dc219..93610b014 100644 --- a/src/main/java/appeng/client/render/cablebus/SmartCableTextures.java +++ b/src/main/java/appeng/client/render/cablebus/SmartCableTextures.java @@ -18,7 +18,6 @@ package appeng.client.render.cablebus; - import java.util.Arrays; import java.util.function.Function; @@ -29,72 +28,58 @@ import net.minecraft.util.ResourceLocation; import appeng.core.AppEng; - /** * Manages the channel textures for smart cables. */ -public class SmartCableTextures -{ +public class SmartCableTextures { - public static final Material[] SMART_CHANNELS_TEXTURES = Arrays.stream( new ResourceLocation[] { - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_00" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_01" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_02" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_03" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_04" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_10" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_11" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_12" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_13" ),// - new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_14" )// - } ).map( e -> new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, e ) ).toArray( Material[]::new ); + public static final Material[] SMART_CHANNELS_TEXTURES = Arrays + .stream(new ResourceLocation[] { new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_00"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_01"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_02"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_03"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_04"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_10"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_11"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_12"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_13"), // + new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_14")// + }).map(e -> new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, e)).toArray(Material[]::new); - // Textures used to display channels on smart cables. There's two sets of 5 textures each, and - // one of each set are composed together to get even/odd colored channels - private final TextureAtlasSprite[] textures; + // Textures used to display channels on smart cables. There's two sets of 5 + // textures each, and + // one of each set are composed together to get even/odd colored channels + private final TextureAtlasSprite[] textures; - public SmartCableTextures( Function bakedTextureGetter ) - { - this.textures = Arrays.stream( SMART_CHANNELS_TEXTURES )// - .map( bakedTextureGetter )// - .toArray( TextureAtlasSprite[]::new ); - } + public SmartCableTextures(Function bakedTextureGetter) { + this.textures = Arrays.stream(SMART_CHANNELS_TEXTURES)// + .map(bakedTextureGetter)// + .toArray(TextureAtlasSprite[]::new); + } - /** - * The odd variant is used for displaying channels 1-4 as in use. - */ - public TextureAtlasSprite getOddTextureForChannels( int channels ) - { - if( channels < 0 ) - { - return this.textures[0]; - } - else if( channels <= 4 ) - { - return this.textures[channels]; - } - else - { - return this.textures[4]; - } - } + /** + * The odd variant is used for displaying channels 1-4 as in use. + */ + public TextureAtlasSprite getOddTextureForChannels(int channels) { + if (channels < 0) { + return this.textures[0]; + } else if (channels <= 4) { + return this.textures[channels]; + } else { + return this.textures[4]; + } + } - /** - * The odd variant is used for displaying channels 5-8 as in use. - */ - public TextureAtlasSprite getEvenTextureForChannels( int channels ) - { - if( channels < 5 ) - { - return this.textures[5]; - } - else if( channels <= 8 ) - { - return this.textures[1 + channels]; - } - else - { - return this.textures[9]; - } - } + /** + * The odd variant is used for displaying channels 5-8 as in use. + */ + public TextureAtlasSprite getEvenTextureForChannels(int channels) { + if (channels < 5) { + return this.textures[5]; + } else if (channels <= 8) { + return this.textures[1 + channels]; + } else { + return this.textures[9]; + } + } } diff --git a/src/main/java/appeng/client/render/crafting/CraftingCubeBakedModel.java b/src/main/java/appeng/client/render/crafting/CraftingCubeBakedModel.java index 1470cc1f2..0e5697cc3 100644 --- a/src/main/java/appeng/client/render/crafting/CraftingCubeBakedModel.java +++ b/src/main/java/appeng/client/render/crafting/CraftingCubeBakedModel.java @@ -18,11 +18,11 @@ package appeng.client.render.crafting; +import java.util.*; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.client.render.cablebus.CubeBuilder; -import appeng.tile.crafting.CraftingCubeModelData; -import appeng.tile.crafting.TileCraftingTile; -import appeng.util.Platform; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.ItemOverrideList; @@ -31,266 +31,255 @@ import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.*; - +import appeng.client.render.cablebus.CubeBuilder; +import appeng.tile.crafting.CraftingCubeModelData; +import appeng.tile.crafting.TileCraftingTile; +import appeng.util.Platform; /** - * The base model for baked models used by components of the crafting cube multi-block in it's formed state. - * Primarily this base class handles adding the "ring" that frames the multi-block structure and delegates - * rendering of the "inner" part of each block to the subclasses of this class. + * The base model for baked models used by components of the crafting cube + * multi-block in it's formed state. Primarily this base class handles adding + * the "ring" that frames the multi-block structure and delegates rendering of + * the "inner" part of each block to the subclasses of this class. */ -abstract class CraftingCubeBakedModel implements IDynamicBakedModel -{ +abstract class CraftingCubeBakedModel implements IDynamicBakedModel { - private final TextureAtlasSprite ringCorner; + private final TextureAtlasSprite ringCorner; - private final TextureAtlasSprite ringHor; + private final TextureAtlasSprite ringHor; - private final TextureAtlasSprite ringVer; + private final TextureAtlasSprite ringVer; - CraftingCubeBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer ) - { - this.ringCorner = ringCorner; - this.ringHor = ringHor; - this.ringVer = ringVer; - } + CraftingCubeBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer) { + this.ringCorner = ringCorner; + this.ringHor = ringHor; + this.ringVer = ringVer; + } - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { - if( side == null ) - { - return Collections.emptyList(); // No generic quads for this model - } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, + @Nonnull IModelData extraData) { + if (side == null) { + return Collections.emptyList(); // No generic quads for this model + } - EnumSet connections = getConnections( extraData ); + EnumSet connections = getConnections(extraData); - List quads = new ArrayList<>(); - CubeBuilder builder = new CubeBuilder( quads ); + List quads = new ArrayList<>(); + CubeBuilder builder = new CubeBuilder(quads); - builder.setDrawFaces( EnumSet.of( side ) ); + builder.setDrawFaces(EnumSet.of(side)); - // Add the quads for the ring that frames the entire multi-block structure - this.addRing( builder, side, connections ); + // Add the quads for the ring that frames the entire multi-block structure + this.addRing(builder, side, connections); - // Calculate the bounds of the "inner" block that is framed by the border drawn above - float x2 = connections.contains( Direction.EAST ) ? 16 : 13.01f; - float x1 = connections.contains( Direction.WEST ) ? 0 : 2.99f; + // Calculate the bounds of the "inner" block that is framed by the border drawn + // above + float x2 = connections.contains(Direction.EAST) ? 16 : 13.01f; + float x1 = connections.contains(Direction.WEST) ? 0 : 2.99f; - float y2 = connections.contains( Direction.UP ) ? 16 : 13.01f; - float y1 = connections.contains( Direction.DOWN ) ? 0 : 2.99f; + float y2 = connections.contains(Direction.UP) ? 16 : 13.01f; + float y1 = connections.contains(Direction.DOWN) ? 0 : 2.99f; - float z2 = connections.contains( Direction.SOUTH ) ? 16 : 13.01f; - float z1 = connections.contains( Direction.NORTH ) ? 0 : 2.99f; + float z2 = connections.contains(Direction.SOUTH) ? 16 : 13.01f; + float z1 = connections.contains(Direction.NORTH) ? 0 : 2.99f; - // On the axis of the side that we're currently drawing, extend the dimensions - // out to the outer face of the block - switch( side ) - { - case DOWN: - case UP: - y1 = 0; - y2 = 16; - break; - case NORTH: - case SOUTH: - z1 = 0; - z2 = 16; - break; - case WEST: - case EAST: - x1 = 0; - x2 = 16; - break; - } + // On the axis of the side that we're currently drawing, extend the dimensions + // out to the outer face of the block + switch (side) { + case DOWN: + case UP: + y1 = 0; + y2 = 16; + break; + case NORTH: + case SOUTH: + z1 = 0; + z2 = 16; + break; + case WEST: + case EAST: + x1 = 0; + x2 = 16; + break; + } - this.addInnerCube( side, state, extraData, builder, x1, y1, z1, x2, y2, z2 ); + this.addInnerCube(side, state, extraData, builder, x1, y1, z1, x2, y2, z2); - return quads; - } + return quads; + } - private void addRing( CubeBuilder builder, @Nullable Direction side, EnumSet connections ) - { - // Fill in the corners - builder.setTexture( this.ringCorner ); - this.addCornerCap( builder, connections, side, Direction.UP, Direction.EAST, Direction.NORTH ); - this.addCornerCap( builder, connections, side, Direction.UP, Direction.EAST, Direction.SOUTH ); - this.addCornerCap( builder, connections, side, Direction.UP, Direction.WEST, Direction.NORTH ); - this.addCornerCap( builder, connections, side, Direction.UP, Direction.WEST, Direction.SOUTH ); - this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.EAST, Direction.NORTH ); - this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.EAST, Direction.SOUTH ); - this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.WEST, Direction.NORTH ); - this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.WEST, Direction.SOUTH ); + private void addRing(CubeBuilder builder, @Nullable Direction side, EnumSet connections) { + // Fill in the corners + builder.setTexture(this.ringCorner); + this.addCornerCap(builder, connections, side, Direction.UP, Direction.EAST, Direction.NORTH); + this.addCornerCap(builder, connections, side, Direction.UP, Direction.EAST, Direction.SOUTH); + this.addCornerCap(builder, connections, side, Direction.UP, Direction.WEST, Direction.NORTH); + this.addCornerCap(builder, connections, side, Direction.UP, Direction.WEST, Direction.SOUTH); + this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.EAST, Direction.NORTH); + this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.EAST, Direction.SOUTH); + this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.WEST, Direction.NORTH); + this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.WEST, Direction.SOUTH); - // Fill in the remaining stripes of the face - for( Direction a : Direction.values() ) - { - if( a == side || a == side.getOpposite() ) - { - continue; - } + // Fill in the remaining stripes of the face + for (Direction a : Direction.values()) { + if (a == side || a == side.getOpposite()) { + continue; + } - // Select the horizontal or vertical ring texture depending on which side we're filling in - if( ( side.getAxis() != Direction.Axis.Y ) && ( a == Direction.NORTH || a == Direction.EAST || a == Direction.WEST || a == Direction.SOUTH ) ) - { - builder.setTexture( this.ringVer ); - } - else if( side.getAxis() == Direction.Axis.Y && ( a == Direction.EAST || a == Direction.WEST ) ) - { - builder.setTexture( this.ringVer ); - } - else - { - builder.setTexture( this.ringHor ); - } + // Select the horizontal or vertical ring texture depending on which side we're + // filling in + if ((side.getAxis() != Direction.Axis.Y) + && (a == Direction.NORTH || a == Direction.EAST || a == Direction.WEST || a == Direction.SOUTH)) { + builder.setTexture(this.ringVer); + } else if (side.getAxis() == Direction.Axis.Y && (a == Direction.EAST || a == Direction.WEST)) { + builder.setTexture(this.ringVer); + } else { + builder.setTexture(this.ringHor); + } - // If there's an adjacent crafting cube block on side a, then the core of the block already extends - // fully to this side. So only bother drawing the stripe, if there's no connection. - if( !connections.contains( a ) ) - { - // Note that since we're drawing something that "looks" 2-dimensional, - // two of the following will always be 0 and 16. - float x1 = 0, y1 = 0, z1 = 0, x2 = 16, y2 = 16, z2 = 16; + // If there's an adjacent crafting cube block on side a, then the core of the + // block already extends + // fully to this side. So only bother drawing the stripe, if there's no + // connection. + if (!connections.contains(a)) { + // Note that since we're drawing something that "looks" 2-dimensional, + // two of the following will always be 0 and 16. + float x1 = 0, y1 = 0, z1 = 0, x2 = 16, y2 = 16, z2 = 16; - switch( a ) - { - case DOWN: - y1 = 0; - y2 = 3; - break; - case UP: - y1 = 13.0f; - y2 = 16; - break; - case WEST: - x1 = 0; - x2 = 3; - break; - case EAST: - x1 = 13; - x2 = 16; - break; - case NORTH: - z1 = 0; - z2 = 3; - break; - case SOUTH: - z1 = 13; - z2 = 16; - break; - } + switch (a) { + case DOWN: + y1 = 0; + y2 = 3; + break; + case UP: + y1 = 13.0f; + y2 = 16; + break; + case WEST: + x1 = 0; + x2 = 3; + break; + case EAST: + x1 = 13; + x2 = 16; + break; + case NORTH: + z1 = 0; + z2 = 3; + break; + case SOUTH: + z1 = 13; + z2 = 16; + break; + } - // Constraint the stripe in the two directions perpendicular to a in case there has been a corner - // drawn in those directions. Since a corner is drawn if the three touching faces dont have adjacent - // crafting cube blocks, we'd have to check for a, side, and the perpendicular direction. But in this - // block, we've already checked for side (due to face culling) and a (see above). - Direction perpendicular = Platform.rotateAround( a, side ); - for( Direction cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) ) - { - if( !connections.contains( cornerCandidate ) ) - { - // There's a cap in this direction - switch( cornerCandidate ) - { - case DOWN: - y1 = 3; - break; - case UP: - y2 = 13; - break; - case NORTH: - z1 = 3; - break; - case SOUTH: - z2 = 13; - break; - case WEST: - x1 = 3; - break; - case EAST: - x2 = 13; - break; - } - } - } + // Constraint the stripe in the two directions perpendicular to a in case there + // has been a corner + // drawn in those directions. Since a corner is drawn if the three touching + // faces dont have adjacent + // crafting cube blocks, we'd have to check for a, side, and the perpendicular + // direction. But in this + // block, we've already checked for side (due to face culling) and a (see + // above). + Direction perpendicular = Platform.rotateAround(a, side); + for (Direction cornerCandidate : EnumSet.of(perpendicular, perpendicular.getOpposite())) { + if (!connections.contains(cornerCandidate)) { + // There's a cap in this direction + switch (cornerCandidate) { + case DOWN: + y1 = 3; + break; + case UP: + y2 = 13; + break; + case NORTH: + z1 = 3; + break; + case SOUTH: + z2 = 13; + break; + case WEST: + x1 = 3; + break; + case EAST: + x2 = 13; + break; + } + } + } - builder.addCube( x1, y1, z1, x2, y2, z2 ); - } - } - } + builder.addCube(x1, y1, z1, x2, y2, z2); + } + } + } - /** - * Adds a 3x3x3 corner cap to the cube builder if there are no adjacent crafting cubes on that corner. - */ - private void addCornerCap( CubeBuilder builder, EnumSet connections, Direction side, Direction down, Direction west, Direction north ) - { - if( connections.contains( down ) || connections.contains( west ) || connections.contains( north ) ) - { - return; - } + /** + * Adds a 3x3x3 corner cap to the cube builder if there are no adjacent crafting + * cubes on that corner. + */ + private void addCornerCap(CubeBuilder builder, EnumSet connections, Direction side, Direction down, + Direction west, Direction north) { + if (connections.contains(down) || connections.contains(west) || connections.contains(north)) { + return; + } - // Only add faces for sides that can actually be seen (the outside of the cube) - if( side != down && side != west && side != north ) - { - return; - } + // Only add faces for sides that can actually be seen (the outside of the cube) + if (side != down && side != west && side != north) { + return; + } - float x1 = ( west == Direction.WEST ? 0 : 13 ); - float y1 = ( down == Direction.DOWN ? 0 : 13 ); - float z1 = ( north == Direction.NORTH ? 0 : 13 ); - float x2 = ( west == Direction.WEST ? 3 : 16 ); - float y2 = ( down == Direction.DOWN ? 3 : 16 ); - float z2 = ( north == Direction.NORTH ? 3 : 16 ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); - } + float x1 = (west == Direction.WEST ? 0 : 13); + float y1 = (down == Direction.DOWN ? 0 : 13); + float z1 = (north == Direction.NORTH ? 0 : 13); + float x2 = (west == Direction.WEST ? 3 : 16); + float y2 = (down == Direction.DOWN ? 3 : 16); + float z2 = (north == Direction.NORTH ? 3 : 16); + builder.addCube(x1, y1, z1, x2, y2, z2); + } - // Retrieve the cube connection state from the block state - // If none is present, just assume there are no adjacent crafting cube blocks - private static EnumSet getConnections( IModelData modelData ) - { - if (!(modelData instanceof CraftingCubeModelData)) { - return EnumSet.noneOf(Direction.class); - } + // Retrieve the cube connection state from the block state + // If none is present, just assume there are no adjacent crafting cube blocks + private static EnumSet getConnections(IModelData modelData) { + if (!(modelData instanceof CraftingCubeModelData)) { + return EnumSet.noneOf(Direction.class); + } - return ((CraftingCubeModelData) modelData).getConnections(); - } + return ((CraftingCubeModelData) modelData).getConnections(); + } - protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2); + protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, + float x1, float y1, float z1, float x2, float y2, float z2); - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.ringCorner; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.ringCorner; + } - @Override - public boolean func_230044_c_() { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } } diff --git a/src/main/java/appeng/client/render/crafting/CraftingCubeModel.java b/src/main/java/appeng/client/render/crafting/CraftingCubeModel.java index f20de000c..6593da4d9 100644 --- a/src/main/java/appeng/client/render/crafting/CraftingCubeModel.java +++ b/src/main/java/appeng/client/render/crafting/CraftingCubeModel.java @@ -18,11 +18,13 @@ package appeng.client.render.crafting; +import java.util.Collection; +import java.util.Set; +import java.util.function.Function; -import appeng.block.crafting.AbstractCraftingUnitBlock; -import appeng.core.AppEng; import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -30,93 +32,91 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; - +import appeng.block.crafting.AbstractCraftingUnitBlock; +import appeng.core.AppEng; /** * The built-in model for the connected texture crafting cube. */ -class CraftingCubeModel implements IModelGeometry -{ +class CraftingCubeModel implements IModelGeometry { - private final static Material RING_CORNER = texture( "ring_corner" ); - private final static Material RING_SIDE_HOR = texture( "ring_side_hor" ); - private final static Material RING_SIDE_VER = texture( "ring_side_ver" ); - private final static Material UNIT_BASE = texture( "unit_base" ); - private final static Material LIGHT_BASE = texture( "light_base" ); - private final static Material ACCELERATOR_LIGHT = texture( "accelerator_light" ); - private final static Material STORAGE_1K_LIGHT = texture( "1k_storage_light" ); - private final static Material STORAGE_4K_LIGHT = texture( "4k_storage_light" ); - private final static Material STORAGE_16K_LIGHT = texture( "16k_storage_light" ); - private final static Material STORAGE_64K_LIGHT = texture( "64k_storage_light" ); - private final static Material MONITOR_BASE = texture( "monitor_base" ); - private final static Material MONITOR_LIGHT_DARK = texture( "monitor_light_dark" ); - private final static Material MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" ); - private final static Material MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" ); + private final static Material RING_CORNER = texture("ring_corner"); + private final static Material RING_SIDE_HOR = texture("ring_side_hor"); + private final static Material RING_SIDE_VER = texture("ring_side_ver"); + private final static Material UNIT_BASE = texture("unit_base"); + private final static Material LIGHT_BASE = texture("light_base"); + private final static Material ACCELERATOR_LIGHT = texture("accelerator_light"); + private final static Material STORAGE_1K_LIGHT = texture("1k_storage_light"); + private final static Material STORAGE_4K_LIGHT = texture("4k_storage_light"); + private final static Material STORAGE_16K_LIGHT = texture("16k_storage_light"); + private final static Material STORAGE_64K_LIGHT = texture("64k_storage_light"); + private final static Material MONITOR_BASE = texture("monitor_base"); + private final static Material MONITOR_LIGHT_DARK = texture("monitor_light_dark"); + private final static Material MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium"); + private final static Material MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright"); - private final AbstractCraftingUnitBlock.CraftingUnitType type; + private final AbstractCraftingUnitBlock.CraftingUnitType type; - CraftingCubeModel( AbstractCraftingUnitBlock.CraftingUnitType type ) - { - this.type = type; - } + CraftingCubeModel(AbstractCraftingUnitBlock.CraftingUnitType type) { + this.type = type; + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return ImmutableList.of( RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT, STORAGE_1K_LIGHT, STORAGE_4K_LIGHT, - STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE, MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return ImmutableList.of(RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT, + STORAGE_1K_LIGHT, STORAGE_4K_LIGHT, STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE, + MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT); + } - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - // Retrieve our textures and pass them on to the baked model - TextureAtlasSprite ringCorner = spriteGetter.apply( RING_CORNER ); - TextureAtlasSprite ringSideHor = spriteGetter.apply( RING_SIDE_HOR ); - TextureAtlasSprite ringSideVer = spriteGetter.apply( RING_SIDE_VER ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + // Retrieve our textures and pass them on to the baked model + TextureAtlasSprite ringCorner = spriteGetter.apply(RING_CORNER); + TextureAtlasSprite ringSideHor = spriteGetter.apply(RING_SIDE_HOR); + TextureAtlasSprite ringSideVer = spriteGetter.apply(RING_SIDE_VER); - switch( this.type ) - { - case UNIT: - return new UnitBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ) ); - case ACCELERATOR: - case STORAGE_1K: - case STORAGE_4K: - case STORAGE_16K: - case STORAGE_64K: - return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter - .apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) ); - case MONITOR: - return new MonitorBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ), spriteGetter - .apply( MONITOR_BASE ), spriteGetter.apply( - MONITOR_LIGHT_DARK ), spriteGetter.apply( MONITOR_LIGHT_MEDIUM ), spriteGetter.apply( MONITOR_LIGHT_BRIGHT ) ); - default: - throw new IllegalArgumentException( "Unsupported crafting unit type: " + this.type ); - } - } + switch (this.type) { + case UNIT: + return new UnitBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(UNIT_BASE)); + case ACCELERATOR: + case STORAGE_1K: + case STORAGE_4K: + case STORAGE_16K: + case STORAGE_64K: + return new LightBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(LIGHT_BASE), + getLightTexture(spriteGetter, this.type)); + case MONITOR: + return new MonitorBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(UNIT_BASE), + spriteGetter.apply(MONITOR_BASE), spriteGetter.apply(MONITOR_LIGHT_DARK), + spriteGetter.apply(MONITOR_LIGHT_MEDIUM), spriteGetter.apply(MONITOR_LIGHT_BRIGHT)); + default: + throw new IllegalArgumentException("Unsupported crafting unit type: " + this.type); + } + } - private static TextureAtlasSprite getLightTexture( Function textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type ) - { - switch( type ) - { - case ACCELERATOR: - return textureGetter.apply( ACCELERATOR_LIGHT ); - case STORAGE_1K: - return textureGetter.apply( STORAGE_1K_LIGHT ); - case STORAGE_4K: - return textureGetter.apply( STORAGE_4K_LIGHT ); - case STORAGE_16K: - return textureGetter.apply( STORAGE_16K_LIGHT ); - case STORAGE_64K: - return textureGetter.apply( STORAGE_64K_LIGHT ); - default: - throw new IllegalArgumentException( "Crafting unit type " + type + " does not use a light texture." ); - } - } + private static TextureAtlasSprite getLightTexture(Function textureGetter, + AbstractCraftingUnitBlock.CraftingUnitType type) { + switch (type) { + case ACCELERATOR: + return textureGetter.apply(ACCELERATOR_LIGHT); + case STORAGE_1K: + return textureGetter.apply(STORAGE_1K_LIGHT); + case STORAGE_4K: + return textureGetter.apply(STORAGE_4K_LIGHT); + case STORAGE_16K: + return textureGetter.apply(STORAGE_16K_LIGHT); + case STORAGE_64K: + return textureGetter.apply(STORAGE_64K_LIGHT); + default: + throw new IllegalArgumentException("Crafting unit type " + type + " does not use a light texture."); + } + } - private static Material texture( String name ) - { - return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name)); - } + private static Material texture(String name) { + return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name)); + } } diff --git a/src/main/java/appeng/client/render/crafting/CraftingCubeModelLoader.java b/src/main/java/appeng/client/render/crafting/CraftingCubeModelLoader.java index f9bd1d85f..52b430134 100644 --- a/src/main/java/appeng/client/render/crafting/CraftingCubeModelLoader.java +++ b/src/main/java/appeng/client/render/crafting/CraftingCubeModelLoader.java @@ -18,44 +18,44 @@ package appeng.client.render.crafting; - -import appeng.block.crafting.AbstractCraftingUnitBlock; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; + import net.minecraft.resources.IResourceManager; import net.minecraftforge.client.model.IModelLoader; +import appeng.block.crafting.AbstractCraftingUnitBlock; /** - * Loader that allows access to the built-in crafting cube model from block-model JSONs. + * Loader that allows access to the built-in crafting cube model from + * block-model JSONs. */ -public class CraftingCubeModelLoader implements IModelLoader -{ +public class CraftingCubeModelLoader implements IModelLoader { - public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader(); + public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader(); - @Override - public void onResourceManagerReload(IResourceManager resourceManager) { - } + @Override + public void onResourceManagerReload(IResourceManager resourceManager) { + } - @Override - public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { - AbstractCraftingUnitBlock.CraftingUnitType unitType = null; + @Override + public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { + AbstractCraftingUnitBlock.CraftingUnitType unitType = null; - JsonElement typeEl = modelContents.get("type"); - if (typeEl != null) { - String typeName = deserializationContext.deserialize(typeEl, String.class); - if (typeName != null) { - unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase()); - } - } - if (unitType == null) { - throw new JsonParseException("type property is missing"); - } + JsonElement typeEl = modelContents.get("type"); + if (typeEl != null) { + String typeName = deserializationContext.deserialize(typeEl, String.class); + if (typeName != null) { + unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase()); + } + } + if (unitType == null) { + throw new JsonParseException("type property is missing"); + } - return new CraftingCubeModel(unitType); - } + return new CraftingCubeModel(unitType); + } } diff --git a/src/main/java/appeng/client/render/crafting/CraftingCubeRendering.java b/src/main/java/appeng/client/render/crafting/CraftingCubeRendering.java index 59ff267ec..92e25128e 100644 --- a/src/main/java/appeng/client/render/crafting/CraftingCubeRendering.java +++ b/src/main/java/appeng/client/render/crafting/CraftingCubeRendering.java @@ -18,26 +18,23 @@ package appeng.client.render.crafting; - -import appeng.bootstrap.BlockRenderingCustomizer; -import appeng.bootstrap.IBlockRendering; -import appeng.bootstrap.IItemRendering; import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.bootstrap.BlockRenderingCustomizer; +import appeng.bootstrap.IBlockRendering; +import appeng.bootstrap.IItemRendering; /** * Rendering customization for the crafting cube. */ -public class CraftingCubeRendering extends BlockRenderingCustomizer -{ - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - // Disable auto-rotation - rendering.modelCustomizer( ( loc, model ) -> model ); - } +public class CraftingCubeRendering extends BlockRenderingCustomizer { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + // Disable auto-rotation + rendering.modelCustomizer((loc, model) -> model); + } } diff --git a/src/main/java/appeng/client/render/crafting/CraftingMonitorTESR.java b/src/main/java/appeng/client/render/crafting/CraftingMonitorTESR.java index b7561d58f..799874ab2 100644 --- a/src/main/java/appeng/client/render/crafting/CraftingMonitorTESR.java +++ b/src/main/java/appeng/client/render/crafting/CraftingMonitorTESR.java @@ -18,10 +18,8 @@ package appeng.client.render.crafting; - -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.core.Api; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -31,41 +29,42 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; - -import appeng.api.storage.data.IAEItemStack; -import appeng.client.render.TesrRenderHelper; -import appeng.tile.crafting.TileCraftingMonitorTile; import net.minecraftforge.registries.ForgeRegistries; +import appeng.api.storage.channels.IItemStorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.client.render.TesrRenderHelper; +import appeng.core.Api; +import appeng.tile.crafting.TileCraftingMonitorTile; /** * Renders the item currently being crafted */ -@OnlyIn( Dist.CLIENT ) -public class CraftingMonitorTESR extends TileEntityRenderer -{ +@OnlyIn(Dist.CLIENT) +public class CraftingMonitorTESR extends TileEntityRenderer { - public CraftingMonitorTESR(TileEntityRendererDispatcher rendererDispatcherIn) { - super(rendererDispatcherIn); - } + public CraftingMonitorTESR(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } - @Override - public void render(TileCraftingMonitorTile te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) { + @Override + public void render(TileCraftingMonitorTile te, float partialTicks, MatrixStack matrixStack, + IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) { - Direction facing = te.getForward(); + Direction facing = te.getForward(); - IAEItemStack jobProgress = te.getJobProgress(); + IAEItemStack jobProgress = te.getJobProgress(); - if( jobProgress != null ) - { - matrixStack.push(); - matrixStack.translate(0.5, 0.5, 0.5); // Move to the center of the block + if (jobProgress != null) { + matrixStack.push(); + matrixStack.translate(0.5, 0.5, 0.5); // Move to the center of the block - TesrRenderHelper.rotateToFace( matrixStack, facing, (byte) 0 ); - matrixStack.translate(0, 0.08, 0.5); - TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.3f, -0.18f, 15728880, combinedOverlay); + TesrRenderHelper.rotateToFace(matrixStack, facing, (byte) 0); + matrixStack.translate(0, 0.08, 0.5); + TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.3f, -0.18f, 15728880, + combinedOverlay); - matrixStack.pop(); - } - } + matrixStack.pop(); + } + } } diff --git a/src/main/java/appeng/client/render/crafting/EncodedPatternBakedModel.java b/src/main/java/appeng/client/render/crafting/EncodedPatternBakedModel.java index 9c04b636a..87caebfce 100644 --- a/src/main/java/appeng/client/render/crafting/EncodedPatternBakedModel.java +++ b/src/main/java/appeng/client/render/crafting/EncodedPatternBakedModel.java @@ -1,9 +1,14 @@ package appeng.client.render.crafting; -import appeng.client.render.DelegateBakedModel; -import appeng.items.misc.ItemEncodedPattern; +import java.util.List; +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; @@ -21,57 +26,51 @@ import net.minecraftforge.client.model.PerspectiveMapWrapper; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Random; +import appeng.client.render.DelegateBakedModel; +import appeng.items.misc.ItemEncodedPattern; /** - * This model is used to substitute the crafting result's item model for our encoded pattern model if these - * two conditions are met: - * - The player is holding shift - * - The itemstack is being rendered in the UI (not on the ground, etc.) + * This model is used to substitute the crafting result's item model for our + * encoded pattern model if these two conditions are met: - The player is + * holding shift - The itemstack is being rendered in the UI (not on the ground, + * etc.) * - * We do this by abusing a custom {@link ItemOverrideList} since it will be called each frame with the itemstack - * that is about to be rendered. We return a custom IBakedModel ({@link ShiftHoldingModelWrapper} if the player - * is holding down shift from the override list. - * This custom baked model implements {@link #doesHandlePerspectives()} and returns the crafting result model - * if the model for {@link ItemCameraTransforms.TransformType#GUI} is requested. + * We do this by abusing a custom {@link ItemOverrideList} since it will be + * called each frame with the itemstack that is about to be rendered. We return + * a custom IBakedModel ({@link ShiftHoldingModelWrapper} if the player is + * holding down shift from the override list. This custom baked model implements + * {@link #doesHandlePerspectives()} and returns the crafting result model if + * the model for {@link ItemCameraTransforms.TransformType#GUI} is requested. */ public class EncodedPatternBakedModel extends DelegateBakedModel { private final CustomOverrideList overrides; - EncodedPatternBakedModel(IBakedModel baseModel) - { + EncodedPatternBakedModel(IBakedModel baseModel) { super(baseModel); this.overrides = new CustomOverrideList(); } @Override - public ItemOverrideList getOverrides() - { + public ItemOverrideList getOverrides() { return this.overrides; } /** - * Since the ItemOverrideList handling comes before handling the perspective awareness (which is the first place - * where we - * know how we are being rendered) we need to remember the model of the crafting output, and make the decision on - * which to render later on. - * Sadly, Forge is pretty inconsistent when it will call the handlePerspective method, so some methods are called - * even on this interim-model. - * Usually those methods only matter for rendering on the ground and other cases, where we wouldn't render the - * crafting output model anyway, + * Since the ItemOverrideList handling comes before handling the perspective + * awareness (which is the first place where we know how we are being rendered) + * we need to remember the model of the crafting output, and make the decision + * on which to render later on. Sadly, Forge is pretty inconsistent when it will + * call the handlePerspective method, so some methods are called even on this + * interim-model. Usually those methods only matter for rendering on the ground + * and other cases, where we wouldn't render the crafting output model anyway, * so in those cases we delegate to the model of the encoded pattern. */ - private static class ShiftHoldingModelWrapper extends DelegateBakedModel - { + private static class ShiftHoldingModelWrapper extends DelegateBakedModel { private final IBakedModel outputModel; - private ShiftHoldingModelWrapper( IBakedModel patternModel, IBakedModel outputModel ) - { + private ShiftHoldingModelWrapper(IBakedModel patternModel, IBakedModel outputModel) { super(patternModel); this.outputModel = outputModel; } @@ -82,16 +81,14 @@ public class EncodedPatternBakedModel extends DelegateBakedModel { } @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { - // No need to re-check for shift being held since this model is only handed out in that case - if( cameraTransformType == ItemCameraTransforms.TransformType.GUI ) - { - ImmutableMap transforms = PerspectiveMapWrapper.getTransforms(outputModel.getItemCameraTransforms()); - return PerspectiveMapWrapper.handlePerspective( this.outputModel, transforms, cameraTransformType, mat ); - } - else - { + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { + // No need to re-check for shift being held since this model is only handed out + // in that case + if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) { + ImmutableMap transforms = PerspectiveMapWrapper + .getTransforms(outputModel.getItemCameraTransforms()); + return PerspectiveMapWrapper.handlePerspective(this.outputModel, transforms, cameraTransformType, mat); + } else { return getBaseModel().handlePerspective(cameraTransformType, mat); } } @@ -111,38 +108,36 @@ public class EncodedPatternBakedModel extends DelegateBakedModel { } @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { return getBaseModel().handlePerspective(cameraTransformType, mat); } /** - * Item Override Lists are the only point during item rendering where we can access the item stack that is being - * rendered. - * So this is the point where we actually check if shift is being held, and if so, determine the crafting output - * model. + * Item Override Lists are the only point during item rendering where we can + * access the item stack that is being rendered. So this is the point where we + * actually check if shift is being held, and if so, determine the crafting + * output model. */ - private class CustomOverrideList extends ItemOverrideList - { + private class CustomOverrideList extends ItemOverrideList { @Nullable @Override - public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity) { + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, + @Nullable LivingEntity entity) { boolean shiftHeld = Screen.hasShiftDown(); - if( shiftHeld ) - { + if (shiftHeld) { ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem(); - ItemStack output = iep.getOutput( stack ); - if( !output.isEmpty() ) - { - IBakedModel realModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel( output ); + ItemStack output = iep.getOutput(stack); + if (!output.isEmpty()) { + IBakedModel realModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher() + .getItemModel(output); // Give the item model a chance to handle the overrides as well - realModel = realModel.getOverrides().getModelWithOverrides( realModel, output, world, entity ); + realModel = realModel.getOverrides().getModelWithOverrides(realModel, output, world, entity); return new ShiftHoldingModelWrapper(getBaseModel(), realModel); } } - return getBaseModel().getOverrides().getModelWithOverrides( originalModel, stack, world, entity ); + return getBaseModel().getOverrides().getModelWithOverrides(originalModel, stack, world, entity); } } diff --git a/src/main/java/appeng/client/render/crafting/EncodedPatternModel.java b/src/main/java/appeng/client/render/crafting/EncodedPatternModel.java index a1d9962d2..5f046b061 100644 --- a/src/main/java/appeng/client/render/crafting/EncodedPatternModel.java +++ b/src/main/java/appeng/client/render/crafting/EncodedPatternModel.java @@ -1,16 +1,17 @@ package appeng.client.render.crafting; +import java.util.Collection; +import java.util.Set; +import java.util.function.Function; + import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; - /** * This model is used to provide the {@link EncodedPatternBakedModel}. */ @@ -23,14 +24,17 @@ public class EncodedPatternModel implements IModelGeometry } @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { return modelGetter.apply(baseModel).getTextures(modelGetter, missingTextureErrors); } @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { IBakedModel baseModel = bakery.getBakedModel(this.baseModel, modelTransform, spriteGetter); - return new EncodedPatternBakedModel( baseModel); + return new EncodedPatternBakedModel(baseModel); } } diff --git a/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java b/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java index 583c0fe8b..8ffa8cf54 100644 --- a/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java +++ b/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java @@ -2,13 +2,15 @@ package appeng.client.render.crafting; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.resources.IResourceManager; import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelLoader; /** - * Provides our custom {@link EncodedPatternBakedModel encoded pattern item model}. + * Provides our custom {@link EncodedPatternBakedModel encoded pattern item + * model}. */ public class EncodedPatternModelLoader implements IModelLoader { diff --git a/src/main/java/appeng/client/render/crafting/LightBakedModel.java b/src/main/java/appeng/client/render/crafting/LightBakedModel.java index 344073012..eca8b8811 100644 --- a/src/main/java/appeng/client/render/crafting/LightBakedModel.java +++ b/src/main/java/appeng/client/render/crafting/LightBakedModel.java @@ -18,44 +18,42 @@ package appeng.client.render.crafting; - import net.minecraft.block.BlockState; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.Direction; +import net.minecraftforge.client.model.data.IModelData; import appeng.block.crafting.AbstractCraftingUnitBlock; import appeng.client.render.cablebus.CubeBuilder; -import net.minecraftforge.client.model.data.IModelData; - /** - * Crafting cube baked model that adds a full-bright light texture on top of a normal base texture onto the inner cube. - * The light texture is only drawn fullbright if the multiblock is currently powered. + * Crafting cube baked model that adds a full-bright light texture on top of a + * normal base texture onto the inner cube. The light texture is only drawn + * fullbright if the multiblock is currently powered. */ -class LightBakedModel extends CraftingCubeBakedModel -{ +class LightBakedModel extends CraftingCubeBakedModel { - private final TextureAtlasSprite baseTexture; + private final TextureAtlasSprite baseTexture; - private final TextureAtlasSprite lightTexture; + private final TextureAtlasSprite lightTexture; - LightBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture ) - { - super( ringCorner, ringHor, ringVer ); - this.baseTexture = baseTexture; - this.lightTexture = lightTexture; - } + LightBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, + TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture) { + super(ringCorner, ringHor, ringVer); + this.baseTexture = baseTexture; + this.lightTexture = lightTexture; + } - @Override - protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2) - { - builder.setTexture( this.baseTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); + @Override + protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, + float y1, float z1, float x2, float y2, float z2) { + builder.setTexture(this.baseTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); - boolean powered = state.get( AbstractCraftingUnitBlock.POWERED ); - builder.setRenderFullBright( powered ); - builder.setTexture( this.lightTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); - } + boolean powered = state.get(AbstractCraftingUnitBlock.POWERED); + builder.setRenderFullBright(powered); + builder.setTexture(this.lightTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); + } } diff --git a/src/main/java/appeng/client/render/crafting/MonitorBakedModel.java b/src/main/java/appeng/client/render/crafting/MonitorBakedModel.java index fc02ce6ec..3e997ea8c 100644 --- a/src/main/java/appeng/client/render/crafting/MonitorBakedModel.java +++ b/src/main/java/appeng/client/render/crafting/MonitorBakedModel.java @@ -18,95 +18,93 @@ package appeng.client.render.crafting; +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.Direction; +import net.minecraftforge.client.model.data.IModelData; import appeng.api.util.AEColor; import appeng.block.crafting.BlockCraftingMonitor; import appeng.client.render.cablebus.CubeBuilder; import appeng.client.render.model.AEModelData; import appeng.tile.crafting.CraftingMonitorModelData; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.Direction; -import net.minecraftforge.client.model.data.IModelData; - /** - * The baked model for the crafting monitor. Please note that this model doesn't handle the item being displayed. That - * is handled by a TESR. - * Instead, this model adds 3 layered light textures using the [dark|medium|bright] color variants of the attached bus - * color. The textures - * are full-bright if the cube is powered. + * The baked model for the crafting monitor. Please note that this model doesn't + * handle the item being displayed. That is handled by a TESR. Instead, this + * model adds 3 layered light textures using the [dark|medium|bright] color + * variants of the attached bus color. The textures are full-bright if the cube + * is powered. */ -public class MonitorBakedModel extends CraftingCubeBakedModel -{ +public class MonitorBakedModel extends CraftingCubeBakedModel { - private final TextureAtlasSprite chassisTexture; + private final TextureAtlasSprite chassisTexture; - private final TextureAtlasSprite baseTexture; + private final TextureAtlasSprite baseTexture; - private final TextureAtlasSprite lightDarkTexture; + private final TextureAtlasSprite lightDarkTexture; - private final TextureAtlasSprite lightMediumTexture; + private final TextureAtlasSprite lightMediumTexture; - private final TextureAtlasSprite lightBrightTexture; + private final TextureAtlasSprite lightBrightTexture; - MonitorBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture ) - { - super( ringCorner, ringHor, ringVer ); - this.chassisTexture = chassisTexture; - this.baseTexture = baseTexture; - this.lightDarkTexture = lightDarkTexture; - this.lightMediumTexture = lightMediumTexture; - this.lightBrightTexture = lightBrightTexture; - } + MonitorBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, + TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, + TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture) { + super(ringCorner, ringHor, ringVer); + this.chassisTexture = chassisTexture; + this.baseTexture = baseTexture; + this.lightDarkTexture = lightDarkTexture; + this.lightMediumTexture = lightMediumTexture; + this.lightBrightTexture = lightBrightTexture; + } - @Override - protected void addInnerCube(Direction side, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2) - { - Direction forward = getForward( modelData ); + @Override + protected void addInnerCube(Direction side, BlockState state, IModelData modelData, CubeBuilder builder, float x1, + float y1, float z1, float x2, float y2, float z2) { + Direction forward = getForward(modelData); - // For sides other than the front, use the chassis texture - if( side != forward ) - { - builder.setTexture( this.chassisTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); - return; - } + // For sides other than the front, use the chassis texture + if (side != forward) { + builder.setTexture(this.chassisTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); + return; + } - builder.setTexture( this.baseTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); + builder.setTexture(this.baseTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); - // Now add the three layered light textures - AEColor color = getColor( modelData ); - boolean powered = state.get( BlockCraftingMonitor.POWERED ); + // Now add the three layered light textures + AEColor color = getColor(modelData); + boolean powered = state.get(BlockCraftingMonitor.POWERED); - builder.setRenderFullBright( powered ); + builder.setRenderFullBright(powered); - builder.setColorRGB( color.whiteVariant ); - builder.setTexture( this.lightBrightTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); + builder.setColorRGB(color.whiteVariant); + builder.setTexture(this.lightBrightTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); - builder.setColorRGB( color.mediumVariant ); - builder.setTexture( this.lightMediumTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); + builder.setColorRGB(color.mediumVariant); + builder.setTexture(this.lightMediumTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); - builder.setColorRGB( color.blackVariant ); - builder.setTexture( this.lightDarkTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); + builder.setColorRGB(color.blackVariant); + builder.setTexture(this.lightDarkTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); - } + } - private static AEColor getColor(IModelData modelData) { - if (modelData instanceof CraftingMonitorModelData) { - return ((CraftingMonitorModelData) modelData).getColor(); - } - return AEColor.TRANSPARENT; - } + private static AEColor getColor(IModelData modelData) { + if (modelData instanceof CraftingMonitorModelData) { + return ((CraftingMonitorModelData) modelData).getColor(); + } + return AEColor.TRANSPARENT; + } - private static Direction getForward(IModelData modelData) { - if (modelData instanceof AEModelData) { - return ((AEModelData) modelData).getForward(); - } - return Direction.NORTH; - } + private static Direction getForward(IModelData modelData) { + if (modelData instanceof AEModelData) { + return ((AEModelData) modelData).getForward(); + } + return Direction.NORTH; + } } diff --git a/src/main/java/appeng/client/render/crafting/UnitBakedModel.java b/src/main/java/appeng/client/render/crafting/UnitBakedModel.java index 7c2f51e9b..a3f9b83a5 100644 --- a/src/main/java/appeng/client/render/crafting/UnitBakedModel.java +++ b/src/main/java/appeng/client/render/crafting/UnitBakedModel.java @@ -18,33 +18,30 @@ package appeng.client.render.crafting; - import net.minecraft.block.BlockState; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; - -import appeng.client.render.cablebus.CubeBuilder; import net.minecraftforge.client.model.data.IModelData; +import appeng.client.render.cablebus.CubeBuilder; /** * A simple crafting unit model that uses an un-lit texture for the inner block. */ -class UnitBakedModel extends CraftingCubeBakedModel -{ +class UnitBakedModel extends CraftingCubeBakedModel { - private final TextureAtlasSprite unitTexture; + private final TextureAtlasSprite unitTexture; - UnitBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture ) - { - super( ringCorner, ringHor, ringVer ); - this.unitTexture = unitTexture; - } + UnitBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, + TextureAtlasSprite unitTexture) { + super(ringCorner, ringHor, ringVer); + this.unitTexture = unitTexture; + } - @Override - protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2) - { - builder.setTexture( this.unitTexture ); - builder.addCube( x1, y1, z1, x2, y2, z2 ); - } + @Override + protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, + float y1, float z1, float x2, float y2, float z2) { + builder.setTexture(this.unitTexture); + builder.addCube(x1, y1, z1, x2, y2, z2); + } } diff --git a/src/main/java/appeng/client/render/effects/AssemblerFX.java b/src/main/java/appeng/client/render/effects/AssemblerFX.java index 22d5d864a..58278a864 100644 --- a/src/main/java/appeng/client/render/effects/AssemblerFX.java +++ b/src/main/java/appeng/client/render/effects/AssemblerFX.java @@ -18,10 +18,12 @@ package appeng.client.render.effects; +import java.util.Locale; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; + import net.minecraft.client.particle.IAnimatedSprite; import net.minecraft.client.particle.IParticleFactory; import net.minecraft.client.particle.IParticleRenderType; @@ -39,200 +41,190 @@ import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleType; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.storage.data.IAEItemStack; import appeng.client.EffectType; import appeng.core.AppEng; import appeng.entity.EntityFloatingItem; import appeng.entity.ICanDie; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.Locale; +public class AssemblerFX extends Particle implements ICanDie { + public static final ParticleType TYPE = new ParticleType<>(false, + new AssemblerParticleData.Deserializer()); -public class AssemblerFX extends Particle implements ICanDie -{ + static { + TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx"); + } - public static final ParticleType TYPE = new ParticleType<>(false, new AssemblerParticleData.Deserializer()); + private final EntityFloatingItem fi; + private final float speed; + private float time = 0; - static { - TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx"); - } + public AssemblerFX(final World w, final double x, final double y, final double z, final double r, final double g, + final double b, final float speed, final ItemStack displayItem) { + super(w, x, y, z, r, g, b); + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.speed = speed; + this.fi = new EntityFloatingItem(this, w, x, y, z, displayItem); + w.addEntity(this.fi); + this.maxAge = (int) Math.ceil(Math.max(1, 100.0f / speed)) + 2; + } - private final EntityFloatingItem fi; - private final float speed; - private float time = 0; + @Override + public boolean isDead() { + return this.isExpired; + } - public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final ItemStack displayItem ) - { - super( w, x, y, z, r, g, b ); - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.speed = speed; - this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem ); - w.addEntity( this.fi ); - this.maxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2; - } + @Override + public int getBrightnessForRender(final float par1) { + final int j1 = 13; + return j1 << 20 | j1 << 4; + } - @Override - public boolean isDead() - { - return this.isExpired; - } + @Override + public void tick() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - @Override - public int getBrightnessForRender( final float par1 ) - { - final int j1 = 13; - return j1 << 20 | j1 << 4; - } + if (this.age++ >= this.maxAge) { + this.setExpired(); + } - @Override - public void tick() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.motionY -= 0.04D * this.particleGravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; - if( this.age++ >= this.maxAge ) - { - this.setExpired(); - } + if (this.isExpired) { + this.fi.remove(); + } else { + final float lifeSpan = (float) this.age / (float) this.maxAge; + this.fi.setProgress(lifeSpan); + } + } - this.motionY -= 0.04D * this.particleGravity; - this.move( this.motionX, this.motionY, this.motionZ ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; + @Override + public IParticleRenderType getRenderType() { + return IParticleRenderType.NO_RENDER; + } - if( this.isExpired ) - { - this.fi.remove(); - } - else - { - final float lifeSpan = (float) this.age / (float) this.maxAge; - this.fi.setProgress( lifeSpan ); - } - } + @Override + public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { + this.time += partialTicks; + if (this.time > 4.0) { + this.time -= 4.0; + // if ( AppEng.proxy.shouldAddParticles( r ) ) + for (int x = 0; x < (int) Math.ceil(this.speed / 5); x++) { + AppEng.proxy.spawnEffect(EffectType.Crafting, this.world, this.posX, this.posY, this.posZ, null); + } + } + } - @Override - public IParticleRenderType getRenderType() { - return IParticleRenderType.NO_RENDER; - } + public static class AssemblerParticleData implements IParticleData { - @Override - public void renderParticle( IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks ) - { - this.time += partialTicks; - if( this.time > 4.0 ) - { - this.time -= 4.0; - // if ( AppEng.proxy.shouldAddParticles( r ) ) - for( int x = 0; x < (int) Math.ceil( this.speed / 5 ); x++ ) - { - AppEng.proxy.spawnEffect( EffectType.Crafting, this.world, this.posX, this.posY, this.posZ, null ); - } - } - } + private final float r; + private final float g; + private final float b; + private final float speed; + private final ItemStack itemStack; - public static class AssemblerParticleData implements IParticleData { + public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) { + this.r = r; + this.g = g; + this.b = b; + this.speed = speed; + this.itemStack = itemStack; + } - private final float r; - private final float g; - private final float b; - private final float speed; - private final ItemStack itemStack; + @Override + public ParticleType getType() { + return TYPE; + } - public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) { - this.r = r; - this.g = g; - this.b = b; - this.speed = speed; - this.itemStack = itemStack; - } + @Override + public void write(PacketBuffer buffer) { + buffer.writeFloat(r); + buffer.writeFloat(g); + buffer.writeFloat(b); + buffer.writeFloat(speed); + buffer.writeItemStack(itemStack); + } - @Override - public ParticleType getType() { - return TYPE; - } + public static class Deserializer implements IDeserializer { - @Override - public void write(PacketBuffer buffer) { - buffer.writeFloat(r); - buffer.writeFloat(g); - buffer.writeFloat(b); - buffer.writeFloat(speed); - buffer.writeItemStack(itemStack); - } + @Override + public AssemblerParticleData deserialize(ParticleType particleTypeIn, + StringReader reader) throws CommandSyntaxException { + reader.expect(' '); + float r = reader.readFloat(); + reader.expect(' '); + float g = reader.readFloat(); + reader.expect(' '); + float b = reader.readFloat(); + reader.expect(' '); + float speed = reader.readFloat(); + reader.expect(' '); + ItemParser itemparser = (new ItemParser(reader, false)).parse(); + ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false); + return new AssemblerParticleData(r, g, b, speed, itemstack); + } - public static class Deserializer implements IDeserializer { + @Override + public AssemblerParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { + float r = buffer.readFloat(); + float g = buffer.readFloat(); + float b = buffer.readFloat(); + float speed = buffer.readFloat(); + ItemStack itemStack = buffer.readItemStack(); + return new AssemblerParticleData(r, g, b, speed, itemStack); + } - @Override - public AssemblerParticleData deserialize(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - float r = reader.readFloat(); - reader.expect(' '); - float g = reader.readFloat(); - reader.expect(' '); - float b = reader.readFloat(); - reader.expect(' '); - float speed = reader.readFloat(); - reader.expect(' '); - ItemParser itemparser = (new ItemParser(reader, false)).parse(); - ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false); - return new AssemblerParticleData(r, g, b, speed, itemstack); - } + } - @Override - public AssemblerParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { - float r = buffer.readFloat(); - float g = buffer.readFloat(); - float b = buffer.readFloat(); - float speed = buffer.readFloat(); - ItemStack itemStack = buffer.readItemStack(); - return new AssemblerParticleData(r, g, b, speed, itemStack); - } + @Override + public String getParameters() { + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), + this.r, this.g, this.b, this.speed) + + (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize(); + } - } + public float getR() { + return r; + } - @Override - public String getParameters() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), this.r, this.g, this.b, this.speed) - + (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize(); - } + public float getG() { + return g; + } - public float getR() { - return r; - } + public float getB() { + return b; + } - public float getG() { - return g; - } + public float getSpeed() { + return speed; + } - public float getB() { - return b; - } + public ItemStack getItemStack() { + return itemStack; + } + } - public float getSpeed() { - return speed; - } + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + public Factory(IAnimatedSprite spriteSet) { + } - public ItemStack getItemStack() { - return itemStack; - } - } - - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - public Factory(IAnimatedSprite spriteSet) { - } - - public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack); - } - } + public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack); + } + } } diff --git a/src/main/java/appeng/client/render/effects/ChargedOreFX.java b/src/main/java/appeng/client/render/effects/ChargedOreFX.java index 48d10f962..012399797 100644 --- a/src/main/java/appeng/client/render/effects/ChargedOreFX.java +++ b/src/main/java/appeng/client/render/effects/ChargedOreFX.java @@ -18,8 +18,6 @@ package appeng.client.render.effects; - -import appeng.core.AppEng; import net.minecraft.client.particle.IAnimatedSprite; import net.minecraft.client.particle.IParticleFactory; import net.minecraft.client.particle.Particle; @@ -30,44 +28,45 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.core.AppEng; + @OnlyIn(Dist.CLIENT) -public class ChargedOreFX extends RedstoneParticle -{ - public static final BasicParticleType TYPE = new BasicParticleType(false); +public class ChargedOreFX extends RedstoneParticle { + public static final BasicParticleType TYPE = new BasicParticleType(false); - static { - TYPE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx"); - } - - private static final RedstoneParticleData PARTICLE_DATA = new RedstoneParticleData(0.21f, 0.61f, 1.0f, 1.0f); - - private ChargedOreFX(World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, IAnimatedSprite spriteSet) { - super(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, PARTICLE_DATA, spriteSet); + static { + TYPE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx"); } - @Override - public int getBrightnessForRender( final float par1 ) - { - int j1 = super.getBrightnessForRender( par1 ); - j1 = Math.max( j1 >> 20, j1 >> 4 ); - j1 += 3; - if( j1 > 15 ) - { - j1 = 15; - } - return j1 << 20 | j1 << 4; - } + private static final RedstoneParticleData PARTICLE_DATA = new RedstoneParticleData(0.21f, 0.61f, 1.0f, 1.0f); - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + private ChargedOreFX(World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, + IAnimatedSprite spriteSet) { + super(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, PARTICLE_DATA, spriteSet); + } - public Factory(IAnimatedSprite p_i50477_1_) { - this.spriteSet = p_i50477_1_; - } + @Override + public int getBrightnessForRender(final float par1) { + int j1 = super.getBrightnessForRender(par1); + j1 = Math.max(j1 >> 20, j1 >> 4); + j1 += 3; + if (j1 > 15) { + j1 = 15; + } + return j1 << 20 | j1 << 4; + } - public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - return new ChargedOreFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); - } - } + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; + + public Factory(IAnimatedSprite p_i50477_1_) { + this.spriteSet = p_i50477_1_; + } + + public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new ChargedOreFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } } diff --git a/src/main/java/appeng/client/render/effects/CraftingFx.java b/src/main/java/appeng/client/render/effects/CraftingFx.java index 227ad3a73..c7e39f8a0 100644 --- a/src/main/java/appeng/client/render/effects/CraftingFx.java +++ b/src/main/java/appeng/client/render/effects/CraftingFx.java @@ -18,9 +18,8 @@ package appeng.client.render.effects; - -import appeng.core.AppEng; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.particle.*; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BufferBuilder; @@ -40,140 +39,142 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.util.AEPartLocation; +import appeng.core.AppEng; +@OnlyIn(Dist.CLIENT) +public class CraftingFx extends BreakingParticle { -@OnlyIn( Dist.CLIENT ) -public class CraftingFx extends BreakingParticle -{ + public static final BasicParticleType TYPE = new BasicParticleType(false); - public static final BasicParticleType TYPE = new BasicParticleType(false); + static { + TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx"); + } - static { - TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx"); - } + private final int startBlkX; + private final int startBlkY; + private final int startBlkZ; - private final int startBlkX; - private final int startBlkY; - private final int startBlkZ; + public CraftingFx(final World par1World, final double x, final double y, final double z, + final IAnimatedSprite sprite) { + super(par1World, x, y, z, new ItemStack(Items.DIAMOND)); + this.particleGravity = 0; + this.particleBlue = 1; + this.particleGreen = 0.9f; + this.particleRed = 1; + this.particleAlpha = 1.3f; + this.particleScale = 1.5f; + this.selectSpriteRandomly(sprite); + this.maxAge /= 1.2; - public CraftingFx( final World par1World, final double x, final double y, final double z, final IAnimatedSprite sprite ) - { - super( par1World, x, y, z, new ItemStack(Items.DIAMOND) ); - this.particleGravity = 0; - this.particleBlue = 1; - this.particleGreen = 0.9f; - this.particleRed = 1; - this.particleAlpha = 1.3f; - this.particleScale = 1.5f; - this.selectSpriteRandomly(sprite); - this.maxAge /= 1.2; + this.startBlkX = MathHelper.floor(this.posX); + this.startBlkY = MathHelper.floor(this.posY); + this.startBlkZ = MathHelper.floor(this.posZ); + } - this.startBlkX = MathHelper.floor( this.posX ); - this.startBlkY = MathHelper.floor( this.posY ); - this.startBlkZ = MathHelper.floor( this.posZ ); - } + @Override + public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { - @Override - public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { + if (partialTicks < 0 || partialTicks > 1) { + return; + } - if( partialTicks < 0 || partialTicks > 1 ) - { - return; - } + float offX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX)); + float offY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY)); + float offZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ)); - float offX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX)); - float offY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY)); - float offZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ)); + final int blkX = MathHelper.floor(offX); + final int blkY = MathHelper.floor(offY); + final int blkZ = MathHelper.floor(offZ); + // I believe this particle is same as breaking particle, but should not exit the + // original block it was + // spawned in (which is encased in glass) + if (blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ) { + Vec3d vec3d = renderInfo.getProjectedView(); + offX -= vec3d.x; + offY -= vec3d.y; + offZ -= vec3d.z; - final int blkX = MathHelper.floor( offX ); - final int blkY = MathHelper.floor( offY ); - final int blkZ = MathHelper.floor( offZ ); - // I believe this particle is same as breaking particle, but should not exit the original block it was - // spawned in (which is encased in glass) - if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ ) - { - Vec3d vec3d = renderInfo.getProjectedView(); - offX -= vec3d.x; - offY -= vec3d.y; - offZ -= vec3d.z; + Vector3f[] avector3f = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), + new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F) }; + float scale = this.getScale(partialTicks); - Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)}; - float scale = this.getScale(partialTicks); + for (int i = 0; i < 4; ++i) { + Vector3f vector3f = avector3f[i]; + vector3f.transform(renderInfo.getRotation()); + vector3f.mul(scale); + vector3f.add(offX, offY, offZ); + } - for(int i = 0; i < 4; ++i) { - Vector3f vector3f = avector3f[i]; - vector3f.transform(renderInfo.getRotation()); - vector3f.mul(scale); - vector3f.add(offX, offY, offZ); - } + float minU = this.getMinU(); + float maxU = this.getMaxU(); + float minV = this.getMinV(); + float maxV = this.getMaxV(); + int j = this.getBrightnessForRender(partialTicks); + buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV) + .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j) + .endVertex(); + buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV) + .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j) + .endVertex(); + buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV) + .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j) + .endVertex(); + buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV) + .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j) + .endVertex(); + } + } - float minU = this.getMinU(); - float maxU = this.getMaxU(); - float minV = this.getMinV(); - float maxV = this.getMaxV(); - int j = this.getBrightnessForRender(partialTicks); - buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex(); - buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex(); - buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex(); - buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex(); - } - } + public void fromItem(final AEPartLocation d) { + this.posX += 0.2 * d.xOffset; + this.posY += 0.2 * d.yOffset; + this.posZ += 0.2 * d.zOffset; + this.particleScale *= 0.8f; + } - public void fromItem( final AEPartLocation d ) - { - this.posX += 0.2 * d.xOffset; - this.posY += 0.2 * d.yOffset; - this.posZ += 0.2 * d.zOffset; - this.particleScale *= 0.8f; - } + @Override + public void tick() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - @Override - public void tick() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + if (this.age++ >= this.maxAge) { + this.setExpired(); + } - if( this.age++ >= this.maxAge ) - { - this.setExpired(); - } + this.motionY -= 0.04D * this.particleGravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + this.particleScale *= 0.51f; + this.particleAlpha *= 0.51f; + } - this.motionY -= 0.04D * this.particleGravity; - this.move( this.motionX, this.motionY, this.motionZ ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - this.particleScale *= 0.51f; - this.particleAlpha *= 0.51f; - } + public void setMotionX(float motionX) { + this.motionX = motionX; + } - public void setMotionX( float motionX ) - { - this.motionX = motionX; - } + public void setMotionY(float motionY) { + this.motionY = motionY; + } - public void setMotionY( float motionY ) - { - this.motionY = motionY; - } + public void setMotionZ(float motionZ) { + this.motionZ = motionZ; + } - public void setMotionZ( float motionZ ) - { - this.motionZ = motionZ; - } + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + public Factory(IAnimatedSprite p_i50477_1_) { + this.spriteSet = p_i50477_1_; + } - public Factory(IAnimatedSprite p_i50477_1_) { - this.spriteSet = p_i50477_1_; - } - - public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - return new CraftingFx(worldIn, x, y, z, spriteSet); - } - } + public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, + double ySpeed, double zSpeed) { + return new CraftingFx(worldIn, x, y, z, spriteSet); + } + } } diff --git a/src/main/java/appeng/client/render/effects/EnergyFx.java b/src/main/java/appeng/client/render/effects/EnergyFx.java index 5247f76f1..3f25cd374 100644 --- a/src/main/java/appeng/client/render/effects/EnergyFx.java +++ b/src/main/java/appeng/client/render/effects/EnergyFx.java @@ -18,8 +18,6 @@ package appeng.client.render.effects; - -import appeng.core.AppEng; import net.minecraft.client.particle.*; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -34,37 +32,36 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.util.AEPartLocation; +import appeng.core.AppEng; +@OnlyIn(Dist.CLIENT) +public class EnergyFx extends BreakingParticle { -@OnlyIn( Dist.CLIENT ) -public class EnergyFx extends BreakingParticle -{ + public static final BasicParticleType TYPE = new BasicParticleType(false); - public static final BasicParticleType TYPE = new BasicParticleType(false); + static { + TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx"); + } - static { - TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx"); - } + private final int startBlkX; + private final int startBlkY; + private final int startBlkZ; - private final int startBlkX; - private final int startBlkY; - private final int startBlkZ; + public EnergyFx(final World par1World, final double par2, final double par4, final double par6, + final IAnimatedSprite sprite) { + super(par1World, par2, par4, par6, new ItemStack(Items.DIAMOND)); + this.particleGravity = 0; + this.particleBlue = 1; + this.particleGreen = 1; + this.particleRed = 1; + this.particleAlpha = 1.4f; + this.particleScale = 3.5f; + this.selectSpriteRandomly(sprite); - public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final IAnimatedSprite sprite ) - { - super( par1World, par2, par4, par6, new ItemStack(Items.DIAMOND) ); - this.particleGravity = 0; - this.particleBlue = 1; - this.particleGreen = 1; - this.particleRed = 1; - this.particleAlpha = 1.4f; - this.particleScale = 3.5f; - this.selectSpriteRandomly(sprite); - - this.startBlkX = MathHelper.floor( this.posX ); - this.startBlkY = MathHelper.floor( this.posY ); - this.startBlkZ = MathHelper.floor( this.posZ ); - } + this.startBlkX = MathHelper.floor(this.posX); + this.startBlkY = MathHelper.floor(this.posY); + this.startBlkZ = MathHelper.floor(this.posZ); + } // FIXME @Override // FIXME public int getFXLayer() @@ -125,13 +122,13 @@ public class EnergyFx extends BreakingParticle // FIXME } // FIXME } // FIXME - public void fromItem( final AEPartLocation d ) - { - this.posX += 0.2 * d.xOffset; - this.posY += 0.2 * d.yOffset; - this.posZ += 0.2 * d.zOffset; - this.particleScale *= 0.8f; - } + public void fromItem(final AEPartLocation d) { + this.posX += 0.2 * d.xOffset; + this.posY += 0.2 * d.yOffset; + this.posZ += 0.2 * d.zOffset; + this.particleScale *= 0.8f; + } + // FIXME // FIXME @Override // FIXME public void tick() @@ -155,36 +152,34 @@ public class EnergyFx extends BreakingParticle // FIXME this.particleAlpha *= 0.89f; // FIXME } // FIXME - public void setMotionX( float motionX ) - { - this.motionX = motionX; - } + public void setMotionX(float motionX) { + this.motionX = motionX; + } - public void setMotionY( float motionY ) - { - this.motionY = motionY; - } + public void setMotionY(float motionY) { + this.motionY = motionY; + } - public void setMotionZ( float motionZ ) - { - this.motionZ = motionZ; - } + public void setMotionZ(float motionZ) { + this.motionZ = motionZ; + } - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - public Factory(IAnimatedSprite spriteSet) { - this.spriteSet = spriteSet; - } + public Factory(IAnimatedSprite spriteSet) { + this.spriteSet = spriteSet; + } - public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet); - result.setMotionX((float) xSpeed); - result.setMotionY((float) ySpeed); - result.setMotionZ((float) zSpeed); - return result; - } - } + public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet); + result.setMotionX((float) xSpeed); + result.setMotionY((float) ySpeed); + result.setMotionZ((float) zSpeed); + return result; + } + } } diff --git a/src/main/java/appeng/client/render/effects/LightningArcFX.java b/src/main/java/appeng/client/render/effects/LightningArcFX.java index 603746974..43d580d99 100644 --- a/src/main/java/appeng/client/render/effects/LightningArcFX.java +++ b/src/main/java/appeng/client/render/effects/LightningArcFX.java @@ -18,10 +18,8 @@ package appeng.client.render.effects; - import java.util.Random; -import appeng.core.AppEng; import net.minecraft.client.particle.*; import net.minecraft.particles.BasicParticleType; import net.minecraft.particles.ParticleType; @@ -29,64 +27,66 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.core.AppEng; -public class LightningArcFX extends LightningFX -{ - public static final ParticleType TYPE = new ParticleType<>(false, LightningArcParticleData.DESERIALIZER); +public class LightningArcFX extends LightningFX { + public static final ParticleType TYPE = new ParticleType<>(false, + LightningArcParticleData.DESERIALIZER); - static { - TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx"); - } + static { + TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx"); + } - private static final Random RANDOM_GENERATOR = new Random(); + private static final Random RANDOM_GENERATOR = new Random(); - private final double rx; - private final double ry; - private final double rz; + private final double rx; + private final double ry; + private final double rz; - public LightningArcFX( final World w, final double x, final double y, final double z, final double ex, final double ey, final double ez, final double r, final double g, final double b ) - { - super( w, x, y, z, r, g, b, 6 ); + public LightningArcFX(final World w, final double x, final double y, final double z, final double ex, + final double ey, final double ez, final double r, final double g, final double b) { + super(w, x, y, z, r, g, b, 6); - this.rx = ex - x; - this.ry = ey - y; - this.rz = ez - z; + this.rx = ex - x; + this.ry = ey - y; + this.rz = ez - z; - this.regen(); - } + this.regen(); + } - @Override - protected void regen() - { - final double i = 1.0 / ( this.getSteps() - 1 ); - final double lastDirectionX = this.rx * i; - final double lastDirectionY = this.ry * i; - final double lastDirectionZ = this.rz * i; + @Override + protected void regen() { + final double i = 1.0 / (this.getSteps() - 1); + final double lastDirectionX = this.rx * i; + final double lastDirectionY = this.ry * i; + final double lastDirectionZ = this.rz * i; - final double len = Math.sqrt( lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ ); - for( int s = 0; s < this.getSteps(); s++ ) - { - final double[][] localSteps = this.getPrecomputedSteps(); + final double len = Math.sqrt( + lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ); + for (int s = 0; s < this.getSteps(); s++) { + final double[][] localSteps = this.getPrecomputedSteps(); - localSteps[s][0] = ( lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0; - localSteps[s][1] = ( lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0; - localSteps[s][2] = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0; - } - } + localSteps[s][0] = (lastDirectionX + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0; + localSteps[s][1] = (lastDirectionY + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0; + localSteps[s][2] = (lastDirectionZ + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0; + } + } - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - public Factory(IAnimatedSprite spriteSet) { - this.spriteSet = spriteSet; - } + public Factory(IAnimatedSprite spriteSet) { + this.spriteSet = spriteSet; + } - public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - SpriteTexturedParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y, data.target.z, 0, 0, 0); - lightningFX.selectSpriteRandomly(this.spriteSet); - return lightningFX; - } - } + public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + SpriteTexturedParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y, + data.target.z, 0, 0, 0); + lightningFX.selectSpriteRandomly(this.spriteSet); + return lightningFX; + } + } } diff --git a/src/main/java/appeng/client/render/effects/LightningArcParticleData.java b/src/main/java/appeng/client/render/effects/LightningArcParticleData.java index f9868995b..83981bd45 100644 --- a/src/main/java/appeng/client/render/effects/LightningArcParticleData.java +++ b/src/main/java/appeng/client/render/effects/LightningArcParticleData.java @@ -1,16 +1,18 @@ package appeng.client.render.effects; +import java.util.Locale; + import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; + import net.minecraft.network.PacketBuffer; import net.minecraft.particles.IParticleData; import net.minecraft.particles.ParticleType; import net.minecraft.util.math.Vec3d; -import java.util.Locale; - /** - * Contains the target point of the lightning arc (the source point is infered from the particle starting position). + * Contains the target point of the lightning arc (the source point is infered + * from the particle starting position). */ public class LightningArcParticleData implements IParticleData { @@ -22,7 +24,8 @@ public class LightningArcParticleData implements IParticleData { public static final IDeserializer DESERIALIZER = new IDeserializer() { @Override - public LightningArcParticleData deserialize(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { + public LightningArcParticleData deserialize(ParticleType particleTypeIn, + StringReader reader) throws CommandSyntaxException { reader.expect(' '); float x = reader.readFloat(); reader.expect(' '); @@ -33,7 +36,8 @@ public class LightningArcParticleData implements IParticleData { } @Override - public LightningArcParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { + public LightningArcParticleData read(ParticleType particleTypeIn, + PacketBuffer buffer) { float x = buffer.readFloat(); float y = buffer.readFloat(); float z = buffer.readFloat(); diff --git a/src/main/java/appeng/client/render/effects/LightningFX.java b/src/main/java/appeng/client/render/effects/LightningFX.java index 307454c88..4d5723ca0 100644 --- a/src/main/java/appeng/client/render/effects/LightningFX.java +++ b/src/main/java/appeng/client/render/effects/LightningFX.java @@ -18,11 +18,10 @@ package appeng.client.render.effects; - import java.util.Random; -import appeng.core.AppEng; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.particle.*; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -38,251 +37,234 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -@OnlyIn( Dist.CLIENT ) -public class LightningFX extends SpriteTexturedParticle -{ - public static final BasicParticleType TYPE = new BasicParticleType(false); +import appeng.core.AppEng; - static { - TYPE.setRegistryName(AppEng.MOD_ID, "lightning_fx"); - } +@OnlyIn(Dist.CLIENT) +public class LightningFX extends SpriteTexturedParticle { + public static final BasicParticleType TYPE = new BasicParticleType(false); - private static final Random RANDOM_GENERATOR = new Random(); - private static final int STEPS = 5; - private static final int BRIGHTNESS = 13 << 4; + static { + TYPE.setRegistryName(AppEng.MOD_ID, "lightning_fx"); + } - private final double[][] precomputedSteps; - private final double[] vertices = new double[3]; - private final double[] verticesWithUV = new double[3]; - private boolean hasData = false; + private static final Random RANDOM_GENERATOR = new Random(); + private static final int STEPS = 5; + private static final int BRIGHTNESS = 13 << 4; - private LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b ) - { - this( w, x, y, z, r, g, b, 6 ); - this.regen(); - } + private final double[][] precomputedSteps; + private final double[] vertices = new double[3]; + private final double[] verticesWithUV = new double[3]; + private boolean hasData = false; - protected LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge ) - { - super( w, x, y, z, r, g, b ); - this.precomputedSteps = new double[LightningFX.STEPS][3]; - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.maxAge = maxAge; - } + private LightningFX(final World w, final double x, final double y, final double z, final double r, final double g, + final double b) { + this(w, x, y, z, r, g, b, 6); + this.regen(); + } - protected void regen() - { - double lastDirectionX = ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9; - double lastDirectionY = ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9; - double lastDirectionZ = ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9; - for( int s = 0; s < LightningFX.STEPS; s++ ) - { - this.precomputedSteps[s][0] = lastDirectionX = ( lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0; - this.precomputedSteps[s][1] = lastDirectionY = ( lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0; - this.precomputedSteps[s][2] = lastDirectionZ = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0; - } - } + protected LightningFX(final World w, final double x, final double y, final double z, final double r, final double g, + final double b, final int maxAge) { + super(w, x, y, z, r, g, b); + this.precomputedSteps = new double[LightningFX.STEPS][3]; + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.maxAge = maxAge; + } - protected int getSteps() - { - return LightningFX.STEPS; - } + protected void regen() { + double lastDirectionX = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9; + double lastDirectionY = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9; + double lastDirectionZ = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9; + for (int s = 0; s < LightningFX.STEPS; s++) { + this.precomputedSteps[s][0] = lastDirectionX = (lastDirectionX + + (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0; + this.precomputedSteps[s][1] = lastDirectionY = (lastDirectionY + + (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0; + this.precomputedSteps[s][2] = lastDirectionZ = (lastDirectionZ + + (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0; + } + } - @Override - public IParticleRenderType getRenderType() { - // TODO: FIXME - return IParticleRenderType.PARTICLE_SHEET_OPAQUE; - } + protected int getSteps() { + return LightningFX.STEPS; + } - @Override - public void tick() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + @Override + public IParticleRenderType getRenderType() { + // TODO: FIXME + return IParticleRenderType.PARTICLE_SHEET_OPAQUE; + } - if( this.age++ >= this.maxAge ) - { - this.setExpired(); - } + @Override + public void tick() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - this.motionY -= 0.04D * this.particleGravity; - this.move( this.motionX, this.motionY, this.motionZ ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - } + if (this.age++ >= this.maxAge) { + this.setExpired(); + } - @Override - public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { - Vec3d vec3d = renderInfo.getProjectedView(); - float centerX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX()); - float centerY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY()); - float centerZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ()); + this.motionY -= 0.04D * this.particleGravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + } - final float j = 1.0f; - float red = this.particleRed * j * 0.9f; - float green = this.particleGreen * j * 0.95f; - float blue = this.particleBlue * j; - final float alpha = this.particleAlpha; + @Override + public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { + Vec3d vec3d = renderInfo.getProjectedView(); + float centerX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX()); + float centerY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY()); + float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ()); - if( this.age == 3 ) - { - this.regen(); - } + final float j = 1.0f; + float red = this.particleRed * j * 0.9f; + float green = this.particleGreen * j * 0.95f; + float blue = this.particleBlue * j; + final float alpha = this.particleAlpha; - float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2; - float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2; + if (this.age == 3) { + this.regen(); + } - double scale = 0.02;// 0.02F * this.particleScale; + float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2; + float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2; - final double[] a = new double[3]; - final double[] b = new double[3]; + double scale = 0.02;// 0.02F * this.particleScale; - double ox = 0; - double oy = 0; - double oz = 0; + final double[] a = new double[3]; + final double[] b = new double[3]; - final PlayerEntity p = Minecraft.getInstance().player; + double ox = 0; + double oy = 0; + double oz = 0; - // FIXME: Billboard rotation is not applied to the particle yet, - // FIXME The old version apparently did this by hand using rX,rZ -> replicate using the quaternion + final PlayerEntity p = Minecraft.getInstance().player; - for( int layer = 0; layer < 2; layer++ ) - { - if( layer == 0 ) - { - scale = 0.04; + // FIXME: Billboard rotation is not applied to the particle yet, + // FIXME The old version apparently did this by hand using rX,rZ -> replicate + // using the quaternion + + for (int layer = 0; layer < 2; layer++) { + if (layer == 0) { + scale = 0.04; // FIXME offX *= 0.001; // FIXME offY *= 0.001; // FIXME offZ *= 0.001; - red = this.particleRed * j * 0.4f; - green = this.particleGreen * j * 0.25f; - blue = this.particleBlue * j * 0.45f; - } - else - { + red = this.particleRed * j * 0.4f; + green = this.particleGreen * j * 0.25f; + blue = this.particleBlue * j * 0.45f; + } else { // FIXME offX = 0; // FIXME offY = 0; // FIXME offZ = 0; - scale = 0.02; - red = this.particleRed * j * 0.9f; - green = this.particleGreen * j * 0.65f; - blue = this.particleBlue * j * 0.85f; - } + scale = 0.02; + red = this.particleRed * j * 0.9f; + green = this.particleGreen * j * 0.65f; + blue = this.particleBlue * j * 0.85f; + } - for( int cycle = 0; cycle < 3; cycle++ ) - { - this.clear(); + for (int cycle = 0; cycle < 3; cycle++) { + this.clear(); - // FIXME removed interpPos here, check if this is correct - double x = centerX; // FIXME - offX; - double y = centerY; // FIXME - offY; - double z = centerZ; // FIXME - offZ; + // FIXME removed interpPos here, check if this is correct + double x = centerX; // FIXME - offX; + double y = centerY; // FIXME - offY; + double z = centerZ; // FIXME - offZ; - for( int s = 0; s < LightningFX.STEPS; s++ ) - { - final double xN = x + this.precomputedSteps[s][0]; - final double yN = y + this.precomputedSteps[s][1]; - final double zN = z + this.precomputedSteps[s][2]; + for (int s = 0; s < LightningFX.STEPS; s++) { + final double xN = x + this.precomputedSteps[s][0]; + final double yN = y + this.precomputedSteps[s][1]; + final double zN = z + this.precomputedSteps[s][2]; - final double xD = xN - x; - final double yD = yN - y; - final double zD = zN - z; + final double xD = xN - x; + final double yD = yN - y; + final double zD = zN - z; - if( cycle == 0 ) - { - ox = ( yD * 0 ) - ( 1 * zD ); - oy = ( zD * 0 ) - ( 0 * xD ); - oz = ( xD * 1 ) - ( 0 * yD ); - } - if( cycle == 1 ) - { - ox = ( yD * 1 ) - ( 0 * zD ); - oy = ( zD * 0 ) - ( 1 * xD ); - oz = ( xD * 0 ) - ( 0 * yD ); - } - if( cycle == 2 ) - { - ox = ( yD * 0 ) - ( 0 * zD ); - oy = ( zD * 1 ) - ( 0 * xD ); - oz = ( xD * 0 ) - ( 1 * yD ); - } + if (cycle == 0) { + ox = (yD * 0) - (1 * zD); + oy = (zD * 0) - (0 * xD); + oz = (xD * 1) - (0 * yD); + } + if (cycle == 1) { + ox = (yD * 1) - (0 * zD); + oy = (zD * 0) - (1 * xD); + oz = (xD * 0) - (0 * yD); + } + if (cycle == 2) { + ox = (yD * 0) - (0 * zD); + oy = (zD * 1) - (0 * xD); + oz = (xD * 0) - (1 * yD); + } - final double ss = Math - .sqrt( ox * ox + oy * oy + oz * oz ) / ( ( ( (double) LightningFX.STEPS - (double) s ) / LightningFX.STEPS ) * scale ); - ox /= ss; - oy /= ss; - oz /= ss; + final double ss = Math.sqrt(ox * ox + oy * oy + oz * oz) + / ((((double) LightningFX.STEPS - (double) s) / LightningFX.STEPS) * scale); + ox /= ss; + oy /= ss; + oz /= ss; - a[0] = x + ox; - a[1] = y + oy; - a[2] = z + oz; + a[0] = x + ox; + a[1] = y + oy; + a[2] = z + oz; - b[0] = x; - b[1] = y; - b[2] = z; + b[0] = x; + b[1] = y; + b[2] = z; - this.draw( red, green, blue, buffer, a, b, u, v ); + this.draw(red, green, blue, buffer, a, b, u, v); - x = xN; - y = yN; - z = zN; - } - } - } - } + x = xN; + y = yN; + z = zN; + } + } + } + } - private void clear() - { - this.hasData = false; - } + private void clear() { + this.hasData = false; + } - private void draw( float red, float green, float blue, final IVertexBuilder tess, final double[] a, final double[] b, final float u, final float v ) - { - if( this.hasData ) - { - tess.pos( a[0], a[1], a[2] ).tex( u, v ).color( red, green, blue, this.particleAlpha ).lightmap( BRIGHTNESS, BRIGHTNESS ).endVertex(); - tess.pos( this.vertices[0], this.vertices[1], this.vertices[2] ) - .tex( u, v ) - .color( red, green, blue, this.particleAlpha ) - .lightmap( BRIGHTNESS, BRIGHTNESS ) - .endVertex(); - tess.pos( this.verticesWithUV[0], this.verticesWithUV[1], this.verticesWithUV[2] ) - .tex( u, v ) - .color( red, green, blue, this.particleAlpha ) - .lightmap( BRIGHTNESS, BRIGHTNESS ) - .endVertex(); - tess.pos( b[0], b[1], b[2] ).tex( u, v ).color( red, green, blue, this.particleAlpha ).lightmap( BRIGHTNESS, BRIGHTNESS ).endVertex(); - } - this.hasData = true; - for( int x = 0; x < 3; x++ ) - { - this.vertices[x] = a[x]; - this.verticesWithUV[x] = b[x]; - } - } + private void draw(float red, float green, float blue, final IVertexBuilder tess, final double[] a, final double[] b, + final float u, final float v) { + if (this.hasData) { + tess.pos(a[0], a[1], a[2]).tex(u, v).color(red, green, blue, this.particleAlpha) + .lightmap(BRIGHTNESS, BRIGHTNESS).endVertex(); + tess.pos(this.vertices[0], this.vertices[1], this.vertices[2]).tex(u, v) + .color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex(); + tess.pos(this.verticesWithUV[0], this.verticesWithUV[1], this.verticesWithUV[2]).tex(u, v) + .color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex(); + tess.pos(b[0], b[1], b[2]).tex(u, v).color(red, green, blue, this.particleAlpha) + .lightmap(BRIGHTNESS, BRIGHTNESS).endVertex(); + } + this.hasData = true; + for (int x = 0; x < 3; x++) { + this.vertices[x] = a[x]; + this.verticesWithUV[x] = b[x]; + } + } - protected double[][] getPrecomputedSteps() - { - return this.precomputedSteps; - } + protected double[][] getPrecomputedSteps() { + return this.precomputedSteps; + } - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - public Factory(IAnimatedSprite spriteSet) { - this.spriteSet = spriteSet; - } + public Factory(IAnimatedSprite spriteSet) { + this.spriteSet = spriteSet; + } - public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - LightningFX lightningFX = new LightningFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed); - lightningFX.selectSpriteRandomly(this.spriteSet); - return lightningFX; - } - } + public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + LightningFX lightningFX = new LightningFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed); + lightningFX.selectSpriteRandomly(this.spriteSet); + return lightningFX; + } + } } diff --git a/src/main/java/appeng/client/render/effects/MatterCannonFX.java b/src/main/java/appeng/client/render/effects/MatterCannonFX.java index 92005da3e..694fdfeb3 100644 --- a/src/main/java/appeng/client/render/effects/MatterCannonFX.java +++ b/src/main/java/appeng/client/render/effects/MatterCannonFX.java @@ -18,9 +18,8 @@ package appeng.client.render.effects; - -import appeng.core.AppEng; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.particle.BreakingParticle; import net.minecraft.client.particle.IAnimatedSprite; import net.minecraft.client.particle.IParticleFactory; @@ -32,74 +31,71 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.particles.BasicParticleType; import net.minecraft.world.World; - -import appeng.api.util.AEPartLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.api.util.AEPartLocation; +import appeng.core.AppEng; -public class MatterCannonFX extends BreakingParticle -{ +public class MatterCannonFX extends BreakingParticle { - public static final BasicParticleType TYPE = new BasicParticleType(false); + public static final BasicParticleType TYPE = new BasicParticleType(false); - static { - TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx"); - } + static { + TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx"); + } - public MatterCannonFX( final World par1World, final double x, final double y, final double z, IAnimatedSprite sprite ) - { - super( par1World, x, y, z, new ItemStack(Items.DIAMOND) ); - this.particleGravity = 0; - this.particleBlue = 1; - this.particleGreen = 1; - this.particleRed = 1; - this.particleAlpha = 1.4f; - this.particleScale = 1.1f; - this.motionX = 0.0f; - this.motionY = 0.0f; - this.motionZ = 0.0f; - this.selectSpriteRandomly(sprite); - } + public MatterCannonFX(final World par1World, final double x, final double y, final double z, + IAnimatedSprite sprite) { + super(par1World, x, y, z, new ItemStack(Items.DIAMOND)); + this.particleGravity = 0; + this.particleBlue = 1; + this.particleGreen = 1; + this.particleRed = 1; + this.particleAlpha = 1.4f; + this.particleScale = 1.1f; + this.motionX = 0.0f; + this.motionY = 0.0f; + this.motionZ = 0.0f; + this.selectSpriteRandomly(sprite); + } - public void fromItem( final AEPartLocation d ) - { - this.particleScale *= 1.2f; - } + public void fromItem(final AEPartLocation d) { + this.particleScale *= 1.2f; + } - @Override - public void tick() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + @Override + public void tick() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if( this.age++ >= this.maxAge ) - { - this.setExpired(); - } + if (this.age++ >= this.maxAge) { + this.setExpired(); + } - this.motionY -= 0.04D * this.particleGravity; - this.move( this.motionX, this.motionY, this.motionZ ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; + this.motionY -= 0.04D * this.particleGravity; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; - this.particleScale *= 1.19f; - this.particleAlpha *= 0.59f; - } + this.particleScale *= 1.19f; + this.particleAlpha *= 0.59f; + } - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - public Factory(IAnimatedSprite spriteSet) { - this.spriteSet = spriteSet; - } + public Factory(IAnimatedSprite spriteSet) { + this.spriteSet = spriteSet; + } - public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - return new MatterCannonFX(world, x, y, z, spriteSet); - } - } + public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed, + double ySpeed, double zSpeed) { + return new MatterCannonFX(world, x, y, z, spriteSet); + } + } } diff --git a/src/main/java/appeng/client/render/effects/VibrantFX.java b/src/main/java/appeng/client/render/effects/VibrantFX.java index 1d5ce8882..34a745bee 100644 --- a/src/main/java/appeng/client/render/effects/VibrantFX.java +++ b/src/main/java/appeng/client/render/effects/VibrantFX.java @@ -18,87 +18,83 @@ package appeng.client.render.effects; - -import appeng.core.AppEng; import net.minecraft.client.particle.*; import net.minecraft.particles.BasicParticleType; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.core.AppEng; -@OnlyIn( Dist.CLIENT ) -public class VibrantFX extends SpriteTexturedParticle -{ +@OnlyIn(Dist.CLIENT) +public class VibrantFX extends SpriteTexturedParticle { - public static final BasicParticleType TYPE = new BasicParticleType(false); + public static final BasicParticleType TYPE = new BasicParticleType(false); - static { - TYPE.setRegistryName(AppEng.MOD_ID, "vibrant_fx"); - } + static { + TYPE.setRegistryName(AppEng.MOD_ID, "vibrant_fx"); + } - public VibrantFX( final World par1World, final double x, final double y, final double z, final double par8, final double par10, final double par12, IAnimatedSprite sprite) - { - super( par1World, x, y, z, par8, par10, par12 ); - final float f = this.rand.nextFloat() * 0.1F + 0.8F; - this.particleRed = f * 0.7f; - this.particleGreen = f * 0.89f; - this.particleBlue = f * 0.9f; - this.selectSpriteRandomly(sprite); - this.setSize( 0.04F, 0.04F ); - this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.maxAge = (int) ( 20.0D / ( Math.random() * 0.8D + 0.1D ) ); - } + public VibrantFX(final World par1World, final double x, final double y, final double z, final double par8, + final double par10, final double par12, IAnimatedSprite sprite) { + super(par1World, x, y, z, par8, par10, par12); + final float f = this.rand.nextFloat() * 0.1F + 0.8F; + this.particleRed = f * 0.7f; + this.particleGreen = f * 0.89f; + this.particleBlue = f * 0.9f; + this.selectSpriteRandomly(sprite); + this.setSize(0.04F, 0.04F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D)); + } - @Override - public IParticleRenderType getRenderType() { - // FIXME Might be PARTICLE_SHEET_LIT - return IParticleRenderType.PARTICLE_SHEET_OPAQUE; - } + @Override + public IParticleRenderType getRenderType() { + // FIXME Might be PARTICLE_SHEET_LIT + return IParticleRenderType.PARTICLE_SHEET_OPAQUE; + } - @Override - public int getBrightnessForRender( final float par1 ) - { - // This just means full brightness - return 15 << 20 | 15 << 4; - } + @Override + public int getBrightnessForRender(final float par1) { + // This just means full brightness + return 15 << 20 | 15 << 4; + } - /** - * Called to update the entity's position/logic. - */ - @Override - public void tick() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - // this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.particleScale *= 0.95; + /** + * Called to update the entity's position/logic. + */ + @Override + public void tick() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + // this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.particleScale *= 0.95; - if( this.maxAge <= 0 || this.particleScale < 0.1 ) - { - this.setExpired(); - } - this.maxAge--; - } + if (this.maxAge <= 0 || this.particleScale < 0.1) { + this.setExpired(); + } + this.maxAge--; + } - @OnlyIn(Dist.CLIENT) - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + @OnlyIn(Dist.CLIENT) + public static class Factory implements IParticleFactory { + private final IAnimatedSprite spriteSet; - public Factory(IAnimatedSprite spriteSet) { - this.spriteSet = spriteSet; - } + public Factory(IAnimatedSprite spriteSet) { + this.spriteSet = spriteSet; + } - public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - return new VibrantFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet); - } - } + public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new VibrantFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet); + } + } } diff --git a/src/main/java/appeng/client/render/model/AEInternalModelData.java b/src/main/java/appeng/client/render/model/AEInternalModelData.java index ab2f38ef9..055c860e0 100644 --- a/src/main/java/appeng/client/render/model/AEInternalModelData.java +++ b/src/main/java/appeng/client/render/model/AEInternalModelData.java @@ -1,10 +1,10 @@ package appeng.client.render.model; +import javax.annotation.Nullable; + import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nullable; - public abstract class AEInternalModelData implements IModelData { @Override diff --git a/src/main/java/appeng/client/render/model/AEModelData.java b/src/main/java/appeng/client/render/model/AEModelData.java index d400e96b5..39fb29a58 100644 --- a/src/main/java/appeng/client/render/model/AEModelData.java +++ b/src/main/java/appeng/client/render/model/AEModelData.java @@ -1,16 +1,19 @@ package appeng.client.render.model; +import java.util.Objects; + +import javax.annotation.Nullable; + import com.google.common.base.Preconditions; + import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nullable; -import java.util.Objects; - /** - * This implementation of IModelData allows us to know precisely which data is part of the - * model data. This is relevant for {@link AutoRotatingBakedModel} and {@link AutoRotatingCacheKey}. + * This implementation of IModelData allows us to know precisely which data is + * part of the model data. This is relevant for {@link AutoRotatingBakedModel} + * and {@link AutoRotatingCacheKey}. */ public class AEModelData implements IModelData { @@ -36,11 +39,12 @@ public class AEModelData implements IModelData { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AEModelData that = (AEModelData) o; - return up == that.up && - forward == that.forward; + return up == that.up && forward == that.forward; } @Override diff --git a/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java b/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java index bdc1d9d50..d56034458 100644 --- a/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java +++ b/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java @@ -18,13 +18,19 @@ package appeng.client.render.model; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.client.render.FacingToRotation; import com.google.common.base.Objects; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; + import net.minecraft.block.BlockState; import net.minecraft.client.renderer.Vector4f; import net.minecraft.client.renderer.model.BakedQuad; @@ -44,298 +50,249 @@ import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.client.model.pipeline.IVertexConsumer; import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import appeng.client.render.FacingToRotation; +public class AutoRotatingBakedModel implements IBakedModel { -public class AutoRotatingBakedModel implements IBakedModel -{ + private final IBakedModel parent; + private final LoadingCache> quadCache; - private final IBakedModel parent; - private final LoadingCache> quadCache; + public AutoRotatingBakedModel(IBakedModel parent) { + this.parent = parent; + // 6 (DUNSWE) * 6 (DUNSWE) * 7 (DUNSWE + null) = 252 + this.quadCache = CacheBuilder.newBuilder().maximumSize(252) + .build(new CacheLoader>() { + @Override + public List load(AutoRotatingCacheKey key) { + return AutoRotatingBakedModel.this.getRotatedModel(key.getBlockState(), key.getSide(), + new Random(0), key.getModelData()); + } + }); + } - public AutoRotatingBakedModel(IBakedModel parent ) - { - this.parent = parent; - // 6 (DUNSWE) * 6 (DUNSWE) * 7 (DUNSWE + null) = 252 - this.quadCache = CacheBuilder.newBuilder().maximumSize( 252 ).build( new CacheLoader>() - { - @Override - public List load( AutoRotatingCacheKey key ) - { - return AutoRotatingBakedModel.this.getRotatedModel( key.getBlockState(), key.getSide(), new Random(0), key.getModelData() ); - } - } ); - } + private List getRotatedModel(BlockState state, Direction side, Random rand, AEModelData modelData) { + FacingToRotation f2r = FacingToRotation.get(modelData.getForward(), modelData.getUp()); - private List getRotatedModel(BlockState state, Direction side, Random rand, AEModelData modelData) - { - FacingToRotation f2r = FacingToRotation.get( modelData.getForward(), modelData.getUp() ); + if (f2r.isRedundant()) { + return AutoRotatingBakedModel.this.parent.getQuads(state, side, rand, modelData); + } - if (f2r.isRedundant()) { - return AutoRotatingBakedModel.this.parent.getQuads( state, side, rand, modelData ); - } + List original = AutoRotatingBakedModel.this.parent.getQuads(state, f2r.resultingRotate(side), rand, + modelData); + List rotated = new ArrayList<>(original.size()); + for (BakedQuad quad : original) { + BakedQuadBuilder builder = new BakedQuadBuilder(); + VertexRotator rot = new VertexRotator(f2r, quad.getFace()); + rot.setParent(builder); + quad.pipe(rot); + if (quad.getFace() != null) { + builder.setQuadOrientation(f2r.rotate(quad.getFace())); + } else { + builder.setQuadOrientation(null); - List original = AutoRotatingBakedModel.this.parent.getQuads( state, f2r.resultingRotate( side ), rand, modelData ); - List rotated = new ArrayList<>( original.size() ); - for( BakedQuad quad : original ) - { - BakedQuadBuilder builder = new BakedQuadBuilder(); - VertexRotator rot = new VertexRotator( f2r, quad.getFace() ); - rot.setParent( builder ); - quad.pipe( rot ); - if( quad.getFace() != null ) - { - builder.setQuadOrientation( f2r.rotate( quad.getFace() ) ); - } - else - { - builder.setQuadOrientation( null ); + } + BakedQuad unpackedQuad = builder.build(); - } - BakedQuad unpackedQuad = builder.build(); + // Make a copy of it to resolve the vertex data and throw away the unpacked + // stuff + // This also fixes a bug in Forge's UnpackedBakedQuad, which unpacks a + // byte-based normal like 0,0,-1 + // to 0,0,-0.99607843. We replace these normals with the proper 0,0,-1 when + // rotation, which + // causes a bug in the AO lighter, if an unpacked quad pipes this value back to + // it. + // Packing it back to the vanilla vertex format will fix this inconsistency + // because it converts + // the normal back to a byte-based format, which then re-applies Forge's own bug + // when piping it + // to the AO lighter, thus fixing our problem. + BakedQuad packedQuad = new BakedQuad(unpackedQuad.getVertexData(), quad.getTintIndex(), + unpackedQuad.getFace(), quad.func_187508_a(), quad.shouldApplyDiffuseLighting()); + rotated.add(packedQuad); + } + return rotated; + } - // Make a copy of it to resolve the vertex data and throw away the unpacked stuff - // This also fixes a bug in Forge's UnpackedBakedQuad, which unpacks a byte-based normal like 0,0,-1 - // to 0,0,-0.99607843. We replace these normals with the proper 0,0,-1 when rotation, which - // causes a bug in the AO lighter, if an unpacked quad pipes this value back to it. - // Packing it back to the vanilla vertex format will fix this inconsistency because it converts - // the normal back to a byte-based format, which then re-applies Forge's own bug when piping it - // to the AO lighter, thus fixing our problem. - BakedQuad packedQuad = new BakedQuad( unpackedQuad.getVertexData(), quad.getTintIndex(), unpackedQuad.getFace(), quad.func_187508_a(), quad - .shouldApplyDiffuseLighting() ); - rotated.add( packedQuad ); - } - return rotated; - } + @Override + public boolean isAmbientOcclusion() { + return this.parent.isAmbientOcclusion(); + } - @Override - public boolean isAmbientOcclusion() - { - return this.parent.isAmbientOcclusion(); - } + @Override + public boolean isGui3d() { + return this.parent.isGui3d(); + } - @Override - public boolean isGui3d() - { - return this.parent.isGui3d(); - } + @Override + public boolean func_230044_c_() { + return parent.func_230044_c_(); + } - @Override - public boolean func_230044_c_() { - return parent.func_230044_c_(); - } + @Override + public boolean isBuiltInRenderer() { + return this.parent.isBuiltInRenderer(); + } - @Override - public boolean isBuiltInRenderer() - { - return this.parent.isBuiltInRenderer(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.parent.getParticleTexture(); + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.parent.getParticleTexture(); - } + @Override + @Deprecated + public ItemCameraTransforms getItemCameraTransforms() { + return parent.getItemCameraTransforms(); + } - @Override - @Deprecated - public ItemCameraTransforms getItemCameraTransforms() { - return parent.getItemCameraTransforms(); - } + @Override + public ItemOverrideList getOverrides() { + return parent.getOverrides(); + } - @Override - public ItemOverrideList getOverrides() { - return parent.getOverrides(); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + return getQuads(state, side, rand, EmptyModelData.INSTANCE); + } - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - return getQuads(state, side, rand, EmptyModelData.INSTANCE); - } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, + @Nonnull IModelData extraData) { - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + if (!(extraData instanceof AEModelData)) { + return this.parent.getQuads(state, side, rand, extraData); + } - if (!(extraData instanceof AEModelData)) { - return this.parent.getQuads( state, side, rand, extraData ); - } + AEModelData aeModelData = (AEModelData) extraData; + quadCache.invalidateAll(); // FIXME + if (aeModelData.isCacheable()) { + return quadCache.getUnchecked(new AutoRotatingCacheKey(state, aeModelData, side)); + } else { + return this.getRotatedModel(state, side, rand, aeModelData); + } + } - AEModelData aeModelData = (AEModelData) extraData; - quadCache.invalidateAll(); // FIXME - if (aeModelData.isCacheable()) { - return quadCache.getUnchecked(new AutoRotatingCacheKey(state, aeModelData, side)); - } else { - return this.getRotatedModel(state, side, rand, aeModelData); - } - } + @Nonnull + @Override + public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, + @Nonnull IModelData tileData) { + return this.parent.getModelData(world, pos, state, tileData); + } - @Nonnull - @Override - public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { - return this.parent.getModelData(world, pos, state, tileData); - } + public static class VertexRotator extends QuadGatheringTransformer { + private final FacingToRotation f2r; + private final Direction face; - public static class VertexRotator extends QuadGatheringTransformer - { - private final FacingToRotation f2r; - private final Direction face; + public VertexRotator(FacingToRotation f2r, Direction face) { + this.f2r = f2r; + this.face = face; + } - public VertexRotator( FacingToRotation f2r, Direction face ) - { - this.f2r = f2r; - this.face = face; - } + @Override + public void setParent(IVertexConsumer parent) { + super.setParent(parent); + if (Objects.equal(this.getVertexFormat(), parent.getVertexFormat())) { + return; + } + this.setVertexFormat(parent.getVertexFormat()); + } - @Override - public void setParent( IVertexConsumer parent ) - { - super.setParent( parent ); - if( Objects.equal( this.getVertexFormat(), parent.getVertexFormat() ) ) - { - return; - } - this.setVertexFormat( parent.getVertexFormat() ); - } + @Override + protected void processQuad() { + VertexFormat format = this.parent.getVertexFormat(); + ImmutableList elements = format.getElements(); - @Override - protected void processQuad() - { - VertexFormat format = this.parent.getVertexFormat(); - ImmutableList elements = format.getElements(); + for (int v = 0; v < 4; v++) { + for (int e = 0; e < elements.size(); e++) { + VertexFormatElement element = elements.get(e); + if (element.getUsage() == VertexFormatElement.Usage.POSITION) { + this.parent.put(e, this.transform(this.quadData[e][v])); + } else if (element.getUsage() == VertexFormatElement.Usage.NORMAL) { + this.parent.put(e, this.transformNormal(this.quadData[e][v])); + } else { + this.parent.put(e, this.quadData[e][v]); + } + } + } + } - for( int v = 0; v < 4; v++ ) - { - for( int e = 0; e < elements.size(); e++ ) - { - VertexFormatElement element = elements.get( e ); - if( element.getUsage() == VertexFormatElement.Usage.POSITION ) - { - this.parent.put( e, this.transform( this.quadData[e][v] ) ); - } - else if( element.getUsage() == VertexFormatElement.Usage.NORMAL ) - { - this.parent.put( e, this.transformNormal( this.quadData[e][v] ) ); - } - else - { - this.parent.put( e, this.quadData[e][v] ); - } - } - } - } + private float[] transform(float[] fs) { + switch (fs.length) { + case 3: + Vector4f vec = new Vector4f(fs[0], fs[1], fs[2], 1); + vec.setX(vec.getX() - 0.5f); + vec.setY(vec.getY() - 0.5f); + vec.setZ(vec.getZ() - 0.5f); + vec.transform(this.f2r.getMat()); + vec.setX(vec.getX() + 0.5f); + vec.setY(vec.getY() + 0.5f); + vec.setZ(vec.getZ() + 0.5f); + return new float[] { vec.getX(), vec.getY(), vec.getZ() }; + case 4: + Vector4f vecc = new Vector4f(fs[0], fs[1], fs[2], fs[3]); + vecc.setX(vecc.getX() - 0.5f); + vecc.setY(vecc.getY() - 0.5f); + vecc.setZ(vecc.getZ() - 0.5f); + vecc.transform(this.f2r.getMat()); + vecc.setX(vecc.getX() + 0.5f); + vecc.setY(vecc.getY() + 0.5f); + vecc.setZ(vecc.getZ() + 0.5f); + return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), vecc.getW() }; - private float[] transform( float[] fs ) - { - switch( fs.length ) - { - case 3: - Vector4f vec = new Vector4f( fs[0], fs[1], fs[2], 1 ); - vec.setX(vec.getX() - 0.5f); - vec.setY(vec.getY() - 0.5f); - vec.setZ(vec.getZ() - 0.5f); - vec.transform(this.f2r.getMat()); - vec.setX(vec.getX() + 0.5f); - vec.setY(vec.getY() + 0.5f); - vec.setZ(vec.getZ() + 0.5f); - return new float[] { vec.getX(), vec.getY(), vec.getZ() }; - case 4: - Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] ); - vecc.setX(vecc.getX() - 0.5f); - vecc.setY(vecc.getY() - 0.5f); - vecc.setZ(vecc.getZ() - 0.5f); - vecc.transform(this.f2r.getMat()); - vecc.setX(vecc.getX() + 0.5f); - vecc.setY(vecc.getY() + 0.5f); - vecc.setZ(vecc.getZ() + 0.5f); - return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), vecc.getW() }; + default: + return fs; + } + } - default: - return fs; - } - } + private float[] transformNormal(float[] fs) { + if (this.face == null) { + switch (fs.length) { + case 3: + Vector4f vec = new Vector4f(fs[0], fs[1], fs[2], 0); + vec.transform(this.f2r.getMat()); + return new float[] { vec.getX(), vec.getY(), vec.getZ() }; + case 4: + Vector4f vec4 = new Vector4f(fs[0], fs[1], fs[2], fs[3]); + vec4.transform(this.f2r.getMat()); + return new float[] { vec4.getX(), vec4.getY(), vec4.getZ(), 0 }; - private float[] transformNormal( float[] fs ) - { - if( this.face == null ) - { - switch( fs.length ) - { - case 3: - Vector4f vec = new Vector4f( fs[0], fs[1], fs[2], 0 ); - vec.transform( this.f2r.getMat() ); - return new float[] { - vec.getX(), - vec.getY(), - vec.getZ() - }; - case 4: - Vector4f vec4 = new Vector4f( fs[0], fs[1], fs[2], fs[3] ); - vec4.transform( this.f2r.getMat() ); - return new float[] { - vec4.getX(), - vec4.getY(), - vec4.getZ(), - 0 - }; + default: + return fs; + } + } else { + switch (fs.length) { + case 3: + Vec3i vec = this.f2r.rotate(this.face).getDirectionVec(); + return new float[] { vec.getX(), vec.getY(), vec.getZ() }; + case 4: + Vector4f veccc = new Vector4f(fs[0], fs[1], fs[2], fs[3]); + Vec3i vecc = this.f2r.rotate(this.face).getDirectionVec(); + return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), veccc.getW() }; - default: - return fs; - } - } - else - { - switch( fs.length ) - { - case 3: - Vec3i vec = this.f2r.rotate( this.face ).getDirectionVec(); - return new float[] { - vec.getX(), - vec.getY(), - vec.getZ() - }; - case 4: - Vector4f veccc = new Vector4f( fs[0], fs[1], fs[2], fs[3] ); - Vec3i vecc = this.f2r.rotate( this.face ).getDirectionVec(); - return new float[] { - vecc.getX(), - vecc.getY(), - vecc.getZ(), - veccc.getW() - }; + default: + return fs; + } + } + } - default: - return fs; - } - } - } + @Override + public void setQuadTint(int tint) { + this.parent.setQuadTint(tint); + } - @Override - public void setQuadTint( int tint ) - { - this.parent.setQuadTint( tint ); - } + @Override + public void setQuadOrientation(Direction orientation) { + this.parent.setQuadOrientation(f2r.rotate(orientation)); + } - @Override - public void setQuadOrientation( Direction orientation ) - { - this.parent.setQuadOrientation( f2r.rotate(orientation) ); - } + @Override + public void setApplyDiffuseLighting(boolean diffuse) { + this.parent.setApplyDiffuseLighting(diffuse); + } - @Override - public void setApplyDiffuseLighting( boolean diffuse ) - { - this.parent.setApplyDiffuseLighting( diffuse ); - } - - @Override - public void setTexture( TextureAtlasSprite texture ) - { - this.parent.setTexture( texture ); - } - } + @Override + public void setTexture(TextureAtlasSprite texture) { + this.parent.setTexture(texture); + } + } } diff --git a/src/main/java/appeng/client/render/model/AutoRotatingCacheKey.java b/src/main/java/appeng/client/render/model/AutoRotatingCacheKey.java index aa7207535..9f2cb0009 100644 --- a/src/main/java/appeng/client/render/model/AutoRotatingCacheKey.java +++ b/src/main/java/appeng/client/render/model/AutoRotatingCacheKey.java @@ -18,63 +18,54 @@ package appeng.client.render.model; - import net.minecraft.block.BlockState; import net.minecraft.util.Direction; - /** * Used as the cache key for caching automatically rotated baked models. */ -final class AutoRotatingCacheKey -{ - private final BlockState blockState; - private final AEModelData modelData; - private final Direction side; +final class AutoRotatingCacheKey { + private final BlockState blockState; + private final AEModelData modelData; + private final Direction side; - AutoRotatingCacheKey( BlockState blockState, AEModelData modelData, Direction side ) - { - this.blockState = blockState; - this.modelData = modelData; - this.side = side; - } + AutoRotatingCacheKey(BlockState blockState, AEModelData modelData, Direction side) { + this.blockState = blockState; + this.modelData = modelData; + this.side = side; + } - public BlockState getBlockState() - { - return this.blockState; - } + public BlockState getBlockState() { + return this.blockState; + } - public AEModelData getModelData() { - return modelData; - } + public AEModelData getModelData() { + return modelData; + } - public Direction getSide() - { - return this.side; - } + public Direction getSide() { + return this.side; + } - @Override - public boolean equals( Object o ) - { - if( this == o ) - { - return true; - } - if( o == null || this.getClass() != o.getClass() ) - { - return false; - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || this.getClass() != o.getClass()) { + return false; + } - AutoRotatingCacheKey cacheKey = (AutoRotatingCacheKey) o; - return this.blockState.equals( cacheKey.blockState ) && this.modelData.equals(cacheKey.modelData) && this.side == cacheKey.side; - } + AutoRotatingCacheKey cacheKey = (AutoRotatingCacheKey) o; + return this.blockState.equals(cacheKey.blockState) && this.modelData.equals(cacheKey.modelData) + && this.side == cacheKey.side; + } - @Override - public int hashCode() - { - int result = this.blockState.hashCode(); - result = 31 * result + this.modelData.hashCode(); - result = 31 * result + ( this.side != null ? this.side.hashCode() : 0 ); - return result; - } + @Override + public int hashCode() { + int result = this.blockState.hashCode(); + result = 31 * result + this.modelData.hashCode(); + result = 31 * result + (this.side != null ? this.side.hashCode() : 0); + return result; + } } diff --git a/src/main/java/appeng/client/render/model/BiometricCardBakedModel.java b/src/main/java/appeng/client/render/model/BiometricCardBakedModel.java index 8d581ea18..ac850b876 100644 --- a/src/main/java/appeng/client/render/model/BiometricCardBakedModel.java +++ b/src/main/java/appeng/client/render/model/BiometricCardBakedModel.java @@ -1,10 +1,10 @@ package appeng.client.render.model; - import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ExecutionException; + import javax.annotation.Nullable; import com.google.common.cache.Cache; @@ -30,191 +30,160 @@ import appeng.api.util.AEColor; import appeng.client.render.cablebus.CubeBuilder; import appeng.core.AELog; +class BiometricCardBakedModel implements IBakedModel { -class BiometricCardBakedModel implements IBakedModel -{ + private final IBakedModel baseModel; - private final IBakedModel baseModel; + private final TextureAtlasSprite texture; - private final TextureAtlasSprite texture; + private final int hash; - private final int hash; + private final Cache modelCache; - private final Cache modelCache; + private final ImmutableList generalQuads; - private final ImmutableList generalQuads; + BiometricCardBakedModel(IBakedModel baseModel, TextureAtlasSprite texture) { + this(baseModel, texture, 0, createCache()); + } - BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture ) - { - this( baseModel, texture, 0, createCache() ); - } + private BiometricCardBakedModel(IBakedModel baseModel, TextureAtlasSprite texture, int hash, + Cache modelCache) { + this.baseModel = baseModel; + this.texture = texture; + this.hash = hash; + this.generalQuads = ImmutableList.copyOf(this.buildGeneralQuads()); + this.modelCache = modelCache; + } - private BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, int hash, Cache modelCache ) - { - this.baseModel = baseModel; - this.texture = texture; - this.hash = hash; - this.generalQuads = ImmutableList.copyOf( this.buildGeneralQuads() ); - this.modelCache = modelCache; - } + private static Cache createCache() { + return CacheBuilder.newBuilder().maximumSize(100).build(); + } - private static Cache createCache() - { - return CacheBuilder.newBuilder().maximumSize( 100 ).build(); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { + List quads = this.baseModel.getQuads(state, side, rand, EmptyModelData.INSTANCE); - List quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE ); + if (side != null) { + return quads; + } - if( side != null ) - { - return quads; - } + List result = new ArrayList<>(quads.size() + this.generalQuads.size()); + result.addAll(quads); + result.addAll(this.generalQuads); + return result; + } - List result = new ArrayList<>( quads.size() + this.generalQuads.size() ); - result.addAll( quads ); - result.addAll( this.generalQuads ); - return result; - } + private List buildGeneralQuads() { + CubeBuilder builder = new CubeBuilder(); - private List buildGeneralQuads() - { - CubeBuilder builder = new CubeBuilder(); + builder.setTexture(this.texture); - builder.setTexture( this.texture ); + AEColor col = AEColor.values()[Math.abs(3 + this.hash) % AEColor.values().length]; + if (this.hash == 0) { + col = AEColor.BLACK; + } - AEColor col = AEColor.values()[Math.abs( 3 + this.hash ) % AEColor.values().length]; - if( this.hash == 0 ) - { - col = AEColor.BLACK; - } + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 6; y++) { + final boolean isLit; - for( int x = 0; x < 8; x++ ) - { - for( int y = 0; y < 6; y++ ) - { - final boolean isLit; + // This makes the border always use the darker color + if (x == 0 || y == 0 || x == 7 || y == 5) { + isLit = false; + } else { + isLit = (this.hash & (1 << x)) != 0 || (this.hash & (1 << y)) != 0; + } - // This makes the border always use the darker color - if( x == 0 || y == 0 || x == 7 || y == 5 ) - { - isLit = false; - } - else - { - isLit = ( this.hash & ( 1 << x ) ) != 0 || ( this.hash & ( 1 << y ) ) != 0; - } + if (isLit) { + builder.setColorRGB(col.mediumVariant); + } else { + final float scale = 0.3f / 255.0f; + builder.setColorRGB(((col.blackVariant >> 16) & 0xff) * scale, + ((col.blackVariant >> 8) & 0xff) * scale, (col.blackVariant & 0xff) * scale); + } - if( isLit ) - { - builder.setColorRGB( col.mediumVariant ); - } - else - { - final float scale = 0.3f / 255.0f; - builder.setColorRGB( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale, ( col.blackVariant & 0xff ) * scale ); - } + builder.addCube(4 + x, 6 + y, 7.5f, 4 + x + 1, 6 + y + 1, 8.5f); + } + } + return builder.getOutput(); + } - builder.addCube( 4 + x, 6 + y, 7.5f, 4 + x + 1, 6 + y + 1, 8.5f ); - } - } - return builder.getOutput(); - } + @Override + public boolean isAmbientOcclusion() { + return this.baseModel.isAmbientOcclusion(); + } - @Override - public boolean isAmbientOcclusion() - { - return this.baseModel.isAmbientOcclusion(); - } + @Override + public boolean isGui3d() { + return this.baseModel.isGui3d(); + } - @Override - public boolean isGui3d() - { - return this.baseModel.isGui3d(); - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean isBuiltInRenderer() { + return this.baseModel.isBuiltInRenderer(); + } - @Override - public boolean isBuiltInRenderer() - { - return this.baseModel.isBuiltInRenderer(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.baseModel.getParticleTexture(); + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.baseModel.getParticleTexture(); - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return this.baseModel.getItemCameraTransforms(); + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return this.baseModel.getItemCameraTransforms(); - } + @Override + public ItemOverrideList getOverrides() { + return new ItemOverrideList() { + @Override + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, + LivingEntity entity) { + String username = ""; + if (stack.getItem() instanceof IBiometricCard) { + final GameProfile gp = ((IBiometricCard) stack.getItem()).getProfile(stack); + if (gp != null) { + if (gp.getId() != null) { + username = gp.getId().toString(); + } else { + username = gp.getName(); + } + } + } + final int hash = !username.isEmpty() ? username.hashCode() : 0; - @Override - public ItemOverrideList getOverrides() - { - return new ItemOverrideList() - { - @Override - public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) - { - String username = ""; - if( stack.getItem() instanceof IBiometricCard ) - { - final GameProfile gp = ( (IBiometricCard) stack.getItem() ).getProfile( stack ); - if( gp != null ) - { - if( gp.getId() != null ) - { - username = gp.getId().toString(); - } - else - { - username = gp.getName(); - } - } - } - final int hash = !username.isEmpty() ? username.hashCode() : 0; + // Get hash + if (hash == 0) { + return BiometricCardBakedModel.this; + } - // Get hash - if( hash == 0 ) - { - return BiometricCardBakedModel.this; - } + try { + return BiometricCardBakedModel.this.modelCache.get(hash, + () -> new BiometricCardBakedModel(BiometricCardBakedModel.this.baseModel, + BiometricCardBakedModel.this.texture, hash, + BiometricCardBakedModel.this.modelCache)); + } catch (ExecutionException e) { + AELog.error(e); + return BiometricCardBakedModel.this; + } + } + }; + } - try - { - return BiometricCardBakedModel.this.modelCache.get( hash, () -> new BiometricCardBakedModel( BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) ); - } - catch( ExecutionException e ) - { - AELog.error( e ); - return BiometricCardBakedModel.this; - } - } - }; - } + @Override + public boolean doesHandlePerspectives() { + return true; + } - @Override - public boolean doesHandlePerspectives() - { - return true; - } - - @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { - baseModel.handlePerspective( cameraTransformType, mat ); - return this; - } + @Override + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { + baseModel.handlePerspective(cameraTransformType, mat); + return this; + } } diff --git a/src/main/java/appeng/client/render/model/BiometricCardModel.java b/src/main/java/appeng/client/render/model/BiometricCardModel.java index 032edd723..9f173bf05 100644 --- a/src/main/java/appeng/client/render/model/BiometricCardModel.java +++ b/src/main/java/appeng/client/render/model/BiometricCardModel.java @@ -1,10 +1,10 @@ package appeng.client.render.model; - import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; + import javax.annotation.Nullable; import com.mojang.datafixers.util.Pair; @@ -13,37 +13,37 @@ import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; - -import appeng.core.AppEng; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; +import appeng.core.AppEng; /** - * Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player - * name + * Model wrapper for the biometric card item model, which combines a base card + * layer with a "visual hash" of the player name */ -public class BiometricCardModel implements IModelGeometry -{ +public class BiometricCardModel implements IModelGeometry { - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card_base" ); - private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "item/biometric_card_hash" ) ); + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "item/biometric_card_base"); + private static final Material TEXTURE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "item/biometric_card_hash")); - @Override - public Collection getTextures( IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors ) - { - return Collections.singleton( TEXTURE ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.singleton(TEXTURE); + } - @Nullable - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform transformIn, ItemOverrideList overrides, ResourceLocation locationIn ) - { - TextureAtlasSprite texture = spriteGetter.apply( TEXTURE ); + @Nullable + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform transformIn, + ItemOverrideList overrides, ResourceLocation locationIn) { + TextureAtlasSprite texture = spriteGetter.apply(TEXTURE); - IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, transformIn, spriteGetter ); + IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, transformIn, spriteGetter); - return new BiometricCardBakedModel( baseModel, texture ); - } + return new BiometricCardBakedModel(baseModel, texture); + } } diff --git a/src/main/java/appeng/client/render/model/ColorApplicatorBakedModel.java b/src/main/java/appeng/client/render/model/ColorApplicatorBakedModel.java index d7eedb6dc..9dab86e98 100644 --- a/src/main/java/appeng/client/render/model/ColorApplicatorBakedModel.java +++ b/src/main/java/appeng/client/render/model/ColorApplicatorBakedModel.java @@ -1,10 +1,10 @@ package appeng.client.render.model; - import java.util.ArrayList; import java.util.EnumMap; import java.util.List; import java.util.Random; + import javax.annotation.Nullable; import com.mojang.blaze3d.matrix.MatrixStack; @@ -20,120 +20,100 @@ import net.minecraft.util.Direction; import net.minecraftforge.client.model.PerspectiveMapWrapper; import net.minecraftforge.client.model.data.EmptyModelData; +class ColorApplicatorBakedModel implements IBakedModel { -class ColorApplicatorBakedModel implements IBakedModel -{ + private final IBakedModel baseModel; - private final IBakedModel baseModel; + private final IModelTransform transforms; - private final IModelTransform transforms; + private final EnumMap> quadsBySide; - private final EnumMap> quadsBySide; + private final List generalQuads; - private final List generalQuads; + ColorApplicatorBakedModel(IBakedModel baseModel, IModelTransform transforms, TextureAtlasSprite texDark, + TextureAtlasSprite texMedium, TextureAtlasSprite texBright) { + this.baseModel = baseModel; + this.transforms = transforms; - ColorApplicatorBakedModel( IBakedModel baseModel, IModelTransform transforms, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) - { - this.baseModel = baseModel; - this.transforms = transforms; + // Put the tint indices in... Since this is an item model, we are ignoring rand + this.generalQuads = this.fixQuadTint(null, texDark, texMedium, texBright); + this.quadsBySide = new EnumMap<>(Direction.class); + for (Direction facing : Direction.values()) { + this.quadsBySide.put(facing, this.fixQuadTint(facing, texDark, texMedium, texBright)); + } + } - // Put the tint indices in... Since this is an item model, we are ignoring rand - this.generalQuads = this.fixQuadTint( null, texDark, texMedium, texBright ); - this.quadsBySide = new EnumMap<>( Direction.class ); - for( Direction facing : Direction.values() ) - { - this.quadsBySide.put( facing, this.fixQuadTint( facing, texDark, texMedium, texBright ) ); - } - } + private List fixQuadTint(Direction facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, + TextureAtlasSprite texBright) { + List quads = this.baseModel.getQuads(null, facing, new Random(0), EmptyModelData.INSTANCE); + List result = new ArrayList<>(quads.size()); + for (BakedQuad quad : quads) { + int tint; - private List fixQuadTint( Direction facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) - { - List quads = this.baseModel.getQuads( null, facing, new Random( 0 ), EmptyModelData.INSTANCE ); - List result = new ArrayList<>( quads.size() ); - for( BakedQuad quad : quads ) - { - int tint; + if (quad.func_187508_a() == texDark) { + tint = 1; + } else if (quad.func_187508_a() == texMedium) { + tint = 2; + } else if (quad.func_187508_a() == texBright) { + tint = 3; + } else { + result.add(quad); + continue; + } - if( quad.func_187508_a() == texDark ) - { - tint = 1; - } - else if( quad.func_187508_a() == texMedium ) - { - tint = 2; - } - else if( quad.func_187508_a() == texBright ) - { - tint = 3; - } - else - { - result.add( quad ); - continue; - } + BakedQuad newQuad = new BakedQuad(quad.getVertexData(), tint, quad.getFace(), quad.func_187508_a(), + quad.shouldApplyDiffuseLighting()); + result.add(newQuad); + } - BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.func_187508_a(), quad.shouldApplyDiffuseLighting() ); - result.add( newQuad ); - } + return result; + } - return result; - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + if (side == null) { + return this.generalQuads; + } + return this.quadsBySide.get(side); + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { - if( side == null ) - { - return this.generalQuads; - } - return this.quadsBySide.get( side ); - } + @Override + public boolean isAmbientOcclusion() { + return this.baseModel.isAmbientOcclusion(); + } - @Override - public boolean isAmbientOcclusion() - { - return this.baseModel.isAmbientOcclusion(); - } + @Override + public boolean isGui3d() { + return this.baseModel.isGui3d(); + } - @Override - public boolean isGui3d() - { - return this.baseModel.isGui3d(); - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean isBuiltInRenderer() { + return this.baseModel.isBuiltInRenderer(); + } - @Override - public boolean isBuiltInRenderer() - { - return this.baseModel.isBuiltInRenderer(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.baseModel.getParticleTexture(); + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.baseModel.getParticleTexture(); - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return this.baseModel.getItemCameraTransforms(); + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return this.baseModel.getItemCameraTransforms(); - } + @Override + public ItemOverrideList getOverrides() { + return this.baseModel.getOverrides(); + } - @Override - public ItemOverrideList getOverrides() - { - return this.baseModel.getOverrides(); - } - - @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { - return PerspectiveMapWrapper.handlePerspective( this, transforms, cameraTransformType, mat ); - } + @Override + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { + return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType, mat); + } } diff --git a/src/main/java/appeng/client/render/model/ColorApplicatorModel.java b/src/main/java/appeng/client/render/model/ColorApplicatorModel.java index a9a7a9ef7..1472641f3 100644 --- a/src/main/java/appeng/client/render/model/ColorApplicatorModel.java +++ b/src/main/java/appeng/client/render/model/ColorApplicatorModel.java @@ -1,11 +1,11 @@ package appeng.client.render.model; - import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; + import javax.annotation.Nullable; import com.mojang.datafixers.util.Pair; @@ -16,37 +16,42 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.ModelLoaderRegistry; - -import appeng.core.AppEng; import net.minecraftforge.client.model.geometry.IModelGeometry; +import appeng.core.AppEng; /** - * A color applicator uses the base model, and extends it with additional layers that are colored according to the - * selected color of the applicator. + * A color applicator uses the base model, and extends it with additional layers + * that are colored according to the selected color of the applicator. */ -public class ColorApplicatorModel implements IModelGeometry -{ +public class ColorApplicatorModel implements IModelGeometry { - private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" ); + private static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, + "item/color_applicator_colored"); - private static final Material TEXTURE_DARK = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_tip_dark" ) ); - private static final Material TEXTURE_MEDIUM = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_tip_medium" ) ); - private static final Material TEXTURE_BRIGHT = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_tip_bright" ) ); + private static final Material TEXTURE_DARK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "item/color_applicator_tip_dark")); + private static final Material TEXTURE_MEDIUM = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "item/color_applicator_tip_medium")); + private static final Material TEXTURE_BRIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "item/color_applicator_tip_bright")); - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Arrays.asList( TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Arrays.asList(TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK); + } - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); - TextureAtlasSprite texDark = spriteGetter.apply( TEXTURE_DARK ); - TextureAtlasSprite texMedium = spriteGetter.apply( TEXTURE_MEDIUM ); - TextureAtlasSprite texBright = spriteGetter.apply( TEXTURE_BRIGHT ); + TextureAtlasSprite texDark = spriteGetter.apply(TEXTURE_DARK); + TextureAtlasSprite texMedium = spriteGetter.apply(TEXTURE_MEDIUM); + TextureAtlasSprite texBright = spriteGetter.apply(TEXTURE_BRIGHT); - return new ColorApplicatorBakedModel( baseModel, modelTransform, texDark, texMedium, texBright ); - } + return new ColorApplicatorBakedModel(baseModel, modelTransform, texDark, texMedium, texBright); + } } diff --git a/src/main/java/appeng/client/render/model/DriveBakedModel.java b/src/main/java/appeng/client/render/model/DriveBakedModel.java index 326fde664..24e0b466d 100644 --- a/src/main/java/appeng/client/render/model/DriveBakedModel.java +++ b/src/main/java/appeng/client/render/model/DriveBakedModel.java @@ -18,12 +18,14 @@ package appeng.client.render.model; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.api.definitions.IItems; -import appeng.block.storage.DriveSlotCellType; -import appeng.block.storage.DriveSlotsState; -import appeng.client.render.DelegateBakedModel; -import appeng.core.Api; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.model.BakedQuad; @@ -34,98 +36,92 @@ import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; +import appeng.api.definitions.IItems; +import appeng.block.storage.DriveSlotCellType; +import appeng.block.storage.DriveSlotsState; +import appeng.client.render.DelegateBakedModel; +import appeng.core.Api; +public class DriveBakedModel extends DelegateBakedModel { + private final Map bakedCells; -public class DriveBakedModel extends DelegateBakedModel -{ - private final Map bakedCells; + public DriveBakedModel(IBakedModel bakedBase, Map bakedCells) { + super(bakedBase); + this.bakedCells = bakedCells; + } - public DriveBakedModel( IBakedModel bakedBase, Map bakedCells ) - { - super(bakedBase); - this.bakedCells = bakedCells; - } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, + @Nonnull IModelData extraData) { - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + List result = new ArrayList<>(super.getQuads(state, side, rand, extraData)); - List result = new ArrayList<>(super.getQuads(state, side, rand, extraData)); + if (!(extraData instanceof DriveModelData)) { + return result; + } + DriveModelData driveModelData = (DriveModelData) extraData; - if (!(extraData instanceof DriveModelData)) { - return result; - } - DriveModelData driveModelData = (DriveModelData) extraData; + DriveSlotsState slotsState = driveModelData.getSlotsState(); - DriveSlotsState slotsState = driveModelData.getSlotsState(); + if (side == null && slotsState != null) { + for (int row = 0; row < 5; row++) { + for (int col = 0; col < 2; col++) { + Matrix4f transform = new Matrix4f(); - if( side == null && slotsState != null ) - { - for( int row = 0; row < 5; row++ ) - { - for( int col = 0; col < 2; col++ ) - { - Matrix4f transform = new Matrix4f(); + // Position this drive model copy at the correct slot. The transform is based on + // the + // cell-model being in slot 0,0 at the top left of the drive. + float xOffset = -col * 7 / 16.0f; + float yOffset = -row * 3 / 16.0f; + transform.setTranslation(xOffset, yOffset, 0); - // Position this drive model copy at the correct slot. The transform is based on the - // cell-model being in slot 0,0 at the top left of the drive. - float xOffset = -col * 7 / 16.0f; - float yOffset = -row * 3 / 16.0f; - transform.setTranslation( xOffset, yOffset, 0 ); + int slot = row * 2 + col; - int slot = row * 2 + col; + // Add the drive chassis + Item cell = slotsState.getCell(slot); + IBakedModel cellChassisModel = getCellChassisModel(cell); + addModel(state, rand, extraData, result, cellChassisModel, transform); + } + } + } - // Add the drive chassis - Item cell = slotsState.getCell(slot); - IBakedModel cellChassisModel = getCellChassisModel(cell); - addModel(state, rand, extraData, result, cellChassisModel, transform); - } - } - } + return result; + } - return result; - } + @Override + public boolean isAmbientOcclusion() { + // We have faces inside the chassis that are facing east, but should not receive + // ambient occlusion from the east-side, but sadly this cannot be fine-tuned on + // a + // face-by-face basis. + return false; + } - @Override - public boolean isAmbientOcclusion() { - // We have faces inside the chassis that are facing east, but should not receive - // ambient occlusion from the east-side, but sadly this cannot be fine-tuned on a - // face-by-face basis. - return false; - } + // Determine which drive chassis to show based on the used cell + private IBakedModel getCellChassisModel(Item cell) { + IItems items = Api.INSTANCE.definitions().items(); + if (cell == null) { + return bakedCells.get(DriveSlotCellType.EMPTY); + } else if (items.fluidCell1k().item() == cell || items.fluidCell4k().item() == cell + || items.fluidCell16k().item() == cell || items.fluidCell64k().item() == cell) { + return bakedCells.get(DriveSlotCellType.FLUID); + } else { + // Fall back to an item model + return bakedCells.get(DriveSlotCellType.ITEM); + } + } - // Determine which drive chassis to show based on the used cell - private IBakedModel getCellChassisModel(Item cell) { - IItems items = Api.INSTANCE.definitions().items(); - if (cell == null) { - return bakedCells.get(DriveSlotCellType.EMPTY); - } else if (items.fluidCell1k().item() == cell - || items.fluidCell4k().item() == cell - || items.fluidCell16k().item() == cell - || items.fluidCell64k().item() == cell) { - return bakedCells.get(DriveSlotCellType.FLUID); - } else { - // Fall back to an item model - return bakedCells.get(DriveSlotCellType.ITEM); - } - } - - private static void addModel(@Nullable BlockState state, @Nonnull Random rand, @Nonnull IModelData extraData, List result, IBakedModel bakedCell, Matrix4f transform) { - MatrixVertexTransformer transformer = new MatrixVertexTransformer( transform ); - for( BakedQuad bakedQuad : bakedCell.getQuads( state, null, rand, extraData ) ) - { - BakedQuadBuilder builder = new BakedQuadBuilder(); - transformer.setParent( builder ); - transformer.setVertexFormat( builder.getVertexFormat() ); - bakedQuad.pipe( transformer ); - result.add( builder.build() ); - } - } + private static void addModel(@Nullable BlockState state, @Nonnull Random rand, @Nonnull IModelData extraData, + List result, IBakedModel bakedCell, Matrix4f transform) { + MatrixVertexTransformer transformer = new MatrixVertexTransformer(transform); + for (BakedQuad bakedQuad : bakedCell.getQuads(state, null, rand, extraData)) { + BakedQuadBuilder builder = new BakedQuadBuilder(); + transformer.setParent(builder); + transformer.setVertexFormat(builder.getVertexFormat()); + bakedQuad.pipe(transformer); + result.add(builder.build()); + } + } } diff --git a/src/main/java/appeng/client/render/model/DriveModel.java b/src/main/java/appeng/client/render/model/DriveModel.java index f509ed6f1..1ba54aa6c 100644 --- a/src/main/java/appeng/client/render/model/DriveModel.java +++ b/src/main/java/appeng/client/render/model/DriveModel.java @@ -18,56 +18,56 @@ package appeng.client.render.model; +import java.util.*; +import java.util.function.Function; -import appeng.block.storage.DriveSlotCellType; -import appeng.block.storage.DriveSlotState; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.*; -import java.util.function.Function; +import appeng.block.storage.DriveSlotCellType; +import appeng.block.storage.DriveSlotState; -public class DriveModel implements IModelGeometry -{ +public class DriveModel implements IModelGeometry { - private static final ResourceLocation MODEL_BASE = new ResourceLocation( "appliedenergistics2:block/drive/drive_base" ); + private static final ResourceLocation MODEL_BASE = new ResourceLocation( + "appliedenergistics2:block/drive/drive_base"); - private static final Map MODELS_CELLS = ImmutableMap.of( - DriveSlotCellType.EMPTY, new ResourceLocation( "appliedenergistics2:block/drive/drive_cell_empty" ), - DriveSlotCellType.ITEM, new ResourceLocation( "appliedenergistics2:block/drive/drive_cell_items" ), - DriveSlotCellType.FLUID, new ResourceLocation( "appliedenergistics2:block/drive/drive_cell_fluids" ) - ); + private static final Map MODELS_CELLS = ImmutableMap.of( + DriveSlotCellType.EMPTY, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_empty"), + DriveSlotCellType.ITEM, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_items"), + DriveSlotCellType.FLUID, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_fluids")); - public static final Set DEPENDENCIES = ImmutableSet.builder() - .addAll(MODELS_CELLS.values()) - .add(MODEL_BASE) - .build(); + public static final Set DEPENDENCIES = ImmutableSet.builder() + .addAll(MODELS_CELLS.values()).add(MODEL_BASE).build(); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - EnumMap cellModels = new EnumMap<>( DriveSlotCellType.class ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + EnumMap cellModels = new EnumMap<>(DriveSlotCellType.class); - // Load the base model and the model for each cell state. - for( DriveSlotCellType cellType : MODELS_CELLS.keySet() ) - { - IBakedModel cellModel = bakery.getBakedModel( MODELS_CELLS.get( cellType ), modelTransform, spriteGetter ); - cellModels.put( cellType, cellModel ); - } + // Load the base model and the model for each cell state. + for (DriveSlotCellType cellType : MODELS_CELLS.keySet()) { + IBakedModel cellModel = bakery.getBakedModel(MODELS_CELLS.get(cellType), modelTransform, spriteGetter); + cellModels.put(cellType, cellModel); + } - IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter ); - return new DriveBakedModel( baseModel, cellModels ); - } + IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); + return new DriveBakedModel(baseModel, cellModels); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Collections.emptyList(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.emptyList(); + } } diff --git a/src/main/java/appeng/client/render/model/DriveModelData.java b/src/main/java/appeng/client/render/model/DriveModelData.java index d9e446fc1..9f9882093 100644 --- a/src/main/java/appeng/client/render/model/DriveModelData.java +++ b/src/main/java/appeng/client/render/model/DriveModelData.java @@ -1,13 +1,16 @@ package appeng.client.render.model; -import appeng.block.storage.DriveSlotsState; +import java.util.Objects; + +import javax.annotation.Nullable; + import com.google.common.base.Preconditions; + import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nullable; -import java.util.Objects; +import appeng.block.storage.DriveSlotsState; public class DriveModelData extends AEModelData { @@ -29,9 +32,12 @@ public class DriveModelData extends AEModelData { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; DriveModelData that = (DriveModelData) o; return slotsState.equals(that.slotsState); } diff --git a/src/main/java/appeng/client/render/model/GlassBakedModel.java b/src/main/java/appeng/client/render/model/GlassBakedModel.java index a0abc8c8c..02374c4c9 100644 --- a/src/main/java/appeng/client/render/model/GlassBakedModel.java +++ b/src/main/java/appeng/client/render/model/GlassBakedModel.java @@ -18,7 +18,6 @@ package appeng.client.render.model; - import java.util.*; import java.util.function.Function; import java.util.stream.IntStream; @@ -41,9 +40,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; - -import appeng.decorative.solid.BlockQuartzGlass; -import appeng.decorative.solid.GlassState; import net.minecraft.world.IBlockReader; import net.minecraft.world.ILightReader; import net.minecraftforge.client.model.data.IDynamicBakedModel; @@ -52,304 +48,277 @@ import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; +import appeng.decorative.solid.BlockQuartzGlass; +import appeng.decorative.solid.GlassState; -class GlassBakedModel implements IDynamicBakedModel -{ +class GlassBakedModel implements IDynamicBakedModel { - // This unlisted property is used to determine the actual block that should be rendered - public static final ModelProperty GLASS_STATE = new ModelProperty<>(); + // This unlisted property is used to determine the actual block that should be + // rendered + public static final ModelProperty GLASS_STATE = new ModelProperty<>(); - private static final byte[][][] OFFSETS = generateOffsets(); + private static final byte[][][] OFFSETS = generateOffsets(); - // Alternating textures based on position - static final Material TEXTURE_A = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( "appliedenergistics2:block/glass/quartz_glass_a" )); - static final Material TEXTURE_B = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( "appliedenergistics2:block/glass/quartz_glass_b" )); - static final Material TEXTURE_C = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( "appliedenergistics2:block/glass/quartz_glass_c" )); - static final Material TEXTURE_D = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( "appliedenergistics2:block/glass/quartz_glass_d" )); + // Alternating textures based on position + static final Material TEXTURE_A = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation("appliedenergistics2:block/glass/quartz_glass_a")); + static final Material TEXTURE_B = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation("appliedenergistics2:block/glass/quartz_glass_b")); + static final Material TEXTURE_C = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation("appliedenergistics2:block/glass/quartz_glass_c")); + static final Material TEXTURE_D = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation("appliedenergistics2:block/glass/quartz_glass_d")); - // Frame texture - static final Material[] TEXTURES_FRAME = generateTexturesFrame(); + // Frame texture + static final Material[] TEXTURES_FRAME = generateTexturesFrame(); - // Generates the required textures for the frame - private static Material[] generateTexturesFrame() - { - return IntStream.range( 1, 16 ) - .mapToObj( Integer::toBinaryString ) - .map( s -> Strings.padStart( s, 4, '0' ) ) - .map( s -> new ResourceLocation( "appliedenergistics2:block/glass/quartz_glass_frame" + s ) ) - .map( rl -> new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, rl) ) - .toArray( Material[]::new ); - } + // Generates the required textures for the frame + private static Material[] generateTexturesFrame() { + return IntStream.range(1, 16).mapToObj(Integer::toBinaryString).map(s -> Strings.padStart(s, 4, '0')) + .map(s -> new ResourceLocation("appliedenergistics2:block/glass/quartz_glass_frame" + s)) + .map(rl -> new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, rl)).toArray(Material[]::new); + } - private final TextureAtlasSprite[] glassTextures; + private final TextureAtlasSprite[] glassTextures; - private final TextureAtlasSprite[] frameTextures; + private final TextureAtlasSprite[] frameTextures; - public GlassBakedModel( Function bakedTextureGetter ) - { - this.glassTextures = new TextureAtlasSprite[] { - bakedTextureGetter.apply( TEXTURE_A ), - bakedTextureGetter.apply( TEXTURE_B ), - bakedTextureGetter.apply( TEXTURE_C ), - bakedTextureGetter.apply( TEXTURE_D ) - }; + public GlassBakedModel(Function bakedTextureGetter) { + this.glassTextures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_A), + bakedTextureGetter.apply(TEXTURE_B), bakedTextureGetter.apply(TEXTURE_C), + bakedTextureGetter.apply(TEXTURE_D) }; - // The first frame texture would be empty, so we simply leave it set to null here - this.frameTextures = new TextureAtlasSprite[16]; - for( int i = 0; i < TEXTURES_FRAME.length; i++ ) - { - this.frameTextures[1 + i] = bakedTextureGetter.apply( TEXTURES_FRAME[i] ); - } - } + // The first frame texture would be empty, so we simply leave it set to null + // here + this.frameTextures = new TextureAtlasSprite[16]; + for (int i = 0; i < TEXTURES_FRAME.length; i++) { + this.frameTextures[1 + i] = bakedTextureGetter.apply(TEXTURES_FRAME[i]); + } + } - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData ) - { - if( side == null ) - { - return Collections.emptyList(); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData extraData) { + if (side == null) { + return Collections.emptyList(); + } - final GlassState glassState = extraData.getData( GLASS_STATE ); + final GlassState glassState = extraData.getData(GLASS_STATE); - if( glassState == null ) - { - return Collections.emptyList(); - } + if (glassState == null) { + return Collections.emptyList(); + } - // TODO: This could just use the Random instance we're given... - final int cx = Math.abs( glassState.getX() % 10 ); - final int cy = Math.abs( glassState.getY() % 10 ); - final int cz = Math.abs( glassState.getZ() % 10 ); + // TODO: This could just use the Random instance we're given... + final int cx = Math.abs(glassState.getX() % 10); + final int cy = Math.abs(glassState.getY() % 10); + final int cz = Math.abs(glassState.getZ() % 10); - int u = OFFSETS[cx][cy][cz] % 4; - int v = OFFSETS[9 - cx][9 - cy][9 - cz] % 4; + int u = OFFSETS[cx][cy][cz] % 4; + int v = OFFSETS[9 - cx][9 - cy][9 - cz] % 4; - int texIdx = Math.abs( ( OFFSETS[cx][cy][cz] + ( glassState.getX() + glassState.getY() + glassState.getZ() ) ) % 4 ); + int texIdx = Math.abs((OFFSETS[cx][cy][cz] + (glassState.getX() + glassState.getY() + glassState.getZ())) % 4); - if( texIdx < 2 ) - { - u /= 2; - v /= 2; - } + if (texIdx < 2) { + u /= 2; + v /= 2; + } - final TextureAtlasSprite glassTexture = this.glassTextures[texIdx]; + final TextureAtlasSprite glassTexture = this.glassTextures[texIdx]; - // Render the glass side - final List quads = new ArrayList<>( 5 ); // At most 5 + // Render the glass side + final List quads = new ArrayList<>(5); // At most 5 - final List corners = RenderHelper.getFaceCorners( side ); - quads.add( this.createQuad( side, corners, glassTexture, u, v ) ); + final List corners = RenderHelper.getFaceCorners(side); + quads.add(this.createQuad(side, corners, glassTexture, u, v)); - /* - * This needs some explanation: - * The bit-field contains 4-bits, one for each direction that a frame may be drawn. - * Converted to a number, the bit-field is then used as an index into the list of - * frame textures, which have been created in such a way that their filenames - * indicate, in which directions they contain borders. - * i.e. bitmask = 0101 means a border should be drawn up and down (in terms of u,v space). - * Converted to a number, this bitmask is 5. So the texture at index 5 is used. - * That texture had "0101" in its filename to indicate this. - */ - final int edgeBitmask = makeBitmask( glassState, side ); - final TextureAtlasSprite sideSprite = this.frameTextures[edgeBitmask]; + /* + * This needs some explanation: The bit-field contains 4-bits, one for each + * direction that a frame may be drawn. Converted to a number, the bit-field is + * then used as an index into the list of frame textures, which have been + * created in such a way that their filenames indicate, in which directions they + * contain borders. i.e. bitmask = 0101 means a border should be drawn up and + * down (in terms of u,v space). Converted to a number, this bitmask is 5. So + * the texture at index 5 is used. That texture had "0101" in its filename to + * indicate this. + */ + final int edgeBitmask = makeBitmask(glassState, side); + final TextureAtlasSprite sideSprite = this.frameTextures[edgeBitmask]; - if( sideSprite != null ) - { - quads.add( this.createQuad( side, corners, sideSprite, 0, 0 ) ); - } + if (sideSprite != null) { + quads.add(this.createQuad(side, corners, sideSprite, 0, 0)); + } - return quads; - } + return quads; + } - @Override - public boolean func_230044_c_() - { - // TODO: Forge: Auto-generated method stub - return false; - } + @Override + public boolean func_230044_c_() { + // TODO: Forge: Auto-generated method stub + return false; + } - /** - * Creates the bitmask that indicates, in which directions (in terms of u,v space) a border should be drawn. - */ - private static int makeBitmask( GlassState state, Direction side ) - { - switch( side ) - { - case DOWN: - return makeBitmask( state, Direction.SOUTH, Direction.EAST, Direction.NORTH, Direction.WEST ); - case UP: - return makeBitmask( state, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.EAST ); - case NORTH: - return makeBitmask( state, Direction.UP, Direction.WEST, Direction.DOWN, Direction.EAST ); - case SOUTH: - return makeBitmask( state, Direction.UP, Direction.EAST, Direction.DOWN, Direction.WEST ); - case WEST: - return makeBitmask( state, Direction.UP, Direction.SOUTH, Direction.DOWN, Direction.NORTH ); - case EAST: - return makeBitmask( state, Direction.UP, Direction.NORTH, Direction.DOWN, Direction.SOUTH ); - default: - throw new IllegalArgumentException( "Unsupported side!" ); - } - } + /** + * Creates the bitmask that indicates, in which directions (in terms of u,v + * space) a border should be drawn. + */ + private static int makeBitmask(GlassState state, Direction side) { + switch (side) { + case DOWN: + return makeBitmask(state, Direction.SOUTH, Direction.EAST, Direction.NORTH, Direction.WEST); + case UP: + return makeBitmask(state, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.EAST); + case NORTH: + return makeBitmask(state, Direction.UP, Direction.WEST, Direction.DOWN, Direction.EAST); + case SOUTH: + return makeBitmask(state, Direction.UP, Direction.EAST, Direction.DOWN, Direction.WEST); + case WEST: + return makeBitmask(state, Direction.UP, Direction.SOUTH, Direction.DOWN, Direction.NORTH); + case EAST: + return makeBitmask(state, Direction.UP, Direction.NORTH, Direction.DOWN, Direction.SOUTH); + default: + throw new IllegalArgumentException("Unsupported side!"); + } + } - private static int makeBitmask( GlassState state, Direction up, Direction right, Direction down, Direction left ) - { + private static int makeBitmask(GlassState state, Direction up, Direction right, Direction down, Direction left) { - int bitmask = 0; + int bitmask = 0; - if( !state.isFlushWith( up ) ) - { - bitmask |= 1; - } - if( !state.isFlushWith( right ) ) - { - bitmask |= 2; - } - if( !state.isFlushWith( down ) ) - { - bitmask |= 4; - } - if( !state.isFlushWith( left ) ) - { - bitmask |= 8; - } - return bitmask; - } + if (!state.isFlushWith(up)) { + bitmask |= 1; + } + if (!state.isFlushWith(right)) { + bitmask |= 2; + } + if (!state.isFlushWith(down)) { + bitmask |= 4; + } + if (!state.isFlushWith(left)) { + bitmask |= 8; + } + return bitmask; + } - private BakedQuad createQuad( Direction side, List corners, TextureAtlasSprite sprite, float uOffset, float vOffset ) - { - return this.createQuad( side, corners.get( 0 ), corners.get( 1 ), corners.get( 2 ), corners.get( 3 ), sprite, uOffset, vOffset ); - } + private BakedQuad createQuad(Direction side, List corners, TextureAtlasSprite sprite, float uOffset, + float vOffset) { + return this.createQuad(side, corners.get(0), corners.get(1), corners.get(2), corners.get(3), sprite, uOffset, + vOffset); + } - private BakedQuad createQuad( Direction side, Vec3d c1, Vec3d c2, Vec3d c3, Vec3d c4, TextureAtlasSprite sprite, float uOffset, float vOffset ) - { - Vec3d normal = new Vec3d( side.getDirectionVec() ); + private BakedQuad createQuad(Direction side, Vec3d c1, Vec3d c2, Vec3d c3, Vec3d c4, TextureAtlasSprite sprite, + float uOffset, float vOffset) { + Vec3d normal = new Vec3d(side.getDirectionVec()); - // Apply the u,v shift. - // This mirrors the logic from OffsetIcon from 1.7 - float u1 = MathHelper.clamp( 0 - uOffset, 0, 16 ); - float u2 = MathHelper.clamp( 16 - uOffset, 0, 16 ); - float v1 = MathHelper.clamp( 0 - vOffset, 0, 16 ); - float v2 = MathHelper.clamp( 16 - vOffset, 0, 16 ); + // Apply the u,v shift. + // This mirrors the logic from OffsetIcon from 1.7 + float u1 = MathHelper.clamp(0 - uOffset, 0, 16); + float u2 = MathHelper.clamp(16 - uOffset, 0, 16); + float v1 = MathHelper.clamp(0 - vOffset, 0, 16); + float v2 = MathHelper.clamp(16 - vOffset, 0, 16); - BakedQuadBuilder builder = new BakedQuadBuilder(sprite); - builder.setQuadOrientation(side); - this.putVertex( builder, normal, c1.x, c1.y, c1.z, sprite, u1, v1 ); - this.putVertex( builder, normal, c2.x, c2.y, c2.z, sprite, u1, v2 ); - this.putVertex( builder, normal, c3.x, c3.y, c3.z, sprite, u2, v2 ); - this.putVertex( builder, normal, c4.x, c4.y, c4.z, sprite, u2, v1 ); - return builder.build(); - } + BakedQuadBuilder builder = new BakedQuadBuilder(sprite); + builder.setQuadOrientation(side); + this.putVertex(builder, normal, c1.x, c1.y, c1.z, sprite, u1, v1); + this.putVertex(builder, normal, c2.x, c2.y, c2.z, sprite, u1, v2); + this.putVertex(builder, normal, c3.x, c3.y, c3.z, sprite, u2, v2); + this.putVertex(builder, normal, c4.x, c4.y, c4.z, sprite, u2, v1); + return builder.build(); + } - /* - * This method is as complicated as it is, because the order in which we push data into the vertexbuffer actually - * has to be precisely the order - * in which the vertex elements had been declared in the vertex format. - */ - private void putVertex( BakedQuadBuilder builder, Vec3d normal, double x, double y, double z, TextureAtlasSprite sprite, float u, float v ) - { - VertexFormat vertexFormat = builder.getVertexFormat(); - for( int e = 0; e < vertexFormat.getElements().size(); e++ ) - { - VertexFormatElement el = vertexFormat.getElements().get(e); - switch( el.getUsage() ) - { - case POSITION: - builder.put( e, (float) x, (float) y, (float) z, 1.0f ); - break; - case COLOR: - builder.put( e, 1.0f, 1.0f, 1.0f, 1.0f ); - break; - case NORMAL: - builder.put( e, (float) normal.x, (float) normal.y, (float) normal.z, 0f ); - break; - case UV: - if( el.getIndex() == 0 ) - { - u = sprite.getInterpolatedU( u ); - v = sprite.getInterpolatedV( v ); - builder.put( e, u, v, 0f, 1f ); - break; - } - // Important: Fall through for getIndex() != 0 - default: - builder.put( e ); - break; - } - } - } + /* + * This method is as complicated as it is, because the order in which we push + * data into the vertexbuffer actually has to be precisely the order in which + * the vertex elements had been declared in the vertex format. + */ + private void putVertex(BakedQuadBuilder builder, Vec3d normal, double x, double y, double z, + TextureAtlasSprite sprite, float u, float v) { + VertexFormat vertexFormat = builder.getVertexFormat(); + for (int e = 0; e < vertexFormat.getElements().size(); e++) { + VertexFormatElement el = vertexFormat.getElements().get(e); + switch (el.getUsage()) { + case POSITION: + builder.put(e, (float) x, (float) y, (float) z, 1.0f); + break; + case COLOR: + builder.put(e, 1.0f, 1.0f, 1.0f, 1.0f); + break; + case NORMAL: + builder.put(e, (float) normal.x, (float) normal.y, (float) normal.z, 0f); + break; + case UV: + if (el.getIndex() == 0) { + u = sprite.getInterpolatedU(u); + v = sprite.getInterpolatedV(v); + builder.put(e, u, v, 0f, 1f); + break; + } + // Important: Fall through for getIndex() != 0 + default: + builder.put(e); + break; + } + } + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.frameTextures[this.frameTextures.length - 1]; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.frameTextures[this.frameTextures.length - 1]; + } - private static byte[][][] generateOffsets() - { - final Random r = new Random( 924 ); - final byte[][][] offset = new byte[10][10][10]; + private static byte[][][] generateOffsets() { + final Random r = new Random(924); + final byte[][][] offset = new byte[10][10][10]; - for( int x = 0; x < 10; x++ ) - { - for( int y = 0; y < 10; y++ ) - { - r.nextBytes( offset[x][y] ); - } - } + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 10; y++) { + r.nextBytes(offset[x][y]); + } + } - return offset; - } + return offset; + } - @Nonnull - @Override - public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { + @Nonnull + @Override + public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, + @Nonnull IModelData tileData) { - EnumSet flushWith = EnumSet.noneOf( Direction.class ); - // Test every direction for another glass block - for( Direction facing : Direction.values() ) - { - if( isGlassBlock( world, pos, facing ) ) - { - flushWith.add( facing ); - } - } + EnumSet flushWith = EnumSet.noneOf(Direction.class); + // Test every direction for another glass block + for (Direction facing : Direction.values()) { + if (isGlassBlock(world, pos, facing)) { + flushWith.add(facing); + } + } - GlassState glassState = new GlassState( pos.getX(), pos.getY(), pos.getZ(), flushWith ); - return new ModelDataMap.Builder() - .withInitial(GLASS_STATE, glassState) - .build(); + GlassState glassState = new GlassState(pos.getX(), pos.getY(), pos.getZ(), flushWith); + return new ModelDataMap.Builder().withInitial(GLASS_STATE, glassState).build(); - } + } - private static boolean isGlassBlock(IBlockReader world, BlockPos pos, Direction facing ) - { - return world.getBlockState( pos.offset( facing ) ).getBlock() instanceof BlockQuartzGlass; - } + private static boolean isGlassBlock(IBlockReader world, BlockPos pos, Direction facing) { + return world.getBlockState(pos.offset(facing)).getBlock() instanceof BlockQuartzGlass; + } } diff --git a/src/main/java/appeng/client/render/model/GlassModel.java b/src/main/java/appeng/client/render/model/GlassModel.java index 76d894fc9..91befb96c 100644 --- a/src/main/java/appeng/client/render/model/GlassModel.java +++ b/src/main/java/appeng/client/render/model/GlassModel.java @@ -18,41 +18,42 @@ package appeng.client.render.model; - import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; -import com.google.common.collect.ImmutableSet; +import javax.annotation.Nullable; +import com.google.common.collect.ImmutableSet; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import javax.annotation.Nullable; - /** * Model class for the connected texture glass model. */ -public class GlassModel implements IModelGeometry -{ +public class GlassModel implements IModelGeometry { - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - return new GlassBakedModel( spriteGetter ); - } + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + return new GlassBakedModel(spriteGetter); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return ImmutableSet.builder() - .add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B, GlassBakedModel.TEXTURE_C, GlassBakedModel.TEXTURE_D) - .add(GlassBakedModel.TEXTURES_FRAME) - .build(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return ImmutableSet + .builder().add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B, + GlassBakedModel.TEXTURE_C, GlassBakedModel.TEXTURE_D) + .add(GlassBakedModel.TEXTURES_FRAME).build(); + } } diff --git a/src/main/java/appeng/client/render/model/MatrixVertexTransformer.java b/src/main/java/appeng/client/render/model/MatrixVertexTransformer.java index e0c3a784a..31e93b7aa 100644 --- a/src/main/java/appeng/client/render/model/MatrixVertexTransformer.java +++ b/src/main/java/appeng/client/render/model/MatrixVertexTransformer.java @@ -18,6 +18,7 @@ package appeng.client.render.model; +import java.util.List; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Vector4f; @@ -27,147 +28,107 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.util.Direction; import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer; -import java.util.List; - - /** * Applies an arbitrary transformation matrix to the vertices of a quad. */ -final class MatrixVertexTransformer extends QuadGatheringTransformer -{ +final class MatrixVertexTransformer extends QuadGatheringTransformer { - private final Matrix4f transform; + private final Matrix4f transform; - public MatrixVertexTransformer( Matrix4f transform ) - { - this.transform = transform; - } + public MatrixVertexTransformer(Matrix4f transform) { + this.transform = transform; + } - @Override - protected void processQuad() - { - VertexFormat format = this.parent.getVertexFormat(); - List elements = format.getElements(); - int count = elements.size(); + @Override + protected void processQuad() { + VertexFormat format = this.parent.getVertexFormat(); + List elements = format.getElements(); + int count = elements.size(); - for( int v = 0; v < 4; v++ ) - { - for( int e = 0; e < count; e++ ) - { - VertexFormatElement element = elements.get( e ); - if( element.getUsage() == VertexFormatElement.Usage.POSITION ) - { - this.parent.put( e, this.transform( this.quadData[e][v], element.getElementCount() ) ); - } - else if( element.getUsage() == VertexFormatElement.Usage.NORMAL ) - { - this.parent.put( e, this.transformNormal( this.quadData[e][v] ) ); - } - else - { - this.parent.put( e, this.quadData[e][v] ); - } - } - } - } + for (int v = 0; v < 4; v++) { + for (int e = 0; e < count; e++) { + VertexFormatElement element = elements.get(e); + if (element.getUsage() == VertexFormatElement.Usage.POSITION) { + this.parent.put(e, this.transform(this.quadData[e][v], element.getElementCount())); + } else if (element.getUsage() == VertexFormatElement.Usage.NORMAL) { + this.parent.put(e, this.transformNormal(this.quadData[e][v])); + } else { + this.parent.put(e, this.quadData[e][v]); + } + } + } + } - @Override - public void setQuadTint( int tint ) - { - this.parent.setQuadTint( tint ); - } + @Override + public void setQuadTint(int tint) { + this.parent.setQuadTint(tint); + } - @Override - public void setQuadOrientation( Direction orientation ) - { - this.parent.setQuadOrientation( orientation ); - } + @Override + public void setQuadOrientation(Direction orientation) { + this.parent.setQuadOrientation(orientation); + } - @Override - public void setApplyDiffuseLighting( boolean diffuse ) - { - this.parent.setApplyDiffuseLighting( diffuse ); - } + @Override + public void setApplyDiffuseLighting(boolean diffuse) { + this.parent.setApplyDiffuseLighting(diffuse); + } - @Override - public void setTexture( TextureAtlasSprite texture ) - { - this.parent.setTexture( texture ); - } + @Override + public void setTexture(TextureAtlasSprite texture) { + this.parent.setTexture(texture); + } - private float[] transform( float[] fs, int elemCount ) - { - switch( fs.length ) - { - case 3: - Vector4f vec = new Vector4f( fs[0], fs[1], fs[2], 1 ); - vec.setX(vec.getX() - 0.5f); - vec.setY(vec.getY() - 0.5f); - vec.setZ(vec.getZ() - 0.5f); - vec.transform(this.transform); // FIXME: Check this, we're using a Vec4, input is Vec3 - vec.setX(vec.getX() + 0.5f); - vec.setY(vec.getY() + 0.5f); - vec.setZ(vec.getZ() + 0.5f); - return new float[] { - vec.getX(), - vec.getY(), - vec.getZ() - }; - case 4: - Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] ); - // Otherwise all translation is lost - if( elemCount == 3 ) - { - vecc.setW(1); - } - vecc.setX(vecc.getX() - 0.5f); - vecc.setY(vecc.getY() - 0.5f); - vecc.setZ(vecc.getZ() - 0.5f); - vecc.transform(this.transform); - vecc.setX(vecc.getX() + 0.5f); - vecc.setY(vecc.getY() + 0.5f); - vecc.setZ(vecc.getZ() + 0.5f); - return new float[] { - vecc.getX(), - vecc.getY(), - vecc.getZ(), - vecc.getW() - }; + private float[] transform(float[] fs, int elemCount) { + switch (fs.length) { + case 3: + Vector4f vec = new Vector4f(fs[0], fs[1], fs[2], 1); + vec.setX(vec.getX() - 0.5f); + vec.setY(vec.getY() - 0.5f); + vec.setZ(vec.getZ() - 0.5f); + vec.transform(this.transform); // FIXME: Check this, we're using a Vec4, input is Vec3 + vec.setX(vec.getX() + 0.5f); + vec.setY(vec.getY() + 0.5f); + vec.setZ(vec.getZ() + 0.5f); + return new float[] { vec.getX(), vec.getY(), vec.getZ() }; + case 4: + Vector4f vecc = new Vector4f(fs[0], fs[1], fs[2], fs[3]); + // Otherwise all translation is lost + if (elemCount == 3) { + vecc.setW(1); + } + vecc.setX(vecc.getX() - 0.5f); + vecc.setY(vecc.getY() - 0.5f); + vecc.setZ(vecc.getZ() - 0.5f); + vecc.transform(this.transform); + vecc.setX(vecc.getX() + 0.5f); + vecc.setY(vecc.getY() + 0.5f); + vecc.setZ(vecc.getZ() + 0.5f); + return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), vecc.getW() }; - default: - return fs; - } - } + default: + return fs; + } + } - private float[] transformNormal( float[] fs ) - { - Vector4f normal; + private float[] transformNormal(float[] fs) { + Vector4f normal; - switch( fs.length ) - { - case 3: - normal = new Vector4f( fs[0], fs[1], fs[2], 0 ); - normal.transform(this.transform); - normal.normalize(); - return new float[] { - normal.getX(), - normal.getY(), - normal.getZ() - }; + switch (fs.length) { + case 3: + normal = new Vector4f(fs[0], fs[1], fs[2], 0); + normal.transform(this.transform); + normal.normalize(); + return new float[] { normal.getX(), normal.getY(), normal.getZ() }; - case 4: - normal = new Vector4f( fs[0], fs[1], fs[2], fs[3] ); - normal.transform(this.transform); - normal.normalize(); - return new float[] { - normal.getX(), - normal.getY(), - normal.getZ(), - normal.getW() - }; + case 4: + normal = new Vector4f(fs[0], fs[1], fs[2], fs[3]); + normal.transform(this.transform); + normal.normalize(); + return new float[] { normal.getX(), normal.getY(), normal.getZ(), normal.getW() }; - default: - return fs; - } - } + default: + return fs; + } + } } diff --git a/src/main/java/appeng/client/render/model/MemoryCardBakedModel.java b/src/main/java/appeng/client/render/model/MemoryCardBakedModel.java index 759bf6166..5bb634586 100644 --- a/src/main/java/appeng/client/render/model/MemoryCardBakedModel.java +++ b/src/main/java/appeng/client/render/model/MemoryCardBakedModel.java @@ -1,12 +1,12 @@ package appeng.client.render.model; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.concurrent.ExecutionException; + import javax.annotation.Nullable; import com.google.common.cache.Cache; @@ -34,187 +34,159 @@ import appeng.api.util.AEColor; import appeng.client.render.cablebus.CubeBuilder; import appeng.core.AELog; +class MemoryCardBakedModel implements IBakedModel { + private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { AEColor.TRANSPARENT, AEColor.TRANSPARENT, + AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, + AEColor.TRANSPARENT, }; -class MemoryCardBakedModel implements IBakedModel -{ - private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { - AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, - AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, - }; + private final IBakedModel baseModel; - private final IBakedModel baseModel; + private final TextureAtlasSprite texture; - private final TextureAtlasSprite texture; + private final AEColor[] colorCode; - private final AEColor[] colorCode; + private final Cache modelCache; - private final Cache modelCache; + private final ImmutableList generalQuads; - private final ImmutableList generalQuads; + MemoryCardBakedModel(IBakedModel baseModel, TextureAtlasSprite texture) { + this(baseModel, texture, DEFAULT_COLOR_CODE, createCache()); + } - MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture ) - { - this( baseModel, texture, DEFAULT_COLOR_CODE, createCache() ); - } + private MemoryCardBakedModel(IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, + Cache modelCache) { + this.baseModel = baseModel; + this.texture = texture; + this.colorCode = hash; + this.generalQuads = ImmutableList.copyOf(this.buildGeneralQuads()); + this.modelCache = modelCache; + } - private MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache modelCache ) - { - this.baseModel = baseModel; - this.texture = texture; - this.colorCode = hash; - this.generalQuads = ImmutableList.copyOf( this.buildGeneralQuads() ); - this.modelCache = modelCache; - } + private static Cache createCache() { + return CacheBuilder.newBuilder().maximumSize(100).build(); + } - private static Cache createCache() - { - return CacheBuilder.newBuilder().maximumSize( 100 ).build(); - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - @Override - public List getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand ) - { + List quads = this.baseModel.getQuads(state, side, rand, EmptyModelData.INSTANCE); - List quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE ); + if (side != null) { + return quads; + } - if( side != null ) - { - return quads; - } + List result = new ArrayList<>(quads.size() + this.generalQuads.size()); + result.addAll(quads); + result.addAll(this.generalQuads); + return result; + } - List result = new ArrayList<>( quads.size() + this.generalQuads.size() ); - result.addAll( quads ); - result.addAll( this.generalQuads ); - return result; - } + private List buildGeneralQuads() { + CubeBuilder builder = new CubeBuilder(); - private List buildGeneralQuads() - { - CubeBuilder builder = new CubeBuilder(); + builder.setTexture(this.texture); - builder.setTexture( this.texture ); + for (int x = 0; x < 4; x++) { + for (int y = 0; y < 2; y++) { + final AEColor color = this.colorCode[x + y * 4]; - for( int x = 0; x < 4; x++ ) - { - for( int y = 0; y < 2; y++ ) - { - final AEColor color = this.colorCode[x + y * 4]; + builder.setColorRGB(color.mediumVariant); + builder.addCube(7 + x, 8 + (1 - y), 7.5f, 7 + x + 1, 8 + (1 - y) + 1, 8.5f); + } + } - builder.setColorRGB( color.mediumVariant ); - builder.addCube( 7 + x, 8 + ( 1 - y ), 7.5f, 7 + x + 1, 8 + ( 1 - y ) + 1, 8.5f ); - } - } + return builder.getOutput(); + } - return builder.getOutput(); - } + @Override + public boolean isAmbientOcclusion() { + return this.baseModel.isAmbientOcclusion(); + } - @Override - public boolean isAmbientOcclusion() - { - return this.baseModel.isAmbientOcclusion(); - } + @Override + public boolean isGui3d() { + return this.baseModel.isGui3d(); + } - @Override - public boolean isGui3d() - { - return this.baseModel.isGui3d(); - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean isBuiltInRenderer() { + return this.baseModel.isBuiltInRenderer(); + } - @Override - public boolean isBuiltInRenderer() - { - return this.baseModel.isBuiltInRenderer(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.baseModel.getParticleTexture(); + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.baseModel.getParticleTexture(); - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return this.baseModel.getItemCameraTransforms(); + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return this.baseModel.getItemCameraTransforms(); - } + @Override + public ItemOverrideList getOverrides() { + return new ItemOverrideList() { + @Override + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, + LivingEntity entity) { + try { + if (stack.getItem() instanceof IMemoryCard) { + final IMemoryCard memoryCard = (IMemoryCard) stack.getItem(); + final AEColor[] colors = memoryCard.getColorCode(stack); - @Override - public ItemOverrideList getOverrides() - { - return new ItemOverrideList() - { - @Override - public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) - { - try - { - if( stack.getItem() instanceof IMemoryCard ) - { - final IMemoryCard memoryCard = (IMemoryCard) stack.getItem(); - final AEColor[] colors = memoryCard.getColorCode( stack ); + return MemoryCardBakedModel.this.modelCache.get(new CacheKey(colors), + () -> new MemoryCardBakedModel(MemoryCardBakedModel.this.baseModel, + MemoryCardBakedModel.this.texture, colors, + MemoryCardBakedModel.this.modelCache)); + } + } catch (ExecutionException e) { + AELog.error(e); + } - return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ), - () -> new MemoryCardBakedModel( MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) ); - } - } - catch( ExecutionException e ) - { - AELog.error( e ); - } + return MemoryCardBakedModel.this; + } + }; + } - return MemoryCardBakedModel.this; - } - }; - } + @Override + public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { + baseModel.handlePerspective(cameraTransformType, mat); + return this; + } - @Override - public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat ) - { - baseModel.handlePerspective( cameraTransformType, mat ); - return this; - } + private static class CacheKey { + private final AEColor[] key; - private static class CacheKey - { - private final AEColor[] key; + CacheKey(AEColor[] key) { + this.key = key; + } - CacheKey( AEColor[] key ) - { - this.key = key; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(this.key); + return result; + } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode( this.key ); - return result; - } - - @Override - public boolean equals( Object obj ) - { - if( this == obj ) - { - return true; - } - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } - CacheKey other = (CacheKey) obj; - return Arrays.equals( this.key, other.key ); - } - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + CacheKey other = (CacheKey) obj; + return Arrays.equals(this.key, other.key); + } + } } diff --git a/src/main/java/appeng/client/render/model/MemoryCardModel.java b/src/main/java/appeng/client/render/model/MemoryCardModel.java index 5305244d0..1fe9a06ba 100644 --- a/src/main/java/appeng/client/render/model/MemoryCardModel.java +++ b/src/main/java/appeng/client/render/model/MemoryCardModel.java @@ -1,10 +1,10 @@ package appeng.client.render.model; - import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; + import javax.annotation.Nullable; import com.mojang.datafixers.util.Pair; @@ -13,36 +13,37 @@ import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; - -import appeng.core.AppEng; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; +import appeng.core.AppEng; /** - * Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile. + * Model wrapper for the memory card item model, which combines a base card + * layer with a "visual hash" of the part/tile. */ -public class MemoryCardModel implements IModelGeometry -{ +public class MemoryCardModel implements IModelGeometry { - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card_base" ); - private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "item/memory_card_hash" ) ); + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "item/memory_card_base"); + private static final Material TEXTURE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "item/memory_card_hash")); - @Override - public Collection getTextures( IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors ) - { - return Collections.singleton( TEXTURE ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.singleton(TEXTURE); + } - @Nullable - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) - { - TextureAtlasSprite texture = spriteGetter.apply( TEXTURE ); + @Nullable + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + TextureAtlasSprite texture = spriteGetter.apply(TEXTURE); - IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter ); + IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); - return new MemoryCardBakedModel( baseModel, texture ); - } + return new MemoryCardBakedModel(baseModel, texture); + } } diff --git a/src/main/java/appeng/client/render/model/RenderHelper.java b/src/main/java/appeng/client/render/model/RenderHelper.java index c768e65f2..cb5b3b633 100644 --- a/src/main/java/appeng/client/render/model/RenderHelper.java +++ b/src/main/java/appeng/client/render/model/RenderHelper.java @@ -18,7 +18,6 @@ package appeng.client.render.model; - import java.util.EnumMap; import java.util.List; @@ -28,69 +27,62 @@ import com.google.common.collect.Lists; import net.minecraft.util.Direction; import net.minecraft.util.math.Vec3d; - // TODO: Investigate use of CubeBuilder instead -final class RenderHelper -{ +final class RenderHelper { - private static EnumMap> cornersForFacing = generateCornersForFacings(); + private static EnumMap> cornersForFacing = generateCornersForFacings(); - private RenderHelper() - { + private RenderHelper() { - } + } - static List getFaceCorners( Direction side ) - { - return cornersForFacing.get( side ); - } + static List getFaceCorners(Direction side) { + return cornersForFacing.get(side); + } - private static EnumMap> generateCornersForFacings() - { - EnumMap> result = new EnumMap<>( Direction.class ); + private static EnumMap> generateCornersForFacings() { + EnumMap> result = new EnumMap<>(Direction.class); - for( Direction facing : Direction.values() ) - { - List corners; + for (Direction facing : Direction.values()) { + List corners; - float offset = ( facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE ) ? 0 : 1; + float offset = (facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) ? 0 : 1; - switch( facing.getAxis() ) - { - default: - case X: - corners = Lists.newArrayList( new Vec3d( offset, 1, 1 ), new Vec3d( offset, 0, 1 ), new Vec3d( offset, 0, 0 ), new Vec3d( offset, 1, 0 ) ); - break; - case Y: - corners = Lists.newArrayList( new Vec3d( 1, offset, 1 ), new Vec3d( 1, offset, 0 ), new Vec3d( 0, offset, 0 ), new Vec3d( 0, offset, 1 ) ); - break; - case Z: - corners = Lists.newArrayList( new Vec3d( 0, 1, offset ), new Vec3d( 0, 0, offset ), new Vec3d( 1, 0, offset ), new Vec3d( 1, 1, offset ) ); - break; - } + switch (facing.getAxis()) { + default: + case X: + corners = Lists.newArrayList(new Vec3d(offset, 1, 1), new Vec3d(offset, 0, 1), + new Vec3d(offset, 0, 0), new Vec3d(offset, 1, 0)); + break; + case Y: + corners = Lists.newArrayList(new Vec3d(1, offset, 1), new Vec3d(1, offset, 0), + new Vec3d(0, offset, 0), new Vec3d(0, offset, 1)); + break; + case Z: + corners = Lists.newArrayList(new Vec3d(0, 1, offset), new Vec3d(0, 0, offset), + new Vec3d(1, 0, offset), new Vec3d(1, 1, offset)); + break; + } - if( facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE ) - { - corners = Lists.reverse( corners ); - } + if (facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) { + corners = Lists.reverse(corners); + } - result.put( facing, ImmutableList.copyOf( corners ) ); - } + result.put(facing, ImmutableList.copyOf(corners)); + } - return result; - } + return result; + } - private static Vec3d adjust( Vec3d vec, Direction.Axis axis, double delta ) - { - switch( axis ) - { - default: - case X: - return new Vec3d( vec.x + delta, vec.y, vec.z ); - case Y: - return new Vec3d( vec.x, vec.y + delta, vec.z ); - case Z: - return new Vec3d( vec.x, vec.y, vec.z + delta ); - } - } + private static Vec3d adjust(Vec3d vec, Direction.Axis axis, double delta) { + switch (axis) { + default: + case X: + return new Vec3d(vec.x + delta, vec.y, vec.z); + case Y: + return new Vec3d(vec.x, vec.y + delta, vec.z); + case Z: + return new Vec3d(vec.x, vec.y, vec.z + delta); + } + } } diff --git a/src/main/java/appeng/client/render/model/SkyCompassBakedModel.java b/src/main/java/appeng/client/render/model/SkyCompassBakedModel.java index c8f41afae..e879be048 100644 --- a/src/main/java/appeng/client/render/model/SkyCompassBakedModel.java +++ b/src/main/java/appeng/client/render/model/SkyCompassBakedModel.java @@ -18,7 +18,6 @@ package appeng.client.render.model; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -26,8 +25,6 @@ import java.util.Random; import javax.annotation.Nullable; -import appeng.hooks.CompassManager; -import appeng.hooks.CompassResult; import net.minecraft.block.BlockState; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.renderer.Matrix4f; @@ -44,188 +41,172 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.client.model.data.IDynamicBakedModel; - import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; +import appeng.hooks.CompassManager; +import appeng.hooks.CompassResult; /** - * This baked model combines the quads of a compass base and the quads of a compass pointer, which will be rotated - * around the Y-axis to get the compass to point in the right direction. + * This baked model combines the quads of a compass base and the quads of a + * compass pointer, which will be rotated around the Y-axis to get the compass + * to point in the right direction. */ -public class SkyCompassBakedModel implements IDynamicBakedModel -{ - // Rotation is expressed as radians - public static final ModelProperty ROTATION = new ModelProperty<>(); +public class SkyCompassBakedModel implements IDynamicBakedModel { + // Rotation is expressed as radians + public static final ModelProperty ROTATION = new ModelProperty<>(); - private final IBakedModel base; + private final IBakedModel base; - private final IBakedModel pointer; + private final IBakedModel pointer; - private float fallbackRotation = 0; + private float fallbackRotation = 0; - public SkyCompassBakedModel( IBakedModel base, IBakedModel pointer ) - { - this.base = base; - this.pointer = pointer; - } + public SkyCompassBakedModel(IBakedModel base, IBakedModel pointer) { + this.base = base; + this.pointer = pointer; + } - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData ) - { - float rotation = 0; - // Get rotation from the special block state - Float rotationFromData = extraData.getData(ROTATION); - if (rotationFromData != null) { - rotation = rotationFromData; - } - else - { - // This is used to render a compass pointing in a specific direction when being held in hand - rotation = this.fallbackRotation; - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData extraData) { + float rotation = 0; + // Get rotation from the special block state + Float rotationFromData = extraData.getData(ROTATION); + if (rotationFromData != null) { + rotation = rotationFromData; + } else { + // This is used to render a compass pointing in a specific direction when being + // held in hand + rotation = this.fallbackRotation; + } - // Pre-compute the quad count to avoid list resizes - List quads = new ArrayList<>(); - quads.addAll( this.base.getQuads( state, side, rand, extraData ) ); + // Pre-compute the quad count to avoid list resizes + List quads = new ArrayList<>(); + quads.addAll(this.base.getQuads(state, side, rand, extraData)); - // We'll add the pointer as "sideless" - if( side == null ) - { - // Set up the rotation around the Y-axis for the pointer - Matrix4f matrix = new Matrix4f(); - matrix.setIdentity(); - matrix.mul( new Quaternion( 0, rotation, 0, false ) ); + // We'll add the pointer as "sideless" + if (side == null) { + // Set up the rotation around the Y-axis for the pointer + Matrix4f matrix = new Matrix4f(); + matrix.setIdentity(); + matrix.mul(new Quaternion(0, rotation, 0, false)); - MatrixVertexTransformer transformer = new MatrixVertexTransformer( matrix ); - for( BakedQuad bakedQuad : this.pointer.getQuads( state, side, rand, extraData ) ) - { - BakedQuadBuilder builder = new BakedQuadBuilder(); + MatrixVertexTransformer transformer = new MatrixVertexTransformer(matrix); + for (BakedQuad bakedQuad : this.pointer.getQuads(state, side, rand, extraData)) { + BakedQuadBuilder builder = new BakedQuadBuilder(); - transformer.setParent( builder ); - transformer.setVertexFormat( builder.getVertexFormat() ); - bakedQuad.pipe( transformer ); - // FIXME: This entire code is no longer truly valid... - // FIXME builder.setQuadOrientation( null ); // After rotation, facing a specific side cannot be guaranteed - // anymore - BakedQuad q = builder.build(); - quads.add( q ); - } - } + transformer.setParent(builder); + transformer.setVertexFormat(builder.getVertexFormat()); + bakedQuad.pipe(transformer); + // FIXME: This entire code is no longer truly valid... + // FIXME builder.setQuadOrientation( null ); // After rotation, facing a + // specific side cannot be guaranteed + // anymore + BakedQuad q = builder.build(); + quads.add(q); + } + } - return quads; - } + return quads; + } - @Override - public boolean isAmbientOcclusion() - { - return this.base.isAmbientOcclusion(); - } + @Override + public boolean isAmbientOcclusion() { + return this.base.isAmbientOcclusion(); + } - @Override - public boolean isGui3d() - { - return true; - } + @Override + public boolean isGui3d() { + return true; + } - @Override - public boolean func_230044_c_() { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.base.getParticleTexture(); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.base.getParticleTexture(); + } - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return this.base.getItemCameraTransforms(); - } + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return this.base.getItemCameraTransforms(); + } - @Override - public ItemOverrideList getOverrides() - { - /* - * This handles setting the rotation of the compass when being held in hand. If it's not held in hand, it'll - * animate using the - * spinning animation. - */ - return new ItemOverrideList() - { - @Override - public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity) { - // FIXME: This check prevents compasses being held by OTHERS from getting the rotation, BUT do we actually still need this??? - if (world != null && entity instanceof ClientPlayerEntity) - { - PlayerEntity player = (PlayerEntity) entity; + @Override + public ItemOverrideList getOverrides() { + /* + * This handles setting the rotation of the compass when being held in hand. If + * it's not held in hand, it'll animate using the spinning animation. + */ + return new ItemOverrideList() { + @Override + public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, + @Nullable LivingEntity entity) { + // FIXME: This check prevents compasses being held by OTHERS from getting the + // rotation, BUT do we actually still need this??? + if (world != null && entity instanceof ClientPlayerEntity) { + PlayerEntity player = (PlayerEntity) entity; - float offRads = (float) ( player.rotationYaw / 180.0f * (float) Math.PI + Math.PI ); + float offRads = (float) (player.rotationYaw / 180.0f * (float) Math.PI + Math.PI); - SkyCompassBakedModel.this.fallbackRotation = offRads + getAnimatedRotation( player.getPosition(), true ); - } - else - { - SkyCompassBakedModel.this.fallbackRotation = getAnimatedRotation( null, false ); - } + SkyCompassBakedModel.this.fallbackRotation = offRads + + getAnimatedRotation(player.getPosition(), true); + } else { + SkyCompassBakedModel.this.fallbackRotation = getAnimatedRotation(null, false); + } - return originalModel; - } - }; - } + return originalModel; + } + }; + } - /** - * Gets the effective, animated rotation for the compass given the current position of the compass. - */ - public static float getAnimatedRotation( @Nullable BlockPos pos, boolean prefetch ) - { + /** + * Gets the effective, animated rotation for the compass given the current + * position of the compass. + */ + public static float getAnimatedRotation(@Nullable BlockPos pos, boolean prefetch) { - // Only query for a meteor position if we know our own position - if( pos != null ) - { - CompassResult cr = CompassManager.INSTANCE.getCompassDirection( 0, pos.getX(), pos.getY(), pos.getZ() ); + // Only query for a meteor position if we know our own position + if (pos != null) { + CompassResult cr = CompassManager.INSTANCE.getCompassDirection(0, pos.getX(), pos.getY(), pos.getZ()); - // Prefetch meteor positions from the server for adjacent blocks so they are available more quickly when - // we're moving - if( prefetch ) - { - for( int i = 0; i < 3; i++ ) - { - for( int j = 0; j < 3; j++ ) - { - CompassManager.INSTANCE.getCompassDirection( 0, pos.getX() + i - 1, pos.getY(), pos.getZ() + j - 1 ); - } - } - } + // Prefetch meteor positions from the server for adjacent blocks so they are + // available more quickly when + // we're moving + if (prefetch) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + CompassManager.INSTANCE.getCompassDirection(0, pos.getX() + i - 1, pos.getY(), + pos.getZ() + j - 1); + } + } + } - if( cr.isValidResult() ) - { - if( cr.isSpin() ) - { - long timeMillis = System.currentTimeMillis(); - // .5 seconds per full rotation - timeMillis %= 500; - return timeMillis / 500.f * (float) Math.PI * 2; - } - else - { - return (float) cr.getRad(); - } - } - } + if (cr.isValidResult()) { + if (cr.isSpin()) { + long timeMillis = System.currentTimeMillis(); + // .5 seconds per full rotation + timeMillis %= 500; + return timeMillis / 500.f * (float) Math.PI * 2; + } else { + return (float) cr.getRad(); + } + } + } - long timeMillis = System.currentTimeMillis(); - // 3 seconds per full rotation - timeMillis %= 3000; - return timeMillis / 3000.f * (float) Math.PI * 2; - } + long timeMillis = System.currentTimeMillis(); + // 3 seconds per full rotation + timeMillis %= 3000; + return timeMillis / 3000.f * (float) Math.PI * 2; + } } diff --git a/src/main/java/appeng/client/render/model/SkyCompassModel.java b/src/main/java/appeng/client/render/model/SkyCompassModel.java index a786e96a5..13b1a8e4f 100644 --- a/src/main/java/appeng/client/render/model/SkyCompassModel.java +++ b/src/main/java/appeng/client/render/model/SkyCompassModel.java @@ -18,44 +18,48 @@ package appeng.client.render.model; - -import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.IModelConfiguration; -import net.minecraftforge.client.model.geometry.IModelGeometry; - import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.function.Function; +import com.google.common.collect.ImmutableList; +import com.mojang.datafixers.util.Pair; + +import net.minecraft.client.renderer.model.*; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModelConfiguration; +import net.minecraftforge.client.model.geometry.IModelGeometry; /** - * The parent model for the compass baked model. Declares the dependencies for the base and pointer submodels mostly. + * The parent model for the compass baked model. Declares the dependencies for + * the base and pointer submodels mostly. */ -public class SkyCompassModel implements IModelGeometry -{ +public class SkyCompassModel implements IModelGeometry { - private static final ResourceLocation MODEL_BASE = new ResourceLocation( "appliedenergistics2:block/sky_compass_base" ); + private static final ResourceLocation MODEL_BASE = new ResourceLocation( + "appliedenergistics2:block/sky_compass_base"); - private static final ResourceLocation MODEL_POINTER = new ResourceLocation( "appliedenergistics2:block/sky_compass_pointer" ); + private static final ResourceLocation MODEL_POINTER = new ResourceLocation( + "appliedenergistics2:block/sky_compass_pointer"); - public static final List DEPENDENCIES = ImmutableList.of( MODEL_BASE, MODEL_POINTER ); + public static final List DEPENDENCIES = ImmutableList.of(MODEL_BASE, MODEL_POINTER); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); - IBakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter); - return new SkyCompassBakedModel(baseModel, pointerModel); - } + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); + IBakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter); + return new SkyCompassBakedModel(baseModel, pointerModel); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Collections.emptyList(); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Collections.emptyList(); + } } diff --git a/src/main/java/appeng/client/render/model/UVLModelLoader.java b/src/main/java/appeng/client/render/model/UVLModelLoader.java index 1e8d16060..ed9cd63e7 100644 --- a/src/main/java/appeng/client/render/model/UVLModelLoader.java +++ b/src/main/java/appeng/client/render/model/UVLModelLoader.java @@ -18,9 +18,21 @@ package appeng.client.render.model; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +import javax.annotation.Nullable; import com.google.gson.*; import com.mojang.blaze3d.matrix.MatrixStack; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.TransformationMatrix; @@ -40,160 +52,146 @@ import net.minecraftforge.client.model.geometry.IModelGeometry; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.client.model.pipeline.VertexLighterFlat; import net.minecraftforge.common.model.TransformationHelper; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import javax.annotation.Nullable; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; +public class UVLModelLoader implements IModelLoader { + public static final UVLModelLoader INSTANCE = new UVLModelLoader(); -public class UVLModelLoader implements IModelLoader -{ + @Override + public void onResourceManagerReload(IResourceManager resourceManager) { + } - public static final UVLModelLoader INSTANCE = new UVLModelLoader(); + @Override + public UVLModelWrapper read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { + modelContents.remove("loader"); + BlockModel blockModel = UVLSERIALIZER.fromJson(modelContents, BlockModel.class); + return new UVLModelWrapper(blockModel); + } - @Override - public void onResourceManagerReload(IResourceManager resourceManager) { - } + final Gson UVLSERIALIZER = (new GsonBuilder()) + .registerTypeAdapter(BlockModel.class, new ModelLoaderRegistry.ExpandedBlockModelDeserializer()) + .registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer()) + .registerTypeAdapter(BlockPartFace.class, new BlockPartFaceOverrideSerializer()) + .registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer()) + .registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer()) + .registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()) + .registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer()) + .registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer()).create(); - @Override - public UVLModelWrapper read(JsonDeserializationContext deserializationContext, JsonObject modelContents) { - modelContents.remove("loader"); - BlockModel blockModel = UVLSERIALIZER.fromJson(modelContents, BlockModel.class); - return new UVLModelWrapper(blockModel); - } + private static class BlockPartFaceOverrideSerializer extends BlockPartFace.Deserializer { + @Override + public BlockPartFace deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, + JsonDeserializationContext p_deserialize_3_) throws JsonParseException { + BlockPartFace blockFace = super.deserialize(p_deserialize_1_, p_deserialize_2_, p_deserialize_3_); + Pair uvl = this.parseUVL(p_deserialize_1_.getAsJsonObject()); + if (uvl != null) { + return new BlockPartFaceWithUVL(blockFace.cullFace, blockFace.tintIndex, blockFace.texture, + blockFace.blockFaceUV, uvl.getLeft(), uvl.getRight()); + } + return blockFace; + } - final Gson UVLSERIALIZER = (new GsonBuilder()) - .registerTypeAdapter(BlockModel.class, new ModelLoaderRegistry.ExpandedBlockModelDeserializer()) - .registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer()) - .registerTypeAdapter(BlockPartFace.class, new BlockPartFaceOverrideSerializer()) - .registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer()) - .registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer()) - .registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()) - .registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer()) - .registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer()) - .create(); + protected Pair parseUVL(JsonObject object) { + if (!object.has("uvlightmap")) { + return null; + } + object = object.get("uvlightmap").getAsJsonObject(); + return new ImmutablePair<>(JSONUtils.getFloat(object, "sky", 0), JSONUtils.getFloat(object, "block", 0)); + } + } - private static class BlockPartFaceOverrideSerializer extends BlockPartFace.Deserializer - { - @Override - public BlockPartFace deserialize( JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_ ) throws JsonParseException - { - BlockPartFace blockFace = super.deserialize(p_deserialize_1_, p_deserialize_2_, p_deserialize_3_); - Pair uvl = this.parseUVL(p_deserialize_1_.getAsJsonObject()); - if (uvl != null) { - return new BlockPartFaceWithUVL(blockFace.cullFace, blockFace.tintIndex, blockFace.texture, blockFace.blockFaceUV, uvl.getLeft(), uvl.getRight()); - } - return blockFace; - } + private static class BlockPartFaceWithUVL extends BlockPartFace { - protected Pair parseUVL( JsonObject object ) - { - if( !object.has( "uvlightmap" ) ) - { - return null; - } - object = object.get( "uvlightmap" ).getAsJsonObject(); - return new ImmutablePair<>( JSONUtils.getFloat( object, "sky", 0 ), JSONUtils.getFloat( object, "block", 0 ) ); - } - } + private final float sky; + private final float block; - private static class BlockPartFaceWithUVL extends BlockPartFace { + public BlockPartFaceWithUVL(@Nullable Direction cullFaceIn, int tintIndexIn, String textureIn, + BlockFaceUV blockFaceUVIn, float sky, float block) { + super(cullFaceIn, tintIndexIn, textureIn, blockFaceUVIn); + this.sky = sky; + this.block = block; + } - private final float sky; - private final float block; + public float getSky() { + return sky; + } - public BlockPartFaceWithUVL(@Nullable Direction cullFaceIn, int tintIndexIn, String textureIn, BlockFaceUV blockFaceUVIn, float sky, float block) { - super(cullFaceIn, tintIndexIn, textureIn, blockFaceUVIn); - this.sky = sky; - this.block = block; - } + public float getBlock() { + return block; + } + } - public float getSky() { - return sky; - } + public static class UVLModelWrapper implements IModelGeometry { + private final BlockModel parent; - public float getBlock() { - return block; - } - } + public UVLModelWrapper(BlockModel parent) { + this.parent = parent; + } - public static class UVLModelWrapper implements IModelGeometry - { - private final BlockModel parent; + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle")); - public UVLModelWrapper( BlockModel parent ) - { - this.parent = parent; - } + IModelBuilder builder = IModelBuilder.of(owner, overrides, particle); + for (BlockPart blockpart : parent.getElements()) { + for (Direction direction : blockpart.mapFaces.keySet()) { + BlockPartFace blockpartface = blockpart.mapFaces.get(direction); + TextureAtlasSprite textureatlassprite1 = spriteGetter + .apply(owner.resolveTexture(blockpartface.texture)); + BakedQuad quad = BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, + modelTransform, modelLocation); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle")); + if (blockpartface instanceof BlockPartFaceWithUVL) { + BlockPartFaceWithUVL uvlFace = (BlockPartFaceWithUVL) blockpartface; + quad = applyPreBakedLighting(quad, textureatlassprite1, uvlFace.sky, uvlFace.block); + } - IModelBuilder builder = IModelBuilder.of(owner, overrides, particle); - for(BlockPart blockpart : parent.getElements()) { - for(Direction direction : blockpart.mapFaces.keySet()) { - BlockPartFace blockpartface = blockpart.mapFaces.get(direction); - TextureAtlasSprite textureatlassprite1 = spriteGetter.apply(owner.resolveTexture(blockpartface.texture)); - BakedQuad quad = BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation); + if (blockpartface.cullFace == null) { + builder.addGeneralQuad(quad); + } else { + builder.addFaceQuad(modelTransform.getRotation().rotateTransform(blockpartface.cullFace), quad); + } + } + } + return builder.build(); + } - if (blockpartface instanceof BlockPartFaceWithUVL) { - BlockPartFaceWithUVL uvlFace = (BlockPartFaceWithUVL) blockpartface; - quad = applyPreBakedLighting(quad, textureatlassprite1, uvlFace.sky, uvlFace.block); - } + private BakedQuad applyPreBakedLighting(BakedQuad quad, TextureAtlasSprite sprite, float sky, float block) { + // FIXME: just piping through the quads and manipulating uv index 2 directly + // seems way easier than this + BakedQuadBuilder builder = new BakedQuadBuilder(sprite); + VertexLighterFlat trans = new VertexLighterFlat(Minecraft.getInstance().getBlockColors()) { - if (blockpartface.cullFace == null) { - builder.addGeneralQuad(quad); - } else { - builder.addFaceQuad( - modelTransform.getRotation().rotateTransform(blockpartface.cullFace), - quad); - } - } - } - return builder.build(); - } + @Override + protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z) { + lightmap[0] = block; + lightmap[1] = sky; + } - private BakedQuad applyPreBakedLighting(BakedQuad quad, TextureAtlasSprite sprite, float sky, float block) { - // FIXME: just piping through the quads and manipulating uv index 2 directly seems way easier than this - BakedQuadBuilder builder = new BakedQuadBuilder(sprite); - VertexLighterFlat trans = new VertexLighterFlat( Minecraft.getInstance().getBlockColors() ) - { + @Override + public void setQuadTint(int tint) { + // Tint requires a block state which we don't have at this point + } + }; + MatrixStack identity = new MatrixStack(); + trans.setTransform(identity.getLast()); + trans.setParent(builder); + quad.pipe(trans); + builder.setQuadTint(quad.getTintIndex()); + builder.setQuadOrientation(quad.getFace()); + builder.setApplyDiffuseLighting(false); + return builder.build(); + } - @Override - protected void updateLightmap( float[] normal, float[] lightmap, float x, float y, float z ) - { - lightmap[0] = block; - lightmap[1] = sky; - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, + Set> missingTextureErrors) { + return parent.getTextures(modelGetter, missingTextureErrors); + } - @Override - public void setQuadTint( int tint ) - { - // Tint requires a block state which we don't have at this point - } - }; - MatrixStack identity = new MatrixStack(); - trans.setTransform(identity.getLast()); - trans.setParent( builder ); - quad.pipe( trans ); - builder.setQuadTint( quad.getTintIndex() ); - builder.setQuadOrientation( quad.getFace() ); - builder.setApplyDiffuseLighting( false ); - return builder.build(); - } - - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return parent.getTextures(modelGetter, missingTextureErrors); - } - - } + } } diff --git a/src/main/java/appeng/client/render/renderable/ItemRenderable.java b/src/main/java/appeng/client/render/renderable/ItemRenderable.java index 05ce56dae..bce7ab55e 100644 --- a/src/main/java/appeng/client/render/renderable/ItemRenderable.java +++ b/src/main/java/appeng/client/render/renderable/ItemRenderable.java @@ -18,49 +18,42 @@ package appeng.client.render.renderable; - import java.nio.FloatBuffer; import java.util.function.Function; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.TransformationMatrix; -import net.minecraft.client.renderer.model.ItemCameraTransforms; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.BufferUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Matrix4f; +import net.minecraft.client.renderer.TransformationMatrix; +import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +public class ItemRenderable implements Renderable { -public class ItemRenderable implements Renderable -{ + private final Function> f; - private final Function> f; + public ItemRenderable(Function> f) { + this.f = f; + } - public ItemRenderable( Function> f ) - { - this.f = f; - } - - @Override - public void renderTileEntityAt(T te, float partialTicks, com.mojang.blaze3d.matrix.MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) - { - Pair pair = this.f.apply( te ); - if( pair != null && pair.getLeft() != null ) - { - if( pair.getRight() != null ) - { - pair.getRight().push(matrixStack); - } - else - { - matrixStack.push(); - } - Minecraft.getInstance().getItemRenderer().renderItem( pair.getLeft(), ItemCameraTransforms.TransformType.GROUND, combinedLight, combinedOverlay, matrixStack, buffers ); - matrixStack.pop(); - } - } + @Override + public void renderTileEntityAt(T te, float partialTicks, com.mojang.blaze3d.matrix.MatrixStack matrixStack, + IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) { + Pair pair = this.f.apply(te); + if (pair != null && pair.getLeft() != null) { + if (pair.getRight() != null) { + pair.getRight().push(matrixStack); + } else { + matrixStack.push(); + } + Minecraft.getInstance().getItemRenderer().renderItem(pair.getLeft(), + ItemCameraTransforms.TransformType.GROUND, combinedLight, combinedOverlay, matrixStack, buffers); + matrixStack.pop(); + } + } } diff --git a/src/main/java/appeng/client/render/renderable/Renderable.java b/src/main/java/appeng/client/render/renderable/Renderable.java index 6bdaf8df4..e6b3410e5 100644 --- a/src/main/java/appeng/client/render/renderable/Renderable.java +++ b/src/main/java/appeng/client/render/renderable/Renderable.java @@ -18,15 +18,14 @@ package appeng.client.render.renderable; - import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.tileentity.TileEntity; +public interface Renderable { -public interface Renderable -{ - - void renderTileEntityAt(T te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay); + void renderTileEntityAt(T te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, + int combinedLight, int combinedOverlay); } diff --git a/src/main/java/appeng/client/render/spatial/SpatialPylonBakedModel.java b/src/main/java/appeng/client/render/spatial/SpatialPylonBakedModel.java index df165ba39..fdc004793 100644 --- a/src/main/java/appeng/client/render/spatial/SpatialPylonBakedModel.java +++ b/src/main/java/appeng/client/render/spatial/SpatialPylonBakedModel.java @@ -18,10 +18,15 @@ package appeng.client.render.spatial; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.client.render.cablebus.CubeBuilder; -import appeng.tile.spatial.TileSpatialPylon; import com.google.common.collect.ImmutableMap; + import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.ItemOverrideList; @@ -30,217 +35,174 @@ import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Map; -import java.util.Random; - +import appeng.client.render.cablebus.CubeBuilder; +import appeng.tile.spatial.TileSpatialPylon; /** * The baked model that will be used for rendering the spatial pylon. */ -class SpatialPylonBakedModel implements IDynamicBakedModel -{ +class SpatialPylonBakedModel implements IDynamicBakedModel { - private final Map textures; + private final Map textures; - SpatialPylonBakedModel( Map textures ) - { - this.textures = ImmutableMap.copyOf( textures ); - } + SpatialPylonBakedModel(Map textures) { + this.textures = ImmutableMap.copyOf(textures); + } - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { - int flags = this.getFlags( extraData ); + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, + @Nonnull IModelData extraData) { + int flags = this.getFlags(extraData); - CubeBuilder builder = new CubeBuilder(); + CubeBuilder builder = new CubeBuilder(); - if( flags != 0 ) - { - Direction ori = null; - int displayAxis = flags & TileSpatialPylon.DISPLAY_Z; - if( displayAxis == TileSpatialPylon.DISPLAY_X ) - { - ori = Direction.EAST; + if (flags != 0) { + Direction ori = null; + int displayAxis = flags & TileSpatialPylon.DISPLAY_Z; + if (displayAxis == TileSpatialPylon.DISPLAY_X) { + ori = Direction.EAST; - if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MAX ) - { - builder.setUvRotation( Direction.SOUTH, 1 ); - builder.setUvRotation( Direction.NORTH, 1 ); - builder.setUvRotation( Direction.UP, 2 ); - builder.setUvRotation( Direction.DOWN, 2 ); - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MIN ) - { - builder.setUvRotation( Direction.SOUTH, 2 ); - builder.setUvRotation( Direction.NORTH, 2 ); - builder.setUvRotation( Direction.UP, 1 ); - builder.setUvRotation( Direction.DOWN, 1 ); - } - else - { - builder.setUvRotation( Direction.SOUTH, 1 ); - builder.setUvRotation( Direction.NORTH, 1 ); - builder.setUvRotation( Direction.UP, 1 ); - builder.setUvRotation( Direction.DOWN, 1 ); - } - } + if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MAX) { + builder.setUvRotation(Direction.SOUTH, 1); + builder.setUvRotation(Direction.NORTH, 1); + builder.setUvRotation(Direction.UP, 2); + builder.setUvRotation(Direction.DOWN, 2); + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MIN) { + builder.setUvRotation(Direction.SOUTH, 2); + builder.setUvRotation(Direction.NORTH, 2); + builder.setUvRotation(Direction.UP, 1); + builder.setUvRotation(Direction.DOWN, 1); + } else { + builder.setUvRotation(Direction.SOUTH, 1); + builder.setUvRotation(Direction.NORTH, 1); + builder.setUvRotation(Direction.UP, 1); + builder.setUvRotation(Direction.DOWN, 1); + } + } - else if( displayAxis == TileSpatialPylon.DISPLAY_Y ) - { - ori = Direction.UP; - if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MAX ) - { - builder.setUvRotation( Direction.NORTH, 3 ); - builder.setUvRotation( Direction.SOUTH, 3 ); - builder.setUvRotation( Direction.EAST, 3 ); - builder.setUvRotation( Direction.WEST, 3 ); - } - } + else if (displayAxis == TileSpatialPylon.DISPLAY_Y) { + ori = Direction.UP; + if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MAX) { + builder.setUvRotation(Direction.NORTH, 3); + builder.setUvRotation(Direction.SOUTH, 3); + builder.setUvRotation(Direction.EAST, 3); + builder.setUvRotation(Direction.WEST, 3); + } + } - else if( displayAxis == TileSpatialPylon.DISPLAY_Z ) - { - ori = Direction.NORTH; - if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MAX ) - { - builder.setUvRotation( Direction.EAST, 2 ); - builder.setUvRotation( Direction.WEST, 1 ); - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MIN ) - { - builder.setUvRotation( Direction.EAST, 1 ); - builder.setUvRotation( Direction.WEST, 2 ); - builder.setUvRotation( Direction.UP, 3 ); - builder.setUvRotation( Direction.DOWN, 3 ); - } - else - { - builder.setUvRotation( Direction.EAST, 1 ); - builder.setUvRotation( Direction.WEST, 2 ); - } - } + else if (displayAxis == TileSpatialPylon.DISPLAY_Z) { + ori = Direction.NORTH; + if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MAX) { + builder.setUvRotation(Direction.EAST, 2); + builder.setUvRotation(Direction.WEST, 1); + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MIN) { + builder.setUvRotation(Direction.EAST, 1); + builder.setUvRotation(Direction.WEST, 2); + builder.setUvRotation(Direction.UP, 3); + builder.setUvRotation(Direction.DOWN, 3); + } else { + builder.setUvRotation(Direction.EAST, 1); + builder.setUvRotation(Direction.WEST, 2); + } + } - builder.setTextures( this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.UP ) ), - this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.DOWN ) ), - this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.NORTH ) ), - this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.SOUTH ) ), - this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.EAST ) ), - this.textures.get( getTextureTypeFromSideOutside( flags, ori, Direction.WEST ) ) ); - builder.addCube( 0, 0, 0, 16, 16, 16 ); + builder.setTextures(this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.UP)), + this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.DOWN)), + this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.NORTH)), + this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.SOUTH)), + this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.EAST)), + this.textures.get(getTextureTypeFromSideOutside(flags, ori, Direction.WEST))); + builder.addCube(0, 0, 0, 16, 16, 16); - if( ( flags & TileSpatialPylon.DISPLAY_POWERED_ENABLED ) == TileSpatialPylon.DISPLAY_POWERED_ENABLED ) - { - builder.setRenderFullBright( true ); - } + if ((flags & TileSpatialPylon.DISPLAY_POWERED_ENABLED) == TileSpatialPylon.DISPLAY_POWERED_ENABLED) { + builder.setRenderFullBright(true); + } - builder.setTextures( this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.UP ) ), - this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.DOWN ) ), - this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.NORTH ) ), - this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.SOUTH ) ), - this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.EAST ) ), - this.textures.get( getTextureTypeFromSideInside( flags, ori, Direction.WEST ) ) ); - builder.addCube( 0, 0, 0, 16, 16, 16 ); - } - else - { - builder.setTexture( this.textures.get( SpatialPylonTextureType.BASE ) ); - builder.addCube( 0, 0, 0, 16, 16, 16 ); + builder.setTextures(this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.UP)), + this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.DOWN)), + this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.NORTH)), + this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.SOUTH)), + this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.EAST)), + this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.WEST))); + builder.addCube(0, 0, 0, 16, 16, 16); + } else { + builder.setTexture(this.textures.get(SpatialPylonTextureType.BASE)); + builder.addCube(0, 0, 0, 16, 16, 16); - builder.setTexture( this.textures.get( SpatialPylonTextureType.DIM ) ); - builder.addCube( 0, 0, 0, 16, 16, 16 ); - } + builder.setTexture(this.textures.get(SpatialPylonTextureType.DIM)); + builder.addCube(0, 0, 0, 16, 16, 16); + } - return builder.getOutput(); - } + return builder.getOutput(); + } - private int getFlags( IModelData modelData ) - { - Integer flags = modelData.getData(TileSpatialPylon.STATE); - return flags != null ? flags : 0; - } + private int getFlags(IModelData modelData) { + Integer flags = modelData.getData(TileSpatialPylon.STATE); + return flags != null ? flags : 0; + } - private static SpatialPylonTextureType getTextureTypeFromSideOutside( int flags, Direction ori, Direction dir ) - { - if( ori == dir || ori.getOpposite() == dir ) - { - return SpatialPylonTextureType.BASE; - } + private static SpatialPylonTextureType getTextureTypeFromSideOutside(int flags, Direction ori, Direction dir) { + if (ori == dir || ori.getOpposite() == dir) { + return SpatialPylonTextureType.BASE; + } - if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_MIDDLE ) - { - return SpatialPylonTextureType.BASE_SPANNED; - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MIN ) - { - return SpatialPylonTextureType.BASE_END; - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MAX ) - { - return SpatialPylonTextureType.BASE_END; - } + if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_MIDDLE) { + return SpatialPylonTextureType.BASE_SPANNED; + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MIN) { + return SpatialPylonTextureType.BASE_END; + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MAX) { + return SpatialPylonTextureType.BASE_END; + } - return SpatialPylonTextureType.BASE; - } + return SpatialPylonTextureType.BASE; + } - private static SpatialPylonTextureType getTextureTypeFromSideInside( int flags, Direction ori, Direction dir ) - { - final boolean good = ( flags & TileSpatialPylon.DISPLAY_ENABLED ) == TileSpatialPylon.DISPLAY_ENABLED; + private static SpatialPylonTextureType getTextureTypeFromSideInside(int flags, Direction ori, Direction dir) { + final boolean good = (flags & TileSpatialPylon.DISPLAY_ENABLED) == TileSpatialPylon.DISPLAY_ENABLED; - if( ori == dir || ori.getOpposite() == dir ) - { - return good ? SpatialPylonTextureType.DIM : SpatialPylonTextureType.RED; - } + if (ori == dir || ori.getOpposite() == dir) { + return good ? SpatialPylonTextureType.DIM : SpatialPylonTextureType.RED; + } - if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_MIDDLE ) - { - return good ? SpatialPylonTextureType.DIM_SPANNED : SpatialPylonTextureType.RED_SPANNED; - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MIN ) - { - return good ? SpatialPylonTextureType.DIM_END : SpatialPylonTextureType.RED_END; - } - else if( ( flags & TileSpatialPylon.DISPLAY_MIDDLE ) == TileSpatialPylon.DISPLAY_END_MAX ) - { - return good ? SpatialPylonTextureType.DIM_END : SpatialPylonTextureType.RED_END; - } + if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_MIDDLE) { + return good ? SpatialPylonTextureType.DIM_SPANNED : SpatialPylonTextureType.RED_SPANNED; + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MIN) { + return good ? SpatialPylonTextureType.DIM_END : SpatialPylonTextureType.RED_END; + } else if ((flags & TileSpatialPylon.DISPLAY_MIDDLE) == TileSpatialPylon.DISPLAY_END_MAX) { + return good ? SpatialPylonTextureType.DIM_END : SpatialPylonTextureType.RED_END; + } - return SpatialPylonTextureType.BASE; - } + return SpatialPylonTextureType.BASE; + } - @Override - public boolean func_230044_c_() { - return false; - } + @Override + public boolean func_230044_c_() { + return false; + } - @Override - public boolean isAmbientOcclusion() - { - return true; - } + @Override + public boolean isAmbientOcclusion() { + return true; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.textures.get( SpatialPylonTextureType.DIM ); - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.textures.get(SpatialPylonTextureType.DIM); + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } } diff --git a/src/main/java/appeng/client/render/spatial/SpatialPylonModel.java b/src/main/java/appeng/client/render/spatial/SpatialPylonModel.java index 704fd3908..f5484f443 100644 --- a/src/main/java/appeng/client/render/spatial/SpatialPylonModel.java +++ b/src/main/java/appeng/client/render/spatial/SpatialPylonModel.java @@ -18,9 +18,12 @@ package appeng.client.render.spatial; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; -import appeng.core.AppEng; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -28,36 +31,33 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; +import appeng.core.AppEng; +public class SpatialPylonModel implements IModelGeometry { -public class SpatialPylonModel implements IModelGeometry -{ + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + Map textures = new EnumMap<>(SpatialPylonTextureType.class); - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - Map textures = new EnumMap<>( SpatialPylonTextureType.class ); + for (SpatialPylonTextureType type : SpatialPylonTextureType.values()) { + textures.put(type, spriteGetter.apply(getTexturePath(type))); + } - for( SpatialPylonTextureType type : SpatialPylonTextureType.values() ) - { - textures.put( type, spriteGetter.apply(getTexturePath( type )) ); - } + return new SpatialPylonBakedModel(textures); + } - return new SpatialPylonBakedModel( textures ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Arrays.stream(SpatialPylonTextureType.values()).map(SpatialPylonModel::getTexturePath) + .collect(Collectors.toList()); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Arrays.stream( SpatialPylonTextureType.values() ) - .map( SpatialPylonModel::getTexturePath ) - .collect( Collectors.toList() ); - } - - private static Material getTexturePath( SpatialPylonTextureType type ) - { - return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase() ) ); - } + private static Material getTexturePath(SpatialPylonTextureType type) { + return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase())); + } } diff --git a/src/main/java/appeng/client/render/spatial/SpatialPylonRendering.java b/src/main/java/appeng/client/render/spatial/SpatialPylonRendering.java index bf9a7614b..242961876 100644 --- a/src/main/java/appeng/client/render/spatial/SpatialPylonRendering.java +++ b/src/main/java/appeng/client/render/spatial/SpatialPylonRendering.java @@ -18,7 +18,6 @@ package appeng.client.render.spatial; - import java.util.Map; import com.google.common.collect.ImmutableMap; @@ -35,24 +34,24 @@ import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IItemRendering; import appeng.core.AppEng; +public class SpatialPylonRendering extends BlockRenderingCustomizer { -public class SpatialPylonRendering extends BlockRenderingCustomizer -{ + private static final ResourceLocation MODEL_ID = new ResourceLocation(AppEng.MOD_ID, + "models/blocks/spatial_pylon/builtin"); - private static final ResourceLocation MODEL_ID = new ResourceLocation( AppEng.MOD_ID, "models/blocks/spatial_pylon/builtin" ); + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + // FIXME rendering.builtInModel( MODEL_ID.getResourcePath(), new + // SpatialPylonModel() ); + // FIXME rendering.stateMapper( this::mapState ); + } - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IBlockRendering rendering, IItemRendering itemRendering ) - { - rendering.renderType(RenderType.getCutout()); - // FIXME rendering.builtInModel( MODEL_ID.getResourcePath(), new SpatialPylonModel() ); - // FIXME rendering.stateMapper( this::mapState ); - } - - // FIXME private Map mapState( Block block ) - // FIXME { - // FIXME return ImmutableMap.of( block.getDefaultState(), new ModelResourceLocation( MODEL_ID, "normal" ) ); - // FIXME } + // FIXME private Map mapState( Block block ) + // FIXME { + // FIXME return ImmutableMap.of( block.getDefaultState(), new + // ModelResourceLocation( MODEL_ID, "normal" ) ); + // FIXME } } diff --git a/src/main/java/appeng/client/render/spatial/SpatialPylonTextureType.java b/src/main/java/appeng/client/render/spatial/SpatialPylonTextureType.java index 47390f53e..b494440aa 100644 --- a/src/main/java/appeng/client/render/spatial/SpatialPylonTextureType.java +++ b/src/main/java/appeng/client/render/spatial/SpatialPylonTextureType.java @@ -18,8 +18,6 @@ package appeng.client.render.spatial; - -enum SpatialPylonTextureType -{ - BASE, BASE_END, BASE_SPANNED, DIM, DIM_END, DIM_SPANNED, RED, RED_END, RED_SPANNED +enum SpatialPylonTextureType { + BASE, BASE_END, BASE_SPANNED, DIM, DIM_END, DIM_SPANNED, RED, RED_END, RED_SPANNED } diff --git a/src/main/java/appeng/client/render/tesr/CrankTESR.java b/src/main/java/appeng/client/render/tesr/CrankTESR.java index 02ee93eca..13f8a22f1 100644 --- a/src/main/java/appeng/client/render/tesr/CrankTESR.java +++ b/src/main/java/appeng/client/render/tesr/CrankTESR.java @@ -18,20 +18,20 @@ package appeng.client.render.tesr; - import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; + import org.lwjgl.opengl.GL11; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -39,36 +39,37 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.client.render.FacingToRotation; import appeng.tile.grindstone.TileCrank; - /** - * This FastTESR only handles the animated model of the turning crank. When the crank is at rest, it is rendered using a - * normal model. + * This FastTESR only handles the animated model of the turning crank. When the + * crank is at rest, it is rendered using a normal model. */ -@OnlyIn( Dist.CLIENT ) -public class CrankTESR extends TileEntityRenderer -{ +@OnlyIn(Dist.CLIENT) +public class CrankTESR extends TileEntityRenderer { - public CrankTESR(TileEntityRendererDispatcher rendererDispatcherIn) { - super(rendererDispatcherIn); - } + public CrankTESR(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } - @Override - public void render(TileCrank te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) { + @Override + public void render(TileCrank te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, + int combinedOverlayIn) { - // Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation - ms.push(); - ms.translate( 0.5, 0.5, 0.5 ); - FacingToRotation.get( te.getForward(), te.getUp() ).push(ms); - ms.rotate( new Quaternion(0, te.getVisibleRotation(), 0, true) ); - ms.translate( -0.5, -0.5, -0.5 ); + // Apply GL transformations relative to the center of the block: 1) TE rotation + // and 2) crank rotation + ms.push(); + ms.translate(0.5, 0.5, 0.5); + FacingToRotation.get(te.getForward(), te.getUp()).push(ms); + ms.rotate(new Quaternion(0, te.getVisibleRotation(), 0, true)); + ms.translate(-0.5, -0.5, -0.5); - BlockState blockState = te.getWorld().getBlockState( te.getPos() ); // FIXME: i think world might be null here - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); - IBakedModel model = dispatcher.getModelForState( blockState ); - IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType()); - dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn); - ms.pop(); + BlockState blockState = te.getWorld().getBlockState(te.getPos()); // FIXME: i think world might be null here + BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + IBakedModel model = dispatcher.getModelForState(blockState); + IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType()); + dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1, + combinedLightIn, combinedOverlayIn); + ms.pop(); - } + } } diff --git a/src/main/java/appeng/client/render/tesr/DriveLedTileEntityRenderer.java b/src/main/java/appeng/client/render/tesr/DriveLedTileEntityRenderer.java index 591351e9b..9584c0728 100644 --- a/src/main/java/appeng/client/render/tesr/DriveLedTileEntityRenderer.java +++ b/src/main/java/appeng/client/render/tesr/DriveLedTileEntityRenderer.java @@ -1,10 +1,10 @@ package appeng.client.render.tesr; -import appeng.block.storage.DriveSlotState; -import appeng.client.render.FacingToRotation; -import appeng.tile.storage.TileDrive; +import java.util.EnumMap; + import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -13,7 +13,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import java.util.EnumMap; +import appeng.block.storage.DriveSlotState; +import appeng.client.render.FacingToRotation; +import appeng.tile.storage.TileDrive; /** * Renders the drive cell status indicators. @@ -34,52 +36,37 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer { STATE_COLORS.put(DriveSlotState.FULL, new Vector3f(1, 0, 0)); } - private static final float L = 14/16.f; // left (x-axis) - private static final float R = 13/16.f; // right (x-axis) - private static final float T = 14/16.f; // top (x-axis) - private static final float B = 12.999f/16.f; // bottom (x-axis) - private static final float FR = 0.4f/16.f; // front (z-axis) - private static final float BA = 1/16.f; // back (z-axis) + private static final float L = 14 / 16.f; // left (x-axis) + private static final float R = 13 / 16.f; // right (x-axis) + private static final float T = 14 / 16.f; // top (x-axis) + private static final float B = 12.999f / 16.f; // bottom (x-axis) + private static final float FR = 0.4f / 16.f; // front (z-axis) + private static final float BA = 1 / 16.f; // back (z-axis) // Vertex data for the LED cuboid (has no back) // Directions are when looking from the front onto the LED private static final float[] LED_QUADS = { // Front Face - R, T, FR, - L, T, FR, - L, B, FR, - R, B, FR, + R, T, FR, L, T, FR, L, B, FR, R, B, FR, // Left Face - L, T, FR, - L, T, BA, - L, B, BA, - L, B, FR, + L, T, FR, L, T, BA, L, B, BA, L, B, FR, // Right Face - R, T, BA, - R, T, FR, - R, B, FR, - R, B, BA, + R, T, BA, R, T, FR, R, B, FR, R, B, BA, // Top Face - R, T, BA, - L, T, BA, - L, T, FR, - R, T, FR, + R, T, BA, L, T, BA, L, T, FR, R, T, FR, // Bottom Face - R, B, FR, - L, B, FR, - L, B, BA, - R, B, BA, - }; + R, B, FR, L, B, FR, L, B, BA, R, B, BA, }; - private static final RenderType STATE = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder() - .build(false)); + private static final RenderType STATE = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, + 32565, false, true, RenderType.State.getBuilder().build(false)); public DriveLedTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } @Override - public void render(TileDrive drive, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) { + public void render(TileDrive drive, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, + int combinedLightIn, int combinedOverlayIn) { if (drive.getCellCount() != 10) { throw new IllegalStateException("Expected drive to have 10 slots"); @@ -90,10 +77,10 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer { FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms); ms.translate(-0.5, -0.5, -0.5); - RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_"); - RenderType rt =RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder() - .transparency(TRANSLUCENT_TRANSPARENCY) - .build(false)); + RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper + .getPrivateValue(RenderState.class, null, "field_228515_g_"); + RenderType rt = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, + RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).build(false)); IVertexBuilder buffer = buffers.getBuffer(STATE); for (int row = 0; row < 5; row++) { @@ -106,7 +93,8 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer { ms.push(); - // Position this drive model copy at the correct slot. The transform is based on the + // Position this drive model copy at the correct slot. The transform is based on + // the // cell-model being in slot 0,0 at the top left of the drive. float xOffset = -col * 7 / 16.0f; float yOffset = -row * 3 / 16.0f; @@ -114,9 +102,10 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer { for (int i = 0; i < LED_QUADS.length; i += 3) { float x = LED_QUADS[i]; - float y = LED_QUADS[i+1]; - float z = LED_QUADS[i+2]; - buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f).endVertex(); + float y = LED_QUADS[i + 1]; + float z = LED_QUADS[i + 2]; + buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f) + .endVertex(); } ms.pop(); diff --git a/src/main/java/appeng/client/render/tesr/InscriberTESR.java b/src/main/java/appeng/client/render/tesr/InscriberTESR.java index 6934f3e30..f75c8ae74 100644 --- a/src/main/java/appeng/client/render/tesr/InscriberTESR.java +++ b/src/main/java/appeng/client/render/tesr/InscriberTESR.java @@ -1,19 +1,16 @@ package appeng.client.render.tesr; - -import appeng.api.features.InscriberProcessType; -import appeng.recipes.handlers.InscriberRecipe; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; - -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; @@ -21,203 +18,209 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.items.IItemHandler; +import appeng.api.features.InscriberProcessType; import appeng.client.render.FacingToRotation; import appeng.core.AppEng; +import appeng.recipes.handlers.InscriberRecipe; import appeng.tile.misc.TileInscriber; - /** - * Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed) + * Renders the dynamic parts of an inscriber (the presses, the animation and the + * item being smashed) */ -public final class InscriberTESR extends TileEntityRenderer -{ +public final class InscriberTESR extends TileEntityRenderer { - private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f; + private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f; - private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/inscriber_inside" )); + private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE, + new ResourceLocation(AppEng.MOD_ID, "block/inscriber_inside")); - public InscriberTESR(TileEntityRendererDispatcher rendererDispatcherIn) { - super(rendererDispatcherIn); - } + public InscriberTESR(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } - @Override - public void render(TileInscriber tile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) { + @Override + public void render(TileInscriber tile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, + int combinedLight, int combinedOverlay) { - // render inscriber + // render inscriber - ms.push(); - ms.translate( 0.5F, 0.5F, 0.5F ); - FacingToRotation.get( tile.getForward(), tile.getUp() ).push(ms); - ms.translate( -0.5F, -0.5F, -0.5F ); + ms.push(); + ms.translate(0.5F, 0.5F, 0.5F); + FacingToRotation.get(tile.getForward(), tile.getUp()).push(ms); + ms.translate(-0.5F, -0.5F, -0.5F); - // render sides of stamps + // render sides of stamps - long absoluteProgress = 0; + long absoluteProgress = 0; - if( tile.isSmash() ) - { - final long currentTime = System.currentTimeMillis(); - absoluteProgress = currentTime - tile.getClientStart(); - if( absoluteProgress > 800 ) - { - tile.setSmash( false ); - } - } + if (tile.isSmash()) { + final long currentTime = System.currentTimeMillis(); + absoluteProgress = currentTime - tile.getClientStart(); + if (absoluteProgress > 800) { + tile.setSmash(false); + } + } - final float relativeProgress = absoluteProgress % 800 / 400.0f; - float progress = relativeProgress; + final float relativeProgress = absoluteProgress % 800 / 400.0f; + float progress = relativeProgress; - if( progress > 1.0f ) - { - progress = 1.0f - ( easeDecompressMotion(progress - 1.0f) ); - } else { - progress = easeCompressMotion(progress); - } + if (progress > 1.0f) { + progress = 1.0f - (easeDecompressMotion(progress - 1.0f)); + } else { + progress = easeCompressMotion(progress); + } - float press = 0.2f; - press -= progress / 5.0f; + float press = 0.2f; + press -= progress / 5.0f; - float middle = 0.5f; - middle += 0.02f; - final float TwoPx = 2.0f / 16.0f; - final float base = 0.4f; + float middle = 0.5f; + middle += 0.02f; + final float TwoPx = 2.0f / 16.0f; + final float base = 0.4f; - final TextureAtlasSprite tas = TEXTURE_INSIDE.getSprite(); + final TextureAtlasSprite tas = TEXTURE_INSIDE.getSprite(); - IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid()); + IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid()); - // Bottom of Top Stamp - addVertex( buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 13 , combinedOverlay, combinedLight, Direction.DOWN); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 13 , combinedOverlay, combinedLight, Direction.DOWN); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, 1.0f - TwoPx, 14, 2 , combinedOverlay, combinedLight, Direction.DOWN); - addVertex( buffer, ms, tas, TwoPx, middle + press, 1.0f - TwoPx, 2, 2 , combinedOverlay, combinedLight, Direction.DOWN); + // Bottom of Top Stamp + addVertex(buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 13, combinedOverlay, combinedLight, Direction.DOWN); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 13, combinedOverlay, combinedLight, + Direction.DOWN); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, 1.0f - TwoPx, 14, 2, combinedOverlay, combinedLight, + Direction.DOWN); + addVertex(buffer, ms, tas, TwoPx, middle + press, 1.0f - TwoPx, 2, 2, combinedOverlay, combinedLight, + Direction.DOWN); - // Front of Top Stamp - addVertex( buffer, ms, tas, TwoPx, middle + base, TwoPx, 2, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + base, TwoPx, 14, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 3 , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 3 , combinedOverlay, combinedLight, Direction.NORTH); + // Front of Top Stamp + addVertex(buffer, ms, tas, TwoPx, middle + base, TwoPx, 2, 3 - 16 * (press - base), combinedOverlay, + combinedLight, Direction.NORTH); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + base, TwoPx, 14, 3 - 16 * (press - base), combinedOverlay, + combinedLight, Direction.NORTH); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 3, combinedOverlay, combinedLight, + Direction.NORTH); + addVertex(buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 3, combinedOverlay, combinedLight, Direction.NORTH); - // Top of Bottom Stamp - middle -= 2.0f * 0.02f; - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 13 , combinedOverlay, combinedLight, Direction.UP); - addVertex( buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 13 , combinedOverlay, combinedLight, Direction.UP); - addVertex( buffer, ms, tas, TwoPx, middle - press, 1.0f - TwoPx, 14, 2 , combinedOverlay, combinedLight, Direction.UP); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, 1.0f - TwoPx, 2, 2 , combinedOverlay, combinedLight, Direction.UP); + // Top of Bottom Stamp + middle -= 2.0f * 0.02f; + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 13, combinedOverlay, combinedLight, + Direction.UP); + addVertex(buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 13, combinedOverlay, combinedLight, Direction.UP); + addVertex(buffer, ms, tas, TwoPx, middle - press, 1.0f - TwoPx, 14, 2, combinedOverlay, combinedLight, + Direction.UP); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, 1.0f - TwoPx, 2, 2, combinedOverlay, combinedLight, + Direction.UP); - // Front of Bottom Stamp - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + -base, TwoPx, 2, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, TwoPx, middle - base, TwoPx, 14, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 3 , combinedOverlay, combinedLight, Direction.NORTH); - addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 3 , combinedOverlay, combinedLight, Direction.NORTH); + // Front of Bottom Stamp + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + -base, TwoPx, 2, 3 - 16 * (press - base), combinedOverlay, + combinedLight, Direction.NORTH); + addVertex(buffer, ms, tas, TwoPx, middle - base, TwoPx, 14, 3 - 16 * (press - base), combinedOverlay, + combinedLight, Direction.NORTH); + addVertex(buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 3, combinedOverlay, combinedLight, + Direction.NORTH); + addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 3, combinedOverlay, combinedLight, + Direction.NORTH); - // render items. + // render items. - IItemHandler tileInv = tile.getInternalInventory(); + IItemHandler tileInv = tile.getInternalInventory(); - int items = 0; - if( !tileInv.getStackInSlot( 0 ).isEmpty() ) - { - items++; - } - if( !tileInv.getStackInSlot( 1 ).isEmpty() ) - { - items++; - } - if( !tileInv.getStackInSlot( 2 ).isEmpty() ) - { - items++; - } + int items = 0; + if (!tileInv.getStackInSlot(0).isEmpty()) { + items++; + } + if (!tileInv.getStackInSlot(1).isEmpty()) { + items++; + } + if (!tileInv.getStackInSlot(2).isEmpty()) { + items++; + } - boolean renderPresses; - if( relativeProgress > 1.0f || items == 0 ) - { - // When crafting completes, dont render the presses (they mave have been consumed, see below) - renderPresses = false; + boolean renderPresses; + if (relativeProgress > 1.0f || items == 0) { + // When crafting completes, dont render the presses (they mave have been + // consumed, see below) + renderPresses = false; - ItemStack is = tileInv.getStackInSlot( 3 ); + ItemStack is = tileInv.getStackInSlot(3); - if( is.isEmpty() ) - { - final InscriberRecipe ir = tile.getTask(); - if( ir != null ) - { - // The "PRESS" type will consume the presses so they should not render after completing - // the press animation - renderPresses = ir.getProcessType() == InscriberProcessType.INSCRIBE; - is = ir.getOutput().copy(); - } - } - this.renderItem( ms, is, 0.0f, buffers, combinedLight, combinedOverlay ); - } - else - { - renderPresses = true; - this.renderItem( ms, tileInv.getStackInSlot( 2 ), 0.0f, buffers, combinedLight, combinedOverlay ); - } + if (is.isEmpty()) { + final InscriberRecipe ir = tile.getTask(); + if (ir != null) { + // The "PRESS" type will consume the presses so they should not render after + // completing + // the press animation + renderPresses = ir.getProcessType() == InscriberProcessType.INSCRIBE; + is = ir.getOutput().copy(); + } + } + this.renderItem(ms, is, 0.0f, buffers, combinedLight, combinedOverlay); + } else { + renderPresses = true; + this.renderItem(ms, tileInv.getStackInSlot(2), 0.0f, buffers, combinedLight, combinedOverlay); + } - if (renderPresses) { - this.renderItem( ms, tileInv.getStackInSlot( 0 ), press, buffers, combinedLight, combinedOverlay ); - this.renderItem( ms, tileInv.getStackInSlot( 1 ), -press, buffers, combinedLight, combinedOverlay ); - } + if (renderPresses) { + this.renderItem(ms, tileInv.getStackInSlot(0), press, buffers, combinedLight, combinedOverlay); + this.renderItem(ms, tileInv.getStackInSlot(1), -press, buffers, combinedLight, combinedOverlay); + } - ms.pop(); - } + ms.pop(); + } - private static void addVertex(IVertexBuilder vb, MatrixStack ms, TextureAtlasSprite sprite, float x, float y, float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) { - vb.pos(ms.getLast().getMatrix(), x, y, z); - vb.color(1.0f, 1.0f, 1.0f, 1.0f); - vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV)); - vb.overlay(overlayUV); - vb.lightmap(lightmapUV); - vb.normal(ms.getLast().getNormal(), front.getXOffset(), front.getYOffset(), front.getZOffset()); - vb.endVertex(); - } + private static void addVertex(IVertexBuilder vb, MatrixStack ms, TextureAtlasSprite sprite, float x, float y, + float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) { + vb.pos(ms.getLast().getMatrix(), x, y, z); + vb.color(1.0f, 1.0f, 1.0f, 1.0f); + vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV)); + vb.overlay(overlayUV); + vb.lightmap(lightmapUV); + vb.normal(ms.getLast().getNormal(), front.getXOffset(), front.getYOffset(), front.getZOffset()); + vb.endVertex(); + } - private static final ResourceLocation TAG_STORAGE_BLOCKS = new ResourceLocation("forge:storage_blocks"); + private static final ResourceLocation TAG_STORAGE_BLOCKS = new ResourceLocation("forge:storage_blocks"); - private void renderItem( MatrixStack ms, final ItemStack stack, final float o, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay ) - { - if( !stack.isEmpty() ) - { - ms.push(); - // move to center - ms.translate( 0.5f, 0.5f + o, 0.5f ); - ms.rotate( new Quaternion(90, 0, 0, true) ); - // set scale - ms.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE ); + private void renderItem(MatrixStack ms, final ItemStack stack, final float o, IRenderTypeBuffer buffers, + int combinedLight, int combinedOverlay) { + if (!stack.isEmpty()) { + ms.push(); + // move to center + ms.translate(0.5f, 0.5f + o, 0.5f); + ms.rotate(new Quaternion(90, 0, 0, true)); + // set scale + ms.scale(ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE); - ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); + ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - // heuristic to scale items down much further than blocks - if( !stack.getItem().getTags().contains(TAG_STORAGE_BLOCKS) ) - { - ms.scale( 0.5f, 0.5f, 0.5f ); - } + // heuristic to scale items down much further than blocks + if (!stack.getItem().getTags().contains(TAG_STORAGE_BLOCKS)) { + ms.scale(0.5f, 0.5f, 0.5f); + } - itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, ms, buffers); - ms.pop(); - } - } + itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, ms, + buffers); + ms.pop(); + } + } - public static void registerTexture( TextureStitchEvent.Pre evt ) - { - if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) { - evt.addSprite(TEXTURE_INSIDE.getTextureLocation()); - } - } + public static void registerTexture(TextureStitchEvent.Pre evt) { + if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) { + evt.addSprite(TEXTURE_INSIDE.getTextureLocation()); + } + } - // See https://easings.net/#easeOutBack - private static float easeCompressMotion(float x) { - float c1 = 1.70158f; - float c3 = c1 + 1; + // See https://easings.net/#easeOutBack + private static float easeCompressMotion(float x) { + float c1 = 1.70158f; + float c3 = c1 + 1; - return (float) (1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2)); - } + return (float) (1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2)); + } - // See https://easings.net/#easeInQuint - private static float easeDecompressMotion(float x) { - return x * x * x * x * x; - } + // See https://easings.net/#easeInQuint + private static float easeDecompressMotion(float x) { + return x * x * x * x * x; + } } diff --git a/src/main/java/appeng/client/render/tesr/ModularTESR.java b/src/main/java/appeng/client/render/tesr/ModularTESR.java index fa5f3925a..06e98af3c 100644 --- a/src/main/java/appeng/client/render/tesr/ModularTESR.java +++ b/src/main/java/appeng/client/render/tesr/ModularTESR.java @@ -18,6 +18,7 @@ package appeng.client.render.tesr; +import java.util.List; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; @@ -32,34 +33,28 @@ import appeng.client.render.FacingToRotation; import appeng.client.render.renderable.Renderable; import appeng.tile.AEBaseTile; -import java.util.List; +@OnlyIn(Dist.CLIENT) +public class ModularTESR extends TileEntityRenderer { + private final List> renderables; -@OnlyIn( Dist.CLIENT ) -public class ModularTESR extends TileEntityRenderer -{ + @SafeVarargs + public ModularTESR(TileEntityRendererDispatcher rendererDispatcherIn, Renderable... renderables) { + super(rendererDispatcherIn); + this.renderables = ImmutableList.copyOf(renderables); + } - private final List> renderables; - - @SafeVarargs - public ModularTESR( TileEntityRendererDispatcher rendererDispatcherIn, Renderable... renderables ) - { - super( rendererDispatcherIn ); - this.renderables = ImmutableList.copyOf(renderables); - } - - @Override - public void render( T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay ) - { - ms.push(); - ms.translate( 0.5, 0.5, 0.5 ); - FacingToRotation.get( te.getForward(), te.getUp() ).push(ms); - ms.translate( -0.5, -0.5, -0.5 ); - for( Renderable renderable : this.renderables ) - { - renderable.renderTileEntityAt( te, partialTicks, ms, buffers, combinedLight, combinedOverlay); - } - ms.pop(); - } + @Override + public void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, + int combinedOverlay) { + ms.push(); + ms.translate(0.5, 0.5, 0.5); + FacingToRotation.get(te.getForward(), te.getUp()).push(ms); + ms.translate(-0.5, -0.5, -0.5); + for (Renderable renderable : this.renderables) { + renderable.renderTileEntityAt(te, partialTicks, ms, buffers, combinedLight, combinedOverlay); + } + ms.pop(); + } } \ No newline at end of file diff --git a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java index 894067191..497b78ff9 100644 --- a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java +++ b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java @@ -18,13 +18,9 @@ package appeng.client.render.tesr; - -import appeng.block.storage.BlockSkyChest; -import appeng.block.storage.BlockSkyChest.SkyChestType; -import appeng.core.AppEng; -import appeng.tile.storage.TileSkyChest; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -39,12 +35,19 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.TextureStitchEvent; +import appeng.block.storage.BlockSkyChest; +import appeng.block.storage.BlockSkyChest.SkyChestType; +import appeng.core.AppEng; +import appeng.tile.storage.TileSkyChest; + // This is mostly a copy&paste job of the vanilla chest TESR @OnlyIn(Dist.CLIENT) public class SkyChestTESR extends TileEntityRenderer { - public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skychest")); - public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skyblockchest")); + public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS, + new ResourceLocation(AppEng.MOD_ID, "models/skychest")); + public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS, + new ResourceLocation(AppEng.MOD_ID, "models/skyblockchest")); private final ModelRenderer singleLid; private final ModelRenderer singleBottom; @@ -64,7 +67,8 @@ public class SkyChestTESR extends TileEntityRenderer { this.singleLatch.rotationPointY = 8.0F; } - public void render(TileSkyChest tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { + public void render(TileSkyChest tileEntityIn, float partialTicks, MatrixStack matrixStackIn, + IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { matrixStackIn.push(); float f = tileEntityIn.getForward().getHorizontalAngle(); matrixStackIn.translate(0.5D, 0.5D, 0.5D); @@ -76,12 +80,15 @@ public class SkyChestTESR extends TileEntityRenderer { f1 = 1.0F - f1 * f1 * f1; Material material = this.getMaterial(tileEntityIn); IVertexBuilder ivertexbuilder = material.getBuffer(bufferIn, RenderType::getEntityCutout); - this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1, combinedLightIn, combinedOverlayIn); + this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1, + combinedLightIn, combinedOverlayIn); matrixStackIn.pop(); } - private void renderModels(MatrixStack matrixStackIn, IVertexBuilder bufferIn, ModelRenderer chestLid, ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn, int combinedOverlayIn) { + private void renderModels(MatrixStack matrixStackIn, IVertexBuilder bufferIn, ModelRenderer chestLid, + ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn, + int combinedOverlayIn) { chestLid.rotateAngleX = -(lidAngle * 1.5707964F); chestLatch.rotateAngleX = chestLid.rotateAngleX; chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn); diff --git a/src/main/java/appeng/client/render/tesr/SkyCompassTESR.java b/src/main/java/appeng/client/render/tesr/SkyCompassTESR.java index 8911d1f4c..f29f417da 100644 --- a/src/main/java/appeng/client/render/tesr/SkyCompassTESR.java +++ b/src/main/java/appeng/client/render/tesr/SkyCompassTESR.java @@ -18,11 +18,9 @@ package appeng.client.render.tesr; - -import appeng.client.render.FacingToRotation; -import appeng.client.render.model.SkyCompassModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; @@ -35,91 +33,86 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.common.property.Properties; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import appeng.block.AEBaseTileBlock; import appeng.block.misc.BlockSkyCompass; +import appeng.client.render.FacingToRotation; import appeng.client.render.model.SkyCompassBakedModel; +import appeng.client.render.model.SkyCompassModel; import appeng.tile.misc.TileSkyCompass; +@OnlyIn(Dist.CLIENT) +public class SkyCompassTESR extends TileEntityRenderer { -@OnlyIn( Dist.CLIENT ) -public class SkyCompassTESR extends TileEntityRenderer -{ + private static BlockRendererDispatcher blockRenderer; - private static BlockRendererDispatcher blockRenderer; + public SkyCompassTESR(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } - public SkyCompassTESR(TileEntityRendererDispatcher rendererDispatcherIn) { - super(rendererDispatcherIn); - } + @Override + public void render(TileSkyCompass te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, + int combinedLightIn, int combinedOverlayIn) { - @Override - public void render(TileSkyCompass te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) { + if (blockRenderer == null) { + blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher(); + } - if( blockRenderer == null ) - { - blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher(); - } + IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType()); - IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType()); + BlockState blockState = te.getBlockState(); + IBakedModel model = blockRenderer.getBlockModelShapes().getModel(blockState); - BlockState blockState = te.getBlockState(); - IBakedModel model = blockRenderer.getBlockModelShapes().getModel( blockState ); + // FIXME: Rotation was previously handled by an auto rotating model I think, but + // FIXME: Should be handled using matrices instead + Direction forward = te.getForward(); + Direction up = te.getUp(); + // This ensures the needle isn't flipped by the model rotator. Since the model + // is symmetrical, this should + // not affect the appearance + if (forward == Direction.UP || forward == Direction.DOWN) { + up = Direction.NORTH; + } + // Flip forward/up for rendering, the base model is facing up without any + // rotation + ms.push(); + ms.translate(0.5D, 0.5D, 0.5D); + FacingToRotation.get(up, forward).push(ms); + ms.translate(-0.5D, -0.5D, -0.5D); - // FIXME: Rotation was previously handled by an auto rotating model I think, but - // FIXME: Should be handled using matrices instead - Direction forward = te.getForward(); - Direction up = te.getUp(); - // This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should - // not affect the appearance - if( forward == Direction.UP || forward == Direction.DOWN ) - { - up = Direction.NORTH; - } - // Flip forward/up for rendering, the base model is facing up without any rotation - ms.push(); - ms.translate(0.5D, 0.5D, 0.5D); - FacingToRotation.get(up, forward).push(ms); - ms.translate(-0.5D, -0.5D, -0.5D); + ModelDataMap modelData = new ModelDataMap.Builder().withInitial(SkyCompassBakedModel.ROTATION, getRotation(te)) + .build(); - ModelDataMap modelData = new ModelDataMap.Builder() - .withInitial(SkyCompassBakedModel.ROTATION, getRotation(te)) - .build(); + blockRenderer.getBlockModelRenderer().renderModel(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, + combinedOverlayIn, modelData); + ms.pop(); - blockRenderer.getBlockModelRenderer().renderModel( ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn, modelData ); - ms.pop(); + } - } + private static float getRotation(TileSkyCompass skyCompass) { + float rotation; - private static float getRotation( TileSkyCompass skyCompass ) - { - float rotation; + if (skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN) { + rotation = SkyCompassBakedModel.getAnimatedRotation(skyCompass.getPos(), false); + } else { + rotation = SkyCompassBakedModel.getAnimatedRotation(null, false); + } - if( skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN ) - { - rotation = SkyCompassBakedModel.getAnimatedRotation( skyCompass.getPos(), false ); - } - else - { - rotation = SkyCompassBakedModel.getAnimatedRotation( null, false ); - } + if (skyCompass.getForward() == Direction.DOWN) { + rotation = flipidiy(rotation); + } - if( skyCompass.getForward() == Direction.DOWN ) - { - rotation = flipidiy( rotation ); - } + return rotation; + } - return rotation; - } - - private static float flipidiy( float rad ) - { - float x = (float) Math.cos( rad ); - float y = (float) Math.sin( rad ); - return (float) Math.atan2( -y, x ); - } + private static float flipidiy(float rad) { + float x = (float) Math.cos(rad); + float y = (float) Math.sin(rad); + return (float) Math.atan2(-y, x); + } } diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index d9163479a..457689f7b 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -18,7 +18,6 @@ package appeng.container; - import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; @@ -26,12 +25,9 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import appeng.container.slot.*; -import appeng.core.sync.packets.PacketInventoryAction; -import appeng.core.sync.packets.PacketValueConfig; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.container.*; import net.minecraft.item.ItemStack; @@ -57,9 +53,12 @@ import appeng.api.storage.data.IAEItemStack; import appeng.client.me.SlotME; import appeng.container.guisync.GuiSync; import appeng.container.guisync.SyncData; +import appeng.container.slot.*; import appeng.core.AELog; import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketInventoryAction; import appeng.core.sync.packets.PacketTargetItemStack; +import appeng.core.sync.packets.PacketValueConfig; import appeng.helpers.ICustomNameObject; import appeng.helpers.InventoryAction; import appeng.me.helpers.PlayerSource; @@ -69,1163 +68,957 @@ import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.item.AEItemStack; +public abstract class AEBaseContainer extends Container { + private final PlayerInventory invPlayer; + private final IActionSource mySrc; + private final HashSet locked = new HashSet<>(); + private final TileEntity tileEntity; + private final IPart part; + private final IGuiItemObject obj; + private final HashMap syncData = new HashMap<>(); + private boolean isContainerValid = true; + private String customName; + private ContainerLocator locator; + private IMEInventoryHandler cellInv; + private IEnergySource powerSrc; + private boolean sentCustomName; + private int ticksSinceCheck = 900; + private IAEItemStack clientRequestedTargetItem = null; + // Slots that were created to represent the player inventory + private List playerInventorySlots = null; + + public AEBaseContainer(ContainerType containerType, int id, final PlayerInventory ip, final TileEntity myTile, + final IPart myPart) { + this(containerType, id, ip, myTile, myPart, null); + } + + public AEBaseContainer(ContainerType containerType, int id, final PlayerInventory ip, final TileEntity myTile, + final IPart myPart, final IGuiItemObject gio) { + super(containerType, id); + this.invPlayer = ip; + this.tileEntity = myTile; + this.part = myPart; + this.obj = gio; + this.mySrc = new PlayerSource(ip.player, this.getActionHost()); + this.prepareSync(); + } + + public AEBaseContainer(ContainerType containerType, int id, final PlayerInventory ip, final Object anchor) { + super(containerType, id); + this.invPlayer = ip; + this.tileEntity = anchor instanceof TileEntity ? (TileEntity) anchor : null; + this.part = anchor instanceof IPart ? (IPart) anchor : null; + this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null; + + if (this.tileEntity == null && this.part == null && this.obj == null) { + throw new IllegalArgumentException("Must have a valid anchor, instead " + anchor + " in " + ip); + } + + this.mySrc = new PlayerSource(ip.player, this.getActionHost()); + + this.prepareSync(); + } + + protected IActionHost getActionHost() { + if (this.obj instanceof IActionHost) { + return (IActionHost) this.obj; + } + + if (this.tileEntity instanceof IActionHost) { + return (IActionHost) this.tileEntity; + } + + if (this.part instanceof IActionHost) { + return (IActionHost) this.part; + } + + return null; + } + + private void prepareSync() { + for (final Field f : this.getClass().getFields()) { + if (f.isAnnotationPresent(GuiSync.class)) { + final GuiSync annotation = f.getAnnotation(GuiSync.class); + if (this.syncData.containsKey(annotation.value())) { + AELog.warn("Channel already in use: " + annotation.value() + " for " + f.getName()); + } else { + this.syncData.put(annotation.value(), new SyncData(this, f, annotation)); + } + } + } + } + + public IAEItemStack getTargetStack() { + return this.clientRequestedTargetItem; + } + + public void setTargetStack(final IAEItemStack stack) { + // client doesn't need to re-send, makes for lower overhead rapid packets. + if (Platform.isClient()) { + if (stack == null && this.clientRequestedTargetItem == null) { + return; + } + if (stack != null && stack.isSameType(this.clientRequestedTargetItem)) { + return; + } + + NetworkHandler.instance().sendToServer(new PacketTargetItemStack((AEItemStack) stack)); + } + + this.clientRequestedTargetItem = stack == null ? null : stack.copy(); + } + + public IActionSource getActionSource() { + return this.mySrc; + } + + public void verifyPermissions(final SecurityPermissions security, final boolean requirePower) { + if (Platform.isClient()) { + return; + } + + this.ticksSinceCheck++; + if (this.ticksSinceCheck < 20) { + return; + } + + this.ticksSinceCheck = 0; + this.setValidContainer(this.isValidContainer() && this.hasAccess(security, requirePower)); + } + + protected boolean hasAccess(final SecurityPermissions perm, final boolean requirePower) { + final IActionHost host = this.getActionHost(); + + if (host != null) { + final IGridNode gn = host.getActionableNode(); + if (gn != null) { + final IGrid g = gn.getGrid(); + if (g != null) { + if (requirePower) { + final IEnergyGrid eg = g.getCache(IEnergyGrid.class); + if (!eg.isNetworkPowered()) { + return false; + } + } + + final ISecurityGrid sg = g.getCache(ISecurityGrid.class); + if (sg.hasPermission(this.getPlayerInventory().player, perm)) { + return true; + } + } + } + } + + return false; + } + + public void lockPlayerInventorySlot(final int idx) { + this.locked.add(idx); + } + + public Object getTarget() { + if (this.tileEntity != null) { + return this.tileEntity; + } + if (this.part != null) { + return this.part; + } + if (this.obj != null) { + return this.obj; + } + return null; + } + + public PlayerInventory getPlayerInv() { + return this.getPlayerInventory(); + } + + public TileEntity getTileEntity() { + return this.tileEntity; + } + + public final void updateFullProgressBar(final int idx, final long value) { + if (this.syncData.containsKey(idx)) { + this.syncData.get(idx).update(value); + return; + } + + this.updateProgressBar(idx, (int) value); + } + + public void stringSync(final int idx, final String value) { + if (this.syncData.containsKey(idx)) { + this.syncData.get(idx).update(value); + } + } + + protected void bindPlayerInventory(final PlayerInventory PlayerInventory, final int offsetX, final int offsetY) { + IItemHandler ih = new PlayerInvWrapper(PlayerInventory); + + // bind player inventory + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + if (this.locked.contains(j + i * 9 + 9)) { + this.addSlot(new SlotDisabled(ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18)); + } else { + this.addSlot(new SlotPlayerInv(ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18)); + } + } + } + + // bind player hotbar + for (int i = 0; i < 9; i++) { + if (this.locked.contains(i)) { + this.addSlot(new SlotDisabled(ih, i, 8 + i * 18 + offsetX, 58 + offsetY)); + } else { + this.addSlot(new SlotPlayerHotBar(ih, i, 8 + i * 18 + offsetX, 58 + offsetY)); + } + } + } + + @Override + protected Slot addSlot(final Slot newSlot) { + if (newSlot instanceof AppEngSlot) { + final AppEngSlot s = (AppEngSlot) newSlot; + s.setContainer(this); + return super.addSlot(newSlot); + } else { + throw new IllegalArgumentException( + "Invalid Slot [" + newSlot + "] for AE Container instead of AppEngSlot."); + } + } + + @Override + public void detectAndSendChanges() { + this.sendCustomName(); + + if (Platform.isServer()) { + if (this.tileEntity != null + && this.tileEntity.getWorld().getTileEntity(this.tileEntity.getPos()) != this.tileEntity) { + this.setValidContainer(false); + } + + for (final IContainerListener listener : this.listeners) { + for (final SyncData sd : this.syncData.values()) { + sd.tick(listener); + } + } + } + + super.detectAndSendChanges(); + } + + @Override + public ItemStack transferStackInSlot(final PlayerEntity p, final int idx) { + if (Platform.isClient()) { + return ItemStack.EMPTY; + } + + final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots! + + if (clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible) { + return ItemStack.EMPTY; + } + if (clickSlot != null && clickSlot.getHasStack()) { + ItemStack tis = clickSlot.getStack(); + + if (tis.isEmpty()) { + return ItemStack.EMPTY; + } + + final List selectedSlots = new ArrayList<>(); + + /** + * Gather a list of valid destinations. + */ + if (clickSlot.isPlayerSide()) { + tis = this.transferStackToContainer(tis); + + if (!tis.isEmpty()) { + // target slots in the container... + for (final Object inventorySlot : this.inventorySlots) { + final AppEngSlot cs = (AppEngSlot) inventorySlot; + + if (!(cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) { + if (cs.isItemValid(tis)) { + selectedSlots.add(cs); + } + } + } + } + } else { + tis = tis.copy(); + + // target slots in the container... + for (final Object inventorySlot : this.inventorySlots) { + final AppEngSlot cs = (AppEngSlot) inventorySlot; + + if ((cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) { + if (cs.isItemValid(tis)) { + selectedSlots.add(cs); + } + } + } + } + + /** + * Handle Fake Slot Shift clicking. + */ + if (selectedSlots.isEmpty() && clickSlot.isPlayerSide()) { + if (!tis.isEmpty()) { + // target slots in the container... + for (final Object inventorySlot : this.inventorySlots) { + final AppEngSlot cs = (AppEngSlot) inventorySlot; + final ItemStack destination = cs.getStack(); + + if (!(cs.isPlayerSide()) && cs instanceof SlotFake) { + if (Platform.itemComparisons().isSameItem(destination, tis)) { + break; + } else if (destination.isEmpty()) { + cs.putStack(tis.copy()); + this.updateSlot(cs); + break; + } + } + } + } + } + + if (!tis.isEmpty()) { + // find partials.. + for (final Slot d : selectedSlots) { + if (d instanceof SlotDisabled || d instanceof SlotME) { + continue; + } + + if (d.isItemValid(tis)) { + if (d.getHasStack()) { + final ItemStack t = d.getStack().copy(); + + if (Platform.itemComparisons().isSameItem(t, tis)) { + int maxSize = t.getMaxStackSize(); + if (maxSize > d.getSlotStackLimit()) { + maxSize = d.getSlotStackLimit(); + } + + int placeable = maxSize - t.getCount(); + if (placeable > 0) { + if (tis.getCount() < placeable) { + placeable = tis.getCount(); + } + + t.setCount(t.getCount() + placeable); + tis.setCount(tis.getCount() - placeable); + + d.putStack(t); + + if (tis.getCount() <= 0) { + clickSlot.putStack(ItemStack.EMPTY); + d.onSlotChanged(); + + this.updateSlot(clickSlot); + this.updateSlot(d); + return ItemStack.EMPTY; + } else { + this.updateSlot(d); + } + } + } + } + } + } + + // FIXME figure out whats the difference between this and the one above ?! + // any match.. + for (final Slot d : selectedSlots) { + if (d instanceof SlotDisabled || d instanceof SlotME) { + continue; + } + + if (d.isItemValid(tis)) { + if (d.getHasStack()) { + final ItemStack t = d.getStack().copy(); + + if (Platform.itemComparisons().isSameItem(t, tis)) { + int maxSize = t.getMaxStackSize(); + if (maxSize > d.getSlotStackLimit()) { + maxSize = d.getSlotStackLimit(); + } + + int placeable = maxSize - t.getCount(); + if (placeable > 0) { + if (tis.getCount() < placeable) { + placeable = tis.getCount(); + } + + t.setCount(t.getCount() + placeable); + tis.setCount(tis.getCount() - placeable); + + d.putStack(t); + + if (tis.getCount() <= 0) { + clickSlot.putStack(ItemStack.EMPTY); + d.onSlotChanged(); + + this.updateSlot(clickSlot); + this.updateSlot(d); + return ItemStack.EMPTY; + } else { + this.updateSlot(d); + } + } + } + } else { + int maxSize = tis.getMaxStackSize(); + if (maxSize > d.getSlotStackLimit()) { + maxSize = d.getSlotStackLimit(); + } + + final ItemStack tmp = tis.copy(); + if (tmp.getCount() > maxSize) { + tmp.setCount(maxSize); + } + + tis.setCount(tis.getCount() - tmp.getCount()); + d.putStack(tmp); + + if (tis.getCount() <= 0) { + clickSlot.putStack(ItemStack.EMPTY); + d.onSlotChanged(); + + this.updateSlot(clickSlot); + this.updateSlot(d); + return ItemStack.EMPTY; + } else { + this.updateSlot(d); + } + } + } + } + } + + clickSlot.putStack(!tis.isEmpty() ? tis : ItemStack.EMPTY); + } + + this.updateSlot(clickSlot); + return ItemStack.EMPTY; + } + + @Override + public final void updateProgressBar(final int idx, final int value) { + if (this.syncData.containsKey(idx)) { + this.syncData.get(idx).update((long) value); + } + } + + @Override + public boolean canInteractWith(final PlayerEntity PlayerEntity) { + if (this.isValidContainer()) { + if (this.tileEntity instanceof IInventory) { + return ((IInventory) this.tileEntity).isUsableByPlayer(PlayerEntity); + } + return true; + } + return false; + } + + @Override + public boolean canDragIntoSlot(final Slot s) { + return ((AppEngSlot) s).isDraggable(); + } + + public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) { + if (slot >= 0 && slot < this.inventorySlots.size()) { + final Slot s = this.getSlot(slot); + + if (s instanceof SlotCraftingTerm) { + switch (action) { + case CRAFT_SHIFT: + case CRAFT_ITEM: + case CRAFT_STACK: + ((SlotCraftingTerm) s).doClick(action, player); + this.updateHeld(player); + default: + } + } + + if (s instanceof SlotFake) { + final ItemStack hand = player.inventory.getItemStack(); + + switch (action) { + case PICKUP_OR_SET_DOWN: + + if (hand.isEmpty()) { + s.putStack(ItemStack.EMPTY); + } else { + s.putStack(hand.copy()); + } + + break; + case PLACE_SINGLE: + + if (!hand.isEmpty()) { + final ItemStack is = hand.copy(); + is.setCount(1); + s.putStack(is); + } + + break; + case SPLIT_OR_PLACE_SINGLE: + + ItemStack is = s.getStack(); + if (!is.isEmpty()) { + if (hand.isEmpty()) { + is.setCount(Math.max(1, is.getCount() - 1)); + } else if (hand.isItemEqual(is)) { + is.setCount(Math.min(is.getMaxStackSize(), is.getCount() + 1)); + } else { + is = hand.copy(); + is.setCount(1); + } + + s.putStack(is); + } else if (!hand.isEmpty()) { + is = hand.copy(); + is.setCount(1); + s.putStack(is); + } + + break; + case CREATIVE_DUPLICATE: + case MOVE_REGION: + case SHIFT_CLICK: + default: + break; + } + } + + if (action == InventoryAction.MOVE_REGION) { + final List from = new ArrayList<>(); + + for (final Object j : this.inventorySlots) { + if (j instanceof Slot && j.getClass() == s.getClass() && !(j instanceof SlotCraftingTerm)) { + from.add((Slot) j); + } + } + + for (final Slot fr : from) { + this.transferStackInSlot(player, fr.slotNumber); + } + } + + return; + } + + // get target item. + final IAEItemStack slotItem = this.clientRequestedTargetItem; + + switch (action) { + case SHIFT_CLICK: + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + if (slotItem != null) { + IAEItemStack ais = slotItem.copy(); + ItemStack myItem = ais.createItemStack(); + + ais.setStackSize(myItem.getMaxStackSize()); + + final InventoryAdaptor adp = InventoryAdaptor.getAdaptor(player); + myItem.setCount((int) ais.getStackSize()); + myItem = adp.simulateAdd(myItem); + + if (!myItem.isEmpty()) { + ais.setStackSize(ais.getStackSize() - myItem.getCount()); + } + + ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais != null) { + adp.addItems(ais.createItemStack()); + } + } + break; + case ROLL_DOWN: + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + final int releaseQty = 1; + final ItemStack isg = player.inventory.getItemStack(); + + if (!isg.isEmpty() && releaseQty > 0) { + IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(isg); + ais.setStackSize(1); + final IAEItemStack extracted = ais.copy(); + + ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais == null) { + final InventoryAdaptor ia = new AdaptorItemHandler( + new WrapperCursorItemHandler(player.inventory)); + + final ItemStack fail = ia.removeItems(1, extracted.getDefinition(), null); + if (fail.isEmpty()) { + this.getCellInventory().extractItems(extracted, Actionable.MODULATE, + this.getActionSource()); + } + + this.updateHeld(player); + } + } + + break; + case ROLL_UP: + case PICKUP_SINGLE: + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + if (slotItem != null) { + int liftQty = 1; + final ItemStack item = player.inventory.getItemStack(); + + if (!item.isEmpty()) { + if (item.getCount() >= item.getMaxStackSize()) { + liftQty = 0; + } + if (!Platform.itemComparisons().isSameItem(slotItem.getDefinition(), item)) { + liftQty = 0; + } + } + + if (liftQty > 0) { + IAEItemStack ais = slotItem.copy(); + ais.setStackSize(1); + ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais != null) { + final InventoryAdaptor ia = new AdaptorItemHandler( + new WrapperCursorItemHandler(player.inventory)); + + final ItemStack fail = ia.addItems(ais.createItemStack()); + if (!fail.isEmpty()) { + this.getCellInventory().injectItems(ais, Actionable.MODULATE, this.getActionSource()); + } + + this.updateHeld(player); + } + } + } + break; + case PICKUP_OR_SET_DOWN: + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + if (player.inventory.getItemStack().isEmpty()) { + if (slotItem != null) { + IAEItemStack ais = slotItem.copy(); + ais.setStackSize(ais.getDefinition().getMaxStackSize()); + ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais != null) { + player.inventory.setItemStack(ais.createItemStack()); + } else { + player.inventory.setItemStack(ItemStack.EMPTY); + } + this.updateHeld(player); + } + } else { + IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(player.inventory.getItemStack()); + ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais != null) { + player.inventory.setItemStack(ais.createItemStack()); + } else { + player.inventory.setItemStack(ItemStack.EMPTY); + } + this.updateHeld(player); + } + + break; + case SPLIT_OR_PLACE_SINGLE: + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + if (player.inventory.getItemStack().isEmpty()) { + if (slotItem != null) { + IAEItemStack ais = slotItem.copy(); + final long maxSize = ais.getDefinition().getMaxStackSize(); + ais.setStackSize(maxSize); + ais = this.getCellInventory().extractItems(ais, Actionable.SIMULATE, this.getActionSource()); + + if (ais != null) { + final long stackSize = Math.min(maxSize, ais.getStackSize()); + ais.setStackSize((stackSize + 1) >> 1); + ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + } + + if (ais != null) { + player.inventory.setItemStack(ais.createItemStack()); + } else { + player.inventory.setItemStack(ItemStack.EMPTY); + } + this.updateHeld(player); + } + } else { + IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(player.inventory.getItemStack()); + ais.setStackSize(1); + ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais == null) { + final ItemStack is = player.inventory.getItemStack(); + is.setCount(is.getCount() - 1); + if (is.getCount() <= 0) { + player.inventory.setItemStack(ItemStack.EMPTY); + } + this.updateHeld(player); + } + } + + break; + case CREATIVE_DUPLICATE: + if (player.abilities.isCreativeMode && slotItem != null) { + final ItemStack is = slotItem.createItemStack(); + is.setCount(is.getMaxStackSize()); + player.inventory.setItemStack(is); + this.updateHeld(player); + } + break; + case MOVE_REGION: + + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return; + } + + if (slotItem != null) { + final int playerInv = 9 * 4; + for (int slotNum = 0; slotNum < playerInv; slotNum++) { + IAEItemStack ais = slotItem.copy(); + ItemStack myItem = ais.createItemStack(); + + ais.setStackSize(myItem.getMaxStackSize()); + + final InventoryAdaptor adp = InventoryAdaptor.getAdaptor(player); + myItem.setCount((int) ais.getStackSize()); + myItem = adp.simulateAdd(myItem); + + if (!myItem.isEmpty()) { + ais.setStackSize(ais.getStackSize() - myItem.getCount()); + } + + ais = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, + this.getActionSource()); + if (ais != null) { + adp.addItems(ais.createItemStack()); + } else { + return; + } + } + } + + break; + default: + break; + } + } + + protected void updateHeld(final ServerPlayerEntity p) { + if (Platform.isServer()) { + NetworkHandler.instance().sendTo(new PacketInventoryAction(InventoryAction.UPDATE_HAND, 0, + AEItemStack.fromItemStack(p.inventory.getItemStack())), p); + } + } + + protected ItemStack transferStackToContainer(final ItemStack input) { + return this.shiftStoreItem(input); + } + + private ItemStack shiftStoreItem(final ItemStack input) { + if (this.getPowerSource() == null || this.getCellInventory() == null) { + return input; + } + final IAEItemStack ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(input), + this.getActionSource()); + if (ais == null) { + return ItemStack.EMPTY; + } + return ais.createItemStack(); + } + + private void updateSlot(final Slot clickSlot) { + // ??? + this.detectAndSendChanges(); + } + + private void sendCustomName() { + // FIXME: Trash this, this is handled by NamedContainerProvider now + if (!this.sentCustomName) { + this.sentCustomName = true; + if (Platform.isServer()) { + ICustomNameObject name = null; + + if (this.part instanceof ICustomNameObject) { + name = (ICustomNameObject) this.part; + } + + if (this.tileEntity instanceof ICustomNameObject) { + name = (ICustomNameObject) this.tileEntity; + } + + if (this.obj instanceof ICustomNameObject) { + name = (ICustomNameObject) this.obj; + } + + if (this instanceof ICustomNameObject) { + name = (ICustomNameObject) this; + } + + if (name != null) { + if (name.hasCustomInventoryName()) { + this.setCustomName(name.getCustomInventoryName().getString()); + } + + if (this.getCustomName() != null) { + NetworkHandler.instance().sendTo(new PacketValueConfig("CustomName", this.getCustomName()), + (ServerPlayerEntity) this.getPlayerInventory().player); + } + } + } + } + } + + public void swapSlotContents(final int slotA, final int slotB) { + final Slot a = this.getSlot(slotA); + final Slot b = this.getSlot(slotB); + + // NPE protection... + if (a == null || b == null) { + return; + } + + final ItemStack isA = a.getStack(); + final ItemStack isB = b.getStack(); + + // something to do? + if (isA.isEmpty() && isB.isEmpty()) { + return; + } + + // can take? + + if (!isA.isEmpty() && !a.canTakeStack(this.getPlayerInventory().player)) { + return; + } + + if (!isB.isEmpty() && !b.canTakeStack(this.getPlayerInventory().player)) { + return; + } + + // swap valid? + + if (!isB.isEmpty() && !a.isItemValid(isB)) { + return; + } + + if (!isA.isEmpty() && !b.isItemValid(isA)) { + return; + } + + ItemStack testA = isB.isEmpty() ? ItemStack.EMPTY : isB.copy(); + ItemStack testB = isA.isEmpty() ? ItemStack.EMPTY : isA.copy(); + + // can put some back? + if (!testA.isEmpty() && testA.getCount() > a.getSlotStackLimit()) { + if (!testB.isEmpty()) { + return; + } + + final int totalA = testA.getCount(); + testA.setCount(a.getSlotStackLimit()); + testB = testA.copy(); + + testB.setCount(totalA - testA.getCount()); + } + + if (!testB.isEmpty() && testB.getCount() > b.getSlotStackLimit()) { + if (!testA.isEmpty()) { + return; + } -public abstract class AEBaseContainer extends Container -{ - private final PlayerInventory invPlayer; - private final IActionSource mySrc; - private final HashSet locked = new HashSet<>(); - private final TileEntity tileEntity; - private final IPart part; - private final IGuiItemObject obj; - private final HashMap syncData = new HashMap<>(); - private boolean isContainerValid = true; - private String customName; - private ContainerLocator locator; - private IMEInventoryHandler cellInv; - private IEnergySource powerSrc; - private boolean sentCustomName; - private int ticksSinceCheck = 900; - private IAEItemStack clientRequestedTargetItem = null; - // Slots that were created to represent the player inventory - private List playerInventorySlots = null; - - public AEBaseContainer( ContainerType containerType, int id, final PlayerInventory ip, final TileEntity myTile, final IPart myPart ) - { - this( containerType, id, ip, myTile, myPart, null ); - } - - public AEBaseContainer(ContainerType containerType, int id, final PlayerInventory ip, final TileEntity myTile, final IPart myPart, final IGuiItemObject gio ) - { - super(containerType, id); - this.invPlayer = ip; - this.tileEntity = myTile; - this.part = myPart; - this.obj = gio; - this.mySrc = new PlayerSource( ip.player, this.getActionHost() ); - this.prepareSync(); - } - - public AEBaseContainer(ContainerType containerType, int id, final PlayerInventory ip, final Object anchor ) - { - super(containerType, id); - this.invPlayer = ip; - this.tileEntity = anchor instanceof TileEntity ? (TileEntity) anchor : null; - this.part = anchor instanceof IPart ? (IPart) anchor : null; - this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null; - - if( this.tileEntity == null && this.part == null && this.obj == null ) - { - throw new IllegalArgumentException( "Must have a valid anchor, instead " + anchor + " in " + ip ); - } - - this.mySrc = new PlayerSource( ip.player, this.getActionHost() ); - - this.prepareSync(); - } - - protected IActionHost getActionHost() - { - if( this.obj instanceof IActionHost ) - { - return (IActionHost) this.obj; - } - - if( this.tileEntity instanceof IActionHost ) - { - return (IActionHost) this.tileEntity; - } - - if( this.part instanceof IActionHost ) - { - return (IActionHost) this.part; - } - - return null; - } - - private void prepareSync() - { - for( final Field f : this.getClass().getFields() ) - { - if( f.isAnnotationPresent( GuiSync.class ) ) - { - final GuiSync annotation = f.getAnnotation( GuiSync.class ); - if( this.syncData.containsKey( annotation.value() ) ) - { - AELog.warn( "Channel already in use: " + annotation.value() + " for " + f.getName() ); - } - else - { - this.syncData.put( annotation.value(), new SyncData( this, f, annotation ) ); - } - } - } - } - - public IAEItemStack getTargetStack() - { - return this.clientRequestedTargetItem; - } - - public void setTargetStack( final IAEItemStack stack ) - { - // client doesn't need to re-send, makes for lower overhead rapid packets. - if( Platform.isClient() ) - { - if( stack == null && this.clientRequestedTargetItem == null ) - { - return; - } - if( stack != null && stack.isSameType( this.clientRequestedTargetItem ) ) - { - return; - } - - NetworkHandler.instance().sendToServer( new PacketTargetItemStack( (AEItemStack) stack ) ); - } - - this.clientRequestedTargetItem = stack == null ? null : stack.copy(); - } - - public IActionSource getActionSource() - { - return this.mySrc; - } - - public void verifyPermissions( final SecurityPermissions security, final boolean requirePower ) - { - if( Platform.isClient() ) - { - return; - } - - this.ticksSinceCheck++; - if( this.ticksSinceCheck < 20 ) - { - return; - } - - this.ticksSinceCheck = 0; - this.setValidContainer( this.isValidContainer() && this.hasAccess( security, requirePower ) ); - } - - protected boolean hasAccess( final SecurityPermissions perm, final boolean requirePower ) - { - final IActionHost host = this.getActionHost(); - - if( host != null ) - { - final IGridNode gn = host.getActionableNode(); - if( gn != null ) - { - final IGrid g = gn.getGrid(); - if( g != null ) - { - if( requirePower ) - { - final IEnergyGrid eg = g.getCache( IEnergyGrid.class ); - if( !eg.isNetworkPowered() ) - { - return false; - } - } - - final ISecurityGrid sg = g.getCache( ISecurityGrid.class ); - if( sg.hasPermission( this.getPlayerInventory().player, perm ) ) - { - return true; - } - } - } - } - - return false; - } - - public void lockPlayerInventorySlot( final int idx ) - { - this.locked.add( idx ); - } - - public Object getTarget() - { - if( this.tileEntity != null ) - { - return this.tileEntity; - } - if( this.part != null ) - { - return this.part; - } - if( this.obj != null ) - { - return this.obj; - } - return null; - } - - public PlayerInventory getPlayerInv() - { - return this.getPlayerInventory(); - } - - public TileEntity getTileEntity() - { - return this.tileEntity; - } - - public final void updateFullProgressBar( final int idx, final long value ) - { - if( this.syncData.containsKey( idx ) ) - { - this.syncData.get( idx ).update( value ); - return; - } - - this.updateProgressBar( idx, (int) value ); - } - - public void stringSync( final int idx, final String value ) - { - if( this.syncData.containsKey( idx ) ) - { - this.syncData.get( idx ).update( value ); - } - } - - protected void bindPlayerInventory( final PlayerInventory PlayerInventory, final int offsetX, final int offsetY ) - { - IItemHandler ih = new PlayerInvWrapper( PlayerInventory ); - - // bind player inventory - for( int i = 0; i < 3; i++ ) - { - for( int j = 0; j < 9; j++ ) - { - if( this.locked.contains( j + i * 9 + 9 ) ) - { - this.addSlot( new SlotDisabled( ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) ); - } - else - { - this.addSlot( new SlotPlayerInv( ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) ); - } - } - } - - // bind player hotbar - for( int i = 0; i < 9; i++ ) - { - if( this.locked.contains( i ) ) - { - this.addSlot( new SlotDisabled( ih, i, 8 + i * 18 + offsetX, 58 + offsetY ) ); - } - else - { - this.addSlot( new SlotPlayerHotBar( ih, i, 8 + i * 18 + offsetX, 58 + offsetY ) ); - } - } - } - - @Override - protected Slot addSlot(final Slot newSlot ) - { - if( newSlot instanceof AppEngSlot ) - { - final AppEngSlot s = (AppEngSlot) newSlot; - s.setContainer( this ); - return super.addSlot( newSlot ); - } - else - { - throw new IllegalArgumentException( "Invalid Slot [" + newSlot + "] for AE Container instead of AppEngSlot." ); - } - } - - @Override - public void detectAndSendChanges() - { - this.sendCustomName(); - - if( Platform.isServer() ) - { - if( this.tileEntity != null && this.tileEntity.getWorld().getTileEntity( this.tileEntity.getPos() ) != this.tileEntity ) - { - this.setValidContainer( false ); - } - - for( final IContainerListener listener : this.listeners ) - { - for( final SyncData sd : this.syncData.values() ) - { - sd.tick( listener ); - } - } - } - - super.detectAndSendChanges(); - } - - @Override - public ItemStack transferStackInSlot( final PlayerEntity p, final int idx ) - { - if( Platform.isClient() ) - { - return ItemStack.EMPTY; - } - - final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots! - - if( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible ) - { - return ItemStack.EMPTY; - } - if( clickSlot != null && clickSlot.getHasStack() ) - { - ItemStack tis = clickSlot.getStack(); - - if( tis.isEmpty() ) - { - return ItemStack.EMPTY; - } - - final List selectedSlots = new ArrayList<>(); - - /** - * Gather a list of valid destinations. - */ - if( clickSlot.isPlayerSide() ) - { - tis = this.transferStackToContainer( tis ); - - if( !tis.isEmpty() ) - { - // target slots in the container... - for( final Object inventorySlot : this.inventorySlots ) - { - final AppEngSlot cs = (AppEngSlot) inventorySlot; - - if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix) ) - { - if( cs.isItemValid( tis ) ) - { - selectedSlots.add( cs ); - } - } - } - } - } - else - { - tis = tis.copy(); - - // target slots in the container... - for( final Object inventorySlot : this.inventorySlots ) - { - final AppEngSlot cs = (AppEngSlot) inventorySlot; - - if( ( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) ) - { - if( cs.isItemValid( tis ) ) - { - selectedSlots.add( cs ); - } - } - } - } - - /** - * Handle Fake Slot Shift clicking. - */ - if( selectedSlots.isEmpty() && clickSlot.isPlayerSide() ) - { - if( !tis.isEmpty() ) - { - // target slots in the container... - for( final Object inventorySlot : this.inventorySlots ) - { - final AppEngSlot cs = (AppEngSlot) inventorySlot; - final ItemStack destination = cs.getStack(); - - if( !( cs.isPlayerSide() ) && cs instanceof SlotFake ) - { - if( Platform.itemComparisons().isSameItem( destination, tis ) ) - { - break; - } - else if( destination.isEmpty() ) - { - cs.putStack( tis.copy() ); - this.updateSlot( cs ); - break; - } - } - } - } - } - - if( !tis.isEmpty() ) - { - // find partials.. - for( final Slot d : selectedSlots ) - { - if( d instanceof SlotDisabled || d instanceof SlotME ) - { - continue; - } - - if( d.isItemValid( tis ) ) - { - if( d.getHasStack() ) - { - final ItemStack t = d.getStack().copy(); - - if( Platform.itemComparisons().isSameItem( t, tis ) ) - { - int maxSize = t.getMaxStackSize(); - if( maxSize > d.getSlotStackLimit() ) - { - maxSize = d.getSlotStackLimit(); - } - - int placeable = maxSize - t.getCount(); - if (placeable > 0) { - if (tis.getCount() < placeable) { - placeable = tis.getCount(); - } - - t.setCount(t.getCount() + placeable); - tis.setCount(tis.getCount() - placeable); - - d.putStack(t); - - if (tis.getCount() <= 0) { - clickSlot.putStack(ItemStack.EMPTY); - d.onSlotChanged(); - - this.updateSlot(clickSlot); - this.updateSlot(d); - return ItemStack.EMPTY; - } else { - this.updateSlot(d); - } - } - } - } - } - } - - // FIXME figure out whats the difference between this and the one above ?! - // any match.. - for( final Slot d : selectedSlots ) - { - if( d instanceof SlotDisabled || d instanceof SlotME ) - { - continue; - } - - if( d.isItemValid( tis ) ) - { - if( d.getHasStack() ) - { - final ItemStack t = d.getStack().copy(); - - if( Platform.itemComparisons().isSameItem( t, tis ) ) - { - int maxSize = t.getMaxStackSize(); - if( maxSize > d.getSlotStackLimit() ) - { - maxSize = d.getSlotStackLimit(); - } - - int placeable = maxSize - t.getCount(); - if (placeable > 0) { - if (tis.getCount() < placeable) { - placeable = tis.getCount(); - } - - t.setCount(t.getCount() + placeable); - tis.setCount(tis.getCount() - placeable); - - d.putStack(t); - - if (tis.getCount() <= 0) { - clickSlot.putStack(ItemStack.EMPTY); - d.onSlotChanged(); - - this.updateSlot(clickSlot); - this.updateSlot(d); - return ItemStack.EMPTY; - } else { - this.updateSlot(d); - } - } - } - } - else - { - int maxSize = tis.getMaxStackSize(); - if( maxSize > d.getSlotStackLimit() ) - { - maxSize = d.getSlotStackLimit(); - } - - final ItemStack tmp = tis.copy(); - if( tmp.getCount() > maxSize ) - { - tmp.setCount( maxSize ); - } - - tis.setCount( tis.getCount() - tmp.getCount() ); - d.putStack( tmp ); - - if( tis.getCount() <= 0 ) - { - clickSlot.putStack( ItemStack.EMPTY ); - d.onSlotChanged(); - - this.updateSlot( clickSlot ); - this.updateSlot( d ); - return ItemStack.EMPTY; - } - else - { - this.updateSlot( d ); - } - } - } - } - } - - clickSlot.putStack( !tis.isEmpty() ? tis : ItemStack.EMPTY ); - } - - this.updateSlot( clickSlot ); - return ItemStack.EMPTY; - } - - @Override - public final void updateProgressBar( final int idx, final int value ) - { - if( this.syncData.containsKey( idx ) ) - { - this.syncData.get( idx ).update( (long) value ); - } - } - - @Override - public boolean canInteractWith( final PlayerEntity PlayerEntity ) - { - if( this.isValidContainer() ) - { - if( this.tileEntity instanceof IInventory ) - { - return ( (IInventory) this.tileEntity ).isUsableByPlayer( PlayerEntity ); - } - return true; - } - return false; - } - - @Override - public boolean canDragIntoSlot( final Slot s ) - { - return ( (AppEngSlot) s ).isDraggable(); - } - - public void doAction( final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id ) - { - if( slot >= 0 && slot < this.inventorySlots.size() ) - { - final Slot s = this.getSlot( slot ); - - if( s instanceof SlotCraftingTerm ) - { - switch( action ) - { - case CRAFT_SHIFT: - case CRAFT_ITEM: - case CRAFT_STACK: - ( (SlotCraftingTerm) s ).doClick( action, player ); - this.updateHeld( player ); - default: - } - } - - if( s instanceof SlotFake ) - { - final ItemStack hand = player.inventory.getItemStack(); - - switch( action ) - { - case PICKUP_OR_SET_DOWN: - - if( hand.isEmpty() ) - { - s.putStack( ItemStack.EMPTY ); - } - else - { - s.putStack( hand.copy() ); - } - - break; - case PLACE_SINGLE: - - if( !hand.isEmpty() ) - { - final ItemStack is = hand.copy(); - is.setCount( 1 ); - s.putStack( is ); - } - - break; - case SPLIT_OR_PLACE_SINGLE: - - ItemStack is = s.getStack(); - if( !is.isEmpty() ) - { - if( hand.isEmpty() ) - { - is.setCount( Math.max( 1, is.getCount() - 1 ) ); - } - else if( hand.isItemEqual( is ) ) - { - is.setCount( Math.min( is.getMaxStackSize(), is.getCount() + 1 ) ); - } - else - { - is = hand.copy(); - is.setCount( 1 ); - } - - s.putStack( is ); - } - else if( !hand.isEmpty() ) - { - is = hand.copy(); - is.setCount( 1 ); - s.putStack( is ); - } - - break; - case CREATIVE_DUPLICATE: - case MOVE_REGION: - case SHIFT_CLICK: - default: - break; - } - } - - if( action == InventoryAction.MOVE_REGION ) - { - final List from = new ArrayList<>(); - - for( final Object j : this.inventorySlots ) - { - if( j instanceof Slot && j.getClass() == s.getClass() && !( j instanceof SlotCraftingTerm ) ) - { - from.add( (Slot) j ); - } - } - - for( final Slot fr : from ) - { - this.transferStackInSlot( player, fr.slotNumber ); - } - } - - return; - } - - // get target item. - final IAEItemStack slotItem = this.clientRequestedTargetItem; - - switch( action ) - { - case SHIFT_CLICK: - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - if( slotItem != null ) - { - IAEItemStack ais = slotItem.copy(); - ItemStack myItem = ais.createItemStack(); - - ais.setStackSize( myItem.getMaxStackSize() ); - - final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player ); - myItem.setCount( (int) ais.getStackSize() ); - myItem = adp.simulateAdd( myItem ); - - if( !myItem.isEmpty() ) - { - ais.setStackSize( ais.getStackSize() - myItem.getCount() ); - } - - ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais != null ) - { - adp.addItems( ais.createItemStack() ); - } - } - break; - case ROLL_DOWN: - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - final int releaseQty = 1; - final ItemStack isg = player.inventory.getItemStack(); - - if( !isg.isEmpty() && releaseQty > 0 ) - { - IAEItemStack ais = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( isg ); - ais.setStackSize( 1 ); - final IAEItemStack extracted = ais.copy(); - - ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais == null ) - { - final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) ); - - final ItemStack fail = ia.removeItems( 1, extracted.getDefinition(), null ); - if( fail.isEmpty() ) - { - this.getCellInventory().extractItems( extracted, Actionable.MODULATE, this.getActionSource() ); - } - - this.updateHeld( player ); - } - } - - break; - case ROLL_UP: - case PICKUP_SINGLE: - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - if( slotItem != null ) - { - int liftQty = 1; - final ItemStack item = player.inventory.getItemStack(); - - if( !item.isEmpty() ) - { - if( item.getCount() >= item.getMaxStackSize() ) - { - liftQty = 0; - } - if( !Platform.itemComparisons().isSameItem( slotItem.getDefinition(), item ) ) - { - liftQty = 0; - } - } - - if( liftQty > 0 ) - { - IAEItemStack ais = slotItem.copy(); - ais.setStackSize( 1 ); - ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais != null ) - { - final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) ); - - final ItemStack fail = ia.addItems( ais.createItemStack() ); - if( !fail.isEmpty() ) - { - this.getCellInventory().injectItems( ais, Actionable.MODULATE, this.getActionSource() ); - } - - this.updateHeld( player ); - } - } - } - break; - case PICKUP_OR_SET_DOWN: - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - if( player.inventory.getItemStack().isEmpty() ) - { - if( slotItem != null ) - { - IAEItemStack ais = slotItem.copy(); - ais.setStackSize( ais.getDefinition().getMaxStackSize() ); - ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais != null ) - { - player.inventory.setItemStack( ais.createItemStack() ); - } - else - { - player.inventory.setItemStack( ItemStack.EMPTY ); - } - this.updateHeld( player ); - } - } - else - { - IAEItemStack ais = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( player.inventory.getItemStack() ); - ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais != null ) - { - player.inventory.setItemStack( ais.createItemStack() ); - } - else - { - player.inventory.setItemStack( ItemStack.EMPTY ); - } - this.updateHeld( player ); - } - - break; - case SPLIT_OR_PLACE_SINGLE: - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - if( player.inventory.getItemStack().isEmpty() ) - { - if( slotItem != null ) - { - IAEItemStack ais = slotItem.copy(); - final long maxSize = ais.getDefinition().getMaxStackSize(); - ais.setStackSize( maxSize ); - ais = this.getCellInventory().extractItems( ais, Actionable.SIMULATE, this.getActionSource() ); - - if( ais != null ) - { - final long stackSize = Math.min( maxSize, ais.getStackSize() ); - ais.setStackSize( ( stackSize + 1 ) >> 1 ); - ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - } - - if( ais != null ) - { - player.inventory.setItemStack( ais.createItemStack() ); - } - else - { - player.inventory.setItemStack( ItemStack.EMPTY ); - } - this.updateHeld( player ); - } - } - else - { - IAEItemStack ais = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( player.inventory.getItemStack() ); - ais.setStackSize( 1 ); - ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais == null ) - { - final ItemStack is = player.inventory.getItemStack(); - is.setCount( is.getCount() - 1 ); - if( is.getCount() <= 0 ) - { - player.inventory.setItemStack( ItemStack.EMPTY ); - } - this.updateHeld( player ); - } - } - - break; - case CREATIVE_DUPLICATE: - if( player.abilities.isCreativeMode && slotItem != null ) - { - final ItemStack is = slotItem.createItemStack(); - is.setCount( is.getMaxStackSize() ); - player.inventory.setItemStack( is ); - this.updateHeld( player ); - } - break; - case MOVE_REGION: - - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return; - } - - if( slotItem != null ) - { - final int playerInv = 9 * 4; - for( int slotNum = 0; slotNum < playerInv; slotNum++ ) - { - IAEItemStack ais = slotItem.copy(); - ItemStack myItem = ais.createItemStack(); - - ais.setStackSize( myItem.getMaxStackSize() ); - - final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player ); - myItem.setCount( (int) ais.getStackSize() ); - myItem = adp.simulateAdd( myItem ); - - if( !myItem.isEmpty() ) - { - ais.setStackSize( ais.getStackSize() - myItem.getCount() ); - } - - ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); - if( ais != null ) - { - adp.addItems( ais.createItemStack() ); - } - else - { - return; - } - } - } - - break; - default: - break; - } - } - - protected void updateHeld( final ServerPlayerEntity p ) - { - if( Platform.isServer() ) - { - NetworkHandler.instance() - .sendTo( - new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ), - p ); - } - } - - protected ItemStack transferStackToContainer( final ItemStack input ) - { - return this.shiftStoreItem( input ); - } - - private ItemStack shiftStoreItem( final ItemStack input ) - { - if( this.getPowerSource() == null || this.getCellInventory() == null ) - { - return input; - } - final IAEItemStack ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( input ), - this.getActionSource() ); - if( ais == null ) - { - return ItemStack.EMPTY; - } - return ais.createItemStack(); - } - - private void updateSlot( final Slot clickSlot ) - { - // ??? - this.detectAndSendChanges(); - } - - private void sendCustomName() - { - // FIXME: Trash this, this is handled by NamedContainerProvider now - if( !this.sentCustomName ) - { - this.sentCustomName = true; - if( Platform.isServer() ) - { - ICustomNameObject name = null; - - if( this.part instanceof ICustomNameObject ) - { - name = (ICustomNameObject) this.part; - } - - if( this.tileEntity instanceof ICustomNameObject ) - { - name = (ICustomNameObject) this.tileEntity; - } - - if( this.obj instanceof ICustomNameObject ) - { - name = (ICustomNameObject) this.obj; - } - - if( this instanceof ICustomNameObject ) - { - name = (ICustomNameObject) this; - } - - if( name != null ) - { - if( name.hasCustomInventoryName() ) - { - this.setCustomName( name.getCustomInventoryName().getString() ); - } - - if( this.getCustomName() != null ) - { - NetworkHandler.instance() - .sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ), - (ServerPlayerEntity) this.getPlayerInventory().player ); - } - } - } - } - } - - public void swapSlotContents( final int slotA, final int slotB ) - { - final Slot a = this.getSlot( slotA ); - final Slot b = this.getSlot( slotB ); - - // NPE protection... - if( a == null || b == null ) - { - return; - } - - final ItemStack isA = a.getStack(); - final ItemStack isB = b.getStack(); - - // something to do? - if( isA.isEmpty() && isB.isEmpty() ) - { - return; - } - - // can take? - - if( !isA.isEmpty() && !a.canTakeStack( this.getPlayerInventory().player ) ) - { - return; - } - - if( !isB.isEmpty() && !b.canTakeStack( this.getPlayerInventory().player ) ) - { - return; - } - - // swap valid? - - if( !isB.isEmpty() && !a.isItemValid( isB ) ) - { - return; - } - - if( !isA.isEmpty() && !b.isItemValid( isA ) ) - { - return; - } - - ItemStack testA = isB.isEmpty() ? ItemStack.EMPTY : isB.copy(); - ItemStack testB = isA.isEmpty() ? ItemStack.EMPTY : isA.copy(); - - // can put some back? - if( !testA.isEmpty() && testA.getCount() > a.getSlotStackLimit() ) - { - if( !testB.isEmpty() ) - { - return; - } - - final int totalA = testA.getCount(); - testA.setCount( a.getSlotStackLimit() ); - testB = testA.copy(); - - testB.setCount( totalA - testA.getCount() ); - } - - if( !testB.isEmpty() && testB.getCount() > b.getSlotStackLimit() ) - { - if( !testA.isEmpty() ) - { - return; - } - - final int totalB = testB.getCount(); - testB.setCount( b.getSlotStackLimit() ); - testA = testB.copy(); - - testA.setCount( totalB - testA.getCount() ); - } - - a.putStack( testA ); - b.putStack( testB ); - } - - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - - } - - public void onSlotChange( final Slot s ) - { - - } - - public boolean isValidForSlot( final Slot s, final ItemStack i ) - { - return true; - } - - public IMEInventoryHandler getCellInventory() - { - return this.cellInv; - } - - public void setCellInventory( final IMEInventoryHandler cellInv ) - { - this.cellInv = cellInv; - } - - public String getCustomName() - { - return this.customName; - } - - public void setCustomName( final String customName ) - { - this.customName = customName; - } - - public PlayerInventory getPlayerInventory() - { - return this.invPlayer; - } - - public boolean isValidContainer() - { - return this.isContainerValid; - } - - public void setValidContainer( final boolean isContainerValid ) - { - this.isContainerValid = isContainerValid; - } - - public ContainerLocator getLocator() - { - return this.locator; - } - - public void setLocator(final ContainerLocator locator) - { - this.locator = locator; - } - - public IEnergySource getPowerSource() - { - return this.powerSrc; - } - - public void setPowerSource( final IEnergySource powerSrc ) - { - this.powerSrc = powerSrc; - } + final int totalB = testB.getCount(); + testB.setCount(b.getSlotStackLimit()); + testA = testB.copy(); + + testA.setCount(totalB - testA.getCount()); + } + + a.putStack(testA); + b.putStack(testB); + } + + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + + } + + public void onSlotChange(final Slot s) { + + } + + public boolean isValidForSlot(final Slot s, final ItemStack i) { + return true; + } + + public IMEInventoryHandler getCellInventory() { + return this.cellInv; + } + + public void setCellInventory(final IMEInventoryHandler cellInv) { + this.cellInv = cellInv; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + public PlayerInventory getPlayerInventory() { + return this.invPlayer; + } + + public boolean isValidContainer() { + return this.isContainerValid; + } + + public void setValidContainer(final boolean isContainerValid) { + this.isContainerValid = isContainerValid; + } + + public ContainerLocator getLocator() { + return this.locator; + } + + public void setLocator(final ContainerLocator locator) { + this.locator = locator; + } + + public IEnergySource getPowerSource() { + return this.powerSrc; + } + + public void setPowerSource(final IEnergySource powerSrc) { + this.powerSrc = powerSrc; + } } diff --git a/src/main/java/appeng/container/ContainerLocator.java b/src/main/java/appeng/container/ContainerLocator.java index 3f63087df..487e0fe10 100644 --- a/src/main/java/appeng/container/ContainerLocator.java +++ b/src/main/java/appeng/container/ContainerLocator.java @@ -18,13 +18,10 @@ package appeng.container; - -import appeng.api.parts.IPartHost; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.parts.AEBasePart; import com.google.common.base.Preconditions; + import io.netty.handler.codec.DecoderException; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; @@ -34,14 +31,19 @@ import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import appeng.api.parts.IPartHost; +import appeng.api.util.AEPartLocation; +import appeng.api.util.DimensionalCoord; +import appeng.parts.AEBasePart; + /** - * Describes how a container the player has opened was originally - * located. This can be one of three ways: + * Describes how a container the player has opened was originally located. This + * can be one of three ways: * *
    - *
  • A tile entity at a given block position.
  • - *
  • A part (i.e. cable bus part) at the side of a given block position.
  • - *
  • An item held by the player.
  • + *
  • A tile entity at a given block position.
  • + *
  • A part (i.e. cable bus part) at the side of a given block position.
  • + *
  • An item held by the player.
  • *
*/ public final class ContainerLocator { @@ -52,13 +54,10 @@ public final class ContainerLocator { */ PLAYER_INVENTORY, /** - * An item used from the player's inventory, but right-clicked - * on a block face, has block position and side in addition to the - * above. + * An item used from the player's inventory, but right-clicked on a block face, + * has block position and side in addition to the above. */ - PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, - BLOCK, - PART + PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, BLOCK, PART } private final Type type; @@ -92,8 +91,9 @@ public final class ContainerLocator { } /** - * Construct a container locator for an item being used on a block. The item could still open a container - * for itself, but it might also open a special container for the block being right-clicked. + * Construct a container locator for an item being used on a block. The item + * could still open a container for itself, but it might also open a special + * container for the block being right-clicked. */ public static ContainerLocator forItemUseContext(ItemUseContext context) { PlayerEntity player = context.getPlayer(); @@ -103,7 +103,8 @@ public final class ContainerLocator { int dimensionId = player.world.getDimension().getType().getId(); int slot = getPlayerInventorySlotFromHand(player, context.getHand()); AEPartLocation side = AEPartLocation.fromFacing(context.getFace()); - return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, dimensionId, context.getPos(), side); + return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, dimensionId, context.getPos(), + side); } public static ContainerLocator forHand(PlayerEntity player, Hand hand) { @@ -128,13 +129,8 @@ public final class ContainerLocator { public static ContainerLocator forPart(AEBasePart part) { IPartHost host = part.getHost(); DimensionalCoord pos = host.getLocation(); - return new ContainerLocator( - Type.PART, - -1, - pos.getWorld().getDimension().getType().getId(), - pos.getBlockPos(), - part.getSide() - ); + return new ContainerLocator(Type.PART, -1, pos.getWorld().getDimension().getType().getId(), pos.getBlockPos(), + part.getSide()); } public boolean hasItemIndex() { @@ -201,37 +197,15 @@ public final class ContainerLocator { byte type = buf.readByte(); switch (type) { case 0: - return new ContainerLocator( - Type.PLAYER_INVENTORY, - buf.readInt(), - -1, - null, - null - ); + return new ContainerLocator(Type.PLAYER_INVENTORY, buf.readInt(), -1, null, null); case 1: - return new ContainerLocator( - Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, - buf.readInt(), - buf.readInt(), - buf.readBlockPos(), - AEPartLocation.values()[buf.readByte()] - ); + return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, buf.readInt(), buf.readInt(), + buf.readBlockPos(), AEPartLocation.values()[buf.readByte()]); case 2: - return new ContainerLocator( - Type.BLOCK, - -1, - buf.readInt(), - buf.readBlockPos(), - null - ); + return new ContainerLocator(Type.BLOCK, -1, buf.readInt(), buf.readBlockPos(), null); case 3: - return new ContainerLocator( - Type.PART, - -1, - buf.readInt(), - buf.readBlockPos(), - AEPartLocation.values()[buf.readByte()] - ); + return new ContainerLocator(Type.PART, -1, buf.readInt(), buf.readBlockPos(), + AEPartLocation.values()[buf.readByte()]); default: throw new DecoderException("ContainerLocator type out of range: " + type); } diff --git a/src/main/java/appeng/container/ContainerNull.java b/src/main/java/appeng/container/ContainerNull.java index 2c4aae645..58e06ad7b 100644 --- a/src/main/java/appeng/container/ContainerNull.java +++ b/src/main/java/appeng/container/ContainerNull.java @@ -18,25 +18,20 @@ package appeng.container; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.Container; - /* * Totally useless container that does nothing. */ -public class ContainerNull extends Container -{ +public class ContainerNull extends Container { - public ContainerNull() - { - super( null, 0 ); - } + public ContainerNull() { + super(null, 0); + } - @Override - public boolean canInteractWith( final PlayerEntity PlayerEntity ) - { - return false; - } + @Override + public boolean canInteractWith(final PlayerEntity PlayerEntity) { + return false; + } } diff --git a/src/main/java/appeng/container/ContainerOpener.java b/src/main/java/appeng/container/ContainerOpener.java index 98904c36d..2ad52b172 100644 --- a/src/main/java/appeng/container/ContainerOpener.java +++ b/src/main/java/appeng/container/ContainerOpener.java @@ -1,13 +1,14 @@ package appeng.container; -import appeng.core.AELog; +import java.util.HashMap; +import java.util.Map; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.ContainerType; -import java.util.HashMap; -import java.util.Map; +import appeng.core.AELog; /** * Allows opening containers generically. diff --git a/src/main/java/appeng/container/guisync/GuiSync.java b/src/main/java/appeng/container/guisync/GuiSync.java index 14d6e922f..b0bb5d002 100644 --- a/src/main/java/appeng/container/guisync/GuiSync.java +++ b/src/main/java/appeng/container/guisync/GuiSync.java @@ -18,21 +18,18 @@ package appeng.container.guisync; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** - * Annotates that this field should be synchronized between the server and client. - * Requires the field to be public. + * Annotates that this field should be synchronized between the server and + * client. Requires the field to be public. */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( ElementType.FIELD ) -public @interface GuiSync -{ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface GuiSync { - int value(); + int value(); } diff --git a/src/main/java/appeng/container/guisync/SyncData.java b/src/main/java/appeng/container/guisync/SyncData.java index 7138b7db8..e00cc4413 100644 --- a/src/main/java/appeng/container/guisync/SyncData.java +++ b/src/main/java/appeng/container/guisync/SyncData.java @@ -18,187 +18,129 @@ package appeng.container.guisync; - import java.io.IOException; import java.lang.reflect.Field; import java.util.EnumSet; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.IContainerListener; + import appeng.container.AEBaseContainer; import appeng.core.AELog; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketProgressBar; import appeng.core.sync.packets.PacketValueConfig; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.IContainerListener; +public class SyncData { -public class SyncData -{ + private final AEBaseContainer source; + private final Field field; + private final int channel; + private Object clientVersion; - private final AEBaseContainer source; - private final Field field; - private final int channel; - private Object clientVersion; + public SyncData(final AEBaseContainer container, final Field field, final GuiSync annotation) { + this.clientVersion = null; + this.source = container; + this.field = field; + this.channel = annotation.value(); + } - public SyncData( final AEBaseContainer container, final Field field, final GuiSync annotation ) - { - this.clientVersion = null; - this.source = container; - this.field = field; - this.channel = annotation.value(); - } + public int getChannel() { + return this.channel; + } - public int getChannel() - { - return this.channel; - } + public void tick(final IContainerListener c) { + try { + final Object val = this.field.get(this.source); + if (val != null && this.clientVersion == null) { + this.send(c, val); + } else if (!val.equals(this.clientVersion)) { + this.send(c, val); + } + } catch (final IllegalArgumentException | IllegalAccessException e) { + AELog.debug(e); + } - public void tick( final IContainerListener c ) - { - try - { - final Object val = this.field.get( this.source ); - if( val != null && this.clientVersion == null ) - { - this.send( c, val ); - } - else if( !val.equals( this.clientVersion ) ) - { - this.send( c, val ); - } - } - catch( final IllegalArgumentException | IllegalAccessException e ) - { - AELog.debug( e ); - } + } - } + private void send(final IContainerListener o, final Object val) { + if (val instanceof String) { + if (o instanceof ServerPlayerEntity) { + NetworkHandler.instance().sendTo(new PacketValueConfig("SyncDat." + this.channel, (String) val), + (ServerPlayerEntity) o); + } + } else if (this.field.getType().isEnum()) { + o.sendWindowProperty(this.source, this.channel, ((Enum) val).ordinal()); + } else if (val instanceof Long || val.getClass() == long.class) { + if (o instanceof ServerPlayerEntity) { + NetworkHandler.instance().sendTo(new PacketProgressBar(this.channel, (Long) val), + (ServerPlayerEntity) o); + } + } else if (val instanceof Boolean || val.getClass() == boolean.class) { + o.sendWindowProperty(this.source, this.channel, ((Boolean) val) ? 1 : 0); + } else { + o.sendWindowProperty(this.source, this.channel, (Integer) val); + } - private void send( final IContainerListener o, final Object val ) - { - if( val instanceof String ) - { - if( o instanceof ServerPlayerEntity) - { - NetworkHandler.instance().sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (ServerPlayerEntity) o ); - } - } - else if( this.field.getType().isEnum() ) - { - o.sendWindowProperty( this.source, this.channel, ( (Enum) val ).ordinal() ); - } - else if( val instanceof Long || val.getClass() == long.class ) - { - if( o instanceof ServerPlayerEntity ) - { - NetworkHandler.instance().sendTo( new PacketProgressBar( this.channel, (Long) val ), (ServerPlayerEntity) o ); - } - } - else if( val instanceof Boolean || val.getClass() == boolean.class ) - { - o.sendWindowProperty( this.source, this.channel, ( (Boolean) val ) ? 1 : 0 ); - } - else - { - o.sendWindowProperty( this.source, this.channel, (Integer) val ); - } + this.clientVersion = val; + } - this.clientVersion = val; - } + public void update(final Object val) { + try { + final Object oldValue = this.field.get(this.source); + if (val instanceof String) { + this.updateString(oldValue, (String) val); + } else { + this.updateValue(oldValue, (Long) val); + } + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } catch (final IllegalAccessException e) { + AELog.debug(e); + } + } - public void update( final Object val ) - { - try - { - final Object oldValue = this.field.get( this.source ); - if( val instanceof String ) - { - this.updateString( oldValue, (String) val ); - } - else - { - this.updateValue( oldValue, (Long) val ); - } - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - catch( final IllegalAccessException e ) - { - AELog.debug( e ); - } - } + private void updateString(final Object oldValue, final String val) { + try { + this.field.set(this.source, val); + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } catch (final IllegalAccessException e) { + AELog.debug(e); + } + } - private void updateString( final Object oldValue, final String val ) - { - try - { - this.field.set( this.source, val ); - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - catch( final IllegalAccessException e ) - { - AELog.debug( e ); - } - } + private void updateValue(final Object oldValue, final long val) { + try { + if (this.field.getType().isEnum()) { + final EnumSet valList = EnumSet.allOf((Class) this.field.getType()); + for (final Enum e : valList) { + if (e.ordinal() == val) { + this.field.set(this.source, e); + break; + } + } + } else { + if (this.field.getType().equals(int.class)) { + this.field.set(this.source, (int) val); + } else if (this.field.getType().equals(long.class)) { + this.field.set(this.source, val); + } else if (this.field.getType().equals(boolean.class)) { + this.field.set(this.source, val == 1); + } else if (this.field.getType().equals(Integer.class)) { + this.field.set(this.source, (int) val); + } else if (this.field.getType().equals(Long.class)) { + this.field.set(this.source, val); + } else if (this.field.getType().equals(Boolean.class)) { + this.field.set(this.source, val == 1); + } + } - private void updateValue( final Object oldValue, final long val ) - { - try - { - if( this.field.getType().isEnum() ) - { - final EnumSet valList = EnumSet.allOf( (Class) this.field.getType() ); - for( final Enum e : valList ) - { - if( e.ordinal() == val ) - { - this.field.set( this.source, e ); - break; - } - } - } - else - { - if( this.field.getType().equals( int.class ) ) - { - this.field.set( this.source, (int) val ); - } - else if( this.field.getType().equals( long.class ) ) - { - this.field.set( this.source, val ); - } - else if( this.field.getType().equals( boolean.class ) ) - { - this.field.set( this.source, val == 1 ); - } - else if( this.field.getType().equals( Integer.class ) ) - { - this.field.set( this.source, (int) val ); - } - else if( this.field.getType().equals( Long.class ) ) - { - this.field.set( this.source, val ); - } - else if( this.field.getType().equals( Boolean.class ) ) - { - this.field.set( this.source, val == 1 ); - } - } - - this.source.onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) ); - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - catch( final IllegalAccessException e ) - { - AELog.debug( e ); - } - } + this.source.onUpdate(this.field.getName(), oldValue, this.field.get(this.source)); + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } catch (final IllegalAccessException e) { + AELog.debug(e); + } + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java index e791ac11b..f5e258b1f 100644 --- a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java +++ b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java @@ -18,15 +18,11 @@ package appeng.container.implementations; - import java.util.Iterator; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; -import appeng.util.EnumCycler; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.*; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; @@ -44,242 +40,210 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.OptionalSlotRestrictedInput; import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.misc.TileCellWorkbench; +import appeng.util.EnumCycler; import appeng.util.Platform; import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.WrapperSupplierItemHandler; import appeng.util.iterators.NullIterator; +public class ContainerCellWorkbench extends ContainerUpgradeable { -public class ContainerCellWorkbench extends ContainerUpgradeable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCellWorkbench::new, TileCellWorkbench.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCellWorkbench::new, TileCellWorkbench.class); + private final TileCellWorkbench workBench; + @GuiSync(2) + public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE; + private ItemStack prevStack = ItemStack.EMPTY; + private int lastUpgrades = 0; - private final TileCellWorkbench workBench; - @GuiSync( 2 ) - public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE; - private ItemStack prevStack = ItemStack.EMPTY; - private int lastUpgrades = 0; + public ContainerCellWorkbench(int id, final PlayerInventory ip, final TileCellWorkbench te) { + super(TYPE, id, ip, te); + this.workBench = te; + } - public ContainerCellWorkbench(int id, final PlayerInventory ip, final TileCellWorkbench te ) - { - super( TYPE, id, ip, te ); - this.workBench = te; - } + public static ContainerCellWorkbench fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerCellWorkbench fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public void setFuzzy(final FuzzyMode valueOf) { + final ICellWorkbenchItem cwi = this.workBench.getCell(); + if (cwi != null) { + cwi.setFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0), valueOf); + } + } - public void setFuzzy( final FuzzyMode valueOf ) - { - final ICellWorkbenchItem cwi = this.workBench.getCell(); - if( cwi != null ) - { - cwi.setFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf ); - } - } + public void nextWorkBenchCopyMode() { + this.workBench.getConfigManager().putSetting(Settings.COPY_MODE, EnumCycler.next(this.getWorkBenchCopyMode())); + } - public void nextWorkBenchCopyMode() - { - this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, EnumCycler.next( this.getWorkBenchCopyMode() ) ); - } + private CopyMode getWorkBenchCopyMode() { + return (CopyMode) this.workBench.getConfigManager().getSetting(Settings.COPY_MODE); + } - private CopyMode getWorkBenchCopyMode() - { - return (CopyMode) this.workBench.getConfigManager().getSetting( Settings.COPY_MODE ); - } + @Override + protected int getHeight() { + return 251; + } - @Override - protected int getHeight() - { - return 251; - } + @Override + protected void setupConfig() { + final IItemHandler cell = this.getUpgradeable().getInventoryByName("cell"); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, + this.getPlayerInv())); - @Override - protected void setupConfig() - { - final IItemHandler cell = this.getUpgradeable().getInventoryByName( "cell" ); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.getPlayerInv() ) ); + final IItemHandler inv = this.getUpgradeable().getInventoryByName("config"); + final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler( + this::getCellUpgradeInventory); + // null, 3 * 8 ); - final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); - final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler( this::getCellUpgradeInventory ); - // null, 3 * 8 ); + int offset = 0; + final int y = 29; + final int x = 8; + for (int w = 0; w < 7; w++) { + for (int z = 0; z < 9; z++) { + this.addSlot(new SlotFakeTypeOnly(inv, offset, x + z * 18, y + w * 18)); + offset++; + } + } - int offset = 0; - final int y = 29; - final int x = 8; - for( int w = 0; w < 7; w++ ) - { - for( int z = 0; z < 9; z++ ) - { - this.addSlot( new SlotFakeTypeOnly( inv, offset, x + z * 18, y + w * 18 ) ); - offset++; - } - } + for (int zz = 0; zz < 3; zz++) { + for (int z = 0; z < 8; z++) { + final int iSLot = zz * 8 + z; + this.addSlot(new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, + upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.getPlayerInventory())); + } + } + /* + * if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; + * z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, + * x, y, z, w, 1 ) ); for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) + * addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, + * z, w + 2, 2 ) ); for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) + * addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, + * z, w + 4, 3 ) ); } + */ + } - for( int zz = 0; zz < 3; zz++ ) - { - for( int z = 0; z < 8; z++ ) - { - final int iSLot = zz * 8 + z; - this.addSlot( - new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this - .getPlayerInventory() ) ); - } - } - /* - * if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new - * OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) ); - * for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( - * inv, this, offset++, x, y, z, w + 2, 2 ) ); - * for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( - * inv, this, offset++, x, y, z, w + 4, 3 ) ); } - */ - } + @Override + public int availableUpgrades() { + final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0); + if (this.prevStack != is) { + this.prevStack = is; + this.lastUpgrades = this.getCellUpgradeInventory().getSlots(); + } + return this.lastUpgrades; + } - @Override - public int availableUpgrades() - { - final ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ); - if( this.prevStack != is ) - { - this.prevStack = is; - this.lastUpgrades = this.getCellUpgradeInventory().getSlots(); - } - return this.lastUpgrades; - } + @Override + public void detectAndSendChanges() { + final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0); + if (Platform.isServer()) { + for (final IContainerListener listener : this.listeners) { + if (this.prevStack != is) { + // if the bars changed an item was probably made, so just send shit! + for (final Slot s : this.inventorySlots) { + if (s instanceof OptionalSlotRestrictedInput) { + final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s; + listener.sendSlotContents(this, sri.slotNumber, sri.getStack()); + } + } - @Override - public void detectAndSendChanges() - { - final ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ); - if( Platform.isServer() ) - { - for( final IContainerListener listener : this.listeners ) - { - if( this.prevStack != is ) - { - // if the bars changed an item was probably made, so just send shit! - for( final Slot s : this.inventorySlots ) - { - if( s instanceof OptionalSlotRestrictedInput ) - { - final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s; - listener.sendSlotContents( this, sri.slotNumber, sri.getStack() ); - } - } + if (listener instanceof ServerPlayerEntity) { + ((ServerPlayerEntity) listener).isChangingQuantityOnly = false; + } + } + } - if( listener instanceof ServerPlayerEntity ) - { - ( (ServerPlayerEntity) listener ).isChangingQuantityOnly = false; - } - } - } + this.setCopyMode(this.getWorkBenchCopyMode()); + this.setFuzzyMode(this.getWorkBenchFuzzyMode()); + } - this.setCopyMode( this.getWorkBenchCopyMode() ); - this.setFuzzyMode( this.getWorkBenchFuzzyMode() ); - } + this.prevStack = is; + this.standardDetectAndSendChanges(); + } - this.prevStack = is; - this.standardDetectAndSendChanges(); - } + @Override + public boolean isSlotEnabled(final int idx) { + return idx < this.availableUpgrades(); + } - @Override - public boolean isSlotEnabled( final int idx ) - { - return idx < this.availableUpgrades(); - } + public IItemHandler getCellUpgradeInventory() { + final IItemHandler upgradeInventory = this.workBench.getCellUpgradeInventory(); - public IItemHandler getCellUpgradeInventory() - { - final IItemHandler upgradeInventory = this.workBench.getCellUpgradeInventory(); + return upgradeInventory == null ? EmptyHandler.INSTANCE : upgradeInventory; + } - return upgradeInventory == null ? EmptyHandler.INSTANCE : upgradeInventory; - } + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("copyMode")) { + this.workBench.getConfigManager().putSetting(Settings.COPY_MODE, this.getCopyMode()); + } - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "copyMode" ) ) - { - this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.getCopyMode() ); - } + super.onUpdate(field, oldValue, newValue); + } - super.onUpdate( field, oldValue, newValue ); - } + public void clear() { + ItemHandlerUtil.clear(this.getUpgradeable().getInventoryByName("config")); + this.detectAndSendChanges(); + } - public void clear() - { - ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) ); - this.detectAndSendChanges(); - } + private FuzzyMode getWorkBenchFuzzyMode() { + final ICellWorkbenchItem cwi = this.workBench.getCell(); + if (cwi != null) { + return cwi.getFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0)); + } + return FuzzyMode.IGNORE_ALL; + } - private FuzzyMode getWorkBenchFuzzyMode() - { - final ICellWorkbenchItem cwi = this.workBench.getCell(); - if( cwi != null ) - { - return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) ); - } - return FuzzyMode.IGNORE_ALL; - } + public void partition() { - public void partition() - { + final IItemHandler inv = this.getUpgradeable().getInventoryByName("config"); - final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); + final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0); + final IStorageChannel channel = is.getItem() instanceof IStorageCell + ? ((IStorageCell) is.getItem()).getChannel() + : AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); - final ItemStack is = this.getUpgradeable().getInventoryByName( "cell" ).getStackInSlot( 0 ); - final IStorageChannel channel = is.getItem() instanceof IStorageCell ? ( (IStorageCell) is.getItem() ).getChannel() : AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ); + final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory(is, null, channel); - final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, channel ); + Iterator i = new NullIterator<>(); + if (cellInv != null) { + final IItemList list = cellInv.getAvailableItems(channel.createList()); + i = list.iterator(); + } - Iterator i = new NullIterator<>(); - if( cellInv != null ) - { - final IItemList list = cellInv.getAvailableItems( channel.createList() ); - i = list.iterator(); - } + for (int x = 0; x < inv.getSlots(); x++) { + if (i.hasNext()) { + // TODO: check if ok + final ItemStack g = i.next().asItemStackRepresentation(); + ItemHandlerUtil.setStackInSlot(inv, x, g); + } else { + ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.EMPTY); + } + } - for( int x = 0; x < inv.getSlots(); x++ ) - { - if( i.hasNext() ) - { - // TODO: check if ok - final ItemStack g = i.next().asItemStackRepresentation(); - ItemHandlerUtil.setStackInSlot( inv, x, g ); - } - else - { - ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY ); - } - } + this.detectAndSendChanges(); + } - this.detectAndSendChanges(); - } + public CopyMode getCopyMode() { + return this.copyMode; + } - public CopyMode getCopyMode() - { - return this.copyMode; - } - - private void setCopyMode( final CopyMode copyMode ) - { - this.copyMode = copyMode; - } + private void setCopyMode(final CopyMode copyMode) { + this.copyMode = copyMode; + } } \ No newline at end of file diff --git a/src/main/java/appeng/container/implementations/ContainerChest.java b/src/main/java/appeng/container/implementations/ContainerChest.java index 4753bf783..f6f839ac7 100644 --- a/src/main/java/appeng/container/implementations/ContainerChest.java +++ b/src/main/java/appeng/container/implementations/ContainerChest.java @@ -18,44 +18,40 @@ package appeng.container.implementations; - -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotRestrictedInput; -import appeng.tile.storage.TileChest; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.api.config.SecurityPermissions; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotRestrictedInput; +import appeng.tile.storage.TileChest; -public class ContainerChest extends AEBaseContainer -{ +public class ContainerChest extends AEBaseContainer { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerChest::new, TileChest.class, SecurityPermissions.BUILD); + private static final ContainerHelper helper = new ContainerHelper<>(ContainerChest::new, + TileChest.class, SecurityPermissions.BUILD); - public ContainerChest( int id, final PlayerInventory ip, final TileChest chest ) - { - super( TYPE, id, ip, chest, null ); + public ContainerChest(int id, final PlayerInventory ip, final TileChest chest) { + super(TYPE, id, ip, chest, null); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, chest.getInternalInventory(), 1, 80, 37, this - .getPlayerInventory() ) ); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, + chest.getInternalInventory(), 1, 80, 37, this.getPlayerInventory())); - this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); + } - public static ContainerChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCondenser.java b/src/main/java/appeng/container/implementations/ContainerCondenser.java index 8d1f38e63..b15daa2c3 100644 --- a/src/main/java/appeng/container/implementations/ContainerCondenser.java +++ b/src/main/java/appeng/container/implementations/ContainerCondenser.java @@ -18,6 +18,11 @@ package appeng.container.implementations; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.IItemHandler; import appeng.api.config.CondenserOutput; import appeng.api.config.Settings; @@ -30,87 +35,74 @@ import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.misc.TileCondenser; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.items.IItemHandler; +public class ContainerCondenser extends AEBaseContainer implements IProgressProvider { -public class ContainerCondenser extends AEBaseContainer implements IProgressProvider -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCondenser::new, TileCondenser.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCondenser::new, TileCondenser.class); + private final TileCondenser condenser; + @GuiSync(0) + public long requiredEnergy = 0; + @GuiSync(1) + public long storedPower = 0; + @GuiSync(2) + public CondenserOutput output = CondenserOutput.TRASH; - private final TileCondenser condenser; - @GuiSync( 0 ) - public long requiredEnergy = 0; - @GuiSync( 1 ) - public long storedPower = 0; - @GuiSync( 2 ) - public CondenserOutput output = CondenserOutput.TRASH; + public ContainerCondenser(int id, final PlayerInventory ip, final TileCondenser condenser) { + super(TYPE, id, ip, condenser, null); + this.condenser = condenser; - public ContainerCondenser(int id, final PlayerInventory ip, final TileCondenser condenser ) - { - super( TYPE, id, ip, condenser, null ); - this.condenser = condenser; + IItemHandler inv = condenser.getInternalInventory(); - IItemHandler inv = condenser.getInternalInventory(); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.TRASH, inv, 0, 51, 52, ip)); + this.addSlot(new SlotOutput(inv, 1, 105, 52, -1)); + this.addSlot( + (new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, inv, 2, 101, 26, ip)) + .setStackLimit(1)); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, inv, 0, 51, 52, ip ) ); - this.addSlot( new SlotOutput( inv, 1, 105, 52, -1 ) ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, inv, 2, 101, 26, ip ) ).setStackLimit( 1 ) ); + this.bindPlayerInventory(ip, 0, 197 - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 ); - } + public static ContainerCondenser fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerCondenser fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @Override + public void detectAndSendChanges() { + if (Platform.isServer()) { + final double maxStorage = this.condenser.getStorage(); + final double requiredEnergy = this.condenser.getRequiredPower(); - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() ) - { - final double maxStorage = this.condenser.getStorage(); - final double requiredEnergy = this.condenser.getRequiredPower(); + this.requiredEnergy = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min(requiredEnergy, maxStorage); + this.storedPower = (int) this.condenser.getStoredPower(); + this.setOutput((CondenserOutput) this.condenser.getConfigManager().getSetting(Settings.CONDENSER_OUTPUT)); + } - this.requiredEnergy = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min( requiredEnergy, maxStorage ); - this.storedPower = (int) this.condenser.getStoredPower(); - this.setOutput( (CondenserOutput) this.condenser.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ) ); - } + super.detectAndSendChanges(); + } - super.detectAndSendChanges(); - } + @Override + public int getCurrentProgress() { + return (int) this.storedPower; + } - @Override - public int getCurrentProgress() - { - return (int) this.storedPower; - } + @Override + public int getMaxProgress() { + return (int) this.requiredEnergy; + } - @Override - public int getMaxProgress() - { - return (int) this.requiredEnergy; - } + public CondenserOutput getOutput() { + return this.output; + } - public CondenserOutput getOutput() - { - return this.output; - } - - private void setOutput( final CondenserOutput output ) - { - this.output = output; - } + private void setOutput(final CondenserOutput output) { + this.output = output; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftAmount.java b/src/main/java/appeng/container/implementations/ContainerCraftAmount.java index 811555106..2615e1b5b 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftAmount.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftAmount.java @@ -18,10 +18,8 @@ package appeng.container.implementations; - import javax.annotation.Nonnull; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -36,72 +34,64 @@ import appeng.api.networking.security.IActionSource; import appeng.api.storage.ITerminalHost; import appeng.api.storage.data.IAEItemStack; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.slot.SlotInaccessible; import appeng.me.helpers.PlayerSource; import appeng.tile.inventory.AppEngInternalInventory; +public class ContainerCraftAmount extends AEBaseContainer { -public class ContainerCraftAmount extends AEBaseContainer -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCraftAmount::new, ITerminalHost.class, SecurityPermissions.CRAFT); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCraftAmount::new, ITerminalHost.class, SecurityPermissions.CRAFT); + private final Slot craftingItem; + private IAEItemStack itemToCreate; - private final Slot craftingItem; - private IAEItemStack itemToCreate; + public ContainerCraftAmount(int id, PlayerInventory ip, final ITerminalHost te) { + super(TYPE, id, ip, te); - public ContainerCraftAmount(int id, PlayerInventory ip, final ITerminalHost te) { - super(TYPE, id, ip, te); + this.craftingItem = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53); + this.addSlot(this.getCraftingItem()); + } - this.craftingItem = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 ); - this.addSlot( this.getCraftingItem() ); - } + public static ContainerCraftAmount fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerCraftAmount fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + this.verifyPermissions(SecurityPermissions.CRAFT, false); + } - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - this.verifyPermissions( SecurityPermissions.CRAFT, false ); - } + public IGrid getGrid() { + final IActionHost h = ((IActionHost) this.getTarget()); + return h.getActionableNode().getGrid(); + } - public IGrid getGrid() - { - final IActionHost h = ( (IActionHost) this.getTarget() ); - return h.getActionableNode().getGrid(); - } + public World getWorld() { + return this.getPlayerInv().player.world; + } - public World getWorld() - { - return this.getPlayerInv().player.world; - } + public IActionSource getActionSrc() { + return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget()); + } - public IActionSource getActionSrc() - { - return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() ); - } + public Slot getCraftingItem() { + return this.craftingItem; + } - public Slot getCraftingItem() - { - return this.craftingItem; - } + public IAEItemStack getItemToCraft() { + return this.itemToCreate; + } - public IAEItemStack getItemToCraft() - { - return this.itemToCreate; - } - - public void setItemToCraft( @Nonnull final IAEItemStack itemToCreate ) - { - this.itemToCreate = itemToCreate; - } + public void setItemToCraft(@Nonnull final IAEItemStack itemToCreate) { + this.itemToCreate = itemToCreate; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java index ea951a5c2..24a9b473d 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java @@ -18,6 +18,23 @@ package appeng.container.implementations; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.Future; + +import javax.annotation.Nonnull; + +import com.google.common.collect.ImmutableSet; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.IContainerListener; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.World; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -48,446 +65,356 @@ import appeng.parts.reporting.PartCraftingTerminal; import appeng.parts.reporting.PartPatternTerminal; import appeng.parts.reporting.PartTerminal; import appeng.util.Platform; -import com.google.common.collect.ImmutableSet; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.IContainerListener; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.World; - -import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.concurrent.Future; - - -public class ContainerCraftConfirm extends AEBaseContainer -{ - - public static ContainerType TYPE; - - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCraftConfirm::new, ITerminalHost.class, SecurityPermissions.CRAFT); - - public static ContainerCraftConfirm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } - - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - private final ArrayList cpus = new ArrayList<>(); - private Future job; - private ICraftingJob result; - @GuiSync( 0 ) - public long bytesUsed; - @GuiSync( 1 ) - public long cpuBytesAvail; - @GuiSync( 2 ) - public int cpuCoProcessors; - @GuiSync( 3 ) - public boolean autoStart = false; - @GuiSync( 4 ) - public boolean simulation = true; - @GuiSync( 5 ) - public int selectedCpu = -1; - @GuiSync( 6 ) - public boolean noCPU = true; - @GuiSync( 7 ) - public String myName = ""; - - public ContainerCraftConfirm(int id, PlayerInventory ip, ITerminalHost te) { - super(TYPE, id, ip, te); - } - - public void cycleCpu( final boolean next ) - { - if( next ) - { - this.setSelectedCpu( this.getSelectedCpu() + 1 ); - } - else - { - this.setSelectedCpu( this.getSelectedCpu() - 1 ); - } - - if( this.getSelectedCpu() < -1 ) - { - this.setSelectedCpu( this.cpus.size() - 1 ); - } - else if( this.getSelectedCpu() >= this.cpus.size() ) - { - this.setSelectedCpu( -1 ); - } - - if( this.getSelectedCpu() == -1 ) - { - this.setCpuAvailableBytes( 0 ); - this.setCpuCoProcessors( 0 ); - this.setName( "" ); - } - else - { - this.setName( this.cpus.get( this.getSelectedCpu() ).getName().getString() ); - this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() ); - this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() ); - } - } - - @Override - public void detectAndSendChanges() - { - if( Platform.isClient() ) - { - return; - } - - final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class ); - final ImmutableSet cpuSet = cc.getCpus(); - - int matches = 0; - boolean changed = false; - for( final ICraftingCPU c : cpuSet ) - { - boolean found = false; - for( final CraftingCPURecord ccr : this.cpus ) - { - if( ccr.getCpu() == c ) - { - found = true; - } - } - - final boolean matched = this.cpuMatches( c ); - - if( matched ) - { - matches++; - } - - if( found == !matched ) - { - changed = true; - } - } - - if( changed || this.cpus.size() != matches ) - { - this.cpus.clear(); - for( final ICraftingCPU c : cpuSet ) - { - if( this.cpuMatches( c ) ) - { - this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) ); - } - } - - this.sendCPUs(); - } - - this.setNoCPU( this.cpus.isEmpty() ); - - super.detectAndSendChanges(); - - if( this.getJob() != null && this.getJob().isDone() ) - { - try - { - this.result = this.getJob().get(); - - if( !this.result.isSimulation() ) - { - this.setSimulation( false ); - if( this.isAutoStart() ) - { - this.startJob(); - return; - } - } - else - { - this.setSimulation( true ); - } - - try - { - final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); - final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); - final PacketMEInventoryUpdate c = this.result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null; - - final IItemList plan = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - this.result.populatePlan( plan ); - - this.setUsedBytes( this.result.getByteTotal() ); - - for( final IAEItemStack out : plan ) - { - - IAEItemStack o = out.copy(); - o.reset(); - o.setStackSize( out.getStackSize() ); - - final IAEItemStack p = out.copy(); - p.reset(); - p.setStackSize( out.getCountRequestable() ); - - final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class ); - final IMEInventory items = sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - - IAEItemStack m = null; - if( c != null && this.result.isSimulation() ) - { - m = o.copy(); - o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() ); - - if( o == null ) - { - o = m.copy(); - o.setStackSize( 0 ); - } - - m.setStackSize( m.getStackSize() - o.getStackSize() ); - } - - if( o.getStackSize() > 0 ) - { - a.appendItem( o ); - } - - if( p.getStackSize() > 0 ) - { - b.appendItem( p ); - } - - if( c != null && m != null && m.getStackSize() > 0 ) - { - c.appendItem( m ); - } - } - - for( final Object g : this.listeners ) - { - if( g instanceof PlayerEntity ) - { - NetworkHandler.instance().sendTo( a, (ServerPlayerEntity) g ); - NetworkHandler.instance().sendTo( b, (ServerPlayerEntity) g ); - if( c != null ) - { - NetworkHandler.instance().sendTo( c, (ServerPlayerEntity) g ); - } - } - } - } - catch( final IOException e ) - { - // :P - } - } - catch( final Throwable e ) - { - this.getPlayerInv().player.sendMessage( new StringTextComponent( "Error: " + e.toString() ) ); - AELog.debug( e ); - this.setValidContainer( false ); - this.result = null; - } - - this.setJob( null ); - } - this.verifyPermissions( SecurityPermissions.CRAFT, false ); - } - - private IGrid getGrid() - { - final IActionHost h = ( (IActionHost) this.getTarget() ); - return h.getActionableNode().getGrid(); - } - - private boolean cpuMatches( final ICraftingCPU c ) - { - return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy(); - } - - private void sendCPUs() - { - Collections.sort( this.cpus ); - - if( this.getSelectedCpu() >= this.cpus.size() ) - { - this.setSelectedCpu( -1 ); - this.setCpuAvailableBytes( 0 ); - this.setCpuCoProcessors( 0 ); - this.setName( "" ); - } - else if( this.getSelectedCpu() != -1 ) - { - this.setName( this.cpus.get( this.getSelectedCpu() ).getName().getString() ); - this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() ); - this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() ); - } - } - - public void startJob() - { - ContainerType originalGui = null; - - final IActionHost ah = this.getActionHost(); - if( ah instanceof WirelessTerminalGuiObject) - { - originalGui = ContainerWirelessTerm.TYPE; - } - - if( ah instanceof PartTerminal) - { - originalGui = ContainerMEMonitorable.TYPE; - } - - if( ah instanceof PartCraftingTerminal) - { - originalGui = ContainerCraftingTerm.TYPE; - } - - if( ah instanceof PartPatternTerminal) - { - originalGui = ContainerPatternTerm.TYPE; - } - - if( this.result != null && !this.isSimulation() ) - { - final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class ); - final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get( this.getSelectedCpu() ).getCpu(), true, - this.getActionSrc() ); - this.setAutoStart( false ); - if( g != null && originalGui != null && this.getLocator() != null ) - { - ContainerOpener.openContainer(originalGui, getPlayerInventory().player, getLocator()); - } - } - } - - private IActionSource getActionSrc() - { - return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() ); - } - - @Override - public void removeListener( final IContainerListener c ) - { - super.removeListener( c ); - if( this.getJob() != null ) - { - this.getJob().cancel( true ); - this.setJob( null ); - } - } - - @Override - public void onContainerClosed( final PlayerEntity par1PlayerEntity ) - { - super.onContainerClosed( par1PlayerEntity ); - if( this.getJob() != null ) - { - this.getJob().cancel( true ); - this.setJob( null ); - } - } - - public World getWorld() - { - return this.getPlayerInv().player.world; - } - - public boolean isAutoStart() - { - return this.autoStart; - } - - public void setAutoStart( final boolean autoStart ) - { - this.autoStart = autoStart; - } - - public long getUsedBytes() - { - return this.bytesUsed; - } - - private void setUsedBytes( final long bytesUsed ) - { - this.bytesUsed = bytesUsed; - } - - public long getCpuAvailableBytes() - { - return this.cpuBytesAvail; - } - - private void setCpuAvailableBytes( final long cpuBytesAvail ) - { - this.cpuBytesAvail = cpuBytesAvail; - } - - public int getCpuCoProcessors() - { - return this.cpuCoProcessors; - } - - private void setCpuCoProcessors( final int cpuCoProcessors ) - { - this.cpuCoProcessors = cpuCoProcessors; - } - - public int getSelectedCpu() - { - return this.selectedCpu; - } - - private void setSelectedCpu( final int selectedCpu ) - { - this.selectedCpu = selectedCpu; - } - - public String getName() - { - return this.myName; - } - - private void setName( @Nonnull final String myName ) - { - this.myName = myName; - } - - public boolean hasNoCPU() - { - return this.noCPU; - } - - private void setNoCPU( final boolean noCPU ) - { - this.noCPU = noCPU; - } - - public boolean isSimulation() - { - return this.simulation; - } - - private void setSimulation( final boolean simulation ) - { - this.simulation = simulation; - } - - private Future getJob() - { - return this.job; - } - - public void setJob( final Future job ) - { - this.job = job; - } + +public class ContainerCraftConfirm extends AEBaseContainer { + + public static ContainerType TYPE; + + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCraftConfirm::new, ITerminalHost.class, SecurityPermissions.CRAFT); + + public static ContainerCraftConfirm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } + + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } + + private final ArrayList cpus = new ArrayList<>(); + private Future job; + private ICraftingJob result; + @GuiSync(0) + public long bytesUsed; + @GuiSync(1) + public long cpuBytesAvail; + @GuiSync(2) + public int cpuCoProcessors; + @GuiSync(3) + public boolean autoStart = false; + @GuiSync(4) + public boolean simulation = true; + @GuiSync(5) + public int selectedCpu = -1; + @GuiSync(6) + public boolean noCPU = true; + @GuiSync(7) + public String myName = ""; + + public ContainerCraftConfirm(int id, PlayerInventory ip, ITerminalHost te) { + super(TYPE, id, ip, te); + } + + public void cycleCpu(final boolean next) { + if (next) { + this.setSelectedCpu(this.getSelectedCpu() + 1); + } else { + this.setSelectedCpu(this.getSelectedCpu() - 1); + } + + if (this.getSelectedCpu() < -1) { + this.setSelectedCpu(this.cpus.size() - 1); + } else if (this.getSelectedCpu() >= this.cpus.size()) { + this.setSelectedCpu(-1); + } + + if (this.getSelectedCpu() == -1) { + this.setCpuAvailableBytes(0); + this.setCpuCoProcessors(0); + this.setName(""); + } else { + this.setName(this.cpus.get(this.getSelectedCpu()).getName().getString()); + this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize()); + this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors()); + } + } + + @Override + public void detectAndSendChanges() { + if (Platform.isClient()) { + return; + } + + final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); + final ImmutableSet cpuSet = cc.getCpus(); + + int matches = 0; + boolean changed = false; + for (final ICraftingCPU c : cpuSet) { + boolean found = false; + for (final CraftingCPURecord ccr : this.cpus) { + if (ccr.getCpu() == c) { + found = true; + } + } + + final boolean matched = this.cpuMatches(c); + + if (matched) { + matches++; + } + + if (found == !matched) { + changed = true; + } + } + + if (changed || this.cpus.size() != matches) { + this.cpus.clear(); + for (final ICraftingCPU c : cpuSet) { + if (this.cpuMatches(c)) { + this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c)); + } + } + + this.sendCPUs(); + } + + this.setNoCPU(this.cpus.isEmpty()); + + super.detectAndSendChanges(); + + if (this.getJob() != null && this.getJob().isDone()) { + try { + this.result = this.getJob().get(); + + if (!this.result.isSimulation()) { + this.setSimulation(false); + if (this.isAutoStart()) { + this.startJob(); + return; + } + } else { + this.setSimulation(true); + } + + try { + final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate((byte) 0); + final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate((byte) 1); + final PacketMEInventoryUpdate c = this.result.isSimulation() ? new PacketMEInventoryUpdate((byte) 2) + : null; + + final IItemList plan = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + this.result.populatePlan(plan); + + this.setUsedBytes(this.result.getByteTotal()); + + for (final IAEItemStack out : plan) { + + IAEItemStack o = out.copy(); + o.reset(); + o.setStackSize(out.getStackSize()); + + final IAEItemStack p = out.copy(); + p.reset(); + p.setStackSize(out.getCountRequestable()); + + final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class); + final IMEInventory items = sg + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + + IAEItemStack m = null; + if (c != null && this.result.isSimulation()) { + m = o.copy(); + o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource()); + + if (o == null) { + o = m.copy(); + o.setStackSize(0); + } + + m.setStackSize(m.getStackSize() - o.getStackSize()); + } + + if (o.getStackSize() > 0) { + a.appendItem(o); + } + + if (p.getStackSize() > 0) { + b.appendItem(p); + } + + if (c != null && m != null && m.getStackSize() > 0) { + c.appendItem(m); + } + } + + for (final Object g : this.listeners) { + if (g instanceof PlayerEntity) { + NetworkHandler.instance().sendTo(a, (ServerPlayerEntity) g); + NetworkHandler.instance().sendTo(b, (ServerPlayerEntity) g); + if (c != null) { + NetworkHandler.instance().sendTo(c, (ServerPlayerEntity) g); + } + } + } + } catch (final IOException e) { + // :P + } + } catch (final Throwable e) { + this.getPlayerInv().player.sendMessage(new StringTextComponent("Error: " + e.toString())); + AELog.debug(e); + this.setValidContainer(false); + this.result = null; + } + + this.setJob(null); + } + this.verifyPermissions(SecurityPermissions.CRAFT, false); + } + + private IGrid getGrid() { + final IActionHost h = ((IActionHost) this.getTarget()); + return h.getActionableNode().getGrid(); + } + + private boolean cpuMatches(final ICraftingCPU c) { + return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy(); + } + + private void sendCPUs() { + Collections.sort(this.cpus); + + if (this.getSelectedCpu() >= this.cpus.size()) { + this.setSelectedCpu(-1); + this.setCpuAvailableBytes(0); + this.setCpuCoProcessors(0); + this.setName(""); + } else if (this.getSelectedCpu() != -1) { + this.setName(this.cpus.get(this.getSelectedCpu()).getName().getString()); + this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize()); + this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors()); + } + } + + public void startJob() { + ContainerType originalGui = null; + + final IActionHost ah = this.getActionHost(); + if (ah instanceof WirelessTerminalGuiObject) { + originalGui = ContainerWirelessTerm.TYPE; + } + + if (ah instanceof PartTerminal) { + originalGui = ContainerMEMonitorable.TYPE; + } + + if (ah instanceof PartCraftingTerminal) { + originalGui = ContainerCraftingTerm.TYPE; + } + + if (ah instanceof PartPatternTerminal) { + originalGui = ContainerPatternTerm.TYPE; + } + + if (this.result != null && !this.isSimulation()) { + final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); + final ICraftingLink g = cc.submitJob(this.result, null, + this.getSelectedCpu() == -1 ? null : this.cpus.get(this.getSelectedCpu()).getCpu(), true, + this.getActionSrc()); + this.setAutoStart(false); + if (g != null && originalGui != null && this.getLocator() != null) { + ContainerOpener.openContainer(originalGui, getPlayerInventory().player, getLocator()); + } + } + } + + private IActionSource getActionSrc() { + return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget()); + } + + @Override + public void removeListener(final IContainerListener c) { + super.removeListener(c); + if (this.getJob() != null) { + this.getJob().cancel(true); + this.setJob(null); + } + } + + @Override + public void onContainerClosed(final PlayerEntity par1PlayerEntity) { + super.onContainerClosed(par1PlayerEntity); + if (this.getJob() != null) { + this.getJob().cancel(true); + this.setJob(null); + } + } + + public World getWorld() { + return this.getPlayerInv().player.world; + } + + public boolean isAutoStart() { + return this.autoStart; + } + + public void setAutoStart(final boolean autoStart) { + this.autoStart = autoStart; + } + + public long getUsedBytes() { + return this.bytesUsed; + } + + private void setUsedBytes(final long bytesUsed) { + this.bytesUsed = bytesUsed; + } + + public long getCpuAvailableBytes() { + return this.cpuBytesAvail; + } + + private void setCpuAvailableBytes(final long cpuBytesAvail) { + this.cpuBytesAvail = cpuBytesAvail; + } + + public int getCpuCoProcessors() { + return this.cpuCoProcessors; + } + + private void setCpuCoProcessors(final int cpuCoProcessors) { + this.cpuCoProcessors = cpuCoProcessors; + } + + public int getSelectedCpu() { + return this.selectedCpu; + } + + private void setSelectedCpu(final int selectedCpu) { + this.selectedCpu = selectedCpu; + } + + public String getName() { + return this.myName; + } + + private void setName(@Nonnull final String myName) { + this.myName = myName; + } + + public boolean hasNoCPU() { + return this.noCPU; + } + + private void setNoCPU(final boolean noCPU) { + this.noCPU = noCPU; + } + + public boolean isSimulation() { + return this.simulation; + } + + private void setSimulation(final boolean simulation) { + this.simulation = simulation; + } + + private Future getJob() { + return this.job; + } + + public void setJob(final Future job) { + this.job = job; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java b/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java index fce3da37b..384152478 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java @@ -18,17 +18,18 @@ package appeng.container.implementations; - import java.io.IOException; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.IContainerListener; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.text.ITextComponent; + import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; - import appeng.api.networking.IGrid; import appeng.api.networking.crafting.CraftingItemList; import appeng.api.networking.crafting.ICraftingCPU; @@ -40,7 +41,9 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.core.sync.packets.PacketValueConfig; @@ -49,249 +52,205 @@ import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.tile.crafting.TileCraftingTile; import appeng.util.Platform; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.IContainerListener; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.text.ITextComponent; +public class ContainerCraftingCPU extends AEBaseContainer + implements IMEMonitorHandlerReceiver, ICustomNameObject { -public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver, ICustomNameObject -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCraftingCPU::new, TileCraftingTile.class, SecurityPermissions.CRAFT); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCraftingCPU::new, TileCraftingTile.class, SecurityPermissions.CRAFT); + private final IItemList list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private IGrid network; + private CraftingCPUCluster monitor = null; + private ITextComponent cpuName = null; - private final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private IGrid network; - private CraftingCPUCluster monitor = null; - private ITextComponent cpuName = null; + @GuiSync(0) + public long eta = -1; - @GuiSync( 0 ) - public long eta = -1; + private ContainerCraftingCPU(int id, final PlayerInventory ip, final TileCraftingTile te) { + this(TYPE, id, ip, te); + } - private ContainerCraftingCPU(int id, final PlayerInventory ip, final TileCraftingTile te ) - { - this( TYPE, id, ip, te ); - } + public ContainerCraftingCPU(ContainerType containerType, int id, final PlayerInventory ip, final Object te) { + super(containerType, id, ip, te); + final IActionHost host = (IActionHost) (te instanceof IActionHost ? te : null); - public ContainerCraftingCPU(ContainerType containerType, int id, final PlayerInventory ip, final Object te ) - { - super( containerType, id, ip, te ); - final IActionHost host = (IActionHost) ( te instanceof IActionHost ? te : null ); + if (host != null && host.getActionableNode() != null) { + this.setNetwork(host.getActionableNode().getGrid()); + } - if( host != null && host.getActionableNode() != null ) - { - this.setNetwork( host.getActionableNode().getGrid() ); - } + if (te instanceof TileCraftingTile) { + this.setCPU((ICraftingCPU) ((IAEMultiBlock) te).getCluster()); + } - if( te instanceof TileCraftingTile ) - { - this.setCPU( (ICraftingCPU) ( (IAEMultiBlock) te ).getCluster() ); - } + if (this.getNetwork() == null && Platform.isServer()) { + this.setValidContainer(false); + } + } - if( this.getNetwork() == null && Platform.isServer() ) - { - this.setValidContainer( false ); - } - } + public static ContainerCraftingCPU fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerCraftingCPU fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + protected void setCPU(final ICraftingCPU c) { + if (c == this.getMonitor()) { + return; + } - protected void setCPU( final ICraftingCPU c ) - { - if( c == this.getMonitor() ) - { - return; - } + if (this.getMonitor() != null) { + this.getMonitor().removeListener(this); + } - if( this.getMonitor() != null ) - { - this.getMonitor().removeListener( this ); - } + for (final Object g : this.listeners) { + if (g instanceof PlayerEntity) { + NetworkHandler.instance().sendTo(new PacketValueConfig("CraftingStatus", "Clear"), + (ServerPlayerEntity) g); + } + } - for( final Object g : this.listeners ) - { - if( g instanceof PlayerEntity ) - { - NetworkHandler.instance().sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (ServerPlayerEntity) g ); - } - } + if (c instanceof CraftingCPUCluster) { + this.cpuName = c.getName(); + this.setMonitor((CraftingCPUCluster) c); + this.list.resetStatus(); + this.getMonitor().getListOfItem(this.list, CraftingItemList.ALL); + this.getMonitor().addListener(this, null); + this.setEstimatedTime(0); + } else { + this.setMonitor(null); + this.cpuName = null; + this.setEstimatedTime(-1); + } + } - if( c instanceof CraftingCPUCluster ) - { - this.cpuName = c.getName(); - this.setMonitor( (CraftingCPUCluster) c ); - this.list.resetStatus(); - this.getMonitor().getListOfItem( this.list, CraftingItemList.ALL ); - this.getMonitor().addListener( this, null ); - this.setEstimatedTime( 0 ); - } - else - { - this.setMonitor( null ); - this.cpuName = null; - this.setEstimatedTime( -1 ); - } - } + public void cancelCrafting() { + if (this.getMonitor() != null) { + this.getMonitor().cancel(); + } + this.setEstimatedTime(-1); + } - public void cancelCrafting() - { - if( this.getMonitor() != null ) - { - this.getMonitor().cancel(); - } - this.setEstimatedTime( -1 ); - } + @Override + public void removeListener(final IContainerListener c) { + super.removeListener(c); - @Override - public void removeListener( final IContainerListener c ) - { - super.removeListener( c ); + if (this.listeners.isEmpty() && this.getMonitor() != null) { + this.getMonitor().removeListener(this); + } + } - if( this.listeners.isEmpty() && this.getMonitor() != null ) - { - this.getMonitor().removeListener( this ); - } - } + @Override + public void onContainerClosed(final PlayerEntity player) { + super.onContainerClosed(player); + if (this.getMonitor() != null) { + this.getMonitor().removeListener(this); + } + } - @Override - public void onContainerClosed( final PlayerEntity player ) - { - super.onContainerClosed( player ); - if( this.getMonitor() != null ) - { - this.getMonitor().removeListener( this ); - } - } + @Override + public void detectAndSendChanges() { + if (Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty()) { + try { + if (this.getEstimatedTime() >= 0) { + final long elapsedTime = this.getMonitor().getElapsedTime(); + final double remainingItems = this.getMonitor().getRemainingItemCount(); + final double startItems = this.getMonitor().getStartItemCount(); + final long eta = (long) (elapsedTime / Math.max(1d, (startItems - remainingItems)) + * remainingItems); + this.setEstimatedTime(eta); + } - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty() ) - { - try - { - if( this.getEstimatedTime() >= 0 ) - { - final long elapsedTime = this.getMonitor().getElapsedTime(); - final double remainingItems = this.getMonitor().getRemainingItemCount(); - final double startItems = this.getMonitor().getStartItemCount(); - final long eta = (long) ( elapsedTime / Math.max( 1d, ( startItems - remainingItems ) ) * remainingItems ); - this.setEstimatedTime( eta ); - } + final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate((byte) 0); + final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate((byte) 1); + final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate((byte) 2); - final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); - final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); - final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 ); + for (final IAEItemStack out : this.list) { + a.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.STORAGE)); + b.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.ACTIVE)); + c.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.PENDING)); + } - for( final IAEItemStack out : this.list ) - { - a.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.STORAGE ) ); - b.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.ACTIVE ) ); - c.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.PENDING ) ); - } + this.list.resetStatus(); - this.list.resetStatus(); + for (final Object g : this.listeners) { + if (g instanceof PlayerEntity) { + if (!a.isEmpty()) { + NetworkHandler.instance().sendTo(a, (ServerPlayerEntity) g); + } - for( final Object g : this.listeners ) - { - if( g instanceof PlayerEntity ) - { - if( !a.isEmpty() ) - { - NetworkHandler.instance().sendTo( a, (ServerPlayerEntity) g ); - } + if (!b.isEmpty()) { + NetworkHandler.instance().sendTo(b, (ServerPlayerEntity) g); + } - if( !b.isEmpty() ) - { - NetworkHandler.instance().sendTo( b, (ServerPlayerEntity) g ); - } + if (!c.isEmpty()) { + NetworkHandler.instance().sendTo(c, (ServerPlayerEntity) g); + } + } + } + } catch (final IOException e) { + // :P + } + } + super.detectAndSendChanges(); + } - if( !c.isEmpty() ) - { - NetworkHandler.instance().sendTo( c, (ServerPlayerEntity) g ); - } - } - } - } - catch( final IOException e ) - { - // :P - } - } - super.detectAndSendChanges(); - } + @Override + public boolean isValid(final Object verificationToken) { + return true; + } - @Override - public boolean isValid( final Object verificationToken ) - { - return true; - } + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource actionSource) { + for (IAEItemStack is : change) { + is = is.copy(); + is.setStackSize(1); + this.list.add(is); + } + } - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource actionSource ) - { - for( IAEItemStack is : change ) - { - is = is.copy(); - is.setStackSize( 1 ); - this.list.add( is ); - } - } + @Override + public void onListUpdate() { - @Override - public void onListUpdate() - { + } - } + @Override + public ITextComponent getCustomInventoryName() { + return this.cpuName; + } - @Override - public ITextComponent getCustomInventoryName() - { - return this.cpuName; - } + @Override + public boolean hasCustomInventoryName() { + return this.cpuName != null; + } - @Override - public boolean hasCustomInventoryName() - { - return this.cpuName != null; - } + public long getEstimatedTime() { + return this.eta; + } - public long getEstimatedTime() - { - return this.eta; - } + private void setEstimatedTime(final long eta) { + this.eta = eta; + } - private void setEstimatedTime( final long eta ) - { - this.eta = eta; - } + CraftingCPUCluster getMonitor() { + return this.monitor; + } - CraftingCPUCluster getMonitor() - { - return this.monitor; - } + private void setMonitor(final CraftingCPUCluster monitor) { + this.monitor = monitor; + } - private void setMonitor( final CraftingCPUCluster monitor ) - { - this.monitor = monitor; - } + IGrid getNetwork() { + return this.network; + } - IGrid getNetwork() - { - return this.network; - } - - private void setNetwork( final IGrid network ) - { - this.network = network; - } + private void setNetwork(final IGrid network) { + this.network = network; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java b/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java index 461d25f5d..3909cd33e 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java @@ -18,181 +18,146 @@ package appeng.container.implementations; - import java.util.ArrayList; import java.util.Collections; import java.util.List; -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; import com.google.common.collect.ImmutableSet; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.api.networking.crafting.ICraftingCPU; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.storage.ITerminalHost; -import appeng.container.guisync.GuiSync; -import appeng.util.Platform; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.api.config.SecurityPermissions; +import appeng.api.networking.crafting.ICraftingCPU; +import appeng.api.networking.crafting.ICraftingGrid; +import appeng.api.storage.ITerminalHost; +import appeng.container.ContainerLocator; +import appeng.container.guisync.GuiSync; +import appeng.util.Platform; -public class ContainerCraftingStatus extends ContainerCraftingCPU -{ +public class ContainerCraftingStatus extends ContainerCraftingCPU { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCraftingStatus::new, ITerminalHost.class, SecurityPermissions.CRAFT); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCraftingStatus::new, ITerminalHost.class, SecurityPermissions.CRAFT); - public static ContainerCraftingStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerCraftingStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - private final List cpus = new ArrayList<>(); - @GuiSync( 5 ) - public int selectedCpu = -1; - @GuiSync( 6 ) - public boolean noCPU = true; - @GuiSync( 7 ) - public String myName = ""; + private final List cpus = new ArrayList<>(); + @GuiSync(5) + public int selectedCpu = -1; + @GuiSync(6) + public boolean noCPU = true; + @GuiSync(7) + public String myName = ""; - public ContainerCraftingStatus(int id, final PlayerInventory ip, final ITerminalHost te ) - { - super( TYPE, id, ip, te ); - } + public ContainerCraftingStatus(int id, final PlayerInventory ip, final ITerminalHost te) { + super(TYPE, id, ip, te); + } - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() && this.getNetwork() != null ) - { - final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class ); - final ImmutableSet cpuSet = cc.getCpus(); + @Override + public void detectAndSendChanges() { + if (Platform.isServer() && this.getNetwork() != null) { + final ICraftingGrid cc = this.getNetwork().getCache(ICraftingGrid.class); + final ImmutableSet cpuSet = cc.getCpus(); - int matches = 0; - boolean changed = false; - for( final ICraftingCPU c : cpuSet ) - { - boolean found = false; - for( final CraftingCPURecord ccr : this.cpus ) - { - if( ccr.getCpu() == c ) - { - found = true; - } - } + int matches = 0; + boolean changed = false; + for (final ICraftingCPU c : cpuSet) { + boolean found = false; + for (final CraftingCPURecord ccr : this.cpus) { + if (ccr.getCpu() == c) { + found = true; + } + } - final boolean matched = this.cpuMatches( c ); + final boolean matched = this.cpuMatches(c); - if( matched ) - { - matches++; - } + if (matched) { + matches++; + } - if( found == !matched ) - { - changed = true; - } - } + if (found == !matched) { + changed = true; + } + } - if( changed || this.cpus.size() != matches ) - { - this.cpus.clear(); - for( final ICraftingCPU c : cpuSet ) - { - if( this.cpuMatches( c ) ) - { - this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) ); - } - } + if (changed || this.cpus.size() != matches) { + this.cpus.clear(); + for (final ICraftingCPU c : cpuSet) { + if (this.cpuMatches(c)) { + this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c)); + } + } - this.sendCPUs(); - } + this.sendCPUs(); + } - this.noCPU = this.cpus.isEmpty(); - } + this.noCPU = this.cpus.isEmpty(); + } - super.detectAndSendChanges(); - } + super.detectAndSendChanges(); + } - private boolean cpuMatches( final ICraftingCPU c ) - { - return c.isBusy(); - } + private boolean cpuMatches(final ICraftingCPU c) { + return c.isBusy(); + } - private void sendCPUs() - { - Collections.sort( this.cpus ); + private void sendCPUs() { + Collections.sort(this.cpus); - if( this.selectedCpu >= this.cpus.size() ) - { - this.selectedCpu = -1; - this.myName = ""; - } - else if( this.selectedCpu != -1 ) - { - this.myName = this.cpus.get( this.selectedCpu ).getName().getString(); - } + if (this.selectedCpu >= this.cpus.size()) { + this.selectedCpu = -1; + this.myName = ""; + } else if (this.selectedCpu != -1) { + this.myName = this.cpus.get(this.selectedCpu).getName().getString(); + } - if( this.selectedCpu == -1 && this.cpus.size() > 0 ) - { - this.selectedCpu = 0; - } + if (this.selectedCpu == -1 && this.cpus.size() > 0) { + this.selectedCpu = 0; + } - if( this.selectedCpu != -1 ) - { - if( this.cpus.get( this.selectedCpu ).getCpu() != this.getMonitor() ) - { - this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() ); - } - } - else - { - this.setCPU( null ); - } - } + if (this.selectedCpu != -1) { + if (this.cpus.get(this.selectedCpu).getCpu() != this.getMonitor()) { + this.setCPU(this.cpus.get(this.selectedCpu).getCpu()); + } + } else { + this.setCPU(null); + } + } - public void cycleCpu( final boolean next ) - { - if( next ) - { - this.selectedCpu++; - } - else - { - this.selectedCpu--; - } + public void cycleCpu(final boolean next) { + if (next) { + this.selectedCpu++; + } else { + this.selectedCpu--; + } - if( this.selectedCpu < -1 ) - { - this.selectedCpu = this.cpus.size() - 1; - } - else if( this.selectedCpu >= this.cpus.size() ) - { - this.selectedCpu = -1; - } + if (this.selectedCpu < -1) { + this.selectedCpu = this.cpus.size() - 1; + } else if (this.selectedCpu >= this.cpus.size()) { + this.selectedCpu = -1; + } - if( this.selectedCpu == -1 && this.cpus.size() > 0 ) - { - this.selectedCpu = 0; - } + if (this.selectedCpu == -1 && this.cpus.size() > 0) { + this.selectedCpu = 0; + } - if( this.selectedCpu == -1 ) - { - this.myName = ""; - this.setCPU( null ); - } - else - { - this.myName = this.cpus.get( this.selectedCpu ).getName().getString(); - this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() ); - } - } + if (this.selectedCpu == -1) { + this.myName = ""; + this.setCPU(null); + } else { + this.myName = this.cpus.get(this.selectedCpu).getName().getString(); + this.setCPU(this.cpus.get(this.selectedCpu).getCpu()); + } + } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java b/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java index acc1cd24a..61e69836b 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java @@ -18,13 +18,10 @@ package appeng.container.implementations; - -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -34,7 +31,9 @@ import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.PlayerInvWrapper; +import appeng.api.config.SecurityPermissions; import appeng.api.storage.ITerminalHost; +import appeng.container.ContainerLocator; import appeng.container.ContainerNull; import appeng.container.slot.SlotCraftingMatrix; import appeng.container.slot.SlotCraftingTerm; @@ -45,115 +44,101 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.inv.WrapperInvItemHandler; +public class ContainerCraftingTerm extends ContainerMEMonitorable + implements IAEAppEngInventory, IContainerCraftingPacket { -public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerCraftingTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerCraftingTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT); + public static ContainerCraftingTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerCraftingTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final PartCraftingTerminal ct; + private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1); + private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9]; + private final SlotCraftingTerm outputSlot; + private IRecipe currentRecipe; - private final PartCraftingTerminal ct; - private final AppEngInternalInventory output = new AppEngInternalInventory( this, 1 ); - private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9]; - private final SlotCraftingTerm outputSlot; - private IRecipe currentRecipe; + public ContainerCraftingTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable) { + super(TYPE, id, ip, monitorable, false); + this.ct = (PartCraftingTerminal) monitorable; - public ContainerCraftingTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable ) - { - super( TYPE, id, ip, monitorable, false ); - this.ct = (PartCraftingTerminal) monitorable; + final IItemHandler crafting = this.ct.getInventoryByName("crafting"); - final IItemHandler crafting = this.ct.getInventoryByName( "crafting" ); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + this.addSlot(this.craftingSlots[x + y * 3] = new SlotCraftingMatrix(this, crafting, x + y * 3, + 37 + x * 18, -72 + y * 18)); + } + } - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 3; x++ ) - { - this.addSlot( this.craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) ); - } - } + this.addSlot(this.outputSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.getActionSource(), + this.getPowerSource(), monitorable, crafting, crafting, this.output, 131, -72 + 18, this)); - this.addSlot( this.outputSlot = new SlotCraftingTerm( this.getPlayerInv().player, this.getActionSource(), this - .getPowerSource(), monitorable, crafting, crafting, this.output, 131, -72 + 18, this ) ); + this.bindPlayerInventory(ip, 0, 0); - this.bindPlayerInventory( ip, 0, 0 ); + this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting)); + } - this.onCraftMatrixChanged( new WrapperInvItemHandler( crafting ) ); - } + /** + * Callback for when the crafting matrix is changed. + */ - /** - * Callback for when the crafting matrix is changed. - */ + @Override + public void onCraftMatrixChanged(IInventory inventory) { + final ContainerNull cn = new ContainerNull(); + final CraftingInventory ic = new CraftingInventory(cn, 3, 3); - @Override - public void onCraftMatrixChanged( IInventory inventory ) - { - final ContainerNull cn = new ContainerNull(); - final CraftingInventory ic = new CraftingInventory( cn, 3, 3 ); + for (int x = 0; x < 9; x++) { + ic.setInventorySlotContents(x, this.craftingSlots[x].getStack()); + } - for( int x = 0; x < 9; x++ ) - { - ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() ); - } + if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) { + World world = this.getPlayerInv().player.world; + this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); + } - if( this.currentRecipe == null || !this.currentRecipe.matches( ic, this.getPlayerInv().player.world ) ) - { - World world = this.getPlayerInv().player.world; - this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); - } + if (this.currentRecipe == null) { + this.outputSlot.putStack(ItemStack.EMPTY); + } else { + final ItemStack craftingResult = this.currentRecipe.getCraftingResult(ic); - if( this.currentRecipe == null ) - { - this.outputSlot.putStack( ItemStack.EMPTY ); - } - else - { - final ItemStack craftingResult = this.currentRecipe.getCraftingResult( ic ); + this.outputSlot.putStack(craftingResult); + } + } - this.outputSlot.putStack( craftingResult ); - } - } + @Override + public void saveChanges() { - @Override - public void saveChanges() - { + } - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + } - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("player")) { + return new PlayerInvWrapper(this.getPlayerInventory()); + } + return this.ct.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "player" ) ) - { - return new PlayerInvWrapper( this.getPlayerInventory() ); - } - return this.ct.getInventoryByName( name ); - } + @Override + public boolean useRealItems() { + return true; + } - @Override - public boolean useRealItems() - { - return true; - } - - public IRecipe getCurrentRecipe() - { - return this.currentRecipe; - } + public IRecipe getCurrentRecipe() { + return this.currentRecipe; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerDrive.java b/src/main/java/appeng/container/implementations/ContainerDrive.java index 20f33189a..01a0baa60 100644 --- a/src/main/java/appeng/container/implementations/ContainerDrive.java +++ b/src/main/java/appeng/container/implementations/ContainerDrive.java @@ -18,49 +18,43 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotRestrictedInput; -import appeng.tile.storage.TileDrive; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotRestrictedInput; +import appeng.tile.storage.TileDrive; -public class ContainerDrive extends AEBaseContainer -{ +public class ContainerDrive extends AEBaseContainer { -public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerDrive::new, TileDrive.class); + private static final ContainerHelper helper = new ContainerHelper<>(ContainerDrive::new, + TileDrive.class); - public static ContainerDrive fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerDrive fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public ContainerDrive(int id, final PlayerInventory ip, final TileDrive drive ) - { - super( TYPE, id, ip, drive, null ); + public ContainerDrive(int id, final PlayerInventory ip, final TileDrive drive) { + super(TYPE, id, ip, drive, null); - for( int y = 0; y < 5; y++ ) - { - for( int x = 0; x < 2; x++ ) - { - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive - .getInternalInventory(), x + y * 2, 71 + x * 18, 14 + y * 18, this.getPlayerInventory() ) ); - } - } + for (int y = 0; y < 5; y++) { + for (int x = 0; x < 2; x++) { + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, + drive.getInternalInventory(), x + y * 2, 71 + x * 18, 14 + y * 18, this.getPlayerInventory())); + } + } - this.bindPlayerInventory( ip, 0, 199 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 199 - /* height of player inventory */82); + } } diff --git a/src/main/java/appeng/container/implementations/ContainerFormationPlane.java b/src/main/java/appeng/container/implementations/ContainerFormationPlane.java index 45caee754..301445a76 100644 --- a/src/main/java/appeng/container/implementations/ContainerFormationPlane.java +++ b/src/main/java/appeng/container/implementations/ContainerFormationPlane.java @@ -18,9 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -32,124 +29,105 @@ import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.config.YesNo; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.OptionalSlotFakeTypeOnly; import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; import appeng.parts.automation.PartFormationPlane; import appeng.util.Platform; +public class ContainerFormationPlane extends ContainerUpgradeable { -public class ContainerFormationPlane extends ContainerUpgradeable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFormationPlane::new, PartFormationPlane.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFormationPlane::new, PartFormationPlane.class, SecurityPermissions.BUILD); + public static ContainerFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @GuiSync(6) + public YesNo placeMode; - @GuiSync( 6 ) - public YesNo placeMode; + public ContainerFormationPlane(int id, final PlayerInventory ip, final PartFormationPlane te) { + super(TYPE, id, ip, te); + } - public ContainerFormationPlane(int id, final PlayerInventory ip, final PartFormationPlane te ) - { - super( TYPE, id, ip, te ); - } + @Override + protected int getHeight() { + return 251; + } - @Override - protected int getHeight() - { - return 251; - } + @Override + protected void setupConfig() { + final int xo = 8; + final int yo = 23 + 6; - @Override - protected void setupConfig() - { - final int xo = 8; - final int yo = 23 + 6; + final IItemHandler config = this.getUpgradeable().getInventoryByName("config"); + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 9; x++) { + if (y < 2) { + this.addSlot(new SlotFakeTypeOnly(config, y * 9 + x, xo + x * 18, yo + y * 18)); + } else { + this.addSlot(new OptionalSlotFakeTypeOnly(config, this, y * 9 + x, xo, yo, x, y, y - 2)); + } + } + } - final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" ); - for( int y = 0; y < 7; y++ ) - { - for( int x = 0; x < 9; x++ ) - { - if( y < 2 ) - { - this.addSlot( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) ); - } - else - { - this.addSlot( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) ); - } - } - } + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, + 8 + 18 * 4, this.getPlayerInventory())).setNotDraggable()); + } - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + @Override + protected boolean supportCapacity() { + return true; + } - @Override - protected boolean supportCapacity() - { - return true; - } + @Override + public int availableUpgrades() { + return 5; + } - @Override - public int availableUpgrades() - { - return 5; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE)); + this.setPlaceMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.PLACE_BLOCK)); + } - if( Platform.isServer() ) - { - this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) ); - this.setPlaceMode( (YesNo) this.getUpgradeable().getConfigManager().getSetting( Settings.PLACE_BLOCK ) ); - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + @Override + public boolean isSlotEnabled(final int idx) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - @Override - public boolean isSlotEnabled( final int idx ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + return upgrades > idx; + } - return upgrades > idx; - } + public YesNo getPlaceMode() { + return this.placeMode; + } - public YesNo getPlaceMode() - { - return this.placeMode; - } - - private void setPlaceMode( final YesNo placeMode ) - { - this.placeMode = placeMode; - } + private void setPlaceMode(final YesNo placeMode) { + this.placeMode = placeMode; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerGrinder.java b/src/main/java/appeng/container/implementations/ContainerGrinder.java index 2209064b1..8d9a7e849 100644 --- a/src/main/java/appeng/container/implementations/ContainerGrinder.java +++ b/src/main/java/appeng/container/implementations/ContainerGrinder.java @@ -18,9 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -28,44 +25,47 @@ import net.minecraft.network.PacketBuffer; import net.minecraftforge.items.IItemHandler; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.SlotInaccessible; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.grindstone.TileGrinder; -public class ContainerGrinder extends AEBaseContainer -{ +public class ContainerGrinder extends AEBaseContainer { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerGrinder::new, TileGrinder.class); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerGrinder::new, TileGrinder.class); - public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public ContainerGrinder(int id, final PlayerInventory ip, final TileGrinder grinder ) - { - super( TYPE, id, ip, grinder, null ); + public ContainerGrinder(int id, final PlayerInventory ip, final TileGrinder grinder) { + super(TYPE, id, ip, grinder, null); - IItemHandler inv = grinder.getInternalInventory(); + IItemHandler inv = grinder.getInternalInventory(); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 0, 12, 17, this.getPlayerInventory() ) ); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 1, 12 + 18, 17, this.getPlayerInventory() ) ); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 2, 12 + 36, 17, this.getPlayerInventory() ) ); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 0, 12, 17, + this.getPlayerInventory())); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 1, 12 + 18, 17, + this.getPlayerInventory())); + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 2, 12 + 36, 17, + this.getPlayerInventory())); - this.addSlot( new SlotInaccessible( inv, 6, 80, 40 ) ); + this.addSlot(new SlotInaccessible(inv, 6, 80, 40)); - this.addSlot( new SlotOutput( inv, 3, 112, 63, 2 * 16 + 15 ) ); - this.addSlot( new SlotOutput( inv, 4, 112 + 18, 63, 2 * 16 + 15 ) ); - this.addSlot( new SlotOutput( inv, 5, 112 + 36, 63, 2 * 16 + 15 ) ); + this.addSlot(new SlotOutput(inv, 3, 112, 63, 2 * 16 + 15)); + this.addSlot(new SlotOutput(inv, 4, 112 + 18, 63, 2 * 16 + 15)); + this.addSlot(new SlotOutput(inv, 5, 112 + 36, 63, 2 * 16 + 15)); - this.bindPlayerInventory( ip, 0, 176 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 176 - /* height of player inventory */82); + } } diff --git a/src/main/java/appeng/container/implementations/ContainerHelper.java b/src/main/java/appeng/container/implementations/ContainerHelper.java index 38071135a..d4c3c92a0 100644 --- a/src/main/java/appeng/container/implementations/ContainerHelper.java +++ b/src/main/java/appeng/container/implementations/ContainerHelper.java @@ -1,18 +1,5 @@ package appeng.container.implementations; -import appeng.api.AEApi; -import appeng.api.config.SecurityPermissions; -import appeng.api.features.IWirelessTermHandler; -import appeng.api.implementations.guiobjects.IGuiItem; -import appeng.api.implementations.guiobjects.IGuiItemObject; -import appeng.api.parts.IPart; -import appeng.api.parts.IPartHost; -import appeng.container.AEBaseContainer; -import appeng.container.ContainerLocator; -import appeng.core.AELog; -import appeng.helpers.ICustomNameObject; -import appeng.helpers.WirelessTerminalGuiObject; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; @@ -27,9 +14,23 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +import appeng.api.AEApi; +import appeng.api.config.SecurityPermissions; +import appeng.api.features.IWirelessTermHandler; +import appeng.api.implementations.guiobjects.IGuiItem; +import appeng.api.implementations.guiobjects.IGuiItemObject; +import appeng.api.parts.IPart; +import appeng.api.parts.IPartHost; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.core.AELog; +import appeng.helpers.ICustomNameObject; +import appeng.helpers.WirelessTerminalGuiObject; +import appeng.util.Platform; + /** - * Helper for containers that can be opened for a part or tile given that either - * implements a given interface. + * Helper for containers that can be opened for a part or tile given + * that either implements a given interface. * * @param */ @@ -45,15 +46,16 @@ public final class ContainerHelper { this(factory, interfaceClass, null); } - public ContainerHelper(ContainerFactory factory, Class interfaceClass, SecurityPermissions requiredPermission) { + public ContainerHelper(ContainerFactory factory, Class interfaceClass, + SecurityPermissions requiredPermission) { this.requiredPermission = requiredPermission; this.interfaceClass = interfaceClass; this.factory = factory; } /** - * Opens a container that is based around a single tile entity. - * The tile entity's position is encoded in the packet buffer. + * Opens a container that is based around a single tile entity. The tile + * entity's position is encoded in the packet buffer. */ public C fromNetwork(int windowId, PlayerInventory inv, PacketBuffer packetBuf) { I host = getHostFromLocator(inv.player, ContainerLocator.read(packetBuf)); @@ -82,15 +84,13 @@ public final class ContainerHelper { ITextComponent title = findContainerTitle(player.world, locator, accessInterface); - INamedContainerProvider container = new SimpleNamedContainerProvider( - (wnd, p, pl) -> { - C c = factory.create(wnd, p, accessInterface); - // Set the original locator on the opened server-side container for it to more - // easily remember how to re-open after being closed. - c.setLocator(locator); - return c; - }, title - ); + INamedContainerProvider container = new SimpleNamedContainerProvider((wnd, p, pl) -> { + C c = factory.create(wnd, p, accessInterface); + // Set the original locator on the opened server-side container for it to more + // easily remember how to re-open after being closed. + c.setLocator(locator); + return c; + }, title); NetworkHooks.openGui((ServerPlayerEntity) player, container, locator::write); return true; @@ -106,8 +106,10 @@ public final class ContainerHelper { } // Use block name at position - // FIXME: this is not right, we'd need to check the part's item stack, or custom naming interface impl - // FIXME: Should move this up, because at this point, it's hard to know where the terminal host came from (part or tile) + // FIXME: this is not right, we'd need to check the part's item stack, or custom + // naming interface impl + // FIXME: Should move this up, because at this point, it's hard to know where + // the terminal host came from (part or tile) if (locator.hasBlockPos()) { return world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent(); } @@ -147,8 +149,8 @@ public final class ContainerHelper { if (interfaceClass.isInstance(part)) { return interfaceClass.cast(part); } else { - AELog.debug("Trying to open a container @ %s for a %s, but the container requires %s", - locator, part.getClass(), interfaceClass); + AELog.debug("Trying to open a container @ %s for a %s, but the container requires %s", locator, + part.getClass(), interfaceClass); return null; } } else { @@ -162,13 +164,12 @@ public final class ContainerHelper { ItemStack it = player.inventory.getStackInSlot(locator.getItemIndex()); if (it.isEmpty()) { - AELog.debug("Cannot open container for player %s since they no longer hold the item in slot %d", - player, locator.hasItemIndex()); + AELog.debug("Cannot open container for player %s since they no longer hold the item in slot %d", player, + locator.hasItemIndex()); return null; } - if ( it.getItem() instanceof IGuiItem ) - { + if (it.getItem() instanceof IGuiItem) { IGuiItem guiItem = (IGuiItem) it.getItem(); // Optionally contains the block the item was used on to open the container BlockPos blockPos = locator.hasBlockPos() ? locator.getBlockPos() : null; @@ -178,10 +179,9 @@ public final class ContainerHelper { } } - if( interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class) ) - { - final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it ); - if ( wh != null) { + if (interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class)) { + final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(it); + if (wh != null) { return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex())); } } @@ -196,8 +196,7 @@ public final class ContainerHelper { private boolean checkPermission(PlayerEntity player, Object accessInterface) { - if (requiredPermission != null) - { + if (requiredPermission != null) { return Platform.checkPermissions(player, accessInterface, requiredPermission, true); } diff --git a/src/main/java/appeng/container/implementations/ContainerIOPort.java b/src/main/java/appeng/container/implementations/ContainerIOPort.java index 065463baa..1c16fd4d6 100644 --- a/src/main/java/appeng/container/implementations/ContainerIOPort.java +++ b/src/main/java/appeng/container/implementations/ContainerIOPort.java @@ -18,9 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -32,129 +29,114 @@ import appeng.api.config.OperationMode; import appeng.api.config.RedstoneMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.storage.TileIOPort; import appeng.util.Platform; +public class ContainerIOPort extends ContainerUpgradeable { -public class ContainerIOPort extends ContainerUpgradeable -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerIOPort::new, TileIOPort.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerIOPort::new, TileIOPort.class, SecurityPermissions.BUILD); + public static ContainerIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @GuiSync(2) + public FullnessMode fMode = FullnessMode.EMPTY; + @GuiSync(3) + public OperationMode opMode = OperationMode.EMPTY; - @GuiSync( 2 ) - public FullnessMode fMode = FullnessMode.EMPTY; - @GuiSync( 3 ) - public OperationMode opMode = OperationMode.EMPTY; + public ContainerIOPort(int id, final PlayerInventory ip, final TileIOPort te) { + super(TYPE, id, ip, te); + } - public ContainerIOPort(int id, final PlayerInventory ip, final TileIOPort te ) - { - super( TYPE, id, ip, te ); - } + @Override + protected int getHeight() { + return 166; + } - @Override - protected int getHeight() - { - return 166; - } + @Override + protected void setupConfig() { + int offX = 19; + int offY = 17; - @Override - protected void setupConfig() - { - int offX = 19; - int offY = 17; + final IItemHandler cells = this.getUpgradeable().getInventoryByName("cells"); - final IItemHandler cells = this.getUpgradeable().getInventoryByName( "cells" ); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 2; x++) { + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, + x + y * 2, offX + x * 18, offY + y * 18, this.getPlayerInventory())); + } + } - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 2; x++ ) - { - this.addSlot( - new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, x + y * 2, offX + x * 18, offY + y * 18, this - .getPlayerInventory() ) ); - } - } + offX = 122; + offY = 17; + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 2; x++) { + this.addSlot(new SlotOutput(cells, 6 + x + y * 2, offX + x * 18, offY + y * 18, + SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon)); + } + } - offX = 122; - offY = 17; - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 2; x++ ) - { - this.addSlot( - new SlotOutput( cells, 6 + x + y * 2, offX + x * 18, offY + y * 18, SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon ) ); - } - } + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + } - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - protected boolean supportCapacity() - { - return false; - } + @Override + public int availableUpgrades() { + return 3; + } - @Override - public int availableUpgrades() - { - return 3; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.setOperationMode( + (OperationMode) this.getUpgradeable().getConfigManager().getSetting(Settings.OPERATION_MODE)); + this.setFullMode( + (FullnessMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FULLNESS_MODE)); + this.setRedStoneMode( + (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED)); + } - if( Platform.isServer() ) - { - this.setOperationMode( (OperationMode) this.getUpgradeable().getConfigManager().getSetting( Settings.OPERATION_MODE ) ); - this.setFullMode( (FullnessMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FULLNESS_MODE ) ); - this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) ); - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + public FullnessMode getFullMode() { + return this.fMode; + } - public FullnessMode getFullMode() - { - return this.fMode; - } + private void setFullMode(final FullnessMode fMode) { + this.fMode = fMode; + } - private void setFullMode( final FullnessMode fMode ) - { - this.fMode = fMode; - } + public OperationMode getOperationMode() { + return this.opMode; + } - public OperationMode getOperationMode() - { - return this.opMode; - } - - private void setOperationMode( final OperationMode opMode ) - { - this.opMode = opMode; - } + private void setOperationMode(final OperationMode opMode) { + this.opMode = opMode; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerInscriber.java b/src/main/java/appeng/container/implementations/ContainerInscriber.java index 55f32c6ed..1d5bf2c89 100644 --- a/src/main/java/appeng/container/implementations/ContainerInscriber.java +++ b/src/main/java/appeng/container/implementations/ContainerInscriber.java @@ -18,6 +18,13 @@ package appeng.container.implementations; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.IItemHandler; import appeng.api.AEApi; import appeng.api.definitions.IItemDefinition; @@ -30,14 +37,6 @@ import appeng.container.slot.SlotRestrictedInput; import appeng.tile.misc.InscriberRecipes; import appeng.tile.misc.TileInscriber; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.items.IItemHandler; - /** * @author AlgorithmX2 @@ -45,139 +44,128 @@ import net.minecraftforge.items.IItemHandler; * @version rv2 * @since rv0 */ -public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider -{ +public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerInscriber::new, TileInscriber.class); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerInscriber::new, TileInscriber.class); - public static ContainerInscriber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerInscriber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - private final TileInscriber ti; + private final TileInscriber ti; - private final Slot top; - private final Slot middle; - private final Slot bottom; + private final Slot top; + private final Slot middle; + private final Slot bottom; - @GuiSync( 2 ) - public int maxProcessingTime = -1; + @GuiSync(2) + public int maxProcessingTime = -1; - @GuiSync( 3 ) - public int processingTime = -1; + @GuiSync(3) + public int processingTime = -1; - public ContainerInscriber(int id, final PlayerInventory ip, final TileInscriber te ) - { - super( TYPE, id, ip, te ); - this.ti = te; + public ContainerInscriber(int id, final PlayerInventory ip, final TileInscriber te) { + super(TYPE, id, ip, te); + this.ti = te; - IItemHandler inv = te.getInternalInventory(); + IItemHandler inv = te.getInternalInventory(); - SlotRestrictedInput top = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 0, 45, 16, this.getPlayerInventory()); - top.setStackLimit(1); - this.top = this.addSlot(top); - SlotRestrictedInput bottom = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 1, 45, 62, this.getPlayerInventory()); - bottom.setStackLimit(1); - this.bottom = this.addSlot(bottom); - SlotRestrictedInput middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, inv, 2, 63, 39, this.getPlayerInventory() ); - middle.setStackLimit(1); - this.middle = this.addSlot(middle); + SlotRestrictedInput top = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 0, + 45, 16, this.getPlayerInventory()); + top.setStackLimit(1); + this.top = this.addSlot(top); + SlotRestrictedInput bottom = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, + 1, 45, 62, this.getPlayerInventory()); + bottom.setStackLimit(1); + this.bottom = this.addSlot(bottom); + SlotRestrictedInput middle = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, inv, + 2, 63, 39, this.getPlayerInventory()); + middle.setStackLimit(1); + this.middle = this.addSlot(middle); - this.addSlot( new SlotOutput( inv, 3, 113, 40, -1 ) ); - } + this.addSlot(new SlotOutput(inv, 3, 113, 40, -1)); + } - @Override - protected int getHeight() - { - return 176; - } + @Override + protected int getHeight() { + return 176; + } - @Override - /** - * Overridden super.setupConfig to prevent setting up the fake slots - */ - protected void setupConfig() - { - this.setupUpgrades(); - } + @Override + /** + * Overridden super.setupConfig to prevent setting up the fake slots + */ + protected void setupConfig() { + this.setupUpgrades(); + } - @Override - protected boolean supportCapacity() - { - return false; - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - public int availableUpgrades() - { - return 3; - } + @Override + public int availableUpgrades() { + return 3; + } - @Override - public void detectAndSendChanges() - { - this.standardDetectAndSendChanges(); + @Override + public void detectAndSendChanges() { + this.standardDetectAndSendChanges(); - if( Platform.isServer() ) - { - this.maxProcessingTime = this.ti.getMaxProcessingTime(); - this.processingTime = this.ti.getProcessingTime(); - } - } + if (Platform.isServer()) { + this.maxProcessingTime = this.ti.getMaxProcessingTime(); + this.processingTime = this.ti.getProcessingTime(); + } + } - @Override - public boolean isValidForSlot( final Slot s, final ItemStack is ) - { - final ItemStack top = this.ti.getInternalInventory().getStackInSlot( 0 ); - final ItemStack bot = this.ti.getInternalInventory().getStackInSlot( 1 ); + @Override + public boolean isValidForSlot(final Slot s, final ItemStack is) { + final ItemStack top = this.ti.getInternalInventory().getStackInSlot(0); + final ItemStack bot = this.ti.getInternalInventory().getStackInSlot(1); - if( s == this.middle ) - { - IItemDefinition press = AEApi.instance().definitions().materials().namePress(); - if( press.isSameAs( top ) || press.isSameAs( bot ) ) - { - return !press.isSameAs( is ); - } + if (s == this.middle) { + IItemDefinition press = AEApi.instance().definitions().materials().namePress(); + if (press.isSameAs(top) || press.isSameAs(bot)) { + return !press.isSameAs(is); + } - return InscriberRecipes.findRecipe(ti.getWorld(), is, top, bot, false) != null; - } - else if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) ) { - ItemStack otherSlot; - if (s == this.top) { - otherSlot = this.bottom.getStack(); - } else { - otherSlot = this.top.getStack(); - } + return InscriberRecipes.findRecipe(ti.getWorld(), is, top, bot, false) != null; + } else if ((s == this.top && !bot.isEmpty()) || (s == this.bottom && !top.isEmpty())) { + ItemStack otherSlot; + if (s == this.top) { + otherSlot = this.bottom.getStack(); + } else { + otherSlot = this.top.getStack(); + } - // name presses - final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress(); - if (namePress.isSameAs(otherSlot)) { - return namePress.isSameAs(is); - } + // name presses + final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress(); + if (namePress.isSameAs(otherSlot)) { + return namePress.isSameAs(is); + } - // everything else - // test for a partial recipe match (ignoring the middle slot) - return InscriberRecipes.isValidOptionalIngredientCombination(ti.getWorld(), is, otherSlot); - } - return true; - } + // everything else + // test for a partial recipe match (ignoring the middle slot) + return InscriberRecipes.isValidOptionalIngredientCombination(ti.getWorld(), is, otherSlot); + } + return true; + } - @Override - public int getCurrentProgress() - { - return this.processingTime; - } + @Override + public int getCurrentProgress() { + return this.processingTime; + } - @Override - public int getMaxProgress() - { - return this.maxProcessingTime; - } + @Override + public int getMaxProgress() { + return this.maxProcessingTime; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerInterface.java b/src/main/java/appeng/container/implementations/ContainerInterface.java index 46b7f3935..b84b8e830 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterface.java +++ b/src/main/java/appeng/container/implementations/ContainerInterface.java @@ -18,121 +18,105 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.YesNo; import appeng.api.util.IConfigManager; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotFake; import appeng.container.slot.SlotNormal; import appeng.container.slot.SlotRestrictedInput; import appeng.helpers.DualityInterface; import appeng.helpers.IInterfaceHost; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +public class ContainerInterface extends ContainerUpgradeable { -public class ContainerInterface extends ContainerUpgradeable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerInterface::new, IInterfaceHost.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerInterface::new, IInterfaceHost.class, SecurityPermissions.BUILD); + public static ContainerInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final DualityInterface myDuality; - private final DualityInterface myDuality; + @GuiSync(3) + public YesNo bMode = YesNo.NO; - @GuiSync( 3 ) - public YesNo bMode = YesNo.NO; + @GuiSync(4) + public YesNo iTermMode = YesNo.YES; - @GuiSync( 4 ) - public YesNo iTermMode = YesNo.YES; + public ContainerInterface(int id, final PlayerInventory ip, final IInterfaceHost te) { + super(TYPE, id, ip, te.getInterfaceDuality().getHost()); - public ContainerInterface(int id, final PlayerInventory ip, final IInterfaceHost te ) - { - super( TYPE, id, ip, te.getInterfaceDuality().getHost() ); + this.myDuality = te.getInterfaceDuality(); - this.myDuality = te.getInterfaceDuality(); + for (int x = 0; x < DualityInterface.NUMBER_OF_PATTERN_SLOTS; x++) { + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, + this.myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7, this.getPlayerInventory())); + } - for( int x = 0; x < DualityInterface.NUMBER_OF_PATTERN_SLOTS; x++ ) - { - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, this.myDuality - .getPatterns(), x, 8 + 18 * x, 90 + 7, this.getPlayerInventory() ) ); - } + for (int x = 0; x < DualityInterface.NUMBER_OF_CONFIG_SLOTS; x++) { + this.addSlot(new SlotFake(this.myDuality.getConfig(), x, 8 + 18 * x, 35)); + } - for( int x = 0; x < DualityInterface.NUMBER_OF_CONFIG_SLOTS; x++ ) - { - this.addSlot( new SlotFake( this.myDuality.getConfig(), x, 8 + 18 * x, 35 ) ); - } + for (int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++) { + this.addSlot(new SlotNormal(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18)); + } + } - for( int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++ ) - { - this.addSlot( new SlotNormal( this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18 ) ); - } - } + @Override + protected int getHeight() { + return 211; + } - @Override - protected int getHeight() - { - return 211; - } + @Override + protected void setupConfig() { + this.setupUpgrades(); + } - @Override - protected void setupConfig() - { - this.setupUpgrades(); - } + @Override + public int availableUpgrades() { + return 1; + } - @Override - public int availableUpgrades() - { - return 1; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); + super.detectAndSendChanges(); + } - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); - super.detectAndSendChanges(); - } + @Override + protected void loadSettingsFromHost(final IConfigManager cm) { + this.setBlockingMode((YesNo) cm.getSetting(Settings.BLOCK)); + this.setInterfaceTerminalMode((YesNo) cm.getSetting(Settings.INTERFACE_TERMINAL)); + } - @Override - protected void loadSettingsFromHost( final IConfigManager cm ) - { - this.setBlockingMode( (YesNo) cm.getSetting( Settings.BLOCK ) ); - this.setInterfaceTerminalMode( (YesNo) cm.getSetting( Settings.INTERFACE_TERMINAL ) ); - } + public YesNo getBlockingMode() { + return this.bMode; + } - public YesNo getBlockingMode() - { - return this.bMode; - } + private void setBlockingMode(final YesNo bMode) { + this.bMode = bMode; + } - private void setBlockingMode( final YesNo bMode ) - { - this.bMode = bMode; - } + public YesNo getInterfaceTerminalMode() { + return this.iTermMode; + } - public YesNo getInterfaceTerminalMode() - { - return this.iTermMode; - } - - private void setInterfaceTerminalMode( final YesNo iTermMode ) - { - this.iTermMode = iTermMode; - } + private void setInterfaceTerminalMode(final YesNo iTermMode) { + this.iTermMode = iTermMode; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java index 08efa928e..f10ce629b 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java @@ -18,29 +18,28 @@ package appeng.container.implementations; - import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraftforge.items.IItemHandler; +import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.YesNo; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketCompressedNBT; import appeng.helpers.DualityInterface; @@ -60,394 +59,325 @@ import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.WrapperRangeItemHandler; import appeng.util.inv.filter.IAEItemFilter; - -public final class ContainerInterfaceTerminal extends AEBaseContainer -{ - - public static ContainerType TYPE; - - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerInterfaceTerminal::new, PartInterfaceTerminal.class, SecurityPermissions.BUILD); - - public static ContainerInterfaceTerminal fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } - - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - /** - * this stuff is all server side.. - */ - - private static long autoBase = Long.MIN_VALUE; - private final Map diList = new HashMap<>(); - private final Map byId = new HashMap<>(); - private IGrid grid; - private CompoundNBT data = new CompoundNBT(); - - public ContainerInterfaceTerminal(int id, final PlayerInventory ip, final PartInterfaceTerminal anchor ) - { - super( TYPE, id, ip, anchor ); - - if( Platform.isServer() ) - { - this.grid = anchor.getActionableNode().getGrid(); - } - - this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 ); - } - - @Override - public void detectAndSendChanges() - { - if( Platform.isClient() ) - { - return; - } - - super.detectAndSendChanges(); - - if( this.grid == null ) - { - return; - } - - int total = 0; - boolean missing = false; - - final IActionHost host = this.getActionHost(); - if( host != null ) - { - final IGridNode agn = host.getActionableNode(); - if( agn != null && agn.isActive() ) - { - for( final IGridNode gn : this.grid.getMachines( TileInterface.class ) ) - { - if( gn.isActive() ) - { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO ) - { - continue; - } - - final InvTracker t = this.diList.get( ih ); - - if( t == null ) - { - missing = true; - } - else - { - final DualityInterface dual = ih.getInterfaceDuality(); - if( !t.unlocalizedName.equals( dual.getTermName() ) ) - { - missing = true; - } - } - - total++; - } - } - - for( final IGridNode gn : this.grid.getMachines( PartInterface.class ) ) - { - if( gn.isActive() ) - { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO ) - { - continue; - } - - final InvTracker t = this.diList.get( ih ); - - if( t == null ) - { - missing = true; - } - else - { - final DualityInterface dual = ih.getInterfaceDuality(); - if( !t.unlocalizedName.equals( dual.getTermName() ) ) - { - missing = true; - } - } - - total++; - } - } - } - } - - if( total != this.diList.size() || missing ) - { - this.regenList( this.data ); - } - else - { - for( final Entry en : this.diList.entrySet() ) - { - final InvTracker inv = en.getValue(); - for( int x = 0; x < inv.server.getSlots(); x++ ) - { - if( this.isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) ) - { - this.addItems( this.data, inv, x, 1 ); - } - } - } - } - - if( !this.data.isEmpty() ) - { - try - { - NetworkHandler.instance().sendTo( new PacketCompressedNBT( this.data ), (ServerPlayerEntity) this.getPlayerInv().player ); - } - catch( final IOException e ) - { - // :P - } - - this.data = new CompoundNBT(); - } - } - - @Override - public void doAction( final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id ) - { - final InvTracker inv = this.byId.get( id ); - if( inv != null ) - { - final ItemStack is = inv.server.getStackInSlot( slot ); - final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty(); - - final InventoryAdaptor playerHand = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) ); - - final IItemHandler theSlot = new WrapperFilteredItemHandler( new WrapperRangeItemHandler( inv.server, slot, slot + 1 ), new PatternSlotFilter() ); - final InventoryAdaptor interfaceSlot = new AdaptorItemHandler( theSlot ); - - switch( action ) - { - case PICKUP_OR_SET_DOWN: - - if( hasItemInHand ) - { - ItemStack inSlot = theSlot.getStackInSlot( 0 ); - if( inSlot.isEmpty() ) - { - player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) ); - } - else - { - inSlot = inSlot.copy(); - final ItemStack inHand = player.inventory.getItemStack().copy(); - - ItemHandlerUtil.setStackInSlot( theSlot, 0, ItemStack.EMPTY ); - player.inventory.setItemStack( ItemStack.EMPTY ); - - player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) ); - - if( player.inventory.getItemStack().isEmpty() ) - { - player.inventory.setItemStack( inSlot ); - } - else - { - player.inventory.setItemStack( inHand ); - ItemHandlerUtil.setStackInSlot( theSlot, 0, inSlot ); - } - } - } - else - { - ItemHandlerUtil.setStackInSlot( theSlot, 0, playerHand.addItems( theSlot.getStackInSlot( 0 ) ) ); - } - - break; - case SPLIT_OR_PLACE_SINGLE: - - if( hasItemInHand ) - { - ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null ); - if( !extra.isEmpty() ) - { - extra = interfaceSlot.addItems( extra ); - } - if( !extra.isEmpty() ) - { - playerHand.addItems( extra ); - } - } - else if( !is.isEmpty() ) - { - ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, ItemStack.EMPTY, null ); - if( !extra.isEmpty() ) - { - extra = playerHand.addItems( extra ); - } - if( !extra.isEmpty() ) - { - interfaceSlot.addItems( extra ); - } - } - - break; - case SHIFT_CLICK: - - final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player ); - - ItemHandlerUtil.setStackInSlot( theSlot, 0, playerInv.addItems( theSlot.getStackInSlot( 0 ) ) ); - - break; - case MOVE_REGION: - - final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player ); - for( int x = 0; x < inv.server.getSlots(); x++ ) - { - ItemHandlerUtil.setStackInSlot( inv.server, x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) ); - } - - break; - case CREATIVE_DUPLICATE: - - if( player.abilities.isCreativeMode && !hasItemInHand ) - { - player.inventory.setItemStack( is.isEmpty() ? ItemStack.EMPTY : is.copy() ); - } - - break; - default: - return; - } - - this.updateHeld( player ); - } - } - - private void regenList( final CompoundNBT data ) - { - this.byId.clear(); - this.diList.clear(); - - final IActionHost host = this.getActionHost(); - if( host != null ) - { - final IGridNode agn = host.getActionableNode(); - if( agn != null && agn.isActive() ) - { - for( final IGridNode gn : this.grid.getMachines( TileInterface.class ) ) - { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES ) - { - this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName().getString() ) ); - } - } - - for( final IGridNode gn : this.grid.getMachines( PartInterface.class ) ) - { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES ) - { - this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName().getString() ) ); - } - } - } - } - - data.putBoolean("clear", true); - - for( final Entry en : this.diList.entrySet() ) - { - final InvTracker inv = en.getValue(); - this.byId.put( inv.which, inv ); - this.addItems( data, inv, 0, inv.server.getSlots() ); - } - } - - private boolean isDifferent( final ItemStack a, final ItemStack b ) - { - if( a.isEmpty() && b.isEmpty() ) - { - return false; - } - - if( a.isEmpty() || b.isEmpty() ) - { - return true; - } - - return !ItemStack.areItemStacksEqual( a, b ); - } - - private void addItems( final CompoundNBT data, final InvTracker inv, final int offset, final int length ) - { - final String name = '=' + Long.toString( inv.which, Character.MAX_RADIX ); - final CompoundNBT tag = data.getCompound( name ); - - if( tag.isEmpty() ) - { - tag.putLong( "sortBy", inv.sortBy ); - tag.putString("un", inv.unlocalizedName); - } - - for( int x = 0; x < length; x++ ) - { - final CompoundNBT itemNBT = new CompoundNBT(); - - final ItemStack is = inv.server.getStackInSlot( x + offset ); - - // "update" client side. - ItemHandlerUtil.setStackInSlot( inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() ); - - if( !is.isEmpty() ) - { - is.write(itemNBT); - } - - tag.put( Integer.toString( x + offset ), itemNBT ); - } - - data.put( name, tag ); - } - - private static class InvTracker - { - - private final long sortBy; - private final long which = autoBase++; - private final String unlocalizedName; - private final IItemHandler client; - private final IItemHandler server; - - public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName ) - { - this.server = patterns; - this.client = new AppEngInternalInventory( null, this.server.getSlots() ); - this.unlocalizedName = unlocalizedName; - this.sortBy = dual.getSortValue(); - } - } - - private static class PatternSlotFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern; - } - } +public final class ContainerInterfaceTerminal extends AEBaseContainer { + + public static ContainerType TYPE; + + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerInterfaceTerminal::new, PartInterfaceTerminal.class, SecurityPermissions.BUILD); + + public static ContainerInterfaceTerminal fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } + + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } + + /** + * this stuff is all server side.. + */ + + private static long autoBase = Long.MIN_VALUE; + private final Map diList = new HashMap<>(); + private final Map byId = new HashMap<>(); + private IGrid grid; + private CompoundNBT data = new CompoundNBT(); + + public ContainerInterfaceTerminal(int id, final PlayerInventory ip, final PartInterfaceTerminal anchor) { + super(TYPE, id, ip, anchor); + + if (Platform.isServer()) { + this.grid = anchor.getActionableNode().getGrid(); + } + + this.bindPlayerInventory(ip, 0, 222 - /* height of player inventory */82); + } + + @Override + public void detectAndSendChanges() { + if (Platform.isClient()) { + return; + } + + super.detectAndSendChanges(); + + if (this.grid == null) { + return; + } + + int total = 0; + boolean missing = false; + + final IActionHost host = this.getActionHost(); + if (host != null) { + final IGridNode agn = host.getActionableNode(); + if (agn != null && agn.isActive()) { + for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) { + if (gn.isActive()) { + final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); + if (ih.getInterfaceDuality().getConfigManager() + .getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { + continue; + } + + final InvTracker t = this.diList.get(ih); + + if (t == null) { + missing = true; + } else { + final DualityInterface dual = ih.getInterfaceDuality(); + if (!t.unlocalizedName.equals(dual.getTermName())) { + missing = true; + } + } + + total++; + } + } + + for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) { + if (gn.isActive()) { + final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); + if (ih.getInterfaceDuality().getConfigManager() + .getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { + continue; + } + + final InvTracker t = this.diList.get(ih); + + if (t == null) { + missing = true; + } else { + final DualityInterface dual = ih.getInterfaceDuality(); + if (!t.unlocalizedName.equals(dual.getTermName())) { + missing = true; + } + } + + total++; + } + } + } + } + + if (total != this.diList.size() || missing) { + this.regenList(this.data); + } else { + for (final Entry en : this.diList.entrySet()) { + final InvTracker inv = en.getValue(); + for (int x = 0; x < inv.server.getSlots(); x++) { + if (this.isDifferent(inv.server.getStackInSlot(x), inv.client.getStackInSlot(x))) { + this.addItems(this.data, inv, x, 1); + } + } + } + } + + if (!this.data.isEmpty()) { + try { + NetworkHandler.instance().sendTo(new PacketCompressedNBT(this.data), + (ServerPlayerEntity) this.getPlayerInv().player); + } catch (final IOException e) { + // :P + } + + this.data = new CompoundNBT(); + } + } + + @Override + public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) { + final InvTracker inv = this.byId.get(id); + if (inv != null) { + final ItemStack is = inv.server.getStackInSlot(slot); + final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty(); + + final InventoryAdaptor playerHand = new AdaptorItemHandler(new WrapperCursorItemHandler(player.inventory)); + + final IItemHandler theSlot = new WrapperFilteredItemHandler( + new WrapperRangeItemHandler(inv.server, slot, slot + 1), new PatternSlotFilter()); + final InventoryAdaptor interfaceSlot = new AdaptorItemHandler(theSlot); + + switch (action) { + case PICKUP_OR_SET_DOWN: + + if (hasItemInHand) { + ItemStack inSlot = theSlot.getStackInSlot(0); + if (inSlot.isEmpty()) { + player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack())); + } else { + inSlot = inSlot.copy(); + final ItemStack inHand = player.inventory.getItemStack().copy(); + + ItemHandlerUtil.setStackInSlot(theSlot, 0, ItemStack.EMPTY); + player.inventory.setItemStack(ItemStack.EMPTY); + + player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy())); + + if (player.inventory.getItemStack().isEmpty()) { + player.inventory.setItemStack(inSlot); + } else { + player.inventory.setItemStack(inHand); + ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot); + } + } + } else { + ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getStackInSlot(0))); + } + + break; + case SPLIT_OR_PLACE_SINGLE: + + if (hasItemInHand) { + ItemStack extra = playerHand.removeItems(1, ItemStack.EMPTY, null); + if (!extra.isEmpty()) { + extra = interfaceSlot.addItems(extra); + } + if (!extra.isEmpty()) { + playerHand.addItems(extra); + } + } else if (!is.isEmpty()) { + ItemStack extra = interfaceSlot.removeItems((is.getCount() + 1) / 2, ItemStack.EMPTY, null); + if (!extra.isEmpty()) { + extra = playerHand.addItems(extra); + } + if (!extra.isEmpty()) { + interfaceSlot.addItems(extra); + } + } + + break; + case SHIFT_CLICK: + + final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player); + + ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getStackInSlot(0))); + + break; + case MOVE_REGION: + + final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player); + for (int x = 0; x < inv.server.getSlots(); x++) { + ItemHandlerUtil.setStackInSlot(inv.server, x, + playerInvAd.addItems(inv.server.getStackInSlot(x))); + } + + break; + case CREATIVE_DUPLICATE: + + if (player.abilities.isCreativeMode && !hasItemInHand) { + player.inventory.setItemStack(is.isEmpty() ? ItemStack.EMPTY : is.copy()); + } + + break; + default: + return; + } + + this.updateHeld(player); + } + } + + private void regenList(final CompoundNBT data) { + this.byId.clear(); + this.diList.clear(); + + final IActionHost host = this.getActionHost(); + if (host != null) { + final IGridNode agn = host.getActionableNode(); + if (agn != null && agn.isActive()) { + for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) { + final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); + final DualityInterface dual = ih.getInterfaceDuality(); + if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { + this.diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName().getString())); + } + } + + for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) { + final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); + final DualityInterface dual = ih.getInterfaceDuality(); + if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { + this.diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName().getString())); + } + } + } + } + + data.putBoolean("clear", true); + + for (final Entry en : this.diList.entrySet()) { + final InvTracker inv = en.getValue(); + this.byId.put(inv.which, inv); + this.addItems(data, inv, 0, inv.server.getSlots()); + } + } + + private boolean isDifferent(final ItemStack a, final ItemStack b) { + if (a.isEmpty() && b.isEmpty()) { + return false; + } + + if (a.isEmpty() || b.isEmpty()) { + return true; + } + + return !ItemStack.areItemStacksEqual(a, b); + } + + private void addItems(final CompoundNBT data, final InvTracker inv, final int offset, final int length) { + final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX); + final CompoundNBT tag = data.getCompound(name); + + if (tag.isEmpty()) { + tag.putLong("sortBy", inv.sortBy); + tag.putString("un", inv.unlocalizedName); + } + + for (int x = 0; x < length; x++) { + final CompoundNBT itemNBT = new CompoundNBT(); + + final ItemStack is = inv.server.getStackInSlot(x + offset); + + // "update" client side. + ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy()); + + if (!is.isEmpty()) { + is.write(itemNBT); + } + + tag.put(Integer.toString(x + offset), itemNBT); + } + + data.put(name, tag); + } + + private static class InvTracker { + + private final long sortBy; + private final long which = autoBase++; + private final String unlocalizedName; + private final IItemHandler client; + private final IItemHandler server; + + public InvTracker(final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName) { + this.server = patterns; + this.client = new AppEngInternalInventory(null, this.server.getSlots()); + this.unlocalizedName = unlocalizedName; + this.sortBy = dual.getSortValue(); + } + } + + private static class PatternSlotFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } + + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern; + } + } } diff --git a/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java b/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java index f2ccfbb8b..9ef67ef7d 100644 --- a/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java +++ b/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java @@ -18,8 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -35,155 +33,133 @@ import appeng.api.config.RedstoneMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.YesNo; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; import appeng.parts.automation.PartLevelEmitter; import appeng.util.Platform; +public class ContainerLevelEmitter extends ContainerUpgradeable { -public class ContainerLevelEmitter extends ContainerUpgradeable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerLevelEmitter::new, PartLevelEmitter.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerLevelEmitter::new, PartLevelEmitter.class, SecurityPermissions.BUILD); + public static ContainerLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final PartLevelEmitter lvlEmitter; - private final PartLevelEmitter lvlEmitter; + @OnlyIn(Dist.CLIENT) + private TextFieldWidget textField; + @GuiSync(2) + public LevelType lvType; + @GuiSync(3) + public long EmitterValue = -1; + @GuiSync(4) + public YesNo cmType; - @OnlyIn( Dist.CLIENT ) - private TextFieldWidget textField; - @GuiSync( 2 ) - public LevelType lvType; - @GuiSync( 3 ) - public long EmitterValue = -1; - @GuiSync( 4 ) - public YesNo cmType; + public ContainerLevelEmitter(int id, final PlayerInventory ip, final PartLevelEmitter te) { + super(TYPE, id, ip, te); + this.lvlEmitter = te; + } - public ContainerLevelEmitter( int id, final PlayerInventory ip, final PartLevelEmitter te ) - { - super( TYPE, id, ip, te ); - this.lvlEmitter = te; - } + @OnlyIn(Dist.CLIENT) + public void setTextField(final TextFieldWidget level) { + this.textField = level; + this.textField.setText(String.valueOf(this.EmitterValue)); + } - @OnlyIn( Dist.CLIENT ) - public void setTextField( final TextFieldWidget level ) - { - this.textField = level; - this.textField.setText( String.valueOf( this.EmitterValue ) ); - } + public void setLevel(final long l, final PlayerEntity player) { + this.lvlEmitter.setReportingValue(l); + this.EmitterValue = l; + } - public void setLevel( final long l, final PlayerEntity player ) - { - this.lvlEmitter.setReportingValue( l ); - this.EmitterValue = l; - } + @Override + protected void setupConfig() { + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + if (this.availableUpgrades() > 0) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 1) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, + 8 + 18, this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 2) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 3) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + } - @Override - protected void setupConfig() - { - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - if( this.availableUpgrades() > 0 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 1 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 2 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 3 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + final IItemHandler inv = this.getUpgradeable().getInventoryByName("config"); + final int y = 40; + final int x = 80 + 44; + this.addSlot(new SlotFakeTypeOnly(inv, 0, x, y)); + } - final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); - final int y = 40; - final int x = 80 + 44; - this.addSlot( new SlotFakeTypeOnly( inv, 0, x, y ) ); - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - protected boolean supportCapacity() - { - return false; - } + @Override + public int availableUpgrades() { - @Override - public int availableUpgrades() - { + return 1; + } - return 1; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.EmitterValue = this.lvlEmitter.getReportingValue(); + this.setCraftingMode( + (YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.CRAFT_VIA_REDSTONE)); + this.setLevelMode((LevelType) this.getUpgradeable().getConfigManager().getSetting(Settings.LEVEL_TYPE)); + this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE)); + this.setRedStoneMode( + (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_EMITTER)); + } - if( Platform.isServer() ) - { - this.EmitterValue = this.lvlEmitter.getReportingValue(); - this.setCraftingMode( (YesNo) this.getUpgradeable().getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) ); - this.setLevelMode( (LevelType) this.getUpgradeable().getConfigManager().getSetting( Settings.LEVEL_TYPE ) ); - this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) ); - this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) ); - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("EmitterValue")) { + if (this.textField != null) { + this.textField.setText(String.valueOf(this.EmitterValue)); + } + } + } - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "EmitterValue" ) ) - { - if( this.textField != null ) - { - this.textField.setText( String.valueOf( this.EmitterValue ) ); - } - } - } + @Override + public YesNo getCraftingMode() { + return this.cmType; + } - @Override - public YesNo getCraftingMode() - { - return this.cmType; - } + @Override + public void setCraftingMode(final YesNo cmType) { + this.cmType = cmType; + } - @Override - public void setCraftingMode( final YesNo cmType ) - { - this.cmType = cmType; - } + public LevelType getLevelMode() { + return this.lvType; + } - public LevelType getLevelMode() - { - return this.lvType; - } - - private void setLevelMode( final LevelType lvType ) - { - this.lvType = lvType; - } + private void setLevelMode(final LevelType lvType) { + this.lvType = lvType; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerMAC.java b/src/main/java/appeng/container/implementations/ContainerMAC.java index 24cc356ee..8c7000466 100644 --- a/src/main/java/appeng/container/implementations/ContainerMAC.java +++ b/src/main/java/appeng/container/implementations/ContainerMAC.java @@ -18,6 +18,13 @@ package appeng.container.implementations; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.world.World; +import net.minecraftforge.items.IItemHandler; import appeng.api.config.RedstoneMode; import appeng.api.config.SecurityPermissions; @@ -33,152 +40,125 @@ import appeng.container.slot.SlotRestrictedInput; import appeng.items.misc.ItemEncodedPattern; import appeng.tile.crafting.TileMolecularAssembler; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.world.World; -import net.minecraftforge.items.IItemHandler; +public class ContainerMAC extends ContainerUpgradeable implements IProgressProvider { -public class ContainerMAC extends ContainerUpgradeable implements IProgressProvider -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerMAC::new, TileMolecularAssembler.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerMAC::new, TileMolecularAssembler.class); + public static ContainerMAC fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerMAC fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private static final int MAX_CRAFT_PROGRESS = 100; + private final TileMolecularAssembler tma; + @GuiSync(4) + public int craftProgress = 0; - private static final int MAX_CRAFT_PROGRESS = 100; - private final TileMolecularAssembler tma; - @GuiSync( 4 ) - public int craftProgress = 0; + public ContainerMAC(int id, final PlayerInventory ip, final TileMolecularAssembler te) { + super(TYPE, id, ip, te); + this.tma = te; + } - public ContainerMAC(int id, final PlayerInventory ip, final TileMolecularAssembler te ) - { - super( TYPE, id, ip, te ); - this.tma = te; - } + public boolean isValidItemForSlot(final int slotIndex, final ItemStack i) { + final IItemHandler mac = this.getUpgradeable().getInventoryByName("mac"); - public boolean isValidItemForSlot( final int slotIndex, final ItemStack i ) - { - final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" ); + final ItemStack is = mac.getStackInSlot(10); + if (is.isEmpty()) { + return false; + } - final ItemStack is = mac.getStackInSlot( 10 ); - if( is.isEmpty() ) - { - return false; - } + if (is.getItem() instanceof ItemEncodedPattern) { + final World w = this.getTileEntity().getWorld(); + final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); + final ICraftingPatternDetails ph = iep.getPatternForItem(is, w); + if (ph.isCraftable()) { + return ph.isValidItemForSlot(slotIndex, i, w); + } + } - if( is.getItem() instanceof ItemEncodedPattern ) - { - final World w = this.getTileEntity().getWorld(); - final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - final ICraftingPatternDetails ph = iep.getPatternForItem( is, w ); - if( ph.isCraftable() ) - { - return ph.isValidItemForSlot( slotIndex, i, w ); - } - } + return false; + } - return false; - } + @Override + protected int getHeight() { + return 197; + } - @Override - protected int getHeight() - { - return 197; - } + @Override + protected void setupConfig() { + int offX = 29; + int offY = 30; - @Override - protected void setupConfig() - { - int offX = 29; - int offY = 30; + final IItemHandler mac = this.getUpgradeable().getInventoryByName("mac"); - final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" ); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + final SlotMACPattern s = new SlotMACPattern(this, mac, x + y * 3, offX + x * 18, offY + y * 18); + this.addSlot(s); + } + } - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 3; x++ ) - { - final SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offX + x * 18, offY + y * 18 ); - this.addSlot( s ); - } - } + offX = 126; + offY = 16; - offX = 126; - offY = 16; + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_CRAFTING_PATTERN, mac, 10, + offX, offY, this.getPlayerInventory())); + this.addSlot(new SlotOutput(mac, 9, offX, offY + 32, -1)); - this.addSlot( - new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_CRAFTING_PATTERN, mac, 10, offX, offY, this.getPlayerInventory() ) ); - this.addSlot( new SlotOutput( mac, 9, offX, offY + 32, -1 ) ); + offX = 122; + offY = 17; - offX = 122; - offY = 17; + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, + 8 + 18 * 4, this.getPlayerInventory())).setNotDraggable()); + } - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - protected boolean supportCapacity() - { - return false; - } + @Override + public int availableUpgrades() { + return 5; + } - @Override - public int availableUpgrades() - { - return 5; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.setRedStoneMode( + (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED)); + } - if( Platform.isServer() ) - { - this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) ); - } + this.craftProgress = this.tma.getCraftingProgress(); - this.craftProgress = this.tma.getCraftingProgress(); + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + @Override + public int getCurrentProgress() { + return this.craftProgress; + } - @Override - public int getCurrentProgress() - { - return this.craftProgress; - } - - @Override - public int getMaxProgress() - { - return MAX_CRAFT_PROGRESS; - } + @Override + public int getMaxProgress() { + return MAX_CRAFT_PROGRESS; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java index ef83c5c28..fcefe09bb 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java +++ b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java @@ -18,17 +18,14 @@ package appeng.container.implementations; - import java.io.IOException; import java.nio.BufferOverflowException; import javax.annotation.Nonnull; -import appeng.api.implementations.guiobjects.IGuiItemObject; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.IContainerListener; import net.minecraft.item.ItemStack; @@ -43,6 +40,7 @@ import appeng.api.config.Settings; import appeng.api.config.SortDir; import appeng.api.config.SortOrder; import appeng.api.config.ViewItems; +import appeng.api.implementations.guiobjects.IGuiItemObject; import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.tiles.IMEChest; import appeng.api.implementations.tiles.IViewCellStorage; @@ -65,6 +63,7 @@ import appeng.api.util.AEPartLocation; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotRestrictedInput; import appeng.core.AELog; @@ -76,403 +75,320 @@ import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; import appeng.util.Platform; +public class ContainerMEMonitorable extends AEBaseContainer + implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver { -public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerMEMonitorable::new, ITerminalHost.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerMEMonitorable::new, ITerminalHost.class); + public static ContainerMEMonitorable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerMEMonitorable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5]; + private final IMEMonitor monitor; + private final IItemList items = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final IConfigManager clientCM; + private final ITerminalHost host; + @GuiSync(99) + public boolean canAccessViewCells = false; + @GuiSync(98) + public boolean hasPower = false; + private IConfigManagerHost gui; + private IConfigManager serverCM; + private IGridNode networkNode; - private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5]; - private final IMEMonitor monitor; - private final IItemList items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final IConfigManager clientCM; - private final ITerminalHost host; - @GuiSync( 99 ) - public boolean canAccessViewCells = false; - @GuiSync( 98 ) - public boolean hasPower = false; - private IConfigManagerHost gui; - private IConfigManager serverCM; - private IGridNode networkNode; + public ContainerMEMonitorable(int id, final PlayerInventory ip, final ITerminalHost monitorable) { + this(TYPE, id, ip, monitorable, true); + } - public ContainerMEMonitorable( int id, final PlayerInventory ip, final ITerminalHost monitorable ) - { - this( TYPE, id, ip, monitorable, true ); - } + public ContainerMEMonitorable(ContainerType containerType, int id, PlayerInventory ip, + final ITerminalHost monitorable, final boolean bindInventory) { + super(containerType, id, ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, + monitorable instanceof IPart ? (IPart) monitorable : null, + monitorable instanceof IGuiItemObject ? (IGuiItemObject) monitorable : null); - public ContainerMEMonitorable(ContainerType containerType, int id, PlayerInventory ip, final ITerminalHost monitorable, final boolean bindInventory ) { - super( containerType, - id, - ip, - monitorable instanceof TileEntity ? (TileEntity) monitorable : null, - monitorable instanceof IPart ? (IPart) monitorable : null, - monitorable instanceof IGuiItemObject ? (IGuiItemObject) monitorable : null); + this.host = monitorable; + this.clientCM = new ConfigManager(this); - this.host = monitorable; - this.clientCM = new ConfigManager( this ); + this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); - this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); + if (Platform.isServer()) { + this.serverCM = monitorable.getConfigManager(); - if( Platform.isServer() ) - { - this.serverCM = monitorable.getConfigManager(); + this.monitor = monitorable + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + if (this.monitor != null) { + this.monitor.addListener(this, null); - this.monitor = monitorable.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - if( this.monitor != null ) - { - this.monitor.addListener( this, null ); + this.setCellInventory(this.monitor); - this.setCellInventory( this.monitor ); + if (monitorable instanceof IPortableCell) { + this.setPowerSource((IEnergySource) monitorable); + } else if (monitorable instanceof IMEChest) { + this.setPowerSource((IEnergySource) monitorable); + } else if (monitorable instanceof IGridHost || monitorable instanceof IActionHost) { + final IGridNode node; + if (monitorable instanceof IGridHost) { + node = ((IGridHost) monitorable).getGridNode(AEPartLocation.INTERNAL); + } else if (monitorable instanceof IActionHost) { + node = ((IActionHost) monitorable).getActionableNode(); + } else { + node = null; + } - if( monitorable instanceof IPortableCell ) - { - this.setPowerSource( (IEnergySource) monitorable ); - } - else if( monitorable instanceof IMEChest ) - { - this.setPowerSource( (IEnergySource) monitorable ); - } - else if( monitorable instanceof IGridHost || monitorable instanceof IActionHost ) - { - final IGridNode node; - if( monitorable instanceof IGridHost ) - { - node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL ); - } - else if( monitorable instanceof IActionHost ) - { - node = ( (IActionHost) monitorable ).getActionableNode(); - } - else - { - node = null; - } + if (node != null) { + this.networkNode = node; + final IGrid g = node.getGrid(); + if (g != null) { + this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class))); + } + } + } + } else { + this.setValidContainer(false); + } + } else { + this.monitor = null; + } - if( node != null ) - { - this.networkNode = node; - final IGrid g = node.getGrid(); - if( g != null ) - { - this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class )) ); - } - } - } - } - else - { - this.setValidContainer( false ); - } - } - else - { - this.monitor = null; - } + this.canAccessViewCells = false; + if (monitorable instanceof IViewCellStorage) { + for (int y = 0; y < 5; y++) { + this.cellView[y] = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.VIEW_CELL, + ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8, + this.getPlayerInventory()); + this.cellView[y].setAllowEdit(this.canAccessViewCells); + this.addSlot(this.cellView[y]); + } + } - this.canAccessViewCells = false; - if( monitorable instanceof IViewCellStorage ) - { - for( int y = 0; y < 5; y++ ) - { - this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ) - .getViewCellStorage(), y, 206, y * 18 + 8, this.getPlayerInventory() ); - this.cellView[y].setAllowEdit( this.canAccessViewCells ); - this.addSlot( this.cellView[y] ); - } - } + if (bindInventory) { + this.bindPlayerInventory(ip, 0, 0); + } + } - if( bindInventory ) - { - this.bindPlayerInventory( ip, 0, 0 ); - } - } + public IGridNode getNetworkNode() { + return this.networkNode; + } - public IGridNode getNetworkNode() - { - return this.networkNode; - } + @Override + public void detectAndSendChanges() { + if (Platform.isServer()) { + if (this.monitor != this.host + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))) { + this.setValidContainer(false); + } - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() ) - { - if( this.monitor != this.host.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ) - { - this.setValidContainer( false ); - } + for (final Settings set : this.serverCM.getSettings()) { + final Enum sideLocal = this.serverCM.getSetting(set); + final Enum sideRemote = this.clientCM.getSetting(set); - for( final Settings set : this.serverCM.getSettings() ) - { - final Enum sideLocal = this.serverCM.getSetting( set ); - final Enum sideRemote = this.clientCM.getSetting( set ); + if (sideLocal != sideRemote) { + this.clientCM.putSetting(set, sideLocal); + for (final IContainerListener crafter : this.listeners) { + if (crafter instanceof ServerPlayerEntity) { + NetworkHandler.instance().sendTo(new PacketValueConfig(set.name(), sideLocal.name()), + (ServerPlayerEntity) crafter); + } + } + } + } - if( sideLocal != sideRemote ) - { - this.clientCM.putSetting( set, sideLocal ); - for( final IContainerListener crafter : this.listeners ) - { - if( crafter instanceof ServerPlayerEntity ) - { - NetworkHandler.instance().sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (ServerPlayerEntity) crafter ); - } - } - } - } + if (!this.items.isEmpty()) { + try { + final IItemList monitorCache = this.monitor.getStorageList(); - if( !this.items.isEmpty() ) - { - try - { - final IItemList monitorCache = this.monitor.getStorageList(); + final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); - final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); + for (final IAEItemStack is : this.items) { + final IAEItemStack send = monitorCache.findPrecise(is); + if (send == null) { + is.setStackSize(0); + piu.appendItem(is); + } else { + piu.appendItem(send); + } + } - for( final IAEItemStack is : this.items ) - { - final IAEItemStack send = monitorCache.findPrecise( is ); - if( send == null ) - { - is.setStackSize( 0 ); - piu.appendItem( is ); - } - else - { - piu.appendItem( send ); - } - } + if (!piu.isEmpty()) { + this.items.resetStatus(); - if( !piu.isEmpty() ) - { - this.items.resetStatus(); + for (final Object c : this.listeners) { + if (c instanceof PlayerEntity) { + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + } + } + } + } catch (final IOException e) { + AELog.debug(e); + } + } - for( final Object c : this.listeners ) - { - if( c instanceof PlayerEntity ) - { - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - } - } - } - } - catch( final IOException e ) - { - AELog.debug( e ); - } - } + this.updatePowerStatus(); - this.updatePowerStatus(); + final boolean oldAccessible = this.canAccessViewCells; + this.canAccessViewCells = this.hasAccess(SecurityPermissions.BUILD, false); + if (this.canAccessViewCells != oldAccessible) { + for (int y = 0; y < 5; y++) { + if (this.cellView[y] != null) { + this.cellView[y].setAllowEdit(this.canAccessViewCells); + } + } + } - final boolean oldAccessible = this.canAccessViewCells; - this.canAccessViewCells = this.hasAccess( SecurityPermissions.BUILD, false ); - if( this.canAccessViewCells != oldAccessible ) - { - for( int y = 0; y < 5; y++ ) - { - if( this.cellView[y] != null ) - { - this.cellView[y].setAllowEdit( this.canAccessViewCells ); - } - } - } + super.detectAndSendChanges(); + } - super.detectAndSendChanges(); - } + } - } + protected void updatePowerStatus() { + try { + if (this.networkNode != null) { + this.setPowered(this.networkNode.isActive()); + } else if (this.getPowerSource() instanceof IEnergyGrid) { + this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered()); + } else { + this.setPowered( + this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8); + } + } catch (final Throwable t) { + // :P + } + } - protected void updatePowerStatus() - { - try - { - if( this.networkNode != null ) - { - this.setPowered( this.networkNode.isActive() ); - } - else if( this.getPowerSource() instanceof IEnergyGrid ) - { - this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() ); - } - else - { - this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 ); - } - } - catch( final Throwable t ) - { - // :P - } - } + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("canAccessViewCells")) { + for (int y = 0; y < 5; y++) { + if (this.cellView[y] != null) { + this.cellView[y].setAllowEdit(this.canAccessViewCells); + } + } + } - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "canAccessViewCells" ) ) - { - for( int y = 0; y < 5; y++ ) - { - if( this.cellView[y] != null ) - { - this.cellView[y].setAllowEdit( this.canAccessViewCells ); - } - } - } + super.onUpdate(field, oldValue, newValue); + } - super.onUpdate( field, oldValue, newValue ); - } + @Override + public void addListener(final IContainerListener c) { + super.addListener(c); - @Override - public void addListener( final IContainerListener c ) - { - super.addListener( c ); + this.queueInventory(c); + } - this.queueInventory( c ); - } + private void queueInventory(final IContainerListener c) { + if (Platform.isServer() && c instanceof PlayerEntity && this.monitor != null) { + try { + PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); + final IItemList monitorCache = this.monitor.getStorageList(); - private void queueInventory( final IContainerListener c ) - { - if( Platform.isServer() && c instanceof PlayerEntity && this.monitor != null ) - { - try - { - PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); - final IItemList monitorCache = this.monitor.getStorageList(); + for (final IAEItemStack send : monitorCache) { + try { + piu.appendItem(send); + } catch (final BufferOverflowException boe) { + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); - for( final IAEItemStack send : monitorCache ) - { - try - { - piu.appendItem( send ); - } - catch( final BufferOverflowException boe ) - { - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); + piu = new PacketMEInventoryUpdate(); + piu.appendItem(send); + } + } - piu = new PacketMEInventoryUpdate(); - piu.appendItem( send ); - } - } + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + } catch (final IOException e) { + AELog.debug(e); + } + } + } - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - } - catch( final IOException e ) - { - AELog.debug( e ); - } - } - } + @Override + public void removeListener(final IContainerListener c) { + super.removeListener(c); - @Override - public void removeListener( final IContainerListener c ) - { - super.removeListener( c ); + if (this.listeners.isEmpty() && this.monitor != null) { + this.monitor.removeListener(this); + } + } - if( this.listeners.isEmpty() && this.monitor != null ) - { - this.monitor.removeListener( this ); - } - } + @Override + public void onContainerClosed(final PlayerEntity player) { + super.onContainerClosed(player); + if (this.monitor != null) { + this.monitor.removeListener(this); + } + } - @Override - public void onContainerClosed( final PlayerEntity player ) - { - super.onContainerClosed( player ); - if( this.monitor != null ) - { - this.monitor.removeListener( this ); - } - } + @Override + public boolean isValid(final Object verificationToken) { + return true; + } - @Override - public boolean isValid( final Object verificationToken ) - { - return true; - } + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource source) { + for (final IAEItemStack is : change) { + this.items.add(is); + } + } - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource source ) - { - for( final IAEItemStack is : change ) - { - this.items.add( is ); - } - } + @Override + public void onListUpdate() { + for (final IContainerListener c : this.listeners) { + this.queueInventory(c); + } + } - @Override - public void onListUpdate() - { - for( final IContainerListener c : this.listeners ) - { - this.queueInventory( c ); - } - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + if (this.getGui() != null) { + this.getGui().updateSetting(manager, settingName, newValue); + } + } - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - if( this.getGui() != null ) - { - this.getGui().updateSetting( manager, settingName, newValue ); - } - } + @Override + public IConfigManager getConfigManager() { + if (Platform.isServer()) { + return this.serverCM; + } + return this.clientCM; + } - @Override - public IConfigManager getConfigManager() - { - if( Platform.isServer() ) - { - return this.serverCM; - } - return this.clientCM; - } + public ItemStack[] getViewCells() { + final ItemStack[] list = new ItemStack[this.cellView.length]; - public ItemStack[] getViewCells() - { - final ItemStack[] list = new ItemStack[this.cellView.length]; + for (int x = 0; x < this.cellView.length; x++) { + list[x] = this.cellView[x].getStack(); + } - for( int x = 0; x < this.cellView.length; x++ ) - { - list[x] = this.cellView[x].getStack(); - } + return list; + } - return list; - } + public SlotRestrictedInput getCellViewSlot(final int index) { + return this.cellView[index]; + } - public SlotRestrictedInput getCellViewSlot( final int index ) - { - return this.cellView[index]; - } + public boolean isPowered() { + return this.hasPower; + } - public boolean isPowered() - { - return this.hasPower; - } + private void setPowered(final boolean isPowered) { + this.hasPower = isPowered; + } - private void setPowered( final boolean isPowered ) - { - this.hasPower = isPowered; - } + private IConfigManagerHost getGui() { + return this.gui; + } - private IConfigManagerHost getGui() - { - return this.gui; - } - - public void setGui( @Nonnull final IConfigManagerHost gui ) - { - this.gui = gui; - } + public void setGui(@Nonnull final IConfigManagerHost gui) { + this.gui = gui; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java index f0e08d2ab..719284a6c 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java +++ b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java @@ -18,103 +18,88 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.implementations.guiobjects.IPortableCell; +import appeng.container.ContainerLocator; import appeng.container.interfaces.IInventorySlotAware; -import net.minecraft.network.PacketBuffer; +public class ContainerMEPortableCell extends ContainerMEMonitorable { -public class ContainerMEPortableCell extends ContainerMEMonitorable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerMEPortableCell::new, IPortableCell.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerMEPortableCell::new, IPortableCell.class); + public static ContainerMEPortableCell fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerMEPortableCell fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private double powerMultiplier = 0.5; - private double powerMultiplier = 0.5; + private final IPortableCell civ; + private int ticks = 0; + private final int slot; - private final IPortableCell civ; - private int ticks = 0; - private final int slot; + public ContainerMEPortableCell(int id, final PlayerInventory ip, final IPortableCell monitorable) { + this(TYPE, id, ip, monitorable); + } - public ContainerMEPortableCell(int id, final PlayerInventory ip, final IPortableCell monitorable ) - { - this(TYPE, id, ip, monitorable); - } + protected ContainerMEPortableCell(ContainerType type, int id, + final PlayerInventory ip, final IPortableCell monitorable) { + super(type, id, ip, monitorable, false); + if (monitorable instanceof IInventorySlotAware) { + final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot(); + this.lockPlayerInventorySlot(slotIndex); + this.slot = slotIndex; + } else { + this.slot = -1; + this.lockPlayerInventorySlot(ip.currentItem); + } + this.civ = monitorable; + this.bindPlayerInventory(ip, 0, 0); + } - protected ContainerMEPortableCell(ContainerType type, int id, final PlayerInventory ip, final IPortableCell monitorable ) - { - super( type, id, ip, monitorable, false ); - if( monitorable instanceof IInventorySlotAware ) - { - final int slotIndex = ( (IInventorySlotAware) monitorable ).getInventorySlot(); - this.lockPlayerInventorySlot( slotIndex ); - this.slot = slotIndex; - } - else - { - this.slot = -1; - this.lockPlayerInventorySlot( ip.currentItem ); - } - this.civ = monitorable; - this.bindPlayerInventory( ip, 0, 0 ); - } + @Override + public void detectAndSendChanges() { + final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() + : this.getPlayerInv().getStackInSlot(this.slot); - @Override - public void detectAndSendChanges() - { - final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot( this.slot ); + if (this.civ == null || currentItem.isEmpty()) { + this.setValidContainer(false); + } else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) { + if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) { + this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack()); + } else { + this.setValidContainer(false); + } + } - if( this.civ == null || currentItem.isEmpty() ) - { - this.setValidContainer( false ); - } - else if( this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack() ) - { - if( ItemStack.areItemsEqual( this.civ.getItemStack(), currentItem ) ) - { - this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() ); - } - else - { - this.setValidContainer( false ); - } - } + // drain 1 ae t + this.ticks++; + if (this.ticks > 10) { + this.civ.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, + PowerMultiplier.CONFIG); + this.ticks = 0; + } + super.detectAndSendChanges(); + } - // drain 1 ae t - this.ticks++; - if( this.ticks > 10 ) - { - this.civ.extractAEPower( this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG ); - this.ticks = 0; - } - super.detectAndSendChanges(); - } + private double getPowerMultiplier() { + return this.powerMultiplier; + } - private double getPowerMultiplier() - { - return this.powerMultiplier; - } - - void setPowerMultiplier( final double powerMultiplier ) - { - this.powerMultiplier = powerMultiplier; - } + void setPowerMultiplier(final double powerMultiplier) { + this.powerMultiplier = powerMultiplier; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java index 1531c3efd..8108ae8e1 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java @@ -18,15 +18,14 @@ package appeng.container.implementations; - import java.io.IOException; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; import appeng.api.AEApi; import appeng.api.implementations.guiobjects.INetworkTool; @@ -40,168 +39,141 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.api.util.AEPartLocation; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.util.Platform; import appeng.util.item.AEItemStack; -import net.minecraft.network.PacketBuffer; +public class ContainerNetworkStatus extends AEBaseContainer { -public class ContainerNetworkStatus extends AEBaseContainer -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerNetworkStatus::new, INetworkTool.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerNetworkStatus::new, INetworkTool.class); + public static ContainerNetworkStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerNetworkStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @GuiSync(0) + public long avgAddition; + @GuiSync(1) + public long powerUsage; + @GuiSync(2) + public long currentPower; + @GuiSync(3) + public long maxPower; + private IGrid network; + private int delay = 40; - @GuiSync( 0 ) - public long avgAddition; - @GuiSync( 1 ) - public long powerUsage; - @GuiSync( 2 ) - public long currentPower; - @GuiSync( 3 ) - public long maxPower; - private IGrid network; - private int delay = 40; + public ContainerNetworkStatus(int id, PlayerInventory ip, final INetworkTool te) { + super(TYPE, id, ip, null, null); + final IGridHost host = te.getGridHost(); - public ContainerNetworkStatus(int id, PlayerInventory ip, final INetworkTool te) { - super(TYPE, id, ip, null, null); - final IGridHost host = te.getGridHost(); + if (host != null) { + this.findNode(host, AEPartLocation.INTERNAL); + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + this.findNode(host, d); + } + } - if( host != null ) - { - this.findNode( host, AEPartLocation.INTERNAL ); - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - this.findNode( host, d ); - } - } + if (this.network == null && Platform.isServer()) { + this.setValidContainer(false); + } + } - if( this.network == null && Platform.isServer() ) - { - this.setValidContainer( false ); - } - } + private void findNode(final IGridHost host, final AEPartLocation d) { + if (this.network == null) { + final IGridNode node = host.getGridNode(d); + if (node != null) { + this.network = node.getGrid(); + } + } + } - private void findNode( final IGridHost host, final AEPartLocation d ) - { - if( this.network == null ) - { - final IGridNode node = host.getGridNode( d ); - if( node != null ) - { - this.network = node.getGrid(); - } - } - } + @Override + public void detectAndSendChanges() { + this.delay++; + if (Platform.isServer() && this.delay > 15 && this.network != null) { + this.delay = 0; - @Override - public void detectAndSendChanges() - { - this.delay++; - if( Platform.isServer() && this.delay > 15 && this.network != null ) - { - this.delay = 0; + final IEnergyGrid eg = this.network.getCache(IEnergyGrid.class); + if (eg != null) { + this.setAverageAddition((long) (100.0 * eg.getAvgPowerInjection())); + this.setPowerUsage((long) (100.0 * eg.getAvgPowerUsage())); + this.setCurrentPower((long) (100.0 * eg.getStoredPower())); + this.setMaxPower((long) (100.0 * eg.getMaxStoredPower())); + } - final IEnergyGrid eg = this.network.getCache( IEnergyGrid.class ); - if( eg != null ) - { - this.setAverageAddition( (long) ( 100.0 * eg.getAvgPowerInjection() ) ); - this.setPowerUsage( (long) ( 100.0 * eg.getAvgPowerUsage() ) ); - this.setCurrentPower( (long) ( 100.0 * eg.getStoredPower() ) ); - this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) ); - } + try { + final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); - try - { - final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); + for (final Class machineClass : this.network.getMachinesClasses()) { + final IItemList list = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + for (final IGridNode machine : this.network.getMachines(machineClass)) { + final IGridBlock blk = machine.getGridBlock(); + final ItemStack is = blk.getMachineRepresentation(); + if (!is.isEmpty()) { + final IAEItemStack ais = AEItemStack.fromItemStack(is); + ais.setStackSize(1); + ais.setCountRequestable((long) (blk.getIdlePowerUsage() * 100.0)); + list.add(ais); + } + } - for( final Class machineClass : this.network.getMachinesClasses() ) - { - final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - for( final IGridNode machine : this.network.getMachines( machineClass ) ) - { - final IGridBlock blk = machine.getGridBlock(); - final ItemStack is = blk.getMachineRepresentation(); - if( !is.isEmpty() ) - { - final IAEItemStack ais = AEItemStack.fromItemStack( is ); - ais.setStackSize( 1 ); - ais.setCountRequestable( (long) ( blk.getIdlePowerUsage() * 100.0 ) ); - list.add( ais ); - } - } + for (final IAEItemStack ais : list) { + piu.appendItem(ais); + } + } - for( final IAEItemStack ais : list ) - { - piu.appendItem( ais ); - } - } + for (final Object c : this.listeners) { + if (c instanceof PlayerEntity) { + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + } + } + } catch (final IOException e) { + // :P + } + } + super.detectAndSendChanges(); + } - for( final Object c : this.listeners ) - { - if( c instanceof PlayerEntity ) - { - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - } - } - } - catch( final IOException e ) - { - // :P - } - } - super.detectAndSendChanges(); - } + public long getCurrentPower() { + return this.currentPower; + } - public long getCurrentPower() - { - return this.currentPower; - } + private void setCurrentPower(final long currentPower) { + this.currentPower = currentPower; + } - private void setCurrentPower( final long currentPower ) - { - this.currentPower = currentPower; - } + public long getMaxPower() { + return this.maxPower; + } - public long getMaxPower() - { - return this.maxPower; - } + private void setMaxPower(final long maxPower) { + this.maxPower = maxPower; + } - private void setMaxPower( final long maxPower ) - { - this.maxPower = maxPower; - } + public long getAverageAddition() { + return this.avgAddition; + } - public long getAverageAddition() - { - return this.avgAddition; - } + private void setAverageAddition(final long avgAddition) { + this.avgAddition = avgAddition; + } - private void setAverageAddition( final long avgAddition ) - { - this.avgAddition = avgAddition; - } + public long getPowerUsage() { + return this.powerUsage; + } - public long getPowerUsage() - { - return this.powerUsage; - } - - private void setPowerUsage( final long powerUsage ) - { - this.powerUsage = powerUsage; - } + private void setPowerUsage(final long powerUsage) { + this.powerUsage = powerUsage; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java index dfdf921d7..86e7d3241 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java @@ -18,12 +18,6 @@ package appeng.container.implementations; - -import appeng.api.implementations.guiobjects.INetworkTool; -import appeng.container.AEBaseContainer; -import appeng.container.ContainerLocator; -import appeng.container.guisync.GuiSync; -import appeng.container.slot.SlotRestrictedInput; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -31,94 +25,84 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; +import appeng.api.implementations.guiobjects.INetworkTool; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.guisync.GuiSync; +import appeng.container.slot.SlotRestrictedInput; -public class ContainerNetworkTool extends AEBaseContainer -{ +public class ContainerNetworkTool extends AEBaseContainer { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerNetworkTool::new, INetworkTool.class); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerNetworkTool::new, INetworkTool.class); - public static ContainerNetworkTool fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerNetworkTool fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - private final INetworkTool toolInv; + private final INetworkTool toolInv; - @GuiSync( 1 ) - public boolean facadeMode; + @GuiSync(1) + public boolean facadeMode; - public ContainerNetworkTool(int id, final PlayerInventory ip, final INetworkTool te ) - { - super( TYPE, id, ip, null, null ); - this.toolInv = te; + public ContainerNetworkTool(int id, final PlayerInventory ip, final INetworkTool te) { + super(TYPE, id, ip, null, null); + this.toolInv = te; - this.lockPlayerInventorySlot( ip.currentItem ); + this.lockPlayerInventorySlot(ip.currentItem); - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 3; x++ ) - { - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te - .getInventory(), y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.getPlayerInventory() ) ) ); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, te.getInventory(), + y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.getPlayerInventory()))); + } + } - this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); + } - public void toggleFacadeMode() - { + public void toggleFacadeMode() { final CompoundNBT data = this.toolInv.getItemStack().getOrCreateTag(); - data.putBoolean("hideFacades", !data.getBoolean( "hideFacades" )); - this.detectAndSendChanges(); - } + data.putBoolean("hideFacades", !data.getBoolean("hideFacades")); + this.detectAndSendChanges(); + } - @Override - public void detectAndSendChanges() - { - final ItemStack currentItem = this.getPlayerInv().getCurrentItem(); + @Override + public void detectAndSendChanges() { + final ItemStack currentItem = this.getPlayerInv().getCurrentItem(); - if( currentItem != this.toolInv.getItemStack() ) - { - if( !currentItem.isEmpty() ) - { - if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) ) - { - this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() ); - } - else - { - this.setValidContainer( false ); - } - } - else - { - this.setValidContainer( false ); - } - } + if (currentItem != this.toolInv.getItemStack()) { + if (!currentItem.isEmpty()) { + if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) { + this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, + this.toolInv.getItemStack()); + } else { + this.setValidContainer(false); + } + } else { + this.setValidContainer(false); + } + } - if( this.isValidContainer() ) - { + if (this.isValidContainer()) { final CompoundNBT data = currentItem.getOrCreateTag(); - this.setFacadeMode( data.getBoolean( "hideFacades" ) ); - } + this.setFacadeMode(data.getBoolean("hideFacades")); + } - super.detectAndSendChanges(); - } + super.detectAndSendChanges(); + } - public boolean isFacadeMode() - { - return this.facadeMode; - } + public boolean isFacadeMode() { + return this.facadeMode; + } - private void setFacadeMode( final boolean facadeMode ) - { - this.facadeMode = facadeMode; - } + private void setFacadeMode(final boolean facadeMode) { + this.facadeMode = facadeMode; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index da5d06c67..c564b3d69 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -18,6 +18,29 @@ package appeng.container.implementations; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.CraftResultInventory; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.CraftingResultSlot; +import net.minecraft.inventory.container.IContainerListener; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.world.World; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.wrapper.PlayerInvWrapper; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -45,569 +68,456 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.item.AEItemStack; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.CraftResultInventory; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.CraftingResultSlot; -import net.minecraft.inventory.container.IContainerListener; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.world.World; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.wrapper.PlayerInvWrapper; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - - -public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket -{ - - public static ContainerType TYPE; - - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerPatternTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT); - - public static ContainerPatternTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } - - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - private final PartPatternTerminal patternTerminal; - private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 ); - private final IItemHandler crafting; - private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9]; - private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3]; - private final SlotPatternTerm craftSlot; - private final SlotRestrictedInput patternSlotIN; - private final SlotRestrictedInput patternSlotOUT; - - private IRecipe currentRecipe; - @GuiSync( 97 ) - public boolean craftingMode = true; - @GuiSync( 96 ) - public boolean substitute = false; - - public ContainerPatternTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable ) - { - super( TYPE, id, ip, monitorable, false ); - this.patternTerminal = (PartPatternTerminal) monitorable; - - final IItemHandler patternInv = this.getPatternTerminal().getInventoryByName( "pattern" ); - final IItemHandler output = this.getPatternTerminal().getInventoryByName( "output" ); - - this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" ); - - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 3; x++ ) - { - this.addSlot( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) ); - } - } - - this.addSlot( this.craftSlot = new SlotPatternTerm( ip.player, this.getActionSource(), this - .getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) ); - this.craftSlot.setIIcon( -1 ); - - for( int y = 0; y < 3; y++ ) - { - this.addSlot( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) ); - this.outputSlots[y].setRenderDisabled( false ); - this.outputSlots[y].setIIcon( -1 ); - } - - this.addSlot( - this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this - .getPlayerInventory() ) ); - this.addSlot( - this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this - .getPlayerInventory() ) ); - - this.patternSlotOUT.setStackLimit( 1 ); - - this.bindPlayerInventory( ip, 0, 0 ); - this.updateOrderOfOutputSlots(); - } - - private void updateOrderOfOutputSlots() - { - if( !this.isCraftingMode() ) - { - this.craftSlot.xPos = -9000; - - for( int y = 0; y < 3; y++ ) - { - this.outputSlots[y].xPos = this.outputSlots[y].getX(); - } - } - else - { - this.craftSlot.xPos = this.craftSlot.getX(); - - for( int y = 0; y < 3; y++ ) - { - this.outputSlots[y].xPos = -9000; - } - } - } - - @Override - public void putStackInSlot( int slotID, ItemStack stack ) - { - super.putStackInSlot( slotID, stack ); - this.getAndUpdateOutput(); - } - - private ItemStack getAndUpdateOutput() - { - final World world = this.getPlayerInv().player.world; - final CraftingInventory ic = new CraftingInventory( this, 3, 3 ); - - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) ); - } - - if( this.currentRecipe == null || !this.currentRecipe.matches( ic, world ) ) - { - this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); - } - - final ItemStack is; - - if( this.currentRecipe == null ) - { - is = ItemStack.EMPTY; - } - else - { - is = this.currentRecipe.getCraftingResult( ic ); - } - - this.cOut.setStackInSlot( 0, is ); - return is; - } - - @Override - public void saveChanges() - { - - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - - } - - public void encode() - { - ItemStack output = this.patternSlotOUT.getStack(); - - final ItemStack[] in = this.getInputs(); - final ItemStack[] out = this.getOutputs(); - - // if there is no input, this would be silly. - if( in == null || out == null ) - { - return; - } - - // first check the output slots, should either be null, or a pattern - if( !output.isEmpty() && !this.isPattern( output ) ) - { - return; - } // if nothing is there we should snag a new pattern. - else if( output.isEmpty() ) - { - output = this.patternSlotIN.getStack(); - if( output.isEmpty() || !this.isPattern( output ) ) - { - return; // no blanks. - } - - // remove one, and clear the input slot. - output.setCount( output.getCount() - 1 ); - if( output.getCount() == 0 ) - { - this.patternSlotIN.putStack( ItemStack.EMPTY ); - } - - // add a new encoded pattern. - Optional maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ); - if( maybePattern.isPresent() ) - { - output = maybePattern.get(); - this.patternSlotOUT.putStack( output ); - } - } - - // encode the slot. - final CompoundNBT encodedValue = new CompoundNBT(); - - final ListNBT tagIn = new ListNBT(); - final ListNBT tagOut = new ListNBT(); - - for( final ItemStack i : in ) - { - tagIn.add( this.createItemTag( i ) ); - } - - for( final ItemStack i : out ) - { - tagOut.add( this.createItemTag( i ) ); - } - - encodedValue.put( "in", tagIn ); - encodedValue.put( "out", tagOut ); - encodedValue.putBoolean("crafting", this.isCraftingMode()); - encodedValue.putBoolean("substitute", this.isSubstitute()); - - output.setTag( encodedValue ); - } - - private ItemStack[] getInputs() - { - final ItemStack[] input = new ItemStack[9]; - boolean hasValue = false; - - for( int x = 0; x < this.craftingSlots.length; x++ ) - { - input[x] = this.craftingSlots[x].getStack(); - if( !input[x].isEmpty() ) - { - hasValue = true; - } - } - - if( hasValue ) - { - return input; - } - - return null; - } - - private ItemStack[] getOutputs() - { - if( this.isCraftingMode() ) - { - final ItemStack out = this.getAndUpdateOutput(); - - if( !out.isEmpty() && out.getCount() > 0 ) - { - return new ItemStack[] { out }; - } - } - else - { - final List list = new ArrayList<>( 3 ); - boolean hasValue = false; - - for( final OptionalSlotFake outputSlot : this.outputSlots ) - { - final ItemStack out = outputSlot.getStack(); - - if( !out.isEmpty() && out.getCount() > 0 ) - { - list.add( out ); - hasValue = true; - } - } - - if( hasValue ) - { - return list.toArray( new ItemStack[list.size()] ); - } - } - - return null; - } - - private boolean isPattern( final ItemStack output ) - { - if( output.isEmpty() ) - { - return false; - } - - final IDefinitions definitions = AEApi.instance().definitions(); - - boolean isPattern = definitions.items().encodedPattern().isSameAs( output ); - isPattern |= definitions.materials().blankPattern().isSameAs( output ); - - return isPattern; - } - - private INBT createItemTag( final ItemStack i ) - { - final CompoundNBT c = new CompoundNBT(); - - if( !i.isEmpty() ) - { - i.write(c); - } - - return c; - } - - @Override - public boolean isSlotEnabled( final int idx ) - { - if( idx == 1 ) - { - return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode(); - } - else if( idx == 2 ) - { - return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode(); - } - else - { - return false; - } - } - - public void craftOrGetItem( final PacketPatternSlot packetPatternSlot ) - { - if( packetPatternSlot.slotItem != null && this.getCellInventory() != null ) - { - final IAEItemStack out = packetPatternSlot.slotItem.copy(); - InventoryAdaptor inv = new AdaptorItemHandler( new WrapperCursorItemHandler( this.getPlayerInv().player.inventory ) ); - final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player ); - - if( packetPatternSlot.shift ) - { - inv = playerInv; - } - - if( !inv.simulateAdd( out.createItemStack() ).isEmpty() ) - { - return; - } - - final IAEItemStack extracted = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), out, this.getActionSource() ); - final PlayerEntity p = this.getPlayerInv().player; - - if( extracted != null ) - { - inv.addItems( extracted.createItemStack() ); - if( p instanceof ServerPlayerEntity ) - { - this.updateHeld( (ServerPlayerEntity) p ); - } - this.detectAndSendChanges(); - return; - } - - final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 ); - final CraftingInventory real = new CraftingInventory( new ContainerNull(), 3, 3 ); - - for( int x = 0; x < 9; x++ ) - { - ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].createItemStack() ); - } - - final IRecipe r = p.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, p.world).orElse(null); - - if( r == null ) - { - return; - } - - final IMEMonitor storage = this.getPatternTerminal() - .getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final IItemList all = storage.getStorageList(); - - final ItemStack is = r.getCraftingResult( ic ); - - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - if( !ic.getStackInSlot( x ).isEmpty() ) - { - final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.world, r, is, ic, - ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) ); - real.setInventorySlotContents( x, pulled ); - } - } - - final IRecipe rr = p.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, real, p.world).orElse(null); - - if( rr == r && Platform.itemComparisons().isSameItem( rr.getCraftingResult( real ), is ) ) - { - final CraftResultInventory craftingResult = new CraftResultInventory(); - craftingResult.setRecipeUsed( rr ); - - final CraftingResultSlot sc = new CraftingResultSlot( p, real, craftingResult, 0, 0, 0 ); - sc.onTake( p, is ); - - for( int x = 0; x < real.getSizeInventory(); x++ ) - { - final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) ); - - if( !failed.isEmpty() ) - { - p.dropItem( failed, false ); - } - } - - inv.addItems( is ); - if( p instanceof ServerPlayerEntity ) - { - this.updateHeld( (ServerPlayerEntity) p ); - } - this.detectAndSendChanges(); - } - else - { - for( int x = 0; x < real.getSizeInventory(); x++ ) - { - final ItemStack failed = real.getStackInSlot( x ); - if( !failed.isEmpty() ) - { - this.getCellInventory() - .injectItems( AEItemStack.fromItemStack( failed ), Actionable.MODULATE, - new MachineSource( this.getPatternTerminal() ) ); - } - } - } - } - } - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - if( Platform.isServer() ) - { - if( this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe() ) - { - this.setCraftingMode( this.getPatternTerminal().isCraftingRecipe() ); - this.updateOrderOfOutputSlots(); - } - - this.substitute = this.patternTerminal.isSubstitution(); - } - } - - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - super.onUpdate( field, oldValue, newValue ); - - if( field.equals( "craftingMode" ) ) - { - this.getAndUpdateOutput(); - this.updateOrderOfOutputSlots(); - } - } - - - - @Override - public void onSlotChange( final Slot s ) - { - if( s == this.patternSlotOUT && Platform.isServer() ) - { - for( final IContainerListener listener : this.listeners ) - { - for( final Slot slot : this.inventorySlots ) - { - if( slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix ) - { - listener.sendSlotContents( this, slot.slotNumber, slot.getStack() ); - } - } - if( listener instanceof ServerPlayerEntity ) - { - ( (ServerPlayerEntity) listener ).isChangingQuantityOnly = false; - } - } - this.detectAndSendChanges(); - } - - if( s == this.craftSlot && Platform.isClient() ) - { - this.getAndUpdateOutput(); - } - } - - public void clear() - { - for( final Slot s : this.craftingSlots ) - { - s.putStack( ItemStack.EMPTY ); - } - - for( final Slot s : this.outputSlots ) - { - s.putStack( ItemStack.EMPTY ); - } - - this.detectAndSendChanges(); - this.getAndUpdateOutput(); - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "player" ) ) - { - return new PlayerInvWrapper( this.getPlayerInventory() ); - } - return this.getPatternTerminal().getInventoryByName( name ); - } - - @Override - public boolean useRealItems() - { - return false; - } - - public void toggleSubstitute() - { - this.substitute = !this.substitute; - - this.detectAndSendChanges(); - this.getAndUpdateOutput(); - } - - public boolean isCraftingMode() - { - return this.craftingMode; - } - - private void setCraftingMode( final boolean craftingMode ) - { - this.craftingMode = craftingMode; - } - - public PartPatternTerminal getPatternTerminal() - { - return this.patternTerminal; - } - - private boolean isSubstitute() - { - return this.substitute; - } - - public void setSubstitute( final boolean substitute ) - { - this.substitute = substitute; - } + +public class ContainerPatternTerm extends ContainerMEMonitorable + implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { + + public static ContainerType TYPE; + + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerPatternTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT); + + public static ContainerPatternTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } + + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } + + private final PartPatternTerminal patternTerminal; + private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1); + private final IItemHandler crafting; + private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9]; + private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3]; + private final SlotPatternTerm craftSlot; + private final SlotRestrictedInput patternSlotIN; + private final SlotRestrictedInput patternSlotOUT; + + private IRecipe currentRecipe; + @GuiSync(97) + public boolean craftingMode = true; + @GuiSync(96) + public boolean substitute = false; + + public ContainerPatternTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable) { + super(TYPE, id, ip, monitorable, false); + this.patternTerminal = (PartPatternTerminal) monitorable; + + final IItemHandler patternInv = this.getPatternTerminal().getInventoryByName("pattern"); + final IItemHandler output = this.getPatternTerminal().getInventoryByName("output"); + + this.crafting = this.getPatternTerminal().getInventoryByName("crafting"); + + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + this.addSlot(this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix(this.crafting, x + y * 3, + 18 + x * 18, -76 + y * 18)); + } + } + + this.addSlot(this.craftSlot = new SlotPatternTerm(ip.player, this.getActionSource(), this.getPowerSource(), + monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this)); + this.craftSlot.setIIcon(-1); + + for (int y = 0; y < 3; y++) { + this.addSlot(this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1)); + this.outputSlots[y].setRenderDisabled(false); + this.outputSlots[y].setIIcon(-1); + } + + this.addSlot(this.patternSlotIN = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, + patternInv, 0, 147, -72 - 9, this.getPlayerInventory())); + this.addSlot(this.patternSlotOUT = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, + patternInv, 1, 147, -72 + 34, this.getPlayerInventory())); + + this.patternSlotOUT.setStackLimit(1); + + this.bindPlayerInventory(ip, 0, 0); + this.updateOrderOfOutputSlots(); + } + + private void updateOrderOfOutputSlots() { + if (!this.isCraftingMode()) { + this.craftSlot.xPos = -9000; + + for (int y = 0; y < 3; y++) { + this.outputSlots[y].xPos = this.outputSlots[y].getX(); + } + } else { + this.craftSlot.xPos = this.craftSlot.getX(); + + for (int y = 0; y < 3; y++) { + this.outputSlots[y].xPos = -9000; + } + } + } + + @Override + public void putStackInSlot(int slotID, ItemStack stack) { + super.putStackInSlot(slotID, stack); + this.getAndUpdateOutput(); + } + + private ItemStack getAndUpdateOutput() { + final World world = this.getPlayerInv().player.world; + final CraftingInventory ic = new CraftingInventory(this, 3, 3); + + for (int x = 0; x < ic.getSizeInventory(); x++) { + ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x)); + } + + if (this.currentRecipe == null || !this.currentRecipe.matches(ic, world)) { + this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); + } + + final ItemStack is; + + if (this.currentRecipe == null) { + is = ItemStack.EMPTY; + } else { + is = this.currentRecipe.getCraftingResult(ic); + } + + this.cOut.setStackInSlot(0, is); + return is; + } + + @Override + public void saveChanges() { + + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + + } + + public void encode() { + ItemStack output = this.patternSlotOUT.getStack(); + + final ItemStack[] in = this.getInputs(); + final ItemStack[] out = this.getOutputs(); + + // if there is no input, this would be silly. + if (in == null || out == null) { + return; + } + + // first check the output slots, should either be null, or a pattern + if (!output.isEmpty() && !this.isPattern(output)) { + return; + } // if nothing is there we should snag a new pattern. + else if (output.isEmpty()) { + output = this.patternSlotIN.getStack(); + if (output.isEmpty() || !this.isPattern(output)) { + return; // no blanks. + } + + // remove one, and clear the input slot. + output.setCount(output.getCount() - 1); + if (output.getCount() == 0) { + this.patternSlotIN.putStack(ItemStack.EMPTY); + } + + // add a new encoded pattern. + Optional maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1); + if (maybePattern.isPresent()) { + output = maybePattern.get(); + this.patternSlotOUT.putStack(output); + } + } + + // encode the slot. + final CompoundNBT encodedValue = new CompoundNBT(); + + final ListNBT tagIn = new ListNBT(); + final ListNBT tagOut = new ListNBT(); + + for (final ItemStack i : in) { + tagIn.add(this.createItemTag(i)); + } + + for (final ItemStack i : out) { + tagOut.add(this.createItemTag(i)); + } + + encodedValue.put("in", tagIn); + encodedValue.put("out", tagOut); + encodedValue.putBoolean("crafting", this.isCraftingMode()); + encodedValue.putBoolean("substitute", this.isSubstitute()); + + output.setTag(encodedValue); + } + + private ItemStack[] getInputs() { + final ItemStack[] input = new ItemStack[9]; + boolean hasValue = false; + + for (int x = 0; x < this.craftingSlots.length; x++) { + input[x] = this.craftingSlots[x].getStack(); + if (!input[x].isEmpty()) { + hasValue = true; + } + } + + if (hasValue) { + return input; + } + + return null; + } + + private ItemStack[] getOutputs() { + if (this.isCraftingMode()) { + final ItemStack out = this.getAndUpdateOutput(); + + if (!out.isEmpty() && out.getCount() > 0) { + return new ItemStack[] { out }; + } + } else { + final List list = new ArrayList<>(3); + boolean hasValue = false; + + for (final OptionalSlotFake outputSlot : this.outputSlots) { + final ItemStack out = outputSlot.getStack(); + + if (!out.isEmpty() && out.getCount() > 0) { + list.add(out); + hasValue = true; + } + } + + if (hasValue) { + return list.toArray(new ItemStack[list.size()]); + } + } + + return null; + } + + private boolean isPattern(final ItemStack output) { + if (output.isEmpty()) { + return false; + } + + final IDefinitions definitions = AEApi.instance().definitions(); + + boolean isPattern = definitions.items().encodedPattern().isSameAs(output); + isPattern |= definitions.materials().blankPattern().isSameAs(output); + + return isPattern; + } + + private INBT createItemTag(final ItemStack i) { + final CompoundNBT c = new CompoundNBT(); + + if (!i.isEmpty()) { + i.write(c); + } + + return c; + } + + @Override + public boolean isSlotEnabled(final int idx) { + if (idx == 1) { + return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode(); + } else if (idx == 2) { + return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode(); + } else { + return false; + } + } + + public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) { + if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) { + final IAEItemStack out = packetPatternSlot.slotItem.copy(); + InventoryAdaptor inv = new AdaptorItemHandler( + new WrapperCursorItemHandler(this.getPlayerInv().player.inventory)); + final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(this.getPlayerInv().player); + + if (packetPatternSlot.shift) { + inv = playerInv; + } + + if (!inv.simulateAdd(out.createItemStack()).isEmpty()) { + return; + } + + final IAEItemStack extracted = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), + out, this.getActionSource()); + final PlayerEntity p = this.getPlayerInv().player; + + if (extracted != null) { + inv.addItems(extracted.createItemStack()); + if (p instanceof ServerPlayerEntity) { + this.updateHeld((ServerPlayerEntity) p); + } + this.detectAndSendChanges(); + return; + } + + final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); + final CraftingInventory real = new CraftingInventory(new ContainerNull(), 3, 3); + + for (int x = 0; x < 9; x++) { + ic.setInventorySlotContents(x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY + : packetPatternSlot.pattern[x].createItemStack()); + } + + final IRecipe r = p.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, p.world) + .orElse(null); + + if (r == null) { + return; + } + + final IMEMonitor storage = this.getPatternTerminal() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final IItemList all = storage.getStorageList(); + + final ItemStack is = r.getCraftingResult(ic); + + for (int x = 0; x < ic.getSizeInventory(); x++) { + if (!ic.getStackInSlot(x).isEmpty()) { + final ItemStack pulled = Platform.extractItemsByRecipe(this.getPowerSource(), + this.getActionSource(), storage, p.world, r, is, ic, ic.getStackInSlot(x), x, all, + Actionable.MODULATE, ItemViewCell.createFilter(this.getViewCells())); + real.setInventorySlotContents(x, pulled); + } + } + + final IRecipe rr = p.world.getRecipeManager() + .getRecipe(IRecipeType.CRAFTING, real, p.world).orElse(null); + + if (rr == r && Platform.itemComparisons().isSameItem(rr.getCraftingResult(real), is)) { + final CraftResultInventory craftingResult = new CraftResultInventory(); + craftingResult.setRecipeUsed(rr); + + final CraftingResultSlot sc = new CraftingResultSlot(p, real, craftingResult, 0, 0, 0); + sc.onTake(p, is); + + for (int x = 0; x < real.getSizeInventory(); x++) { + final ItemStack failed = playerInv.addItems(real.getStackInSlot(x)); + + if (!failed.isEmpty()) { + p.dropItem(failed, false); + } + } + + inv.addItems(is); + if (p instanceof ServerPlayerEntity) { + this.updateHeld((ServerPlayerEntity) p); + } + this.detectAndSendChanges(); + } else { + for (int x = 0; x < real.getSizeInventory(); x++) { + final ItemStack failed = real.getStackInSlot(x); + if (!failed.isEmpty()) { + this.getCellInventory().injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE, + new MachineSource(this.getPatternTerminal())); + } + } + } + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (Platform.isServer()) { + if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) { + this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe()); + this.updateOrderOfOutputSlots(); + } + + this.substitute = this.patternTerminal.isSubstitution(); + } + } + + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + super.onUpdate(field, oldValue, newValue); + + if (field.equals("craftingMode")) { + this.getAndUpdateOutput(); + this.updateOrderOfOutputSlots(); + } + } + + @Override + public void onSlotChange(final Slot s) { + if (s == this.patternSlotOUT && Platform.isServer()) { + for (final IContainerListener listener : this.listeners) { + for (final Slot slot : this.inventorySlots) { + if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) { + listener.sendSlotContents(this, slot.slotNumber, slot.getStack()); + } + } + if (listener instanceof ServerPlayerEntity) { + ((ServerPlayerEntity) listener).isChangingQuantityOnly = false; + } + } + this.detectAndSendChanges(); + } + + if (s == this.craftSlot && Platform.isClient()) { + this.getAndUpdateOutput(); + } + } + + public void clear() { + for (final Slot s : this.craftingSlots) { + s.putStack(ItemStack.EMPTY); + } + + for (final Slot s : this.outputSlots) { + s.putStack(ItemStack.EMPTY); + } + + this.detectAndSendChanges(); + this.getAndUpdateOutput(); + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("player")) { + return new PlayerInvWrapper(this.getPlayerInventory()); + } + return this.getPatternTerminal().getInventoryByName(name); + } + + @Override + public boolean useRealItems() { + return false; + } + + public void toggleSubstitute() { + this.substitute = !this.substitute; + + this.detectAndSendChanges(); + this.getAndUpdateOutput(); + } + + public boolean isCraftingMode() { + return this.craftingMode; + } + + private void setCraftingMode(final boolean craftingMode) { + this.craftingMode = craftingMode; + } + + public PartPatternTerminal getPatternTerminal() { + return this.patternTerminal; + } + + private boolean isSubstitute() { + return this.substitute; + } + + public void setSubstitute(final boolean substitute) { + this.substitute = substitute; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerPriority.java b/src/main/java/appeng/container/implementations/ContainerPriority.java index 9a84cb8d6..4eadc1878 100644 --- a/src/main/java/appeng/container/implementations/ContainerPriority.java +++ b/src/main/java/appeng/container/implementations/ContainerPriority.java @@ -18,8 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -32,81 +30,72 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.config.SecurityPermissions; import appeng.api.parts.IPart; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.helpers.IPriorityHost; import appeng.util.Platform; +public class ContainerPriority extends AEBaseContainer { -public class ContainerPriority extends AEBaseContainer -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerPriority::new, IPriorityHost.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerPriority::new, IPriorityHost.class, SecurityPermissions.BUILD); + public static ContainerPriority fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerPriority fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final IPriorityHost priHost; - private final IPriorityHost priHost; + @OnlyIn(Dist.CLIENT) + private TextFieldWidget textField; + @GuiSync(2) + public long PriorityValue = -1; - @OnlyIn( Dist.CLIENT ) - private TextFieldWidget textField; - @GuiSync( 2 ) - public long PriorityValue = -1; + public ContainerPriority(int id, final PlayerInventory ip, final IPriorityHost te) { + super(TYPE, id, ip, (TileEntity) (te instanceof TileEntity ? te : null), + (IPart) (te instanceof IPart ? te : null)); + this.priHost = te; + } - public ContainerPriority(int id, final PlayerInventory ip, final IPriorityHost te ) - { - super( TYPE, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) ); - this.priHost = te; - } + @OnlyIn(Dist.CLIENT) + public void setTextField(final TextFieldWidget level) { + this.textField = level; + this.textField.setText(String.valueOf(this.PriorityValue)); + } - @OnlyIn( Dist.CLIENT ) - public void setTextField( final TextFieldWidget level ) - { - this.textField = level; - this.textField.setText( String.valueOf( this.PriorityValue ) ); - } + public void setPriority(final int newValue, final PlayerEntity player) { + this.priHost.setPriority(newValue); + this.PriorityValue = newValue; + } - public void setPriority( final int newValue, final PlayerEntity player ) - { - this.priHost.setPriority( newValue ); - this.PriorityValue = newValue; - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.PriorityValue = this.priHost.getPriority(); + } + } - if( Platform.isServer() ) - { - this.PriorityValue = this.priHost.getPriority(); - } - } + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("PriorityValue")) { + if (this.textField != null) { + this.textField.setText(String.valueOf(this.PriorityValue)); + } + } - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "PriorityValue" ) ) - { - if( this.textField != null ) - { - this.textField.setText( String.valueOf( this.PriorityValue ) ); - } - } + super.onUpdate(field, oldValue, newValue); + } - super.onUpdate( field, oldValue, newValue ); - } - - public IPriorityHost getPriorityHost() - { - return this.priHost; - } + public IPriorityHost getPriorityHost() { + return this.priHost; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerQNB.java b/src/main/java/appeng/container/implementations/ContainerQNB.java index 9c5b95a92..2db833c8d 100644 --- a/src/main/java/appeng/container/implementations/ContainerQNB.java +++ b/src/main/java/appeng/container/implementations/ContainerQNB.java @@ -18,44 +18,40 @@ package appeng.container.implementations; - -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotRestrictedInput; -import appeng.tile.qnb.TileQuantumBridge; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.api.config.SecurityPermissions; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotRestrictedInput; +import appeng.tile.qnb.TileQuantumBridge; -public class ContainerQNB extends AEBaseContainer -{ +public class ContainerQNB extends AEBaseContainer { -public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerQNB::new, TileQuantumBridge.class, SecurityPermissions.BUILD); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerQNB::new, TileQuantumBridge.class, SecurityPermissions.BUILD); - public static ContainerQNB fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerQNB fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public ContainerQNB(int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge ) - { - super( TYPE, id, ip, quantumBridge, null ); + public ContainerQNB(int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge) { + super(TYPE, id, ip, quantumBridge, null); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge - .getInternalInventory(), 0, 80, 37, this.getPlayerInventory() ) ).setStackLimit( 1 ) ); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, + quantumBridge.getInternalInventory(), 0, 80, 37, this.getPlayerInventory())).setStackLimit(1)); - this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); + } } diff --git a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java index 192070fe2..7ea94f748 100644 --- a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java +++ b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java @@ -18,10 +18,8 @@ package appeng.container.implementations; - import javax.annotation.Nonnull; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -34,159 +32,135 @@ import net.minecraftforge.items.IItemHandler; import appeng.api.AEApi; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; import appeng.items.contents.QuartzKnifeObj; import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.Platform; +public class ContainerQuartzKnife extends AEBaseContainer { -public class ContainerQuartzKnife extends AEBaseContainer -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerQuartzKnife::new, QuartzKnifeObj.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerQuartzKnife::new, QuartzKnifeObj.class); + public static ContainerQuartzKnife fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerQuartzKnife fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final QuartzKnifeObj toolInv; - private final QuartzKnifeObj toolInv; + private final IItemHandler inSlot = new AppEngInternalInventory(null, 1, 1); + private String myName = ""; - private final IItemHandler inSlot = new AppEngInternalInventory( null, 1, 1 ); - private String myName = ""; + public ContainerQuartzKnife(int id, final PlayerInventory ip, final QuartzKnifeObj te) { + super(TYPE, id, ip, null, null); + this.toolInv = te; - public ContainerQuartzKnife(int id, final PlayerInventory ip, final QuartzKnifeObj te ) - { - super( TYPE, id, ip, null, null ); - this.toolInv = te; + this.addSlot( + new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip)); + this.addSlot(new QuartzKniveSlot(this.inSlot, 0, 134, 44, -1)); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip ) ); - this.addSlot( new QuartzKniveSlot( this.inSlot, 0, 134, 44, -1 ) ); + this.lockPlayerInventorySlot(ip.currentItem); - this.lockPlayerInventorySlot( ip.currentItem ); + this.bindPlayerInventory(ip, 0, 184 - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, 184 - /* height of player inventory */82 ); - } + public void setName(final String value) { + this.myName = value; + } - public void setName( final String value ) - { - this.myName = value; - } + @Override + public void detectAndSendChanges() { + final ItemStack currentItem = this.getPlayerInv().getCurrentItem(); - @Override - public void detectAndSendChanges() - { - final ItemStack currentItem = this.getPlayerInv().getCurrentItem(); + if (currentItem != this.toolInv.getItemStack()) { + if (!currentItem.isEmpty()) { + if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) { + this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, + this.toolInv.getItemStack()); + } else { + this.setValidContainer(false); + } + } else { + this.setValidContainer(false); + } + } - if( currentItem != this.toolInv.getItemStack() ) - { - if( !currentItem.isEmpty() ) - { - if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) ) - { - this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() ); - } - else - { - this.setValidContainer( false ); - } - } - else - { - this.setValidContainer( false ); - } - } + super.detectAndSendChanges(); + } - super.detectAndSendChanges(); - } + @Override + public void onContainerClosed(final PlayerEntity par1PlayerEntity) { + if (this.inSlot.getStackInSlot(0) != null) { + par1PlayerEntity.dropItem(this.inSlot.getStackInSlot(0), false); + } + } - @Override - public void onContainerClosed( final PlayerEntity par1PlayerEntity ) - { - if( this.inSlot.getStackInSlot( 0 ) != null ) - { - par1PlayerEntity.dropItem( this.inSlot.getStackInSlot( 0 ), false ); - } - } + private class QuartzKniveSlot extends SlotOutput { + QuartzKniveSlot(IItemHandler a, int b, int c, int d, int i) { + super(a, b, c, d, i); + } - private class QuartzKniveSlot extends SlotOutput - { - QuartzKniveSlot( IItemHandler a, int b, int c, int d, int i ) - { - super( a, b, c, d, i ); - } + @Override + public ItemStack getStack() { + final IItemHandler baseInv = this.getItemHandler(); + final ItemStack input = baseInv.getStackInSlot(0); + if (input == ItemStack.EMPTY) { + return ItemStack.EMPTY; + } - @Override - public ItemStack getStack() - { - final IItemHandler baseInv = this.getItemHandler(); - final ItemStack input = baseInv.getStackInSlot( 0 ); - if( input == ItemStack.EMPTY ) - { - return ItemStack.EMPTY; - } - - if( SlotRestrictedInput.isMetalIngot( input ) ) - { - if( ContainerQuartzKnife.this.myName.length() > 0 ) - { - return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map(namePressStack -> - { + if (SlotRestrictedInput.isMetalIngot(input)) { + if (ContainerQuartzKnife.this.myName.length() > 0) { + return AEApi.instance().definitions().materials().namePress().maybeStack(1).map(namePressStack -> { final CompoundNBT compound = namePressStack.getOrCreateTag(); - compound.putString("InscribeName", ContainerQuartzKnife.this.myName); + compound.putString("InscribeName", ContainerQuartzKnife.this.myName); - return namePressStack; - } ).orElse( ItemStack.EMPTY ); - } - } - return ItemStack.EMPTY; - } + return namePressStack; + }).orElse(ItemStack.EMPTY); + } + } + return ItemStack.EMPTY; + } - @Override - @Nonnull - public ItemStack decrStackSize( int amount ) - { - ItemStack ret = this.getStack(); - if( !ret.isEmpty() ) - { - this.makePlate(); - } - return ret; - } + @Override + @Nonnull + public ItemStack decrStackSize(int amount) { + ItemStack ret = this.getStack(); + if (!ret.isEmpty()) { + this.makePlate(); + } + return ret; + } - @Override - public void putStack( final ItemStack stack ) - { - if( stack.isEmpty() ) - { - this.makePlate(); - } - } + @Override + public void putStack(final ItemStack stack) { + if (stack.isEmpty()) { + this.makePlate(); + } + } - private void makePlate() - { - if( Platform.isServer() ) - { - if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() ) - { - final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack(); - final ItemStack before = item.copy(); - item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player, p -> { - ContainerQuartzKnife.this.getPlayerInv() - .setInventorySlotContents( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY ); - MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, before, null ) ); - } ); + private void makePlate() { + if (Platform.isServer()) { + if (!this.getItemHandler().extractItem(0, 1, false).isEmpty()) { + final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack(); + final ItemStack before = item.copy(); + item.damageItem(1, ContainerQuartzKnife.this.getPlayerInv().player, p -> { + ContainerQuartzKnife.this.getPlayerInv().setInventorySlotContents( + ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY); + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent( + ContainerQuartzKnife.this.getPlayerInv().player, before, null)); + }); - ContainerQuartzKnife.this.detectAndSendChanges(); - } - } - } - } + ContainerQuartzKnife.this.detectAndSendChanges(); + } + } + } + } } diff --git a/src/main/java/appeng/container/implementations/ContainerSecurityStation.java b/src/main/java/appeng/container/implementations/ContainerSecurityStation.java index aedf1d9ec..4cbe49181 100644 --- a/src/main/java/appeng/container/implementations/ContainerSecurityStation.java +++ b/src/main/java/appeng/container/implementations/ContainerSecurityStation.java @@ -18,8 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -34,6 +32,7 @@ import appeng.api.features.INetworkEncodable; import appeng.api.features.IWirelessTermHandler; import appeng.api.implementations.items.IBiometricCard; import appeng.api.storage.ITerminalHost; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; @@ -42,167 +41,142 @@ import appeng.tile.misc.TileSecurityStation; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory { -public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerSecurityStation::new, ITerminalHost.class, SecurityPermissions.SECURITY); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerSecurityStation::new, ITerminalHost.class, SecurityPermissions.SECURITY); + private final SlotRestrictedInput configSlot; - private final SlotRestrictedInput configSlot; + private final AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory(this, 2); - private final AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory( this, 2 ); + private final SlotRestrictedInput wirelessIn; + private final SlotOutput wirelessOut; - private final SlotRestrictedInput wirelessIn; - private final SlotOutput wirelessOut; + private final TileSecurityStation securityBox; + @GuiSync(0) + public int permissionMode = 0; - private final TileSecurityStation securityBox; - @GuiSync( 0 ) - public int permissionMode = 0; + public ContainerSecurityStation(int id, final PlayerInventory ip, final ITerminalHost monitorable) { + super(TYPE, id, ip, monitorable, false); - public ContainerSecurityStation(int id, final PlayerInventory ip, final ITerminalHost monitorable ) - { - super( TYPE, id, ip, monitorable, false ); + this.securityBox = (TileSecurityStation) monitorable; - this.securityBox = (TileSecurityStation) monitorable; + this.addSlot(this.configSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, + this.securityBox.getConfigSlot(), 0, 37, -33, ip)); - this.addSlot( this.configSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, this.securityBox - .getConfigSlot(), 0, 37, -33, ip ) ); + this.addSlot(this.wirelessIn = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, + this.wirelessEncoder, 0, 212, 10, ip)); + this.addSlot(this.wirelessOut = new SlotOutput(this.wirelessEncoder, 1, 212, 68, -1)); - this.addSlot( - this.wirelessIn = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, this.wirelessEncoder, 0, 212, 10, ip ) ); - this.addSlot( this.wirelessOut = new SlotOutput( this.wirelessEncoder, 1, 212, 68, -1 ) ); + this.bindPlayerInventory(ip, 0, 0); + } - this.bindPlayerInventory( ip, 0, 0 ); - } + public static ContainerSecurityStation fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerSecurityStation fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public void toggleSetting(final String value, final PlayerEntity player) { + try { + final SecurityPermissions permission = SecurityPermissions.valueOf(value); - public void toggleSetting( final String value, final PlayerEntity player ) - { - try - { - final SecurityPermissions permission = SecurityPermissions.valueOf( value ); + final ItemStack a = this.configSlot.getStack(); + if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) { + final IBiometricCard bc = (IBiometricCard) a.getItem(); + if (bc.hasPermission(a, permission)) { + bc.removePermission(a, permission); + } else { + bc.addPermission(a, permission); + } + } + } catch (final EnumConstantNotPresentException ex) { + // :( + } + } - final ItemStack a = this.configSlot.getStack(); - if( !a.isEmpty() && a.getItem() instanceof IBiometricCard ) - { - final IBiometricCard bc = (IBiometricCard) a.getItem(); - if( bc.hasPermission( a, permission ) ) - { - bc.removePermission( a, permission ); - } - else - { - bc.addPermission( a, permission ); - } - } - } - catch( final EnumConstantNotPresentException ex ) - { - // :( - } - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.SECURITY, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.SECURITY, false ); + this.setPermissionMode(0); - this.setPermissionMode( 0 ); + final ItemStack a = this.configSlot.getStack(); + if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) { + final IBiometricCard bc = (IBiometricCard) a.getItem(); - final ItemStack a = this.configSlot.getStack(); - if( !a.isEmpty() && a.getItem() instanceof IBiometricCard ) - { - final IBiometricCard bc = (IBiometricCard) a.getItem(); + for (final SecurityPermissions sp : bc.getPermissions(a)) { + this.setPermissionMode(this.getPermissionMode() | (1 << sp.ordinal())); + } + } - for( final SecurityPermissions sp : bc.getPermissions( a ) ) - { - this.setPermissionMode( this.getPermissionMode() | ( 1 << sp.ordinal() ) ); - } - } + this.updatePowerStatus(); - this.updatePowerStatus(); + super.detectAndSendChanges(); + } - super.detectAndSendChanges(); - } + @Override + public void onContainerClosed(final PlayerEntity player) { + super.onContainerClosed(player); - @Override - public void onContainerClosed( final PlayerEntity player ) - { - super.onContainerClosed( player ); + if (this.wirelessIn.getHasStack()) { + player.dropItem(this.wirelessIn.getStack(), false); + } - if( this.wirelessIn.getHasStack() ) - { - player.dropItem( this.wirelessIn.getStack(), false ); - } + if (this.wirelessOut.getHasStack()) { + player.dropItem(this.wirelessOut.getStack(), false); + } + } - if( this.wirelessOut.getHasStack() ) - { - player.dropItem( this.wirelessOut.getStack(), false ); - } - } + @Override + public void saveChanges() { + // :P + } - @Override - public void saveChanges() - { - // :P - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + if (!this.wirelessOut.getHasStack()) { + if (this.wirelessIn.getHasStack()) { + final ItemStack term = this.wirelessIn.getStack().copy(); + INetworkEncodable networkEncodable = null; - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - if( !this.wirelessOut.getHasStack() ) - { - if( this.wirelessIn.getHasStack() ) - { - final ItemStack term = this.wirelessIn.getStack().copy(); - INetworkEncodable networkEncodable = null; + if (term.getItem() instanceof INetworkEncodable) { + networkEncodable = (INetworkEncodable) term.getItem(); + } - if( term.getItem() instanceof INetworkEncodable ) - { - networkEncodable = (INetworkEncodable) term.getItem(); - } + final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless() + .getWirelessTerminalHandler(term); + if (wTermHandler != null) { + networkEncodable = wTermHandler; + } - final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term ); - if( wTermHandler != null ) - { - networkEncodable = wTermHandler; - } + if (networkEncodable != null) { + networkEncodable.setEncryptionKey(term, String.valueOf(this.securityBox.getSecurityKey()), ""); - if( networkEncodable != null ) - { - networkEncodable.setEncryptionKey( term, String.valueOf( this.securityBox.getSecurityKey() ), "" ); + this.wirelessIn.putStack(ItemStack.EMPTY); + this.wirelessOut.putStack(term); - this.wirelessIn.putStack( ItemStack.EMPTY ); - this.wirelessOut.putStack( term ); + // update the two slots in question... + for (final IContainerListener listener : this.listeners) { + listener.sendSlotContents(this, this.wirelessIn.slotNumber, this.wirelessIn.getStack()); + listener.sendSlotContents(this, this.wirelessOut.slotNumber, this.wirelessOut.getStack()); + } + } + } + } + } - // update the two slots in question... - for( final IContainerListener listener : this.listeners ) - { - listener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() ); - listener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() ); - } - } - } - } - } + public int getPermissionMode() { + return this.permissionMode; + } - public int getPermissionMode() - { - return this.permissionMode; - } - - private void setPermissionMode( final int permissionMode ) - { - this.permissionMode = permissionMode; - } + private void setPermissionMode(final int permissionMode) { + this.permissionMode = permissionMode; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerSkyChest.java b/src/main/java/appeng/container/implementations/ContainerSkyChest.java index d3cf4635f..9638619db 100644 --- a/src/main/java/appeng/container/implementations/ContainerSkyChest.java +++ b/src/main/java/appeng/container/implementations/ContainerSkyChest.java @@ -18,60 +18,52 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotNormal; -import appeng.tile.storage.TileSkyChest; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotNormal; +import appeng.tile.storage.TileSkyChest; -public class ContainerSkyChest extends AEBaseContainer -{ +public class ContainerSkyChest extends AEBaseContainer { -public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerSkyChest::new, TileSkyChest.class); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerSkyChest::new, TileSkyChest.class); + private final TileSkyChest chest; - private final TileSkyChest chest; + public ContainerSkyChest(int id, final PlayerInventory ip, final TileSkyChest chest) { + super(TYPE, id, ip, chest, null); + this.chest = chest; - public ContainerSkyChest(int id, final PlayerInventory ip, final TileSkyChest chest ) - { - super( TYPE, id, ip, chest, null ); - this.chest = chest; + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 9; x++) { + this.addSlot(new SlotNormal(this.chest.getInternalInventory(), y * 9 + x, 8 + 18 * x, 24 + 18 * y)); + } + } - for( int y = 0; y < 4; y++ ) - { - for( int x = 0; x < 9; x++ ) - { - this.addSlot( new SlotNormal( this.chest.getInternalInventory(), y * 9 + x, 8 + 18 * x, 24 + 18 * y ) ); - } - } + this.chest.openInventory(ip.player); - this.chest.openInventory( ip.player ); + this.bindPlayerInventory(ip, 0, 195 - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, 195 - /* height of player inventory */82 ); - } + public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - @Override - public void onContainerClosed( final PlayerEntity par1PlayerEntity ) - { - super.onContainerClosed( par1PlayerEntity ); - this.chest.closeInventory( par1PlayerEntity ); - } + @Override + public void onContainerClosed(final PlayerEntity par1PlayerEntity) { + super.onContainerClosed(par1PlayerEntity); + this.chest.closeInventory(par1PlayerEntity); + } } diff --git a/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java b/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java index 6ff8ea0c8..677af34cc 100644 --- a/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java +++ b/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java @@ -18,11 +18,10 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGrid; @@ -31,146 +30,127 @@ import appeng.api.networking.spatial.ISpatialCache; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.spatial.TileSpatialIOPort; import appeng.util.Platform; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +public class ContainerSpatialIOPort extends AEBaseContainer { -public class ContainerSpatialIOPort extends AEBaseContainer -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerSpatialIOPort::new, TileSpatialIOPort.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerSpatialIOPort::new, TileSpatialIOPort.class, SecurityPermissions.BUILD); + @GuiSync(0) + public long currentPower; + @GuiSync(1) + public long maxPower; + @GuiSync(2) + public long reqPower; + @GuiSync(3) + public long eff; + private IGrid network; + private int delay = 40; - @GuiSync( 0 ) - public long currentPower; - @GuiSync( 1 ) - public long maxPower; - @GuiSync( 2 ) - public long reqPower; - @GuiSync( 3 ) - public long eff; - private IGrid network; - private int delay = 40; + @GuiSync(31) + public int xSize; + @GuiSync(32) + public int ySize; + @GuiSync(33) + public int zSize; - @GuiSync( 31 ) - public int xSize; - @GuiSync( 32 ) - public int ySize; - @GuiSync( 33 ) - public int zSize; + public ContainerSpatialIOPort(int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort) { + super(TYPE, id, ip, spatialIOPort, null); - public ContainerSpatialIOPort(int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort ) - { - super( TYPE, id, ip, spatialIOPort, null ); + if (Platform.isServer()) { + this.network = spatialIOPort.getGridNode(AEPartLocation.INTERNAL).getGrid(); + } - if( Platform.isServer() ) - { - this.network = spatialIOPort.getGridNode( AEPartLocation.INTERNAL ).getGrid(); - } + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, + spatialIOPort.getInternalInventory(), 0, 52, 48, this.getPlayerInventory())); + this.addSlot(new SlotOutput(spatialIOPort.getInternalInventory(), 1, 113, 48, + SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon)); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort - .getInternalInventory(), 0, 52, 48, this.getPlayerInventory() ) ); - this.addSlot( - new SlotOutput( spatialIOPort.getInternalInventory(), 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) ); + this.bindPlayerInventory(ip, 0, 197 - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 ); - } + public static ContainerSpatialIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerSpatialIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.delay++; + if (this.delay > 15 && this.network != null) { + this.delay = 0; - if( Platform.isServer() ) - { - this.delay++; - if( this.delay > 15 && this.network != null ) - { - this.delay = 0; + final IEnergyGrid eg = this.network.getCache(IEnergyGrid.class); + final ISpatialCache sc = this.network.getCache(ISpatialCache.class); + if (eg != null) { + this.setCurrentPower((long) (100.0 * eg.getStoredPower())); + this.setMaxPower((long) (100.0 * eg.getMaxStoredPower())); + this.setRequiredPower((long) (100.0 * sc.requiredPower())); + this.setEfficency((long) (100.0f * sc.currentEfficiency())); - final IEnergyGrid eg = this.network.getCache( IEnergyGrid.class ); - final ISpatialCache sc = this.network.getCache( ISpatialCache.class ); - if( eg != null ) - { - this.setCurrentPower( (long) ( 100.0 * eg.getStoredPower() ) ); - this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) ); - this.setRequiredPower( (long) ( 100.0 * sc.requiredPower() ) ); - this.setEfficency( (long) ( 100.0f * sc.currentEfficiency() ) ); + final DimensionalCoord min = sc.getMin(); + final DimensionalCoord max = sc.getMax(); - final DimensionalCoord min = sc.getMin(); - final DimensionalCoord max = sc.getMax(); + if (min != null && max != null && sc.isValidRegion()) { + this.xSize = sc.getMax().x - sc.getMin().x - 1; + this.ySize = sc.getMax().y - sc.getMin().y - 1; + this.zSize = sc.getMax().z - sc.getMin().z - 1; + } else { + this.xSize = 0; + this.ySize = 0; + this.zSize = 0; + } + } + } + } - if( min != null && max != null && sc.isValidRegion() ) - { - this.xSize = sc.getMax().x - sc.getMin().x - 1; - this.ySize = sc.getMax().y - sc.getMin().y - 1; - this.zSize = sc.getMax().z - sc.getMin().z - 1; - } - else - { - this.xSize = 0; - this.ySize = 0; - this.zSize = 0; - } - } - } - } + super.detectAndSendChanges(); + } - super.detectAndSendChanges(); - } + public long getCurrentPower() { + return this.currentPower; + } - public long getCurrentPower() - { - return this.currentPower; - } + private void setCurrentPower(final long currentPower) { + this.currentPower = currentPower; + } - private void setCurrentPower( final long currentPower ) - { - this.currentPower = currentPower; - } + public long getMaxPower() { + return this.maxPower; + } - public long getMaxPower() - { - return this.maxPower; - } + private void setMaxPower(final long maxPower) { + this.maxPower = maxPower; + } - private void setMaxPower( final long maxPower ) - { - this.maxPower = maxPower; - } + public long getRequiredPower() { + return this.reqPower; + } - public long getRequiredPower() - { - return this.reqPower; - } + private void setRequiredPower(final long reqPower) { + this.reqPower = reqPower; + } - private void setRequiredPower( final long reqPower ) - { - this.reqPower = reqPower; - } + public long getEfficency() { + return this.eff; + } - public long getEfficency() - { - return this.eff; - } - - private void setEfficency( final long eff ) - { - this.eff = eff; - } + private void setEfficency(final long eff) { + this.eff = eff; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerStorageBus.java b/src/main/java/appeng/container/implementations/ContainerStorageBus.java index 7bf788e05..fd4a43281 100644 --- a/src/main/java/appeng/container/implementations/ContainerStorageBus.java +++ b/src/main/java/appeng/container/implementations/ContainerStorageBus.java @@ -18,10 +18,8 @@ package appeng.container.implementations; - import java.util.Iterator; -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -40,6 +38,7 @@ import appeng.api.storage.IMEInventory; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.OptionalSlotFakeTypeOnly; import appeng.container.slot.SlotFakeTypeOnly; @@ -49,171 +48,143 @@ import appeng.util.Platform; import appeng.util.helpers.ItemHandlerUtil; import appeng.util.iterators.NullIterator; +public class ContainerStorageBus extends ContainerUpgradeable { -public class ContainerStorageBus extends ContainerUpgradeable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerStorageBus::new, PartStorageBus.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerStorageBus::new, PartStorageBus.class, SecurityPermissions.BUILD); + public static ContainerStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final PartStorageBus storageBus; - private final PartStorageBus storageBus; + @GuiSync(3) + public AccessRestriction rwMode = AccessRestriction.READ_WRITE; - @GuiSync( 3 ) - public AccessRestriction rwMode = AccessRestriction.READ_WRITE; + @GuiSync(4) + public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY; - @GuiSync( 4 ) - public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY; + public ContainerStorageBus(int id, final PlayerInventory ip, final PartStorageBus te) { + super(TYPE, id, ip, te); + this.storageBus = te; + } - public ContainerStorageBus(int id, final PlayerInventory ip, final PartStorageBus te ) - { - super( TYPE, id, ip, te ); - this.storageBus = te; - } + @Override + protected int getHeight() { + return 251; + } - @Override - protected int getHeight() - { - return 251; - } + @Override + protected void setupConfig() { + final int xo = 8; + final int yo = 23 + 6; - @Override - protected void setupConfig() - { - final int xo = 8; - final int yo = 23 + 6; + final IItemHandler config = this.getUpgradeable().getInventoryByName("config"); + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 9; x++) { + if (y < 2) { + this.addSlot(new SlotFakeTypeOnly(config, y * 9 + x, xo + x * 18, yo + y * 18)); + } else { + this.addSlot(new OptionalSlotFakeTypeOnly(config, this, y * 9 + x, xo, yo, x, y, y - 2)); + } + } + } - final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" ); - for( int y = 0; y < 7; y++ ) - { - for( int x = 0; x < 9; x++ ) - { - if( y < 2 ) - { - this.addSlot( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) ); - } - else - { - this.addSlot( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) ); - } - } - } + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, + 8 + 18 * 4, this.getPlayerInventory())).setNotDraggable()); + } - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + @Override + protected boolean supportCapacity() { + return true; + } - @Override - protected boolean supportCapacity() - { - return true; - } + @Override + public int availableUpgrades() { + return 5; + } - @Override - public int availableUpgrades() - { - return 5; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE)); + this.setReadWriteMode( + (AccessRestriction) this.getUpgradeable().getConfigManager().getSetting(Settings.ACCESS)); + this.setStorageFilter( + (StorageFilter) this.getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER)); + } - if( Platform.isServer() ) - { - this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) ); - this.setReadWriteMode( (AccessRestriction) this.getUpgradeable().getConfigManager().getSetting( Settings.ACCESS ) ); - this.setStorageFilter( (StorageFilter) this.getUpgradeable().getConfigManager().getSetting( Settings.STORAGE_FILTER ) ); - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + @Override + public boolean isSlotEnabled(final int idx) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - @Override - public boolean isSlotEnabled( final int idx ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + return upgrades > idx; + } - return upgrades > idx; - } + public void clear() { + ItemHandlerUtil.clear(this.getUpgradeable().getInventoryByName("config")); + this.detectAndSendChanges(); + } - public void clear() - { - ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) ); - this.detectAndSendChanges(); - } + public void partition() { + final IItemHandler inv = this.getUpgradeable().getInventoryByName("config"); - public void partition() - { - final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); + final IMEInventory cellInv = this.storageBus.getInternalHandler(); - final IMEInventory cellInv = this.storageBus.getInternalHandler(); + Iterator i = new NullIterator<>(); + if (cellInv != null) { + final IItemList list = cellInv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + i = list.iterator(); + } - Iterator i = new NullIterator<>(); - if( cellInv != null ) - { - final IItemList list = cellInv - .getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - i = list.iterator(); - } + for (int x = 0; x < inv.getSlots(); x++) { + if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) { + // TODO: check if ok + final ItemStack g = i.next().asItemStackRepresentation(); + ItemHandlerUtil.setStackInSlot(inv, x, g); + } else { + ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.EMPTY); + } + } - for( int x = 0; x < inv.getSlots(); x++ ) - { - if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) ) - { - // TODO: check if ok - final ItemStack g = i.next().asItemStackRepresentation(); - ItemHandlerUtil.setStackInSlot( inv, x, g ); - } - else - { - ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY ); - } - } + this.detectAndSendChanges(); + } - this.detectAndSendChanges(); - } + public AccessRestriction getReadWriteMode() { + return this.rwMode; + } - public AccessRestriction getReadWriteMode() - { - return this.rwMode; - } + private void setReadWriteMode(final AccessRestriction rwMode) { + this.rwMode = rwMode; + } - private void setReadWriteMode( final AccessRestriction rwMode ) - { - this.rwMode = rwMode; - } + public StorageFilter getStorageFilter() { + return this.storageFilter; + } - public StorageFilter getStorageFilter() - { - return this.storageFilter; - } - - private void setStorageFilter( final StorageFilter storageFilter ) - { - this.storageFilter = storageFilter; - } + private void setStorageFilter(final StorageFilter storageFilter) { + this.storageFilter = storageFilter; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java index cfe38ba4e..8045cb78e 100644 --- a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java +++ b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java @@ -18,8 +18,6 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; @@ -43,6 +41,7 @@ import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.parts.IPart; import appeng.api.util.IConfigManager; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; import appeng.container.slot.IOptionalSlotHost; import appeng.container.slot.OptionalSlotFake; @@ -54,300 +53,249 @@ import appeng.items.tools.ToolNetworkTool; import appeng.parts.automation.PartExportBus; import appeng.util.Platform; +public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost { -public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerUpgradeable::new, IUpgradeableHost.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerUpgradeable::new, IUpgradeableHost.class, SecurityPermissions.BUILD); + public static ContainerUpgradeable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerUpgradeable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final IUpgradeableHost upgradeable; + @GuiSync(0) + public RedstoneMode rsMode = RedstoneMode.IGNORE; + @GuiSync(1) + public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL; + @GuiSync(5) + public YesNo cMode = YesNo.NO; + @GuiSync(6) + public SchedulingMode schedulingMode = SchedulingMode.DEFAULT; + private int tbSlot; + private NetworkToolViewer tbInventory; - private final IUpgradeableHost upgradeable; - @GuiSync( 0 ) - public RedstoneMode rsMode = RedstoneMode.IGNORE; - @GuiSync( 1 ) - public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL; - @GuiSync( 5 ) - public YesNo cMode = YesNo.NO; - @GuiSync( 6 ) - public SchedulingMode schedulingMode = SchedulingMode.DEFAULT; - private int tbSlot; - private NetworkToolViewer tbInventory; + public ContainerUpgradeable(int id, final PlayerInventory ip, final IUpgradeableHost te) { + this(TYPE, id, ip, te); + } - public ContainerUpgradeable(int id, final PlayerInventory ip, final IUpgradeableHost te ) - { - this(TYPE, id, ip, te); - } + public ContainerUpgradeable(ContainerType containerType, int id, final PlayerInventory ip, + final IUpgradeableHost te) { + super(containerType, id, ip, (TileEntity) (te instanceof TileEntity ? te : null), + (IPart) (te instanceof IPart ? te : null)); + this.upgradeable = te; - public ContainerUpgradeable(ContainerType containerType, int id, final PlayerInventory ip, final IUpgradeableHost te ) - { - super( containerType, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) ); - this.upgradeable = te; + World w = null; + int xCoord = 0; + int yCoord = 0; + int zCoord = 0; - World w = null; - int xCoord = 0; - int yCoord = 0; - int zCoord = 0; + if (te instanceof TileEntity) { + final TileEntity myTile = (TileEntity) te; + w = myTile.getWorld(); + xCoord = myTile.getPos().getX(); + yCoord = myTile.getPos().getY(); + zCoord = myTile.getPos().getZ(); + } - if( te instanceof TileEntity ) - { - final TileEntity myTile = (TileEntity) te; - w = myTile.getWorld(); - xCoord = myTile.getPos().getX(); - yCoord = myTile.getPos().getY(); - zCoord = myTile.getPos().getZ(); - } + if (te instanceof IPart) { + final TileEntity mk = te.getTile(); + w = mk.getWorld(); + xCoord = mk.getPos().getX(); + yCoord = mk.getPos().getY(); + zCoord = mk.getPos().getZ(); + } - if( te instanceof IPart ) - { - final TileEntity mk = te.getTile(); - w = mk.getWorld(); - xCoord = mk.getPos().getX(); - yCoord = mk.getPos().getY(); - zCoord = mk.getPos().getZ(); - } + final IInventory pi = this.getPlayerInv(); + for (int x = 0; x < pi.getSizeInventory(); x++) { + final ItemStack pii = pi.getStackInSlot(x); + if (!pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool) { + this.lockPlayerInventorySlot(x); + this.tbSlot = x; + this.tbInventory = (NetworkToolViewer) ((IGuiItem) pii.getItem()).getGuiObject(pii, x, w, + new BlockPos(xCoord, yCoord, zCoord)); + break; + } + } - final IInventory pi = this.getPlayerInv(); - for( int x = 0; x < pi.getSizeInventory(); x++ ) - { - final ItemStack pii = pi.getStackInSlot( x ); - if( !pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool ) - { - this.lockPlayerInventorySlot( x ); - this.tbSlot = x; - this.tbInventory = (NetworkToolViewer) ( (IGuiItem) pii.getItem() ).getGuiObject( pii, x, w, new BlockPos( xCoord, yCoord, zCoord ) ); - break; - } - } + if (this.hasToolbox()) { + for (int v = 0; v < 3; v++) { + for (int u = 0; u < 3; u++) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, + this.tbInventory.getInternalInventory(), u + v * 3, 186 + u * 18, + this.getHeight() - 82 + v * 18, this.getPlayerInventory())).setPlayerSide()); + } + } + } - if( this.hasToolbox() ) - { - for( int v = 0; v < 3; v++ ) - { - for( int u = 0; u < 3; u++ ) - { - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory - .getInternalInventory(), u + v * 3, 186 + u * 18, this.getHeight() - 82 + v * 18, this.getPlayerInventory() ) ).setPlayerSide() ); - } - } - } + this.setupConfig(); - this.setupConfig(); + this.bindPlayerInventory(ip, 0, this.getHeight() - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, this.getHeight() - /* height of player inventory */82 ); - } + public boolean hasToolbox() { + return this.tbInventory != null; + } - public boolean hasToolbox() - { - return this.tbInventory != null; - } + protected int getHeight() { + return 184; + } - protected int getHeight() - { - return 184; - } + protected void setupConfig() { + this.setupUpgrades(); - protected void setupConfig() - { - this.setupUpgrades(); + final IItemHandler inv = this.getUpgradeable().getInventoryByName("config"); + final int y = 40; + final int x = 80; + this.addSlot(new SlotFakeTypeOnly(inv, 0, x, y)); - final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); - final int y = 40; - final int x = 80; - this.addSlot( new SlotFakeTypeOnly( inv, 0, x, y ) ); + if (this.supportCapacity()) { + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 1, x, y, -1, 0, 1)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 2, x, y, 1, 0, 1)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 3, x, y, 0, -1, 1)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 4, x, y, 0, 1, 1)); - if( this.supportCapacity() ) - { - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) ); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 5, x, y, -1, -1, 2)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 6, x, y, 1, -1, 2)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 7, x, y, -1, 1, 2)); + this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 8, x, y, 1, 1, 2)); + } + } - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) ); - this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) ); - } - } + protected void setupUpgrades() { + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + if (this.availableUpgrades() > 0) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 1) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, + 8 + 18, this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 2) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + } + if (this.availableUpgrades() > 3) { + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + } + } - protected void setupUpgrades() - { - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - if( this.availableUpgrades() > 0 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 1 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 2 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - if( this.availableUpgrades() > 3 ) - { - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - } + protected boolean supportCapacity() { + return true; + } - protected boolean supportCapacity() - { - return true; - } + public int availableUpgrades() { + return 4; + } - public int availableUpgrades() - { - return 4; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + final IConfigManager cm = this.getUpgradeable().getConfigManager(); + this.loadSettingsFromHost(cm); + } - if( Platform.isServer() ) - { - final IConfigManager cm = this.getUpgradeable().getConfigManager(); - this.loadSettingsFromHost( cm ); - } + this.checkToolbox(); - this.checkToolbox(); + for (final Object o : this.inventorySlots) { + if (o instanceof OptionalSlotFake) { + final OptionalSlotFake fs = (OptionalSlotFake) o; + if (!fs.isSlotEnabled() && !fs.getDisplayStack().isEmpty()) { + fs.clearStack(); + } + } + } - for( final Object o : this.inventorySlots ) - { - if( o instanceof OptionalSlotFake ) - { - final OptionalSlotFake fs = (OptionalSlotFake) o; - if( !fs.isSlotEnabled() && !fs.getDisplayStack().isEmpty() ) - { - fs.clearStack(); - } - } - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + protected void loadSettingsFromHost(final IConfigManager cm) { + this.setFuzzyMode((FuzzyMode) cm.getSetting(Settings.FUZZY_MODE)); + this.setRedStoneMode((RedstoneMode) cm.getSetting(Settings.REDSTONE_CONTROLLED)); + if (this.getUpgradeable() instanceof PartExportBus) { + this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY)); + this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE)); + } + } - protected void loadSettingsFromHost( final IConfigManager cm ) - { - this.setFuzzyMode( (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE ) ); - this.setRedStoneMode( (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED ) ); - if( this.getUpgradeable() instanceof PartExportBus ) - { - this.setCraftingMode( (YesNo) cm.getSetting( Settings.CRAFT_ONLY ) ); - this.setSchedulingMode( (SchedulingMode) cm.getSetting( Settings.SCHEDULING_MODE ) ); - } - } + protected void checkToolbox() { + if (this.hasToolbox()) { + final ItemStack currentItem = this.getPlayerInv().getStackInSlot(this.tbSlot); - protected void checkToolbox() - { - if( this.hasToolbox() ) - { - final ItemStack currentItem = this.getPlayerInv().getStackInSlot( this.tbSlot ); + if (currentItem != this.tbInventory.getItemStack()) { + if (!currentItem.isEmpty()) { + if (ItemStack.areItemsEqual(this.tbInventory.getItemStack(), currentItem)) { + this.getPlayerInv().setInventorySlotContents(this.tbSlot, this.tbInventory.getItemStack()); + } else { + this.setValidContainer(false); + } + } else { + this.setValidContainer(false); + } + } + } + } - if( currentItem != this.tbInventory.getItemStack() ) - { - if( !currentItem.isEmpty() ) - { - if( ItemStack.areItemsEqual( this.tbInventory.getItemStack(), currentItem ) ) - { - this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() ); - } - else - { - this.setValidContainer( false ); - } - } - else - { - this.setValidContainer( false ); - } - } - } - } + protected void standardDetectAndSendChanges() { + super.detectAndSendChanges(); + } - protected void standardDetectAndSendChanges() - { - super.detectAndSendChanges(); - } + @Override + public boolean isSlotEnabled(final int idx) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - @Override - public boolean isSlotEnabled( final int idx ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + if (idx == 1 && upgrades > 0) { + return true; + } + if (idx == 2 && upgrades > 1) { + return true; + } - if( idx == 1 && upgrades > 0 ) - { - return true; - } - if( idx == 2 && upgrades > 1 ) - { - return true; - } + return false; + } - return false; - } + public FuzzyMode getFuzzyMode() { + return this.fzMode; + } - public FuzzyMode getFuzzyMode() - { - return this.fzMode; - } + public void setFuzzyMode(final FuzzyMode fzMode) { + this.fzMode = fzMode; + } - public void setFuzzyMode( final FuzzyMode fzMode ) - { - this.fzMode = fzMode; - } + public YesNo getCraftingMode() { + return this.cMode; + } - public YesNo getCraftingMode() - { - return this.cMode; - } + public void setCraftingMode(final YesNo cMode) { + this.cMode = cMode; + } - public void setCraftingMode( final YesNo cMode ) - { - this.cMode = cMode; - } + public RedstoneMode getRedStoneMode() { + return this.rsMode; + } - public RedstoneMode getRedStoneMode() - { - return this.rsMode; - } + public void setRedStoneMode(final RedstoneMode rsMode) { + this.rsMode = rsMode; + } - public void setRedStoneMode( final RedstoneMode rsMode ) - { - this.rsMode = rsMode; - } + public SchedulingMode getSchedulingMode() { + return this.schedulingMode; + } - public SchedulingMode getSchedulingMode() - { - return this.schedulingMode; - } + private void setSchedulingMode(final SchedulingMode schedulingMode) { + this.schedulingMode = schedulingMode; + } - private void setSchedulingMode( final SchedulingMode schedulingMode ) - { - this.schedulingMode = schedulingMode; - } - - protected IUpgradeableHost getUpgradeable() - { - return this.upgradeable; - } + protected IUpgradeableHost getUpgradeable() { + return this.upgradeable; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerVibrationChamber.java b/src/main/java/appeng/container/implementations/ContainerVibrationChamber.java index a7c6dad4e..18b607b8d 100644 --- a/src/main/java/appeng/container/implementations/ContainerVibrationChamber.java +++ b/src/main/java/appeng/container/implementations/ContainerVibrationChamber.java @@ -18,82 +18,73 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.container.interfaces.IProgressProvider; import appeng.container.slot.SlotRestrictedInput; import appeng.tile.misc.TileVibrationChamber; import appeng.util.Platform; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +public class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider { -public class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider -{ + public static ContainerType TYPE; -public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerVibrationChamber::new, TileVibrationChamber.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerVibrationChamber::new, TileVibrationChamber.class); + public static ContainerVibrationChamber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerVibrationChamber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final TileVibrationChamber vibrationChamber; + @GuiSync(0) + public int burnSpeed = 0; + @GuiSync(1) + public int remainingBurnTime = 0; - private final TileVibrationChamber vibrationChamber; - @GuiSync( 0 ) - public int burnSpeed = 0; - @GuiSync( 1 ) - public int remainingBurnTime = 0; + public ContainerVibrationChamber(int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber) { + super(TYPE, id, ip, vibrationChamber, null); + this.vibrationChamber = vibrationChamber; - public ContainerVibrationChamber(int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber ) - { - super( TYPE, id, ip, vibrationChamber, null ); - this.vibrationChamber = vibrationChamber; + this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.FUEL, + vibrationChamber.getInternalInventory(), 0, 80, 37, this.getPlayerInventory())); - this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, vibrationChamber.getInternalInventory(), 0, 80, 37, this - .getPlayerInventory() ) ); + this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); + } - this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); - } + @Override + public void detectAndSendChanges() { + if (Platform.isServer()) { + this.remainingBurnTime = this.vibrationChamber.getMaxBurnTime() <= 0 ? 0 + : (int) (100.0 * this.vibrationChamber.getBurnTime() / this.vibrationChamber.getMaxBurnTime()); + this.burnSpeed = this.remainingBurnTime <= 0 ? 0 : this.vibrationChamber.getBurnSpeed(); - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() ) - { - this.remainingBurnTime = this.vibrationChamber - .getMaxBurnTime() <= 0 ? 0 : (int) ( 100.0 * this.vibrationChamber.getBurnTime() / this.vibrationChamber.getMaxBurnTime() ); - this.burnSpeed = this.remainingBurnTime <= 0 ? 0 : this.vibrationChamber.getBurnSpeed(); + } + super.detectAndSendChanges(); + } - } - super.detectAndSendChanges(); - } + @Override + public int getCurrentProgress() { + return this.burnSpeed; + } - @Override - public int getCurrentProgress() - { - return this.burnSpeed; - } + public int getRemainingBurnTime() { + return this.remainingBurnTime; + } - public int getRemainingBurnTime() - { - return this.remainingBurnTime; - } - - @Override - public int getMaxProgress() - { - return TileVibrationChamber.MAX_BURN_SPEED; - } + @Override + public int getMaxProgress() { + return TileVibrationChamber.MAX_BURN_SPEED; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerWireless.java b/src/main/java/appeng/container/implementations/ContainerWireless.java index 188e03105..2d5901099 100644 --- a/src/main/java/appeng/container/implementations/ContainerWireless.java +++ b/src/main/java/appeng/container/implementations/ContainerWireless.java @@ -18,82 +18,73 @@ package appeng.container.implementations; - -import appeng.api.config.SecurityPermissions; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; - -import appeng.container.AEBaseContainer; -import appeng.container.guisync.GuiSync; -import appeng.container.slot.SlotRestrictedInput; -import appeng.core.AEConfig; -import appeng.tile.networking.TileWireless; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; +import appeng.api.config.SecurityPermissions; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotRestrictedInput; +import appeng.core.AEConfig; +import appeng.tile.networking.TileWireless; -public class ContainerWireless extends AEBaseContainer -{ +public class ContainerWireless extends AEBaseContainer { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerWireless::new, TileWireless.class, SecurityPermissions.BUILD); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerWireless::new, TileWireless.class, SecurityPermissions.BUILD); - public static ContainerWireless fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerWireless fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - private final SlotRestrictedInput boosterSlot; - @GuiSync( 1 ) - public long range = 0; - @GuiSync( 2 ) - public long drain = 0; + private final SlotRestrictedInput boosterSlot; + @GuiSync(1) + public long range = 0; + @GuiSync(2) + public long drain = 0; - public ContainerWireless(int id, final PlayerInventory ip, final TileWireless te ) - { - super( TYPE, id, ip, te, null ); + public ContainerWireless(int id, final PlayerInventory ip, final TileWireless te) { + super(TYPE, id, ip, te, null); - this.addSlot( this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, te - .getInternalInventory(), 0, 80, 47, this.getPlayerInventory() ) ); + this.addSlot(this.boosterSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, + te.getInternalInventory(), 0, 80, 47, this.getPlayerInventory())); - this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); - } + this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); + } - @Override - public void detectAndSendChanges() - { - final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount(); + @Override + public void detectAndSendChanges() { + final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount(); - this.setRange( (long) ( 10 * AEConfig.instance().wireless_getMaxRange( boosters ) ) ); - this.setDrain( (long) ( 100 * AEConfig.instance().wireless_getPowerDrain( boosters ) ) ); + this.setRange((long) (10 * AEConfig.instance().wireless_getMaxRange(boosters))); + this.setDrain((long) (100 * AEConfig.instance().wireless_getPowerDrain(boosters))); - super.detectAndSendChanges(); - } + super.detectAndSendChanges(); + } - public long getRange() - { - return this.range; - } + public long getRange() { + return this.range; + } - private void setRange( final long range ) - { - this.range = range; - } + private void setRange(final long range) { + this.range = range; + } - public long getDrain() - { - return this.drain; - } + public long getDrain() { + return this.drain; + } - private void setDrain( final long drain ) - { - this.drain = drain; - } + private void setDrain(final long drain) { + this.drain = drain; + } } diff --git a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java index 4c6ad2637..32f70e85b 100644 --- a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java @@ -18,60 +18,52 @@ package appeng.container.implementations; - -import appeng.container.ContainerLocator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; +import appeng.container.ContainerLocator; import appeng.core.AEConfig; import appeng.core.localization.PlayerMessages; import appeng.helpers.WirelessTerminalGuiObject; import appeng.util.Platform; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; +public class ContainerWirelessTerm extends ContainerMEPortableCell { -public class ContainerWirelessTerm extends ContainerMEPortableCell -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerWirelessTerm::new, WirelessTerminalGuiObject.class); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerWirelessTerm::new, WirelessTerminalGuiObject.class); + public static ContainerWirelessTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerWirelessTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final WirelessTerminalGuiObject wirelessTerminalGUIObject; - private final WirelessTerminalGuiObject wirelessTerminalGUIObject; + public ContainerWirelessTerm(int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui) { + super(TYPE, id, ip, gui); + this.wirelessTerminalGUIObject = gui; + } - public ContainerWirelessTerm(int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui ) - { - super( TYPE, id, ip, gui ); - this.wirelessTerminalGUIObject = gui; - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); + if (!this.wirelessTerminalGUIObject.rangeCheck()) { + if (Platform.isServer() && this.isValidContainer()) { + this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get()); + } - if( !this.wirelessTerminalGUIObject.rangeCheck() ) - { - if( Platform.isServer() && this.isValidContainer() ) - { - this.getPlayerInv().player.sendMessage( PlayerMessages.OutOfRange.get() ); - } - - this.setValidContainer( false ); - } - else - { - this.setPowerMultiplier( AEConfig.instance().wireless_getDrainRate( this.wirelessTerminalGUIObject.getRange() ) ); - } - } + this.setValidContainer(false); + } else { + this.setPowerMultiplier( + AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange())); + } + } } diff --git a/src/main/java/appeng/container/implementations/CraftingCPURecord.java b/src/main/java/appeng/container/implementations/CraftingCPURecord.java index a2f319d6a..f15ec32fb 100644 --- a/src/main/java/appeng/container/implementations/CraftingCPURecord.java +++ b/src/main/java/appeng/container/implementations/CraftingCPURecord.java @@ -18,57 +18,48 @@ package appeng.container.implementations; - import javax.annotation.Nonnull; -import appeng.api.networking.crafting.ICraftingCPU; import net.minecraft.inventory.container.ContainerType; import net.minecraft.util.text.ITextComponent; +import appeng.api.networking.crafting.ICraftingCPU; -public class CraftingCPURecord implements Comparable -{ - private final ITextComponent myName; - private final ICraftingCPU cpu; - private final long size; - private final int processors; +public class CraftingCPURecord implements Comparable { + private final ITextComponent myName; + private final ICraftingCPU cpu; + private final long size; + private final int processors; - public CraftingCPURecord( final long size, final int coProcessors, final ICraftingCPU server ) - { - this.size = size; - this.processors = coProcessors; - this.cpu = server; - this.myName = server.getName(); - } + public CraftingCPURecord(final long size, final int coProcessors, final ICraftingCPU server) { + this.size = size; + this.processors = coProcessors; + this.cpu = server; + this.myName = server.getName(); + } - @Override - public int compareTo( @Nonnull final CraftingCPURecord o ) - { - final int a = Long.compare( o.getProcessors(), this.getProcessors() ); - if( a != 0 ) - { - return a; - } - return Long.compare( o.getSize(), this.getSize() ); - } + @Override + public int compareTo(@Nonnull final CraftingCPURecord o) { + final int a = Long.compare(o.getProcessors(), this.getProcessors()); + if (a != 0) { + return a; + } + return Long.compare(o.getSize(), this.getSize()); + } - ICraftingCPU getCpu() - { - return this.cpu; - } + ICraftingCPU getCpu() { + return this.cpu; + } - ITextComponent getName() - { - return this.myName; - } + ITextComponent getName() { + return this.myName; + } - int getProcessors() - { - return this.processors; - } + int getProcessors() { + return this.processors; + } - long getSize() - { - return this.size; - } + long getSize() { + return this.size; + } } diff --git a/src/main/java/appeng/container/interfaces/IInventorySlotAware.java b/src/main/java/appeng/container/interfaces/IInventorySlotAware.java index 492ed793f..767638b52 100644 --- a/src/main/java/appeng/container/interfaces/IInventorySlotAware.java +++ b/src/main/java/appeng/container/interfaces/IInventorySlotAware.java @@ -1,37 +1,35 @@ -/* - * 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.container.interfaces; - - -/** - * Any item providing a GUI and depending on an exact inventory slot. - * - * This interface is likely a volatile one until a general GUI refactoring occurred. - * Use it with care and expect changes. - * - */ -public interface IInventorySlotAware -{ - /** - * This is needed to select the correct slot index. - * - * @return the inventory index of this portable cell. - */ - int getInventorySlot(); -} +/* + * 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.container.interfaces; + +/** + * Any item providing a GUI and depending on an exact inventory slot. + * + * This interface is likely a volatile one until a general GUI refactoring + * occurred. Use it with care and expect changes. + * + */ +public interface IInventorySlotAware { + /** + * This is needed to select the correct slot index. + * + * @return the inventory index of this portable cell. + */ + int getInventorySlot(); +} diff --git a/src/main/java/appeng/container/interfaces/IProgressProvider.java b/src/main/java/appeng/container/interfaces/IProgressProvider.java index 2f6f72d1d..44868d2f6 100644 --- a/src/main/java/appeng/container/interfaces/IProgressProvider.java +++ b/src/main/java/appeng/container/interfaces/IProgressProvider.java @@ -1,48 +1,48 @@ -/* - * 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.container.interfaces; - - - -/** - * This interface provides the data for anything simulating a progress. - * - * Its main use is in combination with the {@link appeng.client.gui.widgets.GuiProgressBar}, which ensures to scale it to a percentage of 0 to - * 100. - */ -public interface IProgressProvider -{ - - /** - * The current value of the progress. It should cover a range from 0 to the max progress - * - * @return An int representing the current progress - */ - int getCurrentProgress(); - - /** - * The max value the progress. - * - * It is not limited to a value of 100 and can be scaled to fit the current needs. For example scaled down to - * decrease or scaled up to increase the precision. - * - * @return An int representing the max progress - */ - int getMaxProgress(); -} +/* + * 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.container.interfaces; + +/** + * This interface provides the data for anything simulating a progress. + * + * Its main use is in combination with the + * {@link appeng.client.gui.widgets.GuiProgressBar}, which ensures to scale it + * to a percentage of 0 to 100. + */ +public interface IProgressProvider { + + /** + * The current value of the progress. It should cover a range from 0 to the max + * progress + * + * @return An int representing the current progress + */ + int getCurrentProgress(); + + /** + * The max value the progress. + * + * It is not limited to a value of 100 and can be scaled to fit the current + * needs. For example scaled down to decrease or scaled up to increase the + * precision. + * + * @return An int representing the max progress + */ + int getMaxProgress(); +} diff --git a/src/main/java/appeng/container/slot/AppEngCraftingSlot.java b/src/main/java/appeng/container/slot/AppEngCraftingSlot.java index 32388b38d..38b50c374 100644 --- a/src/main/java/appeng/container/slot/AppEngCraftingSlot.java +++ b/src/main/java/appeng/container/slot/AppEngCraftingSlot.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; @@ -30,177 +29,169 @@ import net.minecraftforge.items.IItemHandler; import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.WrapperInvItemHandler; +public class AppEngCraftingSlot extends AppEngSlot { -public class AppEngCraftingSlot extends AppEngSlot -{ + /** + * The craft matrix inventory linked to this result slot. + */ + private final IItemHandler craftMatrix; - /** - * The craft matrix inventory linked to this result slot. - */ - private final IItemHandler craftMatrix; + /** + * The player that is using the GUI where this slot resides. + */ + private final PlayerEntity thePlayer; - /** - * The player that is using the GUI where this slot resides. - */ - private final PlayerEntity thePlayer; + /** + * The number of items that have been crafted so far. Gets passed to + * ItemStack.onCrafting before being reset. + */ + private int amountCrafted; - /** - * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. - */ - private int amountCrafted; + public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory, + final IItemHandler par3IInventory, final int par4, final int par5, final int par6) { + super(par3IInventory, par4, par5, par6); + this.thePlayer = par1PlayerEntity; + this.craftMatrix = par2IInventory; + } - public AppEngCraftingSlot( final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory, final IItemHandler par3IInventory, final int par4, final int par5, final int par6 ) - { - super( par3IInventory, par4, par5, par6 ); - this.thePlayer = par1PlayerEntity; - this.craftMatrix = par2IInventory; - } + /** + * Check if the stack is a valid item for this slot. Always true beside for the + * armor slots. + */ + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - /** - * Check if the stack is a valid item for this slot. Always true beside for the armor slots. - */ - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not + * ore and wood. Typically increases an internal count then calls + * onCrafting(item). + */ + @Override + protected void onCrafting(final ItemStack par1ItemStack, final int par2) { + this.amountCrafted += par2; + this.onCrafting(par1ItemStack); + } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an - * internal count then calls onCrafting(item). - */ - @Override - protected void onCrafting( final ItemStack par1ItemStack, final int par2 ) - { - this.amountCrafted += par2; - this.onCrafting( par1ItemStack ); - } + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not + * ore and wood. + */ + @Override + protected void onCrafting(final ItemStack par1ItemStack) { + par1ItemStack.onCrafting(this.thePlayer.world, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. - */ - @Override - protected void onCrafting( final ItemStack par1ItemStack ) - { - par1ItemStack.onCrafting( this.thePlayer.world, this.thePlayer, this.amountCrafted ); - this.amountCrafted = 0; + // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE ) + // ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 ); + // } + // + // if( par1ItemStack.getItem() instanceof ItemPickaxe ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 ); + // } + // + // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 ); + // } + // + // if( par1ItemStack.getItem() instanceof ItemHoe ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 ); + // } + // + // if( par1ItemStack.getItem() == Items.BREAD ) + // { + // this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 ); + // } + // + // if( par1ItemStack.getItem() == Items.CAKE ) + // { + // this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 ); + // } + // + // if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool) + // par1ItemStack.getItem() + // ).getToolMaterial() != Item.ToolMaterial.WOOD ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 ); + // } + // + // if( par1ItemStack.getItem() instanceof ItemSword ) + // { + // this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 ); + // } + // + // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE + // ) ) + // { + // this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 ); + // } + // + // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) ) + // { + // this.thePlayer.addStat( AchievementList.BOOKCASE, 1 ); + // } + } - // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE ) ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 ); - // } - // - // if( par1ItemStack.getItem() instanceof ItemPickaxe ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 ); - // } - // - // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 ); - // } - // - // if( par1ItemStack.getItem() instanceof ItemHoe ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 ); - // } - // - // if( par1ItemStack.getItem() == Items.BREAD ) - // { - // this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 ); - // } - // - // if( par1ItemStack.getItem() == Items.CAKE ) - // { - // this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 ); - // } - // - // if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool) par1ItemStack.getItem() - // ).getToolMaterial() != Item.ToolMaterial.WOOD ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 ); - // } - // - // if( par1ItemStack.getItem() instanceof ItemSword ) - // { - // this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 ); - // } - // - // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE ) ) - // { - // this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 ); - // } - // - // if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) ) - // { - // this.thePlayer.addStat( AchievementList.BOOKCASE, 1 ); - // } - } + @Override + public ItemStack onTake(final PlayerEntity playerIn, final ItemStack stack) { + BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, new WrapperInvItemHandler(this.craftMatrix)); + this.onCrafting(stack); + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn); + final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3); - @Override - public ItemStack onTake( final PlayerEntity playerIn, final ItemStack stack ) - { - BasicEventHooks.firePlayerCraftingEvent( playerIn, stack, new WrapperInvItemHandler( this.craftMatrix ) ); - this.onCrafting( stack ); - net.minecraftforge.common.ForgeHooks.setCraftingPlayer( playerIn ); - final CraftingInventory ic = new CraftingInventory( this.getContainer(), 3, 3 ); + for (int x = 0; x < this.craftMatrix.getSlots(); x++) { + ic.setInventorySlotContents(x, this.craftMatrix.getStackInSlot(x)); + } - for( int x = 0; x < this.craftMatrix.getSlots(); x++ ) - { - ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) ); - } + final NonNullList aitemstack = this.getRemainingItems(ic, playerIn.world); - final NonNullList aitemstack = this.getRemainingItems( ic, playerIn.world ); + ItemHandlerUtil.copy(ic, this.craftMatrix, false); - ItemHandlerUtil.copy( ic, this.craftMatrix, false ); + net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); - net.minecraftforge.common.ForgeHooks.setCraftingPlayer( null ); + for (int i = 0; i < aitemstack.size(); ++i) { + final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + final ItemStack itemstack2 = aitemstack.get(i); - for( int i = 0; i < aitemstack.size(); ++i ) - { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i ); - final ItemStack itemstack2 = aitemstack.get( i ); + if (!itemstack1.isEmpty()) { + this.craftMatrix.extractItem(i, 1, false); + } - if( !itemstack1.isEmpty() ) - { - this.craftMatrix.extractItem( i, 1, false ); - } + if (!itemstack2.isEmpty()) { + if (this.craftMatrix.getStackInSlot(i).isEmpty()) { + ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2); + } else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + this.thePlayer.dropItem(itemstack2, false); + } + } + } - if( !itemstack2.isEmpty() ) - { - if( this.craftMatrix.getStackInSlot( i ).isEmpty() ) - { - ItemHandlerUtil.setStackInSlot( this.craftMatrix, i, itemstack2 ); - } - else if( !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) ) - { - this.thePlayer.dropItem( itemstack2, false ); - } - } - } + return stack; + } - return stack; - } + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the + * second int arg. Returns the new stack. + */ + @Override + public ItemStack decrStackSize(final int par1) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(par1, this.getStack().getCount()); + } - /** - * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new - * stack. - */ - @Override - public ItemStack decrStackSize( final int par1 ) - { - if( this.getHasStack() ) - { - this.amountCrafted += Math.min( par1, this.getStack().getCount() ); - } + return super.decrStackSize(par1); + } - return super.decrStackSize( par1 ); - } - - // TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring. - protected NonNullList getRemainingItems( CraftingInventory ic, World world ) - { - // FIXME return CraftingManager.getRemainingItems( ic, world ); - return null; - } + // TODO: This is really hacky and NEEDS to be solved with a full container/gui + // refactoring. + protected NonNullList getRemainingItems(CraftingInventory ic, World world) { + // FIXME return CraftingManager.getRemainingItems( ic, world ); + return null; + } } diff --git a/src/main/java/appeng/container/slot/AppEngSlot.java b/src/main/java/appeng/container/slot/AppEngSlot.java index 1ba06827a..df1018fe7 100644 --- a/src/main/java/appeng/container/slot/AppEngSlot.java +++ b/src/main/java/appeng/container/slot/AppEngSlot.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import javax.annotation.Nonnull; import net.minecraft.entity.player.PlayerEntity; @@ -33,257 +32,211 @@ import net.minecraftforge.items.IItemHandler; import appeng.container.AEBaseContainer; import appeng.util.helpers.ItemHandlerUtil; +public class AppEngSlot extends Slot { + private static IInventory emptyInventory = new Inventory(0); + private final IItemHandler itemHandler; + private final int index; -public class AppEngSlot extends Slot -{ - private static IInventory emptyInventory = new Inventory(0); - private final IItemHandler itemHandler; - private final int index; + private final int defX; + private final int defY; + private boolean isDraggable = true; + private boolean isPlayerSide = false; + private AEBaseContainer myContainer = null; + private int IIcon = -1; + private hasCalculatedValidness isValid; + private boolean isDisplay = false; - private final int defX; - private final int defY; - private boolean isDraggable = true; - private boolean isPlayerSide = false; - private AEBaseContainer myContainer = null; - private int IIcon = -1; - private hasCalculatedValidness isValid; - private boolean isDisplay = false; + public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) { + super(emptyInventory, idx, x, y); + this.itemHandler = inv; + this.index = idx; - public AppEngSlot( final IItemHandler inv, final int idx, final int x, final int y ) - { - super( emptyInventory, idx, x, y ); - this.itemHandler = inv; - this.index = idx; + this.defX = x; + this.defY = y; + this.setIsValid(hasCalculatedValidness.NotAvailable); + } - this.defX = x; - this.defY = y; - this.setIsValid( hasCalculatedValidness.NotAvailable ); - } + public Slot setNotDraggable() { + this.setDraggable(false); + return this; + } - public Slot setNotDraggable() - { - this.setDraggable( false ); - return this; - } + public Slot setPlayerSide() { + this.isPlayerSide = true; + return this; + } - public Slot setPlayerSide() - { - this.isPlayerSide = true; - return this; - } + public String getTooltip() { + return null; + } - public String getTooltip() - { - return null; - } + public void clearStack() { + ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, ItemStack.EMPTY); + } - public void clearStack() - { - ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, ItemStack.EMPTY ); - } + @Override + public boolean isItemValid(@Nonnull final ItemStack par1ItemStack) { + if (this.isSlotEnabled()) { + return this.itemHandler.isItemValid(this.index, par1ItemStack); + } + return false; + } - @Override - public boolean isItemValid( @Nonnull final ItemStack par1ItemStack ) - { - if( this.isSlotEnabled() ) - { - return this.itemHandler.isItemValid( this.index, par1ItemStack ); - } - return false; - } + @Override + @Nonnull + public ItemStack getStack() { + if (!this.isSlotEnabled()) { + return ItemStack.EMPTY; + } - @Override - @Nonnull - public ItemStack getStack() - { - if( !this.isSlotEnabled() ) - { - return ItemStack.EMPTY; - } + if (this.itemHandler.getSlots() <= this.getSlotIndex()) { + return ItemStack.EMPTY; + } - if( this.itemHandler.getSlots() <= this.getSlotIndex() ) - { - return ItemStack.EMPTY; - } + if (this.isDisplay()) { + this.setDisplay(false); + return this.getDisplayStack(); + } - if( this.isDisplay() ) - { - this.setDisplay( false ); - return this.getDisplayStack(); - } + return this.itemHandler.getStackInSlot(this.index); + } - return this.itemHandler.getStackInSlot( this.index ); - } + @Override + public void putStack(final ItemStack stack) { + if (this.isSlotEnabled()) { + ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, stack); - @Override - public void putStack( final ItemStack stack ) - { - if( this.isSlotEnabled() ) - { - ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack ); + if (this.getContainer() != null) { + this.getContainer().onSlotChange(this); + } + } + } - if( this.getContainer() != null ) - { - this.getContainer().onSlotChange( this ); - } - } - } + public IItemHandler getItemHandler() { + return this.itemHandler; + } - public IItemHandler getItemHandler() - { - return this.itemHandler; - } + @Override + public void onSlotChanged() { + this.setIsValid(hasCalculatedValidness.NotAvailable); + } - @Override - public void onSlotChanged() - { - this.setIsValid( hasCalculatedValidness.NotAvailable ); - } + @Override + public int getSlotStackLimit() { + return this.itemHandler.getSlotLimit(this.index); + } - @Override - public int getSlotStackLimit() - { - return this.itemHandler.getSlotLimit( this.index ); - } + @Override + public int getItemStackLimit(@Nonnull ItemStack stack) { + return Math.min(this.getSlotStackLimit(), stack.getMaxStackSize()); + } - @Override - public int getItemStackLimit( @Nonnull ItemStack stack ) - { - return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() ); - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + if (this.isSlotEnabled()) { + return !this.itemHandler.extractItem(this.index, 1, true).isEmpty(); + } + return false; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - if( this.isSlotEnabled() ) - { - return !this.itemHandler.extractItem( this.index, 1, true ).isEmpty(); - } - return false; - } + @Override + @Nonnull + public ItemStack decrStackSize(int amount) { + return this.itemHandler.extractItem(this.index, amount, false); + } - @Override - @Nonnull - public ItemStack decrStackSize( int amount ) - { - return this.itemHandler.extractItem( this.index, amount, false ); - } + @Override + public boolean isSameInventory(Slot other) { + return other instanceof AppEngSlot && ((AppEngSlot) other).itemHandler == this.itemHandler; + } - @Override - public boolean isSameInventory( Slot other ) - { - return other instanceof AppEngSlot && ( (AppEngSlot) other ).itemHandler == this.itemHandler; - } + @Override + @OnlyIn(Dist.CLIENT) + public boolean isEnabled() { + return this.isSlotEnabled(); + } - @Override - @OnlyIn( Dist.CLIENT ) - public boolean isEnabled() - { - return this.isSlotEnabled(); - } + public boolean isSlotEnabled() { + return true; + } - public boolean isSlotEnabled() - { - return true; - } + public ItemStack getDisplayStack() { + return this.itemHandler.getStackInSlot(this.index); + } - public ItemStack getDisplayStack() - { - return this.itemHandler.getStackInSlot( this.index ); - } + public float getOpacityOfIcon() { + return 0.4f; + } - public float getOpacityOfIcon() - { - return 0.4f; - } + public boolean renderIconWithItem() { + return false; + } - public boolean renderIconWithItem() - { - return false; - } + public int getIcon() { + return this.getIIcon(); + } - public int getIcon() - { - return this.getIIcon(); - } + public boolean isPlayerSide() { + return this.isPlayerSide; + } - public boolean isPlayerSide() - { - return this.isPlayerSide; - } + public boolean shouldDisplay() { + return this.isSlotEnabled(); + } - public boolean shouldDisplay() - { - return this.isSlotEnabled(); - } + public int getX() { + return this.defX; + } - public int getX() - { - return this.defX; - } + public int getY() { + return this.defY; + } - public int getY() - { - return this.defY; - } + private int getIIcon() { + return this.IIcon; + } - private int getIIcon() - { - return this.IIcon; - } + public void setIIcon(final int iIcon) { + this.IIcon = iIcon; + } - public void setIIcon( final int iIcon ) - { - this.IIcon = iIcon; - } + private boolean isDisplay() { + return this.isDisplay; + } - private boolean isDisplay() - { - return this.isDisplay; - } + public void setDisplay(final boolean isDisplay) { + this.isDisplay = isDisplay; + } - public void setDisplay( final boolean isDisplay ) - { - this.isDisplay = isDisplay; - } + public boolean isDraggable() { + return this.isDraggable; + } - public boolean isDraggable() - { - return this.isDraggable; - } + private void setDraggable(final boolean isDraggable) { + this.isDraggable = isDraggable; + } - private void setDraggable( final boolean isDraggable ) - { - this.isDraggable = isDraggable; - } + void setPlayerSide(final boolean isPlayerSide) { + this.isPlayerSide = isPlayerSide; + } - void setPlayerSide( final boolean isPlayerSide ) - { - this.isPlayerSide = isPlayerSide; - } + public hasCalculatedValidness getIsValid() { + return this.isValid; + } - public hasCalculatedValidness getIsValid() - { - return this.isValid; - } + public void setIsValid(final hasCalculatedValidness isValid) { + this.isValid = isValid; + } - public void setIsValid( final hasCalculatedValidness isValid ) - { - this.isValid = isValid; - } + protected AEBaseContainer getContainer() { + return this.myContainer; + } - protected AEBaseContainer getContainer() - { - return this.myContainer; - } + public void setContainer(final AEBaseContainer myContainer) { + this.myContainer = myContainer; + } - public void setContainer( final AEBaseContainer myContainer ) - { - this.myContainer = myContainer; - } - - public enum hasCalculatedValidness - { - NotAvailable, Valid, Invalid - } + public enum hasCalculatedValidness { + NotAvailable, Valid, Invalid + } } diff --git a/src/main/java/appeng/container/slot/IOptionalSlot.java b/src/main/java/appeng/container/slot/IOptionalSlot.java index 727b6a2f2..634fc7206 100644 --- a/src/main/java/appeng/container/slot/IOptionalSlot.java +++ b/src/main/java/appeng/container/slot/IOptionalSlot.java @@ -18,20 +18,17 @@ package appeng.container.slot; - /** * @author BrockWS * @version rv6 - 2/05/2018 * @since rv6 2/05/2018 */ -public interface IOptionalSlot -{ - default boolean isRenderDisabled() - { - return false; - } +public interface IOptionalSlot { + default boolean isRenderDisabled() { + return false; + } - int getSourceX(); + int getSourceX(); - int getSourceY(); + int getSourceY(); } diff --git a/src/main/java/appeng/container/slot/IOptionalSlotHost.java b/src/main/java/appeng/container/slot/IOptionalSlotHost.java index 995959ce0..72102091b 100644 --- a/src/main/java/appeng/container/slot/IOptionalSlotHost.java +++ b/src/main/java/appeng/container/slot/IOptionalSlotHost.java @@ -18,9 +18,7 @@ package appeng.container.slot; +public interface IOptionalSlotHost { -public interface IOptionalSlotHost -{ - - boolean isSlotEnabled( int idx ); + boolean isSlotEnabled(int idx); } diff --git a/src/main/java/appeng/container/slot/NullSlot.java b/src/main/java/appeng/container/slot/NullSlot.java index a1e2e84ce..40a492af8 100644 --- a/src/main/java/appeng/container/slot/NullSlot.java +++ b/src/main/java/appeng/container/slot/NullSlot.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import javax.annotation.Nonnull; import net.minecraft.entity.player.PlayerEntity; @@ -26,72 +25,60 @@ import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; // FIXME seems unused -public class NullSlot extends Slot -{ +public class NullSlot extends Slot { - public NullSlot() - { - super( null, 0, 0, 0 ); - } + public NullSlot() { + super(null, 0, 0, 0); + } - @Override - public void onSlotChange( final ItemStack par1ItemStack, final ItemStack par2ItemStack ) - { + @Override + public void onSlotChange(final ItemStack par1ItemStack, final ItemStack par2ItemStack) { - } + } - @Override - public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack ) - { - return par2ItemStack; - } + @Override + public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) { + return par2ItemStack; + } - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - @Override - @Nonnull - public ItemStack getStack() - { - return ItemStack.EMPTY; - } + @Override + @Nonnull + public ItemStack getStack() { + return ItemStack.EMPTY; + } - @Override - public void putStack( final ItemStack par1ItemStack ) - { + @Override + public void putStack(final ItemStack par1ItemStack) { - } + } - @Override - public void onSlotChanged() - { + @Override + public void onSlotChanged() { - } + } - @Override - public int getSlotStackLimit() - { - return 0; - } + @Override + public int getSlotStackLimit() { + return 0; + } - @Override - public ItemStack decrStackSize( final int par1 ) - { - return ItemStack.EMPTY; - } + @Override + public ItemStack decrStackSize(final int par1) { + return ItemStack.EMPTY; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } - @Override - public int getSlotIndex() - { - return 0; - } + @Override + public int getSlotIndex() { + return 0; + } } diff --git a/src/main/java/appeng/container/slot/OptionalSlotFake.java b/src/main/java/appeng/container/slot/OptionalSlotFake.java index b187c4503..db6513aa9 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFake.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFake.java @@ -18,77 +18,65 @@ package appeng.container.slot; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class OptionalSlotFake extends SlotFake implements IOptionalSlot { -public class OptionalSlotFake extends SlotFake implements IOptionalSlot -{ + private final int srcX; + private final int srcY; + private final int groupNum; + private final IOptionalSlotHost host; + private boolean renderDisabled = true; - private final int srcX; - private final int srcY; - private final int groupNum; - private final IOptionalSlotHost host; - private boolean renderDisabled = true; + public OptionalSlotFake(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, + final int y, final int offX, final int offY, final int groupNum) { + super(inv, idx, x + offX * 18, y + offY * 18); + this.srcX = x; + this.srcY = y; + this.groupNum = groupNum; + this.host = containerBus; + } - public OptionalSlotFake( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum ) - { - super( inv, idx, x + offX * 18, y + offY * 18 ); - this.srcX = x; - this.srcY = y; - this.groupNum = groupNum; - this.host = containerBus; - } + @Override + @Nonnull + public ItemStack getStack() { + if (!this.isSlotEnabled()) { + if (!this.getDisplayStack().isEmpty()) { + this.clearStack(); + } + } - @Override - @Nonnull - public ItemStack getStack() - { - if( !this.isSlotEnabled() ) - { - if( !this.getDisplayStack().isEmpty() ) - { - this.clearStack(); - } - } + return super.getStack(); + } - return super.getStack(); - } + @Override + public boolean isSlotEnabled() { + if (this.host == null) { + return false; + } - @Override - public boolean isSlotEnabled() - { - if( this.host == null ) - { - return false; - } + return this.host.isSlotEnabled(this.groupNum); + } - return this.host.isSlotEnabled( this.groupNum ); - } + @Override + public boolean isRenderDisabled() { + return this.renderDisabled; + } - @Override - public boolean isRenderDisabled() - { - return this.renderDisabled; - } + public void setRenderDisabled(final boolean renderDisabled) { + this.renderDisabled = renderDisabled; + } - public void setRenderDisabled( final boolean renderDisabled ) - { - this.renderDisabled = renderDisabled; - } + @Override + public int getSourceX() { + return this.srcX; + } - @Override - public int getSourceX() - { - return this.srcX; - } - - @Override - public int getSourceY() - { - return this.srcY; - } + @Override + public int getSourceY() { + return this.srcY; + } } diff --git a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java index 7c86c8b53..1030f0a93 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java @@ -18,35 +18,27 @@ package appeng.container.slot; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class OptionalSlotFakeTypeOnly extends OptionalSlotFake { -public class OptionalSlotFakeTypeOnly extends OptionalSlotFake -{ + public OptionalSlotFakeTypeOnly(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, + final int x, final int y, final int offX, final int offY, final int groupNum) { + super(inv, containerBus, idx, x, y, offX, offY, groupNum); + } - public OptionalSlotFakeTypeOnly( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum ) - { - super( inv, containerBus, idx, x, y, offX, offY, groupNum ); - } + @Override + public void putStack(ItemStack is) { + if (!is.isEmpty()) { + is = is.copy(); + if (is.getCount() > 1) { + is.setCount(1); + } else if (is.getCount() < -1) { + is.setCount(-1); + } + } - @Override - public void putStack( ItemStack is ) - { - if( !is.isEmpty() ) - { - is = is.copy(); - if( is.getCount() > 1 ) - { - is.setCount( 1 ); - } - else if( is.getCount() < -1 ) - { - is.setCount( -1 ); - } - } - - super.putStack( is ); - } + super.putStack(is); + } } diff --git a/src/main/java/appeng/container/slot/OptionalSlotNormal.java b/src/main/java/appeng/container/slot/OptionalSlotNormal.java index 44d4edd37..3a5e065b7 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotNormal.java +++ b/src/main/java/appeng/container/slot/OptionalSlotNormal.java @@ -18,43 +18,36 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot { -public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot -{ + private final int groupNum; + private final IOptionalSlotHost host; - private final int groupNum; - private final IOptionalSlotHost host; + public OptionalSlotNormal(final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot, + final int xPos, final int yPos, final int groupNum) { + super(inv, slot, xPos, yPos); + this.groupNum = groupNum; + this.host = containerBus; + } - public OptionalSlotNormal( final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot, final int xPos, final int yPos, final int groupNum ) - { - super( inv, slot, xPos, yPos ); - this.groupNum = groupNum; - this.host = containerBus; - } + @Override + public boolean isSlotEnabled() { + if (this.host == null) { + return false; + } - @Override - public boolean isSlotEnabled() - { - if( this.host == null ) - { - return false; - } + return this.host.isSlotEnabled(this.groupNum); + } - return this.host.isSlotEnabled( this.groupNum ); - } + @Override + public int getSourceX() { + return this.xPos; + } - @Override - public int getSourceX() - { - return this.xPos; - } - - @Override - public int getSourceY() - { - return this.yPos; - } + @Override + public int getSourceY() { + return this.yPos; + } } diff --git a/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java b/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java index 548bab895..b442fd1b3 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java @@ -18,32 +18,27 @@ package appeng.container.slot; - import net.minecraft.entity.player.PlayerInventory; import net.minecraftforge.items.IItemHandler; +public class OptionalSlotRestrictedInput extends SlotRestrictedInput { -public class OptionalSlotRestrictedInput extends SlotRestrictedInput -{ + private final int groupNum; + private final IOptionalSlotHost host; - private final int groupNum; - private final IOptionalSlotHost host; + public OptionalSlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host, + final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) { + super(valid, i, slotIndex, x, y, invPlayer); + this.groupNum = grpNum; + this.host = host; + } - public OptionalSlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host, final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer ) - { - super( valid, i, slotIndex, x, y, invPlayer ); - this.groupNum = grpNum; - this.host = host; - } + @Override + public boolean isSlotEnabled() { + if (this.host == null) { + return false; + } - @Override - public boolean isSlotEnabled() - { - if( this.host == null ) - { - return false; - } - - return this.host.isSlotEnabled( this.groupNum ); - } + return this.host.isSlotEnabled(this.groupNum); + } } diff --git a/src/main/java/appeng/container/slot/SlotCraftingMatrix.java b/src/main/java/appeng/container/slot/SlotCraftingMatrix.java index e33dff30f..9ad28e7bc 100644 --- a/src/main/java/appeng/container/slot/SlotCraftingMatrix.java +++ b/src/main/java/appeng/container/slot/SlotCraftingMatrix.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -26,44 +25,38 @@ import net.minecraftforge.items.IItemHandler; import appeng.container.AEBaseContainer; import appeng.util.inv.WrapperInvItemHandler; +public class SlotCraftingMatrix extends AppEngSlot { + private final AEBaseContainer c; + private final IInventory wrappedInventory; -public class SlotCraftingMatrix extends AppEngSlot -{ - private final AEBaseContainer c; - private final IInventory wrappedInventory; + public SlotCraftingMatrix(final AEBaseContainer c, final IItemHandler par1iInventory, final int par2, + final int par3, final int par4) { + super(par1iInventory, par2, par3, par4); + this.c = c; + this.wrappedInventory = new WrapperInvItemHandler(par1iInventory); + } - public SlotCraftingMatrix( final AEBaseContainer c, final IItemHandler par1iInventory, final int par2, final int par3, final int par4 ) - { - super( par1iInventory, par2, par3, par4 ); - this.c = c; - this.wrappedInventory = new WrapperInvItemHandler( par1iInventory ); - } + @Override + public void clearStack() { + super.clearStack(); + this.c.onCraftMatrixChanged(this.wrappedInventory); + } - @Override - public void clearStack() - { - super.clearStack(); - this.c.onCraftMatrixChanged( this.wrappedInventory ); - } + @Override + public void putStack(final ItemStack par1ItemStack) { + super.putStack(par1ItemStack); + this.c.onCraftMatrixChanged(this.wrappedInventory); + } - @Override - public void putStack( final ItemStack par1ItemStack ) - { - super.putStack( par1ItemStack ); - this.c.onCraftMatrixChanged( this.wrappedInventory ); - } + @Override + public boolean isPlayerSide() { + return true; + } - @Override - public boolean isPlayerSide() - { - return true; - } - - @Override - public ItemStack decrStackSize( final int par1 ) - { - final ItemStack is = super.decrStackSize( par1 ); - this.c.onCraftMatrixChanged( this.wrappedInventory ); - return is; - } + @Override + public ItemStack decrStackSize(final int par1) { + final ItemStack is = super.decrStackSize(par1); + this.c.onCraftMatrixChanged(this.wrappedInventory); + return is; + } } diff --git a/src/main/java/appeng/container/slot/SlotCraftingTerm.java b/src/main/java/appeng/container/slot/SlotCraftingTerm.java index 42f59de6e..5d0b15494 100644 --- a/src/main/java/appeng/container/slot/SlotCraftingTerm.java +++ b/src/main/java/appeng/container/slot/SlotCraftingTerm.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -56,277 +55,239 @@ import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperInvItemHandler; import appeng.util.item.AEItemStack; +public class SlotCraftingTerm extends AppEngCraftingSlot { -public class SlotCraftingTerm extends AppEngCraftingSlot -{ + private final IItemHandler craftInv; + private final IItemHandler pattern; - private final IItemHandler craftInv; - private final IItemHandler pattern; + private final IActionSource mySrc; + private final IEnergySource energySrc; + private final IStorageMonitorable storage; + private final IContainerCraftingPacket container; - private final IActionSource mySrc; - private final IEnergySource energySrc; - private final IStorageMonitorable storage; - private final IContainerCraftingPacket container; + public SlotCraftingTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, + final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, + final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp) { + super(player, cMatrix, output, 0, x, y); + this.energySrc = energySrc; + this.storage = storage; + this.mySrc = mySrc; + this.pattern = cMatrix; + this.craftInv = secondMatrix; + this.container = ccp; + } - public SlotCraftingTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp ) - { - super( player, cMatrix, output, 0, x, y ); - this.energySrc = energySrc; - this.storage = storage; - this.mySrc = mySrc; - this.pattern = cMatrix; - this.craftInv = secondMatrix; - this.container = ccp; - } + public IItemHandler getCraftingMatrix() { + return this.craftInv; + } - public IItemHandler getCraftingMatrix() - { - return this.craftInv; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public ItemStack onTake(final PlayerEntity p, final ItemStack is) { + return is; + } - @Override - public ItemStack onTake( final PlayerEntity p, final ItemStack is ) - { - return is; - } + public void doClick(final InventoryAction action, final PlayerEntity who) { + if (this.getStack().isEmpty()) { + return; + } + if (Platform.isClient()) { + return; + } - public void doClick( final InventoryAction action, final PlayerEntity who ) - { - if( this.getStack().isEmpty() ) - { - return; - } - if( Platform.isClient() ) - { - return; - } + final IMEMonitor inv = this.storage + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final int howManyPerCraft = this.getStack().getCount(); + int maxTimesToCraft = 0; - final IMEMonitor inv = this.storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final int howManyPerCraft = this.getStack().getCount(); - int maxTimesToCraft = 0; + InventoryAdaptor ia = null; + if (action == InventoryAction.CRAFT_SHIFT) // craft into player inventory... + { + ia = InventoryAdaptor.getAdaptor(who); + maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); + } else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack + { + ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory)); + maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); + } else + // pick up what was crafted... + { + ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory)); + maxTimesToCraft = 1; + } - InventoryAdaptor ia = null; - if( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory... - { - ia = InventoryAdaptor.getAdaptor( who ); - maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft ); - } - else if( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack - { - ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) ); - maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft ); - } - else - // pick up what was crafted... - { - ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) ); - maxTimesToCraft = 1; - } + maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft); - maxTimesToCraft = this.capCraftingAttempts( maxTimesToCraft ); + if (ia == null) { + return; + } - if( ia == null ) - { - return; - } + final ItemStack rs = this.getStack().copy(); + if (rs.isEmpty()) { + return; + } - final ItemStack rs = this.getStack().copy(); - if( rs.isEmpty() ) - { - return; - } + for (int x = 0; x < maxTimesToCraft; x++) { + if (ia.simulateAdd(rs).isEmpty()) { + final IItemList all = inv.getStorageList(); + final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all)); + if (!extra.isEmpty()) { + final List drops = new ArrayList<>(); + drops.add(extra); + Platform.spawnDrops(who.world, + new BlockPos((int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ()), drops); + return; + } + } + } + } - for( int x = 0; x < maxTimesToCraft; x++ ) - { - if( ia.simulateAdd( rs ).isEmpty() ) - { - final IItemList all = inv.getStorageList(); - final ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) ); - if( !extra.isEmpty() ) - { - final List drops = new ArrayList<>(); - drops.add( extra ); - Platform.spawnDrops( who.world, new BlockPos( (int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ() ), drops ); - return; - } - } - } - } + // TODO: This is really hacky and NEEDS to be solved with a full container/gui + // refactoring. + protected IRecipe findRecipe(CraftingInventory ic, World world) { + if (this.container instanceof ContainerCraftingTerm) { + final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container; + final IRecipe recipe = containerTerminal.getCurrentRecipe(); - // TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring. - protected IRecipe findRecipe( CraftingInventory ic, World world ) - { - if( this.container instanceof ContainerCraftingTerm ) - { - final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container; - final IRecipe recipe = containerTerminal.getCurrentRecipe(); + if (recipe != null && recipe.matches(ic, world)) { + return containerTerminal.getCurrentRecipe(); + } + } - if( recipe != null && recipe.matches( ic, world ) ) - { - return containerTerminal.getCurrentRecipe(); - } - } + return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null); + } - return world.getRecipeManager().getRecipe( IRecipeType.CRAFTING, ic, world ).orElse(null); - } + // TODO: This is really hacky and NEEDS to be solved with a full container/gui + // refactoring. + @Override + protected NonNullList getRemainingItems(CraftingInventory ic, World world) { + if (this.container instanceof ContainerCraftingTerm) { + final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container; + final IRecipe recipe = containerTerminal.getCurrentRecipe(); - // TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring. - @Override - protected NonNullList getRemainingItems( CraftingInventory ic, World world ) - { - if( this.container instanceof ContainerCraftingTerm ) - { - final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container; - final IRecipe recipe = containerTerminal.getCurrentRecipe(); + if (recipe != null && recipe.matches(ic, world)) { + return containerTerminal.getCurrentRecipe().getRemainingItems(ic); + } + } - if( recipe != null && recipe.matches( ic, world ) ) - { - return containerTerminal.getCurrentRecipe().getRemainingItems( ic ); - } - } + return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).map(r -> r.getRemainingItems(ic)) + .orElse(NonNullList.create()); + } - return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world) - .map(r -> r.getRemainingItems(ic)) - .orElse(NonNullList.create()); - } + private int capCraftingAttempts(final int maxTimesToCraft) { + return maxTimesToCraft; + } - private int capCraftingAttempts( final int maxTimesToCraft ) - { - return maxTimesToCraft; - } + private ItemStack craftItem(final PlayerEntity p, final ItemStack request, final IMEMonitor inv, + final IItemList all) { + // update crafting matrix... + ItemStack is = this.getStack(); - private ItemStack craftItem( final PlayerEntity p, final ItemStack request, final IMEMonitor inv, final IItemList all ) - { - // update crafting matrix... - ItemStack is = this.getStack(); + if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) { + final ItemStack[] set = new ItemStack[this.getPattern().getSlots()]; + // Safeguard for empty slots in the inventory for now + Arrays.fill(set, ItemStack.EMPTY); - if( !is.isEmpty() && ItemStack.areItemsEqual( request, is ) ) - { - final ItemStack[] set = new ItemStack[this.getPattern().getSlots()]; - // Safeguard for empty slots in the inventory for now - Arrays.fill( set, ItemStack.EMPTY ); + // add one of each item to the items on the board... + if (Platform.isServer()) { + final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); + for (int x = 0; x < 9; x++) { + ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x)); + } - // add one of each item to the items on the board... - if( Platform.isServer() ) - { - final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 ); - for( int x = 0; x < 9; x++ ) - { - ic.setInventorySlotContents( x, this.getPattern().getStackInSlot( x ) ); - } + final IRecipe r = this.findRecipe(ic, p.world); - final IRecipe r = this.findRecipe( ic, p.world ); + if (r == null) { + final Item target = request.getItem(); + if (target.isDamageable() && target.isRepairable(request)) { + boolean isBad = false; + for (int x = 0; x < ic.getSizeInventory(); x++) { + final ItemStack pis = ic.getStackInSlot(x); + if (pis.isEmpty()) { + continue; + } + if (pis.getItem() != target) { + isBad = true; + } + } + if (!isBad) { + super.onTake(p, is); + // actually necessary to cleanup this case... + p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv)); + return request; + } + } + return ItemStack.EMPTY; + } - if( r == null ) - { - final Item target = request.getItem(); - if( target.isDamageable() && target.isRepairable(request) ) - { - boolean isBad = false; - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - final ItemStack pis = ic.getStackInSlot( x ); - if( pis.isEmpty() ) - { - continue; - } - if( pis.getItem() != target ) - { - isBad = true; - } - } - if( !isBad ) - { - super.onTake( p, is ); - // actually necessary to cleanup this case... - p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) ); - return request; - } - } - return ItemStack.EMPTY; - } + is = r.getCraftingResult(ic); - is = r.getCraftingResult( ic ); + if (inv != null) { + for (int x = 0; x < this.getPattern().getSlots(); x++) { + if (!this.getPattern().getStackInSlot(x).isEmpty()) { + set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic, + this.getPattern().getStackInSlot(x), x, all, Actionable.MODULATE, + ItemViewCell.createFilter(this.container.getViewCells())); + ic.setInventorySlotContents(x, set[x]); + } + } + } + } - if( inv != null ) - { - for( int x = 0; x < this.getPattern().getSlots(); x++ ) - { - if( !this.getPattern().getStackInSlot( x ).isEmpty() ) - { - set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.world, r, is, ic, this.getPattern().getStackInSlot( x ), - x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) ); - ic.setInventorySlotContents( x, set[x] ); - } - } - } - } + if (this.preCraft(p, inv, set, is)) { + this.makeItem(p, is); - if( this.preCraft( p, inv, set, is ) ) - { - this.makeItem( p, is ); + this.postCraft(p, inv, set, is); + } - this.postCraft( p, inv, set, is ); - } + p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv)); - p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) ); + return is; + } - return is; - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + private boolean preCraft(final PlayerEntity p, final IMEMonitor inv, final ItemStack[] set, + final ItemStack result) { + return true; + } - private boolean preCraft( final PlayerEntity p, final IMEMonitor inv, final ItemStack[] set, final ItemStack result ) - { - return true; - } + private void makeItem(final PlayerEntity p, final ItemStack is) { + super.onTake(p, is); + } - private void makeItem( final PlayerEntity p, final ItemStack is ) - { - super.onTake( p, is ); - } + private void postCraft(final PlayerEntity p, final IMEMonitor inv, final ItemStack[] set, + final ItemStack result) { + final List drops = new ArrayList<>(); - private void postCraft( final PlayerEntity p, final IMEMonitor inv, final ItemStack[] set, final ItemStack result ) - { - final List drops = new ArrayList<>(); + // add one of each item to the items on the board... + if (Platform.isServer()) { + // set new items onto the crafting table... + for (int x = 0; x < this.craftInv.getSlots(); x++) { + if (this.craftInv.getStackInSlot(x).isEmpty()) { + ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]); + } else if (!set[x].isEmpty()) { + // eek! put it back! + final IAEItemStack fail = inv.injectItems(AEItemStack.fromItemStack(set[x]), Actionable.MODULATE, + this.mySrc); + if (fail != null) { + drops.add(fail.createItemStack()); + } + } + } + } - // add one of each item to the items on the board... - if( Platform.isServer() ) - { - // set new items onto the crafting table... - for( int x = 0; x < this.craftInv.getSlots(); x++ ) - { - if( this.craftInv.getStackInSlot( x ).isEmpty() ) - { - ItemHandlerUtil.setStackInSlot( this.craftInv, x, set[x] ); - } - else if( !set[x].isEmpty() ) - { - // eek! put it back! - final IAEItemStack fail = inv.injectItems( AEItemStack.fromItemStack( set[x] ), Actionable.MODULATE, this.mySrc ); - if( fail != null ) - { - drops.add( fail.createItemStack() ); - } - } - } - } + if (drops.size() > 0) { + Platform.spawnDrops(p.world, new BlockPos((int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ()), drops); + } + } - if( drops.size() > 0 ) - { - Platform.spawnDrops( p.world, new BlockPos( (int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ() ), drops ); - } - } - - IItemHandler getPattern() - { - return this.pattern; - } + IItemHandler getPattern() { + return this.pattern; + } } diff --git a/src/main/java/appeng/container/slot/SlotDisabled.java b/src/main/java/appeng/container/slot/SlotDisabled.java index 46c37b1eb..6ed1690c4 100644 --- a/src/main/java/appeng/container/slot/SlotDisabled.java +++ b/src/main/java/appeng/container/slot/SlotDisabled.java @@ -18,29 +18,23 @@ package appeng.container.slot; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class SlotDisabled extends AppEngSlot { -public class SlotDisabled extends AppEngSlot -{ + public SlotDisabled(final IItemHandler par1iInventory, final int slotIndex, final int x, final int y) { + super(par1iInventory, slotIndex, x, y); + } - public SlotDisabled( final IItemHandler par1iInventory, final int slotIndex, final int x, final int y ) - { - super( par1iInventory, slotIndex, x, y ); - } + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } - - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } } diff --git a/src/main/java/appeng/container/slot/SlotFake.java b/src/main/java/appeng/container/slot/SlotFake.java index e6c8c0002..f8cd8a715 100644 --- a/src/main/java/appeng/container/slot/SlotFake.java +++ b/src/main/java/appeng/container/slot/SlotFake.java @@ -18,52 +18,42 @@ package appeng.container.slot; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class SlotFake extends AppEngSlot { -public class SlotFake extends AppEngSlot -{ + public SlotFake(final IItemHandler inv, final int idx, final int x, final int y) { + super(inv, idx, x, y); + } - public SlotFake( final IItemHandler inv, final int idx, final int x, final int y ) - { - super( inv, idx, x, y ); - } + @Override + public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) { + return par2ItemStack; + } - @Override - public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack ) - { - return par2ItemStack; - } + @Override + public ItemStack decrStackSize(final int par1) { + return ItemStack.EMPTY; + } - @Override - public ItemStack decrStackSize( final int par1 ) - { - return ItemStack.EMPTY; - } + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - @Override - public boolean isItemValid( final ItemStack par1ItemStack ) - { - return false; - } + @Override + public void putStack(ItemStack is) { + if (!is.isEmpty()) { + is = is.copy(); + } - @Override - public void putStack( ItemStack is ) - { - if( !is.isEmpty() ) - { - is = is.copy(); - } + super.putStack(is); + } - super.putStack( is ); - } - - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } } diff --git a/src/main/java/appeng/container/slot/SlotFakeBlacklist.java b/src/main/java/appeng/container/slot/SlotFakeBlacklist.java index e13318a47..a6cffd5cd 100644 --- a/src/main/java/appeng/container/slot/SlotFakeBlacklist.java +++ b/src/main/java/appeng/container/slot/SlotFakeBlacklist.java @@ -18,37 +18,29 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotFakeBlacklist extends SlotFakeTypeOnly { -public class SlotFakeBlacklist extends SlotFakeTypeOnly -{ + public SlotFakeBlacklist(final IItemHandler inv, final int idx, final int x, final int y) { + super(inv, idx, x, y); + } - public SlotFakeBlacklist( final IItemHandler inv, final int idx, final int x, final int y ) - { - super( inv, idx, x, y ); - } + @Override + public float getOpacityOfIcon() { + return 0.8f; + } - @Override - public float getOpacityOfIcon() - { - return 0.8f; - } + @Override + public boolean renderIconWithItem() { + return true; + } - @Override - public boolean renderIconWithItem() - { - return true; - } - - @Override - public int getIcon() - { - if( this.getHasStack() ) - { - return this.getStack().getCount() > 0 ? 16 + 14 : 14; - } - return -1; - } + @Override + public int getIcon() { + if (this.getHasStack()) { + return this.getStack().getCount() > 0 ? 16 + 14 : 14; + } + return -1; + } } diff --git a/src/main/java/appeng/container/slot/SlotFakeCraftingMatrix.java b/src/main/java/appeng/container/slot/SlotFakeCraftingMatrix.java index f92cd4a99..390ca8602 100644 --- a/src/main/java/appeng/container/slot/SlotFakeCraftingMatrix.java +++ b/src/main/java/appeng/container/slot/SlotFakeCraftingMatrix.java @@ -18,15 +18,11 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotFakeCraftingMatrix extends SlotFake { -public class SlotFakeCraftingMatrix extends SlotFake -{ - - public SlotFakeCraftingMatrix( final IItemHandler inv, final int idx, final int x, final int y ) - { - super( inv, idx, x, y ); - } + public SlotFakeCraftingMatrix(final IItemHandler inv, final int idx, final int x, final int y) { + super(inv, idx, x, y); + } } diff --git a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java index d93c0a183..d4c9f6640 100644 --- a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java @@ -18,35 +18,26 @@ package appeng.container.slot; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class SlotFakeTypeOnly extends SlotFake { -public class SlotFakeTypeOnly extends SlotFake -{ + public SlotFakeTypeOnly(final IItemHandler inv, final int idx, final int x, final int y) { + super(inv, idx, x, y); + } - public SlotFakeTypeOnly( final IItemHandler inv, final int idx, final int x, final int y ) - { - super( inv, idx, x, y ); - } + @Override + public void putStack(ItemStack is) { + if (!is.isEmpty()) { + is = is.copy(); + if (is.getCount() > 1) { + is.setCount(1); + } else if (is.getCount() < -1) { + is.setCount(-1); + } + } - @Override - public void putStack( ItemStack is ) - { - if( !is.isEmpty() ) - { - is = is.copy(); - if( is.getCount() > 1 ) - { - is.setCount( 1 ); - } - else if( is.getCount() < -1 ) - { - is.setCount( -1 ); - } - } - - super.putStack( is ); - } + super.putStack(is); + } } diff --git a/src/main/java/appeng/container/slot/SlotInaccessible.java b/src/main/java/appeng/container/slot/SlotInaccessible.java index 3776ade38..23321d0bc 100644 --- a/src/main/java/appeng/container/slot/SlotInaccessible.java +++ b/src/main/java/appeng/container/slot/SlotInaccessible.java @@ -18,52 +18,42 @@ package appeng.container.slot; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class SlotInaccessible extends AppEngSlot { -public class SlotInaccessible extends AppEngSlot -{ + private ItemStack dspStack = ItemStack.EMPTY; - private ItemStack dspStack = ItemStack.EMPTY; + public SlotInaccessible(final IItemHandler i, final int slotIdx, final int x, final int y) { + super(i, slotIdx, x, y); + } - public SlotInaccessible( final IItemHandler i, final int slotIdx, final int x, final int y ) - { - super( i, slotIdx, x, y ); - } + @Override + public boolean isItemValid(final ItemStack i) { + return false; + } - @Override - public boolean isItemValid( final ItemStack i ) - { - return false; - } + @Override + public void onSlotChanged() { + super.onSlotChanged(); + this.dspStack = ItemStack.EMPTY; + } - @Override - public void onSlotChanged() - { - super.onSlotChanged(); - this.dspStack = ItemStack.EMPTY; - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return false; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return false; - } - - @Override - public ItemStack getDisplayStack() - { - if( this.dspStack.isEmpty() ) - { - final ItemStack dsp = super.getDisplayStack(); - if( !dsp.isEmpty() ) - { - this.dspStack = dsp.copy(); - } - } - return this.dspStack; - } + @Override + public ItemStack getDisplayStack() { + if (this.dspStack.isEmpty()) { + final ItemStack dsp = super.getDisplayStack(); + if (!dsp.isEmpty()) { + this.dspStack = dsp.copy(); + } + } + return this.dspStack; + } } diff --git a/src/main/java/appeng/container/slot/SlotInaccessibleHD.java b/src/main/java/appeng/container/slot/SlotInaccessibleHD.java index b95a62e7c..c1519fa11 100644 --- a/src/main/java/appeng/container/slot/SlotInaccessibleHD.java +++ b/src/main/java/appeng/container/slot/SlotInaccessibleHD.java @@ -18,15 +18,11 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotInaccessibleHD extends SlotInaccessible { -public class SlotInaccessibleHD extends SlotInaccessible -{ - - public SlotInaccessibleHD( final IItemHandler i, final int slotIdx, final int x, final int y ) - { - super( i, slotIdx, x, y ); - } + public SlotInaccessibleHD(final IItemHandler i, final int slotIdx, final int x, final int y) { + super(i, slotIdx, x, y); + } } diff --git a/src/main/java/appeng/container/slot/SlotMACPattern.java b/src/main/java/appeng/container/slot/SlotMACPattern.java index c7e05542d..5a13f0941 100644 --- a/src/main/java/appeng/container/slot/SlotMACPattern.java +++ b/src/main/java/appeng/container/slot/SlotMACPattern.java @@ -18,27 +18,22 @@ package appeng.container.slot; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.container.implementations.ContainerMAC; +public class SlotMACPattern extends AppEngSlot { -public class SlotMACPattern extends AppEngSlot -{ + private final ContainerMAC mac; - private final ContainerMAC mac; + public SlotMACPattern(final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y) { + super(i, slotIdx, x, y); + this.mac = mac; + } - public SlotMACPattern( final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y ) - { - super( i, slotIdx, x, y ); - this.mac = mac; - } - - @Override - public boolean isItemValid( final ItemStack i ) - { - return this.mac.isValidItemForSlot( this.getSlotIndex(), i ); - } + @Override + public boolean isItemValid(final ItemStack i) { + return this.mac.isValidItemForSlot(this.getSlotIndex(), i); + } } diff --git a/src/main/java/appeng/container/slot/SlotNormal.java b/src/main/java/appeng/container/slot/SlotNormal.java index 3e2a509ea..d07a855ca 100644 --- a/src/main/java/appeng/container/slot/SlotNormal.java +++ b/src/main/java/appeng/container/slot/SlotNormal.java @@ -18,15 +18,11 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotNormal extends AppEngSlot { -public class SlotNormal extends AppEngSlot -{ - - public SlotNormal( final IItemHandler inv, final int slot, final int xPos, final int yPos ) - { - super( inv, slot, xPos, yPos ); - } + public SlotNormal(final IItemHandler inv, final int slot, final int xPos, final int yPos) { + super(inv, slot, xPos, yPos); + } } diff --git a/src/main/java/appeng/container/slot/SlotOutput.java b/src/main/java/appeng/container/slot/SlotOutput.java index 687483e5b..9f13dbbdf 100644 --- a/src/main/java/appeng/container/slot/SlotOutput.java +++ b/src/main/java/appeng/container/slot/SlotOutput.java @@ -18,23 +18,18 @@ package appeng.container.slot; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class SlotOutput extends AppEngSlot { -public class SlotOutput extends AppEngSlot -{ + public SlotOutput(final IItemHandler a, final int b, final int c, final int d, final int i) { + super(a, b, c, d); + this.setIIcon(i); + } - public SlotOutput( final IItemHandler a, final int b, final int c, final int d, final int i ) - { - super( a, b, c, d ); - this.setIIcon( i ); - } - - @Override - public boolean isItemValid( final ItemStack i ) - { - return false; - } + @Override + public boolean isItemValid(final ItemStack i) { + return false; + } } diff --git a/src/main/java/appeng/container/slot/SlotPatternOutputs.java b/src/main/java/appeng/container/slot/SlotPatternOutputs.java index 70b873d03..8f0128f80 100644 --- a/src/main/java/appeng/container/slot/SlotPatternOutputs.java +++ b/src/main/java/appeng/container/slot/SlotPatternOutputs.java @@ -18,27 +18,22 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotPatternOutputs extends OptionalSlotFake { -public class SlotPatternOutputs extends OptionalSlotFake -{ + public SlotPatternOutputs(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, + final int y, final int offX, final int offY, final int groupNum) { + super(inv, containerBus, idx, x, y, offX, offY, groupNum); + } - public SlotPatternOutputs( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum ) - { - super( inv, containerBus, idx, x, y, offX, offY, groupNum ); - } + @Override + public boolean isSlotEnabled() { + return true; + } - @Override - public boolean isSlotEnabled() - { - return true; - } - - @Override - public boolean shouldDisplay() - { - return super.isSlotEnabled(); - } + @Override + public boolean shouldDisplay() { + return super.isSlotEnabled(); + } } diff --git a/src/main/java/appeng/container/slot/SlotPatternTerm.java b/src/main/java/appeng/container/slot/SlotPatternTerm.java index b2940f7a0..2b414d5e6 100644 --- a/src/main/java/appeng/container/slot/SlotPatternTerm.java +++ b/src/main/java/appeng/container/slot/SlotPatternTerm.java @@ -18,7 +18,6 @@ package appeng.container.slot; - import java.io.IOException; import net.minecraft.entity.player.PlayerEntity; @@ -34,49 +33,44 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.packets.PacketPatternSlot; import appeng.helpers.IContainerCraftingPacket; +public class SlotPatternTerm extends SlotCraftingTerm { -public class SlotPatternTerm extends SlotCraftingTerm -{ + private final int groupNum; + private final IOptionalSlotHost host; - private final int groupNum; - private final IOptionalSlotHost host; + public SlotPatternTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, + final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, + final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, + final IContainerCraftingPacket c) { + super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c); - public SlotPatternTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c ) - { - super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c ); + this.host = h; + this.groupNum = groupNumber; + } - this.host = h; - this.groupNum = groupNumber; - } + public AppEngPacket getRequest(final boolean shift) { + return new PacketPatternSlot(this.getPattern(), + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()), + shift); + } - public AppEngPacket getRequest( final boolean shift ) - { - return new PacketPatternSlot( this - .getPattern(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.getStack() ), shift ); - } + @Override + public ItemStack getStack() { + if (!this.isSlotEnabled()) { + if (!this.getDisplayStack().isEmpty()) { + this.clearStack(); + } + } - @Override - public ItemStack getStack() - { - if( !this.isSlotEnabled() ) - { - if( !this.getDisplayStack().isEmpty() ) - { - this.clearStack(); - } - } + return super.getStack(); + } - return super.getStack(); - } + @Override + public boolean isSlotEnabled() { + if (this.host == null) { + return false; + } - @Override - public boolean isSlotEnabled() - { - if( this.host == null ) - { - return false; - } - - return this.host.isSlotEnabled( this.groupNum ); - } + return this.host.isSlotEnabled(this.groupNum); + } } diff --git a/src/main/java/appeng/container/slot/SlotPlayerHotBar.java b/src/main/java/appeng/container/slot/SlotPlayerHotBar.java index 2d81df4ff..767b913b0 100644 --- a/src/main/java/appeng/container/slot/SlotPlayerHotBar.java +++ b/src/main/java/appeng/container/slot/SlotPlayerHotBar.java @@ -18,16 +18,12 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; +public class SlotPlayerHotBar extends AppEngSlot { -public class SlotPlayerHotBar extends AppEngSlot -{ - - public SlotPlayerHotBar( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 ) - { - super( par1iInventory, par2, par3, par4 ); - this.setPlayerSide( true ); - } + public SlotPlayerHotBar(final IItemHandler par1iInventory, final int par2, final int par3, final int par4) { + super(par1iInventory, par2, par3, par4); + this.setPlayerSide(true); + } } diff --git a/src/main/java/appeng/container/slot/SlotPlayerInv.java b/src/main/java/appeng/container/slot/SlotPlayerInv.java index 3b273817c..0a66a6e46 100644 --- a/src/main/java/appeng/container/slot/SlotPlayerInv.java +++ b/src/main/java/appeng/container/slot/SlotPlayerInv.java @@ -18,19 +18,15 @@ package appeng.container.slot; - import net.minecraftforge.items.IItemHandler; - // there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot. -public class SlotPlayerInv extends AppEngSlot -{ +public class SlotPlayerInv extends AppEngSlot { - public SlotPlayerInv( final IItemHandler par1iInventory, final int idx, final int x, final int y ) - { - super( par1iInventory, idx, x, y ); + public SlotPlayerInv(final IItemHandler par1iInventory, final int idx, final int x, final int y) { + super(par1iInventory, idx, x, y); - this.setPlayerSide( true ); - } + this.setPlayerSide(true); + } } diff --git a/src/main/java/appeng/container/slot/SlotRestrictedInput.java b/src/main/java/appeng/container/slot/SlotRestrictedInput.java index 439ea7e50..041d8d16a 100644 --- a/src/main/java/appeng/container/slot/SlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/SlotRestrictedInput.java @@ -18,15 +18,11 @@ package appeng.container.slot; - -import appeng.items.misc.ItemEncodedPattern; -import appeng.recipes.handlers.GrinderRecipes; -import appeng.tile.misc.InscriberRecipes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Slot; -import net.minecraft.item.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.items.IItemHandler; @@ -43,281 +39,243 @@ import appeng.api.implementations.items.IStorageComponent; import appeng.api.implementations.items.IUpgradeModule; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.ICellWorkbenchItem; +import appeng.items.misc.ItemEncodedPattern; +import appeng.recipes.handlers.GrinderRecipes; +import appeng.tile.misc.InscriberRecipes; import appeng.util.Platform; - /** * @author AlgorithmX2 * @author thatsIch * @version rv2 * @since rv0 */ -public class SlotRestrictedInput extends AppEngSlot -{ +public class SlotRestrictedInput extends AppEngSlot { - private final PlacableItemType which; - private final PlayerInventory p; - private boolean allowEdit = true; - private int stackLimit = -1; + private final PlacableItemType which; + private final PlayerInventory p; + private boolean allowEdit = true; + private int stackLimit = -1; - public SlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x, final int y, final PlayerInventory p ) - { - super( i, slotIndex, x, y ); - this.which = valid; - this.setIIcon( valid.IIcon ); - this.p = p; - } + public SlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x, + final int y, final PlayerInventory p) { + super(i, slotIndex, x, y); + this.which = valid; + this.setIIcon(valid.IIcon); + this.p = p; + } - @Override - public int getSlotStackLimit() - { - if( this.stackLimit != -1 ) - { - return this.stackLimit; - } - return super.getSlotStackLimit(); - } + @Override + public int getSlotStackLimit() { + if (this.stackLimit != -1) { + return this.stackLimit; + } + return super.getSlotStackLimit(); + } - public boolean isValid( final ItemStack is, final World theWorld ) - { - if( this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT ) - { - final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ( (ICraftingPatternItem) is.getItem() ).getPatternForItem( is, - theWorld ) : null; - return ap != null; - } - return true; - } + public boolean isValid(final ItemStack is, final World theWorld) { + if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) { + final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem + ? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld) + : null; + return ap != null; + } + return true; + } - public Slot setStackLimit(final int i ) - { - this.stackLimit = i; - return this; - } + public Slot setStackLimit(final int i) { + this.stackLimit = i; + return this; + } - @Override - public boolean isItemValid( final ItemStack i ) - { - if( !this.getContainer().isValidForSlot( this, i ) ) - { - return false; - } + @Override + public boolean isItemValid(final ItemStack i) { + if (!this.getContainer().isValidForSlot(this, i)) { + return false; + } - if( i.isEmpty() ) - { - return false; - } + if (i.isEmpty()) { + return false; + } - if( i.getItem() == Items.AIR ) - { - return false; - } + if (i.getItem() == Items.AIR) { + return false; + } - if( !super.isItemValid( i ) ) - { - return false; - } + if (!super.isItemValid(i)) { + return false; + } - if( !this.isAllowEdit() ) - { - return false; - } + if (!this.isAllowEdit()) { + return false; + } - final IDefinitions definitions = AEApi.instance().definitions(); - final IMaterials materials = definitions.materials(); - final IItems items = definitions.items(); + 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 ) - { - final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); - final ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.world ); - 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; - } - case BLANK_PATTERN: - return materials.blankPattern().isSameAs( i ); + switch (this.which) { + case ENCODED_CRAFTING_PATTERN: + if (i.getItem() instanceof ICraftingPatternItem) { + final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); + final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world); + 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; + } + case BLANK_PATTERN: + return materials.blankPattern().isSameAs(i); - case PATTERN: + case PATTERN: - if( i.getItem() instanceof ICraftingPatternItem ) - { - return true; - } + if (i.getItem() instanceof ICraftingPatternItem) { + return true; + } - return materials.blankPattern().isSameAs( i ); + return materials.blankPattern().isSameAs(i); - case INSCRIBER_PLATE: - if( materials.namePress().isSameAs( i ) ) - { - return true; - } + case INSCRIBER_PLATE: + if (materials.namePress().isSameAs(i)) { + return true; + } - return InscriberRecipes.isValidOptionalIngredient(p.player.world, i); + return InscriberRecipes.isValidOptionalIngredient(p.player.world, i); - case INSCRIBER_INPUT: - return true;/* - * for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return - * true; - * return false; - */ + case INSCRIBER_INPUT: + return true;/* + * for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) + * ) return true; return false; + */ - case METAL_INGOTS: + case METAL_INGOTS: - return isMetalIngot( i ); + return isMetalIngot(i); - case VIEW_CELL: - return items.viewCell().isSameAs( i ); - case ORE: - return GrinderRecipes.isValidIngredient(p.player.world, i); - case FUEL: - return ForgeHooks.getBurnTime( i ) > 0; - case POWERED_TOOL: - return Platform.isChargeable( i ); - case QE_SINGULARITY: - return materials.qESingularity().isSameAs( i ); + case VIEW_CELL: + return items.viewCell().isSameAs(i); + case ORE: + return GrinderRecipes.isValidIngredient(p.player.world, i); + case FUEL: + return ForgeHooks.getBurnTime(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 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; - } + 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 !(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; - } + return false; + } - @Override - public boolean canTakeStack( final PlayerEntity par1PlayerEntity ) - { - return this.isAllowEdit(); - } + @Override + public boolean canTakeStack(final PlayerEntity par1PlayerEntity) { + return this.isAllowEdit(); + } - @Override - public ItemStack getDisplayStack() - { - if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) ) - { - final ItemStack is = super.getStack(); - if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) - { - final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - final ItemStack out = iep.getOutput( is ); - if( !out.isEmpty() ) - { - return out; - } - } - } - return super.getStack(); - } + @Override + public ItemStack getDisplayStack() { + if (Platform.isClient() && (this.which == PlacableItemType.ENCODED_PATTERN)) { + final ItemStack is = super.getStack(); + if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) { + final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); + final ItemStack out = iep.getOutput(is); + if (!out.isEmpty()) { + return out; + } + } + } + return super.getStack(); + } - public static boolean isMetalIngot( final ItemStack i ) - { - if( Platform.itemComparisons().isSameItem( i, new ItemStack( Items.IRON_INGOT ) ) ) - { - return true; - } + public static boolean isMetalIngot(final ItemStack i) { + if (Platform.itemComparisons().isSameItem(i, new ItemStack(Items.IRON_INGOT))) { + return true; + } - for( final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } ) - { - // FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) ) - // FIXME { - // FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) ) - // FIXME { - // FIXME return true; - // FIXME } - // FIXME } - } + for (final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", + "Nickel", "Aluminium" }) { + // FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) ) + // FIXME { + // FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) ) + // FIXME { + // FIXME return true; + // FIXME } + // FIXME } + } - return false; - } + return false; + } - private boolean isAllowEdit() - { - return this.allowEdit; - } + private boolean isAllowEdit() { + return this.allowEdit; + } - public void setAllowEdit( final boolean allowEdit ) - { - this.allowEdit = allowEdit; - } + public void setAllowEdit(final boolean allowEdit) { + this.allowEdit = allowEdit; + } - public enum PlacableItemType - { - STORAGE_CELLS( 15 ), - ORE( 16 + 15 ), - STORAGE_COMPONENT( 3 * 16 + 15 ), + public enum PlacableItemType { + STORAGE_CELLS(15), ORE(16 + 15), STORAGE_COMPONENT(3 * 16 + 15), - ENCODABLE_ITEM( 4 * 16 + 15 ), - TRASH( 5 * 16 + 15 ), - VALID_ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ), - ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ), + ENCODABLE_ITEM(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15), + ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15), - ENCODED_CRAFTING_PATTERN( 7 * 16 + 15 ), - ENCODED_PATTERN( 7 * 16 + 15 ), - PATTERN( 8 * 16 + 15 ), - BLANK_PATTERN( 8 * 16 + 15 ), - POWERED_TOOL( 9 * 16 + 15 ), + ENCODED_CRAFTING_PATTERN(7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), PATTERN(8 * 16 + 15), + BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15), - RANGE_BOOSTER( 6 * 16 + 15 ), - QE_SINGULARITY( 10 * 16 + 15 ), - SPATIAL_STORAGE_CELLS( 11 * 16 + 15 ), + RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARITY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15), - FUEL( 12 * 16 + 15 ), - UPGRADES( 13 * 16 + 15 ), - WORKBENCH_CELL( 15 ), - BIOMETRIC_CARD( 14 * 16 + 15 ), - VIEW_CELL( 4 * 16 + 14 ), + FUEL(12 * 16 + 15), UPGRADES(13 * 16 + 15), WORKBENCH_CELL(15), BIOMETRIC_CARD(14 * 16 + 15), + VIEW_CELL(4 * 16 + 14), - INSCRIBER_PLATE( 2 * 16 + 14 ), - INSCRIBER_INPUT( 3 * 16 + 14 ), - METAL_INGOTS( 3 * 16 + 14 ); + INSCRIBER_PLATE(2 * 16 + 14), INSCRIBER_INPUT(3 * 16 + 14), METAL_INGOTS(3 * 16 + 14); - public final int IIcon; + public final int IIcon; - PlacableItemType( final int o ) - { - this.IIcon = o; - } - } + PlacableItemType(final int o) { + this.IIcon = o; + } + } } diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index bfb272fce..71f060c4a 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -18,193 +18,191 @@ package appeng.core; - -import appeng.api.config.*; -import appeng.api.util.IConfigManager; -import appeng.api.util.IConfigurableObject; -import appeng.api.features.AEFeature; -import appeng.core.settings.TickRates; -import appeng.util.ConfigManager; -import appeng.util.EnumCycler; -import appeng.util.IConfigManagerHost; -import com.google.common.base.Strings; -import net.minecraft.world.dimension.DimensionType; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import org.apache.commons.lang3.tuple.Pair; +import static net.minecraftforge.common.ForgeConfigSpec.*; import java.util.*; import java.util.function.DoubleSupplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import static net.minecraftforge.common.ForgeConfigSpec.*; +import com.google.common.base.Strings; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.world.dimension.DimensionType; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.config.ModConfig; + +import appeng.api.config.*; +import appeng.api.features.AEFeature; +import appeng.api.util.IConfigManager; +import appeng.api.util.IConfigurableObject; +import appeng.core.settings.TickRates; +import appeng.util.ConfigManager; +import appeng.util.EnumCycler; +import appeng.util.IConfigManagerHost; @Mod.EventBusSubscriber(modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public final class AEConfig implements IConfigurableObject, IConfigManagerHost -{ +public final class AEConfig implements IConfigurableObject, IConfigManagerHost { - public static final ClientConfig CLIENT; - public static final ForgeConfigSpec CLIENT_SPEC; + public static final ClientConfig CLIENT; + public static final ForgeConfigSpec CLIENT_SPEC; - // Default Grindstone ores - private static final String[] ORES_VANILLA = { "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz" }; - private static final String[] ORES_AE = { "CertusQuartz", "Wheat", "Fluix" }; - private static final String[] ORES_COMMON = { "Copper", "Tin", "Silver", "Lead", "Bronze" }; - private static final String[] ORES_MISC = { "Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc" }; + // Default Grindstone ores + private static final String[] ORES_VANILLA = { "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", + "Charcoal", "NetherQuartz" }; + private static final String[] ORES_AE = { "CertusQuartz", "Wheat", "Fluix" }; + private static final String[] ORES_COMMON = { "Copper", "Tin", "Silver", "Lead", "Bronze" }; + private static final String[] ORES_MISC = { "Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", + "Osmium", "Zinc" }; - // Default Energy Conversion Rates - private static final double DEFAULT_IC2_EXCHANGE = 2.0; - private static final double DEFAULT_RF_EXCHANGE = 0.5; + // Default Energy Conversion Rates + private static final double DEFAULT_IC2_EXCHANGE = 2.0; + private static final double DEFAULT_RF_EXCHANGE = 0.5; - static { - final Pair specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); - CLIENT_SPEC = specPair.getRight(); - CLIENT = specPair.getLeft(); - } + static { + final Pair specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); + CLIENT_SPEC = specPair.getRight(); + CLIENT = specPair.getLeft(); + } - public static final String VERSION = "@version@"; - public static final String CHANNEL = "@aechannel@"; - public static final String PACKET_CHANNEL = "AE"; + public static final String VERSION = "@version@"; + public static final String CHANNEL = "@aechannel@"; + public static final String PACKET_CHANNEL = "AE"; - // Config instance - private static final AEConfig instance = new AEConfig(); + // Config instance + private static final AEConfig instance = new AEConfig(); - private final IConfigManager settings = new ConfigManager( this ); + private final IConfigManager settings = new ConfigManager(this); - private final EnumSet featureFlags = EnumSet.noneOf( AEFeature.class ); - private boolean updatable = false; + private final EnumSet featureFlags = EnumSet.noneOf(AEFeature.class); + private boolean updatable = false; - // Misc - private boolean removeCrashingItemsOnLoad; - private int formationPlaneEntityLimit; - private boolean enableEffects; - private boolean useLargeFonts; - private boolean useColoredCraftingStatus; - private boolean disableColoredCableRecipesInJEI; - private int craftingCalculationTimePerTick; - private PowerUnits selectedPowerUnit; + // Misc + private boolean removeCrashingItemsOnLoad; + private int formationPlaneEntityLimit; + private boolean enableEffects; + private boolean useLargeFonts; + private boolean useColoredCraftingStatus; + private boolean disableColoredCableRecipesInJEI; + private int craftingCalculationTimePerTick; + private PowerUnits selectedPowerUnit; - // GUI Buttons - private int[] craftByStacks = new int[4]; - private int[] priorityByStacks = new int[4]; - private int[] levelByStacks = new int[4]; - private final int[] levelByMillibuckets = { 10, 100, 1000, 10000 }; + // GUI Buttons + private int[] craftByStacks = new int[4]; + private int[] priorityByStacks = new int[4]; + private int[] levelByStacks = new int[4]; + private final int[] levelByMillibuckets = { 10, 100, 1000, 10000 }; - // Spatial IO/Dimension - private String storageProviderID; - private String storageDimensionID; - private double spatialPowerExponent; - private double spatialPowerMultiplier; + // Spatial IO/Dimension + private String storageProviderID; + private String storageDimensionID; + private double spatialPowerExponent; + private double spatialPowerMultiplier; - // Grindstone - private List grinderOres; - private Set grinderBlackList; - private float oreDoublePercentage; + // Grindstone + private List grinderOres; + private Set grinderBlackList; + private float oreDoublePercentage; - // Batteries - private int wirelessTerminalBattery; - private int entropyManipulatorBattery; - private int matterCannonBattery; - private int portableCellBattery; - private int colorApplicatorBattery; - private int chargedStaffBattery; + // Batteries + private int wirelessTerminalBattery; + private int entropyManipulatorBattery; + private int matterCannonBattery; + private int portableCellBattery; + private int colorApplicatorBattery; + private int chargedStaffBattery; - // Certus quartz - private float spawnChargedChance; - private int quartzOresPerCluster; - private int quartzOresClusterAmount; + // Certus quartz + private float spawnChargedChance; + private int quartzOresPerCluster; + private int quartzOresClusterAmount; - // Meteors - private int minMeteoriteDistance; - private int minMeteoriteDistanceSq; - private double meteoriteClusterChance; - private int meteoriteMaximumSpawnHeight; - private Set meteoriteDimensionWhitelist; + // Meteors + private int minMeteoriteDistance; + private int minMeteoriteDistanceSq; + private double meteoriteClusterChance; + private int meteoriteMaximumSpawnHeight; + private Set meteoriteDimensionWhitelist; - // Wireless - private double wirelessBaseCost; - private double wirelessCostMultiplier; - private double wirelessTerminalDrainMultiplier; - private double wirelessBaseRange; - private double wirelessBoosterRangeMultiplier; - private double wirelessBoosterExp; - private double wirelessHighWirelessCount; + // Wireless + private double wirelessBaseCost; + private double wirelessCostMultiplier; + private double wirelessTerminalDrainMultiplier; + private double wirelessBaseRange; + private double wirelessBoosterRangeMultiplier; + private double wirelessBoosterExp; + private double wirelessHighWirelessCount; - // Tunnels - public static final double TUNNEL_POWER_LOSS = 0.05; + // Tunnels + public static final double TUNNEL_POWER_LOSS = 0.05; - // FIXME: this is shit, move this concern out of the config class - @SubscribeEvent - public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) { - if (configEvent.getConfig().getSpec() == CLIENT_SPEC) { - instance.syncConfig(CLIENT); - } - } + // FIXME: this is shit, move this concern out of the config class + @SubscribeEvent + public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) { + if (configEvent.getConfig().getSpec() == CLIENT_SPEC) { + instance.syncConfig(CLIENT); + } + } - private void syncConfig(ClientConfig config) { + private void syncConfig(ClientConfig config) { - PowerUnits.EU.conversionRatio = config.powerRatioIc2.get(); - PowerUnits.RF.conversionRatio = config.powerRatioForgeEnergy.get(); - PowerMultiplier.CONFIG.multiplier = config.powerUsageMultiplier.get(); + PowerUnits.EU.conversionRatio = config.powerRatioIc2.get(); + PowerUnits.RF.conversionRatio = config.powerRatioForgeEnergy.get(); + PowerMultiplier.CONFIG.multiplier = config.powerUsageMultiplier.get(); - CondenserOutput.MATTER_BALLS.requiredPower = config.condenserMatterBallsPower.get(); - CondenserOutput.SINGULARITY.requiredPower = config.condenserSingularityPower.get(); + CondenserOutput.MATTER_BALLS.requiredPower = config.condenserMatterBallsPower.get(); + CondenserOutput.SINGULARITY.requiredPower = config.condenserSingularityPower.get(); - this.grinderOres = new ArrayList<>(config.grinderOres.get()); - this.grinderBlackList = new HashSet<>(config.grinderBlackList.get()); - this.oreDoublePercentage = config.oreDoublePercentage.get().floatValue(); + this.grinderOres = new ArrayList<>(config.grinderOres.get()); + this.grinderBlackList = new HashSet<>(config.grinderBlackList.get()); + this.oreDoublePercentage = config.oreDoublePercentage.get().floatValue(); - // FIXME: why is this here exactly??? - this.settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES ); - this.settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL ); - this.settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH ); + // FIXME: why is this here exactly??? + this.settings.registerSetting(Settings.SEARCH_TOOLTIPS, YesNo.YES); + this.settings.registerSetting(Settings.TERMINAL_STYLE, TerminalStyle.TALL); + this.settings.registerSetting(Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH); - this.spawnChargedChance = (float) (1.0 - config.spawnChargedChance.get()); - this.minMeteoriteDistance = config.minMeteoriteDistance.get(); - this.minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance; - this.meteoriteClusterChance = config.meteoriteClusterChance.get(); - this.meteoriteMaximumSpawnHeight = config.meteoriteMaximumSpawnHeight.get(); - this.meteoriteDimensionWhitelist = new HashSet<>(config.meteoriteDimensionWhitelist.get()); + this.spawnChargedChance = (float) (1.0 - config.spawnChargedChance.get()); + this.minMeteoriteDistance = config.minMeteoriteDistance.get(); + this.minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance; + this.meteoriteClusterChance = config.meteoriteClusterChance.get(); + this.meteoriteMaximumSpawnHeight = config.meteoriteMaximumSpawnHeight.get(); + this.meteoriteDimensionWhitelist = new HashSet<>(config.meteoriteDimensionWhitelist.get()); - this.quartzOresPerCluster = config.quartzOresPerCluster.get(); - this.quartzOresClusterAmount = config.quartzOresPerCluster.get(); + this.quartzOresPerCluster = config.quartzOresPerCluster.get(); + this.quartzOresClusterAmount = config.quartzOresPerCluster.get(); - this.wirelessBaseCost = config.wirelessBaseCost.get(); - this.wirelessCostMultiplier = config.wirelessCostMultiplier.get(); - this.wirelessBaseRange = config.wirelessBaseRange.get(); - this.wirelessBoosterRangeMultiplier = config.wirelessBoosterRangeMultiplier.get(); - this.wirelessBoosterExp = config.wirelessBoosterExp.get(); - this.wirelessTerminalDrainMultiplier = config.wirelessTerminalDrainMultiplier.get(); + this.wirelessBaseCost = config.wirelessBaseCost.get(); + this.wirelessCostMultiplier = config.wirelessCostMultiplier.get(); + this.wirelessBaseRange = config.wirelessBaseRange.get(); + this.wirelessBoosterRangeMultiplier = config.wirelessBoosterRangeMultiplier.get(); + this.wirelessBoosterExp = config.wirelessBoosterExp.get(); + this.wirelessTerminalDrainMultiplier = config.wirelessTerminalDrainMultiplier.get(); - this.formationPlaneEntityLimit = config.formationPlaneEntityLimit.get(); + this.formationPlaneEntityLimit = config.formationPlaneEntityLimit.get(); - this.wirelessTerminalBattery = config.wirelessTerminalBattery.get(); - this.chargedStaffBattery = config.chargedStaffBattery.get(); - this.entropyManipulatorBattery = config.entropyManipulatorBattery.get(); - this.portableCellBattery = config.portableCellBattery.get(); - this.colorApplicatorBattery = config.colorApplicatorBattery.get(); - this.matterCannonBattery = config.matterCannonBattery.get(); + this.wirelessTerminalBattery = config.wirelessTerminalBattery.get(); + this.chargedStaffBattery = config.chargedStaffBattery.get(); + this.entropyManipulatorBattery = config.entropyManipulatorBattery.get(); + this.portableCellBattery = config.portableCellBattery.get(); + this.colorApplicatorBattery = config.colorApplicatorBattery.get(); + this.matterCannonBattery = config.matterCannonBattery.get(); - this.clientSync(config); - - this.featureFlags.clear(); - for( final AEFeature feature : AEFeature.values() ) - { - if( feature.isVisible() ) - { - if (config.enabledFeatures.get(feature).get()) { - this.featureFlags.add(feature); - } - } - else - { - this.featureFlags.add( feature ); - } - } + this.clientSync(config); + this.featureFlags.clear(); + for (final AEFeature feature : AEFeature.values()) { + if (feature.isVisible()) { + if (config.enabledFeatures.get(feature).get()) { + this.featureFlags.add(feature); + } + } else { + this.featureFlags.add(feature); + } + } // FIXME final ModContainer imb = net.minecraftforge.fml.common.Loader.instance().getIndexedModList().get( "ImmibisCore" ); // FIXME if( imb != null ) @@ -216,112 +214,101 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost // FIXME } // FIXME } - for( final TickRates tr : TickRates.values() ) - { - tr.setMin(config.tickRateMin.get(tr).get()); - tr.setMax(config.tickRateMin.get(tr).get()); - } + for (final TickRates tr : TickRates.values()) { + tr.setMin(config.tickRateMin.get(tr).get()); + tr.setMax(config.tickRateMin.get(tr).get()); + } - this.storageProviderID = Strings.emptyToNull(config.storageProviderID.get()); - this.storageDimensionID = Strings.emptyToNull(config.storageDimensionID.get()); - this.spatialPowerMultiplier = config.spatialPowerMultiplier.get(); - this.spatialPowerExponent = config.spatialPowerExponent.get(); + this.storageProviderID = Strings.emptyToNull(config.storageProviderID.get()); + this.storageDimensionID = Strings.emptyToNull(config.storageDimensionID.get()); + this.spatialPowerMultiplier = config.spatialPowerMultiplier.get(); + this.spatialPowerExponent = config.spatialPowerExponent.get(); - this.craftingCalculationTimePerTick = config.craftingCalculationTimePerTick.get(); + this.craftingCalculationTimePerTick = config.craftingCalculationTimePerTick.get(); - this.updatable = true; - } + this.updatable = true; + } - public static AEConfig instance() - { - return instance; - } + public static AEConfig instance() { + return instance; + } - private void clientSync(ClientConfig config) - { - this.disableColoredCableRecipesInJEI = config.disableColoredCableRecipesInJEI.get(); - this.enableEffects = config.enableEffects.get(); - this.useLargeFonts = config.useLargeFonts.get(); - this.useColoredCraftingStatus = config.useColoredCraftingStatus.get(); - this.selectedPowerUnit = config.selectedPowerUnit.get(); + private void clientSync(ClientConfig config) { + this.disableColoredCableRecipesInJEI = config.disableColoredCableRecipesInJEI.get(); + this.enableEffects = config.enableEffects.get(); + this.useLargeFonts = config.useLargeFonts.get(); + this.useColoredCraftingStatus = config.useColoredCraftingStatus.get(); + this.selectedPowerUnit = config.selectedPowerUnit.get(); - // load buttons.. - for( int btnNum = 0; btnNum < 4; btnNum++ ) - { - this.craftByStacks[btnNum] = config.craftByStacks.get(btnNum).get(); - this.priorityByStacks[btnNum] = config.priorityByStacks.get(btnNum).get(); - this.levelByStacks[btnNum] = config.levelByStacks.get(btnNum).get(); - } + // load buttons.. + for (int btnNum = 0; btnNum < 4; btnNum++) { + this.craftByStacks[btnNum] = config.craftByStacks.get(btnNum).get(); + this.priorityByStacks[btnNum] = config.priorityByStacks.get(btnNum).get(); + this.levelByStacks[btnNum] = config.levelByStacks.get(btnNum).get(); + } - // FIXME for( final Settings e : this.settings.getSettings() ) - // FIXME { - // FIXME final String Category = "Client"; // e.getClass().getSimpleName(); - // FIXME Enum value = this.settings.getSetting( e ); + // FIXME for( final Settings e : this.settings.getSettings() ) + // FIXME { + // FIXME final String Category = "Client"; // e.getClass().getSimpleName(); + // FIXME Enum value = this.settings.getSetting( e ); // FIXME - // FIXME final Property p = this.get( Category, e.name(), value.name(), this.getListComment( value ) ); + // FIXME final Property p = this.get( Category, e.name(), value.name(), + // this.getListComment( value ) ); // FIXME - // FIXME try - // FIXME { - // FIXME value = Enum.valueOf( value.getClass(), p.getString() ); - // FIXME } - // FIXME catch( final IllegalArgumentException er ) - // FIXME { - // FIXME AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" ); - // FIXME } + // FIXME try + // FIXME { + // FIXME value = Enum.valueOf( value.getClass(), p.getString() ); + // FIXME } + // FIXME catch( final IllegalArgumentException er ) + // FIXME { + // FIXME AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " + // using '" + value.name() + "' instead" ); + // FIXME } // FIXME - // FIXME this.settings.putSetting( e, value ); - // FIXME } - } + // FIXME this.settings.putSetting( e, value ); + // FIXME } + } - private String getListComment( final Enum value ) - { - String comment = null; + private String getListComment(final Enum value) { + String comment = null; - if( value != null ) - { - final EnumSet set = EnumSet.allOf( value.getClass() ); + if (value != null) { + final EnumSet set = EnumSet.allOf(value.getClass()); - for( final Object Oeg : set ) - { - final Enum eg = (Enum) Oeg; - if( comment == null ) - { - comment = "Possible Values: " + eg.name(); - } - else - { - comment += ", " + eg.name(); - } - } - } + for (final Object Oeg : set) { + final Enum eg = (Enum) Oeg; + if (comment == null) { + comment = "Possible Values: " + eg.name(); + } else { + comment += ", " + eg.name(); + } + } + } - return comment; - } + return comment; + } - public boolean isFeatureEnabled( final AEFeature f ) - { - return this.featureFlags.contains( f ); - } + public boolean isFeatureEnabled(final AEFeature f) { + return this.featureFlags.contains(f); + } - public boolean areFeaturesEnabled( Collection features ) - { - return this.featureFlags.containsAll( features ); - } + public boolean areFeaturesEnabled(Collection features) { + return this.featureFlags.containsAll(features); + } - public double wireless_getDrainRate( final double range ) - { - return this.wirelessTerminalDrainMultiplier * range; - } + public double wireless_getDrainRate(final double range) { + return this.wirelessTerminalDrainMultiplier * range; + } - public double wireless_getMaxRange( final int boosters ) - { - return this.wirelessBaseRange + this.wirelessBoosterRangeMultiplier * Math.pow( boosters, this.wirelessBoosterExp ); - } + public double wireless_getMaxRange(final int boosters) { + return this.wirelessBaseRange + + this.wirelessBoosterRangeMultiplier * Math.pow(boosters, this.wirelessBoosterExp); + } - public double wireless_getPowerDrain( final int boosters ) - { - return this.wirelessBaseCost + this.wirelessCostMultiplier * Math.pow( boosters, 1 + boosters / this.wirelessHighWirelessCount ); - } + public double wireless_getPowerDrain(final int boosters) { + return this.wirelessBaseCost + + this.wirelessCostMultiplier * Math.pow(boosters, 1 + boosters / this.wirelessHighWirelessCount); + } // FIXME @Override // FIXME public Property get( final String category, final String key, final String defaultValue, final String comment, final Property.Type type ) @@ -339,68 +326,60 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost // FIXME return prop; // FIXME } - public void save() - { - if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) ) - { - CLIENT.storageProviderID.set(Strings.nullToEmpty(this.storageProviderID)); - CLIENT.storageDimensionID.set(Strings.nullToEmpty(this.storageDimensionID)); - } + public void save() { + if (this.isFeatureEnabled(AEFeature.SPATIAL_IO)) { + CLIENT.storageProviderID.set(Strings.nullToEmpty(this.storageProviderID)); + CLIENT.storageDimensionID.set(Strings.nullToEmpty(this.storageDimensionID)); + } - CLIENT.selectedPowerUnit.set(this.selectedPowerUnit); + CLIENT.selectedPowerUnit.set(this.selectedPowerUnit); - CLIENT_SPEC.save(); - } + CLIENT_SPEC.save(); + } - @Override - public void updateSetting(final IConfigManager manager, final Settings setting, final Enum newValue ) - { - // FIXME for( final Settings e : this.settings.getSettings() ) - // FIXME { - // FIXME if( e == setting ) - // FIXME { - // FIXME final String Category = "Client"; - // FIXME final Property p = this.get( Category, e.name(), this.settings.getSetting( e ).name(), this.getListComment( newValue ) ); - // FIXME p.set( newValue.name() ); - // FIXME } - // FIXME } + @Override + public void updateSetting(final IConfigManager manager, final Settings setting, final Enum newValue) { + // FIXME for( final Settings e : this.settings.getSettings() ) + // FIXME { + // FIXME if( e == setting ) + // FIXME { + // FIXME final String Category = "Client"; + // FIXME final Property p = this.get( Category, e.name(), + // this.settings.getSetting( e ).name(), this.getListComment( newValue ) ); + // FIXME p.set( newValue.name() ); + // FIXME } + // FIXME } // FIXME - // FIXME if( this.updatable ) - // FIXME { - // FIXME this.save(); - // FIXME } - } + // FIXME if( this.updatable ) + // FIXME { + // FIXME this.save(); + // FIXME } + } - @Override - public IConfigManager getConfigManager() - { - return this.settings; - } + @Override + public IConfigManager getConfigManager() { + return this.settings; + } - public boolean useTerminalUseLargeFont() - { - return this.useLargeFonts; - } + public boolean useTerminalUseLargeFont() { + return this.useLargeFonts; + } - public int craftItemsByStackAmounts( final int i ) - { - return this.craftByStacks[i]; - } + public int craftItemsByStackAmounts(final int i) { + return this.craftByStacks[i]; + } - public int priorityByStacksAmounts( final int i ) - { - return this.priorityByStacks[i]; - } + public int priorityByStacksAmounts(final int i) { + return this.priorityByStacks[i]; + } - public int levelByStackAmounts( final int i ) - { - return this.levelByStacks[i]; - } + public int levelByStackAmounts(final int i) { + return this.levelByStacks[i]; + } - public int levelByMillyBuckets( final int i ) - { - return this.levelByMillibuckets[i]; - } + public int levelByMillyBuckets(final int i) { + return this.levelByMillibuckets[i]; + } // FIXME public Enum getSetting( final String category, final Class class1, final Enum myDefault ) // FIXME { @@ -426,445 +405,402 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost // FIXME this.save(); // FIXME } - public PowerUnits selectedPowerUnit() - { - return this.selectedPowerUnit; - } - - @SuppressWarnings("unchecked") - public void nextPowerUnit(final boolean backwards ) - { - this.selectedPowerUnit = EnumCycler.rotateEnum( this.selectedPowerUnit, backwards, (EnumSet) Settings.POWER_UNITS.getPossibleValues() ); - this.save(); - } - - // Getters - public boolean isRemoveCrashingItemsOnLoad() - { - return this.removeCrashingItemsOnLoad; - } - - public int getFormationPlaneEntityLimit() - { - return this.formationPlaneEntityLimit; - } - - public boolean isEnableEffects() - { - return this.enableEffects; - } - - public boolean isUseLargeFonts() - { - return this.useLargeFonts; - } - - public boolean isUseColoredCraftingStatus() - { - return this.useColoredCraftingStatus; - } - - public boolean isDisableColoredCableRecipesInJEI() - { - return this.disableColoredCableRecipesInJEI; - } - - public int getCraftingCalculationTimePerTick() - { - return this.craftingCalculationTimePerTick; - } - - public PowerUnits getSelectedPowerUnit() - { - return this.selectedPowerUnit; - } - - public int[] getCraftByStacks() - { - return this.craftByStacks; - } - - public int[] getPriorityByStacks() - { - return this.priorityByStacks; - } - - public int[] getLevelByStacks() - { - return this.levelByStacks; - } - - public String getStorageProviderID() - { - return this.storageProviderID; - } - - public String getStorageDimensionID() - { - return this.storageDimensionID; - } - - public double getSpatialPowerExponent() - { - return this.spatialPowerExponent; - } - - public double getSpatialPowerMultiplier() - { - return this.spatialPowerMultiplier; - } - - public List getGrinderOres() - { - return this.grinderOres; - } - - public Set getGrinderBlackList() - { - return this.grinderBlackList; - } - - public float getOreDoublePercentage() - { - return this.oreDoublePercentage; - } - - public DoubleSupplier getWirelessTerminalBattery() - { - return () -> this.wirelessTerminalBattery; - } - - public DoubleSupplier getEntropyManipulatorBattery() - { - return () -> this.entropyManipulatorBattery; - } - - public DoubleSupplier getMatterCannonBattery() - { - return () -> this.matterCannonBattery; - } - - public DoubleSupplier getPortableCellBattery() - { - return () -> this.portableCellBattery; - } - - public DoubleSupplier getColorApplicatorBattery() - { - return () -> this.colorApplicatorBattery; - } - - public DoubleSupplier getChargedStaffBattery() - { - return () -> this.chargedStaffBattery; - } - - public float getSpawnChargedChance() - { - return this.spawnChargedChance; - } - - public int getQuartzOresPerCluster() - { - return this.quartzOresPerCluster; - } - - public int getQuartzOresClusterAmount() - { - return this.quartzOresClusterAmount; - } - - public int getMinMeteoriteDistance() - { - return this.minMeteoriteDistance; - } - - public int getMinMeteoriteDistanceSq() - { - return this.minMeteoriteDistanceSq; - } - - public double getMeteoriteClusterChance() - { - return this.meteoriteClusterChance; - } - - public int getMeteoriteMaximumSpawnHeight() - { - return this.meteoriteMaximumSpawnHeight; - } - - public Set getMeteoriteDimensionWhitelist() - { - return this.meteoriteDimensionWhitelist; - } - - public double getWirelessBaseCost() - { - return this.wirelessBaseCost; - } - - public double getWirelessCostMultiplier() - { - return this.wirelessCostMultiplier; - } - - public double getWirelessTerminalDrainMultiplier() - { - return this.wirelessTerminalDrainMultiplier; - } - - public double getWirelessBaseRange() - { - return this.wirelessBaseRange; - } - - public double getWirelessBoosterRangeMultiplier() - { - return this.wirelessBoosterRangeMultiplier; - } - - public double getWirelessBoosterExp() - { - return this.wirelessBoosterExp; - } - - public double getWirelessHighWirelessCount() - { - return this.wirelessHighWirelessCount; - } - - // Setters keep visibility as low as possible. - - void setStorageProviderID( String id ) - { - this.storageProviderID = id; - } - - void setStorageDimensionID( String id ) - { - this.storageDimensionID = id; - } - - private static class ClientConfig { - - // Feature toggles - public final Map enabledFeatures = new EnumMap<>(AEFeature.class); - - // Misc - public final BooleanValue removeCrashingItemsOnLoad; - public final ConfigValue formationPlaneEntityLimit; - public final BooleanValue enableEffects; - public final BooleanValue useLargeFonts; - public final BooleanValue useColoredCraftingStatus; - public final BooleanValue disableColoredCableRecipesInJEI; - public final ConfigValue craftingCalculationTimePerTick; - public final EnumValue selectedPowerUnit; - - // GUI Buttons - private static final int[] BTN_BY_STACK_DEFAULTS = { 1, 10, 100, 1000 }; - public final List> craftByStacks; - public final List> priorityByStacks; - public final List> levelByStacks; - - // Spatial IO/Dimension - public final ConfigValue storageProviderID; - public final ConfigValue storageDimensionID; - public final ConfigValue spatialPowerExponent; - public final ConfigValue spatialPowerMultiplier; - - // Grindstone - public final ConfigValue> grinderOres; - public final ConfigValue> grinderBlackList; - public final DoubleValue oreDoublePercentage; - - // Batteries - public final ConfigValue wirelessTerminalBattery; - public final ConfigValue entropyManipulatorBattery; - public final ConfigValue matterCannonBattery; - public final ConfigValue portableCellBattery; - public final ConfigValue colorApplicatorBattery; - public final ConfigValue chargedStaffBattery; - - // Certus quartz - public final DoubleValue spawnChargedChance; - public final ConfigValue quartzOresPerCluster; - public final ConfigValue quartzOresClusterAmount; - - // Meteors - public final ConfigValue minMeteoriteDistance; - public final ConfigValue meteoriteClusterChance; - public final ConfigValue meteoriteMaximumSpawnHeight; - public final ConfigValue> meteoriteDimensionWhitelist; - - // Wireless - public final ConfigValue wirelessBaseCost; - public final ConfigValue wirelessCostMultiplier; - public final ConfigValue wirelessTerminalDrainMultiplier; - public final ConfigValue wirelessBaseRange; - public final ConfigValue wirelessBoosterRangeMultiplier; - public final ConfigValue wirelessBoosterExp; - - // Power Ratios - public final ConfigValue powerRatioIc2; - public final ConfigValue powerRatioForgeEnergy; - public final DoubleValue powerUsageMultiplier; - - // Condenser Power Requirement - public final ConfigValue condenserMatterBallsPower; - public final ConfigValue condenserSingularityPower; - - public final Map> tickRateMin = new HashMap<>(); - public final Map> tickRateMax = new HashMap<>(); - - public ClientConfig(ForgeConfigSpec.Builder builder) { - - // Feature switches - builder - .comment("Warning: Disabling a feature may disable other features depending on it.") - .push("features"); - - // We need to group by feature category - Map> groupedFeatures = Arrays.stream(AEFeature.values()) - .filter(AEFeature::isVisible) // Only provide config settings for visible features - .collect(Collectors.groupingBy(AEFeature::category)); - - for( final String category : groupedFeatures.keySet() ) - { - List featuresInGroup = groupedFeatures.get(category); - - builder.push(category); - for (AEFeature feature : featuresInGroup) - { - enabledFeatures.put(feature, builder - .comment(Strings.nullToEmpty(feature.comment())) - .define(feature.key(), feature.isEnabled())); - } - builder.pop(); - } - - builder.pop(); - - builder.push("general"); - removeCrashingItemsOnLoad = builder.comment("Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!") - .define("removeCrashingItemsOnLoad", false); - builder.pop(); - - builder.push("automation"); - formationPlaneEntityLimit = builder.comment("TODO") - .define("formationPlaneEntityLimit", 128 ); - builder.pop(); - - builder.push("client"); - this.disableColoredCableRecipesInJEI = builder.comment("TODO").define("disableColoredCableRecipesInJEI", true ); - this.enableEffects = builder.comment("TODO").define("enableEffects", true ); - this.useLargeFonts = builder.comment("TODO").define("useTerminalUseLargeFont", false ); - this.useColoredCraftingStatus = builder.comment("TODO").define("useColoredCraftingStatus", true ); - this.selectedPowerUnit = builder.comment("Power unit shown in AE UIs") - .defineEnum("PowerUnit", PowerUnits.AE, PowerUnits.values()); - - this.craftByStacks = new ArrayList<>(4); - this.priorityByStacks = new ArrayList<>(4); - this.levelByStacks = new ArrayList<>(4); - // load buttons.. - for( int btnNum = 0; btnNum < 4; btnNum++ ) - { - int defaultValue = BTN_BY_STACK_DEFAULTS[btnNum]; - final int buttonCap = (int) ( Math.pow( 10, btnNum + 1 ) - 1 ); - - this.craftByStacks.add(builder.comment("Controls buttons on Crafting Screen") - .defineInRange("craftByStacks" + btnNum, defaultValue, 1, buttonCap)); - this.priorityByStacks.add(builder.comment("Controls buttons on Priority Screen") - .defineInRange("priorityByStacks" + btnNum, defaultValue, 1, buttonCap)); - this.levelByStacks.add(builder.comment("Controls buttons on Level Emitter Screen") - .defineInRange("levelByStacks" + btnNum, defaultValue, 1, buttonCap)); - } - - builder.pop(); - - builder.push("craftingCPU"); - - this.craftingCalculationTimePerTick = builder.define("craftingCalculationTimePerTick", 5 ); - - builder.pop(); - - builder.push("spatialio"); - this.storageProviderID = builder.define("storageProviderID", ""); - this.storageDimensionID = builder.define("storageDimensionID", ""); - this.spatialPowerMultiplier = builder.define("spatialPowerMultiplier", 1250.0); - this.spatialPowerExponent = builder.define("spatialPowerExponent", 1.35); - builder.pop(); - - builder - .comment("Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'") - .push("GrindStone"); - - List defaultGrinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Arrays::stream ).collect(Collectors.toList()); - this.grinderOres = builder - .comment("The list of types to handle. Specify without a prefix like ore or dust.") - .defineList("grinderOres", defaultGrinderOres, obj -> true); // FIXME: tag validation, is that even possible??? - this.grinderBlackList = builder - .comment("Blacklists the exact oredict name from being handled by any recipe.") - .defineList("blacklist", Collections.emptyList(), obj -> true); // FIXME: tag validation, is that even possible??? - this.oreDoublePercentage = builder - .comment("Chance to actually get an output with stacksize > 1.") - .defineInRange("oreDoublePercentage", 90.0, 0.0, 100.0); - builder.pop(); - - builder.push("battery"); - this.wirelessTerminalBattery = builder.define("wirelessTerminal", 1600000); - this.chargedStaffBattery = builder.define("chargedStaff", 200000); - this.entropyManipulatorBattery = builder.define("entropyManipulator", 200000); - this.portableCellBattery = builder.define("portableCell", 20000); - this.colorApplicatorBattery = builder.define("colorApplicator", 20000); - this.matterCannonBattery = builder.define("matterCannon", 8000); - builder.pop(); - - builder.push("worldGen"); - - this.spawnChargedChance = builder.defineInRange("spawnChargedChance", 0.08, 0.0, 1.0); - this.minMeteoriteDistance = builder.define("minMeteoriteDistance", 707 ); - this.meteoriteClusterChance = builder.define("meteoriteClusterChance", 0.1 ); - this.meteoriteMaximumSpawnHeight = builder.define("meteoriteMaximumSpawnHeight", 180 ); - List defaultDimensionWhitelist = new ArrayList<>(); - defaultDimensionWhitelist.add(DimensionType.getKey(DimensionType.OVERWORLD).toString()); - this.meteoriteDimensionWhitelist = builder.defineList("meteoriteDimensionWhitelist", defaultDimensionWhitelist, obj -> true ); - - this.quartzOresPerCluster = builder.define("quartzOresPerCluster", 4 ); - this.quartzOresClusterAmount = builder.define("quartzOresClusterAmount", 15 ); - - builder.pop(); - - builder.push("wireless"); - this.wirelessBaseCost = builder.define("wirelessBaseCost", 8.0); - this.wirelessCostMultiplier = builder.define("wirelessCostMultiplier", 1.0); - this.wirelessBaseRange = builder.define("wirelessBaseRange", 1.0); - this.wirelessBoosterRangeMultiplier = builder.define("wirelessBoosterRangeMultiplier", 16.0); - this.wirelessBoosterExp = builder.define("wirelessBoosterExp", 1.0); - this.wirelessTerminalDrainMultiplier = builder.define("wirelessTerminalDrainMultiplier", 1.5); - builder.pop(); - - builder.push("PowerRatios"); - powerRatioIc2 = builder.define("IC2", DEFAULT_IC2_EXCHANGE); - powerRatioForgeEnergy = builder.define("ForgeEnergy", DEFAULT_RF_EXCHANGE); - powerUsageMultiplier = builder.defineInRange("UsageMultiplier", 1.0, 0.01, Double.MAX_VALUE); - builder.pop(); - - builder.push("Condenser"); - condenserMatterBallsPower = builder.define("MatterBalls", 256); - condenserSingularityPower = builder.define("Singularity", 256000); - builder.pop(); - - builder - .comment(" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested.") - .push("tickRates"); - for (TickRates tickRate : TickRates.values()) { - tickRateMin.put(tickRate, builder.define(tickRate.name() + "Min", tickRate.getDefaultMin())); - tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax())); - } - builder.pop(); - } - - } + public PowerUnits selectedPowerUnit() { + return this.selectedPowerUnit; + } + + @SuppressWarnings("unchecked") + public void nextPowerUnit(final boolean backwards) { + this.selectedPowerUnit = EnumCycler.rotateEnum(this.selectedPowerUnit, backwards, + (EnumSet) Settings.POWER_UNITS.getPossibleValues()); + this.save(); + } + + // Getters + public boolean isRemoveCrashingItemsOnLoad() { + return this.removeCrashingItemsOnLoad; + } + + public int getFormationPlaneEntityLimit() { + return this.formationPlaneEntityLimit; + } + + public boolean isEnableEffects() { + return this.enableEffects; + } + + public boolean isUseLargeFonts() { + return this.useLargeFonts; + } + + public boolean isUseColoredCraftingStatus() { + return this.useColoredCraftingStatus; + } + + public boolean isDisableColoredCableRecipesInJEI() { + return this.disableColoredCableRecipesInJEI; + } + + public int getCraftingCalculationTimePerTick() { + return this.craftingCalculationTimePerTick; + } + + public PowerUnits getSelectedPowerUnit() { + return this.selectedPowerUnit; + } + + public int[] getCraftByStacks() { + return this.craftByStacks; + } + + public int[] getPriorityByStacks() { + return this.priorityByStacks; + } + + public int[] getLevelByStacks() { + return this.levelByStacks; + } + + public String getStorageProviderID() { + return this.storageProviderID; + } + + public String getStorageDimensionID() { + return this.storageDimensionID; + } + + public double getSpatialPowerExponent() { + return this.spatialPowerExponent; + } + + public double getSpatialPowerMultiplier() { + return this.spatialPowerMultiplier; + } + + public List getGrinderOres() { + return this.grinderOres; + } + + public Set getGrinderBlackList() { + return this.grinderBlackList; + } + + public float getOreDoublePercentage() { + return this.oreDoublePercentage; + } + + public DoubleSupplier getWirelessTerminalBattery() { + return () -> this.wirelessTerminalBattery; + } + + public DoubleSupplier getEntropyManipulatorBattery() { + return () -> this.entropyManipulatorBattery; + } + + public DoubleSupplier getMatterCannonBattery() { + return () -> this.matterCannonBattery; + } + + public DoubleSupplier getPortableCellBattery() { + return () -> this.portableCellBattery; + } + + public DoubleSupplier getColorApplicatorBattery() { + return () -> this.colorApplicatorBattery; + } + + public DoubleSupplier getChargedStaffBattery() { + return () -> this.chargedStaffBattery; + } + + public float getSpawnChargedChance() { + return this.spawnChargedChance; + } + + public int getQuartzOresPerCluster() { + return this.quartzOresPerCluster; + } + + public int getQuartzOresClusterAmount() { + return this.quartzOresClusterAmount; + } + + public int getMinMeteoriteDistance() { + return this.minMeteoriteDistance; + } + + public int getMinMeteoriteDistanceSq() { + return this.minMeteoriteDistanceSq; + } + + public double getMeteoriteClusterChance() { + return this.meteoriteClusterChance; + } + + public int getMeteoriteMaximumSpawnHeight() { + return this.meteoriteMaximumSpawnHeight; + } + + public Set getMeteoriteDimensionWhitelist() { + return this.meteoriteDimensionWhitelist; + } + + public double getWirelessBaseCost() { + return this.wirelessBaseCost; + } + + public double getWirelessCostMultiplier() { + return this.wirelessCostMultiplier; + } + + public double getWirelessTerminalDrainMultiplier() { + return this.wirelessTerminalDrainMultiplier; + } + + public double getWirelessBaseRange() { + return this.wirelessBaseRange; + } + + public double getWirelessBoosterRangeMultiplier() { + return this.wirelessBoosterRangeMultiplier; + } + + public double getWirelessBoosterExp() { + return this.wirelessBoosterExp; + } + + public double getWirelessHighWirelessCount() { + return this.wirelessHighWirelessCount; + } + + // Setters keep visibility as low as possible. + + void setStorageProviderID(String id) { + this.storageProviderID = id; + } + + void setStorageDimensionID(String id) { + this.storageDimensionID = id; + } + + private static class ClientConfig { + + // Feature toggles + public final Map enabledFeatures = new EnumMap<>(AEFeature.class); + + // Misc + public final BooleanValue removeCrashingItemsOnLoad; + public final ConfigValue formationPlaneEntityLimit; + public final BooleanValue enableEffects; + public final BooleanValue useLargeFonts; + public final BooleanValue useColoredCraftingStatus; + public final BooleanValue disableColoredCableRecipesInJEI; + public final ConfigValue craftingCalculationTimePerTick; + public final EnumValue selectedPowerUnit; + + // GUI Buttons + private static final int[] BTN_BY_STACK_DEFAULTS = { 1, 10, 100, 1000 }; + public final List> craftByStacks; + public final List> priorityByStacks; + public final List> levelByStacks; + + // Spatial IO/Dimension + public final ConfigValue storageProviderID; + public final ConfigValue storageDimensionID; + public final ConfigValue spatialPowerExponent; + public final ConfigValue spatialPowerMultiplier; + + // Grindstone + public final ConfigValue> grinderOres; + public final ConfigValue> grinderBlackList; + public final DoubleValue oreDoublePercentage; + + // Batteries + public final ConfigValue wirelessTerminalBattery; + public final ConfigValue entropyManipulatorBattery; + public final ConfigValue matterCannonBattery; + public final ConfigValue portableCellBattery; + public final ConfigValue colorApplicatorBattery; + public final ConfigValue chargedStaffBattery; + + // Certus quartz + public final DoubleValue spawnChargedChance; + public final ConfigValue quartzOresPerCluster; + public final ConfigValue quartzOresClusterAmount; + + // Meteors + public final ConfigValue minMeteoriteDistance; + public final ConfigValue meteoriteClusterChance; + public final ConfigValue meteoriteMaximumSpawnHeight; + public final ConfigValue> meteoriteDimensionWhitelist; + + // Wireless + public final ConfigValue wirelessBaseCost; + public final ConfigValue wirelessCostMultiplier; + public final ConfigValue wirelessTerminalDrainMultiplier; + public final ConfigValue wirelessBaseRange; + public final ConfigValue wirelessBoosterRangeMultiplier; + public final ConfigValue wirelessBoosterExp; + + // Power Ratios + public final ConfigValue powerRatioIc2; + public final ConfigValue powerRatioForgeEnergy; + public final DoubleValue powerUsageMultiplier; + + // Condenser Power Requirement + public final ConfigValue condenserMatterBallsPower; + public final ConfigValue condenserSingularityPower; + + public final Map> tickRateMin = new HashMap<>(); + public final Map> tickRateMax = new HashMap<>(); + + public ClientConfig(ForgeConfigSpec.Builder builder) { + + // Feature switches + builder.comment("Warning: Disabling a feature may disable other features depending on it.") + .push("features"); + + // We need to group by feature category + Map> groupedFeatures = Arrays.stream(AEFeature.values()) + .filter(AEFeature::isVisible) // Only provide config settings for visible features + .collect(Collectors.groupingBy(AEFeature::category)); + + for (final String category : groupedFeatures.keySet()) { + List featuresInGroup = groupedFeatures.get(category); + + builder.push(category); + for (AEFeature feature : featuresInGroup) { + enabledFeatures.put(feature, builder.comment(Strings.nullToEmpty(feature.comment())) + .define(feature.key(), feature.isEnabled())); + } + builder.pop(); + } + + builder.pop(); + + builder.push("general"); + removeCrashingItemsOnLoad = builder.comment( + "Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!") + .define("removeCrashingItemsOnLoad", false); + builder.pop(); + + builder.push("automation"); + formationPlaneEntityLimit = builder.comment("TODO").define("formationPlaneEntityLimit", 128); + builder.pop(); + + builder.push("client"); + this.disableColoredCableRecipesInJEI = builder.comment("TODO").define("disableColoredCableRecipesInJEI", + true); + this.enableEffects = builder.comment("TODO").define("enableEffects", true); + this.useLargeFonts = builder.comment("TODO").define("useTerminalUseLargeFont", false); + this.useColoredCraftingStatus = builder.comment("TODO").define("useColoredCraftingStatus", true); + this.selectedPowerUnit = builder.comment("Power unit shown in AE UIs").defineEnum("PowerUnit", + PowerUnits.AE, PowerUnits.values()); + + this.craftByStacks = new ArrayList<>(4); + this.priorityByStacks = new ArrayList<>(4); + this.levelByStacks = new ArrayList<>(4); + // load buttons.. + for (int btnNum = 0; btnNum < 4; btnNum++) { + int defaultValue = BTN_BY_STACK_DEFAULTS[btnNum]; + final int buttonCap = (int) (Math.pow(10, btnNum + 1) - 1); + + this.craftByStacks.add(builder.comment("Controls buttons on Crafting Screen") + .defineInRange("craftByStacks" + btnNum, defaultValue, 1, buttonCap)); + this.priorityByStacks.add(builder.comment("Controls buttons on Priority Screen") + .defineInRange("priorityByStacks" + btnNum, defaultValue, 1, buttonCap)); + this.levelByStacks.add(builder.comment("Controls buttons on Level Emitter Screen") + .defineInRange("levelByStacks" + btnNum, defaultValue, 1, buttonCap)); + } + + builder.pop(); + + builder.push("craftingCPU"); + + this.craftingCalculationTimePerTick = builder.define("craftingCalculationTimePerTick", 5); + + builder.pop(); + + builder.push("spatialio"); + this.storageProviderID = builder.define("storageProviderID", ""); + this.storageDimensionID = builder.define("storageDimensionID", ""); + this.spatialPowerMultiplier = builder.define("spatialPowerMultiplier", 1250.0); + this.spatialPowerExponent = builder.define("spatialPowerExponent", 1.35); + builder.pop(); + + builder.comment( + "Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'") + .push("GrindStone"); + + List defaultGrinderOres = Stream.of(ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC) + .flatMap(Arrays::stream).collect(Collectors.toList()); + this.grinderOres = builder + .comment("The list of types to handle. Specify without a prefix like ore or dust.") + .defineList("grinderOres", defaultGrinderOres, obj -> true); // FIXME: tag validation, is that even + // possible??? + this.grinderBlackList = builder + .comment("Blacklists the exact oredict name from being handled by any recipe.") + .defineList("blacklist", Collections.emptyList(), obj -> true); // FIXME: tag validation, is that + // even possible??? + this.oreDoublePercentage = builder.comment("Chance to actually get an output with stacksize > 1.") + .defineInRange("oreDoublePercentage", 90.0, 0.0, 100.0); + builder.pop(); + + builder.push("battery"); + this.wirelessTerminalBattery = builder.define("wirelessTerminal", 1600000); + this.chargedStaffBattery = builder.define("chargedStaff", 200000); + this.entropyManipulatorBattery = builder.define("entropyManipulator", 200000); + this.portableCellBattery = builder.define("portableCell", 20000); + this.colorApplicatorBattery = builder.define("colorApplicator", 20000); + this.matterCannonBattery = builder.define("matterCannon", 8000); + builder.pop(); + + builder.push("worldGen"); + + this.spawnChargedChance = builder.defineInRange("spawnChargedChance", 0.08, 0.0, 1.0); + this.minMeteoriteDistance = builder.define("minMeteoriteDistance", 707); + this.meteoriteClusterChance = builder.define("meteoriteClusterChance", 0.1); + this.meteoriteMaximumSpawnHeight = builder.define("meteoriteMaximumSpawnHeight", 180); + List defaultDimensionWhitelist = new ArrayList<>(); + defaultDimensionWhitelist.add(DimensionType.getKey(DimensionType.OVERWORLD).toString()); + this.meteoriteDimensionWhitelist = builder.defineList("meteoriteDimensionWhitelist", + defaultDimensionWhitelist, obj -> true); + + this.quartzOresPerCluster = builder.define("quartzOresPerCluster", 4); + this.quartzOresClusterAmount = builder.define("quartzOresClusterAmount", 15); + + builder.pop(); + + builder.push("wireless"); + this.wirelessBaseCost = builder.define("wirelessBaseCost", 8.0); + this.wirelessCostMultiplier = builder.define("wirelessCostMultiplier", 1.0); + this.wirelessBaseRange = builder.define("wirelessBaseRange", 1.0); + this.wirelessBoosterRangeMultiplier = builder.define("wirelessBoosterRangeMultiplier", 16.0); + this.wirelessBoosterExp = builder.define("wirelessBoosterExp", 1.0); + this.wirelessTerminalDrainMultiplier = builder.define("wirelessTerminalDrainMultiplier", 1.5); + builder.pop(); + + builder.push("PowerRatios"); + powerRatioIc2 = builder.define("IC2", DEFAULT_IC2_EXCHANGE); + powerRatioForgeEnergy = builder.define("ForgeEnergy", DEFAULT_RF_EXCHANGE); + powerUsageMultiplier = builder.defineInRange("UsageMultiplier", 1.0, 0.01, Double.MAX_VALUE); + builder.pop(); + + builder.push("Condenser"); + condenserMatterBallsPower = builder.define("MatterBalls", 256); + condenserSingularityPower = builder.define("Singularity", 256000); + builder.pop(); + + builder.comment( + " Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested.") + .push("tickRates"); + for (TickRates tickRate : TickRates.values()) { + tickRateMin.put(tickRate, builder.define(tickRate.name() + "Min", tickRate.getDefaultMin())); + tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax())); + } + builder.pop(); + } + + } } diff --git a/src/main/java/appeng/core/AEItemGroup.java b/src/main/java/appeng/core/AEItemGroup.java index 3d1ab891d..d76e2fdcc 100644 --- a/src/main/java/appeng/core/AEItemGroup.java +++ b/src/main/java/appeng/core/AEItemGroup.java @@ -1,15 +1,16 @@ package appeng.core; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + import appeng.api.AEApi; import appeng.api.definitions.IBlocks; import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IItemDefinition; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -import java.util.ArrayList; -import java.util.List; public class AEItemGroup extends ItemGroup { diff --git a/src/main/java/appeng/core/AELog.java b/src/main/java/appeng/core/AELog.java index 7f6bccdad..627414d90 100644 --- a/src/main/java/appeng/core/AELog.java +++ b/src/main/java/appeng/core/AELog.java @@ -18,374 +18,345 @@ package appeng.core; - import javax.annotation.Nonnull; -import appeng.tile.AEBaseTile; -import appeng.util.Platform; -import net.minecraft.block.BlockState; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; +import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import appeng.api.features.AEFeature; +import appeng.tile.AEBaseTile; +import appeng.util.Platform; +public final class AELog { + private static final String LOGGER_PREFIX = "AE2:"; + private static final String SERVER_SUFFIX = "S"; + private static final String CLIENT_SUFFIX = "C"; -public final class AELog -{ - private static final String LOGGER_PREFIX = "AE2:"; - private static final String SERVER_SUFFIX = "S"; - private static final String CLIENT_SUFFIX = "C"; + private static final Logger SERVER = LogManager.getFormatterLogger(LOGGER_PREFIX + SERVER_SUFFIX); + private static final Logger CLIENT = LogManager.getFormatterLogger(LOGGER_PREFIX + CLIENT_SUFFIX); - private static final Logger SERVER = LogManager.getFormatterLogger( LOGGER_PREFIX + SERVER_SUFFIX ); - private static final Logger CLIENT = LogManager.getFormatterLogger( LOGGER_PREFIX + CLIENT_SUFFIX ); + private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s ). State %s -> %s"; - private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s ). State %s -> %s"; + private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: "; - private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: "; + private AELog() { + } - private AELog() - { - } + /** + * Returns a {@link Logger} logger suitable for the effective side + * (client/server). + * + * @return a suitable logger instance + */ + private static Logger getLogger() { + return Platform.isServer() ? SERVER : CLIENT; + } - /** - * Returns a {@link Logger} logger suitable for the effective side (client/server). - * - * @return a suitable logger instance - */ - private static Logger getLogger() - { - return Platform.isServer() ? SERVER : CLIENT; - } + /** + * Indicates of the global log is enabled or disabled. + * + * By default it is enabled. + * + * @return true when the log is enabled. + */ + public static boolean isLogEnabled() { + return AEConfig.instance() == null || AEConfig.instance().isFeatureEnabled(AEFeature.LOGGING); + } - /** - * Indicates of the global log is enabled or disabled. - * - * By default it is enabled. - * - * @return true when the log is enabled. - */ - public static boolean isLogEnabled() - { - return AEConfig.instance() == null || AEConfig.instance().isFeatureEnabled( AEFeature.LOGGING ); - } + /** + * Logs a formatted message with a specific log level. + * + * This uses {@link String#format(String, Object...)} as opposed to the + * {@link ParameterizedMessage} to allow a more flexible formatting. + * + * The output can be globally disabled via the configuration file. + * + * @param level the intended level. + * @param message the message to be formatted. + * @param params the parameters used for + * {@link String#format(String, Object...)}. + */ + public static void log(@Nonnull final Level level, @Nonnull final String message, final Object... params) { + if (AELog.isLogEnabled()) { + final String formattedMessage = String.format(message, params); + final Logger logger = getLogger(); - /** - * Logs a formatted message with a specific log level. - * - * This uses {@link String#format(String, Object...)} as opposed to the {@link ParameterizedMessage} to allow a more - * flexible formatting. - * - * The output can be globally disabled via the configuration file. - * - * @param level the intended level. - * @param message the message to be formatted. - * @param params the parameters used for {@link String#format(String, Object...)}. - */ - public static void log( @Nonnull final Level level, @Nonnull final String message, final Object... params ) - { - if( AELog.isLogEnabled() ) - { - final String formattedMessage = String.format( message, params ); - final Logger logger = getLogger(); + logger.log(level, formattedMessage); + } + } - logger.log( level, formattedMessage ); - } - } + /** + * Log an exception with a custom message formated via + * {@link String#format(String, Object...)} + * + * Similar to {@link AELog#log(Level, String, Object...)}. + * + * @see AELog#log(Level, String, Object...) + * + * @param level the intended level. + * @param exception + * @param message the message to be formatted. + * @param params the parameters used for + * {@link String#format(String, Object...)}. + */ + public static void log(@Nonnull final Level level, @Nonnull final Throwable exception, @Nonnull String message, + final Object... params) { + if (AELog.isLogEnabled()) { + final String formattedMessage = String.format(message, params); + final Logger logger = getLogger(); - /** - * Log an exception with a custom message formated via {@link String#format(String, Object...)} - * - * Similar to {@link AELog#log(Level, String, Object...)}. - * - * @see AELog#log(Level, String, Object...) - * - * @param level the intended level. - * @param exception - * @param message the message to be formatted. - * @param params the parameters used for {@link String#format(String, Object...)}. - */ - public static void log( @Nonnull final Level level, @Nonnull final Throwable exception, @Nonnull String message, final Object... params ) - { - if( AELog.isLogEnabled() ) - { - final String formattedMessage = String.format( message, params ); - final Logger logger = getLogger(); + logger.log(level, formattedMessage, exception); + } + } - logger.log( level, formattedMessage, exception ); - } - } + /** + * @see AELog#log(Level, String, Object...) + * @param format + * @param params + */ + public static void info(@Nonnull final String format, final Object... params) { + log(Level.INFO, format, params); + } - /** - * @see AELog#log(Level, String, Object...) - * @param format - * @param params - */ - public static void info( @Nonnull final String format, final Object... params ) - { - log( Level.INFO, format, params ); - } + /** + * Log exception as {@link Level#INFO} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + */ + public static void info(@Nonnull final Throwable exception) { + log(Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE); + } - /** - * Log exception as {@link Level#INFO} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - */ - public static void info( @Nonnull final Throwable exception ) - { - log( Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE ); - } + /** + * Log exception as {@link Level#INFO} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + * @param message + */ + public static void info(@Nonnull final Throwable exception, @Nonnull final String message) { + log(Level.INFO, exception, message); + } - /** - * Log exception as {@link Level#INFO} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - * @param message - */ - public static void info( @Nonnull final Throwable exception, @Nonnull final String message ) - { - log( Level.INFO, exception, message ); - } + /** + * @see AELog#log(Level, String, Object...) + * @param format + * @param params + */ + public static void warn(@Nonnull final String format, final Object... params) { + log(Level.WARN, format, params); + } - /** - * @see AELog#log(Level, String, Object...) - * @param format - * @param params - */ - public static void warn( @Nonnull final String format, final Object... params ) - { - log( Level.WARN, format, params ); - } + /** + * Log exception as {@link Level#WARN} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + */ + public static void warn(@Nonnull final Throwable exception) { + log(Level.WARN, exception, DEFAULT_EXCEPTION_MESSAGE); + } - /** - * Log exception as {@link Level#WARN} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - */ - public static void warn( @Nonnull final Throwable exception ) - { - log( Level.WARN, exception, DEFAULT_EXCEPTION_MESSAGE ); - } + /** + * Log exception as {@link Level#WARN} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + * @param message + */ + public static void warn(@Nonnull final Throwable exception, @Nonnull final String message) { + log(Level.WARN, exception, message); + } - /** - * Log exception as {@link Level#WARN} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - * @param message - */ - public static void warn( @Nonnull final Throwable exception, @Nonnull final String message ) - { - log( Level.WARN, exception, message ); - } + /** + * @see AELog#log(Level, String, Object...) + * @param format + * @param params + */ + public static void error(@Nonnull final String format, final Object... params) { + log(Level.ERROR, format, params); + } - /** - * @see AELog#log(Level, String, Object...) - * @param format - * @param params - */ - public static void error( @Nonnull final String format, final Object... params ) - { - log( Level.ERROR, format, params ); - } + /** + * Log exception as {@link Level#ERROR} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + */ + public static void error(@Nonnull final Throwable exception) { + log(Level.ERROR, exception, DEFAULT_EXCEPTION_MESSAGE); + } - /** - * Log exception as {@link Level#ERROR} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - */ - public static void error( @Nonnull final Throwable exception ) - { - log( Level.ERROR, exception, DEFAULT_EXCEPTION_MESSAGE ); - } + /** + * Log exception as {@link Level#ERROR} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + * @param message + */ + public static void error(@Nonnull final Throwable exception, @Nonnull final String message) { + log(Level.ERROR, exception, message); + } - /** - * Log exception as {@link Level#ERROR} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - * @param message - */ - public static void error( @Nonnull final Throwable exception, @Nonnull final String message ) - { - log( Level.ERROR, exception, message ); - } + /** + * Log message as {@link Level#DEBUG} + * + * @see AELog#log(Level, String, Object...) + * @param format + * @param data + */ + public static void debug(@Nonnull final String format, final Object... data) { + if (AELog.isDebugLogEnabled()) { + log(Level.DEBUG, format, data); + } + } - /** - * Log message as {@link Level#DEBUG} - * - * @see AELog#log(Level, String, Object...) - * @param format - * @param data - */ - public static void debug( @Nonnull final String format, final Object... data ) - { - if( AELog.isDebugLogEnabled() ) - { - log( Level.DEBUG, format, data ); - } - } + /** + * Log exception as {@link Level#DEBUG} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + */ + public static void debug(@Nonnull final Throwable exception) { + if (AELog.isDebugLogEnabled()) { + log(Level.DEBUG, exception, DEFAULT_EXCEPTION_MESSAGE); + } + } - /** - * Log exception as {@link Level#DEBUG} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - */ - public static void debug( @Nonnull final Throwable exception ) - { - if( AELog.isDebugLogEnabled() ) - { - log( Level.DEBUG, exception, DEFAULT_EXCEPTION_MESSAGE ); - } - } + /** + * Log exception as {@link Level#DEBUG} + * + * @see AELog#log(Level, Throwable, String, Object...) + * + * @param exception + * @param message + */ + public static void debug(@Nonnull final Throwable exception, @Nonnull final String message) { + if (AELog.isDebugLogEnabled()) { + log(Level.DEBUG, exception, message); + } + } - /** - * Log exception as {@link Level#DEBUG} - * - * @see AELog#log(Level, Throwable, String, Object...) - * - * @param exception - * @param message - */ - public static void debug( @Nonnull final Throwable exception, @Nonnull final String message ) - { - if( AELog.isDebugLogEnabled() ) - { - log( Level.DEBUG, exception, message ); - } - } + /** + * Use to check for an enabled debug log. + * + * Can be used to prevent the execution of debug logic. + * + * @return true when the debug log is enabled. + */ + public static boolean isDebugLogEnabled() { + return AEConfig.instance().isFeatureEnabled(AEFeature.DEBUG_LOGGING); + } - /** - * Use to check for an enabled debug log. - * - * Can be used to prevent the execution of debug logic. - * - * @return true when the debug log is enabled. - */ - public static boolean isDebugLogEnabled() - { - return AEConfig.instance().isFeatureEnabled( AEFeature.DEBUG_LOGGING ); - } + // + // Specialized handlers + // - // - // Specialized handlers - // + /** + * A specialized logging for grinder recipes, can be disabled inside + * configuration file. + * + * @param message String to be logged + */ + public static void grinder(@Nonnull final String message, final Object... params) { + if (AEConfig.instance().isFeatureEnabled(AEFeature.GRINDER_LOGGING)) { + log(Level.DEBUG, "grinder: " + message, params); + } + } - /** - * A specialized logging for grinder recipes, can be disabled inside configuration file. - * - * @param message String to be logged - */ - public static void grinder( @Nonnull final String message, final Object... params ) - { - if( AEConfig.instance().isFeatureEnabled( AEFeature.GRINDER_LOGGING ) ) - { - log( Level.DEBUG, "grinder: " + message, params ); - } - } + /** + * A specialized logging for mod integration errors, can be disabled inside + * configuration file. + * + * @param exception + */ + public static void integration(@Nonnull final Throwable exception) { + if (AEConfig.instance().isFeatureEnabled(AEFeature.INTEGRATION_LOGGING)) { + debug(exception); + } + } - /** - * A specialized logging for mod integration errors, can be disabled inside configuration file. - * - * @param exception - */ - public static void integration( @Nonnull final Throwable exception ) - { - if( AEConfig.instance().isFeatureEnabled( AEFeature.INTEGRATION_LOGGING ) ) - { - debug( exception ); - } - } + /** + * Logging of block updates. + * + * Off by default, can be enabled inside the configuration file. + * + * @see AELog#log(Level, String, Object...) + * @param pos + * @param currentState + * @param newState + * @param aeBaseTile + */ + public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState, + @Nonnull BlockState newState, @Nonnull final AEBaseTile aeBaseTile) { + if (AEConfig.instance().isFeatureEnabled(AEFeature.UPDATE_LOGGING)) { + info(BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState); + } + } - /** - * Logging of block updates. - * - * Off by default, can be enabled inside the configuration file. - * - * @see AELog#log(Level, String, Object...) - * @param pos - * @param currentState - * @param newState - * @param aeBaseTile - */ - public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState, @Nonnull BlockState newState, @Nonnull final AEBaseTile aeBaseTile) - { - if( AEConfig.instance().isFeatureEnabled( AEFeature.UPDATE_LOGGING ) ) - { - info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState ); - } - } + /** + * Use to check for an enabled crafting log. + * + * Can be used to prevent the execution of unneeded logic. + * + * @return true when the crafting log is enabled. + */ + public static boolean isCraftingLogEnabled() { + return AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_LOG); + } - /** - * Use to check for an enabled crafting log. - * - * Can be used to prevent the execution of unneeded logic. - * - * @return true when the crafting log is enabled. - */ - public static boolean isCraftingLogEnabled() - { - return AEConfig.instance().isFeatureEnabled( AEFeature.CRAFTING_LOG ); - } + /** + * Logging for autocrafting. + * + * Off by default, can be enabled inside the configuration file. + * + * @see AELog#log(Level, String, Object...) + * @param message + * @param params + */ + public static void crafting(@Nonnull final String message, final Object... params) { + if (AELog.isCraftingLogEnabled()) { + log(Level.INFO, message, params); + } + } - /** - * Logging for autocrafting. - * - * Off by default, can be enabled inside the configuration file. - * - * @see AELog#log(Level, String, Object...) - * @param message - * @param params - */ - public static void crafting( @Nonnull final String message, final Object... params ) - { - if( AELog.isCraftingLogEnabled() ) - { - log( Level.INFO, message, params ); - } - } + /** + * Use to check for an enabled crafting debug log. + * + * Can be used to prevent the execution of unneeded logic. + * + * @return true when the crafting debug log is enabled. + */ + public static boolean isCraftingDebugLogEnabled() { + return AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_LOG) + && AEConfig.instance().isFeatureEnabled(AEFeature.DEBUG_LOGGING); + } - /** - * Use to check for an enabled crafting debug log. - * - * Can be used to prevent the execution of unneeded logic. - * - * @return true when the crafting debug log is enabled. - */ - public static boolean isCraftingDebugLogEnabled() - { - return AEConfig.instance().isFeatureEnabled( AEFeature.CRAFTING_LOG ) && AEConfig.instance().isFeatureEnabled( AEFeature.DEBUG_LOGGING ); - } - - /** - * Debug logging for autocrafting. - * - * Off by default, can be enabled inside the configuration file. - * - * @see AELog#log(Level, String, Object...) - * @param message - * @param params - */ - public static void craftingDebug( @Nonnull final String message, final Object... params ) - { - if( AELog.isCraftingDebugLogEnabled() ) - { - log( Level.DEBUG, message, params ); - } - } + /** + * Debug logging for autocrafting. + * + * Off by default, can be enabled inside the configuration file. + * + * @see AELog#log(Level, String, Object...) + * @param message + * @param params + */ + public static void craftingDebug(@Nonnull final String message, final Object... params) { + if (AELog.isCraftingDebugLogEnabled()) { + log(Level.DEBUG, message, params); + } + } } diff --git a/src/main/java/appeng/core/AERecipeType.java b/src/main/java/appeng/core/AERecipeType.java index 776313d26..7439cfb8a 100644 --- a/src/main/java/appeng/core/AERecipeType.java +++ b/src/main/java/appeng/core/AERecipeType.java @@ -1,10 +1,11 @@ package appeng.core; -import appeng.recipes.handlers.GrinderRecipe; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.util.ResourceLocation; +import appeng.recipes.handlers.GrinderRecipe; + public class AERecipeType> implements IRecipeType { private final String id; diff --git a/src/main/java/appeng/core/Api.java b/src/main/java/appeng/core/Api.java index d251c6811..e94881606 100644 --- a/src/main/java/appeng/core/Api.java +++ b/src/main/java/appeng/core/Api.java @@ -18,7 +18,6 @@ package appeng.core; - import appeng.api.IAppEngApi; import appeng.api.features.IRegistryContainer; import appeng.api.networking.IGridHelper; @@ -31,69 +30,59 @@ import appeng.core.api.ApiStorage; import appeng.core.features.registries.PartModels; import appeng.core.features.registries.RegistryContainer; +public final class Api implements IAppEngApi { + public static final Api INSTANCE = new Api(); -public final class Api implements IAppEngApi -{ - public static final Api INSTANCE = new Api(); + private final ApiPart partHelper; - private final ApiPart partHelper; + // private MovableTileRegistry MovableRegistry = new MovableTileRegistry(); + private final IRegistryContainer registryContainer; + private final IStorageHelper storageHelper; + private final IGridHelper networkHelper; + private final ApiDefinitions definitions; + private final IClientHelper client; - // private MovableTileRegistry MovableRegistry = new MovableTileRegistry(); - private final IRegistryContainer registryContainer; - private final IStorageHelper storageHelper; - private final IGridHelper networkHelper; - private final ApiDefinitions definitions; - private final IClientHelper client; + private Api() { + this.storageHelper = new ApiStorage(); + this.networkHelper = new ApiGrid(); + this.registryContainer = new RegistryContainer(); + this.partHelper = new ApiPart(); + this.definitions = new ApiDefinitions((PartModels) this.registryContainer.partModels()); + this.client = new ApiClientHelper(); + } - private Api() - { - this.storageHelper = new ApiStorage(); - this.networkHelper = new ApiGrid(); - this.registryContainer = new RegistryContainer(); - this.partHelper = new ApiPart(); - this.definitions = new ApiDefinitions( (PartModels) this.registryContainer.partModels() ); - this.client = new ApiClientHelper(); - } + public PartModels getPartModels() { + return (PartModels) this.registryContainer.partModels(); + } - public PartModels getPartModels() - { - return (PartModels) this.registryContainer.partModels(); - } + @Override + public IRegistryContainer registries() { + return this.registryContainer; + } - @Override - public IRegistryContainer registries() - { - return this.registryContainer; - } + @Override + public IStorageHelper storage() { + return this.storageHelper; + } - @Override - public IStorageHelper storage() - { - return this.storageHelper; - } + @Override + public IGridHelper grid() { + return this.networkHelper; + } - @Override - public IGridHelper grid() - { - return this.networkHelper; - } + @Override + public ApiPart partHelper() { + return this.partHelper; + } - @Override - public ApiPart partHelper() - { - return this.partHelper; - } + @Override + public ApiDefinitions definitions() { + return this.definitions; + } - @Override - public ApiDefinitions definitions() - { - return this.definitions; - } - - @Override - public IClientHelper client() - { - return this.client; - } + @Override + public IClientHelper client() { + return this.client; + } } diff --git a/src/main/java/appeng/core/ApiDefinitions.java b/src/main/java/appeng/core/ApiDefinitions.java index a1eb18306..36ab4ddcd 100644 --- a/src/main/java/appeng/core/ApiDefinitions.java +++ b/src/main/java/appeng/core/ApiDefinitions.java @@ -18,7 +18,6 @@ package appeng.core; - import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IItems; import appeng.api.definitions.IMaterials; @@ -30,53 +29,45 @@ import appeng.core.api.definitions.ApiMaterials; import appeng.core.api.definitions.ApiParts; import appeng.core.features.registries.PartModels; - /** * 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; +public final class ApiDefinitions implements IDefinitions { + private final ApiBlocks blocks; + private final ApiItems items; + private final ApiMaterials materials; + private final ApiParts parts; - private final FeatureFactory registry = new FeatureFactory(); + private final FeatureFactory registry = new FeatureFactory(); - public ApiDefinitions( final PartModels partModels ) - { - this.blocks = new ApiBlocks( this.registry); - this.materials = new ApiMaterials( this.registry ); - this.items = new ApiItems( this.registry, this.materials ); - this.parts = new ApiParts( this.registry, partModels ); - } + public ApiDefinitions(final PartModels partModels) { + this.blocks = new ApiBlocks(this.registry); + this.materials = new ApiMaterials(this.registry); + this.items = new ApiItems(this.registry, this.materials); + this.parts = new ApiParts(this.registry, partModels); + } - public FeatureFactory getRegistry() - { - return registry; - } + public FeatureFactory getRegistry() { + return registry; + } - @Override - public ApiBlocks blocks() - { - return this.blocks; - } + @Override + public ApiBlocks blocks() { + return this.blocks; + } - @Override - public IItems items() - { - return items; - } + @Override + public IItems items() { + return items; + } - @Override - public IMaterials materials() - { - return materials; - } + @Override + public IMaterials materials() { + return materials; + } - @Override - public IParts parts() - { - return parts; - } + @Override + public IParts parts() { + return parts; + } } diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index 2e4a63805..5e45ceebb 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -18,33 +18,13 @@ package appeng.core; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; -import appeng.block.paint.PaintSplotchesModel; -import appeng.block.qnb.QnbFormedModel; -import appeng.bootstrap.components.IClientSetupComponent; -import appeng.bootstrap.components.IInitComponent; -import appeng.bootstrap.components.IPostInitComponent; -import appeng.capabilities.Capabilities; -import appeng.client.ClientHelper; -import appeng.client.render.DummyFluidItemModel; -import appeng.client.render.SimpleModelLoader; -import appeng.client.render.cablebus.CableBusModelLoader; -import appeng.client.render.cablebus.P2PTunnelFrequencyModel; -import appeng.client.render.crafting.CraftingCubeModelLoader; -import appeng.client.render.crafting.EncodedPatternModelLoader; -import appeng.client.render.model.*; -import appeng.client.render.spatial.SpatialPylonModel; -import appeng.core.crash.ModCrashEnhancement; -import appeng.core.features.registries.PartModels; -import appeng.core.stats.AdvancementTriggers; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.worlddata.WorldData; -import appeng.entity.*; -import appeng.hooks.TickHandler; -import appeng.parts.PartPlacement; -import appeng.parts.automation.PlaneModelLoader; -import appeng.server.ServerHelper; import com.google.common.base.Stopwatch; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.ItemRenderer; @@ -77,146 +57,179 @@ import net.minecraftforge.fml.event.server.FMLServerStoppedEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import javax.annotation.Nonnull; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; - +import appeng.block.paint.PaintSplotchesModel; +import appeng.block.qnb.QnbFormedModel; +import appeng.bootstrap.components.IClientSetupComponent; +import appeng.bootstrap.components.IInitComponent; +import appeng.bootstrap.components.IPostInitComponent; +import appeng.capabilities.Capabilities; +import appeng.client.ClientHelper; +import appeng.client.render.DummyFluidItemModel; +import appeng.client.render.SimpleModelLoader; +import appeng.client.render.cablebus.CableBusModelLoader; +import appeng.client.render.cablebus.P2PTunnelFrequencyModel; +import appeng.client.render.crafting.CraftingCubeModelLoader; +import appeng.client.render.crafting.EncodedPatternModelLoader; +import appeng.client.render.model.*; +import appeng.client.render.spatial.SpatialPylonModel; +import appeng.core.crash.ModCrashEnhancement; +import appeng.core.features.registries.PartModels; +import appeng.core.stats.AdvancementTriggers; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.worlddata.WorldData; +import appeng.entity.*; +import appeng.hooks.TickHandler; +import appeng.parts.PartPlacement; +import appeng.parts.automation.PlaneModelLoader; +import appeng.server.ServerHelper; @Mod(AppEng.MOD_ID) -public final class AppEng -{ - public static CommonHelper proxy; +public final class AppEng { + public static CommonHelper proxy; - public static final String MOD_ID = "appliedenergistics2"; - public static final String MOD_NAME = "Applied Energistics 2"; + public static final String MOD_ID = "appliedenergistics2"; + public static final String MOD_NAME = "Applied Energistics 2"; - public static final String ASSETS = "appliedenergistics2:"; + public static final String ASSETS = "appliedenergistics2:"; - // FIXME replicate this in mods.toml! - // FIXME private static final String FORGE_CURRENT_VERSION = ForgeVersion.getVersion(); - // FIXME private static final String FORGE_MAX_VERSION = ( ForgeVersion.majorVersion + 1 ) + ".0.0.0"; - // FIXME public static final String MOD_DEPENDENCIES = "required-after:forge@[" + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");after:ctm@[" + CTM.VERSION + ",);"; + // FIXME replicate this in mods.toml! + // FIXME private static final String FORGE_CURRENT_VERSION = + // ForgeVersion.getVersion(); + // FIXME private static final String FORGE_MAX_VERSION = ( + // ForgeVersion.majorVersion + 1 ) + ".0.0.0"; + // FIXME public static final String MOD_DEPENDENCIES = "required-after:forge@[" + // + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");after:ctm@[" + + // CTM.VERSION + ",);"; - private static AppEng INSTANCE; + private static AppEng INSTANCE; - private final Registration registration; + private final Registration registration; - /** - * determined in pre-init but used in init - */ + /** + * determined in pre-init but used in init + */ - public AppEng() - { - if (INSTANCE != null) { - throw new IllegalStateException(); - } - INSTANCE = this; + public AppEng() { + if (INSTANCE != null) { + throw new IllegalStateException(); + } + INSTANCE = this; - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC); + ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC); - proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new); + proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new); - CrashReportExtender.registerCrashCallable( new ModCrashEnhancement() ); + CrashReportExtender.registerCrashCallable(new ModCrashEnhancement()); - //FIXMEthis.registration = new Registration(); - //FIXMEMinecraftForge.EVENT_BUS.register( this.registration ); + // FIXMEthis.registration = new Registration(); + // FIXMEMinecraftForge.EVENT_BUS.register( this.registration ); - CreativeTab.init(); - CreativeTabFacade.init(); + CreativeTab.init(); + CreativeTabFacade.init(); - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - registration = new Registration(); - modEventBus.addGenericListener(Block.class, registration::registerBlocks); - modEventBus.addGenericListener(Item.class, registration::registerItems); - modEventBus.addGenericListener(EntityType.class, registration::registerEntities); - modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes); - modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities); - modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes); - modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers); - modEventBus.addGenericListener(Feature.class, registration::registerWorldGen); - modEventBus.addGenericListener(Biome.class, registration::registerBiomes); - modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension); - modEventBus.addListener(registration::registerParticleFactories); - modEventBus.addListener(registration::registerTextures); - modEventBus.addListener(registration::registerCommands); + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + registration = new Registration(); + modEventBus.addGenericListener(Block.class, registration::registerBlocks); + modEventBus.addGenericListener(Item.class, registration::registerItems); + modEventBus.addGenericListener(EntityType.class, registration::registerEntities); + modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes); + modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities); + modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes); + modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers); + modEventBus.addGenericListener(Feature.class, registration::registerWorldGen); + modEventBus.addGenericListener(Biome.class, registration::registerBiomes); + modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension); + modEventBus.addListener(registration::registerParticleFactories); + modEventBus.addListener(registration::registerTextures); + modEventBus.addListener(registration::registerCommands); - modEventBus.addListener(this::commonSetup); + modEventBus.addListener(this::commonSetup); - // Register client-only events - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup)); - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent)); - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::registerItemColors)); - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::handleModelBake)); + // Register client-only events + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup)); + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent)); + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::registerItemColors)); + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::handleModelBake)); - MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::unloadWorld ); - MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::onTick ); - MinecraftForge.EVENT_BUS.addListener( this::onServerAboutToStart ); - MinecraftForge.EVENT_BUS.addListener( this::serverStopped ); - MinecraftForge.EVENT_BUS.addListener( this::serverStopping ); + MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::unloadWorld); + MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::onTick); + MinecraftForge.EVENT_BUS.addListener(this::onServerAboutToStart); + MinecraftForge.EVENT_BUS.addListener(this::serverStopped); + MinecraftForge.EVENT_BUS.addListener(this::serverStopping); - MinecraftForge.EVENT_BUS.register( new PartPlacement() ); - } + MinecraftForge.EVENT_BUS.register(new PartPlacement()); + } - private void commonSetup(FMLCommonSetupEvent event) { + private void commonSetup(FMLCommonSetupEvent event) { - ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining(IInitComponent::initialize); - definitions.getRegistry().getBootstrapComponents( IPostInitComponent.class ).forEachRemaining(IPostInitComponent::postInitialize); + ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(IInitComponent.class) + .forEachRemaining(IInitComponent::initialize); + definitions.getRegistry().getBootstrapComponents(IPostInitComponent.class) + .forEachRemaining(IPostInitComponent::postInitialize); - Capabilities.register(); - Registration.setupInternalRegistries(); - Registration.postInit(); + Capabilities.register(); + Registration.setupInternalRegistries(); + Registration.postInit(); - registerNetworkHandler(); + registerNetworkHandler(); - } + } - @OnlyIn(Dist.CLIENT) - private void clientSetup(FMLClientSetupEvent event) { + @OnlyIn(Dist.CLIENT) + private void clientSetup(FMLClientSetupEvent event) { - ((ClientHelper) proxy).clientInit(); + ((ClientHelper) proxy).clientInit(); - RenderingRegistry.registerEntityRenderingHandler(EntityTinyTNTPrimed.TYPE, RenderTinyTNTPrimed::new); - RenderingRegistry.registerEntityRenderingHandler(EntityFloatingItem.TYPE, RenderFloatingItem::new); - RenderingRegistry.registerEntityRenderingHandler(EntitySingularity.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); - RenderingRegistry.registerEntityRenderingHandler(EntityGrowingCrystal.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); - RenderingRegistry.registerEntityRenderingHandler(EntityChargedQuartz.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); + RenderingRegistry.registerEntityRenderingHandler(EntityTinyTNTPrimed.TYPE, RenderTinyTNTPrimed::new); + RenderingRegistry.registerEntityRenderingHandler(EntityFloatingItem.TYPE, RenderFloatingItem::new); + RenderingRegistry.registerEntityRenderingHandler(EntitySingularity.TYPE, + m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); + RenderingRegistry.registerEntityRenderingHandler(EntityGrowingCrystal.TYPE, + m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); + RenderingRegistry.registerEntityRenderingHandler(EntityChargedQuartz.TYPE, + m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer())); - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( IClientSetupComponent.class ).forEachRemaining(IClientSetupComponent::setup); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class) + .forEachRemaining(IClientSetupComponent::setup); - addBuiltInModel("glass", GlassModel::new); - addBuiltInModel("sky_compass", SkyCompassModel::new); - addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new); - addBuiltInModel("memory_card", MemoryCardModel::new); - addBuiltInModel("biometric_card", BiometricCardModel::new); - addBuiltInModel("drive", DriveModel::new); - addBuiltInModel("color_applicator", ColorApplicatorModel::new); - addBuiltInModel("spatial_pylon", SpatialPylonModel::new); - addBuiltInModel("paint_splotches", PaintSplotchesModel::new); - addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new); - addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new); - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"), EncodedPatternModelLoader.INSTANCE); - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"), PlaneModelLoader.INSTANCE); - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"), CraftingCubeModelLoader.INSTANCE); - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE); - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"), new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels())); + addBuiltInModel("glass", GlassModel::new); + addBuiltInModel("sky_compass", SkyCompassModel::new); + addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new); + addBuiltInModel("memory_card", MemoryCardModel::new); + addBuiltInModel("biometric_card", BiometricCardModel::new); + addBuiltInModel("drive", DriveModel::new); + addBuiltInModel("color_applicator", ColorApplicatorModel::new); + addBuiltInModel("spatial_pylon", SpatialPylonModel::new); + addBuiltInModel("paint_splotches", PaintSplotchesModel::new); + addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new); + addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new); + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"), + EncodedPatternModelLoader.INSTANCE); + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"), + PlaneModelLoader.INSTANCE); + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"), + CraftingCubeModelLoader.INSTANCE); + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE); + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"), + new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels())); - } + } - private static > void addBuiltInModel(String id, Supplier modelFactory) { - ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id), new SimpleModelLoader(modelFactory)); - } + private static > void addBuiltInModel(String id, Supplier modelFactory) { + ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id), + new SimpleModelLoader(modelFactory)); + } - @Nonnull - public static AppEng instance() - { - if (INSTANCE == null) { - throw new IllegalStateException(); - } - return INSTANCE; - } + @Nonnull + public static AppEng instance() { + if (INSTANCE == null) { + throw new IllegalStateException(); + } + return INSTANCE; + } // public Biome getStorageBiome() // { @@ -233,10 +246,9 @@ public final class AppEng // return this.registration.storageDimensionID; // } - public AdvancementTriggers getAdvancementTriggers() - { - return this.registration.advancementTriggers; - } + public AdvancementTriggers getAdvancementTriggers() { + return this.registration.advancementTriggers; + } // @EventHandler // private void preInit( final FMLPreInitializationEvent event ) @@ -278,45 +290,41 @@ public final class AppEng // new PluginLoader().loadPlugins( injectables, event.getAsmData() ); // } - private void startService( final String serviceName, final Thread thread ) - { - thread.setName( serviceName ); - thread.setPriority( Thread.MIN_PRIORITY ); + private void startService(final String serviceName, final Thread thread) { + thread.setName(serviceName); + thread.setPriority(Thread.MIN_PRIORITY); - AELog.info( "Starting " + serviceName ); - thread.start(); - } + AELog.info("Starting " + serviceName); + thread.start(); + } - private void registerNetworkHandler() - { - final Stopwatch start = Stopwatch.createStarted(); - AELog.info( "Post Initialization ( started )" ); + private void registerNetworkHandler() { + final Stopwatch start = Stopwatch.createStarted(); + AELog.info("Post Initialization ( started )"); - // FIXME IntegrationRegistry.INSTANCE.postInit(); - // FIXME CrashReportExtender.registerCrashCallable( new IntegrationCrashEnhancement() ); + // FIXME IntegrationRegistry.INSTANCE.postInit(); + // FIXME CrashReportExtender.registerCrashCallable( new + // IntegrationCrashEnhancement() ); - AppEng.proxy.postInit(); - AEConfig.instance().save(); + AppEng.proxy.postInit(); + AEConfig.instance().save(); - NetworkHandler.init( new ResourceLocation(MOD_ID, "main") ); + NetworkHandler.init(new ResourceLocation(MOD_ID, "main")); - AELog.info( "Post Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" ); - } + AELog.info("Post Initialization ( ended after " + start.elapsed(TimeUnit.MILLISECONDS) + "ms )"); + } - private void onServerAboutToStart(final FMLServerAboutToStartEvent evt) - { - WorldData.onServerStarting( evt.getServer() ); - } + private void onServerAboutToStart(final FMLServerAboutToStartEvent evt) { + WorldData.onServerStarting(evt.getServer()); + } - private void serverStopping( final FMLServerStoppingEvent event ) - { - WorldData.instance().onServerStopping(); - } + private void serverStopping(final FMLServerStoppingEvent event) { + WorldData.instance().onServerStopping(); + } - private void serverStopped( final FMLServerStoppedEvent event ) - { - WorldData.instance().onServerStoppped(); - TickHandler.INSTANCE.shutdown(); - } + private void serverStopped(final FMLServerStoppedEvent event) { + WorldData.instance().onServerStoppped(); + TickHandler.INSTANCE.shutdown(); + } } diff --git a/src/main/java/appeng/core/CommonHelper.java b/src/main/java/appeng/core/CommonHelper.java index eb35837fb..d5a2fc4cb 100644 --- a/src/main/java/appeng/core/CommonHelper.java +++ b/src/main/java/appeng/core/CommonHelper.java @@ -18,7 +18,6 @@ package appeng.core; - import java.util.List; import java.util.Random; @@ -36,32 +35,32 @@ import appeng.client.ActionKey; import appeng.client.EffectType; import appeng.core.sync.AppEngPacket; +public abstract class CommonHelper { -public abstract class CommonHelper -{ + public abstract World getWorld(); - public abstract World getWorld(); + public abstract void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk); - public abstract void bindTileEntitySpecialRenderer( Class tile, AEBaseBlock blk ); + public abstract List getPlayers(); - public abstract List getPlayers(); + public abstract void sendToAllNearExcept(PlayerEntity p, double x, double y, double z, double dist, World w, + AppEngPacket packet); - public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet ); + public abstract void spawnEffect(EffectType effect, World world, double posX, double posY, double posZ, + Object extra); - public abstract void spawnEffect( EffectType effect, World world, double posX, double posY, double posZ, Object extra ); + public abstract boolean shouldAddParticles(Random r); - public abstract boolean shouldAddParticles( Random r ); + public abstract RayTraceResult getRTR(); - public abstract RayTraceResult getRTR(); + public abstract void postInit(); - public abstract void postInit(); + public abstract CableRenderMode getRenderMode(); - public abstract CableRenderMode getRenderMode(); + public abstract void triggerUpdates(); - public abstract void triggerUpdates(); + public abstract void updateRenderMode(PlayerEntity player); - public abstract void updateRenderMode( PlayerEntity player ); - - public abstract boolean isActionKey( @Nonnull final ActionKey key, InputMappings.Input input ); + public abstract boolean isActionKey(@Nonnull final ActionKey key, InputMappings.Input input); } diff --git a/src/main/java/appeng/core/CreativeTab.java b/src/main/java/appeng/core/CreativeTab.java index 27a2c0356..2f443c3f3 100644 --- a/src/main/java/appeng/core/CreativeTab.java +++ b/src/main/java/appeng/core/CreativeTab.java @@ -18,14 +18,12 @@ package appeng.core; +public final class CreativeTab { -public final class CreativeTab -{ + public static AEItemGroup INSTANCE; - public static AEItemGroup INSTANCE; - - public static void init() { - INSTANCE = new AEItemGroup( "appliedenergistics2" ); - } + public static void init() { + INSTANCE = new AEItemGroup("appliedenergistics2"); + } } \ No newline at end of file diff --git a/src/main/java/appeng/core/CreativeTabFacade.java b/src/main/java/appeng/core/CreativeTabFacade.java index 25d383695..f70a63c91 100644 --- a/src/main/java/appeng/core/CreativeTabFacade.java +++ b/src/main/java/appeng/core/CreativeTabFacade.java @@ -18,7 +18,6 @@ package appeng.core; - import java.util.Optional; import net.minecraft.block.Blocks; @@ -28,28 +27,25 @@ import net.minecraft.item.ItemStack; import appeng.api.AEApi; +public final class CreativeTabFacade { + public static ItemGroup instance = null; -public final class CreativeTabFacade -{ - public static ItemGroup instance = null; + static void init() { + instance = new ItemGroup("appliedenergistics2.facades") { - static void init() - { - instance = new ItemGroup("appliedenergistics2.facades") { + @Override + public ItemStack createIcon() { - @Override - public ItemStack createIcon() - { + // FIXME final Optional maybeFacade = + // AEApi.instance().definitions().items().facade().maybeItem(); + // FIXME if( maybeFacade.isPresent() ) + { + // FIXME return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon(); + } - // FIXME final Optional maybeFacade = AEApi.instance().definitions().items().facade().maybeItem(); - // FIXME if( maybeFacade.isPresent() ) - { - // FIXME return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon(); - } - - return new ItemStack( Blocks.OAK_PLANKS ); - } - }; - } + return new ItemStack(Blocks.OAK_PLANKS); + } + }; + } } \ No newline at end of file diff --git a/src/main/java/appeng/core/FacadeConfig.java b/src/main/java/appeng/core/FacadeConfig.java index 5bc10e50d..7f503d553 100644 --- a/src/main/java/appeng/core/FacadeConfig.java +++ b/src/main/java/appeng/core/FacadeConfig.java @@ -18,52 +18,48 @@ package appeng.core; +import java.io.File; -import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; -import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.block.Block; import net.minecraft.util.ResourceLocation; -import java.io.File; +import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +public class FacadeConfig { -public class FacadeConfig -{ + private static final String CONFIG_VERSION = "1"; + private static final String CONFIG_COMMON_KEY = "common"; + private static final String CONFIG_COMMON_COMMENT = "Settings applied to all facades.\n\n" // + + "By default full blocks with no tile entity and a model do not need whitelisting.\n"// + + "This will only be read once during client startup."; + private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_KEY = "allowTileEntityFacades"; + private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_COMMENT = "Unsupported: Allows whitelisting TileEntity as facades. Could work, have render issues, or corrupt your world. USE AT YOUR OWN RISK."; + private static final String CONFIG_FACADES_KEY = "facades"; + private static final String CONFIG_FACADES_COMMENT = "A way to explicitly handle certain blocks as facades.\n\n" // + + "Blocks can be added by their resource location under the following rules.\n" // + + " - One category per domain like minecraft or appliedenergistics2\n" // + + " - One key per id. E.g. glass in case of minecraft:glass\n" // + + " - An integer value ranging from 0 to 16 representing the metadata 0-15 and 16 as wildcard for all" // + + " - Multiple entries for the same id but different metadata are possible when needed"; - private static final String CONFIG_VERSION = "1"; - private static final String CONFIG_COMMON_KEY = "common"; - private static final String CONFIG_COMMON_COMMENT = "Settings applied to all facades.\n\n" // - + "By default full blocks with no tile entity and a model do not need whitelisting.\n"// - + "This will only be read once during client startup."; - private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_KEY = "allowTileEntityFacades"; - private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_COMMENT = "Unsupported: Allows whitelisting TileEntity as facades. Could work, have render issues, or corrupt your world. USE AT YOUR OWN RISK."; - private static final String CONFIG_FACADES_KEY = "facades"; - private static final String CONFIG_FACADES_COMMENT = "A way to explicitly handle certain blocks as facades.\n\n" // - + "Blocks can be added by their resource location under the following rules.\n" // - + " - One category per domain like minecraft or appliedenergistics2\n" // - + " - One key per id. E.g. glass in case of minecraft:glass\n" // - + " - An integer value ranging from 0 to 16 representing the metadata 0-15 and 16 as wildcard for all" // - + " - Multiple entries for the same id but different metadata are possible when needed"; + private static FacadeConfig instance; - private static FacadeConfig instance; + private final boolean allowTileEntityFacades; + private final Object2IntMap whiteList; - private final boolean allowTileEntityFacades; - private final Object2IntMap whiteList; + private FacadeConfig(boolean allowTileEntityFacades, Object2IntMap whiteList) { + this.allowTileEntityFacades = allowTileEntityFacades; + this.whiteList = whiteList; + } - private FacadeConfig( boolean allowTileEntityFacades, Object2IntMap whiteList ) - { - this.allowTileEntityFacades = allowTileEntityFacades; - this.whiteList = whiteList; - } - - /** - * Creates a custom confuration based on a {@link Configuration}, but ultimately throws it away after reading it - * once to save a couple MB of memory. - * - * @param configFile - */ - public static void init( final File configFile ) - { + /** + * Creates a custom confuration based on a {@link Configuration}, but ultimately + * throws it away after reading it once to save a couple MB of memory. + * + * @param configFile + */ + public static void init(final File configFile) { // FIXME final Configuration configurartion = migrate( new Configuration( configFile, CONFIG_VERSION ) ); // FIXME // FIXME final boolean allowTileEntityFacades = configurartion @@ -91,8 +87,8 @@ public class FacadeConfig // FIXME configurartion.save(); // FIXME } - instance = new FacadeConfig( false, new Object2IntArrayMap<>() ); // FIXME - } + instance = new FacadeConfig(false, new Object2IntArrayMap<>()); // FIXME + } // FIXME private static Configuration migrate( Configuration configurartion ) // FIXME { @@ -132,25 +128,21 @@ public class FacadeConfig // FIXME return configurartion; // FIXME } - public static FacadeConfig instance() - { - return instance; - } + public static FacadeConfig instance() { + return instance; + } - public boolean allowTileEntityFacades() - { - return this.allowTileEntityFacades; - } + public boolean allowTileEntityFacades() { + return this.allowTileEntityFacades; + } - public boolean isWhiteListed( final Block block, final int metadata ) - { - final Integer entry = this.whiteList.get( block.getRegistryName() ); + public boolean isWhiteListed(final Block block, final int metadata) { + final Integer entry = this.whiteList.get(block.getRegistryName()); - if( entry != null ) - { - return entry == metadata || entry == 16; - } + if (entry != null) { + return entry == metadata || entry == 16; + } - return false; - } + return false; + } } diff --git a/src/main/java/appeng/core/PluginLoader.java b/src/main/java/appeng/core/PluginLoader.java index af7ab5363..c894266a2 100644 --- a/src/main/java/appeng/core/PluginLoader.java +++ b/src/main/java/appeng/core/PluginLoader.java @@ -18,7 +18,6 @@ package appeng.core; - import java.lang.annotation.ElementType; import java.lang.reflect.Constructor; import java.util.Collection; @@ -37,131 +36,113 @@ import net.minecraftforge.forgespi.language.ModFileScanData; import appeng.api.AEInjectable; import appeng.api.AEPlugin; - /** - * Loads AE plugins on startup and provides them with access to various components of the AE API. + * Loads AE plugins on startup and provides them with access to various + * components of the AE API. */ -class PluginLoader -{ +class PluginLoader { - public void loadPlugins( Collection injectables ) - { - Map, Object> injectableMap = mapInjectables( injectables ); - findAndInstantiatePlugins( injectableMap ); - } + public void loadPlugins(Collection injectables) { + Map, Object> injectableMap = mapInjectables(injectables); + findAndInstantiatePlugins(injectableMap); + } - private static void findAndInstantiatePlugins( Map, Object> injectableMap ) - { - Type aType = Type.getType( AEPlugin.class ); - Set allAnnotated = ModList.get().getAllScanData().stream().map( ModFileScanData::getAnnotations ).flatMap( Collection::stream ).filter( a -> a.getAnnotationType().equals( aType ) ).filter( a -> a.getTargetType() == ElementType.TYPE ).collect( Collectors.toSet() ); + private static void findAndInstantiatePlugins(Map, Object> injectableMap) { + Type aType = Type.getType(AEPlugin.class); + Set allAnnotated = ModList.get().getAllScanData().stream() + .map(ModFileScanData::getAnnotations).flatMap(Collection::stream) + .filter(a -> a.getAnnotationType().equals(aType)).filter(a -> a.getTargetType() == ElementType.TYPE) + .collect(Collectors.toSet()); - for( ModFileScanData.AnnotationData candidate : allAnnotated ) - { + for (ModFileScanData.AnnotationData candidate : allAnnotated) { - String cName = candidate.getMemberName(); - Class aClass; - try - { - aClass = Class.forName( cName ); - } - catch( ClassNotFoundException e ) - { - AELog.error( e, "Couldn't find annotated AE plugin class " + cName ); - throw new RuntimeException( "Couldn't find annotated AE plugin class " + cName, e ); - } + String cName = candidate.getMemberName(); + Class aClass; + try { + aClass = Class.forName(cName); + } catch (ClassNotFoundException e) { + AELog.error(e, "Couldn't find annotated AE plugin class " + cName); + throw new RuntimeException("Couldn't find annotated AE plugin class " + cName, e); + } - // Try instantiating the plugin - try - { - Object plugin = instantiatePlugin( aClass, injectableMap ); - AELog.info( "Loaded AE2 Plugin {}", plugin.getClass() ); - } - catch( Exception e ) - { - AELog.error( e, "Unable to instantiate AE plugin " + cName ); - throw new RuntimeException( "Unable to instantiate AE plugin " + cName, e ); - } - } - } + // Try instantiating the plugin + try { + Object plugin = instantiatePlugin(aClass, injectableMap); + AELog.info("Loaded AE2 Plugin {}", plugin.getClass()); + } catch (Exception e) { + AELog.error(e, "Unable to instantiate AE plugin " + cName); + throw new RuntimeException("Unable to instantiate AE plugin " + cName, e); + } + } + } - private static Object instantiatePlugin( Class aClass, Map, Object> injectableMap ) throws Exception - { + private static Object instantiatePlugin(Class aClass, Map, Object> injectableMap) throws Exception { - Constructor[] constructors = aClass.getDeclaredConstructors(); + Constructor[] constructors = aClass.getDeclaredConstructors(); - if( constructors.length == 0 ) - { - // This is the default no-arg constructor, although it seems pointless to instantiate anything but not take - // any AE dependencies as parameters - return aClass.newInstance(); - } - else if( constructors.length != 1 ) - { - throw new IllegalArgumentException( "Expected a single constructor, but found: " + constructors.length ); - } + if (constructors.length == 0) { + // This is the default no-arg constructor, although it seems pointless to + // instantiate anything but not take + // any AE dependencies as parameters + return aClass.newInstance(); + } else if (constructors.length != 1) { + throw new IllegalArgumentException("Expected a single constructor, but found: " + constructors.length); + } - Constructor constructor = constructors[0]; - constructor.setAccessible( true ); + Constructor constructor = constructors[0]; + constructor.setAccessible(true); - Object[] args = findInjectables( constructor, injectableMap ); + Object[] args = findInjectables(constructor, injectableMap); - return constructor.newInstance( args ); - } + return constructor.newInstance(args); + } - private static Object[] findInjectables( Constructor constructor, Map, Object> injectableMap ) - { + private static Object[] findInjectables(Constructor constructor, Map, Object> injectableMap) { - Class[] types = constructor.getParameterTypes(); - Object[] args = new Object[types.length]; + Class[] types = constructor.getParameterTypes(); + Object[] args = new Object[types.length]; - for( int i = 0; i < types.length; i++ ) - { - args[i] = injectableMap.get( types[i] ); - if( args[i] == null ) - { - throw new IllegalArgumentException( "Constructor has parameter of type " + types[i] + " which is not an injectable type." + " Please see the documentation for @AEPlugin." ); - } - } + for (int i = 0; i < types.length; i++) { + args[i] = injectableMap.get(types[i]); + if (args[i] == null) { + throw new IllegalArgumentException("Constructor has parameter of type " + types[i] + + " which is not an injectable type." + " Please see the documentation for @AEPlugin."); + } + } - return args; - } + return args; + } - private static Map, Object> mapInjectables( Collection injectables ) - { - ImmutableMap.Builder, Object> builder = ImmutableMap.builder(); + private static Map, Object> mapInjectables(Collection injectables) { + ImmutableMap.Builder, Object> builder = ImmutableMap.builder(); - for( Object injectable : injectables ) - { - // Get all super-interfaces that were annotated with @AEInjectable - Set> injectableIfs = getInjectableInterfaces( injectable.getClass() ); - for( Class injectableIf : injectableIfs ) - { - builder.put( injectableIf, injectable ); - } - } + for (Object injectable : injectables) { + // Get all super-interfaces that were annotated with @AEInjectable + Set> injectableIfs = getInjectableInterfaces(injectable.getClass()); + for (Class injectableIf : injectableIfs) { + builder.put(injectableIf, injectable); + } + } - return builder.build(); - } + return builder.build(); + } - private static Set> getInjectableInterfaces( Class aClass ) - { - Set> hierarchy = new HashSet<>(); - getFullHierarchy( aClass, hierarchy ); + private static Set> getInjectableInterfaces(Class aClass) { + Set> hierarchy = new HashSet<>(); + getFullHierarchy(aClass, hierarchy); - return hierarchy.stream().filter( c -> c.getAnnotation( AEInjectable.class ) != null ).collect( Collectors.toSet() ); - } + return hierarchy.stream().filter(c -> c.getAnnotation(AEInjectable.class) != null).collect(Collectors.toSet()); + } - // Recursively gather all superclasses and superinterfaces of the given class and put them into the given collection - private static void getFullHierarchy( Class aClass, Set> classes ) - { - classes.add( aClass ); - for( Class anIf : aClass.getInterfaces() ) - { - getFullHierarchy( anIf, classes ); - } - if( aClass.getSuperclass() != null ) - { - getFullHierarchy( aClass.getSuperclass(), classes ); - } - } + // Recursively gather all superclasses and superinterfaces of the given class + // and put them into the given collection + private static void getFullHierarchy(Class aClass, Set> classes) { + classes.add(aClass); + for (Class anIf : aClass.getInterfaces()) { + getFullHierarchy(anIf, classes); + } + if (aClass.getSuperclass() != null) { + getFullHierarchy(aClass.getSuperclass(), classes); + } + } } diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 525a213ce..27da1a978 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -18,6 +18,42 @@ package appeng.core; +import java.util.Objects; + +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScreenManager; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.item.Item; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.particles.ParticleType; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.placement.Placement; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.*; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.common.ModDimension; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.common.extensions.IForgeContainerType; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.network.IContainerFactory; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.IForgeRegistry; import appeng.api.AEApi; import appeng.api.config.Upgrades; @@ -73,493 +109,285 @@ import appeng.spatial.StorageCellBiome; import appeng.spatial.StorageCellModDimension; import appeng.tile.AEBaseTile; import appeng.worldgen.MeteoriteWorldGen; -import net.minecraft.advancements.CriteriaTriggers; -import appeng.worldgen.MeteoriteWorldGen; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScreenManager; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.particles.ParticleType; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.gen.placement.Placement; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.*; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.ModDimension; -import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.extensions.IForgeContainerType; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.event.server.FMLServerStartingEvent; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.fml.network.IContainerFactory; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.IForgeRegistry; -import java.util.Objects; +final class Registration { + public Registration() { + AeStats.register(); + advancementTriggers = new AdvancementTriggers(CriteriaTriggers::register); + } -final class Registration -{ + AdvancementTriggers advancementTriggers; - public Registration() { - AeStats.register(); - advancementTriggers = new AdvancementTriggers( CriteriaTriggers::register ); - } + public static void setupInternalRegistries() { + // TODO: Do not use the internal API + final Api api = Api.INSTANCE; + final IRegistryContainer registries = api.registries(); - AdvancementTriggers advancementTriggers; + final IGridCacheRegistry gcr = registries.gridCache(); + gcr.registerGridCache(ITickManager.class, TickManagerCache.class); + gcr.registerGridCache(IEnergyGrid.class, EnergyGridCache.class); + gcr.registerGridCache(IPathingGrid.class, PathGridCache.class); + gcr.registerGridCache(IStorageGrid.class, GridStorageCache.class); + gcr.registerGridCache(P2PCache.class, P2PCache.class); + gcr.registerGridCache(ISpatialCache.class, SpatialPylonCache.class); + gcr.registerGridCache(ISecurityGrid.class, SecurityCache.class); + gcr.registerGridCache(ICraftingGrid.class, CraftingGridCache.class); - public static void setupInternalRegistries() - { - // TODO: Do not use the internal API - final Api api = Api.INSTANCE; - final IRegistryContainer registries = api.registries(); + registries.cell().addCellHandler(new BasicCellHandler()); + registries.cell().addCellHandler(new CreativeCellHandler()); + registries.cell().addCellGuiHandler(new BasicItemCellGuiHandler()); + registries.cell().addCellGuiHandler(new BasicFluidCellGuiHandler()); - final IGridCacheRegistry gcr = registries.gridCache(); - gcr.registerGridCache( ITickManager.class, TickManagerCache.class ); - gcr.registerGridCache( IEnergyGrid.class, EnergyGridCache.class ); - gcr.registerGridCache( IPathingGrid.class, PathGridCache.class ); - gcr.registerGridCache( IStorageGrid.class, GridStorageCache.class ); - gcr.registerGridCache( P2PCache.class, P2PCache.class ); - gcr.registerGridCache( ISpatialCache.class, SpatialPylonCache.class ); - gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class ); - gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class ); + api.definitions().materials().matterBall().maybeStack(1).ifPresent(ammoStack -> { + final double weight = 32; - registries.cell().addCellHandler( new BasicCellHandler() ); - registries.cell().addCellHandler( new CreativeCellHandler() ); - registries.cell().addCellGuiHandler( new BasicItemCellGuiHandler() ); - registries.cell().addCellGuiHandler( new BasicFluidCellGuiHandler() ); + registries.matterCannon().registerAmmo(ammoStack, weight); + }); - api.definitions().materials().matterBall().maybeStack( 1 ).ifPresent( ammoStack -> - { - final double weight = 32; + PartItemPredicate.register(); + } - registries.matterCannon().registerAmmo( ammoStack, weight ); - } ); + @OnlyIn(Dist.CLIENT) + public void modelRegistryEvent(ModelRegistryEvent event) { + registerSpecialModels(); - PartItemPredicate.register(); - } - - @OnlyIn( Dist.CLIENT ) - public void modelRegistryEvent( ModelRegistryEvent event ) - { - registerSpecialModels(); - - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - final IModelRegistry registry = new IModelRegistry() { - @Override - public void registerItemVariants(Item item, ResourceLocation... names) { + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + final IModelRegistry registry = new IModelRegistry() { + @Override + public void registerItemVariants(Item item, ResourceLocation... names) { // FIXME REMOVE OR IMPL - } + } - }; - final Dist dist = FMLEnvironment.dist; - definitions.getRegistry().getBootstrapComponents( IModelRegistrationComponent.class ).forEachRemaining(b -> b.modelRegistration( dist, registry ) ); - } + }; + final Dist dist = FMLEnvironment.dist; + definitions.getRegistry().getBootstrapComponents(IModelRegistrationComponent.class) + .forEachRemaining(b -> b.modelRegistration(dist, registry)); + } - /** - * Registers any JSON model files with Minecraft that are not referenced via blockstates or item IDs - */ - @OnlyIn(Dist.CLIENT) - private void registerSpecialModels() { - SkyCompassModel.DEPENDENCIES.forEach(ModelLoader::addSpecialModel); - ModelLoader.addSpecialModel(BiometricCardModel.MODEL_BASE); - ModelLoader.addSpecialModel(MemoryCardModel.MODEL_BASE); - DriveModel.DEPENDENCIES.forEach(ModelLoader::addSpecialModel); + /** + * Registers any JSON model files with Minecraft that are not referenced via + * blockstates or item IDs + */ + @OnlyIn(Dist.CLIENT) + private void registerSpecialModels() { + SkyCompassModel.DEPENDENCIES.forEach(ModelLoader::addSpecialModel); + ModelLoader.addSpecialModel(BiometricCardModel.MODEL_BASE); + ModelLoader.addSpecialModel(MemoryCardModel.MODEL_BASE); + DriveModel.DEPENDENCIES.forEach(ModelLoader::addSpecialModel); - PartModels partModels = (PartModels) Api.INSTANCE.registries().partModels(); - partModels.getModels().forEach(ModelLoader::addSpecialModel); - partModels.setInitialized(true); - } + PartModels partModels = (PartModels) Api.INSTANCE.registries().partModels(); + partModels.getModels().forEach(ModelLoader::addSpecialModel); + partModels.setInitialized(true); + } - public void registerBlocks( RegistryEvent.Register event ) - { - final IForgeRegistry registry = event.getRegistry(); - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - final Dist dist = FMLEnvironment.dist; - definitions.getRegistry().getBootstrapComponents( IBlockRegistrationComponent.class ).forEachRemaining( b -> b.blockRegistration( dist, registry ) ); - } + public void registerBlocks(RegistryEvent.Register event) { + final IForgeRegistry registry = event.getRegistry(); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + final Dist dist = FMLEnvironment.dist; + definitions.getRegistry().getBootstrapComponents(IBlockRegistrationComponent.class) + .forEachRemaining(b -> b.blockRegistration(dist, registry)); + } - public void registerItems( RegistryEvent.Register event ) - { - final IForgeRegistry registry = event.getRegistry(); - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - final Dist dist = FMLEnvironment.dist; - definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( dist, registry ) ); - } + public void registerItems(RegistryEvent.Register event) { + final IForgeRegistry registry = event.getRegistry(); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + final Dist dist = FMLEnvironment.dist; + definitions.getRegistry().getBootstrapComponents(IItemRegistrationComponent.class) + .forEachRemaining(b -> b.itemRegistration(dist, registry)); + } - public void registerTileEntities( RegistryEvent.Register> event ) - { - final IForgeRegistry> registry = event.getRegistry(); - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( ITileEntityRegistrationComponent.class ).forEachRemaining(b -> b.register( registry ) ); - } + public void registerTileEntities(RegistryEvent.Register> event) { + final IForgeRegistry> registry = event.getRegistry(); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(ITileEntityRegistrationComponent.class) + .forEachRemaining(b -> b.register(registry)); + } - public void registerContainerTypes( RegistryEvent.Register> event ) { - final IForgeRegistry> registry = event.getRegistry(); + public void registerContainerTypes(RegistryEvent.Register> event) { + final IForgeRegistry> registry = event.getRegistry(); - ContainerCellWorkbench.TYPE = registerContainer( - registry, - "cellworkbench", - ContainerCellWorkbench::fromNetwork, - ContainerCellWorkbench::open - ); - ContainerChest.TYPE = registerContainer( - registry, - "chest", - ContainerChest::fromNetwork, - ContainerChest::open - ); - ContainerCondenser.TYPE = registerContainer( - registry, - "condenser", - ContainerCondenser::fromNetwork, - ContainerCondenser::open - ); - ContainerCraftAmount.TYPE = registerContainer( - registry, - "craftamount", - ContainerCraftAmount::fromNetwork, - ContainerCraftAmount::open - ); - ContainerCraftConfirm.TYPE = registerContainer( - registry, - "craftconfirm", - ContainerCraftConfirm::fromNetwork, - ContainerCraftConfirm::open - ); - ContainerCraftingCPU.TYPE = registerContainer( - registry, - "craftingcpu", - ContainerCraftingCPU::fromNetwork, - ContainerCraftingCPU::open - ); - ContainerCraftingStatus.TYPE = registerContainer( - registry, - "craftingstatus", - ContainerCraftingStatus::fromNetwork, - ContainerCraftingStatus::open - ); - ContainerCraftingTerm.TYPE = registerContainer( - registry, - "craftingterm", - ContainerCraftingTerm::fromNetwork, - ContainerCraftingTerm::open - ); - ContainerDrive.TYPE = registerContainer( - registry, - "drive", - ContainerDrive::fromNetwork, - ContainerDrive::open - ); - ContainerFormationPlane.TYPE = registerContainer( - registry, - "formationplane", - ContainerFormationPlane::fromNetwork, - ContainerFormationPlane::open - ); - ContainerGrinder.TYPE = registerContainer( - registry, - "grinder", - ContainerGrinder::fromNetwork, - ContainerGrinder::open - ); - ContainerInscriber.TYPE = registerContainer( - registry, - "inscriber", - ContainerInscriber::fromNetwork, - ContainerInscriber::open - ); - ContainerInterface.TYPE = registerContainer( - registry, - "interface", - ContainerInterface::fromNetwork, - ContainerInterface::open - ); - ContainerInterfaceTerminal.TYPE = registerContainer( - registry, - "interfaceterminal", - ContainerInterfaceTerminal::fromNetwork, - ContainerInterfaceTerminal::open - ); - ContainerIOPort.TYPE = registerContainer( - registry, - "ioport", - ContainerIOPort::fromNetwork, - ContainerIOPort::open - ); - ContainerLevelEmitter.TYPE = registerContainer( - registry, - "levelemitter", - ContainerLevelEmitter::fromNetwork, - ContainerLevelEmitter::open - ); - ContainerMAC.TYPE = registerContainer( - registry, - "mac", - ContainerMAC::fromNetwork, - ContainerMAC::open - ); - ContainerMEMonitorable.TYPE = registerContainer( - registry, - "memonitorable", - ContainerMEMonitorable::fromNetwork, - ContainerMEMonitorable::open - ); - ContainerMEPortableCell.TYPE = registerContainer( - registry, - "meportablecell", - ContainerMEPortableCell::fromNetwork, - ContainerMEPortableCell::open - ); - ContainerNetworkStatus.TYPE = registerContainer( - registry, - "networkstatus", - ContainerNetworkStatus::fromNetwork, - ContainerNetworkStatus::open - ); - ContainerNetworkTool.TYPE = registerContainer( - registry, - "networktool", - ContainerNetworkTool::fromNetwork, - ContainerNetworkTool::open - ); - ContainerPatternTerm.TYPE = registerContainer( - registry, - "patternterm", - ContainerPatternTerm::fromNetwork, - ContainerPatternTerm::open - ); - ContainerPriority.TYPE = registerContainer( - registry, - "priority", - ContainerPriority::fromNetwork, - ContainerPriority::open - ); - ContainerQNB.TYPE = registerContainer( - registry, - "qnb", - ContainerQNB::fromNetwork, - ContainerQNB::open - ); - ContainerQuartzKnife.TYPE = registerContainer( - registry, - "quartzknife", - ContainerQuartzKnife::fromNetwork, - ContainerQuartzKnife::open - ); - ContainerSecurityStation.TYPE = registerContainer( - registry, - "securitystation", - ContainerSecurityStation::fromNetwork, - ContainerSecurityStation::open - ); - ContainerSkyChest.TYPE = registerContainer( - registry, - "skychest", - ContainerSkyChest::fromNetwork, - ContainerSkyChest::open - ); - ContainerSpatialIOPort.TYPE = registerContainer( - registry, - "spatialioport", - ContainerSpatialIOPort::fromNetwork, - ContainerSpatialIOPort::open - ); - ContainerStorageBus.TYPE = registerContainer( - registry, - "storagebus", - ContainerStorageBus::fromNetwork, - ContainerStorageBus::open - ); - ContainerUpgradeable.TYPE = registerContainer( - registry, - "upgradeable", - ContainerUpgradeable::fromNetwork, - ContainerUpgradeable::open - ); - ContainerVibrationChamber.TYPE = registerContainer( - registry, - "vibrationchamber", - ContainerVibrationChamber::fromNetwork, - ContainerVibrationChamber::open - ); - ContainerWireless.TYPE = registerContainer( - registry, - "wireless", - ContainerWireless::fromNetwork, - ContainerWireless::open - ); - ContainerWirelessTerm.TYPE = registerContainer( - registry, - "wirelessterm", - ContainerWirelessTerm::fromNetwork, - ContainerWirelessTerm::open - ); + ContainerCellWorkbench.TYPE = registerContainer(registry, "cellworkbench", ContainerCellWorkbench::fromNetwork, + ContainerCellWorkbench::open); + ContainerChest.TYPE = registerContainer(registry, "chest", ContainerChest::fromNetwork, ContainerChest::open); + ContainerCondenser.TYPE = registerContainer(registry, "condenser", ContainerCondenser::fromNetwork, + ContainerCondenser::open); + ContainerCraftAmount.TYPE = registerContainer(registry, "craftamount", ContainerCraftAmount::fromNetwork, + ContainerCraftAmount::open); + ContainerCraftConfirm.TYPE = registerContainer(registry, "craftconfirm", ContainerCraftConfirm::fromNetwork, + ContainerCraftConfirm::open); + ContainerCraftingCPU.TYPE = registerContainer(registry, "craftingcpu", ContainerCraftingCPU::fromNetwork, + ContainerCraftingCPU::open); + ContainerCraftingStatus.TYPE = registerContainer(registry, "craftingstatus", + ContainerCraftingStatus::fromNetwork, ContainerCraftingStatus::open); + ContainerCraftingTerm.TYPE = registerContainer(registry, "craftingterm", ContainerCraftingTerm::fromNetwork, + ContainerCraftingTerm::open); + ContainerDrive.TYPE = registerContainer(registry, "drive", ContainerDrive::fromNetwork, ContainerDrive::open); + ContainerFormationPlane.TYPE = registerContainer(registry, "formationplane", + ContainerFormationPlane::fromNetwork, ContainerFormationPlane::open); + ContainerGrinder.TYPE = registerContainer(registry, "grinder", ContainerGrinder::fromNetwork, + ContainerGrinder::open); + ContainerInscriber.TYPE = registerContainer(registry, "inscriber", ContainerInscriber::fromNetwork, + ContainerInscriber::open); + ContainerInterface.TYPE = registerContainer(registry, "interface", ContainerInterface::fromNetwork, + ContainerInterface::open); + ContainerInterfaceTerminal.TYPE = registerContainer(registry, "interfaceterminal", + ContainerInterfaceTerminal::fromNetwork, ContainerInterfaceTerminal::open); + ContainerIOPort.TYPE = registerContainer(registry, "ioport", ContainerIOPort::fromNetwork, + ContainerIOPort::open); + ContainerLevelEmitter.TYPE = registerContainer(registry, "levelemitter", ContainerLevelEmitter::fromNetwork, + ContainerLevelEmitter::open); + ContainerMAC.TYPE = registerContainer(registry, "mac", ContainerMAC::fromNetwork, ContainerMAC::open); + ContainerMEMonitorable.TYPE = registerContainer(registry, "memonitorable", ContainerMEMonitorable::fromNetwork, + ContainerMEMonitorable::open); + ContainerMEPortableCell.TYPE = registerContainer(registry, "meportablecell", + ContainerMEPortableCell::fromNetwork, ContainerMEPortableCell::open); + ContainerNetworkStatus.TYPE = registerContainer(registry, "networkstatus", ContainerNetworkStatus::fromNetwork, + ContainerNetworkStatus::open); + ContainerNetworkTool.TYPE = registerContainer(registry, "networktool", ContainerNetworkTool::fromNetwork, + ContainerNetworkTool::open); + ContainerPatternTerm.TYPE = registerContainer(registry, "patternterm", ContainerPatternTerm::fromNetwork, + ContainerPatternTerm::open); + ContainerPriority.TYPE = registerContainer(registry, "priority", ContainerPriority::fromNetwork, + ContainerPriority::open); + ContainerQNB.TYPE = registerContainer(registry, "qnb", ContainerQNB::fromNetwork, ContainerQNB::open); + ContainerQuartzKnife.TYPE = registerContainer(registry, "quartzknife", ContainerQuartzKnife::fromNetwork, + ContainerQuartzKnife::open); + ContainerSecurityStation.TYPE = registerContainer(registry, "securitystation", + ContainerSecurityStation::fromNetwork, ContainerSecurityStation::open); + ContainerSkyChest.TYPE = registerContainer(registry, "skychest", ContainerSkyChest::fromNetwork, + ContainerSkyChest::open); + ContainerSpatialIOPort.TYPE = registerContainer(registry, "spatialioport", ContainerSpatialIOPort::fromNetwork, + ContainerSpatialIOPort::open); + ContainerStorageBus.TYPE = registerContainer(registry, "storagebus", ContainerStorageBus::fromNetwork, + ContainerStorageBus::open); + ContainerUpgradeable.TYPE = registerContainer(registry, "upgradeable", ContainerUpgradeable::fromNetwork, + ContainerUpgradeable::open); + ContainerVibrationChamber.TYPE = registerContainer(registry, "vibrationchamber", + ContainerVibrationChamber::fromNetwork, ContainerVibrationChamber::open); + ContainerWireless.TYPE = registerContainer(registry, "wireless", ContainerWireless::fromNetwork, + ContainerWireless::open); + ContainerWirelessTerm.TYPE = registerContainer(registry, "wirelessterm", ContainerWirelessTerm::fromNetwork, + ContainerWirelessTerm::open); - ContainerFluidFormationPlane.TYPE = registerContainer( - registry, - "fluid_formation_plane", - ContainerFluidFormationPlane::fromNetwork, - ContainerFluidFormationPlane::open - ); - ContainerFluidIO.TYPE = registerContainer( - registry, - "fluid_io", - ContainerFluidIO::fromNetwork, - ContainerFluidIO::open - ); - ContainerFluidInterface.TYPE = registerContainer( - registry, - "fluid_interface", - ContainerFluidInterface::fromNetwork, - ContainerFluidInterface::open - ); - ContainerFluidLevelEmitter.TYPE = registerContainer( - registry, - "fluid_level_emitter", - ContainerFluidLevelEmitter::fromNetwork, - ContainerFluidLevelEmitter::open - ); - ContainerFluidStorageBus.TYPE = registerContainer( - registry, - "fluid_storage_bus", - ContainerFluidStorageBus::fromNetwork, - ContainerFluidStorageBus::open - ); - ContainerFluidTerminal.TYPE = registerContainer( - registry, - "fluid_terminal", - ContainerFluidTerminal::fromNetwork, - ContainerFluidTerminal::open - ); + ContainerFluidFormationPlane.TYPE = registerContainer(registry, "fluid_formation_plane", + ContainerFluidFormationPlane::fromNetwork, ContainerFluidFormationPlane::open); + ContainerFluidIO.TYPE = registerContainer(registry, "fluid_io", ContainerFluidIO::fromNetwork, + ContainerFluidIO::open); + ContainerFluidInterface.TYPE = registerContainer(registry, "fluid_interface", + ContainerFluidInterface::fromNetwork, ContainerFluidInterface::open); + ContainerFluidLevelEmitter.TYPE = registerContainer(registry, "fluid_level_emitter", + ContainerFluidLevelEmitter::fromNetwork, ContainerFluidLevelEmitter::open); + ContainerFluidStorageBus.TYPE = registerContainer(registry, "fluid_storage_bus", + ContainerFluidStorageBus::fromNetwork, ContainerFluidStorageBus::open); + ContainerFluidTerminal.TYPE = registerContainer(registry, "fluid_terminal", ContainerFluidTerminal::fromNetwork, + ContainerFluidTerminal::open); - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - ScreenManager.registerFactory(ContainerGrinder.TYPE, GuiGrinder::new); - ScreenManager.registerFactory(ContainerQNB.TYPE, GuiQNB::new); - ScreenManager.registerFactory(ContainerSkyChest.TYPE, GuiSkyChest::new); - ScreenManager.registerFactory(ContainerChest.TYPE, GuiChest::new); - ScreenManager.registerFactory(ContainerWireless.TYPE, GuiWireless::new); - ScreenManager.>registerFactory(ContainerMEMonitorable.TYPE, GuiMEMonitorable::new); - ScreenManager.registerFactory(ContainerMEPortableCell.TYPE, GuiMEPortableCell::new); - ScreenManager.registerFactory(ContainerWirelessTerm.TYPE, GuiWirelessTerm::new); - ScreenManager.registerFactory(ContainerNetworkStatus.TYPE, GuiNetworkStatus::new); - ScreenManager.>registerFactory(ContainerCraftingCPU.TYPE, GuiCraftingCPU::new); - ScreenManager.registerFactory(ContainerNetworkTool.TYPE, GuiNetworkTool::new); - ScreenManager.registerFactory(ContainerQuartzKnife.TYPE, GuiQuartzKnife::new); - ScreenManager.registerFactory(ContainerDrive.TYPE, GuiDrive::new); - ScreenManager.registerFactory(ContainerVibrationChamber.TYPE, GuiVibrationChamber::new); - ScreenManager.registerFactory(ContainerCondenser.TYPE, GuiCondenser::new); - ScreenManager.registerFactory(ContainerInterface.TYPE, GuiInterface::new); - ScreenManager.registerFactory(ContainerFluidInterface.TYPE, GuiFluidInterface::new); - ScreenManager.>registerFactory(ContainerUpgradeable.TYPE, GuiUpgradeable::new); - ScreenManager.registerFactory(ContainerFluidIO.TYPE, GuiFluidIO::new); - ScreenManager.registerFactory(ContainerIOPort.TYPE, GuiIOPort::new); - ScreenManager.registerFactory(ContainerStorageBus.TYPE, GuiStorageBus::new); - ScreenManager.registerFactory(ContainerFluidStorageBus.TYPE, GuiFluidStorageBus::new); - ScreenManager.registerFactory(ContainerFormationPlane.TYPE, GuiFormationPlane::new); - ScreenManager.registerFactory(ContainerFluidFormationPlane.TYPE, GuiFluidFormationPlane::new); - ScreenManager.registerFactory(ContainerPriority.TYPE, GuiPriority::new); - ScreenManager.registerFactory(ContainerSecurityStation.TYPE, GuiSecurityStation::new); - ScreenManager.registerFactory(ContainerCraftingTerm.TYPE, GuiCraftingTerm::new); - ScreenManager.registerFactory(ContainerPatternTerm.TYPE, GuiPatternTerm::new); - ScreenManager.registerFactory(ContainerFluidTerminal.TYPE, GuiFluidTerminal::new); - ScreenManager.registerFactory(ContainerLevelEmitter.TYPE, GuiLevelEmitter::new); - ScreenManager.registerFactory(ContainerFluidLevelEmitter.TYPE, GuiFluidLevelEmitter::new); - ScreenManager.registerFactory(ContainerSpatialIOPort.TYPE, GuiSpatialIOPort::new); - ScreenManager.registerFactory(ContainerInscriber.TYPE, GuiInscriber::new); - ScreenManager.registerFactory(ContainerCellWorkbench.TYPE, GuiCellWorkbench::new); - ScreenManager.registerFactory(ContainerMAC.TYPE, GuiMAC::new); - ScreenManager.registerFactory(ContainerCraftAmount.TYPE, GuiCraftAmount::new); - ScreenManager.registerFactory(ContainerCraftConfirm.TYPE, GuiCraftConfirm::new); - ScreenManager.registerFactory(ContainerInterfaceTerminal.TYPE, GuiInterfaceTerminal::new); - ScreenManager.registerFactory(ContainerCraftingStatus.TYPE, GuiCraftingStatus::new); - }); - } + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { + ScreenManager.registerFactory(ContainerGrinder.TYPE, GuiGrinder::new); + ScreenManager.registerFactory(ContainerQNB.TYPE, GuiQNB::new); + ScreenManager.registerFactory(ContainerSkyChest.TYPE, GuiSkyChest::new); + ScreenManager.registerFactory(ContainerChest.TYPE, GuiChest::new); + ScreenManager.registerFactory(ContainerWireless.TYPE, GuiWireless::new); + ScreenManager.>registerFactory( + ContainerMEMonitorable.TYPE, GuiMEMonitorable::new); + ScreenManager.registerFactory(ContainerMEPortableCell.TYPE, GuiMEPortableCell::new); + ScreenManager.registerFactory(ContainerWirelessTerm.TYPE, GuiWirelessTerm::new); + ScreenManager.registerFactory(ContainerNetworkStatus.TYPE, GuiNetworkStatus::new); + ScreenManager.>registerFactory( + ContainerCraftingCPU.TYPE, GuiCraftingCPU::new); + ScreenManager.registerFactory(ContainerNetworkTool.TYPE, GuiNetworkTool::new); + ScreenManager.registerFactory(ContainerQuartzKnife.TYPE, GuiQuartzKnife::new); + ScreenManager.registerFactory(ContainerDrive.TYPE, GuiDrive::new); + ScreenManager.registerFactory(ContainerVibrationChamber.TYPE, GuiVibrationChamber::new); + ScreenManager.registerFactory(ContainerCondenser.TYPE, GuiCondenser::new); + ScreenManager.registerFactory(ContainerInterface.TYPE, GuiInterface::new); + ScreenManager.registerFactory(ContainerFluidInterface.TYPE, GuiFluidInterface::new); + ScreenManager.>registerFactory( + ContainerUpgradeable.TYPE, GuiUpgradeable::new); + ScreenManager.registerFactory(ContainerFluidIO.TYPE, GuiFluidIO::new); + ScreenManager.registerFactory(ContainerIOPort.TYPE, GuiIOPort::new); + ScreenManager.registerFactory(ContainerStorageBus.TYPE, GuiStorageBus::new); + ScreenManager.registerFactory(ContainerFluidStorageBus.TYPE, GuiFluidStorageBus::new); + ScreenManager.registerFactory(ContainerFormationPlane.TYPE, GuiFormationPlane::new); + ScreenManager.registerFactory(ContainerFluidFormationPlane.TYPE, GuiFluidFormationPlane::new); + ScreenManager.registerFactory(ContainerPriority.TYPE, GuiPriority::new); + ScreenManager.registerFactory(ContainerSecurityStation.TYPE, GuiSecurityStation::new); + ScreenManager.registerFactory(ContainerCraftingTerm.TYPE, GuiCraftingTerm::new); + ScreenManager.registerFactory(ContainerPatternTerm.TYPE, GuiPatternTerm::new); + ScreenManager.registerFactory(ContainerFluidTerminal.TYPE, GuiFluidTerminal::new); + ScreenManager.registerFactory(ContainerLevelEmitter.TYPE, GuiLevelEmitter::new); + ScreenManager.registerFactory(ContainerFluidLevelEmitter.TYPE, GuiFluidLevelEmitter::new); + ScreenManager.registerFactory(ContainerSpatialIOPort.TYPE, GuiSpatialIOPort::new); + ScreenManager.registerFactory(ContainerInscriber.TYPE, GuiInscriber::new); + ScreenManager.registerFactory(ContainerCellWorkbench.TYPE, GuiCellWorkbench::new); + ScreenManager.registerFactory(ContainerMAC.TYPE, GuiMAC::new); + ScreenManager.registerFactory(ContainerCraftAmount.TYPE, GuiCraftAmount::new); + ScreenManager.registerFactory(ContainerCraftConfirm.TYPE, GuiCraftConfirm::new); + ScreenManager.registerFactory(ContainerInterfaceTerminal.TYPE, GuiInterfaceTerminal::new); + ScreenManager.registerFactory(ContainerCraftingStatus.TYPE, GuiCraftingStatus::new); + }); + } - private ContainerType registerContainer(IForgeRegistry> registry, - String id, - IContainerFactory factory, - ContainerOpener.Opener opener) { - ContainerType type = IForgeContainerType.create(factory); - type.setRegistryName(AppEng.MOD_ID, id); - registry.register(type); - ContainerOpener.addOpener(type, opener); - return type; - } - public void registerRecipeSerializers( RegistryEvent.Register> event ) - { - IForgeRegistry> r = event.getRegistry(); + private ContainerType registerContainer(IForgeRegistry> registry, + String id, IContainerFactory factory, ContainerOpener.Opener opener) { + ContainerType type = IForgeContainerType.create(factory); + type.setRegistryName(AppEng.MOD_ID, id); + registry.register(type); + ContainerOpener.addOpener(type, opener); + return type; + } - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); + public void registerRecipeSerializers(RegistryEvent.Register> event) { + IForgeRegistry> r = event.getRegistry(); - GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName()); - InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName()); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); - r.registerAll( - DisassembleRecipe.SERIALIZER, - GrinderRecipeSerializer.INSTANCE, - InscriberRecipeSerializer.INSTANCE + GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName()); + InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName()); + + r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE, InscriberRecipeSerializer.INSTANCE // FacadeRecipe.getSerializer( (ItemFacade) definitions.items().facade().item() ) FIXME reimplement facades - ); + ); - CraftingHelper.register( FeaturesEnabled.Serializer.INSTANCE ); - } + CraftingHelper.register(FeaturesEnabled.Serializer.INSTANCE); + } - public void registerEntities( RegistryEvent.Register> event ) - { - // Special case only used on the client-side - EntityFloatingItem.TYPE = EntityType.Builder.create(EntityFloatingItem::new, EntityClassification.MISC) - .build("appliedenergistics2:floating_item"); + public void registerEntities(RegistryEvent.Register> event) { + // Special case only used on the client-side + EntityFloatingItem.TYPE = EntityType.Builder + .create(EntityFloatingItem::new, EntityClassification.MISC) + .build("appliedenergistics2:floating_item"); - final IForgeRegistry> registry = event.getRegistry(); - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( IEntityRegistrationComponent.class ).forEachRemaining(b -> b.entityRegistration( registry ) ); - } + final IForgeRegistry> registry = event.getRegistry(); + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(IEntityRegistrationComponent.class) + .forEachRemaining(b -> b.entityRegistration(registry)); + } - public void registerParticleTypes( RegistryEvent.Register> event ) - { - final IForgeRegistry> registry = event.getRegistry(); - registry.register(ChargedOreFX.TYPE); - registry.register(VibrantFX.TYPE); - registry.register(LightningFX.TYPE); - } + public void registerParticleTypes(RegistryEvent.Register> event) { + final IForgeRegistry> registry = event.getRegistry(); + registry.register(ChargedOreFX.TYPE); + registry.register(VibrantFX.TYPE); + registry.register(LightningFX.TYPE); + } - public void registerParticleFactories(ParticleFactoryRegisterEvent event) { - Minecraft.getInstance().particles.registerFactory(AssemblerFX.TYPE, AssemblerFX.Factory::new); - Minecraft.getInstance().particles.registerFactory(ChargedOreFX.TYPE, ChargedOreFX.Factory::new); - Minecraft.getInstance().particles.registerFactory(CraftingFx.TYPE, CraftingFx.Factory::new); - Minecraft.getInstance().particles.registerFactory(EnergyFx.TYPE, EnergyFx.Factory::new); - Minecraft.getInstance().particles.registerFactory(LightningArcFX.TYPE, LightningArcFX.Factory::new); - Minecraft.getInstance().particles.registerFactory(LightningFX.TYPE, LightningFX.Factory::new); - Minecraft.getInstance().particles.registerFactory(MatterCannonFX.TYPE, MatterCannonFX.Factory::new); - Minecraft.getInstance().particles.registerFactory(VibrantFX.TYPE, VibrantFX.Factory::new); - } + public void registerParticleFactories(ParticleFactoryRegisterEvent event) { + Minecraft.getInstance().particles.registerFactory(AssemblerFX.TYPE, AssemblerFX.Factory::new); + Minecraft.getInstance().particles.registerFactory(ChargedOreFX.TYPE, ChargedOreFX.Factory::new); + Minecraft.getInstance().particles.registerFactory(CraftingFx.TYPE, CraftingFx.Factory::new); + Minecraft.getInstance().particles.registerFactory(EnergyFx.TYPE, EnergyFx.Factory::new); + Minecraft.getInstance().particles.registerFactory(LightningArcFX.TYPE, LightningArcFX.Factory::new); + Minecraft.getInstance().particles.registerFactory(LightningFX.TYPE, LightningFX.Factory::new); + Minecraft.getInstance().particles.registerFactory(MatterCannonFX.TYPE, MatterCannonFX.Factory::new); + Minecraft.getInstance().particles.registerFactory(VibrantFX.TYPE, VibrantFX.Factory::new); + } // // @SubscribeEvent @@ -572,112 +400,116 @@ final class Registration // } // } - // FIXME LATER - public static void postInit() - { - final IRegistryContainer registries = AEApi.instance().registries(); - // TODO: Do not use the internal API - ApiDefinitions definitions = Api.INSTANCE.definitions(); - final IParts parts = definitions.parts(); - final IBlocks blocks = definitions.blocks(); - final IItems items = definitions.items(); + // FIXME LATER + public static void postInit() { + final IRegistryContainer registries = AEApi.instance().registries(); + // TODO: Do not use the internal API + ApiDefinitions definitions = Api.INSTANCE.definitions(); + final IParts parts = definitions.parts(); + final IBlocks blocks = definitions.blocks(); + final IItems items = definitions.items(); - // FIXME this.registerSpatialDimension(); + // FIXME this.registerSpatialDimension(); - // default settings.. - ( (P2PTunnelRegistry) registries.p2pTunnel() ).configure(); + // default settings.. + ((P2PTunnelRegistry) registries.p2pTunnel()).configure(); - // Interface - Upgrades.CRAFTING.registerItem( parts.iface(), 1 ); - Upgrades.CRAFTING.registerItem( blocks.iface(), 1 ); + // Interface + Upgrades.CRAFTING.registerItem(parts.iface(), 1); + Upgrades.CRAFTING.registerItem(blocks.iface(), 1); - // IO Port! - Upgrades.SPEED.registerItem( blocks.iOPort(), 3 ); - Upgrades.REDSTONE.registerItem( blocks.iOPort(), 1 ); + // IO Port! + Upgrades.SPEED.registerItem(blocks.iOPort(), 3); + Upgrades.REDSTONE.registerItem(blocks.iOPort(), 1); - // Level Emitter! - Upgrades.FUZZY.registerItem( parts.levelEmitter(), 1 ); - Upgrades.CRAFTING.registerItem( parts.levelEmitter(), 1 ); + // Level Emitter! + Upgrades.FUZZY.registerItem(parts.levelEmitter(), 1); + Upgrades.CRAFTING.registerItem(parts.levelEmitter(), 1); - // Import Bus - Upgrades.FUZZY.registerItem( parts.importBus(), 1 ); - Upgrades.REDSTONE.registerItem( parts.importBus(), 1 ); - Upgrades.CAPACITY.registerItem( parts.importBus(), 2 ); - Upgrades.SPEED.registerItem( parts.importBus(), 4 ); + // Import Bus + Upgrades.FUZZY.registerItem(parts.importBus(), 1); + Upgrades.REDSTONE.registerItem(parts.importBus(), 1); + Upgrades.CAPACITY.registerItem(parts.importBus(), 2); + Upgrades.SPEED.registerItem(parts.importBus(), 4); - // Fluid Import Bus - Upgrades.CAPACITY.registerItem( parts.fluidImportBus(), 2 ); - Upgrades.REDSTONE.registerItem( parts.fluidImportBus(), 1 ); - Upgrades.SPEED.registerItem( parts.fluidImportBus(), 4 ); + // Fluid Import Bus + Upgrades.CAPACITY.registerItem(parts.fluidImportBus(), 2); + Upgrades.REDSTONE.registerItem(parts.fluidImportBus(), 1); + Upgrades.SPEED.registerItem(parts.fluidImportBus(), 4); - // Export Bus - 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 ); + // Export Bus + 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); - // Fluid Export Bus - Upgrades.CAPACITY.registerItem( parts.fluidExportBus(), 2 ); - Upgrades.REDSTONE.registerItem( parts.fluidExportBus(), 1 ); - Upgrades.SPEED.registerItem( parts.fluidExportBus(), 4 ); + // Fluid Export Bus + Upgrades.CAPACITY.registerItem(parts.fluidExportBus(), 2); + Upgrades.REDSTONE.registerItem(parts.fluidExportBus(), 1); + Upgrades.SPEED.registerItem(parts.fluidExportBus(), 4); - // Storage Cells - Upgrades.FUZZY.registerItem( items.cell1k(), 1 ); - Upgrades.INVERTER.registerItem( items.cell1k(), 1 ); + // Storage Cells + Upgrades.FUZZY.registerItem(items.cell1k(), 1); + Upgrades.INVERTER.registerItem(items.cell1k(), 1); - Upgrades.FUZZY.registerItem( items.cell4k(), 1 ); - Upgrades.INVERTER.registerItem( items.cell4k(), 1 ); + Upgrades.FUZZY.registerItem(items.cell4k(), 1); + Upgrades.INVERTER.registerItem(items.cell4k(), 1); - Upgrades.FUZZY.registerItem( items.cell16k(), 1 ); - Upgrades.INVERTER.registerItem( items.cell16k(), 1 ); + Upgrades.FUZZY.registerItem(items.cell16k(), 1); + Upgrades.INVERTER.registerItem(items.cell16k(), 1); - Upgrades.FUZZY.registerItem( items.cell64k(), 1 ); - Upgrades.INVERTER.registerItem( items.cell64k(), 1 ); + Upgrades.FUZZY.registerItem(items.cell64k(), 1); + Upgrades.INVERTER.registerItem(items.cell64k(), 1); - Upgrades.FUZZY.registerItem( items.portableCell(), 1 ); - Upgrades.INVERTER.registerItem( items.portableCell(), 1 ); + Upgrades.FUZZY.registerItem(items.portableCell(), 1); + Upgrades.INVERTER.registerItem(items.portableCell(), 1); - Upgrades.FUZZY.registerItem( items.viewCell(), 1 ); - Upgrades.INVERTER.registerItem( items.viewCell(), 1 ); + Upgrades.FUZZY.registerItem(items.viewCell(), 1); + Upgrades.INVERTER.registerItem(items.viewCell(), 1); - // Storage Bus - Upgrades.FUZZY.registerItem( parts.storageBus(), 1 ); - Upgrades.INVERTER.registerItem( parts.storageBus(), 1 ); - Upgrades.CAPACITY.registerItem( parts.storageBus(), 5 ); + // Storage Bus + Upgrades.FUZZY.registerItem(parts.storageBus(), 1); + Upgrades.INVERTER.registerItem(parts.storageBus(), 1); + Upgrades.CAPACITY.registerItem(parts.storageBus(), 5); - // Storage Bus Fluids - Upgrades.INVERTER.registerItem( parts.fluidStorageBus(), 1 ); - Upgrades.CAPACITY.registerItem( parts.fluidStorageBus(), 5 ); + // Storage Bus Fluids + Upgrades.INVERTER.registerItem(parts.fluidStorageBus(), 1); + Upgrades.CAPACITY.registerItem(parts.fluidStorageBus(), 5); - // Formation Plane - Upgrades.FUZZY.registerItem( parts.formationPlane(), 1 ); - Upgrades.INVERTER.registerItem( parts.formationPlane(), 1 ); - Upgrades.CAPACITY.registerItem( parts.formationPlane(), 5 ); + // Formation Plane + Upgrades.FUZZY.registerItem(parts.formationPlane(), 1); + Upgrades.INVERTER.registerItem(parts.formationPlane(), 1); + Upgrades.CAPACITY.registerItem(parts.formationPlane(), 5); - // Matter Cannon - Upgrades.FUZZY.registerItem( items.massCannon(), 1 ); - Upgrades.INVERTER.registerItem( items.massCannon(), 1 ); - Upgrades.SPEED.registerItem( items.massCannon(), 4 ); + // Matter Cannon + Upgrades.FUZZY.registerItem(items.massCannon(), 1); + Upgrades.INVERTER.registerItem(items.massCannon(), 1); + Upgrades.SPEED.registerItem(items.massCannon(), 4); - // Molecular Assembler - Upgrades.SPEED.registerItem( blocks.molecularAssembler(), 5 ); + // Molecular Assembler + Upgrades.SPEED.registerItem(blocks.molecularAssembler(), 5); - // Inscriber - Upgrades.SPEED.registerItem( blocks.inscriber(), 3 ); + // Inscriber + Upgrades.SPEED.registerItem(blocks.inscriber(), 3); - // Wireless Terminal Handler - items.wirelessTerminal().maybeItem().ifPresent( terminal -> registries.wireless().registerWirelessHandler( (IWirelessTermHandler) terminal ) ); + // Wireless Terminal Handler + items.wirelessTerminal().maybeItem() + .ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal)); - // Charge Rates - items.chargedStaff().maybeItem().ifPresent( chargedStaff -> registries.charger().addChargeRate( chargedStaff, 320d ) ); - items.portableCell().maybeItem().ifPresent( chargedStaff -> registries.charger().addChargeRate( chargedStaff, 800d ) ); - items.colorApplicator().maybeItem().ifPresent( colorApplicator -> registries.charger().addChargeRate( colorApplicator, 800d ) ); - items.wirelessTerminal().maybeItem().ifPresent( terminal -> registries.charger().addChargeRate( terminal, 8000d ) ); - items.entropyManipulator().maybeItem().ifPresent( entropyManipulator -> registries.charger().addChargeRate( entropyManipulator, 8000d ) ); - items.massCannon().maybeItem().ifPresent( massCannon -> registries.charger().addChargeRate( massCannon, 8000d ) ); - blocks.energyCell().maybeItem().ifPresent( cell -> registries.charger().addChargeRate( cell, 8000d ) ); - blocks.energyCellDense().maybeItem().ifPresent( cell -> registries.charger().addChargeRate( cell, 16000d ) ); + // Charge Rates + items.chargedStaff().maybeItem() + .ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d)); + items.portableCell().maybeItem() + .ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 800d)); + items.colorApplicator().maybeItem() + .ifPresent(colorApplicator -> registries.charger().addChargeRate(colorApplicator, 800d)); + items.wirelessTerminal().maybeItem().ifPresent(terminal -> registries.charger().addChargeRate(terminal, 8000d)); + items.entropyManipulator().maybeItem() + .ifPresent(entropyManipulator -> registries.charger().addChargeRate(entropyManipulator, 8000d)); + items.massCannon().maybeItem().ifPresent(massCannon -> registries.charger().addChargeRate(massCannon, 8000d)); + blocks.energyCell().maybeItem().ifPresent(cell -> registries.charger().addChargeRate(cell, 8000d)); + blocks.energyCellDense().maybeItem().ifPresent(cell -> registries.charger().addChargeRate(cell, 16000d)); // FIXME // add villager trading to black smiths for a few basic materials // FIXME if( AEConfig.instance().isFeatureEnabled( AEFeature.VILLAGER_TRADING ) ) @@ -686,110 +518,104 @@ final class Registration // FIXME // VillagerRegistry.instance().getRegisteredVillagers().registerVillageTradeHandler( 3, new AETrading() ); // FIXME } - final IMovableRegistry mr = registries.movable(); + final IMovableRegistry mr = registries.movable(); - /* - * You can't move bed rock. - */ - mr.blacklistBlock( net.minecraft.block.Blocks.BEDROCK ); + /* + * You can't move bed rock. + */ + mr.blacklistBlock(net.minecraft.block.Blocks.BEDROCK); - /* - * White List Vanilla... - */ - mr.whiteListTileEntity( net.minecraft.tileentity.BannerTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.BeaconTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.BrewingStandTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.ChestTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.CommandBlockTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.ComparatorTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.DaylightDetectorTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.DispenserTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.DropperTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.EnchantingTableTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.EnderChestTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.EndPortalTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.FurnaceTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.HopperTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.MobSpawnerTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.PistonTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.ShulkerBoxTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.SignTileEntity.class ); - mr.whiteListTileEntity( net.minecraft.tileentity.SkullTileEntity.class ); + /* + * White List Vanilla... + */ + mr.whiteListTileEntity(net.minecraft.tileentity.BannerTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.BeaconTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.BrewingStandTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.ChestTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.CommandBlockTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.ComparatorTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.DaylightDetectorTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.DispenserTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.DropperTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.EnchantingTableTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.EnderChestTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.EndPortalTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.FurnaceTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.HopperTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.MobSpawnerTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.PistonTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.ShulkerBoxTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.SignTileEntity.class); + mr.whiteListTileEntity(net.minecraft.tileentity.SkullTileEntity.class); - /* - * Whitelist AE2 - */ - mr.whiteListTileEntity( AEBaseTile.class ); + /* + * Whitelist AE2 + */ + mr.whiteListTileEntity(AEBaseTile.class); - /* - * world gen - */ - for( final IWorldGen.WorldGenType type : IWorldGen.WorldGenType.values() ) - { - // FIXME: registries.worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class ); + /* + * world gen + */ + for (final IWorldGen.WorldGenType type : IWorldGen.WorldGenType.values()) { + // FIXME: registries.worldgen().disableWorldGenForProviderID( type, + // StorageWorldProvider.class ); - registries.worldgen().disableWorldGenForDimension( type, DimensionType.THE_NETHER.getRegistryName() ); + registries.worldgen().disableWorldGenForDimension(type, DimensionType.THE_NETHER.getRegistryName()); - registries.worldgen().disableWorldGenForDimension( type, DimensionType.THE_NETHER.getRegistryName() ); - } + registries.worldgen().disableWorldGenForDimension(type, DimensionType.THE_NETHER.getRegistryName()); + } - // whitelist from config - for( final String dimension : AEConfig.instance().getMeteoriteDimensionWhitelist() ) - { - registries.worldgen().enableWorldGenForDimension( IWorldGen.WorldGenType.METEORITES, new ResourceLocation( dimension ) ); - } + // whitelist from config + for (final String dimension : AEConfig.instance().getMeteoriteDimensionWhitelist()) { + registries.worldgen().enableWorldGenForDimension(IWorldGen.WorldGenType.METEORITES, + new ResourceLocation(dimension)); + } - ForgeRegistries.BIOMES.forEach( - b -> { - b.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, - new ConfiguredFeature>( - MeteoriteWorldGen.INSTANCE, - IFeatureConfig.NO_FEATURE_CONFIG - ) - ); - } - ); + ForgeRegistries.BIOMES.forEach(b -> { + b.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, + new ConfiguredFeature>(MeteoriteWorldGen.INSTANCE, + IFeatureConfig.NO_FEATURE_CONFIG)); + }); - } + } - public void registerWorldGen( RegistryEvent.Register> evt ) - { - IForgeRegistry> r = evt.getRegistry(); + public void registerWorldGen(RegistryEvent.Register> evt) { + IForgeRegistry> r = evt.getRegistry(); - r.register( MeteoriteWorldGen.INSTANCE ); - } + r.register(MeteoriteWorldGen.INSTANCE); + } - public void registerBiomes(RegistryEvent.Register evt) { - evt.getRegistry().register(StorageCellBiome.INSTANCE); - } + public void registerBiomes(RegistryEvent.Register evt) { + evt.getRegistry().register(StorageCellBiome.INSTANCE); + } - public void registerModDimension(RegistryEvent.Register evt) - { - evt.getRegistry().register(StorageCellModDimension.INSTANCE); - } + public void registerModDimension(RegistryEvent.Register evt) { + evt.getRegistry().register(StorageCellModDimension.INSTANCE); + } - public void registerTextures(TextureStitchEvent.Pre event) { - SkyChestTESR.registerTextures(event); - InscriberTESR.registerTexture(event); - } + public void registerTextures(TextureStitchEvent.Pre event) { + SkyChestTESR.registerTextures(event); + InscriberTESR.registerTexture(event); + } - public void registerCommands( final FMLServerStartingEvent evt ) - { - new AECommand().register(evt.getCommandDispatcher()); - } + public void registerCommands(final FMLServerStartingEvent evt) { + new AECommand().register(evt.getCommandDispatcher()); + } - @OnlyIn(Dist.CLIENT) - public void registerItemColors(ColorHandlerEvent.Item event) { - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( IItemColorRegistrationComponent.class ).forEachRemaining(c -> c.register(event.getItemColors(), event.getBlockColors())); - } + @OnlyIn(Dist.CLIENT) + public void registerItemColors(ColorHandlerEvent.Item event) { + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(IItemColorRegistrationComponent.class) + .forEachRemaining(c -> c.register(event.getItemColors(), event.getBlockColors())); + } - @OnlyIn(Dist.CLIENT) - public void handleModelBake(ModelBakeEvent event) { - // TODO: Do not use the internal API - final ApiDefinitions definitions = Api.INSTANCE.definitions(); - definitions.getRegistry().getBootstrapComponents( IModelBakeComponent.class ).forEachRemaining(c -> c.onModelBakeEvent(event)); - } + @OnlyIn(Dist.CLIENT) + public void handleModelBake(ModelBakeEvent event) { + // TODO: Do not use the internal API + final ApiDefinitions definitions = Api.INSTANCE.definitions(); + definitions.getRegistry().getBootstrapComponents(IModelBakeComponent.class) + .forEachRemaining(c -> c.onModelBakeEvent(event)); + } } diff --git a/src/main/java/appeng/core/api/ApiClientHelper.java b/src/main/java/appeng/core/api/ApiClientHelper.java index 82312a7af..ca885686e 100644 --- a/src/main/java/appeng/core/api/ApiClientHelper.java +++ b/src/main/java/appeng/core/api/ApiClientHelper.java @@ -1,62 +1,51 @@ package appeng.core.api; - import java.util.List; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; + import appeng.api.config.IncludeExclude; import appeng.api.storage.ICellInventory; import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.data.IAEStack; import appeng.api.util.IClientHelper; import appeng.core.localization.GuiText; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +public class ApiClientHelper implements IClientHelper { + @Override + public > void addCellInformation(ICellInventoryHandler handler, + List lines) { + if (handler == null) { + return; + } -public class ApiClientHelper implements IClientHelper -{ - @Override - public > void addCellInformation( ICellInventoryHandler handler, List lines ) - { - if( handler == null ) - { - return; - } + final ICellInventory cellInventory = handler.getCellInv(); - final ICellInventory cellInventory = handler.getCellInv(); + if (cellInventory != null) { + lines.add(new StringTextComponent(cellInventory.getUsedBytes() + " ") + .appendSibling(GuiText.Of.textComponent()).appendText(" " + cellInventory.getTotalBytes() + " ") + .appendSibling(GuiText.BytesUsed.textComponent())); - if( cellInventory != null ) - { - lines.add(new StringTextComponent(cellInventory.getUsedBytes() + " ") - .appendSibling(GuiText.Of.textComponent()) - .appendText(" " + cellInventory.getTotalBytes() + " ") - .appendSibling(GuiText.BytesUsed.textComponent())); + lines.add(new StringTextComponent(cellInventory.getStoredItemTypes() + " ") + .appendSibling(GuiText.Of.textComponent()).appendText(" " + cellInventory.getTotalItemTypes() + " ") + .appendSibling(GuiText.Types.textComponent())); + } - lines.add(new StringTextComponent(cellInventory.getStoredItemTypes() + " ") - .appendSibling(GuiText.Of.textComponent()) - .appendText(" " + cellInventory.getTotalItemTypes() + " ") - .appendSibling(GuiText.Types.textComponent())); - } + if (handler.isPreformatted()) { + final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included + : GuiText.Excluded).getLocal(); - if( handler.isPreformatted() ) - { - final String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal(); + if (handler.isFuzzy()) { + lines.add(GuiText.Partitioned.textComponent().appendText(" - " + list + " ") + .appendSibling(GuiText.Fuzzy.textComponent())); + } else { + lines.add(GuiText.Partitioned.textComponent().appendText(" - " + list + " ") + .appendSibling(GuiText.Precise.textComponent())); + } + } - if( handler.isFuzzy() ) - { - lines.add( GuiText.Partitioned.textComponent() - .appendText(" - " + list + " ") - .appendSibling(GuiText.Fuzzy.textComponent())); - } - else - { - lines.add( GuiText.Partitioned.textComponent() - .appendText(" - " + list + " ") - .appendSibling(GuiText.Precise.textComponent())); - } - } - - } + } } diff --git a/src/main/java/appeng/core/api/ApiGrid.java b/src/main/java/appeng/core/api/ApiGrid.java index b4cf311a3..45c8f2c25 100644 --- a/src/main/java/appeng/core/api/ApiGrid.java +++ b/src/main/java/appeng/core/api/ApiGrid.java @@ -18,7 +18,6 @@ package appeng.core.api; - import com.google.common.base.Preconditions; import appeng.api.exceptions.FailedConnectionException; @@ -31,35 +30,30 @@ import appeng.me.GridConnection; import appeng.me.GridNode; import appeng.util.Platform; - /** * @author yueh * @version rv5 * @since rv5 */ -public class ApiGrid implements IGridHelper -{ +public class ApiGrid implements IGridHelper { - @Override - public IGridNode createGridNode( final IGridBlock blk ) - { - Preconditions.checkNotNull( blk ); + @Override + public IGridNode createGridNode(final IGridBlock blk) { + Preconditions.checkNotNull(blk); - if( Platform.isClient() ) - { - throw new IllegalStateException( "Grid features for " + blk + " are server side only." ); - } + if (Platform.isClient()) { + throw new IllegalStateException("Grid features for " + blk + " are server side only."); + } - return new GridNode( blk ); - } + return new GridNode(blk); + } - @Override - public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnectionException - { - Preconditions.checkNotNull( a ); - Preconditions.checkNotNull( b ); + @Override + public IGridConnection createGridConnection(final IGridNode a, final IGridNode b) throws FailedConnectionException { + Preconditions.checkNotNull(a); + Preconditions.checkNotNull(b); - return GridConnection.create( a, b, AEPartLocation.INTERNAL ); - } + return GridConnection.create(a, b, AEPartLocation.INTERNAL); + } } diff --git a/src/main/java/appeng/core/api/ApiPart.java b/src/main/java/appeng/core/api/ApiPart.java index 62ba3e000..df9d064e1 100644 --- a/src/main/java/appeng/core/api/ApiPart.java +++ b/src/main/java/appeng/core/api/ApiPart.java @@ -18,7 +18,6 @@ package appeng.core.api; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; @@ -32,19 +31,16 @@ import appeng.api.parts.IPartHelper; import appeng.core.AppEng; import appeng.parts.PartPlacement; +public class ApiPart implements IPartHelper { -public class ApiPart implements IPartHelper -{ + @Override + public ActionResultType placeBus(final ItemStack is, final BlockPos pos, final Direction side, + final PlayerEntity player, final Hand hand, final World w) { + return PartPlacement.place(is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0); + } - @Override - public ActionResultType placeBus( final ItemStack is, final BlockPos pos, final Direction side, final PlayerEntity player, final Hand hand, final World w ) - { - return PartPlacement.place( is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0 ); - } - - @Override - public CableRenderMode getCableRenderMode() - { - return AppEng.proxy.getRenderMode(); - } + @Override + public CableRenderMode getCableRenderMode() { + return AppEng.proxy.getRenderMode(); + } } diff --git a/src/main/java/appeng/core/api/ApiStorage.java b/src/main/java/appeng/core/api/ApiStorage.java index 49161659a..3f347311f 100644 --- a/src/main/java/appeng/core/api/ApiStorage.java +++ b/src/main/java/appeng/core/api/ApiStorage.java @@ -18,7 +18,6 @@ package appeng.core.api; - import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -56,177 +55,152 @@ import appeng.util.Platform; import appeng.util.item.AEItemStack; import appeng.util.item.ItemList; +public class ApiStorage implements IStorageHelper { -public class ApiStorage implements IStorageHelper -{ + private final ClassToInstanceMap> channels; - private final ClassToInstanceMap> channels; + public ApiStorage() { + this.channels = MutableClassToInstanceMap.create(); + this.registerStorageChannel(IItemStorageChannel.class, new ItemStorageChannel()); + this.registerStorageChannel(IFluidStorageChannel.class, new FluidStorageChannel()); + } - public ApiStorage() - { - this.channels = MutableClassToInstanceMap.create(); - this.registerStorageChannel( IItemStorageChannel.class, new ItemStorageChannel() ); - this.registerStorageChannel( IFluidStorageChannel.class, new FluidStorageChannel() ); - } + @Override + public , C extends IStorageChannel> void registerStorageChannel(Class channel, + C factory) { + Preconditions.checkNotNull(channel); + Preconditions.checkNotNull(factory); + Preconditions.checkArgument(channel.isInstance(factory)); + Preconditions.checkArgument(!this.channels.containsKey(channel)); - @Override - public , C extends IStorageChannel> void registerStorageChannel( Class channel, C factory ) - { - Preconditions.checkNotNull( channel ); - Preconditions.checkNotNull( factory ); - Preconditions.checkArgument( channel.isInstance( factory ) ); - Preconditions.checkArgument( !this.channels.containsKey( channel ) ); + this.channels.putInstance(channel, factory); + } - this.channels.putInstance( channel, factory ); - } + @Override + public , C extends IStorageChannel> C getStorageChannel(Class channel) { + Preconditions.checkNotNull(channel); - @Override - public , C extends IStorageChannel> C getStorageChannel( Class channel ) - { - Preconditions.checkNotNull( channel ); + final C type = this.channels.getInstance(channel); - final C type = this.channels.getInstance( channel ); + Preconditions.checkNotNull(type); - Preconditions.checkNotNull( type ); + return type; + } - return type; - } + @Override + public Collection>> storageChannels() { + return Collections.unmodifiableCollection(this.channels.values()); + } - @Override - public Collection>> storageChannels() - { - return Collections.unmodifiableCollection( this.channels.values() ); - } + @Override + public ICraftingLink loadCraftingLink(final CompoundNBT data, final ICraftingRequester req) { + Preconditions.checkNotNull(data); + Preconditions.checkNotNull(req); - @Override - public ICraftingLink loadCraftingLink( final CompoundNBT data, final ICraftingRequester req ) - { - Preconditions.checkNotNull( data ); - Preconditions.checkNotNull( req ); + return new CraftingLink(data, req); + } - return new CraftingLink( data, req ); - } + @Override + public > T poweredInsert(IEnergySource energy, IMEInventory inv, T input, + IActionSource src, Actionable mode) { + return Platform.poweredInsert(energy, inv, input, src, mode); + } - @Override - public > T poweredInsert( IEnergySource energy, IMEInventory inv, T input, IActionSource src, Actionable mode ) - { - return Platform.poweredInsert( energy, inv, input, src, mode ); - } + @Override + public > T poweredExtraction(IEnergySource energy, IMEInventory inv, T request, + IActionSource src, Actionable mode) { + return Platform.poweredExtraction(energy, inv, request, src, mode); + } - @Override - public > T poweredExtraction( IEnergySource energy, IMEInventory inv, T request, IActionSource src, Actionable mode ) - { - return Platform.poweredExtraction( energy, inv, request, src, mode ); - } + @Override + public void postChanges(IStorageGrid gs, ItemStack removedCell, ItemStack addedCell, IActionSource src) { + Preconditions.checkNotNull(gs); + Preconditions.checkNotNull(removedCell); + Preconditions.checkNotNull(addedCell); + Preconditions.checkNotNull(src); - @Override - public void postChanges( IStorageGrid gs, ItemStack removedCell, ItemStack addedCell, IActionSource src ) - { - Preconditions.checkNotNull( gs ); - Preconditions.checkNotNull( removedCell ); - Preconditions.checkNotNull( addedCell ); - Preconditions.checkNotNull( src ); + Platform.postChanges(gs, removedCell, addedCell, src); + } - Platform.postChanges( gs, removedCell, addedCell, src ); - } + private static final class ItemStorageChannel implements IItemStorageChannel { - private static final class ItemStorageChannel implements IItemStorageChannel - { + @Override + public IItemList createList() { + return new ItemList(); + } - @Override - public IItemList createList() - { - return new ItemList(); - } + @Override + public IAEItemStack createStack(Object input) { + Preconditions.checkNotNull(input); - @Override - public IAEItemStack createStack( Object input ) - { - Preconditions.checkNotNull( input ); + if (input instanceof ItemStack) { + return AEItemStack.fromItemStack((ItemStack) input); + } - if( input instanceof ItemStack ) - { - return AEItemStack.fromItemStack( (ItemStack) input ); - } + return null; + } - return null; - } + @Override + public IAEItemStack createFromNBT(CompoundNBT nbt) { + Preconditions.checkNotNull(nbt); + return AEItemStack.fromNBT(nbt); + } - @Override - public IAEItemStack createFromNBT( CompoundNBT nbt ) - { - Preconditions.checkNotNull( nbt ); - return AEItemStack.fromNBT( nbt ); - } + @Override + public IAEItemStack readFromPacket(PacketBuffer input) { + Preconditions.checkNotNull(input); - @Override - public IAEItemStack readFromPacket( PacketBuffer input ) - { - Preconditions.checkNotNull( input ); + return AEItemStack.fromPacket(input); + } + } - return AEItemStack.fromPacket( input ); - } - } + private static final class FluidStorageChannel implements IFluidStorageChannel { - private static final class FluidStorageChannel implements IFluidStorageChannel - { + @Override + public int transferFactor() { + return 125; + } - @Override - public int transferFactor() - { - return 125; - } + @Override + public int getUnitsPerByte() { + return 8000; + } - @Override - public int getUnitsPerByte() - { - return 8000; - } + @Override + public IItemList createList() { + return new FluidList(); + } - @Override - public IItemList createList() - { - return new FluidList(); - } + @Override + public IAEFluidStack createStack(Object input) { + Preconditions.checkNotNull(input); - @Override - public IAEFluidStack createStack( Object input ) - { - Preconditions.checkNotNull( input ); + if (input instanceof FluidStack) { + return AEFluidStack.fromFluidStack((FluidStack) input); + } + if (input instanceof ItemStack) { + final ItemStack is = (ItemStack) input; + if (is.getItem() instanceof FluidDummyItem) { + return AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is)); + } else { + return AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is).orElse(null)); + } + } - if( input instanceof FluidStack ) - { - return AEFluidStack.fromFluidStack( (FluidStack) input ); - } - if( input instanceof ItemStack ) - { - final ItemStack is = (ItemStack) input; - if( is.getItem() instanceof FluidDummyItem ) - { - return AEFluidStack.fromFluidStack( ( (FluidDummyItem) is.getItem() ).getFluidStack( is ) ); - } - else - { - return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ).orElse( null ) ); - } - } + return null; + } - return null; - } + @Override + public IAEFluidStack readFromPacket(PacketBuffer input) { + Preconditions.checkNotNull(input); - @Override - public IAEFluidStack readFromPacket( PacketBuffer input ) - { - Preconditions.checkNotNull( input ); + return AEFluidStack.fromPacket(input); + } - return AEFluidStack.fromPacket( input ); - } - - @Override - public IAEFluidStack createFromNBT( CompoundNBT nbt ) - { - Preconditions.checkNotNull( nbt ); - return AEFluidStack.fromNBT( nbt ); - } - } + @Override + public IAEFluidStack createFromNBT(CompoundNBT nbt) { + Preconditions.checkNotNull(nbt); + return AEFluidStack.fromNBT(nbt); + } + } } diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index 9be106cda..d61b9710a 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -18,6 +18,18 @@ package appeng.core.api.definitions; +import static appeng.block.AEBaseBlock.defaultProps; +import static appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType; +import static appeng.decorative.solid.BlockSkyStone.SkystoneType; + +import net.minecraft.block.*; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.entity.EntityClassification; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.ToolType; import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlocks; @@ -72,982 +84,860 @@ import appeng.tile.storage.TileChest; import appeng.tile.storage.TileDrive; import appeng.tile.storage.TileIOPort; import appeng.tile.storage.TileSkyChest; -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.entity.EntityClassification; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.ToolType; - -import static appeng.block.AEBaseBlock.defaultProps; -import static appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType; -import static appeng.decorative.solid.BlockSkyStone.SkystoneType; - /** * 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 quartzBlock; - private final IBlockDefinition quartzPillar; - private final IBlockDefinition chiseledQuartzBlock; - private final IBlockDefinition quartzGlass; - private final IBlockDefinition quartzVibrantGlass; - private final IBlockDefinition quartzFixture; - private final IBlockDefinition fluixBlock; - private final IBlockDefinition skyStoneBlock; - private final IBlockDefinition smoothSkyStoneBlock; - private final IBlockDefinition skyStoneBrick; - private final IBlockDefinition skyStoneSmallBrick; - private final IBlockDefinition skyStoneChest; - private final IBlockDefinition smoothSkyStoneChest; - private final IBlockDefinition skyCompass; - private final ITileDefinition grindstone; - private final ITileDefinition crank; - private final ITileDefinition inscriber; - private final ITileDefinition wirelessAccessPoint; - private final ITileDefinition charger; - private final IBlockDefinition tinyTNT; - private final ITileDefinition securityStation; - 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 fluidIface; - 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 skyStoneStairs; - private final IBlockDefinition smoothSkyStoneStairs; - private final IBlockDefinition skyStoneBrickStairs; - private final IBlockDefinition skyStoneSmallBrickStairs; - private final IBlockDefinition fluixStairs; - private final IBlockDefinition quartzStairs; - private final IBlockDefinition chiseledQuartzStairs; - private final IBlockDefinition quartzPillarStairs; - - private final IBlockDefinition skyStoneSlab; - private final IBlockDefinition smoothSkyStoneSlab; - private final IBlockDefinition skyStoneBrickSlab; - private final IBlockDefinition skyStoneSmallBrickSlab; - private final IBlockDefinition fluixSlab; - private final IBlockDefinition quartzSlab; - private final IBlockDefinition chiseledQuartzSlab; - private final IBlockDefinition quartzPillarSlab; - - private final IBlockDefinition itemGen; - private final IBlockDefinition chunkLoader; - private final IBlockDefinition phantomNode; - private final IBlockDefinition cubeGenerator; - private final IBlockDefinition energyGenerator; - - private static final Block.Properties QUARTZ_PROPERTIES = defaultProps(Material.ROCK) - .hardnessAndResistance(3, 5); - - private static final Block.Properties SKYSTONE_PROPERTIES = defaultProps( Material.ROCK ) - .hardnessAndResistance( 50, 150 ); - - public ApiBlocks(FeatureFactory registry) - { - this.quartzOre = registry.block( "quartz_ore", () -> new BlockQuartzOre(QUARTZ_PROPERTIES)) - .features( AEFeature.CERTUS_ORE ) - .build(); - this.quartzOreCharged = registry.block( "charged_quartz_ore", () -> new BlockChargedQuartzOre(QUARTZ_PROPERTIES) ) - .features( AEFeature.CERTUS_ORE, AEFeature.CHARGED_CERTUS_ORE ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - } - }) - .build(); - this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ) - .features( AEFeature.SPATIAL_IO ) - .build(); - - FeatureFactory deco = registry.features( AEFeature.DECORATIVE_BLOCKS ); - this.quartzBlock = deco.block( "quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build(); - this.quartzPillar = deco.block( "quartz_pillar", () -> new BlockQuartzPillar(QUARTZ_PROPERTIES) ).build(); - this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build(); - - this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS ) - .block( "quartz_glass", () -> new BlockQuartzGlass(defaultProps(Material.GLASS).notSolid()) ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - } - }) - .build(); - this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", () -> new BlockQuartzLamp(defaultProps(Material.GLASS).lightValue(15).notSolid()) ) - .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - } - }) - .build(); - - this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new ) - .features( AEFeature.DECORATIVE_LIGHTS ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - } - }) - .build(); - - this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build(); - - this.skyStoneBlock = registry.features( AEFeature.SKY_STONE ) - .block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE, defaultProps(Material.ROCK) - .hardnessAndResistance(50, 150) - .harvestLevel(3) ) ) - .build(); - - this.smoothSkyStoneBlock = registry.features( AEFeature.SKY_STONE ) - .block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK, SKYSTONE_PROPERTIES ) ) - .build(); - this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK, SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK, SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - - Block.Properties skyStoneChestProps = defaultProps(Material.ROCK) - .hardnessAndResistance(50, 150) - .notSolid(); - - TileEntityDefinition skyChestTile = registry.tileEntity("sky_chest", TileSkyChest.class, TileSkyChest::new) - .rendering(new TileEntityRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer(SkyChestTESR::new); - } - }) - .build(); - this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( BlockSkyChest.SkyChestType.STONE, skyStoneChestProps ) ) - .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS ) - .tileEntity( skyChestTile ) - .build(); - this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( BlockSkyChest.SkyChestType.BLOCK, skyStoneChestProps ) ) - .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS ) - .tileEntity( skyChestTile ) - .build(); - - this.skyCompass = registry.block( "sky_compass", () -> new BlockSkyCompass(defaultProps(Material.MISCELLANEOUS)) ) - .features( AEFeature.METEORITE_COMPASS ) - .tileEntity( registry.tileEntity("sky_compass", TileSkyCompass.class, TileSkyCompass::new) - .rendering( new SkyCompassRendering() ) - .build() ) - .build(); - this.grindstone = registry.block( "grindstone", () -> new BlockGrinder(defaultProps(Material.ROCK).hardnessAndResistance(3.2f)) ) - .features( AEFeature.GRIND_STONE ) - .tileEntity( registry.tileEntity("grindstone", TileGrinder.class, TileGrinder::new ).build() ) - .build(); - this.crank = registry.block( "crank", () -> new BlockCrank(defaultProps(Material.WOOD).harvestTool(ToolType.AXE).harvestLevel(0).notSolid()) ) - .features( AEFeature.GRIND_STONE ) - .tileEntity( registry.tileEntity("crank", TileCrank.class, TileCrank::new ) - .rendering(new TileEntityRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer(CrankTESR::new); - } - }) - .build() ) - .build(); - this.inscriber = registry.block( "inscriber", () -> new BlockInscriber(defaultProps(Material.IRON).notSolid()) ) - .features( AEFeature.INSCRIBER ) - .tileEntity( registry.tileEntity("inscriber", TileInscriber.class, TileInscriber::new) - .rendering(new InscriberRendering()) - .build() ) - .build(); - this.wirelessAccessPoint = registry.block( "wireless_access_point", BlockWireless::new ) - .features( AEFeature.WIRELESS_ACCESS_TERMINAL ) - .tileEntity( registry.tileEntity("wireless_access_point", TileWireless.class, TileWireless::new).build() ) - .rendering( new WirelessRendering() ) - .build(); - this.charger = registry.block( "charger", BlockCharger::new ) - .features( AEFeature.CHARGER ) - .tileEntity( registry.tileEntity("charger", TileCharger.class, TileCharger::new) - .rendering( new TileEntityRenderingCustomizer() - { - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( TileEntityRendering rendering ) - { - rendering.tileEntityRenderer( BlockCharger.createTesr() ); - } - } ) - .build() ) - .build(); - - EntityTinyTNTPrimed.TYPE = registry.entity("tiny_tnt_primed", EntityTinyTNTPrimed::new, EntityClassification.MISC) - .customize(p -> p.setTrackingRange(16) - .setUpdateInterval(4) - .setShouldReceiveVelocityUpdates(true)) - .build(); - - this.tinyTNT = registry.block( "tiny_tnt", () -> new BlockTinyTNT(defaultProps(Material.TNT).sound(SoundType.GROUND).hardnessAndResistance(0).notSolid()) ) - .features( AEFeature.TINY_TNT ) - .bootstrap( ( block, item ) -> (IInitComponent) () -> DispenserBlock.registerDispenseBehavior( item, - new DispenserBehaviorTinyTNT() ) ) - .build(); - this.securityStation = registry.block( "security_station", BlockSecurityStation::new ) - .features( AEFeature.SECURITY ) - .tileEntity( registry.tileEntity("security_station", TileSecurityStation.class, TileSecurityStation::new).build() ) - .rendering( new SecurityStationRendering() ) - .build(); - - TileEntityDefinition quantumRingTile = registry.tileEntity("quantum_ring", TileQuantumBridge.class, TileQuantumBridge::new).build(); - this.quantumRing = registry.block( "quantum_ring", BlockQuantumRing::new ) - .features( AEFeature.QUANTUM_NETWORK_BRIDGE ) - .tileEntity( quantumRingTile ) - .rendering( new QuantumBridgeRendering() ) - .build(); - this.quantumLink = registry.block( "quantum_link", BlockQuantumLinkChamber::new ) - .features( AEFeature.QUANTUM_NETWORK_BRIDGE ) - .tileEntity( quantumRingTile ) - .rendering( new QuantumBridgeRendering() ) - .build(); - this.spatialPylon = registry.block( "spatial_pylon", BlockSpatialPylon::new ) - .features( AEFeature.SPATIAL_IO ) - .tileEntity( registry.tileEntity("spatial_pylon", TileSpatialPylon.class, TileSpatialPylon::new).build() ) - .rendering( new SpatialPylonRendering() ) - .build(); - this.spatialIOPort = registry.block( "spatial_io_port", BlockSpatialIOPort::new ) - .features( AEFeature.SPATIAL_IO ) - .tileEntity( registry.tileEntity("spatial_io_port", TileSpatialIOPort.class, TileSpatialIOPort::new).build() ) - .build(); - this.controller = registry.block( "controller", BlockController::new ) - .features( AEFeature.CHANNELS ) - .tileEntity( registry.tileEntity("controller", TileController.class, TileController::new).build() ) - .rendering( new ControllerRendering() ) - .build(); - this.drive = registry.block( "drive", BlockDrive::new ) - .features( AEFeature.STORAGE_CELLS, AEFeature.ME_DRIVE ) - .tileEntity( registry.tileEntity("drive", TileDrive.class, TileDrive::new) - .rendering(new TileEntityRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer(DriveLedTileEntityRenderer::new); - } - }) - .build() ) - .rendering( new DriveRendering() ) - .build(); - this.chest = registry.block( "chest", BlockChest::new ) - .features( AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST ) - .tileEntity( registry.tileEntity("chest", TileChest.class, TileChest::new).build() ) - .rendering( new ChestRendering() ) - .build(); - this.iface = registry.block( "interface", BlockInterface::new ) - .features( AEFeature.INTERFACE ) - .tileEntity( registry.tileEntity("interface", TileInterface.class, TileInterface::new).build() ) - .build(); - this.fluidIface = registry.block( "fluid_interface", BlockFluidInterface::new ) - .features( AEFeature.FLUID_INTERFACE ) - .tileEntity( registry.tileEntity("fluid_interface", TileFluidInterface.class, TileFluidInterface::new).build() ) - .build(); - this.cellWorkbench = registry.block( "cell_workbench", BlockCellWorkbench::new ) - .features( AEFeature.STORAGE_CELLS ) - .tileEntity( registry.tileEntity("cell_workbench", TileCellWorkbench.class, TileCellWorkbench::new).build() ) - .build(); - this.iOPort = registry.block( "io_port", BlockIOPort::new ) - .features( AEFeature.STORAGE_CELLS, AEFeature.IO_PORT ) - .tileEntity( registry.tileEntity("io_port", TileIOPort.class, TileIOPort::new).build() ) - .build(); - this.condenser = registry.block( "condenser", BlockCondenser::new ) - .features( AEFeature.CONDENSER ) - .tileEntity( registry.tileEntity("condenser", TileCondenser.class, TileCondenser::new).build() ) - .build(); - this.energyAcceptor = registry.block( "energy_acceptor", BlockEnergyAcceptor::new ) - .features( AEFeature.ENERGY_ACCEPTOR ) - .tileEntity( registry.tileEntity("energy_acceptor", TileEnergyAcceptor.class, TileEnergyAcceptor::new).build() ) - .build(); - this.vibrationChamber = registry.block( "vibration_chamber", BlockVibrationChamber::new ) - .features( AEFeature.POWER_GEN ) - .tileEntity( registry.tileEntity("vibration_chamber", TileVibrationChamber.class, TileVibrationChamber::new).build() ) - .build(); - this.quartzGrowthAccelerator = registry.block( "quartz_growth_accelerator", BlockQuartzGrowthAccelerator::new ) - .tileEntity( registry.tileEntity("quartz_growth_accelerator", TileQuartzGrowthAccelerator.class, TileQuartzGrowthAccelerator::new).build() ) - .features( AEFeature.CRYSTAL_GROWTH_ACCELERATOR ) - .build(); - this.energyCell = registry.block( "energy_cell", BlockEnergyCell::new ) - .features( AEFeature.ENERGY_CELLS ) - .item( AEBaseBlockItemChargeable::new ) - .tileEntity( registry.tileEntity("energy_cell", TileEnergyCell.class, TileEnergyCell::new).build() ) - .rendering( new BlockEnergyCellRendering( new ResourceLocation( AppEng.MOD_ID, "energy_cell" ) ) ) - .build(); - this.energyCellDense = registry.block( "dense_energy_cell", BlockDenseEnergyCell::new ) - .features( AEFeature.ENERGY_CELLS, AEFeature.DENSE_ENERGY_CELLS ) - .item( AEBaseBlockItemChargeable::new ) - .tileEntity( registry.tileEntity("dense_energy_cell", TileDenseEnergyCell.class, TileDenseEnergyCell::new).build() ) - .rendering( new BlockEnergyCellRendering( new ResourceLocation( AppEng.MOD_ID, "dense_energy_cell" ) ) ) - .build(); - this.energyCellCreative = registry.block( "creative_energy_cell", BlockCreativeEnergyCell::new ) - .features( AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("creative_energy_cell", TileCreativeEnergyCell.class, TileCreativeEnergyCell::new).build() ) - .build(); - - - TileEntityDefinition craftingUnit = registry.tileEntity("crafting_unit", TileCraftingTile.class, TileCraftingTile::new) - .build(); - - FeatureFactory crafting = registry.features( AEFeature.CRAFTING_CPU ); - Block.Properties craftingBlockProps = defaultProps(Material.IRON); - this.craftingUnit = crafting.block( "crafting_unit", () -> new CraftingUnitBlock( craftingBlockProps, CraftingUnitType.UNIT ) ) - .rendering( new CraftingCubeRendering() ) - .tileEntity( craftingUnit ) - .build(); - this.craftingAccelerator = crafting.block( "crafting_accelerator", () -> new CraftingUnitBlock( craftingBlockProps, CraftingUnitType.ACCELERATOR ) ) - .rendering( new CraftingCubeRendering() ) - .tileEntity( craftingUnit ) - .build(); - - TileEntityDefinition craftingStorage = registry.tileEntity("crafting_storage", TileCraftingStorageTile.class, TileCraftingStorageTile::new) - .build(); - this.craftingStorage1k = crafting.block( "1k_crafting_storage", () -> new BlockCraftingStorage( craftingBlockProps, CraftingUnitType.STORAGE_1K ) ) - .item( ItemCraftingStorage::new ) - .tileEntity(craftingStorage) - .rendering( new CraftingCubeRendering() ) - .build(); - this.craftingStorage4k = crafting.block( "4k_crafting_storage", () -> new BlockCraftingStorage( craftingBlockProps, CraftingUnitType.STORAGE_4K ) ) - .item( ItemCraftingStorage::new ) - .tileEntity(craftingStorage) - .rendering( new CraftingCubeRendering() ) - .build(); - this.craftingStorage16k = crafting.block( "16k_crafting_storage", () -> new BlockCraftingStorage( craftingBlockProps, CraftingUnitType.STORAGE_16K ) ) - .item( ItemCraftingStorage::new ) - .tileEntity(craftingStorage) - .rendering( new CraftingCubeRendering() ) - .build(); - this.craftingStorage64k = crafting.block( "64k_crafting_storage", () -> new BlockCraftingStorage( craftingBlockProps, CraftingUnitType.STORAGE_64K ) ) - .item( ItemCraftingStorage::new ) - .tileEntity(craftingStorage) - .rendering( new CraftingCubeRendering() ) - .build(); - this.craftingMonitor = crafting.block( "crafting_monitor", () -> new BlockCraftingMonitor(craftingBlockProps) ) - .tileEntity( registry.tileEntity("crafting_monitor", TileCraftingMonitorTile.class, TileCraftingMonitorTile::new) - .rendering(new TileEntityRenderingCustomizer() { - @OnlyIn(Dist.CLIENT) - @Override - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer(CraftingMonitorTESR::new); - } - }) - .build() ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - rendering.modelCustomizer((path, model) -> { - // The formed model handles rotations itself, the unformed one does not - if (model instanceof MonitorBakedModel) { - return model; - } - return new AutoRotatingBakedModel(model); - }); - } - }) - .build(); - - this.molecularAssembler = registry.block( "molecular_assembler", () -> new BlockMolecularAssembler(defaultProps(Material.IRON).notSolid()) ) - .features( AEFeature.MOLECULAR_ASSEMBLER ) - .rendering(new BlockRenderingCustomizer() { - @OnlyIn(Dist.CLIENT) - @Override - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - // FIXME: This is an old comment, check if it still applies - /** - * NOTE: This is only used to determine how to render an item being held in hand. - * For determining block rendering, the method below is used (canRenderInLayer). - */ - rendering.renderType(RenderType.getCutout()); - rendering.renderType(rt -> rt == RenderType.getCutout() || rt == RenderType.getTranslucent()); - } - }) - .tileEntity( registry.tileEntity("molecular_assembler", TileMolecularAssembler.class, TileMolecularAssembler::new).build() ) - .build(); - - this.lightDetector = registry.block( "light_detector", BlockLightDetector::new ) - .features( AEFeature.LIGHT_DETECTOR ) - .tileEntity( registry.tileEntity("light_detector", TileLightDetector.class, TileLightDetector::new).build() ) - .rendering(new BlockRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(IBlockRendering rendering, IItemRendering itemRendering) { - rendering.renderType(RenderType.getCutout()); - } - }) - .build(); - this.paint = registry.block( "paint", BlockPaint::new ) - .features( AEFeature.PAINT_BALLS ) - .tileEntity( registry.tileEntity("paint", TilePaint.class, TilePaint::new).build() ) - .rendering( new PaintRendering() ) - .build(); - - this.skyStoneStairs = deco.block( "sky_stone_stairs", () -> new StairsBlock(this.skyStoneBlock().block()::getDefaultState, SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.smoothSkyStoneStairs = deco.block( "smooth_sky_stone_stairs", () -> new StairsBlock(this.smoothSkyStoneBlock().block()::getDefaultState, SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.skyStoneBrickStairs = deco.block( "sky_stone_brick_stairs", () -> new StairsBlock(this.skyStoneBrick().block()::getDefaultState, SKYSTONE_PROPERTIES) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.skyStoneSmallBrickStairs = deco.block( "sky_stone_small_brick_stairs", () -> new StairsBlock(this.skyStoneSmallBrick().block()::getDefaultState, SKYSTONE_PROPERTIES) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - - this.fluixStairs = deco.block( "fluix_stairs", () -> new StairsBlock(this.fluixBlock().block()::getDefaultState, QUARTZ_PROPERTIES) ) - .addFeatures( AEFeature.FLUIX ) - .build(); - this.quartzStairs = deco.block( "quartz_stairs", () -> new StairsBlock(this.quartzBlock().block()::getDefaultState, QUARTZ_PROPERTIES) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - this.chiseledQuartzStairs = deco.block( "chiseled_quartz_stairs", () -> new StairsBlock(this.chiseledQuartzBlock().block()::getDefaultState, QUARTZ_PROPERTIES) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - this.quartzPillarStairs = deco.block( "quartz_pillar_stairs", () -> new StairsBlock(this.quartzPillar().block()::getDefaultState, QUARTZ_PROPERTIES) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - - this.multiPart = registry.block( "cable_bus", BlockCableBus::new ) - .rendering( new CableBusRendering() ) - .tileEntity( registry.tileEntity( "cable_bus", TileCableBus.class, TileCableBus::new) - .rendering(new TileEntityRenderingCustomizer() { - @Override - @OnlyIn(Dist.CLIENT) - public void customize(TileEntityRendering rendering) { - rendering.tileEntityRenderer(CableBusTESR::new); - } - }) - .build()) - .build(); - - this.skyStoneSlab = deco.block( "sky_stone_slab", () -> new SlabBlock( SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.smoothSkyStoneSlab = deco.block( "smooth_sky_stone_slab", () -> new SlabBlock( SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.skyStoneBrickSlab = deco.block( "sky_stone_brick_slab", () -> new SlabBlock( SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - this.skyStoneSmallBrickSlab = deco.block( "sky_stone_small_brick_slab", () -> new SlabBlock( SKYSTONE_PROPERTIES ) ) - .addFeatures( AEFeature.SKY_STONE ) - .build(); - - this.fluixSlab = deco.block( "fluix_slab", () -> new SlabBlock( QUARTZ_PROPERTIES ) ) - .addFeatures( AEFeature.FLUIX ) - .build(); - this.quartzSlab = deco.block( "quartz_slab", () -> new SlabBlock( QUARTZ_PROPERTIES ) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - this.chiseledQuartzSlab = deco.block( "chiseled_quartz_slab", () -> new SlabBlock( QUARTZ_PROPERTIES ) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - this.quartzPillarSlab = deco.block( "quartz_pillar_slab", () -> new SlabBlock( QUARTZ_PROPERTIES ) ) - .addFeatures( AEFeature.CERTUS ) - .build(); - - this.itemGen = registry.block( "debug_item_gen", BlockItemGen::new ) - .features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("debug_item_gen", TileItemGen.class, TileItemGen::new).build() ) - .build(); - this.chunkLoader = registry.block( "debug_chunk_loader", BlockChunkloader::new ) - .features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("debug_chunk_loader", TileChunkLoader.class, TileChunkLoader::new).build() ) - .build(); - this.phantomNode = registry.block( "debug_phantom_node", BlockPhantomNode::new ) - .features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("debug_phantom_node", TilePhantomNode.class, TilePhantomNode::new).build() ) - .build(); - this.cubeGenerator = registry.block( "debug_cube_gen", BlockCubeGenerator::new ) - .features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("debug_cube_gen", TileCubeGenerator.class, TileCubeGenerator::new).build() ) - .build(); - this.energyGenerator = registry.block( "debug_energy_gen", BlockEnergyGenerator::new ) - .features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ) - .tileEntity( registry.tileEntity("debug_energy_gen", TileEnergyGenerator.class, TileEnergyGenerator::new).build() ) - .build(); - } - - @Override - public IBlockDefinition quartzOre() - { - return this.quartzOre; - } - - @Override - public IBlockDefinition quartzOreCharged() - { - return this.quartzOreCharged; - } - - @Override - public IBlockDefinition matrixFrame() - { - return this.matrixFrame; - } - - @Override - public IBlockDefinition quartzBlock() - { - return this.quartzBlock; - } - - @Override - public IBlockDefinition quartzPillar() - { - return this.quartzPillar; - } - - @Override - public IBlockDefinition chiseledQuartzBlock() - { - return this.chiseledQuartzBlock; - } - - @Override - public IBlockDefinition quartzGlass() - { - return this.quartzGlass; - } - - @Override - public IBlockDefinition quartzVibrantGlass() - { - return this.quartzVibrantGlass; - } - - @Override - public IBlockDefinition quartzFixture() - { - return this.quartzFixture; - } - - @Override - public IBlockDefinition fluixBlock() - { - return this.fluixBlock; - } - - @Override - public IBlockDefinition skyStoneBlock() - { - return this.skyStoneBlock; - } - - @Override - public IBlockDefinition smoothSkyStoneBlock() - { - return this.smoothSkyStoneBlock; - } - - @Override - public IBlockDefinition skyStoneBrick() - { - return this.skyStoneBrick; - } - - @Override - public IBlockDefinition skyStoneSmallBrick() - { - return this.skyStoneSmallBrick; - } - - @Override - public IBlockDefinition skyStoneChest() - { - return this.skyStoneChest; - } - - @Override - public IBlockDefinition smoothSkyStoneChest() - { - return this.smoothSkyStoneChest; - } - - @Override - public IBlockDefinition skyCompass() - { - return this.skyCompass; - } - - @Override - public IBlockDefinition skyStoneStairs() - { - return this.skyStoneStairs; - } - - @Override - public IBlockDefinition smoothSkyStoneStairs() - { - return this.smoothSkyStoneStairs; - } - - @Override - public IBlockDefinition skyStoneBrickStairs() - { - return this.skyStoneBrickStairs; - } - - @Override - public IBlockDefinition skyStoneSmallBrickStairs() - { - return this.skyStoneSmallBrickStairs; - } - - @Override - public IBlockDefinition fluixStairs() - { - return this.fluixStairs; - } - - @Override - public IBlockDefinition quartzStairs() - { - return this.quartzStairs; - } - - @Override - public IBlockDefinition chiseledQuartzStairs() - { - return this.chiseledQuartzStairs; - } - - @Override - public IBlockDefinition quartzPillarStairs() - { - return this.quartzPillarStairs; - } - - @Override - public IBlockDefinition skyStoneSlab() - { - return this.skyStoneSlab; - } - - @Override - public IBlockDefinition smoothSkyStoneSlab() - { - return this.smoothSkyStoneSlab; - } - - @Override - public IBlockDefinition skyStoneBrickSlab() - { - return this.skyStoneBrickSlab; - } - - @Override - public IBlockDefinition skyStoneSmallBrickSlab() - { - return this.skyStoneSmallBrickSlab; - } - - @Override - public IBlockDefinition fluixSlab() - { - return this.fluixSlab; - } - - @Override - public IBlockDefinition quartzSlab() - { - return this.quartzSlab; - } - - @Override - public IBlockDefinition chiseledQuartzSlab() - { - return this.chiseledQuartzSlab; - } - - @Override - public IBlockDefinition quartzPillarSlab() - { - return this.quartzPillarSlab; - } - - @Override - public ITileDefinition grindstone() - { - return this.grindstone; - } - - @Override - public ITileDefinition crank() - { - return this.crank; - } - - @Override - public ITileDefinition inscriber() - { - return this.inscriber; - } - - @Override - public ITileDefinition wirelessAccessPoint() - { - return this.wirelessAccessPoint; - } - - @Override - public ITileDefinition charger() - { - return this.charger; - } - - @Override - public IBlockDefinition tinyTNT() - { - return this.tinyTNT; - } - - @Override - public ITileDefinition securityStation() - { - return this.securityStation; - } - - @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 fluidIface() - { - return this.fluidIface; - } - - @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 IBlockDefinition energyGenerator() - { - return this.energyGenerator; - } +public final class ApiBlocks implements IBlocks { + private final IBlockDefinition quartzOre; + private final IBlockDefinition quartzOreCharged; + private final IBlockDefinition matrixFrame; + private final IBlockDefinition quartzBlock; + private final IBlockDefinition quartzPillar; + private final IBlockDefinition chiseledQuartzBlock; + private final IBlockDefinition quartzGlass; + private final IBlockDefinition quartzVibrantGlass; + private final IBlockDefinition quartzFixture; + private final IBlockDefinition fluixBlock; + private final IBlockDefinition skyStoneBlock; + private final IBlockDefinition smoothSkyStoneBlock; + private final IBlockDefinition skyStoneBrick; + private final IBlockDefinition skyStoneSmallBrick; + private final IBlockDefinition skyStoneChest; + private final IBlockDefinition smoothSkyStoneChest; + private final IBlockDefinition skyCompass; + private final ITileDefinition grindstone; + private final ITileDefinition crank; + private final ITileDefinition inscriber; + private final ITileDefinition wirelessAccessPoint; + private final ITileDefinition charger; + private final IBlockDefinition tinyTNT; + private final ITileDefinition securityStation; + 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 fluidIface; + 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 skyStoneStairs; + private final IBlockDefinition smoothSkyStoneStairs; + private final IBlockDefinition skyStoneBrickStairs; + private final IBlockDefinition skyStoneSmallBrickStairs; + private final IBlockDefinition fluixStairs; + private final IBlockDefinition quartzStairs; + private final IBlockDefinition chiseledQuartzStairs; + private final IBlockDefinition quartzPillarStairs; + + private final IBlockDefinition skyStoneSlab; + private final IBlockDefinition smoothSkyStoneSlab; + private final IBlockDefinition skyStoneBrickSlab; + private final IBlockDefinition skyStoneSmallBrickSlab; + private final IBlockDefinition fluixSlab; + private final IBlockDefinition quartzSlab; + private final IBlockDefinition chiseledQuartzSlab; + private final IBlockDefinition quartzPillarSlab; + + private final IBlockDefinition itemGen; + private final IBlockDefinition chunkLoader; + private final IBlockDefinition phantomNode; + private final IBlockDefinition cubeGenerator; + private final IBlockDefinition energyGenerator; + + private static final Block.Properties QUARTZ_PROPERTIES = defaultProps(Material.ROCK).hardnessAndResistance(3, 5); + + private static final Block.Properties SKYSTONE_PROPERTIES = defaultProps(Material.ROCK).hardnessAndResistance(50, + 150); + + public ApiBlocks(FeatureFactory registry) { + this.quartzOre = registry.block("quartz_ore", () -> new BlockQuartzOre(QUARTZ_PROPERTIES)) + .features(AEFeature.CERTUS_ORE).build(); + this.quartzOreCharged = registry.block("charged_quartz_ore", () -> new BlockChargedQuartzOre(QUARTZ_PROPERTIES)) + .features(AEFeature.CERTUS_ORE, AEFeature.CHARGED_CERTUS_ORE).rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } + }).build(); + this.matrixFrame = registry.block("matrix_frame", BlockMatrixFrame::new).features(AEFeature.SPATIAL_IO).build(); + + FeatureFactory deco = registry.features(AEFeature.DECORATIVE_BLOCKS); + this.quartzBlock = deco.block("quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES)).build(); + this.quartzPillar = deco.block("quartz_pillar", () -> new BlockQuartzPillar(QUARTZ_PROPERTIES)).build(); + this.chiseledQuartzBlock = deco.block("chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES)) + .build(); + + this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS) + .block("quartz_glass", () -> new BlockQuartzGlass(defaultProps(Material.GLASS).notSolid())) + .rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } + }).build(); + this.quartzVibrantGlass = deco + .block("quartz_vibrant_glass", + () -> new BlockQuartzLamp(defaultProps(Material.GLASS).lightValue(15).notSolid())) + .addFeatures(AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS) + .rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } + }).build(); + + this.quartzFixture = registry.block("quartz_fixture", BlockQuartzFixture::new) + .features(AEFeature.DECORATIVE_LIGHTS).rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } + }).build(); + + this.fluixBlock = registry.features(AEFeature.FLUIX) + .block("fluix_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES)).build(); + + this.skyStoneBlock = registry + .features( + AEFeature.SKY_STONE) + .block("sky_stone_block", () -> new BlockSkyStone(SkystoneType.STONE, + defaultProps(Material.ROCK).hardnessAndResistance(50, 150).harvestLevel(3))) + .build(); + + this.smoothSkyStoneBlock = registry.features(AEFeature.SKY_STONE) + .block("smooth_sky_stone_block", () -> new BlockSkyStone(SkystoneType.BLOCK, SKYSTONE_PROPERTIES)) + .build(); + this.skyStoneBrick = deco + .block("sky_stone_brick", () -> new BlockSkyStone(SkystoneType.BRICK, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.skyStoneSmallBrick = deco + .block("sky_stone_small_brick", () -> new BlockSkyStone(SkystoneType.SMALL_BRICK, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + + Block.Properties skyStoneChestProps = defaultProps(Material.ROCK).hardnessAndResistance(50, 150).notSolid(); + + TileEntityDefinition skyChestTile = registry.tileEntity("sky_chest", TileSkyChest.class, TileSkyChest::new) + .rendering(new TileEntityRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(SkyChestTESR::new); + } + }).build(); + this.skyStoneChest = registry + .block("sky_stone_chest", () -> new BlockSkyChest(BlockSkyChest.SkyChestType.STONE, skyStoneChestProps)) + .features(AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS).tileEntity(skyChestTile).build(); + this.smoothSkyStoneChest = registry + .block("smooth_sky_stone_chest", + () -> new BlockSkyChest(BlockSkyChest.SkyChestType.BLOCK, skyStoneChestProps)) + .features(AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS).tileEntity(skyChestTile).build(); + + this.skyCompass = registry.block("sky_compass", () -> new BlockSkyCompass(defaultProps(Material.MISCELLANEOUS))) + .features(AEFeature.METEORITE_COMPASS) + .tileEntity(registry.tileEntity("sky_compass", TileSkyCompass.class, TileSkyCompass::new) + .rendering(new SkyCompassRendering()).build()) + .build(); + this.grindstone = registry + .block("grindstone", () -> new BlockGrinder(defaultProps(Material.ROCK).hardnessAndResistance(3.2f))) + .features(AEFeature.GRIND_STONE) + .tileEntity(registry.tileEntity("grindstone", TileGrinder.class, TileGrinder::new).build()).build(); + this.crank = registry + .block("crank", + () -> new BlockCrank( + defaultProps(Material.WOOD).harvestTool(ToolType.AXE).harvestLevel(0).notSolid())) + .features(AEFeature.GRIND_STONE) + .tileEntity(registry.tileEntity("crank", TileCrank.class, TileCrank::new) + .rendering(new TileEntityRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(CrankTESR::new); + } + }).build()) + .build(); + this.inscriber = registry.block("inscriber", () -> new BlockInscriber(defaultProps(Material.IRON).notSolid())) + .features(AEFeature.INSCRIBER) + .tileEntity(registry.tileEntity("inscriber", TileInscriber.class, TileInscriber::new) + .rendering(new InscriberRendering()).build()) + .build(); + this.wirelessAccessPoint = registry.block("wireless_access_point", BlockWireless::new) + .features(AEFeature.WIRELESS_ACCESS_TERMINAL) + .tileEntity(registry.tileEntity("wireless_access_point", TileWireless.class, TileWireless::new).build()) + .rendering(new WirelessRendering()).build(); + this.charger = registry.block("charger", BlockCharger::new).features(AEFeature.CHARGER) + .tileEntity(registry.tileEntity("charger", TileCharger.class, TileCharger::new) + .rendering(new TileEntityRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(BlockCharger.createTesr()); + } + }).build()) + .build(); + + EntityTinyTNTPrimed.TYPE = registry + .entity("tiny_tnt_primed", EntityTinyTNTPrimed::new, EntityClassification.MISC) + .customize(p -> p.setTrackingRange(16).setUpdateInterval(4).setShouldReceiveVelocityUpdates(true)) + .build(); + + this.tinyTNT = registry + .block("tiny_tnt", + () -> new BlockTinyTNT( + defaultProps(Material.TNT).sound(SoundType.GROUND).hardnessAndResistance(0).notSolid())) + .features(AEFeature.TINY_TNT).bootstrap((block, item) -> (IInitComponent) () -> DispenserBlock + .registerDispenseBehavior(item, new DispenserBehaviorTinyTNT())) + .build(); + this.securityStation = registry.block("security_station", BlockSecurityStation::new) + .features(AEFeature.SECURITY).tileEntity(registry + .tileEntity("security_station", TileSecurityStation.class, TileSecurityStation::new).build()) + .rendering(new SecurityStationRendering()).build(); + + TileEntityDefinition quantumRingTile = registry + .tileEntity("quantum_ring", TileQuantumBridge.class, TileQuantumBridge::new).build(); + this.quantumRing = registry.block("quantum_ring", BlockQuantumRing::new) + .features(AEFeature.QUANTUM_NETWORK_BRIDGE).tileEntity(quantumRingTile) + .rendering(new QuantumBridgeRendering()).build(); + this.quantumLink = registry.block("quantum_link", BlockQuantumLinkChamber::new) + .features(AEFeature.QUANTUM_NETWORK_BRIDGE).tileEntity(quantumRingTile) + .rendering(new QuantumBridgeRendering()).build(); + this.spatialPylon = registry.block("spatial_pylon", BlockSpatialPylon::new).features(AEFeature.SPATIAL_IO) + .tileEntity(registry.tileEntity("spatial_pylon", TileSpatialPylon.class, TileSpatialPylon::new).build()) + .rendering(new SpatialPylonRendering()).build(); + this.spatialIOPort = registry.block("spatial_io_port", BlockSpatialIOPort::new).features(AEFeature.SPATIAL_IO) + .tileEntity( + registry.tileEntity("spatial_io_port", TileSpatialIOPort.class, TileSpatialIOPort::new).build()) + .build(); + this.controller = registry.block("controller", BlockController::new).features(AEFeature.CHANNELS) + .tileEntity(registry.tileEntity("controller", TileController.class, TileController::new).build()) + .rendering(new ControllerRendering()).build(); + this.drive = registry.block("drive", BlockDrive::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_DRIVE) + .tileEntity(registry.tileEntity("drive", TileDrive.class, TileDrive::new) + .rendering(new TileEntityRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(DriveLedTileEntityRenderer::new); + } + }).build()) + .rendering(new DriveRendering()).build(); + this.chest = registry.block("chest", BlockChest::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST) + .tileEntity(registry.tileEntity("chest", TileChest.class, TileChest::new).build()) + .rendering(new ChestRendering()).build(); + this.iface = registry.block("interface", BlockInterface::new).features(AEFeature.INTERFACE) + .tileEntity(registry.tileEntity("interface", TileInterface.class, TileInterface::new).build()).build(); + this.fluidIface = registry.block("fluid_interface", BlockFluidInterface::new) + .features(AEFeature.FLUID_INTERFACE).tileEntity(registry + .tileEntity("fluid_interface", TileFluidInterface.class, TileFluidInterface::new).build()) + .build(); + this.cellWorkbench = registry.block("cell_workbench", BlockCellWorkbench::new).features(AEFeature.STORAGE_CELLS) + .tileEntity( + registry.tileEntity("cell_workbench", TileCellWorkbench.class, TileCellWorkbench::new).build()) + .build(); + this.iOPort = registry.block("io_port", BlockIOPort::new).features(AEFeature.STORAGE_CELLS, AEFeature.IO_PORT) + .tileEntity(registry.tileEntity("io_port", TileIOPort.class, TileIOPort::new).build()).build(); + this.condenser = registry.block("condenser", BlockCondenser::new).features(AEFeature.CONDENSER) + .tileEntity(registry.tileEntity("condenser", TileCondenser.class, TileCondenser::new).build()).build(); + this.energyAcceptor = registry.block("energy_acceptor", BlockEnergyAcceptor::new) + .features(AEFeature.ENERGY_ACCEPTOR).tileEntity(registry + .tileEntity("energy_acceptor", TileEnergyAcceptor.class, TileEnergyAcceptor::new).build()) + .build(); + this.vibrationChamber = registry.block("vibration_chamber", BlockVibrationChamber::new) + .features(AEFeature.POWER_GEN) + .tileEntity(registry + .tileEntity("vibration_chamber", TileVibrationChamber.class, TileVibrationChamber::new).build()) + .build(); + this.quartzGrowthAccelerator = registry.block("quartz_growth_accelerator", BlockQuartzGrowthAccelerator::new) + .tileEntity(registry.tileEntity("quartz_growth_accelerator", TileQuartzGrowthAccelerator.class, + TileQuartzGrowthAccelerator::new).build()) + .features(AEFeature.CRYSTAL_GROWTH_ACCELERATOR).build(); + this.energyCell = registry.block("energy_cell", BlockEnergyCell::new).features(AEFeature.ENERGY_CELLS) + .item(AEBaseBlockItemChargeable::new) + .tileEntity(registry.tileEntity("energy_cell", TileEnergyCell.class, TileEnergyCell::new).build()) + .rendering(new BlockEnergyCellRendering(new ResourceLocation(AppEng.MOD_ID, "energy_cell"))).build(); + this.energyCellDense = registry.block("dense_energy_cell", BlockDenseEnergyCell::new) + .features(AEFeature.ENERGY_CELLS, AEFeature.DENSE_ENERGY_CELLS).item(AEBaseBlockItemChargeable::new) + .tileEntity(registry + .tileEntity("dense_energy_cell", TileDenseEnergyCell.class, TileDenseEnergyCell::new).build()) + .rendering(new BlockEnergyCellRendering(new ResourceLocation(AppEng.MOD_ID, "dense_energy_cell"))) + .build(); + this.energyCellCreative = registry.block("creative_energy_cell", BlockCreativeEnergyCell::new) + .features(AEFeature.CREATIVE) + .tileEntity(registry + .tileEntity("creative_energy_cell", TileCreativeEnergyCell.class, TileCreativeEnergyCell::new) + .build()) + .build(); + + TileEntityDefinition craftingUnit = registry + .tileEntity("crafting_unit", TileCraftingTile.class, TileCraftingTile::new).build(); + + FeatureFactory crafting = registry.features(AEFeature.CRAFTING_CPU); + Block.Properties craftingBlockProps = defaultProps(Material.IRON); + this.craftingUnit = crafting + .block("crafting_unit", () -> new CraftingUnitBlock(craftingBlockProps, CraftingUnitType.UNIT)) + .rendering(new CraftingCubeRendering()).tileEntity(craftingUnit).build(); + this.craftingAccelerator = crafting + .block("crafting_accelerator", + () -> new CraftingUnitBlock(craftingBlockProps, CraftingUnitType.ACCELERATOR)) + .rendering(new CraftingCubeRendering()).tileEntity(craftingUnit).build(); + + TileEntityDefinition craftingStorage = registry + .tileEntity("crafting_storage", TileCraftingStorageTile.class, TileCraftingStorageTile::new).build(); + this.craftingStorage1k = crafting + .block("1k_crafting_storage", + () -> new BlockCraftingStorage(craftingBlockProps, CraftingUnitType.STORAGE_1K)) + .item(ItemCraftingStorage::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering()) + .build(); + this.craftingStorage4k = crafting + .block("4k_crafting_storage", + () -> new BlockCraftingStorage(craftingBlockProps, CraftingUnitType.STORAGE_4K)) + .item(ItemCraftingStorage::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering()) + .build(); + this.craftingStorage16k = crafting + .block("16k_crafting_storage", + () -> new BlockCraftingStorage(craftingBlockProps, CraftingUnitType.STORAGE_16K)) + .item(ItemCraftingStorage::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering()) + .build(); + this.craftingStorage64k = crafting + .block("64k_crafting_storage", + () -> new BlockCraftingStorage(craftingBlockProps, CraftingUnitType.STORAGE_64K)) + .item(ItemCraftingStorage::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering()) + .build(); + this.craftingMonitor = crafting.block("crafting_monitor", () -> new BlockCraftingMonitor(craftingBlockProps)) + .tileEntity(registry + .tileEntity("crafting_monitor", TileCraftingMonitorTile.class, TileCraftingMonitorTile::new) + .rendering(new TileEntityRenderingCustomizer() { + @OnlyIn(Dist.CLIENT) + @Override + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(CraftingMonitorTESR::new); + } + }).build()) + .rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + rendering.modelCustomizer((path, model) -> { + // The formed model handles rotations itself, the unformed one does not + if (model instanceof MonitorBakedModel) { + return model; + } + return new AutoRotatingBakedModel(model); + }); + } + }).build(); + + this.molecularAssembler = registry + .block("molecular_assembler", () -> new BlockMolecularAssembler(defaultProps(Material.IRON).notSolid())) + .features(AEFeature.MOLECULAR_ASSEMBLER).rendering(new BlockRenderingCustomizer() { + @OnlyIn(Dist.CLIENT) + @Override + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + // FIXME: This is an old comment, check if it still applies + /** + * NOTE: This is only used to determine how to render an item being held in + * hand. For determining block rendering, the method below is used + * (canRenderInLayer). + */ + rendering.renderType(RenderType.getCutout()); + rendering.renderType(rt -> rt == RenderType.getCutout() || rt == RenderType.getTranslucent()); + } + }) + .tileEntity(registry + .tileEntity("molecular_assembler", TileMolecularAssembler.class, TileMolecularAssembler::new) + .build()) + .build(); + + this.lightDetector = registry.block("light_detector", BlockLightDetector::new) + .features(AEFeature.LIGHT_DETECTOR) + .tileEntity( + registry.tileEntity("light_detector", TileLightDetector.class, TileLightDetector::new).build()) + .rendering(new BlockRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IBlockRendering rendering, IItemRendering itemRendering) { + rendering.renderType(RenderType.getCutout()); + } + }).build(); + this.paint = registry.block("paint", BlockPaint::new).features(AEFeature.PAINT_BALLS) + .tileEntity(registry.tileEntity("paint", TilePaint.class, TilePaint::new).build()) + .rendering(new PaintRendering()).build(); + + this.skyStoneStairs = deco + .block("sky_stone_stairs", + () -> new StairsBlock(this.skyStoneBlock().block()::getDefaultState, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.smoothSkyStoneStairs = deco + .block("smooth_sky_stone_stairs", + () -> new StairsBlock(this.smoothSkyStoneBlock().block()::getDefaultState, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.skyStoneBrickStairs = deco + .block("sky_stone_brick_stairs", + () -> new StairsBlock(this.skyStoneBrick().block()::getDefaultState, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.skyStoneSmallBrickStairs = deco + .block("sky_stone_small_brick_stairs", + () -> new StairsBlock(this.skyStoneSmallBrick().block()::getDefaultState, SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + + this.fluixStairs = deco + .block("fluix_stairs", + () -> new StairsBlock(this.fluixBlock().block()::getDefaultState, QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.FLUIX).build(); + this.quartzStairs = deco + .block("quartz_stairs", + () -> new StairsBlock(this.quartzBlock().block()::getDefaultState, QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + this.chiseledQuartzStairs = deco + .block("chiseled_quartz_stairs", + () -> new StairsBlock(this.chiseledQuartzBlock().block()::getDefaultState, QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + this.quartzPillarStairs = deco + .block("quartz_pillar_stairs", + () -> new StairsBlock(this.quartzPillar().block()::getDefaultState, QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + + this.multiPart = registry.block("cable_bus", BlockCableBus::new).rendering(new CableBusRendering()) + .tileEntity(registry.tileEntity("cable_bus", TileCableBus.class, TileCableBus::new) + .rendering(new TileEntityRenderingCustomizer() { + @Override + @OnlyIn(Dist.CLIENT) + public void customize(TileEntityRendering rendering) { + rendering.tileEntityRenderer(CableBusTESR::new); + } + }).build()) + .build(); + + this.skyStoneSlab = deco.block("sky_stone_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.smoothSkyStoneSlab = deco.block("smooth_sky_stone_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.skyStoneBrickSlab = deco.block("sky_stone_brick_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + this.skyStoneSmallBrickSlab = deco.block("sky_stone_small_brick_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES)) + .addFeatures(AEFeature.SKY_STONE).build(); + + this.fluixSlab = deco.block("fluix_slab", () -> new SlabBlock(QUARTZ_PROPERTIES)).addFeatures(AEFeature.FLUIX) + .build(); + this.quartzSlab = deco.block("quartz_slab", () -> new SlabBlock(QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + this.chiseledQuartzSlab = deco.block("chiseled_quartz_slab", () -> new SlabBlock(QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + this.quartzPillarSlab = deco.block("quartz_pillar_slab", () -> new SlabBlock(QUARTZ_PROPERTIES)) + .addFeatures(AEFeature.CERTUS).build(); + + this.itemGen = registry.block("debug_item_gen", BlockItemGen::new) + .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE) + .tileEntity(registry.tileEntity("debug_item_gen", TileItemGen.class, TileItemGen::new).build()).build(); + this.chunkLoader = registry.block("debug_chunk_loader", BlockChunkloader::new) + .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE) + .tileEntity( + registry.tileEntity("debug_chunk_loader", TileChunkLoader.class, TileChunkLoader::new).build()) + .build(); + this.phantomNode = registry.block("debug_phantom_node", BlockPhantomNode::new) + .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE) + .tileEntity( + registry.tileEntity("debug_phantom_node", TilePhantomNode.class, TilePhantomNode::new).build()) + .build(); + this.cubeGenerator = registry.block("debug_cube_gen", BlockCubeGenerator::new) + .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE) + .tileEntity( + registry.tileEntity("debug_cube_gen", TileCubeGenerator.class, TileCubeGenerator::new).build()) + .build(); + this.energyGenerator = registry.block("debug_energy_gen", BlockEnergyGenerator::new) + .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE).tileEntity(registry + .tileEntity("debug_energy_gen", TileEnergyGenerator.class, TileEnergyGenerator::new).build()) + .build(); + } + + @Override + public IBlockDefinition quartzOre() { + return this.quartzOre; + } + + @Override + public IBlockDefinition quartzOreCharged() { + return this.quartzOreCharged; + } + + @Override + public IBlockDefinition matrixFrame() { + return this.matrixFrame; + } + + @Override + public IBlockDefinition quartzBlock() { + return this.quartzBlock; + } + + @Override + public IBlockDefinition quartzPillar() { + return this.quartzPillar; + } + + @Override + public IBlockDefinition chiseledQuartzBlock() { + return this.chiseledQuartzBlock; + } + + @Override + public IBlockDefinition quartzGlass() { + return this.quartzGlass; + } + + @Override + public IBlockDefinition quartzVibrantGlass() { + return this.quartzVibrantGlass; + } + + @Override + public IBlockDefinition quartzFixture() { + return this.quartzFixture; + } + + @Override + public IBlockDefinition fluixBlock() { + return this.fluixBlock; + } + + @Override + public IBlockDefinition skyStoneBlock() { + return this.skyStoneBlock; + } + + @Override + public IBlockDefinition smoothSkyStoneBlock() { + return this.smoothSkyStoneBlock; + } + + @Override + public IBlockDefinition skyStoneBrick() { + return this.skyStoneBrick; + } + + @Override + public IBlockDefinition skyStoneSmallBrick() { + return this.skyStoneSmallBrick; + } + + @Override + public IBlockDefinition skyStoneChest() { + return this.skyStoneChest; + } + + @Override + public IBlockDefinition smoothSkyStoneChest() { + return this.smoothSkyStoneChest; + } + + @Override + public IBlockDefinition skyCompass() { + return this.skyCompass; + } + + @Override + public IBlockDefinition skyStoneStairs() { + return this.skyStoneStairs; + } + + @Override + public IBlockDefinition smoothSkyStoneStairs() { + return this.smoothSkyStoneStairs; + } + + @Override + public IBlockDefinition skyStoneBrickStairs() { + return this.skyStoneBrickStairs; + } + + @Override + public IBlockDefinition skyStoneSmallBrickStairs() { + return this.skyStoneSmallBrickStairs; + } + + @Override + public IBlockDefinition fluixStairs() { + return this.fluixStairs; + } + + @Override + public IBlockDefinition quartzStairs() { + return this.quartzStairs; + } + + @Override + public IBlockDefinition chiseledQuartzStairs() { + return this.chiseledQuartzStairs; + } + + @Override + public IBlockDefinition quartzPillarStairs() { + return this.quartzPillarStairs; + } + + @Override + public IBlockDefinition skyStoneSlab() { + return this.skyStoneSlab; + } + + @Override + public IBlockDefinition smoothSkyStoneSlab() { + return this.smoothSkyStoneSlab; + } + + @Override + public IBlockDefinition skyStoneBrickSlab() { + return this.skyStoneBrickSlab; + } + + @Override + public IBlockDefinition skyStoneSmallBrickSlab() { + return this.skyStoneSmallBrickSlab; + } + + @Override + public IBlockDefinition fluixSlab() { + return this.fluixSlab; + } + + @Override + public IBlockDefinition quartzSlab() { + return this.quartzSlab; + } + + @Override + public IBlockDefinition chiseledQuartzSlab() { + return this.chiseledQuartzSlab; + } + + @Override + public IBlockDefinition quartzPillarSlab() { + return this.quartzPillarSlab; + } + + @Override + public ITileDefinition grindstone() { + return this.grindstone; + } + + @Override + public ITileDefinition crank() { + return this.crank; + } + + @Override + public ITileDefinition inscriber() { + return this.inscriber; + } + + @Override + public ITileDefinition wirelessAccessPoint() { + return this.wirelessAccessPoint; + } + + @Override + public ITileDefinition charger() { + return this.charger; + } + + @Override + public IBlockDefinition tinyTNT() { + return this.tinyTNT; + } + + @Override + public ITileDefinition securityStation() { + return this.securityStation; + } + + @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 fluidIface() { + return this.fluidIface; + } + + @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 IBlockDefinition energyGenerator() { + return this.energyGenerator; + } } diff --git a/src/main/java/appeng/core/api/definitions/ApiItems.java b/src/main/java/appeng/core/api/definitions/ApiItems.java index f95944d21..c6b8e3d0a 100644 --- a/src/main/java/appeng/core/api/definitions/ApiItems.java +++ b/src/main/java/appeng/core/api/definitions/ApiItems.java @@ -18,13 +18,19 @@ package appeng.core.api.definitions; +import java.util.function.Consumer; + +import net.minecraft.entity.EntityClassification; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraftforge.common.ToolType; import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItems; +import appeng.api.features.AEFeature; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; import appeng.bootstrap.FeatureFactory; -import appeng.api.features.AEFeature; import appeng.core.CreativeTabFacade; import appeng.core.features.ActivityState; import appeng.core.features.ColoredItemDefinition; @@ -47,556 +53,494 @@ import appeng.items.storage.ItemViewCell; import appeng.items.tools.*; import appeng.items.tools.powered.*; import appeng.items.tools.quartz.*; -import net.minecraft.entity.EntityClassification; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraftforge.common.ToolType; - -import java.util.function.Consumer; - /** * 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; +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 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 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 cellCreative; + private final IItemDefinition viewCell; - private final IItemDefinition cell1k; - private final IItemDefinition cell4k; - private final IItemDefinition cell16k; - private final IItemDefinition cell64k; + private final IItemDefinition cell1k; + private final IItemDefinition cell4k; + private final IItemDefinition cell16k; + private final IItemDefinition cell64k; - private final IItemDefinition fluidCell1k; - private final IItemDefinition fluidCell4k; - private final IItemDefinition fluidCell16k; - private final IItemDefinition fluidCell64k; + private final IItemDefinition fluidCell1k; + private final IItemDefinition fluidCell4k; + private final IItemDefinition fluidCell16k; + private final IItemDefinition fluidCell64k; - private final IItemDefinition spatialCell2; - private final IItemDefinition spatialCell16; - private final IItemDefinition spatialCell128; + private final IItemDefinition spatialCell2; + private final IItemDefinition spatialCell16; + private final IItemDefinition spatialCell128; - private final IItemDefinition facade; - private final IItemDefinition certusCrystalSeed; - private final IItemDefinition fluixCrystalSeed; - private final IItemDefinition netherQuartzSeed; + private final IItemDefinition facade; + private final IItemDefinition certusCrystalSeed; + private final IItemDefinition fluixCrystalSeed; + private final IItemDefinition netherQuartzSeed; - // rv1 - private final IItemDefinition encodedPattern; - private final IItemDefinition colorApplicator; + // rv1 + private final IItemDefinition encodedPattern; + private final IItemDefinition colorApplicator; - private final AEColoredItemDefinition coloredPaintBall; - private final AEColoredItemDefinition coloredLumenPaintBall; + 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; + // unsupported dev tools + private final IItemDefinition toolEraser; + private final IItemDefinition toolMeteoritePlacer; + private final IItemDefinition toolDebugCard; + private final IItemDefinition toolReplicatorCard; - private final IItemDefinition dummyFluidItem; + private final IItemDefinition dummyFluidItem; - public ApiItems(FeatureFactory registry, ApiMaterials materials) - { - FeatureFactory certusTools = registry.features( AEFeature.CERTUS_QUARTZ_TOOLS ); - this.certusQuartzAxe = certusTools.item( "certus_quartz_axe", props -> new ToolQuartzAxe( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_AXE ) - .build(); - this.certusQuartzHoe = certusTools.item( "certus_quartz_hoe", props -> new ToolQuartzHoe( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_HOE ) - .build(); - this.certusQuartzShovel = certusTools.item( "certus_quartz_shovel", props -> new ToolQuartzSpade( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_SPADE ) - .build(); - this.certusQuartzPick = certusTools.item( "certus_quartz_pickaxe", props -> new ToolQuartzPickaxe( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_PICKAXE ) - .build(); - this.certusQuartzSword = certusTools.item( "certus_quartz_sword", props -> new ToolQuartzSword( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.COMBAT) - .addFeatures( AEFeature.QUARTZ_SWORD ) - .build(); - this.certusQuartzWrench = certusTools.item( "certus_quartz_wrench", ToolQuartzWrench::new ) - .itemGroup(ItemGroup.TOOLS) - .props(props -> props.maxStackSize( 1 ) ) - .addFeatures( AEFeature.QUARTZ_WRENCH ) + public ApiItems(FeatureFactory registry, ApiMaterials materials) { + FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS); + this.certusQuartzAxe = certusTools + .item("certus_quartz_axe", props -> new ToolQuartzAxe(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); + this.certusQuartzHoe = certusTools + .item("certus_quartz_hoe", props -> new ToolQuartzHoe(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); + this.certusQuartzShovel = certusTools + .item("certus_quartz_shovel", props -> new ToolQuartzSpade(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); + this.certusQuartzPick = certusTools + .item("certus_quartz_pickaxe", props -> new ToolQuartzPickaxe(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); + this.certusQuartzSword = certusTools + .item("certus_quartz_sword", props -> new ToolQuartzSword(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); + this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", ToolQuartzWrench::new) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH) // FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) ) - .build(); - this.certusQuartzKnife = certusTools.item( "certus_quartz_cutting_knife", props -> new ToolQuartzCuttingKnife( props, AEFeature.CERTUS_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) - .addFeatures( AEFeature.QUARTZ_KNIFE ) + .build(); + this.certusQuartzKnife = certusTools + .item("certus_quartz_cutting_knife", + props -> new ToolQuartzCuttingKnife(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) + .addFeatures(AEFeature.QUARTZ_KNIFE) // FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) ) - .build(); + .build(); - FeatureFactory netherTools = registry.features( AEFeature.NETHER_QUARTZ_TOOLS ); - this.netherQuartzAxe = netherTools.item( "nether_quartz_axe", props -> new ToolQuartzAxe( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_AXE ) - .build(); - this.netherQuartzHoe = netherTools.item( "nether_quartz_hoe", props -> new ToolQuartzHoe( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_HOE ) - .build(); - this.netherQuartzShovel = netherTools.item( "nether_quartz_shovel", props -> new ToolQuartzSpade( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_SPADE ) - .build(); - this.netherQuartzPick = netherTools.item( "nether_quartz_pickaxe", props -> new ToolQuartzPickaxe( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .addFeatures( AEFeature.QUARTZ_PICKAXE ) - .build(); - this.netherQuartzSword = netherTools.item( "nether_quartz_sword", props -> new ToolQuartzSword( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.COMBAT) - .addFeatures( AEFeature.QUARTZ_SWORD ) - .build(); - this.netherQuartzWrench = netherTools.item( "nether_quartz_wrench", ToolQuartzWrench::new ) - .itemGroup(ItemGroup.TOOLS) - .props(props -> props.maxStackSize( 1 ) ) - .addFeatures( AEFeature.QUARTZ_WRENCH ) + FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS); + this.netherQuartzAxe = netherTools + .item("nether_quartz_axe", props -> new ToolQuartzAxe(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); + this.netherQuartzHoe = netherTools + .item("nether_quartz_hoe", props -> new ToolQuartzHoe(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); + this.netherQuartzShovel = netherTools + .item("nether_quartz_shovel", props -> new ToolQuartzSpade(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); + this.netherQuartzPick = netherTools + .item("nether_quartz_pickaxe", props -> new ToolQuartzPickaxe(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); + this.netherQuartzSword = netherTools + .item("nether_quartz_sword", props -> new ToolQuartzSword(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); + this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", ToolQuartzWrench::new) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH) // FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) ) - .build(); - this.netherQuartzKnife = netherTools.item( "nether_quartz_cutting_knife", props -> new ToolQuartzCuttingKnife( props, AEFeature.NETHER_QUARTZ_TOOLS ) ) - .itemGroup(ItemGroup.TOOLS) - .props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) - .addFeatures( AEFeature.QUARTZ_KNIFE ) + .build(); + this.netherQuartzKnife = netherTools + .item("nether_quartz_cutting_knife", + props -> new ToolQuartzCuttingKnife(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) + .addFeatures(AEFeature.QUARTZ_KNIFE) // FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) ) - .build(); - - Consumer chargedDefaults = props -> props.maxStackSize( 1 ).maxDamage( 32 ).setNoRepair(); - - FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS ); - this.entropyManipulator = powerTools.item( "entropy_manipulator", ToolEntropyManipulator::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.ENTROPY_MANIPULATOR ) - .dispenserBehavior( DispenserBlockTool::new ) - .build(); - this.wirelessTerminal = powerTools.item( "wireless_terminal", ToolWirelessTerminal::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.WIRELESS_ACCESS_TERMINAL ) - .build(); - this.chargedStaff = powerTools.item( "charged_staff", ToolChargedStaff::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.CHARGED_STAFF ) - .build(); - this.massCannon = powerTools.item( "matter_cannon", ToolMatterCannon::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.MATTER_CANNON ) - .dispenserBehavior( DispenserMatterCannon::new ) - .build(); - this.portableCell = powerTools.item( "portable_cell", ToolPortableCell::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS ) - .build(); - this.colorApplicator = powerTools.item( "color_applicator", ToolColorApplicator::new ) - .props(chargedDefaults) - .addFeatures( AEFeature.COLOR_APPLICATOR ) - .dispenserBehavior( DispenserBlockTool::new ) - .rendering( new ToolColorApplicatorRendering() ) - .build(); - - this.biometricCard = registry.item( "biometric_card", ToolBiometricCard::new ) - .props(props -> props.maxStackSize( 1 )) - .features( AEFeature.SECURITY ) - .build(); - this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new ) - .props(props -> props.maxStackSize( 1 )) - .features( AEFeature.MEMORY_CARD ) - .build(); - this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ) - .props(props -> props.maxStackSize( 1 ).addToolType( ToolType.get("wrench"), 0 ) ) - .features( AEFeature.NETWORK_TOOL ) - .build(); - - this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new ) - .props(props -> props.maxStackSize(1)) - .features( AEFeature.STORAGE_CELLS, AEFeature.CREATIVE ) - .build(); - this.viewCell = registry.item( "view_cell", ItemViewCell::new ) - .props(props -> props.maxStackSize(1)) - .features( AEFeature.VIEW_CELL ) - .build(); - - Consumer storageCellProps = p -> p.maxStackSize(1); - - FeatureFactory storageCells = registry.features( AEFeature.STORAGE_CELLS ); - this.cell1k = storageCells.item( "1k_storage_cell", props -> new BasicItemStorageCell(props, MaterialType.ITEM_1K_CELL_COMPONENT, 1 ) ).props(storageCellProps).build(); - this.cell4k = storageCells.item( "4k_storage_cell", props -> new BasicItemStorageCell(props, MaterialType.ITEM_4K_CELL_COMPONENT, 4 ) ).props(storageCellProps).build(); - this.cell16k = storageCells.item( "16k_storage_cell", props -> new BasicItemStorageCell(props, MaterialType.ITEM_16K_CELL_COMPONENT, 16 ) ).props(storageCellProps).build(); - this.cell64k = storageCells.item( "64k_storage_cell", props -> new BasicItemStorageCell(props, MaterialType.ITEM_64K_CELL_COMPONENT, 64 ) ).props(storageCellProps).build(); - - this.fluidCell1k = storageCells.item( "1k_fluid_storage_cell", props -> new BasicFluidStorageCell(props, MaterialType.FLUID_1K_CELL_COMPONENT, 1 ) ).props(storageCellProps).build(); - this.fluidCell4k = storageCells.item( "4k_fluid_storage_cell", props -> new BasicFluidStorageCell(props, MaterialType.FLUID_4K_CELL_COMPONENT, 4 ) ).props(storageCellProps).build(); - this.fluidCell16k = storageCells.item( "16k_fluid_storage_cell", props -> new BasicFluidStorageCell(props, MaterialType.FLUID_16K_CELL_COMPONENT, 16 ) ).props(storageCellProps).build(); - this.fluidCell64k = storageCells.item( "64k_fluid_storage_cell", props -> new BasicFluidStorageCell(props, MaterialType.FLUID_64K_CELL_COMPONENT, 64 ) ).props(storageCellProps).build(); - - FeatureFactory spatialCells = registry.features( AEFeature.SPATIAL_IO ); - this.spatialCell2 = spatialCells.item( "2_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 2 ) ).props(storageCellProps).build(); - this.spatialCell16 = spatialCells.item( "16_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 16 ) ).props(storageCellProps).build(); - this.spatialCell128 = spatialCells.item( "128_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 128 ) ).props(storageCellProps).build(); - - this.facade = registry.item( "facade", ItemFacade::new ) - .features( AEFeature.FACADES ) - .itemGroup( CreativeTabFacade.instance ) - .rendering( new FacadeRendering() ) - .build(); - - this.certusCrystalSeed = registry.item( "certus_crystal_seed", props -> new ItemCrystalSeed(props, materials.purifiedCertusQuartzCrystal().item()) ) - .features( AEFeature.CRYSTAL_SEEDS ) - .build(); - this.fluixCrystalSeed = registry.item( "fluix_crystal_seed", props -> new ItemCrystalSeed(props, materials.purifiedFluixCrystal().item()) ) - .features( AEFeature.CRYSTAL_SEEDS ) - .build(); - this.netherQuartzSeed = registry.item( "nether_quartz_seed", props -> new ItemCrystalSeed(props, materials.purifiedNetherQuartzCrystal().item()) ) - .features( AEFeature.CRYSTAL_SEEDS ) - .build(); - - EntityGrowingCrystal.TYPE = registry.entity("growing_crystal", EntityGrowingCrystal::new, EntityClassification.MISC) - .customize(builder -> builder.size(0.25F, 0.25F)) - .build(); - - // rv1 - this.encodedPattern = registry.item( "encoded_pattern", ItemEncodedPattern::new ) - .props(props -> props.maxStackSize(1)) - .features( AEFeature.PATTERNS ) - .build(); - - this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false); - this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true); - - FeatureFactory debugTools = registry.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE ); - this.toolEraser = debugTools.item( "debug_eraser", ToolEraser::new ).build(); - this.toolMeteoritePlacer = debugTools.item( "debug_meteorite_placer", ToolMeteoritePlacer::new ).build(); - this.toolDebugCard = debugTools.item( "debug_card", ToolDebugCard::new ).build(); - this.toolReplicatorCard = debugTools.item( "debug_replicator_card", ToolReplicatorCard::new ).build(); - debugTools.item( "debug_part_placer", ToolDebugPartPlacer::new ).build(); - - this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build(); - } - - private static AEColoredItemDefinition createPaintBalls(FeatureFactory registry, String idSuffix, boolean lumen) { - ColoredItemDefinition colors = new ColoredItemDefinition(); - for (AEColor color : AEColor.values()) { - if (color == AEColor.TRANSPARENT) { - continue; // Fluix paintballs don't exist - } - - String id = color.registryPrefix + idSuffix; - IItemDefinition paintBall = registry.item(id, props -> new ItemPaintBall(props, color, lumen)) - .features(AEFeature.PAINT_BALLS) - .rendering(new ItemPaintBallRendering(color, lumen)) - .build(); - colors.add(color, new ItemStackSrc(paintBall.item(), ActivityState.Enabled)); - } - return colors; - } - - @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.chargedStaff; - } - - @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 fluidCell1k() - { - return this.fluidCell1k; - } - - @Override - public IItemDefinition fluidCell4k() - { - return this.fluidCell4k; - } - - @Override - public IItemDefinition fluidCell16k() - { - return this.fluidCell16k; - } - - @Override - public IItemDefinition fluidCell64k() - { - return this.fluidCell64k; - } - - @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 certusCrystalSeed() { - return certusCrystalSeed; - } - - @Override - public IItemDefinition fluixCrystalSeed() { - return fluixCrystalSeed; - } - - @Override - public IItemDefinition netherQuartzSeed() { - return netherQuartzSeed; - } - - @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 toolEraser() - { - return this.toolEraser; - } - - public IItemDefinition toolMeteoritePlacer() - { - return this.toolMeteoritePlacer; - } - - public IItemDefinition toolDebugCard() - { - return this.toolDebugCard; - } - - public IItemDefinition toolReplicatorCard() - { - return this.toolReplicatorCard; - } - - public IItemDefinition dummyFluidItem() - { - return this.dummyFluidItem; - } + .build(); + + Consumer chargedDefaults = props -> props.maxStackSize(1).maxDamage(32).setNoRepair(); + + FeatureFactory powerTools = registry.features(AEFeature.POWERED_TOOLS); + this.entropyManipulator = powerTools.item("entropy_manipulator", ToolEntropyManipulator::new) + .props(chargedDefaults).addFeatures(AEFeature.ENTROPY_MANIPULATOR) + .dispenserBehavior(DispenserBlockTool::new).build(); + this.wirelessTerminal = powerTools.item("wireless_terminal", ToolWirelessTerminal::new).props(chargedDefaults) + .addFeatures(AEFeature.WIRELESS_ACCESS_TERMINAL).build(); + this.chargedStaff = powerTools.item("charged_staff", ToolChargedStaff::new).props(chargedDefaults) + .addFeatures(AEFeature.CHARGED_STAFF).build(); + this.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new).props(chargedDefaults) + .addFeatures(AEFeature.MATTER_CANNON).dispenserBehavior(DispenserMatterCannon::new).build(); + this.portableCell = powerTools.item("portable_cell", ToolPortableCell::new).props(chargedDefaults) + .addFeatures(AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS).build(); + this.colorApplicator = powerTools.item("color_applicator", ToolColorApplicator::new).props(chargedDefaults) + .addFeatures(AEFeature.COLOR_APPLICATOR).dispenserBehavior(DispenserBlockTool::new) + .rendering(new ToolColorApplicatorRendering()).build(); + + this.biometricCard = registry.item("biometric_card", ToolBiometricCard::new) + .props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build(); + this.memoryCard = registry.item("memory_card", ToolMemoryCard::new).props(props -> props.maxStackSize(1)) + .features(AEFeature.MEMORY_CARD).build(); + this.networkTool = registry.item("network_tool", ToolNetworkTool::new) + .props(props -> props.maxStackSize(1).addToolType(ToolType.get("wrench"), 0)) + .features(AEFeature.NETWORK_TOOL).build(); + + this.cellCreative = registry.item("creative_storage_cell", ItemCreativeStorageCell::new) + .props(props -> props.maxStackSize(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build(); + this.viewCell = registry.item("view_cell", ItemViewCell::new).props(props -> props.maxStackSize(1)) + .features(AEFeature.VIEW_CELL).build(); + + Consumer storageCellProps = p -> p.maxStackSize(1); + + FeatureFactory storageCells = registry.features(AEFeature.STORAGE_CELLS); + this.cell1k = storageCells + .item("1k_storage_cell", + props -> new BasicItemStorageCell(props, MaterialType.ITEM_1K_CELL_COMPONENT, 1)) + .props(storageCellProps).build(); + this.cell4k = storageCells + .item("4k_storage_cell", + props -> new BasicItemStorageCell(props, MaterialType.ITEM_4K_CELL_COMPONENT, 4)) + .props(storageCellProps).build(); + this.cell16k = storageCells + .item("16k_storage_cell", + props -> new BasicItemStorageCell(props, MaterialType.ITEM_16K_CELL_COMPONENT, 16)) + .props(storageCellProps).build(); + this.cell64k = storageCells + .item("64k_storage_cell", + props -> new BasicItemStorageCell(props, MaterialType.ITEM_64K_CELL_COMPONENT, 64)) + .props(storageCellProps).build(); + + this.fluidCell1k = storageCells + .item("1k_fluid_storage_cell", + props -> new BasicFluidStorageCell(props, MaterialType.FLUID_1K_CELL_COMPONENT, 1)) + .props(storageCellProps).build(); + this.fluidCell4k = storageCells + .item("4k_fluid_storage_cell", + props -> new BasicFluidStorageCell(props, MaterialType.FLUID_4K_CELL_COMPONENT, 4)) + .props(storageCellProps).build(); + this.fluidCell16k = storageCells + .item("16k_fluid_storage_cell", + props -> new BasicFluidStorageCell(props, MaterialType.FLUID_16K_CELL_COMPONENT, 16)) + .props(storageCellProps).build(); + this.fluidCell64k = storageCells + .item("64k_fluid_storage_cell", + props -> new BasicFluidStorageCell(props, MaterialType.FLUID_64K_CELL_COMPONENT, 64)) + .props(storageCellProps).build(); + + FeatureFactory spatialCells = registry.features(AEFeature.SPATIAL_IO); + this.spatialCell2 = spatialCells + .item("2_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 2)) + .props(storageCellProps).build(); + this.spatialCell16 = spatialCells + .item("16_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 16)) + .props(storageCellProps).build(); + this.spatialCell128 = spatialCells + .item("128_cubed_spatial_storage_cell", props -> new ItemSpatialStorageCell(props, 128)) + .props(storageCellProps).build(); + + this.facade = registry.item("facade", ItemFacade::new).features(AEFeature.FACADES) + .itemGroup(CreativeTabFacade.instance).rendering(new FacadeRendering()).build(); + + this.certusCrystalSeed = registry + .item("certus_crystal_seed", + props -> new ItemCrystalSeed(props, materials.purifiedCertusQuartzCrystal().item())) + .features(AEFeature.CRYSTAL_SEEDS).build(); + this.fluixCrystalSeed = registry + .item("fluix_crystal_seed", + props -> new ItemCrystalSeed(props, materials.purifiedFluixCrystal().item())) + .features(AEFeature.CRYSTAL_SEEDS).build(); + this.netherQuartzSeed = registry + .item("nether_quartz_seed", + props -> new ItemCrystalSeed(props, materials.purifiedNetherQuartzCrystal().item())) + .features(AEFeature.CRYSTAL_SEEDS).build(); + + EntityGrowingCrystal.TYPE = registry + .entity("growing_crystal", EntityGrowingCrystal::new, EntityClassification.MISC) + .customize(builder -> builder.size(0.25F, 0.25F)).build(); + + // rv1 + this.encodedPattern = registry.item("encoded_pattern", ItemEncodedPattern::new) + .props(props -> props.maxStackSize(1)).features(AEFeature.PATTERNS).build(); + + this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false); + this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true); + + FeatureFactory debugTools = registry.features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE); + this.toolEraser = debugTools.item("debug_eraser", ToolEraser::new).build(); + this.toolMeteoritePlacer = debugTools.item("debug_meteorite_placer", ToolMeteoritePlacer::new).build(); + this.toolDebugCard = debugTools.item("debug_card", ToolDebugCard::new).build(); + this.toolReplicatorCard = debugTools.item("debug_replicator_card", ToolReplicatorCard::new).build(); + debugTools.item("debug_part_placer", ToolDebugPartPlacer::new).build(); + + this.dummyFluidItem = registry.item("dummy_fluid_item", FluidDummyItem::new) + .rendering(new FluidDummyItemRendering()).build(); + } + + private static AEColoredItemDefinition createPaintBalls(FeatureFactory registry, String idSuffix, boolean lumen) { + ColoredItemDefinition colors = new ColoredItemDefinition(); + for (AEColor color : AEColor.values()) { + if (color == AEColor.TRANSPARENT) { + continue; // Fluix paintballs don't exist + } + + String id = color.registryPrefix + idSuffix; + IItemDefinition paintBall = registry.item(id, props -> new ItemPaintBall(props, color, lumen)) + .features(AEFeature.PAINT_BALLS).rendering(new ItemPaintBallRendering(color, lumen)).build(); + colors.add(color, new ItemStackSrc(paintBall.item(), ActivityState.Enabled)); + } + return colors; + } + + @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.chargedStaff; + } + + @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 fluidCell1k() { + return this.fluidCell1k; + } + + @Override + public IItemDefinition fluidCell4k() { + return this.fluidCell4k; + } + + @Override + public IItemDefinition fluidCell16k() { + return this.fluidCell16k; + } + + @Override + public IItemDefinition fluidCell64k() { + return this.fluidCell64k; + } + + @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 certusCrystalSeed() { + return certusCrystalSeed; + } + + @Override + public IItemDefinition fluixCrystalSeed() { + return fluixCrystalSeed; + } + + @Override + public IItemDefinition netherQuartzSeed() { + return netherQuartzSeed; + } + + @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 toolEraser() { + return this.toolEraser; + } + + public IItemDefinition toolMeteoritePlacer() { + return this.toolMeteoritePlacer; + } + + public IItemDefinition toolDebugCard() { + return this.toolDebugCard; + } + + public IItemDefinition toolReplicatorCard() { + return this.toolReplicatorCard; + } + + public IItemDefinition dummyFluidItem() { + return this.dummyFluidItem; + } } diff --git a/src/main/java/appeng/core/api/definitions/ApiMaterials.java b/src/main/java/appeng/core/api/definitions/ApiMaterials.java index c846006d3..805ef05d6 100644 --- a/src/main/java/appeng/core/api/definitions/ApiMaterials.java +++ b/src/main/java/appeng/core/api/definitions/ApiMaterials.java @@ -18,6 +18,9 @@ package appeng.core.api.definitions; +import com.google.common.base.Preconditions; + +import net.minecraft.entity.EntityClassification; import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IMaterials; @@ -29,524 +32,463 @@ import appeng.entity.EntityChargedQuartz; import appeng.entity.EntitySingularity; import appeng.items.materials.ItemMaterial; import appeng.items.materials.MaterialType; -import com.google.common.base.Preconditions; -import net.minecraft.entity.EntityClassification; - /** * 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 certusQuartzCrystal; - private final IItemDefinition certusQuartzCrystalCharged; - private final IItemDefinition fluixCrystal; - private final IItemDefinition fluixPearl; - - private final IItemDefinition woodenGear; - - private final IItemDefinition wirelessReceiver; - private final IItemDefinition wirelessBooster; - - private final IItemDefinition annihilationCore; - private final IItemDefinition formationCore; - - private final IItemDefinition singularity; - private final IItemDefinition qESingularity; - private final IItemDefinition blankPattern; - - private final IItemDefinition fluidCell1kPart; - private final IItemDefinition fluidCell4kPart; - private final IItemDefinition fluidCell16kPart; - private final IItemDefinition fluidCell64kPart; - - private final FeatureFactory registry; - - public ApiMaterials( FeatureFactory registry ) - { - this.registry = registry; - - EntitySingularity.TYPE = registry.entity("singularity", EntitySingularity::new, EntityClassification.MISC) - .customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4).setShouldReceiveVelocityUpdates(true)) - .build(); - - EntityChargedQuartz.TYPE = registry.entity("charged_quartz", EntityChargedQuartz::new, EntityClassification.MISC) - .customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4).setShouldReceiveVelocityUpdates(true)) - .build(); - - this.cell2SpatialPart = createMaterial(MaterialType.SPATIAL_2_CELL_COMPONENT ); - this.cell16SpatialPart = createMaterial(MaterialType.SPATIAL_16_CELL_COMPONENT ); - this.cell128SpatialPart = createMaterial(MaterialType.SPATIAL_128_CELL_COMPONENT ); - this.silicon = createMaterial(MaterialType.SILICON ); - this.skyDust = createMaterial(MaterialType.SKY_DUST ); - this.calcProcessorPress = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRESS ); - this.engProcessorPress = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRESS ); - this.logicProcessorPress = createMaterial(MaterialType.LOGIC_PROCESSOR_PRESS ); - this.siliconPress = createMaterial(MaterialType.SILICON_PRESS ); - this.namePress = createMaterial(MaterialType.NAME_PRESS ); - this.calcProcessorPrint = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRINT ); - this.engProcessorPrint = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRINT ); - this.logicProcessorPrint = createMaterial(MaterialType.LOGIC_PROCESSOR_PRINT ); - this.siliconPrint = createMaterial(MaterialType.SILICON_PRINT ); - this.logicProcessor = createMaterial(MaterialType.LOGIC_PROCESSOR ); - this.calcProcessor = createMaterial(MaterialType.CALCULATION_PROCESSOR ); - this.engProcessor = createMaterial(MaterialType.ENGINEERING_PROCESSOR ); - this.basicCard = createMaterial(MaterialType.BASIC_CARD ); - this.advCard = createMaterial(MaterialType.ADVANCED_CARD ); - this.purifiedCertusQuartzCrystal = createMaterial(MaterialType.PURIFIED_CERTUS_QUARTZ_CRYSTAL ); - this.purifiedNetherQuartzCrystal = createMaterial(MaterialType.PURIFIED_NETHER_QUARTZ_CRYSTAL ); - this.purifiedFluixCrystal = createMaterial(MaterialType.PURIFIED_FLUIX_CRYSTAL ); - this.cell1kPart = createMaterial(MaterialType.ITEM_1K_CELL_COMPONENT ); - this.cell4kPart = createMaterial(MaterialType.ITEM_4K_CELL_COMPONENT ); - this.cell16kPart = createMaterial(MaterialType.ITEM_16K_CELL_COMPONENT ); - this.cell64kPart = createMaterial(MaterialType.ITEM_64K_CELL_COMPONENT ); - this.emptyStorageCell = createMaterial(MaterialType.EMPTY_STORAGE_CELL ); - this.cardRedstone = createMaterial(MaterialType.CARD_REDSTONE ); - this.cardSpeed = createMaterial(MaterialType.CARD_SPEED ); - this.cardCapacity = createMaterial(MaterialType.CARD_CAPACITY ); - this.cardFuzzy = createMaterial(MaterialType.CARD_FUZZY ); - this.cardInverter = createMaterial(MaterialType.CARD_INVERTER ); - this.cardCrafting = createMaterial(MaterialType.CARD_CRAFTING ); - this.enderDust = createMaterial(MaterialType.ENDER_DUST ); - this.flour = createMaterial(MaterialType.FLOUR ); - this.goldDust = createMaterial(MaterialType.GOLD_DUST ); - this.ironDust = createMaterial(MaterialType.IRON_DUST ); - this.fluixDust = createMaterial(MaterialType.FLUIX_DUST ); - this.certusQuartzDust = createMaterial(MaterialType.CERTUS_QUARTZ_DUST ); - this.netherQuartzDust = createMaterial(MaterialType.NETHER_QUARTZ_DUST ); - this.matterBall = createMaterial(MaterialType.MATTER_BALL ); - this.certusQuartzCrystal = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL ); - this.certusQuartzCrystalCharged = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL_CHARGED ); - this.fluixCrystal = createMaterial(MaterialType.FLUIX_CRYSTAL ); - this.fluixPearl = createMaterial(MaterialType.FLUIX_PEARL ); - this.woodenGear = createMaterial(MaterialType.WOODEN_GEAR ); - this.wirelessReceiver = createMaterial(MaterialType.WIRELESS_RECEIVER); - this.wirelessBooster = createMaterial(MaterialType.WIRELESS_BOOSTER ); - this.annihilationCore = createMaterial(MaterialType.ANNIHILATION_CORE ); - this.formationCore = createMaterial(MaterialType.FORMATION_CORE ); - this.singularity = createMaterial(MaterialType.SINGULARITY ); - this.qESingularity = createMaterial(MaterialType.QUANTUM_ENTANGLED_SINGULARITY ); - this.blankPattern = createMaterial(MaterialType.BLANK_PATTERN ); - this.fluidCell1kPart = createMaterial(MaterialType.FLUID_1K_CELL_COMPONENT ); - this.fluidCell4kPart = createMaterial(MaterialType.FLUID_4K_CELL_COMPONENT ); - this.fluidCell16kPart = createMaterial(MaterialType.FLUID_16K_CELL_COMPONENT ); - this.fluidCell64kPart = createMaterial(MaterialType.FLUID_64K_CELL_COMPONENT ); - } - - private IItemDefinition createMaterial(final MaterialType mat) - { - Preconditions.checkState( !mat.isRegistered(), "Cannot create the same material twice." ); - - IItemDefinition def = registry.item(mat.getId(), props -> new ItemMaterial(props, mat)) - .features(mat.getFeature().toArray(new AEFeature[0])) - .build(); - - boolean enabled = true; - - for( final AEFeature f : mat.getFeature() ) - { - enabled = enabled && AEConfig.instance().isFeatureEnabled( f ); - } - - mat.setStackSrc( new MaterialStackSrc( mat, enabled ) ); - mat.setItemInstance( def.item() ); - mat.markReady(); - return def; - } - - @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 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 wirelessReceiver() - { - return this.wirelessReceiver; - } - - @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; - } - - @Override - public IItemDefinition fluidCell1kPart() - { - return this.fluidCell1kPart; - } - - @Override - public IItemDefinition fluidCell4kPart() - { - return this.fluidCell4kPart; - } - - @Override - public IItemDefinition fluidCell16kPart() - { - return this.fluidCell16kPart; - } - - @Override - public IItemDefinition fluidCell64kPart() - { - return this.fluidCell64kPart; - } +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 certusQuartzCrystal; + private final IItemDefinition certusQuartzCrystalCharged; + private final IItemDefinition fluixCrystal; + private final IItemDefinition fluixPearl; + + private final IItemDefinition woodenGear; + + private final IItemDefinition wirelessReceiver; + private final IItemDefinition wirelessBooster; + + private final IItemDefinition annihilationCore; + private final IItemDefinition formationCore; + + private final IItemDefinition singularity; + private final IItemDefinition qESingularity; + private final IItemDefinition blankPattern; + + private final IItemDefinition fluidCell1kPart; + private final IItemDefinition fluidCell4kPart; + private final IItemDefinition fluidCell16kPart; + private final IItemDefinition fluidCell64kPart; + + private final FeatureFactory registry; + + public ApiMaterials(FeatureFactory registry) { + this.registry = registry; + + EntitySingularity.TYPE = registry + .entity("singularity", EntitySingularity::new, EntityClassification.MISC) + .customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4) + .setShouldReceiveVelocityUpdates(true)) + .build(); + + EntityChargedQuartz.TYPE = registry + .entity("charged_quartz", EntityChargedQuartz::new, EntityClassification.MISC) + .customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4) + .setShouldReceiveVelocityUpdates(true)) + .build(); + + this.cell2SpatialPart = createMaterial(MaterialType.SPATIAL_2_CELL_COMPONENT); + this.cell16SpatialPart = createMaterial(MaterialType.SPATIAL_16_CELL_COMPONENT); + this.cell128SpatialPart = createMaterial(MaterialType.SPATIAL_128_CELL_COMPONENT); + this.silicon = createMaterial(MaterialType.SILICON); + this.skyDust = createMaterial(MaterialType.SKY_DUST); + this.calcProcessorPress = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRESS); + this.engProcessorPress = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRESS); + this.logicProcessorPress = createMaterial(MaterialType.LOGIC_PROCESSOR_PRESS); + this.siliconPress = createMaterial(MaterialType.SILICON_PRESS); + this.namePress = createMaterial(MaterialType.NAME_PRESS); + this.calcProcessorPrint = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRINT); + this.engProcessorPrint = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRINT); + this.logicProcessorPrint = createMaterial(MaterialType.LOGIC_PROCESSOR_PRINT); + this.siliconPrint = createMaterial(MaterialType.SILICON_PRINT); + this.logicProcessor = createMaterial(MaterialType.LOGIC_PROCESSOR); + this.calcProcessor = createMaterial(MaterialType.CALCULATION_PROCESSOR); + this.engProcessor = createMaterial(MaterialType.ENGINEERING_PROCESSOR); + this.basicCard = createMaterial(MaterialType.BASIC_CARD); + this.advCard = createMaterial(MaterialType.ADVANCED_CARD); + this.purifiedCertusQuartzCrystal = createMaterial(MaterialType.PURIFIED_CERTUS_QUARTZ_CRYSTAL); + this.purifiedNetherQuartzCrystal = createMaterial(MaterialType.PURIFIED_NETHER_QUARTZ_CRYSTAL); + this.purifiedFluixCrystal = createMaterial(MaterialType.PURIFIED_FLUIX_CRYSTAL); + this.cell1kPart = createMaterial(MaterialType.ITEM_1K_CELL_COMPONENT); + this.cell4kPart = createMaterial(MaterialType.ITEM_4K_CELL_COMPONENT); + this.cell16kPart = createMaterial(MaterialType.ITEM_16K_CELL_COMPONENT); + this.cell64kPart = createMaterial(MaterialType.ITEM_64K_CELL_COMPONENT); + this.emptyStorageCell = createMaterial(MaterialType.EMPTY_STORAGE_CELL); + this.cardRedstone = createMaterial(MaterialType.CARD_REDSTONE); + this.cardSpeed = createMaterial(MaterialType.CARD_SPEED); + this.cardCapacity = createMaterial(MaterialType.CARD_CAPACITY); + this.cardFuzzy = createMaterial(MaterialType.CARD_FUZZY); + this.cardInverter = createMaterial(MaterialType.CARD_INVERTER); + this.cardCrafting = createMaterial(MaterialType.CARD_CRAFTING); + this.enderDust = createMaterial(MaterialType.ENDER_DUST); + this.flour = createMaterial(MaterialType.FLOUR); + this.goldDust = createMaterial(MaterialType.GOLD_DUST); + this.ironDust = createMaterial(MaterialType.IRON_DUST); + this.fluixDust = createMaterial(MaterialType.FLUIX_DUST); + this.certusQuartzDust = createMaterial(MaterialType.CERTUS_QUARTZ_DUST); + this.netherQuartzDust = createMaterial(MaterialType.NETHER_QUARTZ_DUST); + this.matterBall = createMaterial(MaterialType.MATTER_BALL); + this.certusQuartzCrystal = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL); + this.certusQuartzCrystalCharged = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL_CHARGED); + this.fluixCrystal = createMaterial(MaterialType.FLUIX_CRYSTAL); + this.fluixPearl = createMaterial(MaterialType.FLUIX_PEARL); + this.woodenGear = createMaterial(MaterialType.WOODEN_GEAR); + this.wirelessReceiver = createMaterial(MaterialType.WIRELESS_RECEIVER); + this.wirelessBooster = createMaterial(MaterialType.WIRELESS_BOOSTER); + this.annihilationCore = createMaterial(MaterialType.ANNIHILATION_CORE); + this.formationCore = createMaterial(MaterialType.FORMATION_CORE); + this.singularity = createMaterial(MaterialType.SINGULARITY); + this.qESingularity = createMaterial(MaterialType.QUANTUM_ENTANGLED_SINGULARITY); + this.blankPattern = createMaterial(MaterialType.BLANK_PATTERN); + this.fluidCell1kPart = createMaterial(MaterialType.FLUID_1K_CELL_COMPONENT); + this.fluidCell4kPart = createMaterial(MaterialType.FLUID_4K_CELL_COMPONENT); + this.fluidCell16kPart = createMaterial(MaterialType.FLUID_16K_CELL_COMPONENT); + this.fluidCell64kPart = createMaterial(MaterialType.FLUID_64K_CELL_COMPONENT); + } + + private IItemDefinition createMaterial(final MaterialType mat) { + Preconditions.checkState(!mat.isRegistered(), "Cannot create the same material twice."); + + IItemDefinition def = registry.item(mat.getId(), props -> new ItemMaterial(props, mat)) + .features(mat.getFeature().toArray(new AEFeature[0])).build(); + + boolean enabled = true; + + for (final AEFeature f : mat.getFeature()) { + enabled = enabled && AEConfig.instance().isFeatureEnabled(f); + } + + mat.setStackSrc(new MaterialStackSrc(mat, enabled)); + mat.setItemInstance(def.item()); + mat.markReady(); + return def; + } + + @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 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 wirelessReceiver() { + return this.wirelessReceiver; + } + + @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; + } + + @Override + public IItemDefinition fluidCell1kPart() { + return this.fluidCell1kPart; + } + + @Override + public IItemDefinition fluidCell4kPart() { + return this.fluidCell4kPart; + } + + @Override + public IItemDefinition fluidCell16kPart() { + return this.fluidCell16kPart; + } + + @Override + public IItemDefinition fluidCell64kPart() { + return this.fluidCell64kPart; + } } diff --git a/src/main/java/appeng/core/api/definitions/ApiParts.java b/src/main/java/appeng/core/api/definitions/ApiParts.java index 9cec4d532..5280f0638 100644 --- a/src/main/java/appeng/core/api/definitions/ApiParts.java +++ b/src/main/java/appeng/core/api/definitions/ApiParts.java @@ -18,6 +18,13 @@ package appeng.core.api.definitions; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IParts; @@ -40,391 +47,361 @@ import appeng.parts.misc.*; import appeng.parts.networking.*; import appeng.parts.p2p.*; import appeng.parts.reporting.*; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - /** * 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 cableDenseCovered; - private final AEColoredItemDefinition cableDenseSmart; - 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 fluidIface; - private final IItemDefinition levelEmitter; - private final IItemDefinition fluidLevelEmitter; - private final IItemDefinition annihilationPlane; - private final IItemDefinition identityAnnihilationPlane; - private final IItemDefinition fluidAnnihilationPlane; - private final IItemDefinition formationPlane; - private final IItemDefinition fluidFormationPlane; - private final IItemDefinition p2PTunnelME; - private final IItemDefinition p2PTunnelRedstone; - private final IItemDefinition p2PTunnelItems; - private final IItemDefinition p2PTunnelFluids; - private final IItemDefinition p2PTunnelEU; - private final IItemDefinition p2PTunnelFE; - 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; - private final IItemDefinition fluidImportBus; - private final IItemDefinition fluidExportBus; - private final IItemDefinition fluidTerminal; - private final IItemDefinition fluidStorageBus; +public final class ApiParts implements IParts { + private final AEColoredItemDefinition cableSmart; + private final AEColoredItemDefinition cableCovered; + private final AEColoredItemDefinition cableGlass; + private final AEColoredItemDefinition cableDenseCovered; + private final AEColoredItemDefinition cableDenseSmart; + 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 fluidIface; + private final IItemDefinition levelEmitter; + private final IItemDefinition fluidLevelEmitter; + private final IItemDefinition annihilationPlane; + private final IItemDefinition identityAnnihilationPlane; + private final IItemDefinition fluidAnnihilationPlane; + private final IItemDefinition formationPlane; + private final IItemDefinition fluidFormationPlane; + private final IItemDefinition p2PTunnelME; + private final IItemDefinition p2PTunnelRedstone; + private final IItemDefinition p2PTunnelItems; + private final IItemDefinition p2PTunnelFluids; + private final IItemDefinition p2PTunnelEU; + private final IItemDefinition p2PTunnelFE; + 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; + private final IItemDefinition fluidImportBus; + private final IItemDefinition fluidExportBus; + private final IItemDefinition fluidTerminal; + private final IItemDefinition fluidStorageBus; - public ApiParts( FeatureFactory registry, PartModels partModels ) - { - registerPartModels(partModels); + public ApiParts(FeatureFactory registry, PartModels partModels) { + registerPartModels(partModels); - this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART, PartCableSmart::new); - this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED, PartCableCovered::new); - this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS, PartCableGlass::new); - this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable", PartType.CABLE_DENSE_COVERED, PartDenseCableCovered::new); - this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART, PartDenseCableSmart::new); - this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, PartQuartzFiber::new ); - this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, PartToggleBus::new ); - this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS, PartInvertedToggleBus::new ); - this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, PartCableAnchor::new ); - this.monitor = createPart(registry, "monitor", PartType.MONITOR, PartPanel::new ); - this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR, PartSemiDarkPanel::new ); - this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, PartDarkPanel::new ); - this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, PartStorageBus::new ); - this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS, PartFluidStorageBus::new ); - this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, PartImportBus::new ); - this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS, PartFluidImportBus::new ); - this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, PartExportBus::new ); - this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS, PartFluidExportBus::new ); - this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, PartLevelEmitter::new ); - this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER, PartFluidLevelEmitter::new ); - this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE, PartAnnihilationPlane::new ); - this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane", PartType.IDENTITY_ANNIHILATION_PLANE, PartIdentityAnnihilationPlane::new ); - this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane", PartType.FLUID_ANNIHILATION_PLANE, PartFluidAnnihilationPlane::new ); - this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE, PartFormationPlane::new ); - this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE, PartFluidFormationPlane::new ); - this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL, PartPatternTerminal::new ); - this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL, PartCraftingTerminal::new ); - this.terminal = createPart(registry, "terminal", PartType.TERMINAL, PartTerminal::new ); - this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR, PartStorageMonitor::new ); - this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR, PartConversionMonitor::new ); - this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, PartInterface::new ); - this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE, PartFluidInterface::new ); - this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, PartP2PTunnelME::new ); - this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE, PartP2PRedstone::new ); - this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, PartP2PItems::new ); - this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID, PartP2PFluids::new ); - this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2, PartP2PIC2Power::new); - this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, PartP2PFEPower::new ); - this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT, PartP2PLight::new ); - this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL, PartInterfaceTerminal::new ); - this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, PartFluidTerminal::new ); - } + this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART, + PartCableSmart::new); + this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED, + PartCableCovered::new); + this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS, + PartCableGlass::new); + this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable", + PartType.CABLE_DENSE_COVERED, PartDenseCableCovered::new); + this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART, + PartDenseCableSmart::new); + this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, PartQuartzFiber::new); + this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, PartToggleBus::new); + this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS, + PartInvertedToggleBus::new); + this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, PartCableAnchor::new); + this.monitor = createPart(registry, "monitor", PartType.MONITOR, PartPanel::new); + this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR, + PartSemiDarkPanel::new); + this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, PartDarkPanel::new); + this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, PartStorageBus::new); + this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS, + PartFluidStorageBus::new); + this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, PartImportBus::new); + this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS, + PartFluidImportBus::new); + this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, PartExportBus::new); + this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS, + PartFluidExportBus::new); + this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, PartLevelEmitter::new); + this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER, + PartFluidLevelEmitter::new); + this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE, + PartAnnihilationPlane::new); + this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane", + PartType.IDENTITY_ANNIHILATION_PLANE, PartIdentityAnnihilationPlane::new); + this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane", + PartType.FLUID_ANNIHILATION_PLANE, PartFluidAnnihilationPlane::new); + this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE, + PartFormationPlane::new); + this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE, + PartFluidFormationPlane::new); + this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL, + PartPatternTerminal::new); + this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL, + PartCraftingTerminal::new); + this.terminal = createPart(registry, "terminal", PartType.TERMINAL, PartTerminal::new); + this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR, + PartStorageMonitor::new); + this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR, + PartConversionMonitor::new); + this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, PartInterface::new); + this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE, + PartFluidInterface::new); + this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, PartP2PTunnelME::new); + this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE, + PartP2PRedstone::new); + this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, PartP2PItems::new); + this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID, PartP2PFluids::new); + this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2, + // PartP2PIC2Power::new); + this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, PartP2PFEPower::new); + this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT, PartP2PLight::new); + this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL, + PartInterfaceTerminal::new); + this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, PartFluidTerminal::new); + } - private void registerPartModels(PartModels partModels) { + private void registerPartModels(PartModels partModels) { - // Register the built-in models for annihilation planes - ResourceLocation fluidFormationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/fluid_formation_plane" ); - ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/fluid_formation_plane_on" ); + // Register the built-in models for annihilation planes + ResourceLocation fluidFormationPlaneTexture = new ResourceLocation(AppEng.MOD_ID, + "item/part/fluid_formation_plane"); + ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation(AppEng.MOD_ID, + "parts/fluid_formation_plane_on"); - // Register all part models - for( PartType partType : PartType.values() ) - { - partModels.registerModels( partType.getModels() ); - } - } + // Register all part models + for (PartType partType : PartType.values()) { + partModels.registerModels(partType.getModels()); + } + } - private IItemDefinition createPart(FeatureFactory registry, String id, PartType type, Function factory) { - return registry.item(id, props -> new ItemPart<>(props, type, factory)) - .itemGroup(CreativeTab.INSTANCE) - .rendering(new ItemPartRendering()) - .build(); - } + private IItemDefinition createPart(FeatureFactory registry, String id, PartType type, + Function factory) { + return registry.item(id, props -> new ItemPart<>(props, type, factory)).itemGroup(CreativeTab.INSTANCE) + .rendering(new ItemPartRendering()).build(); + } - private AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry, String idSuffix, PartType type, Function factory) - { - final ColoredItemDefinition definition = new ColoredItemDefinition(); + private AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry, + String idSuffix, PartType type, Function factory) { + final ColoredItemDefinition definition = new ColoredItemDefinition(); - for( final AEColor color : AEColor.values() ) - { - String id = color.registryPrefix + '_' + idSuffix; + for (final AEColor color : AEColor.values()) { + String id = color.registryPrefix + '_' + idSuffix; - IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color)) - .itemGroup(CreativeTab.INSTANCE) - .rendering(new ItemPartRendering(color)) - .build(); + IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color)) + .itemGroup(CreativeTab.INSTANCE).rendering(new ItemPartRendering(color)).build(); - definition.add( color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled) ); - } + definition.add(color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled)); + } - return definition; - } + return definition; + } - @Override - public AEColoredItemDefinition cableSmart() - { - return this.cableSmart; - } + @Override + public AEColoredItemDefinition cableSmart() { + return this.cableSmart; + } - @Override - public AEColoredItemDefinition cableCovered() - { - return this.cableCovered; - } + @Override + public AEColoredItemDefinition cableCovered() { + return this.cableCovered; + } - @Override - public AEColoredItemDefinition cableGlass() - { - return this.cableGlass; - } + @Override + public AEColoredItemDefinition cableGlass() { + return this.cableGlass; + } - @Override - public AEColoredItemDefinition cableDenseCovered() - { - return this.cableDenseCovered; - } + @Override + public AEColoredItemDefinition cableDenseCovered() { + return this.cableDenseCovered; + } - @Override - public AEColoredItemDefinition cableDenseSmart() - { - return this.cableDenseSmart; - } + @Override + public AEColoredItemDefinition cableDenseSmart() { + return this.cableDenseSmart; + } - @Override - public IItemDefinition quartzFiber() - { - return this.quartzFiber; - } + @Override + public IItemDefinition quartzFiber() { + return this.quartzFiber; + } - @Override - public IItemDefinition toggleBus() - { - return this.toggleBus; - } + @Override + public IItemDefinition toggleBus() { + return this.toggleBus; + } - @Override - public IItemDefinition invertedToggleBus() - { - return this.invertedToggleBus; - } + @Override + public IItemDefinition invertedToggleBus() { + return this.invertedToggleBus; + } - @Override - public IItemDefinition storageBus() - { - return this.storageBus; - } + @Override + public IItemDefinition storageBus() { + return this.storageBus; + } - @Override - public IItemDefinition importBus() - { - return this.importBus; - } + @Override + public IItemDefinition importBus() { + return this.importBus; + } - @Override - public IItemDefinition exportBus() - { - return this.exportBus; - } + @Override + public IItemDefinition exportBus() { + return this.exportBus; + } - @Override - public IItemDefinition iface() - { - return this.iface; - } + @Override + public IItemDefinition iface() { + return this.iface; + } - @Override - public IItemDefinition fluidIface() - { - return this.fluidIface; - } + @Override + public IItemDefinition fluidIface() { + return this.fluidIface; + } - @Override - public IItemDefinition levelEmitter() - { - return this.levelEmitter; - } + @Override + public IItemDefinition levelEmitter() { + return this.levelEmitter; + } - @Override - public IItemDefinition annihilationPlane() - { - return this.annihilationPlane; - } + @Override + public IItemDefinition annihilationPlane() { + return this.annihilationPlane; + } - @Override - public IItemDefinition identityAnnihilationPlane() - { - return this.identityAnnihilationPlane; - } + @Override + public IItemDefinition identityAnnihilationPlane() { + return this.identityAnnihilationPlane; + } - @Override - public IItemDefinition formationPlane() - { - return this.formationPlane; - } + @Override + public IItemDefinition formationPlane() { + return this.formationPlane; + } - @Override - public IItemDefinition p2PTunnelME() - { - return this.p2PTunnelME; - } + @Override + public IItemDefinition p2PTunnelME() { + return this.p2PTunnelME; + } - @Override - public IItemDefinition p2PTunnelRedstone() - { - return this.p2PTunnelRedstone; - } + @Override + public IItemDefinition p2PTunnelRedstone() { + return this.p2PTunnelRedstone; + } - @Override - public IItemDefinition p2PTunnelItems() - { - return this.p2PTunnelItems; - } + @Override + public IItemDefinition p2PTunnelItems() { + return this.p2PTunnelItems; + } - @Override - public IItemDefinition p2PTunnelFluids() - { - return this.p2PTunnelFluids; - } + @Override + public IItemDefinition p2PTunnelFluids() { + return this.p2PTunnelFluids; + } - @Override - public IItemDefinition p2PTunnelEU() - { - return this.p2PTunnelEU; - } + @Override + public IItemDefinition p2PTunnelEU() { + return this.p2PTunnelEU; + } - @Override - public IItemDefinition p2PTunnelFE() - { - return this.p2PTunnelFE; - } + @Override + public IItemDefinition p2PTunnelFE() { + return this.p2PTunnelFE; + } - @Override - public IItemDefinition p2PTunnelLight() - { - return this.p2PTunnelLight; - } + @Override + public IItemDefinition p2PTunnelLight() { + return this.p2PTunnelLight; + } - @Override - public IItemDefinition cableAnchor() - { - return this.cableAnchor; - } + @Override + public IItemDefinition cableAnchor() { + return this.cableAnchor; + } - @Override - public IItemDefinition monitor() - { - return this.monitor; - } + @Override + public IItemDefinition monitor() { + return this.monitor; + } - @Override - public IItemDefinition semiDarkMonitor() - { - return this.semiDarkMonitor; - } + @Override + public IItemDefinition semiDarkMonitor() { + return this.semiDarkMonitor; + } - @Override - public IItemDefinition darkMonitor() - { - return this.darkMonitor; - } + @Override + public IItemDefinition darkMonitor() { + return this.darkMonitor; + } - @Override - public IItemDefinition interfaceTerminal() - { - return this.interfaceTerminal; - } + @Override + public IItemDefinition interfaceTerminal() { + return this.interfaceTerminal; + } - @Override - public IItemDefinition patternTerminal() - { - return this.patternTerminal; - } + @Override + public IItemDefinition patternTerminal() { + return this.patternTerminal; + } - @Override - public IItemDefinition craftingTerminal() - { - return this.craftingTerminal; - } + @Override + public IItemDefinition craftingTerminal() { + return this.craftingTerminal; + } - @Override - public IItemDefinition terminal() - { - return this.terminal; - } + @Override + public IItemDefinition terminal() { + return this.terminal; + } - @Override - public IItemDefinition storageMonitor() - { - return this.storageMonitor; - } + @Override + public IItemDefinition storageMonitor() { + return this.storageMonitor; + } - @Override - public IItemDefinition conversionMonitor() - { - return this.conversionMonitor; - } + @Override + public IItemDefinition conversionMonitor() { + return this.conversionMonitor; + } - @Override - public IItemDefinition fluidTerminal() - { - return this.fluidTerminal; - } + @Override + public IItemDefinition fluidTerminal() { + return this.fluidTerminal; + } - @Override - public IItemDefinition fluidImportBus() - { - return this.fluidImportBus; - } + @Override + public IItemDefinition fluidImportBus() { + return this.fluidImportBus; + } - @Override - public IItemDefinition fluidExportBus() - { - return this.fluidExportBus; - } + @Override + public IItemDefinition fluidExportBus() { + return this.fluidExportBus; + } - @Override - public IItemDefinition fluidStorageBus() - { - return this.fluidStorageBus; - } + @Override + public IItemDefinition fluidStorageBus() { + return this.fluidStorageBus; + } - @Override - public IItemDefinition fluidLevelEmitter() - { - return this.fluidLevelEmitter; - } + @Override + public IItemDefinition fluidLevelEmitter() { + return this.fluidLevelEmitter; + } - @Override - public IItemDefinition fluidAnnihilationPlane() - { - return this.fluidAnnihilationPlane; - } + @Override + public IItemDefinition fluidAnnihilationPlane() { + return this.fluidAnnihilationPlane; + } - @Override - public IItemDefinition fluidFormationnPlane() - { - return this.fluidFormationPlane; - } + @Override + public IItemDefinition fluidFormationnPlane() { + return this.fluidFormationPlane; + } } diff --git a/src/main/java/appeng/core/crash/ModCrashEnhancement.java b/src/main/java/appeng/core/crash/ModCrashEnhancement.java index e6bfb6b03..a5c078288 100644 --- a/src/main/java/appeng/core/crash/ModCrashEnhancement.java +++ b/src/main/java/appeng/core/crash/ModCrashEnhancement.java @@ -18,11 +18,10 @@ package appeng.core.crash; - -import appeng.core.AEConfig; import net.minecraftforge.fml.common.ICrashCallable; import net.minecraftforge.versions.forge.ForgeVersion; +import appeng.core.AEConfig; public class ModCrashEnhancement implements ICrashCallable { @@ -33,8 +32,7 @@ public class ModCrashEnhancement implements ICrashCallable { @Override public String call() throws Exception { - return AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " + - ForgeVersion.getVersion(); + return AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " + ForgeVersion.getVersion(); } } diff --git a/src/main/java/appeng/core/features/ActivityState.java b/src/main/java/appeng/core/features/ActivityState.java index 0cc74f7b3..fc210d02f 100644 --- a/src/main/java/appeng/core/features/ActivityState.java +++ b/src/main/java/appeng/core/features/ActivityState.java @@ -18,20 +18,14 @@ package appeng.core.features; +public enum ActivityState { + Enabled, Disabled; -public enum ActivityState -{ - Enabled, Disabled; - - public static ActivityState from( final boolean enabled ) - { - if( enabled ) - { - return ActivityState.Enabled; - } - else - { - return ActivityState.Disabled; - } - } + public static ActivityState from(final boolean enabled) { + if (enabled) { + return ActivityState.Enabled; + } else { + return ActivityState.Disabled; + } + } } diff --git a/src/main/java/appeng/core/features/BlockDefinition.java b/src/main/java/appeng/core/features/BlockDefinition.java index 1fcbdce37..a5b128e13 100644 --- a/src/main/java/appeng/core/features/BlockDefinition.java +++ b/src/main/java/appeng/core/features/BlockDefinition.java @@ -18,10 +18,8 @@ package appeng.core.features; - import java.util.Set; -import appeng.api.features.AEFeature; import com.google.common.base.Preconditions; import net.minecraft.block.Block; @@ -31,44 +29,38 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import appeng.api.definitions.IBlockDefinition; +import appeng.api.features.AEFeature; +public class BlockDefinition extends ItemDefinition implements IBlockDefinition { + private final Block block; -public class BlockDefinition extends ItemDefinition implements IBlockDefinition -{ - private final Block block; + private final BlockItem blockItem; - private final BlockItem blockItem; + public BlockDefinition(String registryName, Block block, BlockItem item, Set features) { + super(registryName, item, features); + this.block = block; + this.blockItem = item; + } - public BlockDefinition( String registryName, Block block, BlockItem item, Set features ) - { - super( registryName, item, features ); - this.block = block; - this.blockItem = item; - } + @Override + public final Block block() { + return this.block; + } - @Override - public final Block block() - { - return this.block; - } + @Override + public BlockItem blockItem() { + return blockItem; + } - @Override - public BlockItem blockItem() - { - return blockItem; - } + @Override + public final ItemStack stack(int stackSize) { + Preconditions.checkArgument(stackSize > 0); - @Override - public final ItemStack stack( int stackSize ) - { - Preconditions.checkArgument( stackSize > 0 ); + return new ItemStack(block, stackSize); + } - return new ItemStack(block, stackSize); - } - - @Override - public final boolean isSameAs( final IBlockReader world, final BlockPos pos ) - { - return world.getBlockState( pos ).getBlock() == this.block; - } + @Override + public final boolean isSameAs(final IBlockReader world, final BlockPos pos) { + return world.getBlockState(pos).getBlock() == this.block; + } } diff --git a/src/main/java/appeng/core/features/BlockStackSrc.java b/src/main/java/appeng/core/features/BlockStackSrc.java index 63077f114..cf70bb4d5 100644 --- a/src/main/java/appeng/core/features/BlockStackSrc.java +++ b/src/main/java/appeng/core/features/BlockStackSrc.java @@ -18,7 +18,6 @@ package appeng.core.features; - import javax.annotation.Nullable; import com.google.common.base.Preconditions; @@ -27,39 +26,33 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +public class BlockStackSrc implements IStackSrc { -public class BlockStackSrc implements IStackSrc -{ + private final Block block; + private final boolean enabled; - private final Block block; - private final boolean enabled; + public BlockStackSrc(final Block block, final ActivityState state) { + Preconditions.checkNotNull(block); + Preconditions.checkNotNull(state); + Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled); - public BlockStackSrc( final Block block, final ActivityState state ) - { - Preconditions.checkNotNull( block ); - Preconditions.checkNotNull( state ); - Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled ); + this.block = block; + this.enabled = state == ActivityState.Enabled; + } - this.block = block; - this.enabled = state == ActivityState.Enabled; - } + @Nullable + @Override + public ItemStack stack(final int i) { + return new ItemStack(this.block, i); + } - @Nullable - @Override - public ItemStack stack( final int i ) - { - return new ItemStack( this.block, i ); - } + @Override + public Item getItem() { + return null; + } - @Override - public Item getItem() - { - return null; - } - - @Override - public boolean isEnabled() - { - return this.enabled; - } + @Override + public boolean isEnabled() { + return this.enabled; + } } diff --git a/src/main/java/appeng/core/features/ColoredItemDefinition.java b/src/main/java/appeng/core/features/ColoredItemDefinition.java index db24a3288..0ec7ed407 100644 --- a/src/main/java/appeng/core/features/ColoredItemDefinition.java +++ b/src/main/java/appeng/core/features/ColoredItemDefinition.java @@ -18,7 +18,6 @@ package appeng.core.features; - import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -27,76 +26,63 @@ import net.minecraft.tileentity.TileEntity; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; +public final class ColoredItemDefinition implements AEColoredItemDefinition { -public final class ColoredItemDefinition implements AEColoredItemDefinition -{ + private final ItemStackSrc[] colors = new ItemStackSrc[17]; - private final ItemStackSrc[] colors = new ItemStackSrc[17]; + public void add(final AEColor v, final ItemStackSrc is) { + this.colors[v.ordinal()] = is; + } - public void add( final AEColor v, final ItemStackSrc is ) - { - this.colors[v.ordinal()] = is; - } + @Override + public Block block(final AEColor color) { + return null; + } - @Override - public Block block( final AEColor color ) - { - return null; - } + @Override + public Item item(final AEColor color) { + final ItemStackSrc is = this.colors[color.ordinal()]; - @Override - public Item item( final AEColor color ) - { - final ItemStackSrc is = this.colors[color.ordinal()]; + if (is == null) { + return null; + } - if( is == null ) - { - return null; - } + return is.getItem(); + } - return is.getItem(); - } + @Override + public Class entity(final AEColor color) { + return null; + } - @Override - public Class entity( final AEColor color ) - { - return null; - } + @Override + public ItemStack stack(final AEColor color, final int stackSize) { + final ItemStackSrc is = this.colors[color.ordinal()]; - @Override - public ItemStack stack( final AEColor color, final int stackSize ) - { - final ItemStackSrc is = this.colors[color.ordinal()]; + if (is == null) { + return ItemStack.EMPTY; + } - if( is == null ) - { - return ItemStack.EMPTY; - } + return is.stack(stackSize); + } - return is.stack( stackSize ); - } + @Override + public ItemStack[] allStacks(final int stackSize) { + final ItemStack[] is = new ItemStack[this.colors.length]; + for (int x = 0; x < is.length; x++) { + is[x] = this.colors[x].stack(1); + } + return is; + } - @Override - public ItemStack[] allStacks( final int stackSize ) - { - final ItemStack[] is = new ItemStack[this.colors.length]; - for( int x = 0; x < is.length; x++ ) - { - is[x] = this.colors[x].stack( 1 ); - } - return is; - } + @Override + public boolean sameAs(final AEColor color, final ItemStack comparableItem) { + final ItemStackSrc is = this.colors[color.ordinal()]; - @Override - public boolean sameAs( final AEColor color, final ItemStack comparableItem ) - { - final ItemStackSrc is = this.colors[color.ordinal()]; + if (comparableItem.isEmpty() || is == null) { + return false; + } - if( comparableItem.isEmpty() || is == null ) - { - return false; - } - - return comparableItem.getItem() == is.getItem(); - } + return comparableItem.getItem() == is.getItem(); + } } diff --git a/src/main/java/appeng/core/features/DamagedItemDefinition.java b/src/main/java/appeng/core/features/DamagedItemDefinition.java index c393b7600..75808b066 100644 --- a/src/main/java/appeng/core/features/DamagedItemDefinition.java +++ b/src/main/java/appeng/core/features/DamagedItemDefinition.java @@ -18,77 +18,67 @@ package appeng.core.features; - import java.util.Collections; import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; -import appeng.api.features.AEFeature; import com.google.common.base.Preconditions; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.api.definitions.IItemDefinition; +import appeng.api.features.AEFeature; +public final class DamagedItemDefinition implements IItemDefinition { + private final String identifier; + private final IStackSrc source; -public final class DamagedItemDefinition implements IItemDefinition -{ - private final String identifier; - private final IStackSrc source; + public DamagedItemDefinition(@Nonnull final String identifier, @Nonnull final IStackSrc source) { + this.identifier = Preconditions.checkNotNull(identifier); + this.source = Preconditions.checkNotNull(source); + } - public DamagedItemDefinition( @Nonnull final String identifier, @Nonnull final IStackSrc source ) - { - this.identifier = Preconditions.checkNotNull( identifier ); - this.source = Preconditions.checkNotNull( source ); - } + @Override + public Item item() { + return source.getItem(); + } - @Override - public Item item() { - return source.getItem(); - } + @Override + public ItemStack stack(int stackSize) { + return source.stack(stackSize); + } - @Override - public ItemStack stack(int stackSize) { - return source.stack(stackSize); - } + @Nonnull + @Override + public String identifier() { + return this.identifier; + } - @Nonnull - @Override - public String identifier() - { - return this.identifier; - } + @Override + public Optional maybeItem() { + return Optional.of(this.source.getItem()); + } - @Override - public Optional maybeItem() - { - return Optional.of(this.source.getItem()); - } + @Override + public Optional maybeStack(final int stackSize) { + return Optional.of(this.source.stack(stackSize)); + } - @Override - public Optional maybeStack( final int stackSize ) - { - return Optional.of(this.source.stack(stackSize)); - } + @Override + public Set features() { + return Collections.emptySet(); + } - @Override - public Set features() - { - return Collections.emptySet(); - } + @Override + public boolean isSameAs(final ItemStack comparableStack) { + if (comparableStack.isEmpty()) { + return false; + } - @Override - public boolean isSameAs( final ItemStack comparableStack ) - { - if( comparableStack.isEmpty() ) - { - return false; - } - - return comparableStack.getItem() == this.source.getItem(); - } + return comparableStack.getItem() == this.source.getItem(); + } } diff --git a/src/main/java/appeng/core/features/IStackSrc.java b/src/main/java/appeng/core/features/IStackSrc.java index 88ad1d214..49bbe7c86 100644 --- a/src/main/java/appeng/core/features/IStackSrc.java +++ b/src/main/java/appeng/core/features/IStackSrc.java @@ -18,17 +18,14 @@ package appeng.core.features; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +public interface IStackSrc { -public interface IStackSrc -{ + ItemStack stack(int i); - ItemStack stack( int i ); + Item getItem(); - Item getItem(); - - boolean isEnabled(); + boolean isEnabled(); } diff --git a/src/main/java/appeng/core/features/ItemDefinition.java b/src/main/java/appeng/core/features/ItemDefinition.java index b7fe2e34d..c951e0f91 100644 --- a/src/main/java/appeng/core/features/ItemDefinition.java +++ b/src/main/java/appeng/core/features/ItemDefinition.java @@ -18,66 +18,57 @@ package appeng.core.features; - import java.util.Set; import javax.annotation.Nonnull; -import appeng.api.features.AEFeature; import com.google.common.base.Preconditions; import com.google.common.base.Strings; - import com.google.common.collect.ImmutableSet; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.api.definitions.IItemDefinition; +import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ItemDefinition implements IItemDefinition { + private final String identifier; + private final Item item; + private final Set features; -public class ItemDefinition implements IItemDefinition -{ - private final String identifier; - private final Item item; - private final Set features; + public ItemDefinition(String registryName, Item item, Set features) { + Preconditions.checkArgument(!Strings.isNullOrEmpty(registryName), "registryName"); + this.identifier = registryName; + this.item = item; + this.features = ImmutableSet.copyOf(features); + } - public ItemDefinition( String registryName, Item item, Set features ) - { - Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" ); - this.identifier = registryName; - this.item = item; - this.features = ImmutableSet.copyOf(features); - } + @Nonnull + @Override + public String identifier() { + return this.identifier; + } - @Nonnull - @Override - public String identifier() - { - return this.identifier; - } + @Override + public final Item item() { + return this.item; + } - @Override - public final Item item() - { - return this.item; - } + @Override + public ItemStack stack(final int stackSize) { + return new ItemStack(item, stackSize); + } - @Override - public ItemStack stack( final int stackSize ) - { - return new ItemStack( item, stackSize ); - } + @Override + public Set features() { + return features; + } - @Override - public Set features() - { - return features; - } - - @Override - public final boolean isSameAs( final ItemStack comparableStack ) - { - return Platform.itemComparisons().isEqualItemType( comparableStack, this.stack( 1 ) ); - } + @Override + public final boolean isSameAs(final ItemStack comparableStack) { + return Platform.itemComparisons().isEqualItemType(comparableStack, this.stack(1)); + } } diff --git a/src/main/java/appeng/core/features/ItemStackSrc.java b/src/main/java/appeng/core/features/ItemStackSrc.java index 49c8d3e46..861174625 100644 --- a/src/main/java/appeng/core/features/ItemStackSrc.java +++ b/src/main/java/appeng/core/features/ItemStackSrc.java @@ -18,7 +18,6 @@ package appeng.core.features; - import javax.annotation.Nullable; import com.google.common.base.Preconditions; @@ -26,39 +25,33 @@ import com.google.common.base.Preconditions; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +public class ItemStackSrc implements IStackSrc { -public class ItemStackSrc implements IStackSrc -{ + private final Item item; + private final boolean enabled; - private final Item item; - private final boolean enabled; + public ItemStackSrc(final Item item, final ActivityState state) { + Preconditions.checkNotNull(item); + Preconditions.checkNotNull(state); + Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled); - public ItemStackSrc( final Item item, final ActivityState state ) - { - Preconditions.checkNotNull( item ); - Preconditions.checkNotNull( state ); - Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled ); + this.item = item; + this.enabled = state == ActivityState.Enabled; + } - this.item = item; - this.enabled = state == ActivityState.Enabled; - } + @Nullable + @Override + public ItemStack stack(final int i) { + return new ItemStack(this.item, i); + } - @Nullable - @Override - public ItemStack stack( final int i ) - { - return new ItemStack( this.item, i ); - } + @Override + public Item getItem() { + return this.item; + } - @Override - public Item getItem() - { - return this.item; - } - - @Override - public boolean isEnabled() - { - return this.enabled; - } + @Override + public boolean isEnabled() { + return this.enabled; + } } diff --git a/src/main/java/appeng/core/features/MaterialStackSrc.java b/src/main/java/appeng/core/features/MaterialStackSrc.java index 82e663998..b0af3ed53 100644 --- a/src/main/java/appeng/core/features/MaterialStackSrc.java +++ b/src/main/java/appeng/core/features/MaterialStackSrc.java @@ -18,7 +18,6 @@ package appeng.core.features; - import com.google.common.base.Preconditions; import net.minecraft.item.Item; @@ -26,35 +25,29 @@ import net.minecraft.item.ItemStack; import appeng.items.materials.MaterialType; +public class MaterialStackSrc implements IStackSrc { + private final MaterialType src; + private final boolean enabled; -public class MaterialStackSrc implements IStackSrc -{ - private final MaterialType src; - private final boolean enabled; + public MaterialStackSrc(final MaterialType src, boolean enabled) { + Preconditions.checkNotNull(src); - public MaterialStackSrc( final MaterialType src, boolean enabled ) - { - Preconditions.checkNotNull( src ); + this.src = src; + this.enabled = enabled; + } - this.src = src; - this.enabled = enabled; - } + @Override + public ItemStack stack(final int stackSize) { + return this.src.stack(stackSize); + } - @Override - public ItemStack stack( final int stackSize ) - { - return this.src.stack( stackSize ); - } + @Override + public Item getItem() { + return this.src.getItemInstance(); + } - @Override - public Item getItem() - { - return this.src.getItemInstance(); - } - - @Override - public boolean isEnabled() - { - return this.enabled; - } + @Override + public boolean isEnabled() { + return this.enabled; + } } diff --git a/src/main/java/appeng/core/features/TileDefinition.java b/src/main/java/appeng/core/features/TileDefinition.java index 2b1d218e1..af3bb7cbb 100644 --- a/src/main/java/appeng/core/features/TileDefinition.java +++ b/src/main/java/appeng/core/features/TileDefinition.java @@ -18,33 +18,29 @@ package appeng.core.features; - import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; -import appeng.api.features.AEFeature; import net.minecraft.item.BlockItem; import net.minecraft.tileentity.TileEntity; import appeng.api.definitions.ITileDefinition; +import appeng.api.features.AEFeature; import appeng.block.AEBaseTileBlock; +public final class TileDefinition extends BlockDefinition implements ITileDefinition { + private final AEBaseTileBlock block; -public final class TileDefinition extends BlockDefinition implements ITileDefinition -{ - private final AEBaseTileBlock block; + public TileDefinition(@Nonnull String registryName, AEBaseTileBlock block, BlockItem item, + Set features) { + super(registryName, block, item, features); + this.block = block; + } - public TileDefinition( @Nonnull String registryName, AEBaseTileBlock block, BlockItem item, Set features ) - { - super( registryName, block, item, features ); - this.block = block; - } - - @Override - public Optional> maybeEntity() - { - return Optional.of(this.block.getTileEntityClass()); - } + @Override + public Optional> maybeEntity() { + return Optional.of(this.block.getTileEntityClass()); + } } diff --git a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java index 4135c1dd9..35f6d2fc4 100644 --- a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java +++ b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; @@ -29,58 +28,44 @@ import appeng.api.networking.IGridCache; import appeng.api.networking.IGridCacheRegistry; import appeng.core.AELog; +public final class GridCacheRegistry implements IGridCacheRegistry { + private final Map, Class> caches = new HashMap<>(); -public final class GridCacheRegistry implements IGridCacheRegistry -{ - private final Map, Class> caches = new HashMap<>(); + @Override + public void registerGridCache(final Class iface, + final Class implementation) { + if (iface.isAssignableFrom(implementation)) { + this.caches.put(iface, implementation); + } else { + throw new IllegalArgumentException( + "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + + iface + " and " + implementation); + } + } - @Override - public void registerGridCache( final Class iface, final Class implementation ) - { - if( iface.isAssignableFrom( implementation ) ) - { - this.caches.put( iface, implementation ); - } - else - { - throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation ); - } - } + @Override + public HashMap, IGridCache> createCacheInstance(final IGrid g) { + final HashMap, IGridCache> map = new HashMap<>(); - @Override - public HashMap, IGridCache> createCacheInstance( final IGrid g ) - { - final HashMap, IGridCache> map = new HashMap<>(); + for (final Class iface : this.caches.keySet()) { + try { + final Constructor c = this.caches.get(iface).getConstructor(IGrid.class); + map.put(iface, c.newInstance(g)); + } catch (final NoSuchMethodException e) { + AELog.error("Grid Caches must have a constructor with IGrid as the single param."); + throw new IllegalArgumentException(e); + } catch (final InvocationTargetException e) { + AELog.error("Grid Caches must have a constructor with IGrid as the single param."); + throw new IllegalStateException(e); + } catch (final InstantiationException e) { + AELog.error("Grid Caches must have a constructor with IGrid as the single param."); + throw new IllegalStateException(e); + } catch (final IllegalAccessException e) { + AELog.error("Grid Caches must have a constructor with IGrid as the single param."); + throw new IllegalStateException(e); + } + } - for( final Class iface : this.caches.keySet() ) - { - try - { - final Constructor c = this.caches.get( iface ).getConstructor( IGrid.class ); - map.put( iface, c.newInstance( g ) ); - } - catch( final NoSuchMethodException e ) - { - AELog.error( "Grid Caches must have a constructor with IGrid as the single param." ); - throw new IllegalArgumentException( e ); - } - catch( final InvocationTargetException e ) - { - AELog.error( "Grid Caches must have a constructor with IGrid as the single param." ); - throw new IllegalStateException( e ); - } - catch( final InstantiationException e ) - { - AELog.error( "Grid Caches must have a constructor with IGrid as the single param." ); - throw new IllegalStateException( e ); - } - catch( final IllegalAccessException e ) - { - AELog.error( "Grid Caches must have a constructor with IGrid as the single param." ); - throw new IllegalStateException( e ); - } - } - - return map; - } + return map; + } } diff --git a/src/main/java/appeng/core/features/registries/LocatableRegistry.java b/src/main/java/appeng/core/features/registries/LocatableRegistry.java index 2e36eb9ef..4fe02f849 100644 --- a/src/main/java/appeng/core/features/registries/LocatableRegistry.java +++ b/src/main/java/appeng/core/features/registries/LocatableRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.HashMap; import java.util.Map; @@ -31,38 +30,29 @@ import appeng.api.features.ILocatable; import appeng.api.features.ILocatableRegistry; import appeng.util.Platform; +public final class LocatableRegistry implements ILocatableRegistry { + private final Map set; -public final class LocatableRegistry implements ILocatableRegistry -{ - private final Map set; + public LocatableRegistry() { + this.set = new HashMap<>(); + MinecraftForge.EVENT_BUS.register(this); + } - public LocatableRegistry() - { - this.set = new HashMap<>(); - MinecraftForge.EVENT_BUS.register( this ); - } + @SubscribeEvent + public void updateLocatable(final LocatableEventAnnounce e) { + if (Platform.isClient()) { + return; // IGNORE! + } - @SubscribeEvent - public void updateLocatable( final LocatableEventAnnounce e ) - { - if( Platform.isClient() ) - { - return; // IGNORE! - } + if (e.change == LocatableEvent.REGISTER) { + this.set.put(e.target.getLocatableSerial(), e.target); + } else if (e.change == LocatableEvent.UNREGISTER) { + this.set.remove(e.target.getLocatableSerial()); + } + } - if( e.change == LocatableEvent.REGISTER ) - { - this.set.put( e.target.getLocatableSerial(), e.target ); - } - else if( e.change == LocatableEvent.UNREGISTER ) - { - this.set.remove( e.target.getLocatableSerial() ); - } - } - - @Override - public ILocatable getLocatableBy( final long serial ) - { - return this.set.get( serial ); - } + @Override + public ILocatable getLocatableBy(final long serial) { + return this.set.get(serial); + } } diff --git a/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java b/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java index 6c43ee7a3..494351d15 100644 --- a/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java +++ b/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.HashMap; import net.minecraft.item.ItemStack; @@ -26,36 +25,29 @@ import net.minecraft.item.Items; import appeng.api.features.IMatterCannonAmmoRegistry; +public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry { -public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry -{ + private final HashMap DamageModifiers = new HashMap<>(); - private final HashMap DamageModifiers = new HashMap<>(); + public MatterCannonAmmoRegistry() { + // FIXME OreDictionaryHandler.INSTANCE.observe( this ); + this.registerAmmo(new ItemStack(Items.GOLD_NUGGET), 196.96655); + } - public MatterCannonAmmoRegistry() - { - // FIXME OreDictionaryHandler.INSTANCE.observe( this ); - this.registerAmmo( new ItemStack( Items.GOLD_NUGGET ), 196.96655 ); - } + @Override + public void registerAmmo(final ItemStack ammo, final double weight) { + this.DamageModifiers.put(ammo, weight); + } - @Override - public void registerAmmo( final ItemStack ammo, final double weight ) - { - this.DamageModifiers.put( ammo, weight ); - } - - @Override - public float getPenetration( final ItemStack is ) - { - for( final ItemStack o : this.DamageModifiers.keySet() ) - { - if( ItemStack.areItemsEqual( o, is ) ) - { - return this.DamageModifiers.get( o ).floatValue(); - } - } - return 0; - } + @Override + public float getPenetration(final ItemStack is) { + for (final ItemStack o : this.DamageModifiers.keySet()) { + if (ItemStack.areItemsEqual(o, is)) { + return this.DamageModifiers.get(o).floatValue(); + } + } + return 0; + } // FIXME @Override // FIXME public void oreRegistered( final String name, final ItemStack item ) @@ -138,11 +130,9 @@ public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatt // FIXME this.considerItem( name, item, "Electrum", ( 107.8682 + 196.96655 ) / 2.0 ); // FIXME } - private void considerItem( final String ore, final ItemStack item, final String name, final double weight ) - { - if( ore.equals( "berry" + name ) || ore.equals( "nugget" + name ) ) - { - this.registerAmmo( item, weight ); - } - } + private void considerItem(final String ore, final ItemStack item, final String name, final double weight) { + if (ore.equals("berry" + name) || ore.equals("nugget" + name)) { + this.registerAmmo(item, weight); + } + } } diff --git a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java index c23229364..579ace8c8 100644 --- a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java +++ b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -33,136 +32,115 @@ import appeng.api.movable.IMovableRegistry; import appeng.api.movable.IMovableTile; import appeng.spatial.DefaultSpatialHandler; +public class MovableTileRegistry implements IMovableRegistry { -public class MovableTileRegistry implements IMovableRegistry -{ + private final HashSet blacklisted = new HashSet<>(); - private final HashSet blacklisted = new HashSet<>(); + private final HashMap, IMovableHandler> Valid = new HashMap<>(); + private final List> test = new ArrayList<>(); + private final List handlers = new ArrayList<>(); + private final DefaultSpatialHandler dsh = new DefaultSpatialHandler(); - private final HashMap, IMovableHandler> Valid = new HashMap<>(); - private final List> test = new ArrayList<>(); - private final List handlers = new ArrayList<>(); - private final DefaultSpatialHandler dsh = new DefaultSpatialHandler(); + private final IMovableHandler nullHandler = new DefaultSpatialHandler(); - private final IMovableHandler nullHandler = new DefaultSpatialHandler(); + @Override + public void blacklistBlock(final Block blk) { + this.blacklisted.add(blk); + } - @Override - public void blacklistBlock( final Block blk ) - { - this.blacklisted.add( blk ); - } + @Override + public void whiteListTileEntity(final Class c) { + if (c.getName().equals(TileEntity.class.getName())) { + throw new IllegalArgumentException(new AppEngException("Someone tried to make all tiles movable with " + c + + ", this is a clear violation of the purpose of the white list.")); + } - @Override - public void whiteListTileEntity( final Class c ) - { - if( c.getName().equals( TileEntity.class.getName() ) ) - { - throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) ); - } + this.test.add(c); + } - this.test.add( c ); - } + @Override + public boolean askToMove(final TileEntity te) { + final Class myClass = te.getClass(); + IMovableHandler canMove = this.Valid.get(myClass); - @Override - public boolean askToMove( final TileEntity te ) - { - final Class myClass = te.getClass(); - IMovableHandler canMove = this.Valid.get( myClass ); + if (canMove == null) { + canMove = this.testClass(myClass, te); + } - if( canMove == null ) - { - canMove = this.testClass( myClass, te ); - } + if (canMove != this.nullHandler) { + if (te instanceof IMovableTile) { + ((IMovableTile) te).prepareToMove(); + } - if( canMove != this.nullHandler ) - { - if( te instanceof IMovableTile ) - { - ( (IMovableTile) te ).prepareToMove(); - } + te.remove(); + return true; + } - te.remove(); - return true; - } + return false; + } - return false; - } + private IMovableHandler testClass(final Class myClass, final TileEntity te) { + IMovableHandler handler = null; - private IMovableHandler testClass( final Class myClass, final TileEntity te ) - { - IMovableHandler handler = null; + // ask handlers... + for (final IMovableHandler han : this.handlers) { + if (han.canHandle(myClass, te)) { + handler = han; + break; + } + } - // ask handlers... - for( final IMovableHandler han : this.handlers ) - { - if( han.canHandle( myClass, te ) ) - { - handler = han; - break; - } - } + // if you have a handler your opted in + if (handler != null) { + this.Valid.put(myClass, handler); + return handler; + } - // if you have a handler your opted in - if( handler != null ) - { - this.Valid.put( myClass, handler ); - return handler; - } + // if your movable our opted in + if (te instanceof IMovableTile) { + this.Valid.put(myClass, this.dsh); + return this.dsh; + } - // if your movable our opted in - if( te instanceof IMovableTile ) - { - this.Valid.put( myClass, this.dsh ); - return this.dsh; - } + // if you are on the white list your opted in. + for (final Class testClass : this.test) { + if (testClass.isAssignableFrom(myClass)) { + this.Valid.put(myClass, this.dsh); + return this.dsh; + } + } - // if you are on the white list your opted in. - for( final Class testClass : this.test ) - { - if( testClass.isAssignableFrom( myClass ) ) - { - this.Valid.put( myClass, this.dsh ); - return this.dsh; - } - } + this.Valid.put(myClass, this.nullHandler); + return this.nullHandler; + } - this.Valid.put( myClass, this.nullHandler ); - return this.nullHandler; - } + @Override + public void doneMoving(final TileEntity te) { + if (te instanceof IMovableTile) { + final IMovableTile mt = (IMovableTile) te; + mt.doneMoving(); + } + } - @Override - public void doneMoving( final TileEntity te ) - { - if( te instanceof IMovableTile ) - { - final IMovableTile mt = (IMovableTile) te; - mt.doneMoving(); - } - } + @Override + public void addHandler(final IMovableHandler han) { + this.handlers.add(han); + } - @Override - public void addHandler( final IMovableHandler han ) - { - this.handlers.add( han ); - } + @Override + public IMovableHandler getHandler(final TileEntity te) { + final Class myClass = te.getClass(); + final IMovableHandler h = this.Valid.get(myClass); + return h == null ? this.dsh : h; + } - @Override - public IMovableHandler getHandler( final TileEntity te ) - { - final Class myClass = te.getClass(); - final IMovableHandler h = this.Valid.get( myClass ); - return h == null ? this.dsh : h; - } + @Override + public IMovableHandler getDefaultHandler() { + return this.dsh; + } - @Override - public IMovableHandler getDefaultHandler() - { - return this.dsh; - } - - @Override - public boolean isBlacklisted( final Block blk ) - { - return this.blacklisted.contains( blk ); - } + @Override + public boolean isBlacklisted(final Block blk) { + return this.blacklisted.contains(blk); + } } diff --git a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java index 39467935a..e97c429ac 100644 --- a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java +++ b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -46,36 +45,33 @@ import appeng.api.features.IP2PTunnelRegistry; import appeng.api.util.AEColor; import appeng.capabilities.Capabilities; +public final class P2PTunnelRegistry implements IP2PTunnelRegistry { + private static final int INITIAL_CAPACITY = 40; -public final class P2PTunnelRegistry implements IP2PTunnelRegistry -{ - private static final int INITIAL_CAPACITY = 40; + private final Map tunnels = new HashMap<>(INITIAL_CAPACITY); + private final Map modIdTunnels = new HashMap<>(INITIAL_CAPACITY); + private final Map, TunnelType> capTunnels = new HashMap<>(INITIAL_CAPACITY); - private final Map tunnels = new HashMap<>( INITIAL_CAPACITY ); - private final Map modIdTunnels = new HashMap<>( INITIAL_CAPACITY ); - private final Map, TunnelType> capTunnels = new HashMap<>( INITIAL_CAPACITY ); + public void configure() { - public void configure() - { + final IDefinitions definitions = AEApi.instance().definitions(); + final IBlocks blocks = definitions.blocks(); + final IParts parts = definitions.parts(); - final IDefinitions definitions = AEApi.instance().definitions(); - final IBlocks blocks = definitions.blocks(); - final IParts parts = definitions.parts(); + /** + * light! + */ + this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT); + this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT); - /** - * light! - */ - this.addNewAttunement( new ItemStack( Blocks.TORCH ), TunnelType.LIGHT ); - this.addNewAttunement( new ItemStack( Blocks.GLOWSTONE ), TunnelType.LIGHT ); + /** + * Forge energy tunnel items + */ - /** - * Forge energy tunnel items - */ - - this.addNewAttunement( blocks.energyCellDense(), TunnelType.FE_POWER ); - this.addNewAttunement( blocks.energyAcceptor(), TunnelType.FE_POWER ); - this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER ); - this.addNewAttunement( blocks.energyCellCreative(), TunnelType.FE_POWER ); + this.addNewAttunement(blocks.energyCellDense(), TunnelType.FE_POWER); + this.addNewAttunement(blocks.energyAcceptor(), TunnelType.FE_POWER); + this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER); + this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER); // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER ); // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER ); @@ -84,9 +80,9 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER ); // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER ); - /** - * EU tunnel items - */ + /** + * EU tunnel items + */ // FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable // FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable @@ -94,31 +90,31 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry // FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable // FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable - /** - * attune based on most redstone base items. - */ - this.addNewAttunement( new ItemStack( Items.REDSTONE ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Items.REPEATER ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.REDSTONE_LAMP ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.COMPARATOR ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.DAYLIGHT_DETECTOR ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.REDSTONE_WIRE ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.REDSTONE_BLOCK ), TunnelType.REDSTONE ); - this.addNewAttunement( new ItemStack( Blocks.LEVER ), TunnelType.REDSTONE ); + /** + * attune based on most redstone base items. + */ + this.addNewAttunement(new ItemStack(Items.REDSTONE), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Items.REPEATER), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.REDSTONE_LAMP), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.COMPARATOR), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.DAYLIGHT_DETECTOR), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.REDSTONE_WIRE), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.REDSTONE_BLOCK), TunnelType.REDSTONE); + this.addNewAttunement(new ItemStack(Blocks.LEVER), TunnelType.REDSTONE); - /** - * attune based on lots of random item related stuff - */ + /** + * attune based on lots of random item related stuff + */ - 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(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( new ItemStack( Blocks.HOPPER ), TunnelType.ITEM ); - this.addNewAttunement( new ItemStack( Blocks.CHEST ), TunnelType.ITEM ); - this.addNewAttunement( new ItemStack( Blocks.TRAPPED_CHEST ), 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); // FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM ); // FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM ); // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct @@ -128,15 +124,15 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry // FIXME // itemduct // FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse // FIXME // itemduct - // (opaque) + // (opaque) - /** - * attune based on lots of random item related stuff - */ - this.addNewAttunement( new ItemStack( Items.BUCKET ), TunnelType.FLUID ); - this.addNewAttunement( new ItemStack( Items.LAVA_BUCKET ), TunnelType.FLUID ); - this.addNewAttunement( new ItemStack( Items.MILK_BUCKET ), TunnelType.FLUID ); - this.addNewAttunement( new ItemStack( Items.WATER_BUCKET ), TunnelType.FLUID ); + /** + * attune based on lots of random item related stuff + */ + this.addNewAttunement(new ItemStack(Items.BUCKET), TunnelType.FLUID); + this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID); + this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID); + this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID); // FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID ); // FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID ); // FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID ); @@ -149,132 +145,115 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry // FIXME // hardened // FIXME // (opaque) // FIXME - for( final AEColor c : AEColor.values() ) - { - 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.cableDenseSmart().stack( c, 1 ), TunnelType.ME ); - } + for (final AEColor c : AEColor.values()) { + 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.cableDenseSmart().stack(c, 1), TunnelType.ME); + } - /** - * attune based caps - */ - this.addNewAttunement( Capabilities.FORGE_ENERGY, TunnelType.FE_POWER ); - this.addNewAttunement( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID ); + /** + * attune based caps + */ + this.addNewAttunement(Capabilities.FORGE_ENERGY, TunnelType.FE_POWER); + this.addNewAttunement(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID); - /** - * attune based on the ItemStack's modId - */ + /** + * attune based on the ItemStack's modId + */ - this.addNewAttunement( "thermaldynamics", TunnelType.FE_POWER ); - this.addNewAttunement( "thermalexpansion", TunnelType.FE_POWER ); - this.addNewAttunement( "thermalfoundation", TunnelType.FE_POWER ); - // TODO: Remove when confirmed that the official 1.12 version of EnderIO will support FE. - this.addNewAttunement( "enderio", TunnelType.FE_POWER ); - // TODO: Remove when confirmed that the official 1.12 version of Mekanism will support FE. - this.addNewAttunement( "mekanism", TunnelType.FE_POWER ); - // TODO: Remove when support for RFTools' Powercells support is added - this.addNewAttunement( "rftools", TunnelType.FE_POWER ); - this.addNewAttunement( "ic2", TunnelType.IC2_POWER ); + this.addNewAttunement("thermaldynamics", TunnelType.FE_POWER); + this.addNewAttunement("thermalexpansion", TunnelType.FE_POWER); + this.addNewAttunement("thermalfoundation", TunnelType.FE_POWER); + // TODO: Remove when confirmed that the official 1.12 version of EnderIO will + // support FE. + this.addNewAttunement("enderio", TunnelType.FE_POWER); + // TODO: Remove when confirmed that the official 1.12 version of Mekanism will + // support FE. + this.addNewAttunement("mekanism", TunnelType.FE_POWER); + // TODO: Remove when support for RFTools' Powercells support is added + this.addNewAttunement("rftools", TunnelType.FE_POWER); + this.addNewAttunement("ic2", TunnelType.IC2_POWER); - } + } - @Override - public void addNewAttunement( @Nonnull final String modId, @Nullable final TunnelType type ) - { - if( type == null || modId == null ) - { - return; - } - this.modIdTunnels.put( modId, type ); - } + @Override + public void addNewAttunement(@Nonnull final String modId, @Nullable final TunnelType type) { + if (type == null || modId == null) { + return; + } + this.modIdTunnels.put(modId, type); + } - @Override - public void addNewAttunement( @Nonnull final Capability cap, @Nullable final TunnelType type ) - { - if( type == null || cap == null ) - { - return; - } - this.capTunnels.put( cap, type ); - } + @Override + public void addNewAttunement(@Nonnull final Capability cap, @Nullable final TunnelType type) { + if (type == null || cap == null) { + return; + } + this.capTunnels.put(cap, type); + } - @Override - public void addNewAttunement( @Nonnull final ItemStack trigger, @Nullable final TunnelType type ) - { - if( type == null || trigger.isEmpty() ) - { - return; - } + @Override + public void addNewAttunement(@Nonnull final ItemStack trigger, @Nullable final TunnelType type) { + if (type == null || trigger.isEmpty()) { + return; + } - this.tunnels.put( trigger, type ); - } + this.tunnels.put(trigger, type); + } - @Nullable - @Override - public TunnelType getTunnelTypeByItem( final ItemStack trigger ) - { - if( !trigger.isEmpty() ) - { - // First match exact items - for( final Entry entry : this.tunnels.entrySet() ) - { - final ItemStack is = entry.getKey(); + @Nullable + @Override + public TunnelType getTunnelTypeByItem(final ItemStack trigger) { + if (!trigger.isEmpty()) { + // First match exact items + for (final Entry entry : this.tunnels.entrySet()) { + final ItemStack is = entry.getKey(); - if( is.getItem() == trigger.getItem() ) - { - return entry.getValue(); - } + if (is.getItem() == trigger.getItem()) { + return entry.getValue(); + } - if( ItemStack.areItemsEqual( is, trigger ) ) - { - return entry.getValue(); - } - } + if (ItemStack.areItemsEqual(is, trigger)) { + return entry.getValue(); + } + } - // Next, check if the Item you're holding supports any registered capability - for( Direction face : Direction.values() ) - { - for( Entry, TunnelType> entry : this.capTunnels.entrySet() ) - { - if( trigger.getCapability( entry.getKey(), face ).isPresent() ) - { - return entry.getValue(); - } - } - } + // Next, check if the Item you're holding supports any registered capability + for (Direction face : Direction.values()) { + for (Entry, TunnelType> entry : this.capTunnels.entrySet()) { + if (trigger.getCapability(entry.getKey(), face).isPresent()) { + return entry.getValue(); + } + } + } - // Use the mod id as last option. - for( final Entry entry : this.modIdTunnels.entrySet() ) - { - if( trigger.getItem().getRegistryName() != null && trigger.getItem().getRegistryName().getNamespace().equals( entry.getKey() ) ) - { - return entry.getValue(); - } - } - } + // Use the mod id as last option. + for (final Entry entry : this.modIdTunnels.entrySet()) { + if (trigger.getItem().getRegistryName() != null + && trigger.getItem().getRegistryName().getNamespace().equals(entry.getKey())) { + return entry.getValue(); + } + } + } - return null; - } + return null; + } - @Nonnull - private ItemStack getModItem( final String modID, final String name ) - { + @Nonnull + private ItemStack getModItem(final String modID, final String name) { - final Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( modID + ":" + name ) ); + final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(modID + ":" + name)); - if( item == null ) - { - return ItemStack.EMPTY; - } + if (item == null) { + return ItemStack.EMPTY; + } - final ItemStack myItemStack = new ItemStack( item, 1 ); - return myItemStack; - } + final ItemStack myItemStack = new ItemStack(item, 1); + return myItemStack; + } - private void addNewAttunement( final IItemDefinition definition, final TunnelType type ) - { - definition.maybeStack( 1 ).ifPresent( definitionStack -> this.addNewAttunement( definitionStack, type ) ); - } + private void addNewAttunement(final IItemDefinition definition, final TunnelType type) { + definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type)); + } } diff --git a/src/main/java/appeng/core/features/registries/PartModels.java b/src/main/java/appeng/core/features/registries/PartModels.java index e90fae3e3..c2528cea0 100644 --- a/src/main/java/appeng/core/features/registries/PartModels.java +++ b/src/main/java/appeng/core/features/registries/PartModels.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -27,32 +26,26 @@ import net.minecraft.util.ResourceLocation; import appeng.api.parts.IPartModels; +public class PartModels implements IPartModels { -public class PartModels implements IPartModels -{ + private final Set models = new HashSet<>(); - private final Set models = new HashSet<>(); + private boolean initialized = false; - private boolean initialized = false; + @Override + public void registerModels(Collection partModels) { + if (this.initialized) { + throw new IllegalStateException("Cannot register models after the pre-initialization phase!"); + } - @Override - public void registerModels( Collection partModels ) - { - if( this.initialized ) - { - throw new IllegalStateException( "Cannot register models after the pre-initialization phase!" ); - } + this.models.addAll(partModels); + } - this.models.addAll( partModels ); - } + public Set getModels() { + return this.models; + } - public Set getModels() - { - return this.models; - } - - public void setInitialized( boolean initialized ) - { - this.initialized = initialized; - } + public void setInitialized(boolean initialized) { + this.initialized = initialized; + } } diff --git a/src/main/java/appeng/core/features/registries/PlayerRegistry.java b/src/main/java/appeng/core/features/registries/PlayerRegistry.java index 909bc9079..b300ce995 100644 --- a/src/main/java/appeng/core/features/registries/PlayerRegistry.java +++ b/src/main/java/appeng/core/features/registries/PlayerRegistry.java @@ -18,57 +18,48 @@ package appeng.core.features.registries; +import java.util.UUID; import javax.annotation.Nullable; -import appeng.core.AppEng; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; import appeng.api.features.IPlayerRegistry; +import appeng.core.AppEng; import appeng.core.worlddata.WorldData; -import java.util.UUID; +public class PlayerRegistry implements IPlayerRegistry { + @Override + public int getID(final GameProfile username) { + if (username == null || !username.isComplete()) { + return -1; + } -public class PlayerRegistry implements IPlayerRegistry -{ + return WorldData.instance().playerData().getMePlayerId(username); + } - @Override - public int getID( final GameProfile username ) - { - if( username == null || !username.isComplete() ) - { - return -1; - } + @Override + public int getID(final PlayerEntity player) { + return this.getID(player.getGameProfile()); + } - return WorldData.instance().playerData().getMePlayerId( username ); - } + @Nullable + @Override + public PlayerEntity findPlayer(final int playerID) { + UUID profileId = WorldData.instance().playerData().getProfileId(playerID); + if (profileId == null) { + return null; + } - @Override - public int getID( final PlayerEntity player ) - { - return this.getID( player.getGameProfile() ); - } + for (final PlayerEntity player : AppEng.proxy.getPlayers()) { + if (player.getUniqueID().equals(profileId)) { + return player; + } + } - @Nullable - @Override - public PlayerEntity findPlayer( final int playerID ) - { - UUID profileId = WorldData.instance().playerData().getProfileId(playerID); - if (profileId == null) { - return null; - } - - for( final PlayerEntity player : AppEng.proxy.getPlayers() ) - { - if( player.getUniqueID().equals( profileId ) ) - { - return player; - } - } - - return null; - } + return null; + } } diff --git a/src/main/java/appeng/core/features/registries/RegistryContainer.java b/src/main/java/appeng/core/features/registries/RegistryContainer.java index 3c5141a36..5ccbb2097 100644 --- a/src/main/java/appeng/core/features/registries/RegistryContainer.java +++ b/src/main/java/appeng/core/features/registries/RegistryContainer.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import appeng.api.features.IChargerRegistry; import appeng.api.features.ILocatableRegistry; import appeng.api.features.IMatterCannonAmmoRegistry; @@ -35,7 +34,6 @@ import appeng.api.storage.ICellRegistry; import appeng.core.features.registries.cell.CellRegistry; import appeng.core.features.registries.charger.ChargerRegistry; - /** * represents all registries * @@ -45,90 +43,77 @@ import appeng.core.features.registries.charger.ChargerRegistry; * @version rv5 * @since rv0 */ -public class RegistryContainer implements IRegistryContainer -{ - private final IChargerRegistry charger = new ChargerRegistry(); - private final ICellRegistry cell = new CellRegistry(); - private final ILocatableRegistry locatable = new LocatableRegistry(); - private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry(); - private final IWirelessTermRegistry wireless = new WirelessRegistry(); - private final IGridCacheRegistry gridCache = new GridCacheRegistry(); - private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry(); - private final IMovableRegistry movable = new MovableTileRegistry(); - private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry(); - private final IPlayerRegistry playerRegistry = new PlayerRegistry(); - private final IPartModels partModels = new PartModels(); +public class RegistryContainer implements IRegistryContainer { + private final IChargerRegistry charger = new ChargerRegistry(); + private final ICellRegistry cell = new CellRegistry(); + private final ILocatableRegistry locatable = new LocatableRegistry(); + private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry(); + private final IWirelessTermRegistry wireless = new WirelessRegistry(); + private final IGridCacheRegistry gridCache = new GridCacheRegistry(); + private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry(); + private final IMovableRegistry movable = new MovableTileRegistry(); + private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry(); + private final IPlayerRegistry playerRegistry = new PlayerRegistry(); + private final IPartModels partModels = new PartModels(); - @Override - public IMovableRegistry movable() - { - return this.movable; - } + @Override + public IMovableRegistry movable() { + return this.movable; + } - @Override - public IGridCacheRegistry gridCache() - { - return this.gridCache; - } + @Override + public IGridCacheRegistry gridCache() { + return this.gridCache; + } - @Override - public ISpecialComparisonRegistry specialComparison() - { - return this.comparison; - } + @Override + public ISpecialComparisonRegistry specialComparison() { + return this.comparison; + } - @Override - public IWirelessTermRegistry wireless() - { - return this.wireless; - } + @Override + public IWirelessTermRegistry wireless() { + return this.wireless; + } - @Override - public ICellRegistry cell() - { - return this.cell; - } + @Override + public ICellRegistry cell() { + return this.cell; + } - @Override - public IChargerRegistry charger() - { - return this.charger; - } + @Override + public IChargerRegistry charger() { + return this.charger; + } - @Override - public ILocatableRegistry locatable() - { - return this.locatable; - } + @Override + public ILocatableRegistry locatable() { + return this.locatable; + } - @Override - public IP2PTunnelRegistry p2pTunnel() - { - return this.p2pTunnel; - } + @Override + public IP2PTunnelRegistry p2pTunnel() { + return this.p2pTunnel; + } - @Override - public IMatterCannonAmmoRegistry matterCannon() - { - return this.matterCannonReg; - } + @Override + public IMatterCannonAmmoRegistry matterCannon() { + return this.matterCannonReg; + } - @Override - public IPlayerRegistry players() - { - return this.playerRegistry; - } + @Override + public IPlayerRegistry players() { + return this.playerRegistry; + } - @Override - public IWorldGen worldgen() - { - return WorldGenRegistry.INSTANCE; - } + @Override + public IWorldGen worldgen() { + return WorldGenRegistry.INSTANCE; + } - @Override - public IPartModels partModels() - { - return this.partModels; - } + @Override + public IPartModels partModels() { + return this.partModels; + } } diff --git a/src/main/java/appeng/core/features/registries/SpecialComparisonRegistry.java b/src/main/java/appeng/core/features/registries/SpecialComparisonRegistry.java index d62fa3871..75a0f6cd9 100644 --- a/src/main/java/appeng/core/features/registries/SpecialComparisonRegistry.java +++ b/src/main/java/appeng/core/features/registries/SpecialComparisonRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries; - import java.util.ArrayList; import java.util.List; @@ -28,35 +27,28 @@ import appeng.api.features.IItemComparison; import appeng.api.features.IItemComparisonProvider; import appeng.api.features.ISpecialComparisonRegistry; +public class SpecialComparisonRegistry implements ISpecialComparisonRegistry { -public class SpecialComparisonRegistry implements ISpecialComparisonRegistry -{ + private final List CompRegistry; - private final List CompRegistry; + public SpecialComparisonRegistry() { + this.CompRegistry = new ArrayList<>(); + } - public SpecialComparisonRegistry() - { - this.CompRegistry = new ArrayList<>(); - } + @Override + public IItemComparison getSpecialComparison(final ItemStack stack) { + for (final IItemComparisonProvider i : this.CompRegistry) { + final IItemComparison comp = i.getComparison(stack); + if (comp != null) { + return comp; + } + } - @Override - public IItemComparison getSpecialComparison( final ItemStack stack ) - { - for( final IItemComparisonProvider i : this.CompRegistry ) - { - final IItemComparison comp = i.getComparison( stack ); - if( comp != null ) - { - return comp; - } - } + return null; + } - return null; - } - - @Override - public void addComparisonProvider( final IItemComparisonProvider prov ) - { - this.CompRegistry.add( prov ); - } + @Override + public void addComparisonProvider(final IItemComparisonProvider prov) { + this.CompRegistry.add(prov); + } } diff --git a/src/main/java/appeng/core/features/registries/WirelessRegistry.java b/src/main/java/appeng/core/features/registries/WirelessRegistry.java index 82d58a6c4..9dd347fe5 100644 --- a/src/main/java/appeng/core/features/registries/WirelessRegistry.java +++ b/src/main/java/appeng/core/features/registries/WirelessRegistry.java @@ -18,14 +18,9 @@ package appeng.core.features.registries; - import java.util.ArrayList; import java.util.List; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerMEPortableCell; -import appeng.container.implementations.ContainerWirelessTerm; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; @@ -35,92 +30,76 @@ import appeng.api.AEApi; import appeng.api.features.ILocatable; import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermRegistry; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerMEPortableCell; +import appeng.container.implementations.ContainerWirelessTerm; import appeng.core.localization.PlayerMessages; - import appeng.util.Platform; +public final class WirelessRegistry implements IWirelessTermRegistry { + private final List handlers; -public final class WirelessRegistry implements IWirelessTermRegistry -{ - private final List handlers; + public WirelessRegistry() { + this.handlers = new ArrayList<>(); + } - public WirelessRegistry() - { - this.handlers = new ArrayList<>(); - } + @Override + public void registerWirelessHandler(final IWirelessTermHandler handler) { + if (handler != null) { + this.handlers.add(handler); + } + } - @Override - public void registerWirelessHandler( final IWirelessTermHandler handler ) - { - if( handler != null ) - { - this.handlers.add( handler ); - } - } + @Override + public boolean isWirelessTerminal(final ItemStack is) { + for (final IWirelessTermHandler h : this.handlers) { + if (h.canHandle(is)) { + return true; + } + } + return false; + } - @Override - public boolean isWirelessTerminal( final ItemStack is ) - { - for( final IWirelessTermHandler h : this.handlers ) - { - if( h.canHandle( is ) ) - { - return true; - } - } - return false; - } + @Override + public IWirelessTermHandler getWirelessTerminalHandler(final ItemStack is) { + for (final IWirelessTermHandler h : this.handlers) { + if (h.canHandle(is)) { + return h; + } + } + return null; + } - @Override - public IWirelessTermHandler getWirelessTerminalHandler( final ItemStack is ) - { - for( final IWirelessTermHandler h : this.handlers ) - { - if( h.canHandle( is ) ) - { - return h; - } - } - return null; - } + @Override + public void openWirelessTerminalGui(ItemStack item, IBlockReader world, PlayerEntity player, Hand hand) { + if (Platform.isClient()) { + return; + } - @Override - public void openWirelessTerminalGui( ItemStack item, IBlockReader world, PlayerEntity player, Hand hand ) - { - if( Platform.isClient() ) - { - return; - } + if (!this.isWirelessTerminal(item)) { + player.sendMessage(PlayerMessages.DeviceNotWirelessTerminal.get()); + return; + } - if( !this.isWirelessTerminal( item ) ) - { - player.sendMessage( PlayerMessages.DeviceNotWirelessTerminal.get() ); - return; - } + final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item); + final String unparsedKey = handler.getEncryptionKey(item); + if (unparsedKey.isEmpty()) { + player.sendMessage(PlayerMessages.DeviceNotLinked.get()); + return; + } - final IWirelessTermHandler handler = this.getWirelessTerminalHandler( item ); - final String unparsedKey = handler.getEncryptionKey( item ); - if( unparsedKey.isEmpty() ) - { - player.sendMessage( PlayerMessages.DeviceNotLinked.get() ); - return; - } + final long parsedKey = Long.parseLong(unparsedKey); + final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey); + if (securityStation == null) { + player.sendMessage(PlayerMessages.StationCanNotBeLocated.get()); + return; + } - final long parsedKey = Long.parseLong( unparsedKey ); - final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy( parsedKey ); - if( securityStation == null ) - { - player.sendMessage( PlayerMessages.StationCanNotBeLocated.get() ); - return; - } - - if( handler.hasPower( player, 0.5, item ) ) - { - ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand)); - } - else - { - player.sendMessage( PlayerMessages.DeviceNotPowered.get() ); - } - } + if (handler.hasPower(player, 0.5, item)) { + ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand)); + } else { + player.sendMessage(PlayerMessages.DeviceNotPowered.get()); + } + } } diff --git a/src/main/java/appeng/core/features/registries/WorldGenRegistry.java b/src/main/java/appeng/core/features/registries/WorldGenRegistry.java index 3a1a24409..34b959191 100644 --- a/src/main/java/appeng/core/features/registries/WorldGenRegistry.java +++ b/src/main/java/appeng/core/features/registries/WorldGenRegistry.java @@ -18,109 +18,91 @@ package appeng.core.features.registries; - import java.util.HashSet; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.world.dimension.Dimension; - -import appeng.api.features.IWorldGen; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.common.extensions.IForgeDimension; +import appeng.api.features.IWorldGen; -public final class WorldGenRegistry implements IWorldGen -{ +public final class WorldGenRegistry implements IWorldGen { - public static final WorldGenRegistry INSTANCE = new WorldGenRegistry(); - private final TypeSet[] types; + public static final WorldGenRegistry INSTANCE = new WorldGenRegistry(); + private final TypeSet[] types; - private WorldGenRegistry() - { + private WorldGenRegistry() { - this.types = new TypeSet[WorldGenType.values().length]; + this.types = new TypeSet[WorldGenType.values().length]; - for( final WorldGenType type : WorldGenType.values() ) - { - this.types[type.ordinal()] = new TypeSet(); - } - } + for (final WorldGenType type : WorldGenType.values()) { + this.types[type.ordinal()] = new TypeSet(); + } + } - @Override - public void disableWorldGenForProviderID( WorldGenType type, Class provider ) - { - if( type == null ) - { - throw new IllegalArgumentException( "Bad Type Passed" ); - } + @Override + public void disableWorldGenForProviderID(WorldGenType type, Class provider) { + if (type == null) { + throw new IllegalArgumentException("Bad Type Passed"); + } - if( provider == null ) - { - throw new IllegalArgumentException( "Bad Provider Passed" ); - } + if (provider == null) { + throw new IllegalArgumentException("Bad Provider Passed"); + } - this.types[type.ordinal()].badProviders.add( provider ); - } + this.types[type.ordinal()].badProviders.add(provider); + } - @Override - public void enableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID ) - { - if( type == null ) - { - throw new IllegalArgumentException( "Bad Type Passed" ); - } + @Override + public void enableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) { + if (type == null) { + throw new IllegalArgumentException("Bad Type Passed"); + } - this.types[type.ordinal()].enabledDimensions.add( dimensionID ); - } + this.types[type.ordinal()].enabledDimensions.add(dimensionID); + } - @Override - public void disableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID ) - { - if( type == null ) - { - throw new IllegalArgumentException( "Bad Type Passed" ); - } + @Override + public void disableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) { + if (type == null) { + throw new IllegalArgumentException("Bad Type Passed"); + } - this.types[type.ordinal()].badDimensions.add( dimensionID ); - } + this.types[type.ordinal()].badDimensions.add(dimensionID); + } - @Override - public boolean isWorldGenEnabled( final WorldGenType type, final World w ) - { - if( type == null ) - { - throw new IllegalArgumentException( "Bad Type Passed" ); - } + @Override + public boolean isWorldGenEnabled(final WorldGenType type, final World w) { + if (type == null) { + throw new IllegalArgumentException("Bad Type Passed"); + } - if( w == null ) - { - throw new IllegalArgumentException( "Bad Provider Passed" ); - } + if (w == null) { + throw new IllegalArgumentException("Bad Provider Passed"); + } - ResourceLocation id = w.dimension.getDimension().getType().getRegistryName(); - final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.dimension.getClass() ); - final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( id ); - final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains( id ); + ResourceLocation id = w.dimension.getDimension().getType().getRegistryName(); + final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains(w.dimension.getClass()); + final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains(id); + final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains(id); - if( isBadProvider || isBadDimension ) - { - return false; - } + if (isBadProvider || isBadDimension) { + return false; + } - if( !isGoodDimension && type == WorldGenType.METEORITES ) - { - return false; - } + if (!isGoodDimension && type == WorldGenType.METEORITES) { + return false; + } - return true; - } + return true; + } - private static class TypeSet - { + private static class TypeSet { - final HashSet> badProviders = new HashSet<>(); - final HashSet badDimensions = new HashSet<>(); - final HashSet enabledDimensions = new HashSet<>(); - } + final HashSet> badProviders = new HashSet<>(); + final HashSet badDimensions = new HashSet<>(); + final HashSet enabledDimensions = new HashSet<>(); + } } diff --git a/src/main/java/appeng/core/features/registries/cell/BasicCellHandler.java b/src/main/java/appeng/core/features/registries/cell/BasicCellHandler.java index c4fba4323..338eeb874 100644 --- a/src/main/java/appeng/core/features/registries/cell/BasicCellHandler.java +++ b/src/main/java/appeng/core/features/registries/cell/BasicCellHandler.java @@ -18,7 +18,6 @@ package appeng.core.features.registries.cell; - import net.minecraft.item.ItemStack; import appeng.api.storage.ICellHandler; @@ -30,25 +29,21 @@ import appeng.api.storage.data.IAEStack; import appeng.me.storage.BasicCellInventory; import appeng.me.storage.BasicCellInventoryHandler; +public class BasicCellHandler implements ICellHandler { -public class BasicCellHandler implements ICellHandler -{ + @Override + public boolean isCell(final ItemStack is) { + return BasicCellInventory.isCell(is); + } - @Override - public boolean isCell( final ItemStack is ) - { - return BasicCellInventory.isCell( is ); - } - - @Override - public > ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel ) - { - final ICellInventory inv = BasicCellInventory.createInventory( is, container ); - if( inv == null || inv.getChannel() != channel ) - { - return null; - } - return new BasicCellInventoryHandler<>( inv, channel ); - } + @Override + public > ICellInventoryHandler getCellInventory(final ItemStack is, + final ISaveProvider container, final IStorageChannel channel) { + final ICellInventory inv = BasicCellInventory.createInventory(is, container); + if (inv == null || inv.getChannel() != channel) { + return null; + } + return new BasicCellInventoryHandler<>(inv, channel); + } } diff --git a/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java b/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java index b88304f33..f0afd54ef 100644 --- a/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java +++ b/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java @@ -1,11 +1,6 @@ package appeng.core.features.registries.cell; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerMEMonitorable; -import appeng.container.implementations.ContainerWireless; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -19,21 +14,22 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.util.AEPartLocation; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerMEMonitorable; +import appeng.container.implementations.ContainerWireless; import appeng.util.Platform; +public class BasicItemCellGuiHandler implements ICellGuiHandler { + @Override + public > boolean isHandlerFor(final IStorageChannel channel) { + return channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } -public class BasicItemCellGuiHandler implements ICellGuiHandler -{ - @Override - public > boolean isHandlerFor( final IStorageChannel channel ) - { - return channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } - - @Override - public void openChestGui( final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan ) - { - ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp())); - } + @Override + public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, + final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) { + ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player, + ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp())); + } } diff --git a/src/main/java/appeng/core/features/registries/cell/CellRegistry.java b/src/main/java/appeng/core/features/registries/cell/CellRegistry.java index cf50ace97..93f13b489 100644 --- a/src/main/java/appeng/core/features/registries/cell/CellRegistry.java +++ b/src/main/java/appeng/core/features/registries/cell/CellRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries.cell; - import java.util.ArrayList; import java.util.List; @@ -35,108 +34,88 @@ import appeng.api.storage.ISaveProvider; import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; +public class CellRegistry implements ICellRegistry { -public class CellRegistry implements ICellRegistry -{ + private final List handlers; + private final List guiHandlers; - private final List handlers; - private final List guiHandlers; + public CellRegistry() { + this.handlers = new ArrayList<>(); + this.guiHandlers = new ArrayList<>(); + } - public CellRegistry() - { - this.handlers = new ArrayList<>(); - this.guiHandlers = new ArrayList<>(); - } + @Override + public void addCellHandler(final ICellHandler handler) { + Preconditions.checkNotNull(handler, "Called before FMLCommonSetupEvent."); + Preconditions.checkArgument(!this.handlers.contains(handler), + "Tried to register the same handler instance twice."); - @Override - public void addCellHandler( final ICellHandler handler ) - { - Preconditions.checkNotNull( handler, "Called before FMLCommonSetupEvent." ); - Preconditions.checkArgument( !this.handlers.contains( handler ), "Tried to register the same handler instance twice." ); + this.handlers.add(handler); - this.handlers.add( handler ); + // Verify that the first entry is always our own handler. + Verify.verify(this.handlers.get(0) instanceof BasicCellHandler); + } - // Verify that the first entry is always our own handler. - Verify.verify( this.handlers.get( 0 ) instanceof BasicCellHandler ); - } + @Override + public boolean isCellHandled(final ItemStack is) { + if (is.isEmpty()) { + return false; + } + for (final ICellHandler ch : this.handlers) { + if (ch.isCell(is)) { + return true; + } + } + return false; + } - @Override - public boolean isCellHandled( final ItemStack is ) - { - if( is.isEmpty() ) - { - return false; - } - for( final ICellHandler ch : this.handlers ) - { - if( ch.isCell( is ) ) - { - return true; - } - } - return false; - } + @Override + public ICellHandler getHandler(final ItemStack is) { + if (is.isEmpty()) { + return null; + } + for (final ICellHandler ch : this.handlers) { + if (ch.isCell(is)) { + return ch; + } + } + return null; + } - @Override - public ICellHandler getHandler( final ItemStack is ) - { - if( is.isEmpty() ) - { - return null; - } - for( final ICellHandler ch : this.handlers ) - { - if( ch.isCell( is ) ) - { - return ch; - } - } - return null; - } + @Override + public > ICellInventoryHandler getCellInventory(final ItemStack is, + final ISaveProvider container, final IStorageChannel chan) { + if (is.isEmpty()) { + return null; + } + for (final ICellHandler ch : this.handlers) { + if (ch.isCell(is)) { + return ch.getCellInventory(is, container, chan); + } + } + return null; + } - @Override - public > ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel chan ) - { - if( is.isEmpty() ) - { - return null; - } - for( final ICellHandler ch : this.handlers ) - { - if( ch.isCell( is ) ) - { - return ch.getCellInventory( is, container, chan ); - } - } - return null; - } + @Override + public void addCellGuiHandler(ICellGuiHandler handler) { + this.guiHandlers.add(handler); + } - @Override - public void addCellGuiHandler( ICellGuiHandler handler ) - { - this.guiHandlers.add( handler ); - } + @Override + public > ICellGuiHandler getGuiHandler(final IStorageChannel channel, final ItemStack is) { + ICellGuiHandler fallBack = null; - @Override - public > ICellGuiHandler getGuiHandler( final IStorageChannel channel, final ItemStack is ) - { - ICellGuiHandler fallBack = null; + for (final ICellGuiHandler ch : this.guiHandlers) { + if (ch.isHandlerFor(channel)) { + if (ch.isSpecializedFor(is)) { + return ch; + } - for( final ICellGuiHandler ch : this.guiHandlers ) - { - if( ch.isHandlerFor( channel ) ) - { - if( ch.isSpecializedFor( is ) ) - { - return ch; - } - - if( fallBack == null ) - { - fallBack = ch; - } - } - } - return fallBack; - } + if (fallBack == null) { + fallBack = ch; + } + } + } + return fallBack; + } } diff --git a/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java b/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java index 4a9f3e81c..96c5b9700 100644 --- a/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java +++ b/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java @@ -18,7 +18,6 @@ package appeng.core.features.registries.cell; - import net.minecraft.item.ItemStack; import appeng.api.AEApi; @@ -30,36 +29,30 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.items.storage.ItemCreativeStorageCell; import appeng.me.storage.CreativeCellInventory; +public final class CreativeCellHandler implements ICellHandler { -public final class CreativeCellHandler implements ICellHandler -{ + @Override + public boolean isCell(final ItemStack is) { + return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell; + } - @Override - public boolean isCell( final ItemStack is ) - { - return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell; - } + @Override + public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container, + final IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty() + && is.getItem() instanceof ItemCreativeStorageCell) { + return CreativeCellInventory.getCell(is); + } + return null; + } - @Override - public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is - .getItem() instanceof ItemCreativeStorageCell ) - { - return CreativeCellInventory.getCell( is ); - } - return null; - } + @Override + public int getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) { + return 2; + } - @Override - public int getStatusForCell( final ItemStack is, final ICellInventoryHandler handler ) - { - return 2; - } - - @Override - public double cellIdleDrain( final ItemStack is, final ICellInventoryHandler handler ) - { - return 0; - } + @Override + public double cellIdleDrain(final ItemStack is, final ICellInventoryHandler handler) { + return 0; + } } diff --git a/src/main/java/appeng/core/features/registries/charger/ChargerRegistry.java b/src/main/java/appeng/core/features/registries/charger/ChargerRegistry.java index 743252db4..969162319 100644 --- a/src/main/java/appeng/core/features/registries/charger/ChargerRegistry.java +++ b/src/main/java/appeng/core/features/registries/charger/ChargerRegistry.java @@ -18,7 +18,6 @@ package appeng.core.features.registries.charger; - import java.util.IdentityHashMap; import java.util.Map; @@ -31,45 +30,39 @@ import net.minecraft.item.Item; import appeng.api.features.IChargerRegistry; +public class ChargerRegistry implements IChargerRegistry { + private static final double DEFAULT_CHARGE_RATE = 160d; + private static final double CAPPED_CHARGE_RATE = 16000d; -public class ChargerRegistry implements IChargerRegistry -{ - private static final double DEFAULT_CHARGE_RATE = 160d; - private static final double CAPPED_CHARGE_RATE = 16000d; + private final Map chargeRates; - private final Map chargeRates; + public ChargerRegistry() { + this.chargeRates = new IdentityHashMap<>(); + } - public ChargerRegistry() - { - this.chargeRates = new IdentityHashMap<>(); - } + @Override + @Nonnegative + public double getChargeRate(@Nonnull Item item) { + Preconditions.checkNotNull(item); - @Override - @Nonnegative - public double getChargeRate( @Nonnull Item item ) - { - Preconditions.checkNotNull( item ); + return this.chargeRates.getOrDefault(item, DEFAULT_CHARGE_RATE); + } - return this.chargeRates.getOrDefault( item, DEFAULT_CHARGE_RATE ); - } + @Override + public void addChargeRate(@Nonnull Item item, @Nonnegative double value) { + Preconditions.checkNotNull(item); + Preconditions.checkArgument(value > 0d); - @Override - public void addChargeRate( @Nonnull Item item, @Nonnegative double value ) - { - Preconditions.checkNotNull( item ); - Preconditions.checkArgument( value > 0d ); + final double cappedValue = Math.min(value, CAPPED_CHARGE_RATE); - final double cappedValue = Math.min( value, CAPPED_CHARGE_RATE ); + this.chargeRates.put(item, cappedValue); + } - this.chargeRates.put( item, cappedValue ); - } + @Override + public void removeChargeRate(@Nonnull Item item) { + Preconditions.checkNotNull(item); - @Override - public void removeChargeRate( @Nonnull Item item ) - { - Preconditions.checkNotNull( item ); - - this.chargeRates.remove( item ); - } + this.chargeRates.remove(item); + } } diff --git a/src/main/java/appeng/core/localization/ButtonToolTips.java b/src/main/java/appeng/core/localization/ButtonToolTips.java index 59dff767b..8c8d7a6b9 100644 --- a/src/main/java/appeng/core/localization/ButtonToolTips.java +++ b/src/main/java/appeng/core/localization/ButtonToolTips.java @@ -18,161 +18,76 @@ package appeng.core.localization; - import net.minecraft.client.resources.I18n; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +public enum ButtonToolTips { + PowerUnits, IOMode, CondenserOutput, RedstoneMode, MatchingFuzzy, -public enum ButtonToolTips -{ - PowerUnits, - IOMode, - CondenserOutput, - RedstoneMode, - MatchingFuzzy, + MatchingMode, TransferDirection, SortOrder, SortBy, View, - MatchingMode, - TransferDirection, - SortOrder, - SortBy, - View, + PartitionStorage, Clear, FuzzyMode, OperationMode, TrashController, - PartitionStorage, - Clear, - FuzzyMode, - OperationMode, - TrashController, + InterfaceBlockingMode, InterfaceCraftingMode, Trash, MatterBalls, - InterfaceBlockingMode, - InterfaceCraftingMode, - Trash, - MatterBalls, + Singularity, Read, Write, ReadWrite, AlwaysActive, - Singularity, - Read, - Write, - ReadWrite, - AlwaysActive, + ActiveWithoutSignal, ActiveWithSignal, ActiveOnPulse, - ActiveWithoutSignal, - ActiveWithSignal, - ActiveOnPulse, + EmitLevelsBelow, EmitLevelAbove, MatchingExact, TransferToNetwork, - EmitLevelsBelow, - EmitLevelAbove, - MatchingExact, - TransferToNetwork, + TransferToStorageCell, ToggleSortDirection, - TransferToStorageCell, - ToggleSortDirection, + SearchMode_Auto, SearchMode_Standard, SearchMode_JEIAuto, SearchMode_JEIStandard, SearchMode_AutoKeep, + SearchMode_StandardKeep, SearchMode_JEIAutoKeep, SearchMode_JEIStandardKeep, - SearchMode_Auto, - SearchMode_Standard, - SearchMode_JEIAuto, - SearchMode_JEIStandard, - SearchMode_AutoKeep, - SearchMode_StandardKeep, - SearchMode_JEIAutoKeep, - SearchMode_JEIStandardKeep, + SearchMode, ItemName, NumberOfItems, PartitionStorageHint, - SearchMode, - ItemName, - NumberOfItems, - PartitionStorageHint, + ClearSettings, StoredItems, StoredCraftable, Craftable, - ClearSettings, - StoredItems, - StoredCraftable, - Craftable, + FZPercent_25, FZPercent_50, FZPercent_75, FZPercent_99, FZIgnoreAll, - FZPercent_25, - FZPercent_50, - FZPercent_75, - FZPercent_99, - FZIgnoreAll, + MoveWhenEmpty, MoveWhenWorkIsDone, MoveWhenFull, Disabled, Enable, - MoveWhenEmpty, - MoveWhenWorkIsDone, - MoveWhenFull, - Disabled, - Enable, + Blocking, NonBlocking, - Blocking, - NonBlocking, + LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, + TerminalStyle_Small, - LevelType, - LevelType_Energy, - LevelType_Item, - InventoryTweaks, - TerminalStyle, - TerminalStyle_Full, - TerminalStyle_Tall, - TerminalStyle_Small, + Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, + SubstitutionsDescEnabled, SubstitutionsDescDisabled, CraftOnly, CraftEither, - Stash, - StashDesc, - Encode, - EncodeDescription, - Substitutions, - SubstitutionsOn, - SubstitutionsOff, - SubstitutionsDescEnabled, - SubstitutionsDescDisabled, - CraftOnly, - CraftEither, + Craft, Mod, DoesntDespawn, EmitterMode, CraftViaRedstone, EmitWhenCrafting, ReportInaccessibleItems, + ReportInaccessibleItemsYes, ReportInaccessibleItemsNo, ReportInaccessibleFluids, ReportInaccessibleFluidsYes, + ReportInaccessibleFluidsNo, - Craft, - Mod, - DoesntDespawn, - EmitterMode, - CraftViaRedstone, - EmitWhenCrafting, - ReportInaccessibleItems, - ReportInaccessibleItemsYes, - ReportInaccessibleItemsNo, - ReportInaccessibleFluids, - ReportInaccessibleFluidsYes, - ReportInaccessibleFluidsNo, + BlockPlacement, BlockPlacementYes, BlockPlacementNo, - BlockPlacement, - BlockPlacementYes, - BlockPlacementNo, + // Used in the tooltips of the items in the terminal, when moused over + ItemsStored, ItemsRequestable, - // Used in the tooltips of the items in the terminal, when moused over - ItemsStored, - ItemsRequestable, + SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom, - SchedulingMode, - SchedulingModeDefault, - SchedulingModeRoundRobin, - SchedulingModeRandom, + FilterMode, FilterModeKeep, FilterModeClear; - FilterMode, - FilterModeKeep, - FilterModeClear; + private final String root; - private final String root; + ButtonToolTips() { + this.root = "gui.tooltips.appliedenergistics2"; + } - ButtonToolTips() - { - this.root = "gui.tooltips.appliedenergistics2"; - } + ButtonToolTips(final String r) { + this.root = r; + } - ButtonToolTips( final String r ) - { - this.root = r; - } + @Deprecated + public String getLocal() { + return getTranslationKey().getFormattedText(); + } - @Deprecated - public String getLocal() - { - return getTranslationKey().getFormattedText(); - } - - public ITextComponent getTranslationKey() - { - return new TranslationTextComponent( this.root + '.' + this.toString() ); - } + public ITextComponent getTranslationKey() { + return new TranslationTextComponent(this.root + '.' + this.toString()); + } } diff --git a/src/main/java/appeng/core/localization/GuiText.java b/src/main/java/appeng/core/localization/GuiText.java index 8c1f3dff6..dd4c201ef 100644 --- a/src/main/java/appeng/core/localization/GuiText.java +++ b/src/main/java/appeng/core/localization/GuiText.java @@ -18,207 +18,96 @@ package appeng.core.localization; - import net.minecraft.client.resources.I18n; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +public enum GuiText { + inventory("container"), // mc's default Inventory localization. -public enum GuiText -{ - inventory( "container" ), // mc's default Inventory localization. + Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest, - Chest, - StoredEnergy, - Of, - Condenser, - Drive, - GrindStone, - SkyChest, + VibrationChamber, SpatialIOPort, LevelEmitter, FluidLevelEmitter, Terminal, - VibrationChamber, - SpatialIOPort, - LevelEmitter, - FluidLevelEmitter, - Terminal, + Interface, FluidInterface, Config, StoredItems, StoredFluids, Patterns, ImportBus, ImportBusFluids, ExportBus, + ExportBusFluids, - Interface, - FluidInterface, - Config, - StoredItems, - StoredFluids, - Patterns, - ImportBus, - ImportBusFluids, - ExportBus, - ExportBusFluids, + CellWorkbench, NetworkDetails, StorageCells, IOBuses, IOBusesFluids, - CellWorkbench, - NetworkDetails, - StorageCells, - IOBuses, - IOBusesFluids, + IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell, - IOPort, - BytesUsed, - Types, - QuantumLinkChamber, - PortableCell, + NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain, - NetworkTool, - PowerUsageRate, - PowerInputRate, - Installed, - EnergyDrain, + StorageBus, StorageBusFluids, Priority, Security, Encoded, Blank, Unlinked, Linked, - StorageBus, - StorageBusFluids, - Priority, - Security, - Encoded, - Blank, - Unlinked, - Linked, + SecurityCardEditor, NoPermissions, WirelessTerminal, Wireless, - SecurityCardEditor, - NoPermissions, - WirelessTerminal, - Wireless, + CraftingTerminal, FormationPlane, FluidFormationPlane, Inscriber, QuartzCuttingKnife, - CraftingTerminal, - FormationPlane, - FluidFormationPlane, - Inscriber, - QuartzCuttingKnife, + // spatial + SpatialCapacity, StoredSize, Unformatted, SerialNumber, - // spatial - SpatialCapacity, - StoredSize, - Unformatted, - SerialNumber, + CopyMode, CopyModeDesc, PatternTerminal, - CopyMode, - CopyModeDesc, - PatternTerminal, + // Pattern tooltips + CraftingPattern, ProcessingPattern, Crafts, Creates, And, With, Substitute, Yes, No, - // Pattern tooltips - CraftingPattern, - ProcessingPattern, - Crafts, - Creates, - And, - With, - Substitute, - Yes, - No, + MolecularAssembler, - MolecularAssembler, + StoredPower, MaxPower, RequiredPower, Efficiency, SCSSize, SCSInvalid, InWorldCrafting, - StoredPower, - MaxPower, - RequiredPower, - Efficiency, - SCSSize, - SCSInvalid, - InWorldCrafting, + inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether, - inWorldFluix, - inWorldPurificationCertus, - inWorldPurificationNether, + inWorldPurificationFluix, inWorldSingularity, ChargedQuartz, - inWorldPurificationFluix, - inWorldSingularity, - ChargedQuartz, + NoSecondOutput, OfSecondOutput, MultipleOutputs, - NoSecondOutput, - OfSecondOutput, - MultipleOutputs, + Stores, Next, SelectAmount, Lumen, Empty, - Stores, - Next, - SelectAmount, - Lumen, - Empty, + ConfirmCrafting, Stored, Crafting, Scheduled, CraftingStatus, Cancel, ETA, ETAFormat, - ConfirmCrafting, - Stored, - Crafting, - Scheduled, - CraftingStatus, - Cancel, - ETA, - ETAFormat, + FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, - FromStorage, - ToCraft, - CraftingPlan, - CalculatingWait, - Start, - Bytes, + CraftingCPU, Automatic, CoProcessors, Simulation, Missing, - CraftingCPU, - Automatic, - CoProcessors, - Simulation, - Missing, + InterfaceTerminal, NoCraftingCPUs, Clean, InvalidPattern, - InterfaceTerminal, - NoCraftingCPUs, - Clean, - InvalidPattern, + InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint, - InterfaceTerminalHint, - Range, - TransparentFacades, - TransparentFacadesHint, + NoCraftingJobs, CPUs, FacadeCrafting, inWorldCraftingPresses, ChargedQuartzFind, - NoCraftingJobs, - CPUs, - FacadeCrafting, - inWorldCraftingPresses, - ChargedQuartzFind, + Included, Excluded, Partitioned, Precise, Fuzzy, - Included, - Excluded, - Partitioned, - Precise, - Fuzzy, + // Used in a terminal to indicate that an item is craftable + SmallFontCraft, LargeFontCraft, - // Used in a terminal to indicate that an item is craftable - SmallFontCraft, - LargeFontCraft, + // Used in a ME Interface when no appropriate TileEntity was detected near it + Nothing; - // Used in a ME Interface when no appropriate TileEntity was detected near it - Nothing; + private final String root; - private final String root; + GuiText() { + this.root = "gui.appliedenergistics2"; + } - GuiText() - { - this.root = "gui.appliedenergistics2"; - } + GuiText(final String r) { + this.root = r; + } - GuiText( final String r ) - { - this.root = r; - } + public String getLocal() { + return I18n.format(this.getTranslationKey()); + } - public String getLocal() - { - return I18n.format( this.getTranslationKey() ); - } + public String getTranslationKey() { + return this.root + '.' + this.toString(); + } - public String getTranslationKey() - { - return this.root + '.' + this.toString(); - } + public ITextComponent textComponent() { + return new TranslationTextComponent(getTranslationKey()); + } - public ITextComponent textComponent() { - return new TranslationTextComponent(getTranslationKey()); - } - - public ITextComponent textComponent(Object... args) { - return new TranslationTextComponent(getTranslationKey(), args); - } + public ITextComponent textComponent(Object... args) { + return new TranslationTextComponent(getTranslationKey(), args); + } } diff --git a/src/main/java/appeng/core/localization/PlayerMessages.java b/src/main/java/appeng/core/localization/PlayerMessages.java index 4ec946301..15a4dac79 100644 --- a/src/main/java/appeng/core/localization/PlayerMessages.java +++ b/src/main/java/appeng/core/localization/PlayerMessages.java @@ -18,39 +18,21 @@ package appeng.core.localization; - import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +public enum PlayerMessages { + ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, ResetSettings, MachineNotPowered, -public enum PlayerMessages -{ - ChestCannotReadStorageCell, - InvalidMachine, - LoadedSettings, - SavedSettings, - ResetSettings, - MachineNotPowered, + isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered, + DeviceNotWirelessTerminal, DeviceNotLinked, StationCanNotBeLocated, SettingCleared,; - isNowLocked, - isNowUnlocked, - AmmoDepleted, - CommunicationError, - OutOfRange, - DeviceNotPowered, - DeviceNotWirelessTerminal, - DeviceNotLinked, - StationCanNotBeLocated, - SettingCleared,; + public ITextComponent get() { + return new TranslationTextComponent(this.getTranslationKey()); + } - public ITextComponent get() - { - return new TranslationTextComponent( this.getTranslationKey() ); - } - - String getTranslationKey() - { - return "chat.appliedenergistics2." + this.toString(); - } + String getTranslationKey() { + return "chat.appliedenergistics2." + this.toString(); + } } diff --git a/src/main/java/appeng/core/localization/WailaText.java b/src/main/java/appeng/core/localization/WailaText.java index 69685f149..be2c62d69 100644 --- a/src/main/java/appeng/core/localization/WailaText.java +++ b/src/main/java/appeng/core/localization/WailaText.java @@ -18,62 +18,45 @@ package appeng.core.localization; - import net.minecraft.client.resources.I18n; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +public enum WailaText { + Crafting, -public enum WailaText -{ - Crafting, + DeviceOnline, DeviceOffline, DeviceMissingChannel, - DeviceOnline, - DeviceOffline, - DeviceMissingChannel, + P2PUnlinked, P2PInputOneOutput, P2PInputManyOutputs, P2POutput, - P2PUnlinked, - P2PInputOneOutput, - P2PInputManyOutputs, - P2POutput, + Locked, Unlocked, Showing, - Locked, - Unlocked, - Showing, + Contains, Channels; - Contains, - Channels; + private final String root; - private final String root; + WailaText() { + this.root = "waila.appliedenergistics2"; + } - WailaText() - { - this.root = "waila.appliedenergistics2"; - } + WailaText(final String r) { + this.root = r; + } - WailaText( final String r ) - { - this.root = r; - } + public String getLocal() { + return I18n.format(this.getTranslationKey()); + } - public String getLocal() - { - return I18n.format( this.getTranslationKey() ); - } + public String getTranslationKey() { + return this.root + '.' + this.toString(); + } - public String getTranslationKey() - { - return this.root + '.' + this.toString(); - } + public ITextComponent textComponent() { + return new TranslationTextComponent(this.root + '.' + this.toString()); + } - public ITextComponent textComponent() - { - return new TranslationTextComponent(this.root + '.' + this.toString()); - } - - public ITextComponent textComponent(Object... args) - { - return new TranslationTextComponent(this.root + '.' + this.toString(), args); - } + public ITextComponent textComponent(Object... args) { + return new TranslationTextComponent(this.root + '.' + this.toString(), args); + } } diff --git a/src/main/java/appeng/core/settings/TickRates.java b/src/main/java/appeng/core/settings/TickRates.java index 595467fbe..3046d96c4 100644 --- a/src/main/java/appeng/core/settings/TickRates.java +++ b/src/main/java/appeng/core/settings/TickRates.java @@ -18,82 +18,76 @@ package appeng.core.settings; -public enum TickRates -{ +public enum TickRates { - Interface( 5, 120 ), + Interface(5, 120), - ImportBus( 5, 40 ), + ImportBus(5, 40), - FluidImportBus( 5, 40 ), + FluidImportBus(5, 40), - ExportBus( 5, 60 ), + ExportBus(5, 60), - FluidExportBus( 5, 60 ), + FluidExportBus(5, 60), - AnnihilationPlane( 2, 120 ), + AnnihilationPlane(2, 120), - METunnel( 5, 20 ), + METunnel(5, 20), - Inscriber( 1, 1 ), + Inscriber(1, 1), - Charger( 10, 120 ), + Charger(10, 120), - IOPort( 1, 5 ), + IOPort(1, 5), - VibrationChamber( 10, 40 ), + VibrationChamber(10, 40), - StorageBus( 5, 60 ), + StorageBus(5, 60), - FluidStorageBus( 5, 60 ), + FluidStorageBus(5, 60), - ItemTunnel( 5, 60 ), + ItemTunnel(5, 60), - LightTunnel( 5, 60 ), + LightTunnel(5, 60), - OpenComputersTunnel( 1, 5 ), + OpenComputersTunnel(1, 5), - PressureTunnel( 1, 120 ); + PressureTunnel(1, 120); - private final int defaultMin; - private final int defaultMax; - private int min; - private int max; + private final int defaultMin; + private final int defaultMax; + private int min; + private int max; - TickRates( final int min, final int max ) - { - this.defaultMin = min; - this.defaultMax = max; - this.min = min; - this.max = max; - } + TickRates(final int min, final int max) { + this.defaultMin = min; + this.defaultMax = max; + this.min = min; + this.max = max; + } - public int getDefaultMin() { - return defaultMin; - } + public int getDefaultMin() { + return defaultMin; + } - public int getDefaultMax() { - return defaultMax; - } + public int getDefaultMax() { + return defaultMax; + } - public int getMax() - { - return this.max; - } + public int getMax() { + return this.max; + } - public void setMax( final int max ) - { - this.max = max; - } + public void setMax(final int max) { + this.max = max; + } - public int getMin() - { - return this.min; - } + public int getMin() { + return this.min; + } - public void setMin( final int min ) - { - this.min = min; - } + public void setMin(final int min) { + this.min = min; + } } diff --git a/src/main/java/appeng/core/stats/AdvancementTriggers.java b/src/main/java/appeng/core/stats/AdvancementTriggers.java index ded683317..cbb4d4512 100644 --- a/src/main/java/appeng/core/stats/AdvancementTriggers.java +++ b/src/main/java/appeng/core/stats/AdvancementTriggers.java @@ -18,42 +18,34 @@ package appeng.core.stats; - import appeng.bootstrap.ICriterionTriggerRegistry; +public class AdvancementTriggers { + private AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger("network_apprentice"); + private AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger("network_engineer"); + private AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger("network_admin"); + private AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger("spatial_explorer"); -public class AdvancementTriggers -{ - private AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger( "network_apprentice" ); - private AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger( "network_engineer" ); - private AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger( "network_admin" ); - private AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger( "spatial_explorer" ); + public AdvancementTriggers(ICriterionTriggerRegistry registry) { + registry.register(this.networkApprentice); + registry.register(this.networkEngineer); + registry.register(this.networkAdmin); + registry.register(this.spatialExplorer); + } - public AdvancementTriggers( ICriterionTriggerRegistry registry ) - { - registry.register( this.networkApprentice ); - registry.register( this.networkEngineer ); - registry.register( this.networkAdmin ); - registry.register( this.spatialExplorer ); - } + public IAdvancementTrigger getNetworkApprentice() { + return this.networkApprentice; + } - public IAdvancementTrigger getNetworkApprentice() - { - return this.networkApprentice; - } + public IAdvancementTrigger getNetworkEngineer() { + return this.networkEngineer; + } - public IAdvancementTrigger getNetworkEngineer() - { - return this.networkEngineer; - } + public IAdvancementTrigger getNetworkAdmin() { + return this.networkAdmin; + } - public IAdvancementTrigger getNetworkAdmin() - { - return this.networkAdmin; - } - - public IAdvancementTrigger getSpatialExplorer() - { - return this.spatialExplorer; - } + public IAdvancementTrigger getSpatialExplorer() { + return this.spatialExplorer; + } } diff --git a/src/main/java/appeng/core/stats/AeStats.java b/src/main/java/appeng/core/stats/AeStats.java index 85309a84d..ba739464d 100644 --- a/src/main/java/appeng/core/stats/AeStats.java +++ b/src/main/java/appeng/core/stats/AeStats.java @@ -18,49 +18,46 @@ package appeng.core.stats; - -import appeng.core.AppEng; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.stats.IStatFormatter; import net.minecraft.stats.Stats; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; +import appeng.core.AppEng; -public enum AeStats -{ +public enum AeStats { - // done - ItemsInserted("items_inserted"), + // done + ItemsInserted("items_inserted"), - // done - ItemsExtracted("items_extracted"), + // done + ItemsExtracted("items_extracted"), - // done - TurnedCranks("turned_cranks"); + // done + TurnedCranks("turned_cranks"); - private final ResourceLocation registryName; + private final ResourceLocation registryName; - AeStats(String id) { - this.registryName = new ResourceLocation(AppEng.MOD_ID, id); - } + AeStats(String id) { + this.registryName = new ResourceLocation(AppEng.MOD_ID, id); + } - public void addToPlayer(final PlayerEntity player, final int howMany ) - { - player.addStat( this.registryName, howMany ); - } + public void addToPlayer(final PlayerEntity player, final int howMany) { + player.addStat(this.registryName, howMany); + } - public ResourceLocation getRegistryName() { - return registryName; - } + public ResourceLocation getRegistryName() { + return registryName; + } - public static void register() { - for (AeStats stat : AeStats.values()) { - // Compare with net.minecraft.stats.Stats#registerCustom - ResourceLocation registryName = stat.getRegistryName(); - Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName); - Stats.CUSTOM.get(registryName, IStatFormatter.DEFAULT); - } - } + public static void register() { + for (AeStats stat : AeStats.values()) { + // Compare with net.minecraft.stats.Stats#registerCustom + ResourceLocation registryName = stat.getRegistryName(); + Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName); + Stats.CUSTOM.get(registryName, IStatFormatter.DEFAULT); + } + } } diff --git a/src/main/java/appeng/core/stats/AppEngAdvancementTrigger.java b/src/main/java/appeng/core/stats/AppEngAdvancementTrigger.java index 7adc076b0..36af1101e 100644 --- a/src/main/java/appeng/core/stats/AppEngAdvancementTrigger.java +++ b/src/main/java/appeng/core/stats/AppEngAdvancementTrigger.java @@ -18,7 +18,6 @@ package appeng.core.stats; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -38,139 +37,115 @@ import net.minecraft.util.ResourceLocation; import appeng.core.AppEng; +public class AppEngAdvancementTrigger + implements ICriterionTrigger, IAdvancementTrigger { + private final ResourceLocation ID; + private final Map listeners = new HashMap<>(); -public class AppEngAdvancementTrigger implements ICriterionTrigger, IAdvancementTrigger -{ - private final ResourceLocation ID; - private final Map listeners = new HashMap<>(); + public AppEngAdvancementTrigger(String parString) { + super(); + this.ID = new ResourceLocation(AppEng.MOD_ID, parString); + } - public AppEngAdvancementTrigger( String parString ) - { - super(); - this.ID = new ResourceLocation( AppEng.MOD_ID, parString ); - } + @Override + public ResourceLocation getId() { + return this.ID; + } - @Override - public ResourceLocation getId() - { - return this.ID; - } + @Override + public void addListener(PlayerAdvancements playerAdvancementsIn, + ICriterionTrigger.Listener listener) { + AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn); - @Override - public void addListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener listener ) - { - AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn ); + if (l == null) { + l = new AppEngAdvancementTrigger.Listeners(playerAdvancementsIn); + this.listeners.put(playerAdvancementsIn, l); + } - if( l == null ) - { - l = new AppEngAdvancementTrigger.Listeners( playerAdvancementsIn ); - this.listeners.put( playerAdvancementsIn, l ); - } + l.add(listener); + } - l.add( listener ); - } + @Override + public void removeListener(PlayerAdvancements playerAdvancementsIn, + ICriterionTrigger.Listener listener) { + AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn); - @Override - public void removeListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener listener ) - { - AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn ); + if (l != null) { + l.remove(listener); - if( l != null ) - { - l.remove( listener ); + if (l.isEmpty()) { + this.listeners.remove(playerAdvancementsIn); + } + } + } - if( l.isEmpty() ) - { - this.listeners.remove( playerAdvancementsIn ); - } - } - } + @Override + public void removeAllListeners(PlayerAdvancements playerAdvancementsIn) { + this.listeners.remove(playerAdvancementsIn); + } - @Override - public void removeAllListeners( PlayerAdvancements playerAdvancementsIn ) - { - this.listeners.remove( playerAdvancementsIn ); - } + @Override + public AppEngAdvancementTrigger.Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) { + return new AppEngAdvancementTrigger.Instance(this.getId()); + } - @Override - public AppEngAdvancementTrigger.Instance deserializeInstance( JsonObject json, JsonDeserializationContext context ) - { - return new AppEngAdvancementTrigger.Instance( this.getId() ); - } + @Override + public void trigger(ServerPlayerEntity parPlayer) { + AppEngAdvancementTrigger.Listeners l = this.listeners.get(parPlayer.getAdvancements()); - @Override - public void trigger( ServerPlayerEntity parPlayer ) - { - AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() ); + if (l != null) { + l.trigger(parPlayer); + } + } - if( l != null ) - { - l.trigger( parPlayer ); - } - } + public static class Instance extends CriterionInstance { + public Instance(ResourceLocation parID) { + super(parID); + } - public static class Instance extends CriterionInstance - { - public Instance( ResourceLocation parID ) - { - super( parID ); - } + public boolean test() { + return true; + } + } - public boolean test() - { - return true; - } - } + static class Listeners { + private final PlayerAdvancements playerAdvancements; + private final Set> listeners = new HashSet<>(); - static class Listeners - { - private final PlayerAdvancements playerAdvancements; - private final Set> listeners = new HashSet<>(); + Listeners(PlayerAdvancements playerAdvancementsIn) { + this.playerAdvancements = playerAdvancementsIn; + } - Listeners( PlayerAdvancements playerAdvancementsIn ) - { - this.playerAdvancements = playerAdvancementsIn; - } + public boolean isEmpty() { + return this.listeners.isEmpty(); + } - public boolean isEmpty() - { - return this.listeners.isEmpty(); - } + public void add(ICriterionTrigger.Listener listener) { + this.listeners.add(listener); + } - public void add( ICriterionTrigger.Listener listener ) - { - this.listeners.add( listener ); - } + public void remove(ICriterionTrigger.Listener listener) { + this.listeners.remove(listener); + } - public void remove( ICriterionTrigger.Listener listener ) - { - this.listeners.remove( listener ); - } + public void trigger(PlayerEntity player) { + List> list = null; - public void trigger( PlayerEntity player ) - { - List> list = null; + for (ICriterionTrigger.Listener listener : this.listeners) { + if (listener.getCriterionInstance().test()) { + if (list == null) { + list = new ArrayList<>(); + } - for( ICriterionTrigger.Listener listener : this.listeners ) - { - if( listener.getCriterionInstance().test() ) - { - if( list == null ) - { - list = new ArrayList<>(); - } + list.add(listener); + } + } - list.add( listener ); - } - } - - if( list != null ) - { - for( ICriterionTrigger.Listener l : list ) - { - l.grantCriterion( this.playerAdvancements ); - } - } - } - } + if (list != null) { + for (ICriterionTrigger.Listener l : list) { + l.grantCriterion(this.playerAdvancements); + } + } + } + } } diff --git a/src/main/java/appeng/core/stats/IAdvancementTrigger.java b/src/main/java/appeng/core/stats/IAdvancementTrigger.java index 8ed58c6de..f6d73287a 100644 --- a/src/main/java/appeng/core/stats/IAdvancementTrigger.java +++ b/src/main/java/appeng/core/stats/IAdvancementTrigger.java @@ -18,13 +18,10 @@ package appeng.core.stats; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; - @FunctionalInterface -public interface IAdvancementTrigger -{ - void trigger( ServerPlayerEntity parPlayer ); +public interface IAdvancementTrigger { + void trigger(ServerPlayerEntity parPlayer); } diff --git a/src/main/java/appeng/core/stats/PartItemPredicate.java b/src/main/java/appeng/core/stats/PartItemPredicate.java index 573835097..fc5a25d42 100644 --- a/src/main/java/appeng/core/stats/PartItemPredicate.java +++ b/src/main/java/appeng/core/stats/PartItemPredicate.java @@ -18,7 +18,6 @@ package appeng.core.stats; - import com.google.gson.JsonObject; import net.minecraft.advancements.criterion.ItemPredicate; @@ -30,41 +29,31 @@ import appeng.core.AppEng; import appeng.items.parts.ItemPart; import appeng.items.parts.PartType; +public class PartItemPredicate extends ItemPredicate { + private final PartType partType; -public class PartItemPredicate extends ItemPredicate -{ - private final PartType partType; + public PartItemPredicate(String partName) { + this.partType = PartType.valueOf(partName.toUpperCase()); + } - public PartItemPredicate( String partName ) - { - this.partType = PartType.valueOf( partName.toUpperCase() ); - } + @Override + public boolean test(ItemStack item) { + if (item.getItem() instanceof ItemPart) { + ItemPart itemPart = (ItemPart) item.getItem(); + return itemPart.getType() == partType; + } + return false; + } - @Override - public boolean test( ItemStack item ) - { - if( item.getItem() instanceof ItemPart ) - { - ItemPart itemPart = (ItemPart) item.getItem(); - return itemPart.getType() == partType; - } - return false; - } + public static ItemPredicate deserialize(JsonObject jsonobject) { + if (jsonobject.has("part")) { + return new PartItemPredicate(JSONUtils.getString(jsonobject, "part")); + } else { + return ItemPredicate.ANY; + } + } - public static ItemPredicate deserialize( JsonObject jsonobject ) - { - if( jsonobject.has( "part" ) ) - { - return new PartItemPredicate( JSONUtils.getString( jsonobject, "part" ) ); - } - else - { - return ItemPredicate.ANY; - } - } - - public static void register() - { - ItemPredicate.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize ); - } + public static void register() { + ItemPredicate.register(new ResourceLocation(AppEng.MOD_ID, "part"), PartItemPredicate::deserialize); + } } diff --git a/src/main/java/appeng/core/sync/AppEngPacket.java b/src/main/java/appeng/core/sync/AppEngPacket.java index 46706532e..f243beb8b 100644 --- a/src/main/java/appeng/core/sync/AppEngPacket.java +++ b/src/main/java/appeng/core/sync/AppEngPacket.java @@ -18,57 +18,52 @@ package appeng.core.sync; +import org.apache.commons.lang3.tuple.Pair; -import appeng.core.sync.network.NetworkHandler; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.IPacket; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkDirection; +import appeng.api.features.AEFeature; import appeng.core.AEConfig; import appeng.core.AELog; -import appeng.api.features.AEFeature; import appeng.core.sync.network.INetworkInfo; -import org.apache.commons.lang3.tuple.Pair; +import appeng.core.sync.network.NetworkHandler; +public abstract class AppEngPacket { + private PacketBuffer p; -public abstract class AppEngPacket -{ - private PacketBuffer p; + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + throw new UnsupportedOperationException( + "This packet ( " + this.getPacketID() + " does not implement a server side handler."); + } - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." ); - } + public final int getPacketID() { + return AppEngPacketHandlerBase.PacketTypes.getID(this.getClass()).ordinal(); + } - public final int getPacketID() - { - return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal(); - } + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + throw new UnsupportedOperationException( + "This packet ( " + this.getPacketID() + " does not implement a client side handler."); + } - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." ); - } + protected void configureWrite(final PacketBuffer data) { + data.capacity(data.readableBytes()); + this.p = data; + } - protected void configureWrite( final PacketBuffer data ) - { - data.capacity( data.readableBytes() ); - this.p = data; - } + public IPacket toPacket(NetworkDirection direction) { + if (this.p.array().length > 2 * 1024 * 1024) // 2k walking room :) + { + throw new IllegalArgumentException( + "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!"); + } - public IPacket toPacket( NetworkDirection direction ) - { - if( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :) - { - throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.PACKET_LOGGING)) { + AELog.info(this.getClass().getName() + " : " + p.readableBytes()); + } - if( AEConfig.instance().isFeatureEnabled( AEFeature.PACKET_LOGGING ) ) - { - AELog.info( this.getClass().getName() + " : " + p.readableBytes() ); - } - - return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis(); - } + return direction.buildPacket(Pair.of(p, 0), NetworkHandler.instance().getChannel()).getThis(); + } } diff --git a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java index 6237b8d8f..5b3401ff9 100644 --- a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java +++ b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java @@ -18,7 +18,6 @@ package appeng.core.sync; - import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; @@ -53,86 +52,78 @@ import appeng.core.sync.packets.PacketTargetItemStack; import appeng.core.sync.packets.PacketTransitionEffect; import appeng.core.sync.packets.PacketValueConfig; +public class AppEngPacketHandlerBase { + private static final Map, PacketTypes> REVERSE_LOOKUP = new HashMap<>(); -public class AppEngPacketHandlerBase -{ - private static final Map, PacketTypes> REVERSE_LOOKUP = new HashMap<>(); + public enum PacketTypes { + PACKET_COMPASS_REQUEST(PacketCompassRequest.class, PacketCompassRequest::new), + PACKET_COMPASS_RESPONSE(PacketCompassResponse.class, PacketCompassResponse::new), - public enum PacketTypes - { - PACKET_COMPASS_REQUEST( PacketCompassRequest.class, PacketCompassRequest::new ), + PACKET_INVENTORY_ACTION(PacketInventoryAction.class, PacketInventoryAction::new), - PACKET_COMPASS_RESPONSE( PacketCompassResponse.class, PacketCompassResponse::new ), + PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class, PacketMEInventoryUpdate::new), - PACKET_INVENTORY_ACTION( PacketInventoryAction.class, PacketInventoryAction::new ), + PACKET_ME_FLUID_INVENTORY_UPDATE(PacketMEFluidInventoryUpdate.class, PacketMEFluidInventoryUpdate::new), - PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class, PacketMEInventoryUpdate::new ), + PACKET_CONFIG_BUTTON(PacketConfigButton.class, PacketConfigButton::new), - PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class, PacketMEFluidInventoryUpdate::new ), + PACKET_PART_PLACEMENT(PacketPartPlacement.class, PacketPartPlacement::new), - PACKET_CONFIG_BUTTON( PacketConfigButton.class, PacketConfigButton::new ), + PACKET_LIGHTNING(PacketLightning.class, PacketLightning::new), - PACKET_PART_PLACEMENT( PacketPartPlacement.class, PacketPartPlacement::new ), + PACKET_MATTER_CANNON(PacketMatterCannon.class, PacketMatterCannon::new), - PACKET_LIGHTNING( PacketLightning.class, PacketLightning::new ), + PACKET_MOCK_EXPLOSION(PacketMockExplosion.class, PacketMockExplosion::new), - PACKET_MATTER_CANNON( PacketMatterCannon.class, PacketMatterCannon::new ), + PACKET_VALUE_CONFIG(PacketValueConfig.class, PacketValueConfig::new), - PACKET_MOCK_EXPLOSION( PacketMockExplosion.class, PacketMockExplosion::new ), + PACKET_TRANSITION_EFFECT(PacketTransitionEffect.class, PacketTransitionEffect::new), - PACKET_VALUE_CONFIG( PacketValueConfig.class, PacketValueConfig::new ), + PACKET_PROGRESS_VALUE(PacketProgressBar.class, PacketProgressBar::new), - PACKET_TRANSITION_EFFECT( PacketTransitionEffect.class, PacketTransitionEffect::new ), + PACKET_CLICK(PacketClick.class, PacketClick::new), - PACKET_PROGRESS_VALUE( PacketProgressBar.class, PacketProgressBar::new ), + PACKET_SWITCH_GUIS(PacketSwitchGuis.class, PacketSwitchGuis::new), - PACKET_CLICK( PacketClick.class, PacketClick::new ), + PACKET_SWAP_SLOTS(PacketSwapSlots.class, PacketSwapSlots::new), - PACKET_SWITCH_GUIS( PacketSwitchGuis.class, PacketSwitchGuis::new ), + PACKET_PATTERN_SLOT(PacketPatternSlot.class, PacketPatternSlot::new), - PACKET_SWAP_SLOTS( PacketSwapSlots.class, PacketSwapSlots::new ), + PACKET_RECIPE_JEI(PacketJEIRecipe.class, PacketJEIRecipe::new), - PACKET_PATTERN_SLOT( PacketPatternSlot.class, PacketPatternSlot::new ), + PACKET_TARGET_ITEM(PacketTargetItemStack.class, PacketTargetItemStack::new), - PACKET_RECIPE_JEI( PacketJEIRecipe.class, PacketJEIRecipe::new ), + PACKET_TARGET_FLUID(PacketTargetFluidStack.class, PacketTargetFluidStack::new), - PACKET_TARGET_ITEM( PacketTargetItemStack.class, PacketTargetItemStack::new ), + PACKET_CRAFTING_REQUEST(PacketCraftRequest.class, PacketCraftRequest::new), - PACKET_TARGET_FLUID( PacketTargetFluidStack.class, PacketTargetFluidStack::new ), + PACKET_ASSEMBLER_ANIMATION(PacketAssemblerAnimation.class, PacketAssemblerAnimation::new), - PACKET_CRAFTING_REQUEST( PacketCraftRequest.class, PacketCraftRequest::new ), + PACKET_COMPRESSED_NBT(PacketCompressedNBT.class, PacketCompressedNBT::new), - PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class, PacketAssemblerAnimation::new ), + PACKET_PAINTED_ENTITY(PacketPaintedEntity.class, PacketPaintedEntity::new), - PACKET_COMPRESSED_NBT( PacketCompressedNBT.class, PacketCompressedNBT::new ), + PACKET_FLUID_TANK(PacketFluidSlot.class, PacketFluidSlot::new); - PACKET_PAINTED_ENTITY( PacketPaintedEntity.class, PacketPaintedEntity::new ), + private final Function factory; - PACKET_FLUID_TANK( PacketFluidSlot.class, PacketFluidSlot::new ); + PacketTypes(Class packetClass, Function factory) { + this.factory = factory; - private final Function factory; + REVERSE_LOOKUP.put(packetClass, this); + } - PacketTypes( Class packetClass, Function factory ) - { - this.factory = factory; + public static PacketTypes getPacket(final int id) { + return (values())[id]; + } - REVERSE_LOOKUP.put(packetClass, this ); - } + static PacketTypes getID(final Class c) { + return REVERSE_LOOKUP.get(c); + } - public static PacketTypes getPacket( final int id ) - { - return ( values() )[id]; - } - - static PacketTypes getID( final Class c ) - { - return REVERSE_LOOKUP.get( c ); - } - - public AppEngPacket parsePacket( final PacketBuffer in ) throws IllegalArgumentException - { - return this.factory.apply( in ); - } - } + public AppEngPacket parsePacket(final PacketBuffer in) throws IllegalArgumentException { + return this.factory.apply(in); + } + } } diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index dcac222fc..1c71df6f3 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -18,7 +18,6 @@ package appeng.core.sync; - import java.lang.reflect.Constructor; import net.minecraft.entity.player.PlayerEntity; @@ -48,8 +47,8 @@ import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.client.gui.AEBaseGui; import appeng.container.AEBaseContainer; -import appeng.container.ContainerNull; import appeng.container.ContainerLocator; +import appeng.container.ContainerNull; import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerChest; import appeng.container.implementations.ContainerCondenser; @@ -121,420 +120,368 @@ import appeng.tile.storage.TileIOPort; import appeng.tile.storage.TileSkyChest; import appeng.util.Platform; +public enum GuiBridge { + GUI_Handler(), -public enum GuiBridge -{ - GUI_Handler(), + GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, GuiHostType.WORLD, null), - GUI_GRINDER( ContainerGrinder.class, TileGrinder.class, GuiHostType.WORLD, null ), + GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_QNB( ContainerQNB.class, TileQuantumBridge.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, GuiHostType.WORLD, null), - GUI_SKYCHEST( ContainerSkyChest.class, TileSkyChest.class, GuiHostType.WORLD, null ), + GUI_CHEST(ContainerChest.class, TileChest.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_CHEST( ContainerChest.class, TileChest.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_WIRELESS(ContainerWireless.class, TileWireless.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_WIRELESS( ContainerWireless.class, TileWireless.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, GuiHostType.WORLD, null), - GUI_ME( ContainerMEMonitorable.class, ITerminalHost.class, GuiHostType.WORLD, null ), + GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null), - GUI_PORTABLE_CELL( ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null ), + GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null), - GUI_WIRELESS_TERM( ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null ), + GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null), - GUI_NETWORK_STATUS( ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null ), + GUI_CRAFTING_CPU(ContainerCraftingCPU.class, TileCraftingTile.class, GuiHostType.WORLD, SecurityPermissions.CRAFT), - GUI_CRAFTING_CPU( ContainerCraftingCPU.class, TileCraftingTile.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ), + GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, GuiHostType.ITEM, null), - GUI_NETWORK_TOOL( ContainerNetworkTool.class, INetworkTool.class, GuiHostType.ITEM, null ), + GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, GuiHostType.ITEM, null), - GUI_QUARTZ_KNIFE( ContainerQuartzKnife.class, QuartzKnifeObj.class, GuiHostType.ITEM, null ), + GUI_DRIVE(ContainerDrive.class, TileDrive.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_DRIVE( ContainerDrive.class, TileDrive.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_VIBRATION_CHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, GuiHostType.WORLD, null), - GUI_VIBRATION_CHAMBER( ContainerVibrationChamber.class, TileVibrationChamber.class, GuiHostType.WORLD, null ), + GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, GuiHostType.WORLD, null), - GUI_CONDENSER( ContainerCondenser.class, TileCondenser.class, GuiHostType.WORLD, null ), + GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_INTERFACE( ContainerInterface.class, IInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_FLUID_INTERFACE(ContainerFluidInterface.class, IFluidInterfaceHost.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_FLUID_INTERFACE( ContainerFluidInterface.class, IFluidInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_BUS( ContainerUpgradeable.class, IUpgradeableHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_BUS_FLUID(ContainerFluidIO.class, PartSharedFluidBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_BUS_FLUID( ContainerFluidIO.class, PartSharedFluidBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_IOPORT( ContainerIOPort.class, TileIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_STORAGEBUS( ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_STORAGEBUS_FLUID(ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_STORAGEBUS_FLUID( ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_FORMATION_PLANE(ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_FLUID_FORMATION_PLANE(ContainerFluidFormationPlane.class, PartFluidFormationPlane.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_FLUID_FORMATION_PLANE( ContainerFluidFormationPlane.class, PartFluidFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_PRIORITY( ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_SECURITY(ContainerSecurityStation.class, TileSecurityStation.class, GuiHostType.WORLD, + SecurityPermissions.SECURITY), - GUI_SECURITY( ContainerSecurityStation.class, TileSecurityStation.class, GuiHostType.WORLD, SecurityPermissions.SECURITY ), + GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, GuiHostType.WORLD, + SecurityPermissions.CRAFT), - GUI_CRAFTING_TERMINAL( ContainerCraftingTerm.class, PartCraftingTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ), + GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, + SecurityPermissions.CRAFT), - GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ), + GUI_FLUID_TERMINAL(ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD), - GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + // extends (Container/Gui) + Bus + GUI_LEVEL_EMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - // extends (Container/Gui) + Bus - GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_FLUID_LEVEL_EMITTER(ContainerFluidLevelEmitter.class, PartFluidLevelEmitter.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_FLUID_LEVEL_EMITTER( ContainerFluidLevelEmitter.class, PartFluidLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_SPATIAL_IO_PORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_SPATIAL_IO_PORT( ContainerSpatialIOPort.class, TileSpatialIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, GuiHostType.WORLD, null), - GUI_INSCRIBER( ContainerInscriber.class, TileInscriber.class, GuiHostType.WORLD, null ), + GUI_CELL_WORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, GuiHostType.WORLD, null), - GUI_CELL_WORKBENCH( ContainerCellWorkbench.class, TileCellWorkbench.class, GuiHostType.WORLD, null ), + GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, GuiHostType.WORLD, null), - GUI_MAC( ContainerMAC.class, TileMolecularAssembler.class, GuiHostType.WORLD, null ), + GUI_CRAFTING_AMOUNT(ContainerCraftAmount.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, + SecurityPermissions.CRAFT), - GUI_CRAFTING_AMOUNT( ContainerCraftAmount.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ), + GUI_CRAFTING_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, + SecurityPermissions.CRAFT), - GUI_CRAFTING_CONFIRM( ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ), + GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD, + SecurityPermissions.BUILD), - GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), + GUI_CRAFTING_STATUS(ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, + SecurityPermissions.CRAFT); - GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ); + private final Class tileClass; + private final Class containerClass; + private Class guiClass; + private GuiHostType type; + private SecurityPermissions requiredPermission; - private final Class tileClass; - private final Class containerClass; - private Class guiClass; - private GuiHostType type; - private SecurityPermissions requiredPermission; + GuiBridge() { + this.tileClass = null; + this.guiClass = null; + this.containerClass = null; + } - GuiBridge() - { - this.tileClass = null; - this.guiClass = null; - this.containerClass = null; - } - - GuiBridge( final Class containerClass, final SecurityPermissions requiredPermission ) - { - this.requiredPermission = requiredPermission; - this.containerClass = containerClass; - this.tileClass = null; - this.getGui(); - } - - /** - * I honestly wish I could just use the GuiClass Names myself, but I can't access them without MC's Server - * Exploding. - */ - private void getGui() - { - if( Platform.isClient() ) - { - AEBaseGui.class.getName(); - - final String start = this.containerClass.getName(); - final String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" ); - - if( start.equals( guiClass ) ) - { - throw new IllegalStateException( "Unable to find gui class" ); - } - this.guiClass = null; // FIXME ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass ); - if( this.guiClass == null ) - { - throw new IllegalStateException( "Cannot Load class: " + guiClass ); - } - } - } - - GuiBridge( final Class containerClass, final Class tileClass, final GuiHostType type, final SecurityPermissions requiredPermission ) - { - this.requiredPermission = requiredPermission; - this.containerClass = containerClass; - this.type = type; - this.tileClass = tileClass; - this.getGui(); - } - - public Object getServerGuiElement( final int ordinal, final PlayerEntity player, final World w, final int x, final int y, final int z ) - { - final AEPartLocation side = AEPartLocation.fromOrdinal( ordinal & 0x07 ); - final GuiBridge ID = values()[ordinal >> 4]; - final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1; - if( ID.type.isItem() ) - { - ItemStack it = ItemStack.EMPTY; - if( stem ) - { - it = player.inventory.getCurrentItem(); - } - else if( x >= 0 && x < player.inventory.mainInventory.size() ) - { - it = player.inventory.getStackInSlot( x ); - } - final Object myItem = this.getGuiObject( it, player, w, x, y, z ); - if( myItem != null && ID.CorrectTileOrPart( myItem ) ) - { - return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem ); - } - } - if( ID.type.isTile() ) - { - final TileEntity TE = w.getTileEntity( new BlockPos( x, y, z ) ); - if( TE instanceof IPartHost ) - { - ( (IPartHost) TE ).getPart( side ); - final IPart part = ( (IPartHost) TE ).getPart( side ); - if( ID.CorrectTileOrPart( part ) ) - { - return this.updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part ); - } - } - else - { - if( ID.CorrectTileOrPart( TE ) ) - { - return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE ); - } - } - } - return new ContainerNull(); - } - - private Object getGuiObject( final ItemStack it, final PlayerEntity player, final World w, final int x, final int y, final int z ) - { - return null; - } - - public boolean CorrectTileOrPart( final Object tE ) - { - if( this.tileClass == null ) - { - throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." ); - } - - return this.tileClass.isInstance( tE ); - } - - private Object updateGui( final Object newContainer, final World w, final int x, final int y, final int z, final AEPartLocation side, final Object myItem ) - { - if( newContainer instanceof AEBaseContainer ) - { - // FIXME final AEBaseContainer bc = (AEBaseContainer) newContainer; - // FIXME bc.setLocator( new ContainerLocator( myItem ) ); - // FIXME bc.getLocator().setWorld( w ); - // FIXME bc.getLocator().setX( x ); - // FIXME bc.getLocator().setY( y ); - // FIXME bc.getLocator().setZ( z ); - // FIXME bc.getLocator().setSide( side ); - } - - return newContainer; - } - - public Object ConstructContainer( final PlayerInventory inventory, final AEPartLocation side, final Object tE ) - { - try - { - final Constructor[] c = this.containerClass.getConstructors(); - if( c.length == 0 ) - { - throw new AppEngException( "Invalid Gui Class" ); - } - - final Constructor target = this.findConstructor( c, inventory, tE ); - - if( target == null ) - { - throw new IllegalStateException( "Cannot find " + this.containerClass.getName() + "( " + this.typeName( inventory ) + ", " + this - .typeName( tE ) + " )" ); - } - - return target.newInstance( inventory, tE ); - } - catch( final Throwable t ) - { - throw new IllegalStateException( t ); - } - } - - private Constructor findConstructor( final Constructor[] c, final PlayerInventory inventory, final Object tE ) - { - for( final Constructor con : c ) - { - final Class[] types = con.getParameterTypes(); - if( types.length == 2 ) - { - if( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) ) - { - return con; - } - } - } - return null; - } - - private String typeName( final Object inventory ) - { - if( inventory == null ) - { - return "NULL"; - } - - return inventory.getClass().getName(); - } - - public Object getClientGuiElement( final int ordinal, final PlayerEntity player, final World w, final int x, final int y, final int z ) - { - final AEPartLocation side = AEPartLocation.fromOrdinal( ordinal & 0x07 ); - final GuiBridge ID = values()[ordinal >> 4]; - final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1; - if( ID.type.isItem() ) - { - ItemStack it = ItemStack.EMPTY; - if( stem ) - { - it = player.inventory.getCurrentItem(); - } - else if( x >= 0 && x < player.inventory.mainInventory.size() ) - { - it = player.inventory.getStackInSlot( x ); - } - final Object myItem = this.getGuiObject( it, player, w, x, y, z ); - if( myItem != null && ID.CorrectTileOrPart( myItem ) ) - { - return ID.ConstructGui( player.inventory, side, myItem ); - } - } - if( ID.type.isTile() ) - { - final TileEntity TE = w.getTileEntity( new BlockPos( x, y, z ) ); - if( TE instanceof IPartHost ) - { - ( (IPartHost) TE ).getPart( side ); - final IPart part = ( (IPartHost) TE ).getPart( side ); - if( ID.CorrectTileOrPart( part ) ) - { - return ID.ConstructGui( player.inventory, side, part ); - } - } - else - { - if( ID.CorrectTileOrPart( TE ) ) - { - return ID.ConstructGui( player.inventory, side, TE ); - } - } - } - return null; // FIXME - } - - public Object ConstructGui( final PlayerInventory inventory, final AEPartLocation side, final Object tE ) - { - try - { - final Constructor[] c = this.guiClass.getConstructors(); - if( c.length == 0 ) - { - throw new AppEngException( "Invalid Gui Class" ); - } - - final Constructor target = this.findConstructor( c, inventory, tE ); - - if( target == null ) - { - throw new IllegalStateException( "Cannot find " + this.containerClass.getName() + "( " + this.typeName( inventory ) + ", " + this - .typeName( tE ) + " )" ); - } - - return target.newInstance( inventory, tE ); - } - catch( final Throwable t ) - { - throw new IllegalStateException( t ); - } - } - - public boolean hasPermissions( final TileEntity te, final int x, final int y, final int z, final AEPartLocation side, final PlayerEntity player ) - { - final World w = player.getEntityWorld(); - final BlockPos pos = new BlockPos( x, y, z ); - - if( Platform.hasPermissions( te != null ? new DimensionalCoord( te ) : new DimensionalCoord( player.world, pos ), player ) ) - { - if( this.type.isItem() ) - { - final ItemStack it = player.inventory.getCurrentItem(); - if( !it.isEmpty() && it.getItem() instanceof IGuiItem ) - { - } - } - - if( this.type.isTile() ) - { - final TileEntity TE = w.getTileEntity( pos ); - if( TE instanceof IPartHost ) - { - ( (IPartHost) TE ).getPart( side ); - final IPart part = ( (IPartHost) TE ).getPart( side ); - if( this.CorrectTileOrPart( part ) ) - { - return this.securityCheck( part, player ); - } - } - else - { - if( this.CorrectTileOrPart( TE ) ) - { - return this.securityCheck( TE, player ); - } - } - } - } - return false; - } - - private boolean securityCheck( final Object te, final PlayerEntity player ) - { - if( te instanceof IActionHost && this.requiredPermission != null ) - { - - final IGridNode gn = ( (IActionHost) te ).getActionableNode(); - if( gn != null ) - { - final IGrid g = gn.getGrid(); - if( g != null ) - { - final boolean requirePower = false; - if( requirePower ) - { - final IEnergyGrid eg = g.getCache( IEnergyGrid.class ); - if( !eg.isNetworkPowered() ) - { - return false; - } - } - - final ISecurityGrid sg = g.getCache( ISecurityGrid.class ); - if( sg.hasPermission( player, this.requiredPermission ) ) - { - return true; - } - } - } - - return false; - } - return true; - } - - public GuiHostType getType() - { - return this.type; - } + GuiBridge(final Class containerClass, final SecurityPermissions requiredPermission) { + this.requiredPermission = requiredPermission; + this.containerClass = containerClass; + this.tileClass = null; + this.getGui(); + } + + /** + * I honestly wish I could just use the GuiClass Names myself, but I can't + * access them without MC's Server Exploding. + */ + private void getGui() { + if (Platform.isClient()) { + AEBaseGui.class.getName(); + + final String start = this.containerClass.getName(); + final String guiClass = start.replaceFirst("container.", "client.gui.").replace(".Container", ".Gui"); + + if (start.equals(guiClass)) { + throw new IllegalStateException("Unable to find gui class"); + } + this.guiClass = null; // FIXME ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass + // ); + if (this.guiClass == null) { + throw new IllegalStateException("Cannot Load class: " + guiClass); + } + } + } + + GuiBridge(final Class containerClass, final Class tileClass, final GuiHostType type, + final SecurityPermissions requiredPermission) { + this.requiredPermission = requiredPermission; + this.containerClass = containerClass; + this.type = type; + this.tileClass = tileClass; + this.getGui(); + } + + public Object getServerGuiElement(final int ordinal, final PlayerEntity player, final World w, final int x, + final int y, final int z) { + final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); + final GuiBridge ID = values()[ordinal >> 4]; + final boolean stem = ((ordinal >> 3) & 1) == 1; + if (ID.type.isItem()) { + ItemStack it = ItemStack.EMPTY; + if (stem) { + it = player.inventory.getCurrentItem(); + } else if (x >= 0 && x < player.inventory.mainInventory.size()) { + it = player.inventory.getStackInSlot(x); + } + final Object myItem = this.getGuiObject(it, player, w, x, y, z); + if (myItem != null && ID.CorrectTileOrPart(myItem)) { + return this.updateGui(ID.ConstructContainer(player.inventory, side, myItem), w, x, y, z, side, myItem); + } + } + if (ID.type.isTile()) { + final TileEntity TE = w.getTileEntity(new BlockPos(x, y, z)); + if (TE instanceof IPartHost) { + ((IPartHost) TE).getPart(side); + final IPart part = ((IPartHost) TE).getPart(side); + if (ID.CorrectTileOrPart(part)) { + return this.updateGui(ID.ConstructContainer(player.inventory, side, part), w, x, y, z, side, part); + } + } else { + if (ID.CorrectTileOrPart(TE)) { + return this.updateGui(ID.ConstructContainer(player.inventory, side, TE), w, x, y, z, side, TE); + } + } + } + return new ContainerNull(); + } + + private Object getGuiObject(final ItemStack it, final PlayerEntity player, final World w, final int x, final int y, + final int z) { + return null; + } + + public boolean CorrectTileOrPart(final Object tE) { + if (this.tileClass == null) { + throw new IllegalArgumentException("This Gui Cannot use the standard Handler."); + } + + return this.tileClass.isInstance(tE); + } + + private Object updateGui(final Object newContainer, final World w, final int x, final int y, final int z, + final AEPartLocation side, final Object myItem) { + if (newContainer instanceof AEBaseContainer) { + // FIXME final AEBaseContainer bc = (AEBaseContainer) newContainer; + // FIXME bc.setLocator( new ContainerLocator( myItem ) ); + // FIXME bc.getLocator().setWorld( w ); + // FIXME bc.getLocator().setX( x ); + // FIXME bc.getLocator().setY( y ); + // FIXME bc.getLocator().setZ( z ); + // FIXME bc.getLocator().setSide( side ); + } + + return newContainer; + } + + public Object ConstructContainer(final PlayerInventory inventory, final AEPartLocation side, final Object tE) { + try { + final Constructor[] c = this.containerClass.getConstructors(); + if (c.length == 0) { + throw new AppEngException("Invalid Gui Class"); + } + + final Constructor target = this.findConstructor(c, inventory, tE); + + if (target == null) { + throw new IllegalStateException("Cannot find " + this.containerClass.getName() + "( " + + this.typeName(inventory) + ", " + this.typeName(tE) + " )"); + } + + return target.newInstance(inventory, tE); + } catch (final Throwable t) { + throw new IllegalStateException(t); + } + } + + private Constructor findConstructor(final Constructor[] c, final PlayerInventory inventory, final Object tE) { + for (final Constructor con : c) { + final Class[] types = con.getParameterTypes(); + if (types.length == 2) { + if (types[0].isAssignableFrom(inventory.getClass()) && types[1].isAssignableFrom(tE.getClass())) { + return con; + } + } + } + return null; + } + + private String typeName(final Object inventory) { + if (inventory == null) { + return "NULL"; + } + + return inventory.getClass().getName(); + } + + public Object getClientGuiElement(final int ordinal, final PlayerEntity player, final World w, final int x, + final int y, final int z) { + final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); + final GuiBridge ID = values()[ordinal >> 4]; + final boolean stem = ((ordinal >> 3) & 1) == 1; + if (ID.type.isItem()) { + ItemStack it = ItemStack.EMPTY; + if (stem) { + it = player.inventory.getCurrentItem(); + } else if (x >= 0 && x < player.inventory.mainInventory.size()) { + it = player.inventory.getStackInSlot(x); + } + final Object myItem = this.getGuiObject(it, player, w, x, y, z); + if (myItem != null && ID.CorrectTileOrPart(myItem)) { + return ID.ConstructGui(player.inventory, side, myItem); + } + } + if (ID.type.isTile()) { + final TileEntity TE = w.getTileEntity(new BlockPos(x, y, z)); + if (TE instanceof IPartHost) { + ((IPartHost) TE).getPart(side); + final IPart part = ((IPartHost) TE).getPart(side); + if (ID.CorrectTileOrPart(part)) { + return ID.ConstructGui(player.inventory, side, part); + } + } else { + if (ID.CorrectTileOrPart(TE)) { + return ID.ConstructGui(player.inventory, side, TE); + } + } + } + return null; // FIXME + } + + public Object ConstructGui(final PlayerInventory inventory, final AEPartLocation side, final Object tE) { + try { + final Constructor[] c = this.guiClass.getConstructors(); + if (c.length == 0) { + throw new AppEngException("Invalid Gui Class"); + } + + final Constructor target = this.findConstructor(c, inventory, tE); + + if (target == null) { + throw new IllegalStateException("Cannot find " + this.containerClass.getName() + "( " + + this.typeName(inventory) + ", " + this.typeName(tE) + " )"); + } + + return target.newInstance(inventory, tE); + } catch (final Throwable t) { + throw new IllegalStateException(t); + } + } + + public boolean hasPermissions(final TileEntity te, final int x, final int y, final int z, final AEPartLocation side, + final PlayerEntity player) { + final World w = player.getEntityWorld(); + final BlockPos pos = new BlockPos(x, y, z); + + if (Platform.hasPermissions(te != null ? new DimensionalCoord(te) : new DimensionalCoord(player.world, pos), + player)) { + if (this.type.isItem()) { + final ItemStack it = player.inventory.getCurrentItem(); + if (!it.isEmpty() && it.getItem() instanceof IGuiItem) { + } + } + + if (this.type.isTile()) { + final TileEntity TE = w.getTileEntity(pos); + if (TE instanceof IPartHost) { + ((IPartHost) TE).getPart(side); + final IPart part = ((IPartHost) TE).getPart(side); + if (this.CorrectTileOrPart(part)) { + return this.securityCheck(part, player); + } + } else { + if (this.CorrectTileOrPart(TE)) { + return this.securityCheck(TE, player); + } + } + } + } + return false; + } + + private boolean securityCheck(final Object te, final PlayerEntity player) { + if (te instanceof IActionHost && this.requiredPermission != null) { + + final IGridNode gn = ((IActionHost) te).getActionableNode(); + if (gn != null) { + final IGrid g = gn.getGrid(); + if (g != null) { + final boolean requirePower = false; + if (requirePower) { + final IEnergyGrid eg = g.getCache(IEnergyGrid.class); + if (!eg.isNetworkPowered()) { + return false; + } + } + + final ISecurityGrid sg = g.getCache(ISecurityGrid.class); + if (sg.hasPermission(player, this.requiredPermission)) { + return true; + } + } + } + + return false; + } + return true; + } + + public GuiHostType getType() { + return this.type; + } } diff --git a/src/main/java/appeng/core/sync/GuiHostType.java b/src/main/java/appeng/core/sync/GuiHostType.java index ac7800285..906b12ea8 100644 --- a/src/main/java/appeng/core/sync/GuiHostType.java +++ b/src/main/java/appeng/core/sync/GuiHostType.java @@ -18,18 +18,14 @@ package appeng.core.sync; +public enum GuiHostType { + ITEM_OR_WORLD, ITEM, WORLD; -public enum GuiHostType -{ - ITEM_OR_WORLD, ITEM, WORLD; + public boolean isItem() { + return this != WORLD; + } - public boolean isItem() - { - return this != WORLD; - } - - boolean isTile() - { - return this != ITEM; - } + boolean isTile() { + return this != ITEM; + } } diff --git a/src/main/java/appeng/core/sync/network/AppEngClientPacketHandler.java b/src/main/java/appeng/core/sync/network/AppEngClientPacketHandler.java index a14ab1ff7..25f2593da 100644 --- a/src/main/java/appeng/core/sync/network/AppEngClientPacketHandler.java +++ b/src/main/java/appeng/core/sync/network/AppEngClientPacketHandler.java @@ -18,7 +18,6 @@ package appeng.core.sync.network; - import java.lang.reflect.InvocationTargetException; import net.minecraft.client.Minecraft; @@ -30,22 +29,17 @@ import appeng.core.AELog; import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacketHandlerBase; +public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler { -public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler -{ - - @Override - public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player ) - { - try - { - final int packetType = packet.readInt(); - final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet ); - pack.clientPacketData( manager, Minecraft.getInstance().player ); - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - } + @Override + public void onPacketData(final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, + final PlayerEntity player) { + try { + final int packetType = packet.readInt(); + final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(packet); + pack.clientPacketData(manager, Minecraft.getInstance().player); + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } + } } diff --git a/src/main/java/appeng/core/sync/network/AppEngServerPacketHandler.java b/src/main/java/appeng/core/sync/network/AppEngServerPacketHandler.java index c4e4cff1a..c3229fe0d 100644 --- a/src/main/java/appeng/core/sync/network/AppEngServerPacketHandler.java +++ b/src/main/java/appeng/core/sync/network/AppEngServerPacketHandler.java @@ -18,7 +18,6 @@ package appeng.core.sync.network; - import java.lang.reflect.InvocationTargetException; import net.minecraft.entity.player.PlayerEntity; @@ -29,22 +28,17 @@ import appeng.core.AELog; import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacketHandlerBase; +public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler { -public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler -{ - - @Override - public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player ) - { - try - { - final int packetType = packet.readInt(); - final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet ); - pack.serverPacketData( manager, player ); - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - } + @Override + public void onPacketData(final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, + final PlayerEntity player) { + try { + final int packetType = packet.readInt(); + final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(packet); + pack.serverPacketData(manager, player); + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } + } } diff --git a/src/main/java/appeng/core/sync/network/INetworkInfo.java b/src/main/java/appeng/core/sync/network/INetworkInfo.java index 51766b76c..ff7ff9637 100644 --- a/src/main/java/appeng/core/sync/network/INetworkInfo.java +++ b/src/main/java/appeng/core/sync/network/INetworkInfo.java @@ -18,8 +18,6 @@ package appeng.core.sync.network; - -public interface INetworkInfo -{ +public interface INetworkInfo { } diff --git a/src/main/java/appeng/core/sync/network/IPacketHandler.java b/src/main/java/appeng/core/sync/network/IPacketHandler.java index 74f1ff2e4..7574770a6 100644 --- a/src/main/java/appeng/core/sync/network/IPacketHandler.java +++ b/src/main/java/appeng/core/sync/network/IPacketHandler.java @@ -18,15 +18,12 @@ package appeng.core.sync.network; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.INetHandler; import net.minecraft.network.PacketBuffer; +public interface IPacketHandler { -public interface IPacketHandler -{ - - void onPacketData(INetworkInfo manager, INetHandler handler, PacketBuffer packet, PlayerEntity player ); + void onPacketData(INetworkInfo manager, INetHandler handler, PacketBuffer packet, PlayerEntity player); } diff --git a/src/main/java/appeng/core/sync/network/NetworkHandler.java b/src/main/java/appeng/core/sync/network/NetworkHandler.java index eec9a5e3a..f19d12186 100644 --- a/src/main/java/appeng/core/sync/network/NetworkHandler.java +++ b/src/main/java/appeng/core/sync/network/NetworkHandler.java @@ -18,7 +18,6 @@ package appeng.core.sync.network; - import net.minecraft.client.Minecraft; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.INetHandler; @@ -38,136 +37,109 @@ import net.minecraftforge.fml.network.event.EventNetworkChannel; import appeng.core.sync.AppEngPacket; +public class NetworkHandler { + private static NetworkHandler instance; -public class NetworkHandler -{ - private static NetworkHandler instance; + private final EventNetworkChannel ec; + private final ResourceLocation myChannelName; - private final EventNetworkChannel ec; - private final ResourceLocation myChannelName; + private final IPacketHandler clientHandler; + private final IPacketHandler serveHandler; - private final IPacketHandler clientHandler; - private final IPacketHandler serveHandler; + public NetworkHandler(final ResourceLocation channelName) { + ec = NetworkRegistry.ChannelBuilder.named(myChannelName = channelName).networkProtocolVersion(() -> "1") + .clientAcceptedVersions(s -> true).serverAcceptedVersions(s -> true).eventNetworkChannel(); + ec.registerObject(this); - public NetworkHandler( final ResourceLocation channelName ) - { - ec = NetworkRegistry.ChannelBuilder.named( myChannelName = channelName ).networkProtocolVersion( () -> "1" ).clientAcceptedVersions( s -> true ).serverAcceptedVersions( s -> true ).eventNetworkChannel(); - ec.registerObject( this ); + this.clientHandler = this.createClientSide(); + this.serveHandler = this.createServerSide(); + } - this.clientHandler = this.createClientSide(); - this.serveHandler = this.createServerSide(); - } + public static void init(final ResourceLocation channelName) { + instance = new NetworkHandler(channelName); + } - public static void init( final ResourceLocation channelName ) - { - instance = new NetworkHandler( channelName ); - } + public static NetworkHandler instance() { + return instance; + } - public static NetworkHandler instance() - { - return instance; - } + private IPacketHandler createClientSide() { + try { + return new AppEngClientPacketHandler(); + } catch (final Throwable t) { + return null; + } + } - private IPacketHandler createClientSide() - { - try - { - return new AppEngClientPacketHandler(); - } - catch( final Throwable t ) - { - return null; - } - } + private IPacketHandler createServerSide() { + try { + return new AppEngServerPacketHandler(); + } catch (final Throwable t) { + return null; + } + } - private IPacketHandler createServerSide() - { - try - { - return new AppEngServerPacketHandler(); - } - catch( final Throwable t ) - { - return null; - } - } + @SubscribeEvent + public void serverPacket(final NetworkEvent.ClientCustomPayloadEvent ev) { + if (this.serveHandler != null) { + try { + NetworkEvent.Context ctx = ev.getSource().get(); + ServerPlayNetHandler netHandler = (ServerPlayNetHandler) ctx.getNetworkManager().getNetHandler(); + ctx.setPacketHandled(true); + ctx.enqueueWork( + () -> this.serveHandler.onPacketData(null, netHandler, ev.getPayload(), netHandler.player)); - @SubscribeEvent - public void serverPacket( final NetworkEvent.ClientCustomPayloadEvent ev ) - { - if( this.serveHandler != null ) - { - try - { - NetworkEvent.Context ctx = ev.getSource().get(); - ServerPlayNetHandler netHandler = (ServerPlayNetHandler) ctx.getNetworkManager().getNetHandler(); - ctx.setPacketHandled( true ); - ctx.enqueueWork( () -> this.serveHandler.onPacketData( null, netHandler, ev.getPayload(), netHandler.player ) ); + } catch (final ThreadQuickExitException ignored) { - } - catch( final ThreadQuickExitException ignored ) - { + } + } + } - } - } - } + @SubscribeEvent + public void clientPacket(final NetworkEvent.ServerCustomPayloadEvent ev) { + if (ev instanceof NetworkEvent.ServerCustomPayloadLoginEvent) { + return; + } + if (this.clientHandler != null) { + try { + NetworkEvent.Context ctx = ev.getSource().get(); + INetHandler netHandler = ctx.getNetworkManager().getNetHandler(); + ctx.setPacketHandled(true); + ctx.enqueueWork(() -> this.clientHandler.onPacketData(null, netHandler, ev.getPayload(), null)); + } catch (final ThreadQuickExitException ignored) { - @SubscribeEvent - public void clientPacket( final NetworkEvent.ServerCustomPayloadEvent ev ) - { - if( ev instanceof NetworkEvent.ServerCustomPayloadLoginEvent ) - { - return; - } - if( this.clientHandler != null ) - { - try - { - NetworkEvent.Context ctx = ev.getSource().get(); - INetHandler netHandler = ctx.getNetworkManager().getNetHandler(); - ctx.setPacketHandled( true ); - ctx.enqueueWork( () -> this.clientHandler.onPacketData( null, netHandler, ev.getPayload(), null ) ); - } - catch( final ThreadQuickExitException ignored ) - { + } + } + } - } - } - } + public ResourceLocation getChannel() { + return this.myChannelName; + } - public ResourceLocation getChannel() - { - return this.myChannelName; - } + public void sendToAll(final AppEngPacket message) { + getServer().getPlayerList().sendPacketToAllPlayers(message.toPacket(NetworkDirection.PLAY_TO_CLIENT)); + } - public void sendToAll( final AppEngPacket message ) - { - getServer().getPlayerList().sendPacketToAllPlayers( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) ); - } + public void sendTo(final AppEngPacket message, final ServerPlayerEntity player) { + player.connection.sendPacket(message.toPacket(NetworkDirection.PLAY_TO_CLIENT)); + } - public void sendTo( final AppEngPacket message, final ServerPlayerEntity player ) - { - player.connection.sendPacket( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) ); - } + public void sendToAllAround(final AppEngPacket message, final TargetPoint point) { + IPacket pkt = message.toPacket(NetworkDirection.PLAY_TO_CLIENT); + getServer().getPlayerList().sendToAllNearExcept(point.excluded, point.x, point.y, point.z, point.r2, point.dim, + pkt); + } - public void sendToAllAround( final AppEngPacket message, final TargetPoint point ) - { - IPacket pkt = message.toPacket( NetworkDirection.PLAY_TO_CLIENT ); - getServer().getPlayerList().sendToAllNearExcept( point.excluded, point.x, point.y, point.z, point.r2, point.dim, pkt); - } + public void sendToDimension(final AppEngPacket message, final DimensionType dim) { + getServer().getPlayerList().sendPacketToAllPlayersInDimension(message.toPacket(NetworkDirection.PLAY_TO_CLIENT), + dim); + } - public void sendToDimension( final AppEngPacket message, final DimensionType dim ) - { - getServer().getPlayerList().sendPacketToAllPlayersInDimension( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ), dim ); - } + public void sendToServer(final AppEngPacket message) { + Minecraft.getInstance().getConnection().sendPacket(message.toPacket(NetworkDirection.PLAY_TO_SERVER)); + } - public void sendToServer( final AppEngPacket message ) - { - Minecraft.getInstance().getConnection().sendPacket( message.toPacket( NetworkDirection.PLAY_TO_SERVER ) ); - } - - private MinecraftServer getServer() - { - return LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER ); - } + private MinecraftServer getServer() { + return LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + } } diff --git a/src/main/java/appeng/core/sync/network/TargetPoint.java b/src/main/java/appeng/core/sync/network/TargetPoint.java index 8e95cabdf..509d8500e 100644 --- a/src/main/java/appeng/core/sync/network/TargetPoint.java +++ b/src/main/java/appeng/core/sync/network/TargetPoint.java @@ -1,44 +1,39 @@ package appeng.core.sync.network; - import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.world.dimension.DimensionType; - /** * Created by covers1624 on 1/6/20. */ -public class TargetPoint -{ - - public final ServerPlayerEntity excluded; - public final double x; - public final double y; - public final double z; - public final double r2; - public final DimensionType dim; +public class TargetPoint { - public TargetPoint( double x, double y, double z, double r2, DimensionType dim ) - { - this( null, x, y, z, r2, dim ); - } + public final ServerPlayerEntity excluded; + public final double x; + public final double y; + public final double z; + public final double r2; + public final DimensionType dim; - public TargetPoint( ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim ) - { - this.excluded = excluded; - this.x = x; - this.y = y; - this.z = z; - this.r2 = r2; - this.dim = dim; - } + public TargetPoint(double x, double y, double z, double r2, DimensionType dim) { + this(null, x, y, z, r2, dim); + } + public TargetPoint(ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim) { + this.excluded = excluded; + this.x = x; + this.y = y; + this.z = z; + this.r2 = r2; + this.dim = dim; + } - public static TargetPoint at(double x, double y, double z, double r2, DimensionType dim) { - return new TargetPoint( x, y, z, r2, dim ); - } + public static TargetPoint at(double x, double y, double z, double r2, DimensionType dim) { + return new TargetPoint(x, y, z, r2, dim); + } - public static TargetPoint at(ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim) { - return new TargetPoint( excluded, x, y, z, r2, dim ); - } + public static TargetPoint at(ServerPlayerEntity excluded, double x, double y, double z, double r2, + DimensionType dim) { + return new TargetPoint(excluded, x, y, z, r2, dim); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketAssemblerAnimation.java b/src/main/java/appeng/core/sync/packets/PacketAssemblerAnimation.java index f0febf07f..ca827ece7 100644 --- a/src/main/java/appeng/core/sync/packets/PacketAssemblerAnimation.java +++ b/src/main/java/appeng/core/sync/packets/PacketAssemblerAnimation.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.IOException; import io.netty.buffer.Unpooled; @@ -36,50 +35,46 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.item.AEItemStack; +public class PacketAssemblerAnimation extends AppEngPacket { -public class PacketAssemblerAnimation extends AppEngPacket -{ + private final int x; + private final int y; + private final int z; + public final byte rate; + public final IAEItemStack is; - private final int x; - private final int y; - private final int z; - public final byte rate; - public final IAEItemStack is; + public PacketAssemblerAnimation(final PacketBuffer stream) { + this.x = stream.readInt(); + this.y = stream.readInt(); + this.z = stream.readInt(); + this.rate = stream.readByte(); + this.is = AEItemStack.fromPacket(stream); + } - public PacketAssemblerAnimation( final PacketBuffer stream ) - { - this.x = stream.readInt(); - this.y = stream.readInt(); - this.z = stream.readInt(); - this.rate = stream.readByte(); - this.is = AEItemStack.fromPacket( stream ); - } + // api + public PacketAssemblerAnimation(final BlockPos pos, final byte rate, final IAEItemStack is) { - // api - public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is ) - { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(this.x = pos.getX()); + data.writeInt(this.y = pos.getY()); + data.writeInt(this.z = pos.getZ()); + data.writeByte(this.rate = rate); + is.writeToPacket(data); + this.is = is; - data.writeInt( this.getPacketID() ); - data.writeInt( this.x = pos.getX() ); - data.writeInt( this.y = pos.getY() ); - data.writeInt( this.z = pos.getZ() ); - data.writeByte( this.rate = rate ); - is.writeToPacket( data ); - this.is = is; + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); + final double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); + final double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); - final double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); - final double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D); - - AppEng.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2, this ); - } + AppEng.proxy.spawnEffect(EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2, + this); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketClick.java b/src/main/java/appeng/core/sync/packets/PacketClick.java index 6ec27f17b..fbbfd2c82 100644 --- a/src/main/java/appeng/core/sync/packets/PacketClick.java +++ b/src/main/java/appeng/core/sync/packets/PacketClick.java @@ -18,6 +18,18 @@ package appeng.core.sync.packets; +import io.netty.buffer.Unpooled; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.Vec3d; import appeng.api.AEApi; import appeng.api.definitions.IComparableDefinition; @@ -32,149 +44,122 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.items.tools.ToolNetworkTool; import appeng.items.tools.powered.ToolColorApplicator; -import io.netty.buffer.Unpooled; -import net.minecraft.block.Block; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +public class PacketClick extends AppEngPacket { -public class PacketClick extends AppEngPacket -{ + private final int x; + private final int y; + private final int z; + private Direction side; + private final float hitX; + private final float hitY; + private final float hitZ; + private Hand hand; + private final boolean leftClick; - private final int x; - private final int y; - private final int z; - private Direction side; - private final float hitX; - private final float hitY; - private final float hitZ; - private Hand hand; - private final boolean leftClick; + public PacketClick(final PacketBuffer stream) { + this.x = stream.readInt(); + this.y = stream.readInt(); + this.z = stream.readInt(); + byte side = stream.readByte(); + if (side != -1) { + this.side = Direction.values()[side]; + } else { + this.side = null; + } + this.hitX = stream.readFloat(); + this.hitY = stream.readFloat(); + this.hitZ = stream.readFloat(); + this.hand = Hand.values()[stream.readByte()]; + this.leftClick = stream.readBoolean(); + } - public PacketClick( final PacketBuffer stream ) - { - this.x = stream.readInt(); - this.y = stream.readInt(); - this.z = stream.readInt(); - byte side = stream.readByte(); - if( side != -1 ) - { - this.side = Direction.values()[side]; - } - else - { - this.side = null; - } - this.hitX = stream.readFloat(); - this.hitY = stream.readFloat(); - this.hitZ = stream.readFloat(); - this.hand = Hand.values()[stream.readByte()]; - this.leftClick = stream.readBoolean(); - } + // API for when a block was right clicked + public PacketClick(ItemUseContext context) { + this(context.getPos(), context.getFace(), context.getPos().getX(), context.getPos().getY(), + context.getPos().getZ(), context.getHand()); + } - // API for when a block was right clicked - public PacketClick( ItemUseContext context ) - { - this(context.getPos(), context.getFace(), context.getPos().getX(), context.getPos().getY(), context.getPos().getZ(), context.getHand()); - } + // API for when an item in hand was right-clicked, with no block context + public PacketClick(Hand hand) { + this(BlockPos.ZERO, null, 0, 0, 0, hand); + } - // API for when an item in hand was right-clicked, with no block context - public PacketClick( Hand hand ) - { - this(BlockPos.ZERO, null, 0, 0, 0, hand); - } + private PacketClick(final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, + final Hand hand) { + this(pos, side, hitX, hitY, hitZ, hand, false); + } - private PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) - { - this( pos, side, hitX, hitY, hitZ, hand, false ); - } + public PacketClick(final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, + final Hand hand, boolean leftClick) { - public PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand, boolean leftClick ) - { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(this.x = pos.getX()); + data.writeInt(this.y = pos.getY()); + data.writeInt(this.z = pos.getZ()); + if (side == null) { + data.writeByte(-1); + } else { + data.writeByte(side.ordinal()); + } + data.writeFloat(this.hitX = hitX); + data.writeFloat(this.hitY = hitY); + data.writeFloat(this.hitZ = hitZ); + data.writeByte(hand.ordinal()); + data.writeBoolean(this.leftClick = leftClick); - data.writeInt( this.getPacketID() ); - data.writeInt( this.x = pos.getX() ); - data.writeInt( this.y = pos.getY() ); - data.writeInt( this.z = pos.getZ() ); - if( side == null ) - { - data.writeByte( -1 ); - } - else - { - data.writeByte( side.ordinal() ); - } - data.writeFloat( this.hitX = hitX ); - data.writeFloat( this.hitY = hitY ); - data.writeFloat( this.hitZ = hitZ ); - data.writeByte( hand.ordinal() ); - data.writeBoolean( this.leftClick = leftClick ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + // Indicates that block pos, side and hit vector have valid data + private boolean hasBlockContext() { + return side != null; + } - // Indicates that block pos, side and hit vector have valid data - private boolean hasBlockContext() { - return side != null; - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final BlockPos pos = new BlockPos(this.x, this.y, this.z); - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final BlockPos pos = new BlockPos( this.x, this.y, this.z ); + final ItemStack is = player.getHeldItem(hand); + final IItems items = AEApi.instance().definitions().items(); + final IComparableDefinition maybeMemoryCard = items.memoryCard(); + final IComparableDefinition maybeColorApplicator = items.colorApplicator(); - final ItemStack is = player.getHeldItem(hand); - final IItems items = AEApi.instance().definitions().items(); - final IComparableDefinition maybeMemoryCard = items.memoryCard(); - final IComparableDefinition maybeColorApplicator = items.colorApplicator(); + if (this.leftClick) { + final Block block = player.world.getBlockState(pos).getBlock(); + if (block instanceof BlockCableBus) { + ((BlockCableBus) block).onBlockClickPacket(player.world, pos, player, this.hand, + new Vec3d(this.hitX, this.hitY, this.hitZ)); + } + } else { + if (!is.isEmpty()) { + if (is.getItem() instanceof ToolNetworkTool) { + final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); - if( this.leftClick ) - { - final Block block = player.world.getBlockState( pos ).getBlock(); - if( block instanceof BlockCableBus) - { - ( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) ); - } - } - else - { - if( !is.isEmpty() ) - { - if( is.getItem() instanceof ToolNetworkTool) - { - final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); + if (hasBlockContext()) { + // Reconstruct an item use context + ItemUseContext useContext = new ItemUseContext(player, hand, + new BlockRayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos, false)); + tnt.serverSideToolLogic(useContext); + } else { + ContainerOpener.openContainer(ContainerNetworkTool.TYPE, player, + ContainerLocator.forHand(player, hand)); + } + } - if (hasBlockContext()) { - // Reconstruct an item use context - ItemUseContext useContext = new ItemUseContext(player, hand, new BlockRayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos, false)); - tnt.serverSideToolLogic(useContext); - } else { - ContainerOpener.openContainer(ContainerNetworkTool.TYPE, player, ContainerLocator.forHand(player, hand)); - } - } + if (maybeMemoryCard.isSameAs(is)) { + final IMemoryCard mem = (IMemoryCard) is.getItem(); + mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED); + is.setTag(null); + } - if( maybeMemoryCard.isSameAs( is ) ) - { - final IMemoryCard mem = (IMemoryCard) is.getItem(); - mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); - is.setTag( null ); - } - - else if( maybeColorApplicator.isSameAs( is ) ) - { - final ToolColorApplicator mem = (ToolColorApplicator) is.getItem(); - mem.cycleColors( is, mem.getColor( is ), 1 ); - } - } - } - } + else if (maybeColorApplicator.isSameAs(is)) { + final ToolColorApplicator mem = (ToolColorApplicator) is.getItem(); + mem.cycleColors(is, mem.getColor(is), 1); + } + } + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketCompassRequest.java b/src/main/java/appeng/core/sync/packets/PacketCompassRequest.java index d4fc41d04..ff07c0e5b 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCompassRequest.java +++ b/src/main/java/appeng/core/sync/packets/PacketCompassRequest.java @@ -18,8 +18,6 @@ package appeng.core.sync.packets; - -import appeng.core.worlddata.WorldData; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -30,54 +28,51 @@ import appeng.api.util.DimensionalCoord; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.NetworkHandler; +import appeng.core.worlddata.WorldData; import appeng.services.compass.ICompassCallback; +public class PacketCompassRequest extends AppEngPacket implements ICompassCallback { -public class PacketCompassRequest extends AppEngPacket implements ICompassCallback -{ + final long attunement; + final int cx; + final int cz; + final int cdy; - final long attunement; - final int cx; - final int cz; - final int cdy; + private PlayerEntity talkBackTo; - private PlayerEntity talkBackTo; + public PacketCompassRequest(final PacketBuffer stream) { + this.attunement = stream.readLong(); + this.cx = stream.readInt(); + this.cz = stream.readInt(); + this.cdy = stream.readInt(); + } - public PacketCompassRequest( final PacketBuffer stream ) - { - this.attunement = stream.readLong(); - this.cx = stream.readInt(); - this.cz = stream.readInt(); - this.cdy = stream.readInt(); - } + // api + public PacketCompassRequest(final long attunement, final int cx, final int cz, final int cdy) { - // api - public PacketCompassRequest( final long attunement, final int cx, final int cz, final int cdy ) - { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeLong(this.attunement = attunement); + data.writeInt(this.cx = cx); + data.writeInt(this.cz = cz); + data.writeInt(this.cdy = cdy); - data.writeInt( this.getPacketID() ); - data.writeLong( this.attunement = attunement ); - data.writeInt( this.cx = cx ); - data.writeInt( this.cz = cz ); - data.writeInt( this.cdy = cdy ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + public void calculatedDirection(final boolean hasResult, final boolean spin, final double radians, + final double dist) { + NetworkHandler.instance().sendTo(new PacketCompassResponse(this, hasResult, spin, radians), + (ServerPlayerEntity) this.talkBackTo); + } - @Override - public void calculatedDirection( final boolean hasResult, final boolean spin, final double radians, final double dist ) - { - NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (ServerPlayerEntity) this.talkBackTo ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + this.talkBackTo = player; - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - this.talkBackTo = player; - - final DimensionalCoord loc = new DimensionalCoord( player.world, this.cx << 4, this.cdy << 5, this.cz << 4 ); - WorldData.instance().compassData().service().getCompassDirection( loc, 174, this ); - } + final DimensionalCoord loc = new DimensionalCoord(player.world, this.cx << 4, this.cdy << 5, this.cz << 4); + WorldData.instance().compassData().service().getCompassDirection(loc, 174, this); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketCompassResponse.java b/src/main/java/appeng/core/sync/packets/PacketCompassResponse.java index 1287ad0ae..7fbfd4fac 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCompassResponse.java +++ b/src/main/java/appeng/core/sync/packets/PacketCompassResponse.java @@ -18,9 +18,6 @@ package appeng.core.sync.packets; - -import appeng.hooks.CompassManager; -import appeng.hooks.CompassResult; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -28,50 +25,48 @@ import net.minecraft.network.PacketBuffer; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +import appeng.hooks.CompassManager; +import appeng.hooks.CompassResult; +public class PacketCompassResponse extends AppEngPacket { -public class PacketCompassResponse extends AppEngPacket -{ + private final long attunement; + private final int cx; + private final int cz; + private final int cdy; - private final long attunement; - private final int cx; - private final int cz; - private final int cdy; + private CompassResult cr; - private CompassResult cr; + public PacketCompassResponse(final PacketBuffer stream) { + this.attunement = stream.readLong(); + this.cx = stream.readInt(); + this.cz = stream.readInt(); + this.cdy = stream.readInt(); - public PacketCompassResponse( final PacketBuffer stream ) - { - this.attunement = stream.readLong(); - this.cx = stream.readInt(); - this.cz = stream.readInt(); - this.cdy = stream.readInt(); + this.cr = new CompassResult(stream.readBoolean(), stream.readBoolean(), stream.readDouble()); + } - this.cr = new CompassResult( stream.readBoolean(), stream.readBoolean(), stream.readDouble() ); - } + // api + public PacketCompassResponse(final PacketCompassRequest req, final boolean hasResult, final boolean spin, + final double radians) { - // api - public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians ) - { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeLong(this.attunement = req.attunement); + data.writeInt(this.cx = req.cx); + data.writeInt(this.cz = req.cz); + data.writeInt(this.cdy = req.cdy); - data.writeInt( this.getPacketID() ); - data.writeLong( this.attunement = req.attunement ); - data.writeInt( this.cx = req.cx ); - data.writeInt( this.cz = req.cz ); - data.writeInt( this.cdy = req.cdy ); + data.writeBoolean(hasResult); + data.writeBoolean(spin); + data.writeDouble(radians); - data.writeBoolean( hasResult ); - data.writeBoolean( spin ); - data.writeDouble( radians ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - CompassManager.INSTANCE.postResult( this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr ); - } + @Override + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + CompassManager.INSTANCE.postResult(this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java b/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java index aa05b9433..212415df9 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java +++ b/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -27,7 +26,6 @@ import java.io.OutputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import appeng.client.gui.implementations.GuiInterfaceTerminal; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -39,83 +37,70 @@ import net.minecraft.network.PacketBuffer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import appeng.client.gui.implementations.GuiInterfaceTerminal; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; - //TODO, this is pointless, NBT is already compressed when written to a PacketBuffer. -public class PacketCompressedNBT extends AppEngPacket -{ +public class PacketCompressedNBT extends AppEngPacket { - // input. - private final CompoundNBT in; - // output... - private final PacketBuffer data; - private final GZIPOutputStream compressFrame; + // input. + private final CompoundNBT in; + // output... + private final PacketBuffer data; + private final GZIPOutputStream compressFrame; - public PacketCompressedNBT( final PacketBuffer stream ) - { - this.data = null; - this.compressFrame = null; + public PacketCompressedNBT(final PacketBuffer stream) { + this.data = null; + this.compressFrame = null; - try( DataInputStream inStream = new DataInputStream( new GZIPInputStream( new InputStream() - { + try (DataInputStream inStream = new DataInputStream(new GZIPInputStream(new InputStream() { - @Override - public int read() - { - if( stream.readableBytes() <= 0 ) - { - return -1; - } + @Override + public int read() { + if (stream.readableBytes() <= 0) { + return -1; + } - return stream.readByte() & 0xff; - } - } ) ) ) - { - this.in = CompressedStreamTools.read( inStream ); - } - catch( IOException e ) - { - throw new RuntimeException( "Failed to decompress packet.", e ); - } - } + return stream.readByte() & 0xff; + } + }))) { + this.in = CompressedStreamTools.read(inStream); + } catch (IOException e) { + throw new RuntimeException("Failed to decompress packet.", e); + } + } - // FIXME: this is pointless, PacketBuffer.writeNBT will already compress - // api - public PacketCompressedNBT( final CompoundNBT din ) throws IOException - { + // FIXME: this is pointless, PacketBuffer.writeNBT will already compress + // api + public PacketCompressedNBT(final CompoundNBT din) throws IOException { - this.data = new PacketBuffer( Unpooled.buffer( 2048 ) ); - this.data.writeInt( this.getPacketID() ); + this.data = new PacketBuffer(Unpooled.buffer(2048)); + this.data.writeInt(this.getPacketID()); - this.in = din; + this.in = din; - this.compressFrame = new GZIPOutputStream( new OutputStream() - { + this.compressFrame = new GZIPOutputStream(new OutputStream() { - @Override - public void write( final int value ) - { - PacketCompressedNBT.this.data.writeByte( value ); - } - } ); + @Override + public void write(final int value) { + PacketCompressedNBT.this.data.writeByte(value); + } + }); - CompressedStreamTools.write( din, new DataOutputStream( this.compressFrame ) ); - this.compressFrame.close(); + CompressedStreamTools.write(din, new DataOutputStream(this.compressFrame)); + this.compressFrame.close(); - this.configureWrite( this.data ); - } + this.configureWrite(this.data); + } - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final Screen gs = Minecraft.getInstance().currentScreen; + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final Screen gs = Minecraft.getInstance().currentScreen; - if( gs instanceof GuiInterfaceTerminal) - { - ( (GuiInterfaceTerminal) gs ).postUpdate( this.in ); - } - } + if (gs instanceof GuiInterfaceTerminal) { + ((GuiInterfaceTerminal) gs).postUpdate(this.in); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketConfigButton.java b/src/main/java/appeng/core/sync/packets/PacketConfigButton.java index ea0d7a45e..67d4858b4 100644 --- a/src/main/java/appeng/core/sync/packets/PacketConfigButton.java +++ b/src/main/java/appeng/core/sync/packets/PacketConfigButton.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -32,46 +31,44 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.Platform; +public final class PacketConfigButton extends AppEngPacket { + private final Settings option; + private final boolean rotationDirection; -public final class PacketConfigButton extends AppEngPacket -{ - private final Settings option; - private final boolean rotationDirection; + public PacketConfigButton(final PacketBuffer stream) { + this.option = Settings.values()[stream.readInt()]; + this.rotationDirection = stream.readBoolean(); + } - public PacketConfigButton( final PacketBuffer stream ) - { - this.option = Settings.values()[stream.readInt()]; - this.rotationDirection = stream.readBoolean(); - } + // api + public PacketConfigButton(final Settings option, final boolean rotationDirection) { + this.option = option; + this.rotationDirection = rotationDirection; - // api - public PacketConfigButton( final Settings option, final boolean rotationDirection ) - { - this.option = option; - this.rotationDirection = rotationDirection; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(option.ordinal()); + data.writeBoolean(rotationDirection); - data.writeInt( this.getPacketID() ); - data.writeInt( option.ordinal() ); - data.writeBoolean( rotationDirection ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final ServerPlayerEntity sender = (ServerPlayerEntity) player; - // FIXME if( sender.openContainer instanceof AEBaseContainer ) - // FIXME { - // FIXME final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer; - // FIXME if( baseContainer.getTarget() instanceof IConfigurableObject ) - // FIXME { - // FIXME final IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager(); - // FIXME final Enum newState = EnumCycler.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() ); - // FIXME cm.putSetting( this.option, newState ); - // FIXME } - // FIXME } - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final ServerPlayerEntity sender = (ServerPlayerEntity) player; + // FIXME if( sender.openContainer instanceof AEBaseContainer ) + // FIXME { + // FIXME final AEBaseContainer baseContainer = (AEBaseContainer) + // sender.openContainer; + // FIXME if( baseContainer.getTarget() instanceof IConfigurableObject ) + // FIXME { + // FIXME final IConfigManager cm = ( (IConfigurableObject) + // baseContainer.getTarget() ).getConfigManager(); + // FIXME final Enum newState = EnumCycler.rotateEnum( cm.getSetting( + // this.option ), this.rotationDirection, this.option.getPossibleValues() ); + // FIXME cm.putSetting( this.option, newState ); + // FIXME } + // FIXME } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java index 206bf0a65..5a71c8e2a 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java +++ b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java @@ -18,11 +18,8 @@ package appeng.core.sync.packets; - import java.util.concurrent.Future; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerInscriber; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -35,92 +32,80 @@ import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.crafting.ICraftingJob; import appeng.api.networking.security.IActionHost; import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; import appeng.container.implementations.ContainerCraftAmount; import appeng.container.implementations.ContainerCraftConfirm; +import appeng.container.implementations.ContainerInscriber; import appeng.core.AELog; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +public class PacketCraftRequest extends AppEngPacket { -public class PacketCraftRequest extends AppEngPacket -{ + private final long amount; + private final boolean heldShift; - private final long amount; - private final boolean heldShift; + public PacketCraftRequest(final PacketBuffer stream) { + this.heldShift = stream.readBoolean(); + this.amount = stream.readLong(); + } - public PacketCraftRequest( final PacketBuffer stream ) - { - this.heldShift = stream.readBoolean(); - this.amount = stream.readLong(); - } + public PacketCraftRequest(final int craftAmt, final boolean shift) { + this.amount = craftAmt; + this.heldShift = shift; - public PacketCraftRequest( final int craftAmt, final boolean shift ) - { - this.amount = craftAmt; - this.heldShift = shift; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeBoolean(shift); + data.writeLong(this.amount); - data.writeInt( this.getPacketID() ); - data.writeBoolean( shift ); - data.writeLong( this.amount ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + if (player.openContainer instanceof ContainerCraftAmount) { + final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer; + final Object target = cca.getTarget(); + if (target instanceof IActionHost) { + final IActionHost ah = (IActionHost) target; + final IGridNode gn = ah.getActionableNode(); + if (gn == null) { + return; + } - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - if( player.openContainer instanceof ContainerCraftAmount ) - { - final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer; - final Object target = cca.getTarget(); - if( target instanceof IActionHost ) - { - final IActionHost ah = (IActionHost) target; - final IGridNode gn = ah.getActionableNode(); - if( gn == null ) - { - return; - } + final IGrid g = gn.getGrid(); + if (g == null || cca.getItemToCraft() == null) { + return; + } - final IGrid g = gn.getGrid(); - if( g == null || cca.getItemToCraft() == null ) - { - return; - } + cca.getItemToCraft().setStackSize(this.amount); - cca.getItemToCraft().setStackSize( this.amount ); + Future futureJob = null; + try { + final ICraftingGrid cg = g.getCache(ICraftingGrid.class); + futureJob = cg.beginCraftingJob(cca.getWorld(), cca.getGrid(), cca.getActionSrc(), + cca.getItemToCraft(), null); - Future futureJob = null; - try - { - final ICraftingGrid cg = g.getCache( ICraftingGrid.class ); - futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null ); + final ContainerLocator locator = cca.getLocator(); + if (locator != null) { + ContainerOpener.openContainer(ContainerCraftConfirm.TYPE, player, locator); - final ContainerLocator locator = cca.getLocator(); - if( locator != null ) - { - ContainerOpener.openContainer(ContainerCraftConfirm.TYPE, player, locator); - - if( player.openContainer instanceof ContainerCraftConfirm ) - { - final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer; - ccc.setAutoStart( this.heldShift ); - ccc.setJob( futureJob ); - cca.detectAndSendChanges(); - } - } - } - catch( final Throwable e ) - { - if( futureJob != null ) - { - futureJob.cancel( true ); - } - AELog.debug( e ); - } - } - } - } + if (player.openContainer instanceof ContainerCraftConfirm) { + final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer; + ccc.setAutoStart(this.heldShift); + ccc.setJob(futureJob); + cca.detectAndSendChanges(); + } + } + } catch (final Throwable e) { + if (futureJob != null) { + futureJob.cancel(true); + } + AELog.debug(e); + } + } + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketFluidSlot.java b/src/main/java/appeng/core/sync/packets/PacketFluidSlot.java index 5e9ad65bc..e010c919c 100644 --- a/src/main/java/appeng/core/sync/packets/PacketFluidSlot.java +++ b/src/main/java/appeng/core/sync/packets/PacketFluidSlot.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.util.HashMap; import java.util.Map; @@ -35,60 +34,49 @@ import appeng.core.sync.network.INetworkInfo; import appeng.fluids.container.IFluidSyncContainer; import appeng.fluids.util.AEFluidStack; +public class PacketFluidSlot extends AppEngPacket { + private final Map list; -public class PacketFluidSlot extends AppEngPacket -{ - private final Map list; + public PacketFluidSlot(final PacketBuffer stream) { + this.list = new HashMap<>(); + CompoundNBT tag = stream.readCompoundTag(); - public PacketFluidSlot( final PacketBuffer stream ) - { - this.list = new HashMap<>(); - CompoundNBT tag = stream.readCompoundTag(); + for (final String key : tag.keySet()) { + this.list.put(Integer.parseInt(key), AEFluidStack.fromNBT(tag.getCompound(key))); + } + } - for( final String key : tag.keySet() ) - { - this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompound( key ) ) ); - } - } + // api + public PacketFluidSlot(final Map list) { + this.list = list; + final CompoundNBT sendTag = new CompoundNBT(); + for (Map.Entry fs : list.entrySet()) { + final CompoundNBT tag = new CompoundNBT(); + if (fs.getValue() != null) { + fs.getValue().writeToNBT(tag); + } + sendTag.put(fs.getKey().toString(), tag); + } - // api - public PacketFluidSlot( final Map list ) - { - this.list = list; - final CompoundNBT sendTag = new CompoundNBT(); - for( Map.Entry fs : list.entrySet() ) - { - final CompoundNBT tag = new CompoundNBT(); - if( fs.getValue() != null ) - { - fs.getValue().writeToNBT( tag ); - } - sendTag.put( fs.getKey().toString(), tag ); - } + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); + data.writeInt(this.getPacketID()); + data.writeCompoundTag(sendTag); + this.configureWrite(data); + } - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); - data.writeInt( this.getPacketID() ); - data.writeCompoundTag( sendTag ); - this.configureWrite( data ); - } + @Override + public void clientPacketData(final INetworkInfo manager, final PlayerEntity player) { + final Container c = player.openContainer; + if (c instanceof IFluidSyncContainer) { + ((IFluidSyncContainer) c).receiveFluidSlots(this.list); + } + } - @Override - public void clientPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final Container c = player.openContainer; - if( c instanceof IFluidSyncContainer ) - { - ( (IFluidSyncContainer) c ).receiveFluidSlots( this.list ); - } - } - - @Override - public void serverPacketData( INetworkInfo manager, PlayerEntity player ) - { - final Container c = player.openContainer; - if( c instanceof IFluidSyncContainer ) - { - ( (IFluidSyncContainer) c ).receiveFluidSlots( this.list ); - } - } + @Override + public void serverPacketData(INetworkInfo manager, PlayerEntity player) { + final Container c = player.openContainer; + if (c instanceof IFluidSyncContainer) { + ((IFluidSyncContainer) c).receiveFluidSlots(this.list); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java index 2c20ea0be..667c75cc2 100644 --- a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java @@ -18,6 +18,12 @@ package appeng.core.sync.packets; +import io.netty.buffer.Unpooled; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; import appeng.api.storage.data.IAEItemStack; import appeng.container.AEBaseContainer; @@ -30,139 +36,109 @@ import appeng.core.sync.network.INetworkInfo; import appeng.helpers.InventoryAction; import appeng.util.Platform; import appeng.util.item.AEItemStack; -import io.netty.buffer.Unpooled; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; +public class PacketInventoryAction extends AppEngPacket { -public class PacketInventoryAction extends AppEngPacket -{ + private final InventoryAction action; + private final int slot; + private final long id; + private final IAEItemStack slotItem; - private final InventoryAction action; - private final int slot; - private final long id; - private final IAEItemStack slotItem; + public PacketInventoryAction(final PacketBuffer stream) { + this.action = InventoryAction.values()[stream.readInt()]; + this.slot = stream.readInt(); + this.id = stream.readLong(); + final boolean hasItem = stream.readBoolean(); + if (hasItem) { + this.slotItem = AEItemStack.fromPacket(stream); + } else { + this.slotItem = null; + } + } - public PacketInventoryAction( final PacketBuffer stream ) - { - this.action = InventoryAction.values()[stream.readInt()]; - this.slot = stream.readInt(); - this.id = stream.readLong(); - final boolean hasItem = stream.readBoolean(); - if( hasItem ) - { - this.slotItem = AEItemStack.fromPacket( stream ); - } - else - { - this.slotItem = null; - } - } + // api + public PacketInventoryAction(final InventoryAction action, final int slot, final IAEItemStack slotItem) { - // api - public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem ) - { + if (Platform.isClient()) { + throw new IllegalStateException("invalid packet, client cannot post inv actions with stacks."); + } - if( Platform.isClient() ) - { - throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." ); - } + this.action = action; + this.slot = slot; + this.id = 0; + this.slotItem = slotItem; - this.action = action; - this.slot = slot; - this.id = 0; - this.slotItem = slotItem; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(action.ordinal()); + data.writeInt(slot); + data.writeLong(this.id); - data.writeInt( this.getPacketID() ); - data.writeInt( action.ordinal() ); - data.writeInt( slot ); - data.writeLong( this.id ); + if (slotItem == null) { + data.writeBoolean(false); + } else { + data.writeBoolean(true); + slotItem.writeToPacket(data); + } - if( slotItem == null ) - { - data.writeBoolean( false ); - } - else - { - data.writeBoolean( true ); - slotItem.writeToPacket( data ); - } + this.configureWrite(data); + } - this.configureWrite( data ); - } + // api + public PacketInventoryAction(final InventoryAction action, final int slot, final long id) { + this.action = action; + this.slot = slot; + this.id = id; + this.slotItem = null; - // api - public PacketInventoryAction( final InventoryAction action, final int slot, final long id ) - { - this.action = action; - this.slot = slot; - this.id = id; - this.slotItem = null; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(action.ordinal()); + data.writeInt(slot); + data.writeLong(id); + data.writeBoolean(false); - data.writeInt( this.getPacketID() ); - data.writeInt( action.ordinal() ); - data.writeInt( slot ); - data.writeLong( id ); - data.writeBoolean( false ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final ServerPlayerEntity sender = (ServerPlayerEntity) player; + if (sender.openContainer instanceof AEBaseContainer) { + final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer; + if (this.action == InventoryAction.AUTO_CRAFT) { + final ContainerLocator locator = baseContainer.getLocator(); + if (locator != null) { + ContainerOpener.openContainer(ContainerCraftAmount.TYPE, player, locator); - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final ServerPlayerEntity sender = (ServerPlayerEntity) player; - if( sender.openContainer instanceof AEBaseContainer ) - { - final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer; - if( this.action == InventoryAction.AUTO_CRAFT ) - { - final ContainerLocator locator = baseContainer.getLocator(); - if( locator != null ) - { - ContainerOpener.openContainer(ContainerCraftAmount.TYPE, player, locator); + if (sender.openContainer instanceof ContainerCraftAmount) { + final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer; - if( sender.openContainer instanceof ContainerCraftAmount ) - { - final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer; + if (baseContainer.getTargetStack() != null) { + cca.getCraftingItem().putStack(baseContainer.getTargetStack().asItemStackRepresentation()); + // This is the *actual* item that matters, not the display item above + cca.setItemToCraft(baseContainer.getTargetStack()); + } - if( baseContainer.getTargetStack() != null ) - { - cca.getCraftingItem().putStack( baseContainer.getTargetStack().asItemStackRepresentation() ); - // This is the *actual* item that matters, not the display item above - cca.setItemToCraft( baseContainer.getTargetStack() ); - } + cca.detectAndSendChanges(); + } + } + } else { + baseContainer.doAction(sender, this.action, this.slot, this.id); + } + } + } - cca.detectAndSendChanges(); - } - } - } - else - { - baseContainer.doAction( sender, this.action, this.slot, this.id ); - } - } - } - - @Override - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - if( this.action == InventoryAction.UPDATE_HAND ) - { - if( this.slotItem == null ) - { - AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( ItemStack.EMPTY ); - } - else - { - AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.createItemStack() ); - } - } - } + @Override + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + if (this.action == InventoryAction.UPDATE_HAND) { + if (this.slotItem == null) { + AppEng.proxy.getPlayers().get(0).inventory.setItemStack(ItemStack.EMPTY); + } else { + AppEng.proxy.getPlayers().get(0).inventory.setItemStack(this.slotItem.createItemStack()); + } + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java index f376cba31..e7f3cec83 100644 --- a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.IOException; import io.netty.buffer.Unpooled; @@ -55,188 +54,154 @@ import appeng.util.inv.WrapperInvItemHandler; import appeng.util.item.AEItemStack; import appeng.util.prioritylist.IPartitionList; +public class PacketJEIRecipe extends AppEngPacket { -public class PacketJEIRecipe extends AppEngPacket -{ + private ItemStack[][] recipe; - private ItemStack[][] recipe; + public PacketJEIRecipe(final PacketBuffer stream) { + final CompoundNBT comp = stream.readCompoundTag(); + if (comp != null) { + this.recipe = new ItemStack[9][]; + for (int x = 0; x < this.recipe.length; x++) { + final ListNBT list = comp.getList("#" + x, 10); + if (list.size() > 0) { + this.recipe[x] = new ItemStack[list.size()]; + for (int y = 0; y < list.size(); y++) { + this.recipe[x][y] = ItemStack.read(list.getCompound(y)); + } + } + } + } + } - public PacketJEIRecipe( final PacketBuffer stream ) - { - final CompoundNBT comp = stream.readCompoundTag(); - if( comp != null ) - { - this.recipe = new ItemStack[9][]; - for( int x = 0; x < this.recipe.length; x++ ) - { - final ListNBT list = comp.getList( "#" + x, 10 ); - if( list.size() > 0 ) - { - this.recipe[x] = new ItemStack[list.size()]; - for( int y = 0; y < list.size(); y++ ) - { - this.recipe[x][y] = ItemStack.read( list.getCompound( y ) ); - } - } - } - } - } + // api + public PacketJEIRecipe(final CompoundNBT recipe) { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - // api - public PacketJEIRecipe( final CompoundNBT recipe ) - { - final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); + data.writeInt(this.getPacketID()); - data.writeInt( this.getPacketID() ); + data.writeCompoundTag(recipe); - data.writeCompoundTag( recipe ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final ServerPlayerEntity pmp = (ServerPlayerEntity) player; + final Container con = pmp.openContainer; - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final ServerPlayerEntity pmp = (ServerPlayerEntity) player; - final Container con = pmp.openContainer; + if (!(con instanceof IContainerCraftingPacket)) { + return; + } - if( !( con instanceof IContainerCraftingPacket ) ) - { - return; - } + final IContainerCraftingPacket cct = (IContainerCraftingPacket) con; + final IGridNode node = cct.getNetworkNode(); - final IContainerCraftingPacket cct = (IContainerCraftingPacket) con; - final IGridNode node = cct.getNetworkNode(); + if (node == null) { + return; + } - if( node == null ) - { - return; - } + final IGrid grid = node.getGrid(); + if (grid == null) { + return; + } - final IGrid grid = node.getGrid(); - if( grid == null ) - { - return; - } + final IStorageGrid inv = grid.getCache(IStorageGrid.class); + final IEnergyGrid energy = grid.getCache(IEnergyGrid.class); + final ISecurityGrid security = grid.getCache(ISecurityGrid.class); + final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class); + final IItemHandler craftMatrix = cct.getInventoryByName("crafting"); + final IItemHandler playerInventory = cct.getInventoryByName("player"); - final IStorageGrid inv = grid.getCache( IStorageGrid.class ); - final IEnergyGrid energy = grid.getCache( IEnergyGrid.class ); - final ISecurityGrid security = grid.getCache( ISecurityGrid.class ); - final ICraftingGrid crafting = grid.getCache( ICraftingGrid.class ); - final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" ); - final IItemHandler playerInventory = cct.getInventoryByName( "player" ); + if (inv != null && this.recipe != null && security != null) { + final IMEMonitor storage = inv + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final IPartitionList filter = ItemViewCell.createFilter(cct.getViewCells()); - if( inv != null && this.recipe != null && security != null ) - { - final IMEMonitor storage = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final IPartitionList filter = ItemViewCell.createFilter( cct.getViewCells() ); + for (int x = 0; x < craftMatrix.getSlots(); x++) { + ItemStack currentItem = craftMatrix.getStackInSlot(x); - for( int x = 0; x < craftMatrix.getSlots(); x++ ) - { - ItemStack currentItem = craftMatrix.getStackInSlot( x ); + // prepare slots + if (!currentItem.isEmpty()) { + // already the correct item? + ItemStack newItem = this.canUseInSlot(x, currentItem); - // prepare slots - if( !currentItem.isEmpty() ) - { - // already the correct item? - ItemStack newItem = this.canUseInSlot( x, currentItem ); + // put away old item + if (newItem != currentItem && security.hasPermission(player, SecurityPermissions.INJECT)) { + final IAEItemStack in = AEItemStack.fromItemStack(currentItem); + final IAEItemStack out = cct.useRealItems() + ? Platform.poweredInsert(energy, storage, in, cct.getActionSource()) + : null; + if (out != null) { + currentItem = out.createItemStack(); + } else { + currentItem = ItemStack.EMPTY; + } + } + } - // put away old item - if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) ) - { - final IAEItemStack in = AEItemStack.fromItemStack( currentItem ); - final IAEItemStack out = cct.useRealItems() ? Platform.poweredInsert( energy, storage, in, cct.getActionSource() ) : null; - if( out != null ) - { - currentItem = out.createItemStack(); - } - else - { - currentItem = ItemStack.EMPTY; - } - } - } + if (currentItem.isEmpty() && this.recipe[x] != null) { + // for each variant + for (int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++) { + final IAEItemStack request = AEItemStack.fromItemStack(this.recipe[x][y]); + if (request != null) { + // try ae + if ((filter == null || filter.isListed(request)) + && security.hasPermission(player, SecurityPermissions.EXTRACT)) { + request.setStackSize(1); + IAEItemStack out; - if( currentItem.isEmpty() && this.recipe[x] != null ) - { - // for each variant - for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ ) - { - final IAEItemStack request = AEItemStack.fromItemStack( this.recipe[x][y] ); - if( request != null ) - { - // try ae - if( ( filter == null || filter.isListed( request ) ) && security.hasPermission( player, SecurityPermissions.EXTRACT ) ) - { - request.setStackSize( 1 ); - IAEItemStack out; + if (cct.useRealItems()) { + out = Platform.poweredExtraction(energy, storage, request, cct.getActionSource()); + } else { + // Query the crafting grid if there is a pattern providing the item + if (!crafting.getCraftingFor(request, null, 0, null).isEmpty()) { + out = request; + } else { + // Fall back using an existing item + out = storage.extractItems(request, Actionable.SIMULATE, cct.getActionSource()); + } + } - if( cct.useRealItems() ) - { - out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() ); - } - else - { - // Query the crafting grid if there is a pattern providing the item - if( !crafting.getCraftingFor( request, null, 0, null ).isEmpty() ) - { - out = request; - } - else - { - // Fall back using an existing item - out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() ); - } - } + if (out != null) { + currentItem = out.createItemStack(); + } + } - if( out != null ) - { - currentItem = out.createItemStack(); - } - } + // try inventory + if (currentItem.isEmpty()) { + AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory); - // try inventory - if( currentItem.isEmpty() ) - { - AdaptorItemHandler ad = new AdaptorItemHandler( playerInventory ); + if (cct.useRealItems()) { + currentItem = ad.removeItems(1, this.recipe[x][y], null); + } else { + currentItem = ad.simulateRemove(1, this.recipe[x][y], null); + } + } + } + } + } + ItemHandlerUtil.setStackInSlot(craftMatrix, x, currentItem); + } + con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix)); + } + } - if( cct.useRealItems() ) - { - currentItem = ad.removeItems( 1, this.recipe[x][y], null ); - } - else - { - currentItem = ad.simulateRemove( 1, this.recipe[x][y], null ); - } - } - } - } - } - ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem ); - } - con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) ); - } - } - - /** - * - * @param slot - * @param is itemstack - * @return is if it can be used, else EMPTY - */ - private ItemStack canUseInSlot( int slot, ItemStack is ) - { - if( this.recipe[slot] != null ) - { - for( ItemStack option : this.recipe[slot] ) - { - if( is.isItemEqual( option ) ) - { - return is; - } - } - } - return ItemStack.EMPTY; - } + /** + * + * @param slot + * @param is itemstack + * @return is if it can be used, else EMPTY + */ + private ItemStack canUseInSlot(int slot, ItemStack is) { + if (this.recipe[slot] != null) { + for (ItemStack option : this.recipe[slot]) { + if (is.isItemEqual(option)) { + return is; + } + } + } + return ItemStack.EMPTY; + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketLightning.java b/src/main/java/appeng/core/sync/packets/PacketLightning.java index 7c254191d..07972f796 100644 --- a/src/main/java/appeng/core/sync/packets/PacketLightning.java +++ b/src/main/java/appeng/core/sync/packets/PacketLightning.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -33,51 +32,42 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.Platform; +public class PacketLightning extends AppEngPacket { -public class PacketLightning extends AppEngPacket -{ + private final double x; + private final double y; + private final double z; - private final double x; - private final double y; - private final double z; + public PacketLightning(final PacketBuffer stream) { + this.x = stream.readFloat(); + this.y = stream.readFloat(); + this.z = stream.readFloat(); + } - public PacketLightning( final PacketBuffer stream ) - { - this.x = stream.readFloat(); - this.y = stream.readFloat(); - this.z = stream.readFloat(); - } + // api + public PacketLightning(final double x, final double y, final double z) { + this.x = x; + this.y = y; + this.z = z; - // api - public PacketLightning( final double x, final double y, final double z ) - { - this.x = x; - this.y = y; - this.z = z; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeFloat((float) x); + data.writeFloat((float) y); + data.writeFloat((float) z); - data.writeInt( this.getPacketID() ); - data.writeFloat( (float) x ); - data.writeFloat( (float) y ); - data.writeFloat( (float) z ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - try - { - if( Platform.isClient() && AEConfig.instance().isEnableEffects() ) - { - Minecraft.getInstance().world.addParticle( LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f ); - } - } - catch( final Exception ignored ) - { - } - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + try { + if (Platform.isClient() && AEConfig.instance().isEnableEffects()) { + Minecraft.getInstance().world.addParticle(LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f); + } + } catch (final Exception ignored) { + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketMEFluidInventoryUpdate.java b/src/main/java/appeng/core/sync/packets/PacketMEFluidInventoryUpdate.java index c4f8a1754..4abe6e677 100644 --- a/src/main/java/appeng/core/sync/packets/PacketMEFluidInventoryUpdate.java +++ b/src/main/java/appeng/core/sync/packets/PacketMEFluidInventoryUpdate.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -27,6 +26,7 @@ import java.util.LinkedList; import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; + import javax.annotation.Nullable; import io.netty.buffer.Unpooled; @@ -46,163 +46,136 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.fluids.util.AEFluidStack; - /** * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class PacketMEFluidInventoryUpdate extends AppEngPacket -{ - private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024; - private static final int OPERATION_BYTE_LIMIT = 2 * 1024; - private static final int TEMP_BUFFER_SIZE = 1024; - private static final int STREAM_MASK = 0xff; +public class PacketMEFluidInventoryUpdate extends AppEngPacket { + private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024; + private static final int OPERATION_BYTE_LIMIT = 2 * 1024; + private static final int TEMP_BUFFER_SIZE = 1024; + private static final int STREAM_MASK = 0xff; - // input. - @Nullable - private final List list; - // output... - private final byte ref; + // input. + @Nullable + private final List list; + // output... + private final byte ref; - @Nullable - private final PacketBuffer data; - @Nullable - private final GZIPOutputStream compressFrame; + @Nullable + private final PacketBuffer data; + @Nullable + private final GZIPOutputStream compressFrame; - private int writtenBytes = 0; - private boolean empty = true; + private int writtenBytes = 0; + private boolean empty = true; - public PacketMEFluidInventoryUpdate( final PacketBuffer stream ) - { - this.data = null; - this.compressFrame = null; - this.list = new LinkedList<>(); - this.ref = stream.readByte(); + public PacketMEFluidInventoryUpdate(final PacketBuffer stream) { + this.data = null; + this.compressFrame = null; + this.list = new LinkedList<>(); + this.ref = stream.readByte(); - try( final GZIPInputStream gzReader = new GZIPInputStream( new InputStream() - { - @Override - public int read() - { - if( stream.readableBytes() <= 0 ) - { - return -1; - } + try (final GZIPInputStream gzReader = new GZIPInputStream(new InputStream() { + @Override + public int read() { + if (stream.readableBytes() <= 0) { + return -1; + } - return stream.readByte() & STREAM_MASK; - } - } ) ) - { + return stream.readByte() & STREAM_MASK; + } + })) { - final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) ); - final byte[] tmp = new byte[TEMP_BUFFER_SIZE]; + final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes())); + final byte[] tmp = new byte[TEMP_BUFFER_SIZE]; - while( gzReader.available() != 0 ) - { - final int bytes = gzReader.read( tmp ); + while (gzReader.available() != 0) { + final int bytes = gzReader.read(tmp); - if( bytes > 0 ) - { - uncompressed.writeBytes( tmp, 0, bytes ); - } - } + if (bytes > 0) { + uncompressed.writeBytes(tmp, 0, bytes); + } + } - while( uncompressed.readableBytes() > 0 ) - { - this.list.add( AEFluidStack.fromPacket( uncompressed ) ); - } - } - catch( IOException e ) - { - throw new RuntimeException( "Failed to decompress packet.", e ); - } + while (uncompressed.readableBytes() > 0) { + this.list.add(AEFluidStack.fromPacket(uncompressed)); + } + } catch (IOException e) { + throw new RuntimeException("Failed to decompress packet.", e); + } - this.empty = this.list.isEmpty(); - } + this.empty = this.list.isEmpty(); + } - // api - public PacketMEFluidInventoryUpdate() throws IOException - { - this( (byte) 0 ); - } + // api + public PacketMEFluidInventoryUpdate() throws IOException { + this((byte) 0); + } - // api - public PacketMEFluidInventoryUpdate( final byte ref ) throws IOException - { - this.ref = ref; - this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) ); - this.data.writeInt( this.getPacketID() ); - this.data.writeByte( this.ref ); + // api + public PacketMEFluidInventoryUpdate(final byte ref) throws IOException { + this.ref = ref; + this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT)); + this.data.writeInt(this.getPacketID()); + this.data.writeByte(this.ref); - this.compressFrame = new GZIPOutputStream( new OutputStream() - { - @Override - public void write( final int value ) - { - PacketMEFluidInventoryUpdate.this.data.writeByte( value ); - } - } ); + this.compressFrame = new GZIPOutputStream(new OutputStream() { + @Override + public void write(final int value) { + PacketMEFluidInventoryUpdate.this.data.writeByte(value); + } + }); - this.list = null; - } + this.list = null; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final Screen gs = Minecraft.getInstance().currentScreen; + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final Screen gs = Minecraft.getInstance().currentScreen; - // FIXME if( gs instanceof GuiFluidTerminal ) - // FIXME { - // FIXME ( (GuiFluidTerminal) gs ).postUpdate( this.list ); - // FIXME } - } + // FIXME if( gs instanceof GuiFluidTerminal ) + // FIXME { + // FIXME ( (GuiFluidTerminal) gs ).postUpdate( this.list ); + // FIXME } + } - @Nullable - @Override - public IPacket toPacket( NetworkDirection direction ) - { - try - { - this.compressFrame.close(); + @Nullable + @Override + public IPacket toPacket(NetworkDirection direction) { + try { + this.compressFrame.close(); - this.configureWrite( this.data ); - return super.toPacket( direction ); - } - catch( final IOException e ) - { - AELog.debug( e ); - } + this.configureWrite(this.data); + return super.toPacket(direction); + } catch (final IOException e) { + AELog.debug(e); + } - return null; - } + return null; + } - public void appendFluid( final IAEFluidStack fs ) throws IOException, BufferOverflowException - { - final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) ); - fs.writeToPacket( tmp ); + public void appendFluid(final IAEFluidStack fs) throws IOException, BufferOverflowException { + final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT)); + fs.writeToPacket(tmp); - this.compressFrame.flush(); - if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT ) - { - throw new BufferOverflowException(); - } - else - { - this.writtenBytes += tmp.readableBytes(); - this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() ); - this.empty = false; - } - } + this.compressFrame.flush(); + if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) { + throw new BufferOverflowException(); + } else { + this.writtenBytes += tmp.readableBytes(); + this.compressFrame.write(tmp.array(), 0, tmp.readableBytes()); + this.empty = false; + } + } - public int getLength() - { - return this.data.readableBytes(); - } + public int getLength() { + return this.data.readableBytes(); + } - public boolean isEmpty() - { - return this.empty; - } + public boolean isEmpty() { + return this.empty; + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java b/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java index 5a50317f5..74c2e8c4a 100644 --- a/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java +++ b/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -27,12 +26,9 @@ import java.util.ArrayList; import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; + import javax.annotation.Nullable; -import appeng.client.gui.implementations.GuiCraftConfirm; -import appeng.client.gui.implementations.GuiCraftingCPU; -import appeng.client.gui.implementations.GuiMEMonitorable; -import appeng.client.gui.implementations.GuiNetworkStatus; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -45,179 +41,152 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkDirection; import appeng.api.storage.data.IAEItemStack; +import appeng.client.gui.implementations.GuiCraftConfirm; +import appeng.client.gui.implementations.GuiCraftingCPU; +import appeng.client.gui.implementations.GuiMEMonitorable; +import appeng.client.gui.implementations.GuiNetworkStatus; import appeng.core.AELog; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.item.AEItemStack; +public class PacketMEInventoryUpdate extends AppEngPacket { + private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024; + private static final int OPERATION_BYTE_LIMIT = 2 * 1024; + private static final int TEMP_BUFFER_SIZE = 1024; + private static final int STREAM_MASK = 0xff; -public class PacketMEInventoryUpdate extends AppEngPacket -{ - private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024; - private static final int OPERATION_BYTE_LIMIT = 2 * 1024; - private static final int TEMP_BUFFER_SIZE = 1024; - private static final int STREAM_MASK = 0xff; + // input. + @Nullable + private final List list; + // output... + private final byte ref; - // input. - @Nullable - private final List list; - // output... - private final byte ref; + @Nullable + private final PacketBuffer data; + @Nullable + private final GZIPOutputStream compressFrame; - @Nullable - private final PacketBuffer data; - @Nullable - private final GZIPOutputStream compressFrame; + private int writtenBytes = 0; + private boolean empty = true; - private int writtenBytes = 0; - private boolean empty = true; + public PacketMEInventoryUpdate(final PacketBuffer stream) { + this.data = null; + this.compressFrame = null; + this.list = new ArrayList<>(); + this.ref = stream.readByte(); - public PacketMEInventoryUpdate( final PacketBuffer stream ) - { - this.data = null; - this.compressFrame = null; - this.list = new ArrayList<>(); - this.ref = stream.readByte(); + // int originalBytes = stream.readableBytes(); - // int originalBytes = stream.readableBytes(); + try (GZIPInputStream gzReader = new GZIPInputStream(new InputStream() { + @Override + public int read() { + if (stream.readableBytes() <= 0) { + return -1; + } - try( GZIPInputStream gzReader = new GZIPInputStream( new InputStream() - { - @Override - public int read() - { - if( stream.readableBytes() <= 0 ) - { - return -1; - } + return stream.readByte() & STREAM_MASK; + } + })) { + final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes())); + final byte[] tmp = new byte[TEMP_BUFFER_SIZE]; - return stream.readByte() & STREAM_MASK; - } - } ) ) - { - final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) ); - final byte[] tmp = new byte[TEMP_BUFFER_SIZE]; + while (gzReader.available() != 0) { + final int bytes = gzReader.read(tmp); - while( gzReader.available() != 0 ) - { - final int bytes = gzReader.read( tmp ); + if (bytes > 0) { + uncompressed.writeBytes(tmp, 0, bytes); + } + } - if( bytes > 0 ) - { - uncompressed.writeBytes( tmp, 0, bytes ); - } - } + while (uncompressed.readableBytes() > 0) { + this.list.add(AEItemStack.fromPacket(uncompressed)); + } + } catch (IOException e) { + throw new RuntimeException("Failed to decompress packet.", e); + } - while( uncompressed.readableBytes() > 0 ) - { - this.list.add( AEItemStack.fromPacket( uncompressed ) ); - } - } - catch( IOException e ) - { - throw new RuntimeException( "Failed to decompress packet.", e ); - } + this.empty = this.list.isEmpty(); + } - this.empty = this.list.isEmpty(); - } + // api + public PacketMEInventoryUpdate() throws IOException { + this((byte) 0); + } - // api - public PacketMEInventoryUpdate() throws IOException - { - this( (byte) 0 ); - } + // api + public PacketMEInventoryUpdate(final byte ref) throws IOException { + this.ref = ref; + this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT)); + this.data.writeInt(this.getPacketID()); + this.data.writeByte(this.ref); - // api - public PacketMEInventoryUpdate( final byte ref ) throws IOException - { - this.ref = ref; - this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) ); - this.data.writeInt( this.getPacketID() ); - this.data.writeByte( this.ref ); + this.compressFrame = new GZIPOutputStream(new OutputStream() { + @Override + public void write(final int value) { + PacketMEInventoryUpdate.this.data.writeByte(value); + } + }); - this.compressFrame = new GZIPOutputStream( new OutputStream() - { - @Override - public void write( final int value ) - { - PacketMEInventoryUpdate.this.data.writeByte( value ); - } - } ); + this.list = null; + } - this.list = null; - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final Screen gs = Minecraft.getInstance().currentScreen; - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final Screen gs = Minecraft.getInstance().currentScreen; + if (gs instanceof GuiCraftConfirm) { + ((GuiCraftConfirm) gs).postUpdate(this.list, this.ref); + } - if( gs instanceof GuiCraftConfirm) - { - ( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref ); - } + if (gs instanceof GuiCraftingCPU) { + ((GuiCraftingCPU) gs).postUpdate(this.list, this.ref); + } - if( gs instanceof GuiCraftingCPU) - { - ( (GuiCraftingCPU) gs ).postUpdate( this.list, this.ref ); - } + if (gs instanceof GuiMEMonitorable) { + ((GuiMEMonitorable) gs).postUpdate(this.list); + } - if( gs instanceof GuiMEMonitorable) - { - ( (GuiMEMonitorable) gs ).postUpdate( this.list ); - } + if (gs instanceof GuiNetworkStatus) { + ((GuiNetworkStatus) gs).postUpdate(this.list); + } + } - if( gs instanceof GuiNetworkStatus) - { - ( (GuiNetworkStatus) gs ).postUpdate( this.list ); - } - } + @Nullable + @Override + public IPacket toPacket(NetworkDirection direction) { + try { + this.compressFrame.close(); - @Nullable - @Override - public IPacket toPacket( NetworkDirection direction ) - { - try - { - this.compressFrame.close(); + this.configureWrite(this.data); + return super.toPacket(direction); + } catch (final IOException e) { + AELog.debug(e); + } - this.configureWrite( this.data ); - return super.toPacket( direction ); - } - catch( final IOException e ) - { - AELog.debug( e ); - } + return null; + } - return null; - } + public void appendItem(final IAEItemStack is) throws IOException, BufferOverflowException { + final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT)); + is.writeToPacket(tmp); - public void appendItem( final IAEItemStack is ) throws IOException, BufferOverflowException - { - final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) ); - is.writeToPacket( tmp ); + this.compressFrame.flush(); + if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) { + throw new BufferOverflowException(); + } else { + this.writtenBytes += tmp.readableBytes(); + this.compressFrame.write(tmp.array(), 0, tmp.readableBytes()); + this.empty = false; + } + } - this.compressFrame.flush(); - if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT ) - { - throw new BufferOverflowException(); - } - else - { - this.writtenBytes += tmp.readableBytes(); - this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() ); - this.empty = false; - } - } + public int getLength() { + return this.data.readableBytes(); + } - public int getLength() - { - return this.data.readableBytes(); - } - - public boolean isEmpty() - { - return this.empty; - } + public boolean isEmpty() { + return this.empty; + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketMatterCannon.java b/src/main/java/appeng/core/sync/packets/PacketMatterCannon.java index 178d7fdf2..55115e65d 100644 --- a/src/main/java/appeng/core/sync/packets/PacketMatterCannon.java +++ b/src/main/java/appeng/core/sync/packets/PacketMatterCannon.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -31,74 +30,68 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +public class PacketMatterCannon extends AppEngPacket { -public class PacketMatterCannon extends AppEngPacket -{ + private final double x; + private final double y; + private final double z; + private final double dx; + private final double dy; + private final double dz; + private final byte len; - private final double x; - private final double y; - private final double z; - private final double dx; - private final double dy; - private final double dz; - private final byte len; + public PacketMatterCannon(final PacketBuffer stream) { + this.x = stream.readFloat(); + this.y = stream.readFloat(); + this.z = stream.readFloat(); + this.dx = stream.readFloat(); + this.dy = stream.readFloat(); + this.dz = stream.readFloat(); + this.len = stream.readByte(); + } - public PacketMatterCannon( final PacketBuffer stream ) - { - this.x = stream.readFloat(); - this.y = stream.readFloat(); - this.z = stream.readFloat(); - this.dx = stream.readFloat(); - this.dy = stream.readFloat(); - this.dz = stream.readFloat(); - this.len = stream.readByte(); - } + // api + public PacketMatterCannon(final double x, final double y, final double z, final float dx, final float dy, + final float dz, final byte len) { + final float dl = dx * dx + dy * dy + dz * dz; + final float dlz = (float) Math.sqrt(dl); - // api - public PacketMatterCannon( final double x, final double y, final double z, final float dx, final float dy, final float dz, final byte len ) - { - final float dl = dx * dx + dy * dy + dz * dz; - final float dlz = (float) Math.sqrt( dl ); + this.x = x; + this.y = y; + this.z = z; + this.dx = dx / dlz; + this.dy = dy / dlz; + this.dz = dz / dlz; + this.len = len; - this.x = x; - this.y = y; - this.z = z; - this.dx = dx / dlz; - this.dy = dy / dlz; - this.dz = dz / dlz; - this.len = len; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeFloat((float) x); + data.writeFloat((float) y); + data.writeFloat((float) z); + data.writeFloat((float) this.dx); + data.writeFloat((float) this.dy); + data.writeFloat((float) this.dz); + data.writeByte(len); - data.writeInt( this.getPacketID() ); - data.writeFloat( (float) x ); - data.writeFloat( (float) y ); - data.writeFloat( (float) z ); - data.writeFloat( (float) this.dx ); - data.writeFloat( (float) this.dy ); - data.writeFloat( (float) this.dz ); - data.writeByte( len ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + try { - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - try - { + final World world = Minecraft.getInstance().world; + for (int a = 1; a < this.len; a++) { + // FIXME final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * + // a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND ) + // ); - final World world = Minecraft.getInstance().world; - for( int a = 1; a < this.len; a++ ) - { - // FIXME final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND ) ); - - // FIXME Minecraft.getInstance().particles.addEffect( fx ); - } - } - catch( final Exception ignored ) - { - } - } + // FIXME Minecraft.getInstance().particles.addEffect( fx ); + } + } catch (final Exception ignored) { + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketMockExplosion.java b/src/main/java/appeng/core/sync/packets/PacketMockExplosion.java index 52702a240..2d3431076 100644 --- a/src/main/java/appeng/core/sync/packets/PacketMockExplosion.java +++ b/src/main/java/appeng/core/sync/packets/PacketMockExplosion.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -32,43 +31,38 @@ import appeng.core.AppEng; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +public class PacketMockExplosion extends AppEngPacket { -public class PacketMockExplosion extends AppEngPacket -{ + private final double x; + private final double y; + private final double z; - private final double x; - private final double y; - private final double z; + public PacketMockExplosion(final PacketBuffer stream) { + this.x = stream.readDouble(); + this.y = stream.readDouble(); + this.z = stream.readDouble(); + } - public PacketMockExplosion( final PacketBuffer stream ) - { - this.x = stream.readDouble(); - this.y = stream.readDouble(); - this.z = stream.readDouble(); - } + // api + public PacketMockExplosion(final double x, final double y, final double z) { + this.x = x; + this.y = y; + this.z = z; - // api - public PacketMockExplosion( final double x, final double y, final double z ) - { - this.x = x; - this.y = y; - this.z = z; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeDouble(x); + data.writeDouble(y); + data.writeDouble(z); - data.writeInt( this.getPacketID() ); - data.writeDouble( x ); - data.writeDouble( y ); - data.writeDouble( z ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final World world = AppEng.proxy.getWorld(); - world.addParticle( ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final World world = AppEng.proxy.getWorld(); + world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketPaintedEntity.java b/src/main/java/appeng/core/sync/packets/PacketPaintedEntity.java index 0331b099e..d7e604c94 100644 --- a/src/main/java/appeng/core/sync/packets/PacketPaintedEntity.java +++ b/src/main/java/appeng/core/sync/packets/PacketPaintedEntity.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -30,39 +29,34 @@ import appeng.core.sync.network.INetworkInfo; import appeng.hooks.TickHandler; import appeng.hooks.TickHandler.PlayerColor; +public class PacketPaintedEntity extends AppEngPacket { -public class PacketPaintedEntity extends AppEngPacket -{ + private final AEColor myColor; + private final int entityId; + private int ticks; - private final AEColor myColor; - private final int entityId; - private int ticks; + public PacketPaintedEntity(final PacketBuffer stream) { + this.entityId = stream.readInt(); + this.myColor = AEColor.values()[stream.readByte()]; + this.ticks = stream.readInt(); + } - public PacketPaintedEntity( final PacketBuffer stream ) - { - this.entityId = stream.readInt(); - this.myColor = AEColor.values()[stream.readByte()]; - this.ticks = stream.readInt(); - } + // api + public PacketPaintedEntity(final int myEntity, final AEColor myColor, final int ticksLeft) { - // api - public PacketPaintedEntity( final int myEntity, final AEColor myColor, final int ticksLeft ) - { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(this.entityId = myEntity); + data.writeByte((this.myColor = myColor).ordinal()); + data.writeInt(ticksLeft); - data.writeInt( this.getPacketID() ); - data.writeInt( this.entityId = myEntity ); - data.writeByte( ( this.myColor = myColor ).ordinal() ); - data.writeInt( ticksLeft ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final PlayerColor pc = new PlayerColor( this.entityId, this.myColor, this.ticks ); - TickHandler.INSTANCE.getPlayerColors().put( this.entityId, pc ); - } + @Override + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final PlayerColor pc = new PlayerColor(this.entityId, this.myColor, this.ticks); + TickHandler.INSTANCE.getPlayerColors().put(this.entityId, pc); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketPartPlacement.java b/src/main/java/appeng/core/sync/packets/PacketPartPlacement.java index 84e17364b..d0c73bb6c 100644 --- a/src/main/java/appeng/core/sync/packets/PacketPartPlacement.java +++ b/src/main/java/appeng/core/sync/packets/PacketPartPlacement.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -33,52 +32,47 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.parts.PartPlacement; +public class PacketPartPlacement extends AppEngPacket { -public class PacketPartPlacement extends AppEngPacket -{ + private int x; + private int y; + private int z; + private int face; + private float eyeHeight; + private Hand hand; - private int x; - private int y; - private int z; - private int face; - private float eyeHeight; - private Hand hand; + public PacketPartPlacement(final PacketBuffer stream) { + this.x = stream.readInt(); + this.y = stream.readInt(); + this.z = stream.readInt(); + this.face = stream.readByte(); + this.eyeHeight = stream.readFloat(); + this.hand = Hand.values()[stream.readByte()]; + } - public PacketPartPlacement( final PacketBuffer stream ) - { - this.x = stream.readInt(); - this.y = stream.readInt(); - this.z = stream.readInt(); - this.face = stream.readByte(); - this.eyeHeight = stream.readFloat(); - this.hand = Hand.values()[stream.readByte()]; - } + // api + public PacketPartPlacement(final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand) { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - // api - public PacketPartPlacement( final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand ) - { - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(pos.getX()); + data.writeInt(pos.getY()); + data.writeInt(pos.getZ()); + data.writeByte(face.ordinal()); + data.writeFloat(eyeHeight); + data.writeByte(hand.ordinal()); - data.writeInt( this.getPacketID() ); - data.writeInt( pos.getX() ); - data.writeInt( pos.getY() ); - data.writeInt( pos.getZ() ); - data.writeByte( face.ordinal() ); - data.writeFloat( eyeHeight ); - data.writeByte( hand.ordinal() ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final ServerPlayerEntity sender = (ServerPlayerEntity) player; - AppEng.proxy.updateRenderMode( sender ); - PartPlacement.setEyeHeight( this.eyeHeight ); - PartPlacement.place( sender.getHeldItem( this.hand ), new BlockPos( this.x, this.y, this.z ), Direction.values()[this.face], sender, this.hand, - sender.world, - PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 ); - AppEng.proxy.updateRenderMode( null ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final ServerPlayerEntity sender = (ServerPlayerEntity) player; + AppEng.proxy.updateRenderMode(sender); + PartPlacement.setEyeHeight(this.eyeHeight); + PartPlacement.place(sender.getHeldItem(this.hand), new BlockPos(this.x, this.y, this.z), + Direction.values()[this.face], sender, this.hand, sender.world, + PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0); + AppEng.proxy.updateRenderMode(null); + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java b/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java index b9c42ee13..84ff6f3d7 100644 --- a/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java +++ b/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import java.io.IOException; import io.netty.buffer.Unpooled; @@ -36,85 +35,72 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.item.AEItemStack; +public class PacketPatternSlot extends AppEngPacket { -public class PacketPatternSlot extends AppEngPacket -{ + public final IAEItemStack slotItem; - public final IAEItemStack slotItem; + public final IAEItemStack[] pattern = new IAEItemStack[9]; - public final IAEItemStack[] pattern = new IAEItemStack[9]; + public final boolean shift; - public final boolean shift; + public PacketPatternSlot(final PacketBuffer stream) { - public PacketPatternSlot( final PacketBuffer stream ) - { + this.shift = stream.readBoolean(); - this.shift = stream.readBoolean(); + this.slotItem = this.readItem(stream); - this.slotItem = this.readItem( stream ); + for (int x = 0; x < 9; x++) { + this.pattern[x] = this.readItem(stream); + } + } - for( int x = 0; x < 9; x++ ) - { - this.pattern[x] = this.readItem( stream ); - } - } + private IAEItemStack readItem(final PacketBuffer stream) { + final boolean hasItem = stream.readBoolean(); - private IAEItemStack readItem( final PacketBuffer stream ) - { - final boolean hasItem = stream.readBoolean(); + if (hasItem) { + return AEItemStack.fromPacket(stream); + } - if( hasItem ) - { - return AEItemStack.fromPacket( stream ); - } + return null; + } - return null; - } + // api + public PacketPatternSlot(final IItemHandler pat, final IAEItemStack slotItem, final boolean shift) { - // api - public PacketPatternSlot( final IItemHandler pat, final IAEItemStack slotItem, final boolean shift ) - { + this.slotItem = slotItem; + this.shift = shift; - this.slotItem = slotItem; - this.shift = shift; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); - data.writeInt( this.getPacketID() ); + data.writeBoolean(shift); - data.writeBoolean( shift ); + this.writeItem(slotItem, data); + for (int x = 0; x < 9; x++) { + this.pattern[x] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(pat.getStackInSlot(x)); + this.writeItem(this.pattern[x], data); + } - this.writeItem( slotItem, data ); - for( int x = 0; x < 9; x++ ) - { - this.pattern[x] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( pat.getStackInSlot( x ) ); - this.writeItem( this.pattern[x], data ); - } + this.configureWrite(data); + } - this.configureWrite( data ); - } + private void writeItem(final IAEItemStack slotItem, final PacketBuffer data) { + if (slotItem == null) { + data.writeBoolean(false); + } else { + data.writeBoolean(true); + slotItem.writeToPacket(data); + } + } - private void writeItem( final IAEItemStack slotItem, final PacketBuffer data ) - { - if( slotItem == null ) - { - data.writeBoolean( false ); - } - else - { - data.writeBoolean( true ); - slotItem.writeToPacket( data ); - } - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final ServerPlayerEntity sender = (ServerPlayerEntity) player; - if( sender.openContainer instanceof ContainerPatternTerm ) - { - final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer; - patternTerminal.craftOrGetItem( this ); - } - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final ServerPlayerEntity sender = (ServerPlayerEntity) player; + if (sender.openContainer instanceof ContainerPatternTerm) { + final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer; + patternTerminal.craftOrGetItem(this); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketProgressBar.java b/src/main/java/appeng/core/sync/packets/PacketProgressBar.java index a719473ba..d8483b95c 100644 --- a/src/main/java/appeng/core/sync/packets/PacketProgressBar.java +++ b/src/main/java/appeng/core/sync/packets/PacketProgressBar.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -29,51 +28,43 @@ import appeng.container.AEBaseContainer; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +public class PacketProgressBar extends AppEngPacket { -public class PacketProgressBar extends AppEngPacket -{ + private final short id; + private final long value; - private final short id; - private final long value; + public PacketProgressBar(final PacketBuffer stream) { + this.id = stream.readShort(); + this.value = stream.readLong(); + } - public PacketProgressBar( final PacketBuffer stream ) - { - this.id = stream.readShort(); - this.value = stream.readLong(); - } + // api + public PacketProgressBar(final int shortID, final long value) { + this.id = (short) shortID; + this.value = value; - // api - public PacketProgressBar( final int shortID, final long value ) - { - this.id = (short) shortID; - this.value = value; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeShort(shortID); + data.writeLong(value); - data.writeInt( this.getPacketID() ); - data.writeShort( shortID ); - data.writeLong( value ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final Container c = player.openContainer; + if (c instanceof AEBaseContainer) { + ((AEBaseContainer) c).updateFullProgressBar(this.id, this.value); + } + } - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final Container c = player.openContainer; - if( c instanceof AEBaseContainer ) - { - ( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value ); - } - } - - @Override - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final Container c = player.openContainer; - if( c instanceof AEBaseContainer ) - { - ( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value ); - } - } + @Override + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final Container c = player.openContainer; + if (c instanceof AEBaseContainer) { + ((AEBaseContainer) c).updateFullProgressBar(this.id, this.value); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketSwapSlots.java b/src/main/java/appeng/core/sync/packets/PacketSwapSlots.java index 44c796866..6cc8e7337 100644 --- a/src/main/java/appeng/core/sync/packets/PacketSwapSlots.java +++ b/src/main/java/appeng/core/sync/packets/PacketSwapSlots.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -28,37 +27,31 @@ import appeng.container.AEBaseContainer; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; +public class PacketSwapSlots extends AppEngPacket { -public class PacketSwapSlots extends AppEngPacket -{ + private final int slotA; + private final int slotB; - private final int slotA; - private final int slotB; + public PacketSwapSlots(final PacketBuffer stream) { + this.slotA = stream.readInt(); + this.slotB = stream.readInt(); + } - public PacketSwapSlots( final PacketBuffer stream ) - { - this.slotA = stream.readInt(); - this.slotB = stream.readInt(); - } + // api + public PacketSwapSlots(final int slotA, final int slotB) { + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - // api - public PacketSwapSlots( final int slotA, final int slotB ) - { - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeInt(this.slotA = slotA); + data.writeInt(this.slotB = slotB); - data.writeInt( this.getPacketID() ); - data.writeInt( this.slotA = slotA ); - data.writeInt( this.slotB = slotB ); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - if( player != null && player.openContainer instanceof AEBaseContainer ) - { - ( (AEBaseContainer) player.openContainer ).swapSlotContents( this.slotA, this.slotB ); - } - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + if (player != null && player.openContainer instanceof AEBaseContainer) { + ((AEBaseContainer) player.openContainer).swapSlotContents(this.slotA, this.slotB); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java b/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java index 97189a7a1..4b4c93e6e 100644 --- a/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java +++ b/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java @@ -18,8 +18,6 @@ package appeng.core.sync.packets; - -import appeng.container.ContainerOpener; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -27,51 +25,44 @@ import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.registries.ForgeRegistries; import appeng.container.AEBaseContainer; import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; import appeng.core.sync.AppEngPacket; - import appeng.core.sync.network.INetworkInfo; import appeng.util.Platform; -import net.minecraftforge.registries.ForgeRegistries; +public class PacketSwitchGuis extends AppEngPacket { -public class PacketSwitchGuis extends AppEngPacket -{ + private final ContainerType newGui; - private final ContainerType newGui; + public PacketSwitchGuis(final PacketBuffer stream) { + this.newGui = ForgeRegistries.CONTAINERS.getValue(stream.readResourceLocation()); + } - public PacketSwitchGuis( final PacketBuffer stream ) - { - this.newGui = ForgeRegistries.CONTAINERS.getValue(stream.readResourceLocation()); - } + // api + public PacketSwitchGuis(final ContainerType newGui) { + this.newGui = newGui; - // api - public PacketSwitchGuis( final ContainerType newGui ) - { - this.newGui = newGui; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeResourceLocation(newGui.getRegistryName()); - data.writeInt( this.getPacketID() ); - data.writeResourceLocation(newGui.getRegistryName()); + this.configureWrite(data); + } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final Container c = player.openContainer; - if( c instanceof AEBaseContainer ) - { - final AEBaseContainer bc = (AEBaseContainer) c; - final ContainerLocator locator = bc.getLocator(); - if( locator != null ) - { - ContainerOpener.openContainer(newGui, player, locator); - } - } - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final Container c = player.openContainer; + if (c instanceof AEBaseContainer) { + final AEBaseContainer bc = (AEBaseContainer) c; + final ContainerLocator locator = bc.getLocator(); + if (locator != null) { + ContainerOpener.openContainer(newGui, player, locator); + } + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketTargetFluidStack.java b/src/main/java/appeng/core/sync/packets/PacketTargetFluidStack.java index b49399d06..f97237ee8 100644 --- a/src/main/java/appeng/core/sync/packets/PacketTargetFluidStack.java +++ b/src/main/java/appeng/core/sync/packets/PacketTargetFluidStack.java @@ -1,93 +1,76 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.sync.packets; - - -import io.netty.buffer.Unpooled; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.PacketBuffer; - -import appeng.core.AELog; -import appeng.core.sync.AppEngPacket; -import appeng.core.sync.network.INetworkInfo; -import appeng.fluids.container.ContainerFluidTerminal; -import appeng.fluids.util.AEFluidStack; - - -/** - * @author BrockWS - * @version rv6 - 23/05/2018 - * @since rv6 23/05/2018 - */ -public class PacketTargetFluidStack extends AppEngPacket -{ - private AEFluidStack stack; - - public PacketTargetFluidStack( final PacketBuffer stream ) - { - try - { - if( stream.readableBytes() > 0 ) - { - this.stack = (AEFluidStack) AEFluidStack.fromPacket( stream ); - } - else - { - this.stack = null; - } - } - catch( Exception ex ) - { - AELog.debug( ex ); - this.stack = null; - } - } - - // api - public PacketTargetFluidStack( AEFluidStack stack ) - { - - this.stack = stack; - - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); - data.writeInt( this.getPacketID() ); - if( stack != null ) - { - try - { - stack.writeToPacket( data ); - } - catch( Exception ex ) - { - AELog.debug( ex ); - } - } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - if( player.openContainer instanceof ContainerFluidTerminal ) - { - ( (ContainerFluidTerminal) player.openContainer ).setTargetStack( this.stack ); - } - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.sync.packets; + +import io.netty.buffer.Unpooled; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.PacketBuffer; + +import appeng.core.AELog; +import appeng.core.sync.AppEngPacket; +import appeng.core.sync.network.INetworkInfo; +import appeng.fluids.container.ContainerFluidTerminal; +import appeng.fluids.util.AEFluidStack; + +/** + * @author BrockWS + * @version rv6 - 23/05/2018 + * @since rv6 23/05/2018 + */ +public class PacketTargetFluidStack extends AppEngPacket { + private AEFluidStack stack; + + public PacketTargetFluidStack(final PacketBuffer stream) { + try { + if (stream.readableBytes() > 0) { + this.stack = (AEFluidStack) AEFluidStack.fromPacket(stream); + } else { + this.stack = null; + } + } catch (Exception ex) { + AELog.debug(ex); + this.stack = null; + } + } + + // api + public PacketTargetFluidStack(AEFluidStack stack) { + + this.stack = stack; + + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); + data.writeInt(this.getPacketID()); + if (stack != null) { + try { + stack.writeToPacket(data); + } catch (Exception ex) { + AELog.debug(ex); + } + } + this.configureWrite(data); + } + + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + if (player.openContainer instanceof ContainerFluidTerminal) { + ((ContainerFluidTerminal) player.openContainer).setTargetStack(this.stack); + } + } +} diff --git a/src/main/java/appeng/core/sync/packets/PacketTargetItemStack.java b/src/main/java/appeng/core/sync/packets/PacketTargetItemStack.java index 1d5eef4eb..324864109 100644 --- a/src/main/java/appeng/core/sync/packets/PacketTargetItemStack.java +++ b/src/main/java/appeng/core/sync/packets/PacketTargetItemStack.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; @@ -30,59 +29,43 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.item.AEItemStack; +public class PacketTargetItemStack extends AppEngPacket { + private AEItemStack stack; -public class PacketTargetItemStack extends AppEngPacket -{ - private AEItemStack stack; + public PacketTargetItemStack(final PacketBuffer stream) { + try { + if (stream.readableBytes() > 0) { + this.stack = AEItemStack.fromPacket(stream); + } else { + this.stack = null; + } + } catch (Exception ex) { + AELog.debug(ex); + this.stack = null; + } + } - public PacketTargetItemStack( final PacketBuffer stream ) - { - try - { - if( stream.readableBytes() > 0 ) - { - this.stack = AEItemStack.fromPacket( stream ); - } - else - { - this.stack = null; - } - } - catch( Exception ex ) - { - AELog.debug( ex ); - this.stack = null; - } - } + // api + public PacketTargetItemStack(AEItemStack stack) { - // api - public PacketTargetItemStack( AEItemStack stack ) - { + this.stack = stack; - this.stack = stack; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); + data.writeInt(this.getPacketID()); + if (stack != null) { + try { + stack.writeToPacket(data); + } catch (Exception ex) { + AELog.debug(ex); + } + } + this.configureWrite(data); + } - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); - data.writeInt( this.getPacketID() ); - if( stack != null ) - { - try - { - stack.writeToPacket( data ); - } - catch( Exception ex ) - { - AELog.debug( ex ); - } - } - this.configureWrite( data ); - } - - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - if( player.openContainer instanceof AEBaseContainer ) - { - ( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack ); - } - } + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + if (player.openContainer instanceof AEBaseContainer) { + ((AEBaseContainer) player.openContainer).setTargetStack(this.stack); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java b/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java index 2d730268b..0a3a69a09 100644 --- a/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java +++ b/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java @@ -18,7 +18,6 @@ package appeng.core.sync.packets; - import io.netty.buffer.Unpooled; import net.minecraft.block.BlockState; @@ -43,83 +42,78 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.util.Platform; +public class PacketTransitionEffect extends AppEngPacket { -public class PacketTransitionEffect extends AppEngPacket -{ + private final boolean mode; + private final double x; + private final double y; + private final double z; + private final AEPartLocation d; - private final boolean mode; - private final double x; - private final double y; - private final double z; - private final AEPartLocation d; + public PacketTransitionEffect(final PacketBuffer stream) { + this.x = stream.readFloat(); + this.y = stream.readFloat(); + this.z = stream.readFloat(); + this.d = AEPartLocation.fromOrdinal(stream.readByte()); + this.mode = stream.readBoolean(); + } - public PacketTransitionEffect( final PacketBuffer stream ) - { - this.x = stream.readFloat(); - this.y = stream.readFloat(); - this.z = stream.readFloat(); - this.d = AEPartLocation.fromOrdinal( stream.readByte() ); - this.mode = stream.readBoolean(); - } + // api + public PacketTransitionEffect(final double x, final double y, final double z, final AEPartLocation dir, + final boolean wasBlock) { + this.x = x; + this.y = y; + this.z = z; + this.d = dir; + this.mode = wasBlock; - // api - public PacketTransitionEffect( final double x, final double y, final double z, final AEPartLocation dir, final boolean wasBlock ) - { - this.x = x; - this.y = y; - this.z = z; - this.d = dir; - this.mode = wasBlock; + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeInt(this.getPacketID()); + data.writeFloat((float) x); + data.writeFloat((float) y); + data.writeFloat((float) z); + data.writeByte(this.d.ordinal()); + data.writeBoolean(wasBlock); - data.writeInt( this.getPacketID() ); - data.writeFloat( (float) x ); - data.writeFloat( (float) y ); - data.writeFloat( (float) z ); - data.writeByte( this.d.ordinal() ); - data.writeBoolean( wasBlock ); + this.configureWrite(data); + } - this.configureWrite( data ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final World world = AppEng.proxy.getWorld(); - @Override - @OnlyIn( Dist.CLIENT ) - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final World world = AppEng.proxy.getWorld(); + for (int zz = 0; zz < (this.mode ? 32 : 8); zz++) { + if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) { + double x = this.x + (this.mode ? (Platform.getRandomInt() % 100) * 0.01 + : (Platform.getRandomInt() % 100) * 0.005 - 0.25); + double y = this.y + (this.mode ? (Platform.getRandomInt() % 100) * 0.01 + : (Platform.getRandomInt() % 100) * 0.005 - 0.25); + double z = this.z + (this.mode ? (Platform.getRandomInt() % 100) * 0.01 + : (Platform.getRandomInt() % 100) * 0.005 - 0.25); + double speedX = -0.1f * this.d.xOffset; + double speedY = -0.1f * this.d.yOffset; + double speedZ = -0.1f * this.d.zOffset; - for( int zz = 0; zz < ( this.mode ? 32 : 8 ); zz++ ) - { - if( AppEng.proxy.shouldAddParticles( Platform.getRandom() ) ) - { - double x = this.x + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ); - double y = this.y + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ); - double z = this.z + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ); - double speedX = -0.1f * this.d.xOffset; - double speedY = -0.1f * this.d.yOffset; - double speedZ = -0.1f * this.d.zOffset; + EnergyFx fx = (EnergyFx) Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, x, y, z, speedX, + speedY, speedZ); + // FIXME: *sigh* custom particle data for this one thing :| + if (!this.mode) { + fx.fromItem(this.d); + } + } + } - EnergyFx fx = (EnergyFx) Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, x, y, z, speedX, speedY, speedZ); - // FIXME: *sigh* custom particle data for this one thing :| - if( !this.mode ) - { - fx.fromItem( this.d ); - } - } - } + if (this.mode) { + final BlockPos pos = new BlockPos((int) this.x, (int) this.y, (int) this.z); + final BlockState state = world.getBlockState(pos); + final SoundType sound = state.getSoundType(world, pos, null); - if( this.mode ) - { - final BlockPos pos = new BlockPos( (int) this.x, (int) this.y, (int) this.z ); - final BlockState state = world.getBlockState( pos ); - final SoundType sound = state.getSoundType( world, pos, null ); - - Minecraft.getInstance() - .getSoundHandler() - .play( new SimpleSound( sound - .getBreakSound(), SoundCategory.BLOCKS, ( sound.getVolume() + 1.0F ) / 2.0F, sound - .getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) ); - } - } + Minecraft.getInstance().getSoundHandler() + .play(new SimpleSound(sound.getBreakSound(), SoundCategory.BLOCKS, + (sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F, (float) this.x + 0.5F, + (float) this.y + 0.5F, (float) this.z + 0.5F)); + } + } } diff --git a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java index a274dc278..0a7168960 100644 --- a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java @@ -18,6 +18,17 @@ package appeng.core.sync.packets; +import java.io.IOException; + +import io.netty.buffer.Unpooled; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.container.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Hand; import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; @@ -41,263 +52,174 @@ import appeng.core.sync.network.INetworkInfo; import appeng.fluids.container.ContainerFluidLevelEmitter; import appeng.fluids.container.ContainerFluidStorageBus; import appeng.helpers.IMouseWheelItem; -import io.netty.buffer.Unpooled; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.container.Container; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; -import java.io.IOException; +public class PacketValueConfig extends AppEngPacket { + private final String Name; + private final String Value; -public class PacketValueConfig extends AppEngPacket -{ + public PacketValueConfig(final PacketBuffer stream) { + this.Name = stream.readString(); + this.Value = stream.readString(); + // dis.close(); + } - private final String Name; - private final String Value; + // api + public PacketValueConfig(final String name, final String value) { + this.Name = name; + this.Value = value; - public PacketValueConfig( final PacketBuffer stream ) - { - this.Name = stream.readString(); - this.Value = stream.readString(); - // dis.close(); - } + final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); - // api - public PacketValueConfig( final String name, final String value ) - { - this.Name = name; - this.Value = value; + data.writeInt(this.getPacketID()); - final PacketBuffer data = new PacketBuffer( Unpooled.buffer() ); + data.writeString(name); + data.writeString(value); - data.writeInt( this.getPacketID() ); + this.configureWrite(data); + } - data.writeString( name ); - data.writeString( value ); + @Override + public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { + final Container c = player.openContainer; - this.configureWrite( data ); - } + if (this.Name.equals("Item") && ((!player.getHeldItem(Hand.MAIN_HAND).isEmpty() + && player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem) + || (!player.getHeldItem(Hand.OFF_HAND).isEmpty() + && player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem))) { + final Hand hand; + if (!player.getHeldItem(Hand.MAIN_HAND).isEmpty() + && player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem) { + hand = Hand.MAIN_HAND; + } else if (!player.getHeldItem(Hand.OFF_HAND).isEmpty() + && player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem) { + hand = Hand.OFF_HAND; + } else { + return; + } - @Override - public void serverPacketData( final INetworkInfo manager, final PlayerEntity player ) - { - final Container c = player.openContainer; + final ItemStack is = player.getHeldItem(hand); + final IMouseWheelItem si = (IMouseWheelItem) is.getItem(); + si.onWheel(is, this.Value.equals("WheelUp")); + } else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftingStatus) { + final ContainerCraftingStatus qk = (ContainerCraftingStatus) c; + qk.cycleCpu(this.Value.equals("Next")); + } else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftConfirm) { + final ContainerCraftConfirm qk = (ContainerCraftConfirm) c; + qk.cycleCpu(this.Value.equals("Next")); + } else if (this.Name.equals("Terminal.Start") && c instanceof ContainerCraftConfirm) { + final ContainerCraftConfirm qk = (ContainerCraftConfirm) c; + qk.startJob(); + } else if (this.Name.equals("TileCrafting.Cancel") && c instanceof ContainerCraftingCPU) { + final ContainerCraftingCPU qk = (ContainerCraftingCPU) c; + qk.cancelCrafting(); + } else if (this.Name.equals("QuartzKnife.Name") && c instanceof ContainerQuartzKnife) { + final ContainerQuartzKnife qk = (ContainerQuartzKnife) c; + qk.setName(this.Value); + } else if (this.Name.equals("TileSecurityStation.ToggleOption") && c instanceof ContainerSecurityStation) { + final ContainerSecurityStation sc = (ContainerSecurityStation) c; + sc.toggleSetting(this.Value, player); + } else if (this.Name.equals("PriorityHost.Priority") && c instanceof ContainerPriority) { + final ContainerPriority pc = (ContainerPriority) c; + pc.setPriority(Integer.parseInt(this.Value), player); + } else if (this.Name.equals("LevelEmitter.Value") && c instanceof ContainerLevelEmitter) { + final ContainerLevelEmitter lvc = (ContainerLevelEmitter) c; + lvc.setLevel(Long.parseLong(this.Value), player); + } else if (this.Name.equals("FluidLevelEmitter.Value") && c instanceof ContainerFluidLevelEmitter) { + final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c; + lvc.setLevel(Long.parseLong(this.Value), player); + } else if (this.Name.startsWith("PatternTerminal.") && c instanceof ContainerPatternTerm) { + final ContainerPatternTerm cpt = (ContainerPatternTerm) c; + if (this.Name.equals("PatternTerminal.CraftMode")) { + cpt.getPatternTerminal().setCraftingRecipe(this.Value.equals("1")); + } else if (this.Name.equals("PatternTerminal.Encode")) { + cpt.encode(); + } else if (this.Name.equals("PatternTerminal.Clear")) { + cpt.clear(); + } else if (this.Name.equals("PatternTerminal.Substitute")) { + cpt.getPatternTerminal().setSubstitution(this.Value.equals("1")); + } + } else if (this.Name.startsWith("StorageBus.")) { + if (this.Name.equals("StorageBus.Action")) { + if (this.Value.equals("Partition")) { + if (c instanceof ContainerStorageBus) { + ((ContainerStorageBus) c).partition(); + } else if (c instanceof ContainerFluidStorageBus) { + ((ContainerFluidStorageBus) c).partition(); + } + } else if (this.Value.equals("Clear")) { + if (c instanceof ContainerStorageBus) { + ((ContainerStorageBus) c).clear(); + } else if (c instanceof ContainerFluidStorageBus) { + ((ContainerFluidStorageBus) c).clear(); + } + } + } + } else if (this.Name.startsWith("CellWorkbench.") && c instanceof ContainerCellWorkbench) { + final ContainerCellWorkbench ccw = (ContainerCellWorkbench) c; + if (this.Name.equals("CellWorkbench.Action")) { + if (this.Value.equals("CopyMode")) { + ccw.nextWorkBenchCopyMode(); + } else if (this.Value.equals("Partition")) { + ccw.partition(); + } else if (this.Value.equals("Clear")) { + ccw.clear(); + } + } else if (this.Name.equals("CellWorkbench.Fuzzy")) { + ccw.setFuzzy(FuzzyMode.valueOf(this.Value)); + } + } else if (c instanceof ContainerNetworkTool) { + if (this.Name.equals("NetworkTool") && this.Value.equals("Toggle")) { + ((ContainerNetworkTool) c).toggleFacadeMode(); + } + } else if (c instanceof IConfigurableObject) { + final IConfigManager cm = ((IConfigurableObject) c).getConfigManager(); - if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem) || ( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) ) - { - final Hand hand; - if( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem ) - { - hand = Hand.MAIN_HAND; - } - else if( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) - { - hand = Hand.OFF_HAND; - } - else - { - return; - } + for (final Settings e : cm.getSettings()) { + if (e.name().equals(this.Name)) { + final Enum def = cm.getSetting(e); - final ItemStack is = player.getHeldItem( hand ); - final IMouseWheelItem si = (IMouseWheelItem) is.getItem(); - si.onWheel( is, this.Value.equals( "WheelUp" ) ); - } - else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus) - { - final ContainerCraftingStatus qk = (ContainerCraftingStatus) c; - qk.cycleCpu( this.Value.equals( "Next" ) ); - } - else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm ) - { - final ContainerCraftConfirm qk = (ContainerCraftConfirm) c; - qk.cycleCpu( this.Value.equals( "Next" ) ); - } - else if( this.Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm ) - { - final ContainerCraftConfirm qk = (ContainerCraftConfirm) c; - qk.startJob(); - } - else if( this.Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU ) - { - final ContainerCraftingCPU qk = (ContainerCraftingCPU) c; - qk.cancelCrafting(); - } - else if( this.Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife ) - { - final ContainerQuartzKnife qk = (ContainerQuartzKnife) c; - qk.setName( this.Value ); - } - else if( this.Name.equals( "TileSecurityStation.ToggleOption" ) && c instanceof ContainerSecurityStation ) - { - final ContainerSecurityStation sc = (ContainerSecurityStation) c; - sc.toggleSetting( this.Value, player ); - } - else if( this.Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority ) - { - final ContainerPriority pc = (ContainerPriority) c; - pc.setPriority( Integer.parseInt( this.Value ), player ); - } - else if( this.Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter ) - { - final ContainerLevelEmitter lvc = (ContainerLevelEmitter) c; - lvc.setLevel( Long.parseLong( this.Value ), player ); - } - else if( this.Name.equals( "FluidLevelEmitter.Value" ) && c instanceof ContainerFluidLevelEmitter) - { - final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c; - lvc.setLevel( Long.parseLong( this.Value ), player ); - } - else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm ) - { - final ContainerPatternTerm cpt = (ContainerPatternTerm) c; - if( this.Name.equals( "PatternTerminal.CraftMode" ) ) - { - cpt.getPatternTerminal().setCraftingRecipe( this.Value.equals( "1" ) ); - } - else if( this.Name.equals( "PatternTerminal.Encode" ) ) - { - cpt.encode(); - } - else if( this.Name.equals( "PatternTerminal.Clear" ) ) - { - cpt.clear(); - } - else if( this.Name.equals( "PatternTerminal.Substitute" ) ) - { - cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) ); - } - } - else if( this.Name.startsWith( "StorageBus." ) ) - { - if( this.Name.equals( "StorageBus.Action" ) ) - { - if( this.Value.equals( "Partition" ) ) - { - if( c instanceof ContainerStorageBus ) - { - ( (ContainerStorageBus) c ).partition(); - } - else if( c instanceof ContainerFluidStorageBus) - { - ( (ContainerFluidStorageBus) c ).partition(); - } - } - else if( this.Value.equals( "Clear" ) ) - { - if( c instanceof ContainerStorageBus ) - { - ( (ContainerStorageBus) c ).clear(); - } - else if( c instanceof ContainerFluidStorageBus ) - { - ( (ContainerFluidStorageBus) c ).clear(); - } - } - } - } - else if( this.Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench ) - { - final ContainerCellWorkbench ccw = (ContainerCellWorkbench) c; - if( this.Name.equals( "CellWorkbench.Action" ) ) - { - if( this.Value.equals( "CopyMode" ) ) - { - ccw.nextWorkBenchCopyMode(); - } - else if( this.Value.equals( "Partition" ) ) - { - ccw.partition(); - } - else if( this.Value.equals( "Clear" ) ) - { - ccw.clear(); - } - } - else if( this.Name.equals( "CellWorkbench.Fuzzy" ) ) - { - ccw.setFuzzy( FuzzyMode.valueOf( this.Value ) ); - } - } - else if( c instanceof ContainerNetworkTool ) - { - if( this.Name.equals( "NetworkTool" ) && this.Value.equals( "Toggle" ) ) - { - ( (ContainerNetworkTool) c ).toggleFacadeMode(); - } - } - else if( c instanceof IConfigurableObject) - { - final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager(); + try { + cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value)); + } catch (final IllegalArgumentException err) { + // :P + } - for( final Settings e : cm.getSettings() ) - { - if( e.name().equals( this.Name ) ) - { - final Enum def = cm.getSetting( e ); + break; + } + } + } + } - try - { - cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) ); - } - catch( final IllegalArgumentException err ) - { - // :P - } + @Override + public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { + final Container c = player.openContainer; - break; - } - } - } - } + if (this.Name.equals("CustomName") && c instanceof AEBaseContainer) { + ((AEBaseContainer) c).setCustomName(this.Value); + } else if (this.Name.startsWith("SyncDat.")) { + ((AEBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value); + } else if (this.Name.equals("CraftingStatus") && this.Value.equals("Clear")) { + final Screen gs = Minecraft.getInstance().currentScreen; + if (gs instanceof GuiCraftingCPU) { + ((GuiCraftingCPU) gs).clearItems(); + } + } else if (c instanceof IConfigurableObject) { + final IConfigManager cm = ((IConfigurableObject) c).getConfigManager(); - @Override - public void clientPacketData( final INetworkInfo network, final PlayerEntity player ) - { - final Container c = player.openContainer; + for (final Settings e : cm.getSettings()) { + if (e.name().equals(this.Name)) { + final Enum def = cm.getSetting(e); - if( this.Name.equals( "CustomName" ) && c instanceof AEBaseContainer) - { - ( (AEBaseContainer) c ).setCustomName( this.Value ); - } - else if( this.Name.startsWith( "SyncDat." ) ) - { - ( (AEBaseContainer) c ).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value ); - } - else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) ) - { - final Screen gs = Minecraft.getInstance().currentScreen; - if( gs instanceof GuiCraftingCPU) - { - ( (GuiCraftingCPU) gs ).clearItems(); - } - } - else if( c instanceof IConfigurableObject ) - { - final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager(); + try { + cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value)); + } catch (final IllegalArgumentException err) { + // :P + } - for( final Settings e : cm.getSettings() ) - { - if( e.name().equals( this.Name ) ) - { - final Enum def = cm.getSetting( e ); - - try - { - cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) ); - } - catch( final IllegalArgumentException err ) - { - // :P - } - - break; - } - } - } - } + break; + } + } + } + } } diff --git a/src/main/java/appeng/core/worlddata/CompassData.java b/src/main/java/appeng/core/worlddata/CompassData.java index b469d9d7e..8a2c5c971 100644 --- a/src/main/java/appeng/core/worlddata/CompassData.java +++ b/src/main/java/appeng/core/worlddata/CompassData.java @@ -18,7 +18,6 @@ package appeng.core.worlddata; - import java.io.File; import javax.annotation.Nonnull; @@ -27,28 +26,24 @@ import com.google.common.base.Preconditions; import appeng.services.CompassService; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -final class CompassData implements IWorldCompassData -{ - @Nonnull - private final CompassService service; +final class CompassData implements IWorldCompassData { + @Nonnull + private final CompassService service; - public CompassData( @Nonnull final CompassService service ) - { - Preconditions.checkNotNull( service ); + public CompassData(@Nonnull final CompassService service) { + Preconditions.checkNotNull(service); - this.service = service; - } + this.service = service; + } - @Override - public CompassService service() - { - return this.service; - } + @Override + public CompassService service() { + return this.service; + } } diff --git a/src/main/java/appeng/core/worlddata/IWorldCompassData.java b/src/main/java/appeng/core/worlddata/IWorldCompassData.java index c4b74b85c..e9c4f14fa 100644 --- a/src/main/java/appeng/core/worlddata/IWorldCompassData.java +++ b/src/main/java/appeng/core/worlddata/IWorldCompassData.java @@ -18,16 +18,13 @@ package appeng.core.worlddata; - import appeng.services.CompassService; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -public interface IWorldCompassData -{ - CompassService service(); +public interface IWorldCompassData { + CompassService service(); } diff --git a/src/main/java/appeng/core/worlddata/IWorldData.java b/src/main/java/appeng/core/worlddata/IWorldData.java index c46e4a572..cfe12ecd5 100644 --- a/src/main/java/appeng/core/worlddata/IWorldData.java +++ b/src/main/java/appeng/core/worlddata/IWorldData.java @@ -18,27 +18,24 @@ package appeng.core.worlddata; - import javax.annotation.Nonnull; - /** * @author thatsIch * @version rv3 - 02.11.2015 * @since rv3 30.05.2015 */ -public interface IWorldData -{ - void onServerStopping(); +public interface IWorldData { + void onServerStopping(); - void onServerStoppped(); + void onServerStoppped(); - @Nonnull - IWorldGridStorageData storageData(); + @Nonnull + IWorldGridStorageData storageData(); - @Nonnull - IWorldPlayerData playerData(); + @Nonnull + IWorldPlayerData playerData(); - @Nonnull - IWorldCompassData compassData(); + @Nonnull + IWorldCompassData compassData(); } diff --git a/src/main/java/appeng/core/worlddata/IWorldDimensionData.java b/src/main/java/appeng/core/worlddata/IWorldDimensionData.java index cc2319b00..064552f25 100644 --- a/src/main/java/appeng/core/worlddata/IWorldDimensionData.java +++ b/src/main/java/appeng/core/worlddata/IWorldDimensionData.java @@ -18,26 +18,23 @@ package appeng.core.worlddata; - import javax.annotation.Nullable; import net.minecraft.network.NetworkManager; import appeng.api.util.WorldCoord; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -public interface IWorldDimensionData -{ - void addStorageCell( int newStorageCellID ); +public interface IWorldDimensionData { + void addStorageCell(int newStorageCellID); - WorldCoord getStoredSize( int dim ); + WorldCoord getStoredSize(int dim); - void setStoredSize( int dim, int targetX, int targetY, int targetZ ); + void setStoredSize(int dim, int targetX, int targetY, int targetZ); - void sendToPlayer( @Nullable NetworkManager manager ); + void sendToPlayer(@Nullable NetworkManager manager); } diff --git a/src/main/java/appeng/core/worlddata/IWorldGridStorageData.java b/src/main/java/appeng/core/worlddata/IWorldGridStorageData.java index 55afdab51..4d49f349c 100644 --- a/src/main/java/appeng/core/worlddata/IWorldGridStorageData.java +++ b/src/main/java/appeng/core/worlddata/IWorldGridStorageData.java @@ -18,26 +18,23 @@ package appeng.core.worlddata; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import appeng.me.GridStorage; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -public interface IWorldGridStorageData -{ - GridStorage getGridStorage( long storageID ); +public interface IWorldGridStorageData { + GridStorage getGridStorage(long storageID); - @Nonnull - GridStorage getNewGridStorage(); + @Nonnull + GridStorage getNewGridStorage(); - void destroyGridStorage( long id ); + void destroyGridStorage(long id); - int getNextOrderedValue( String name, int firstValue ); + int getNextOrderedValue(String name, int firstValue); } diff --git a/src/main/java/appeng/core/worlddata/IWorldPlayerData.java b/src/main/java/appeng/core/worlddata/IWorldPlayerData.java index 6e27c2f19..99447f347 100644 --- a/src/main/java/appeng/core/worlddata/IWorldPlayerData.java +++ b/src/main/java/appeng/core/worlddata/IWorldPlayerData.java @@ -18,6 +18,7 @@ package appeng.core.worlddata; +import java.util.UUID; import javax.annotation.Nullable; @@ -25,23 +26,22 @@ import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; -import java.util.UUID; - - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -public interface IWorldPlayerData -{ - /** - * Gets the UUID of the Minecraft profile associated with the given ME player id. - * @param playerID An ME player id. - * @return Null if the ME player id is unknown, otherwise the unique id of the Minecraft profile it originates from. - */ - @Nullable - UUID getProfileId(int playerID ); +public interface IWorldPlayerData { + /** + * Gets the UUID of the Minecraft profile associated with the given ME player + * id. + * + * @param playerID An ME player id. + * @return Null if the ME player id is unknown, otherwise the unique id of the + * Minecraft profile it originates from. + */ + @Nullable + UUID getProfileId(int playerID); - int getMePlayerId(GameProfile profile ); + int getMePlayerId(GameProfile profile); } diff --git a/src/main/java/appeng/core/worlddata/IWorldSpawnData.java b/src/main/java/appeng/core/worlddata/IWorldSpawnData.java index 2f20fa862..a0f964cb8 100644 --- a/src/main/java/appeng/core/worlddata/IWorldSpawnData.java +++ b/src/main/java/appeng/core/worlddata/IWorldSpawnData.java @@ -18,25 +18,22 @@ package appeng.core.worlddata; - import java.util.Collection; import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.dimension.Dimension; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -public interface IWorldSpawnData -{ - void setGenerated( Dimension dim, int chunkX, int chunkZ ); +public interface IWorldSpawnData { + void setGenerated(Dimension dim, int chunkX, int chunkZ); - boolean hasGenerated( Dimension dim, int chunkX, int chunkZ ); + boolean hasGenerated(Dimension dim, int chunkX, int chunkZ); - boolean addNearByMeteorites( Dimension dim, int chunkX, int chunkZ, CompoundNBT newData ); + boolean addNearByMeteorites(Dimension dim, int chunkX, int chunkZ, CompoundNBT newData); - Collection getNearByMeteorites( Dimension dim, int chunkX, int chunkZ ); + Collection getNearByMeteorites(Dimension dim, int chunkX, int chunkZ); } diff --git a/src/main/java/appeng/core/worlddata/MeteorDataNameEncoder.java b/src/main/java/appeng/core/worlddata/MeteorDataNameEncoder.java index 916467764..33bee368e 100644 --- a/src/main/java/appeng/core/worlddata/MeteorDataNameEncoder.java +++ b/src/main/java/appeng/core/worlddata/MeteorDataNameEncoder.java @@ -18,12 +18,10 @@ package appeng.core.worlddata; - import javax.annotation.Nonnull; import com.google.common.base.Preconditions; - /** * encodes data into a common name * @@ -31,32 +29,31 @@ import com.google.common.base.Preconditions; * @version rv3 - 05.06.2015 * @since rv3 05.06.2015 */ -public class MeteorDataNameEncoder -{ - private final int bitScale; +public class MeteorDataNameEncoder { + private final int bitScale; - /** - * @param bitScale how often the coordinates will be shifted right (will scale coordinates down) - */ - public MeteorDataNameEncoder( final int bitScale ) - { - Preconditions.checkArgument( bitScale >= 0 ); - this.bitScale = bitScale; - } + /** + * @param bitScale how often the coordinates will be shifted right (will scale + * coordinates down) + */ + public MeteorDataNameEncoder(final int bitScale) { + Preconditions.checkArgument(bitScale >= 0); + this.bitScale = bitScale; + } - /** - * @param chunkX X coordinate of the chunk. Can be any integer - * @param chunkZ Z coordinate of the chunk. Can be any integer - * - * @return encoded file name suggestion in form of dim_x_y.dat where x and y will be - * shifted to stay conform with the vanilla chunk system - * - * @since rv3 05.06.2015 - */ - public String encode( final int chunkX, final int chunkZ ) - { - final int shiftedX = chunkX >> this.bitScale; - final int shiftedZ = chunkZ >> this.bitScale; - return shiftedX + "_" + shiftedZ; - } + /** + * @param chunkX X coordinate of the chunk. Can be any integer + * @param chunkZ Z coordinate of the chunk. Can be any integer + * + * @return encoded file name suggestion in form of dim_x_y.dat where + * x and y will be shifted to stay conform with the + * vanilla chunk system + * + * @since rv3 05.06.2015 + */ + public String encode(final int chunkX, final int chunkZ) { + final int shiftedX = chunkX >> this.bitScale; + final int shiftedZ = chunkZ >> this.bitScale; + return shiftedX + "_" + shiftedZ; + } } diff --git a/src/main/java/appeng/core/worlddata/PlayerData.java b/src/main/java/appeng/core/worlddata/PlayerData.java index c469c1a5f..9bf181bf4 100644 --- a/src/main/java/appeng/core/worlddata/PlayerData.java +++ b/src/main/java/appeng/core/worlddata/PlayerData.java @@ -18,26 +18,27 @@ package appeng.core.worlddata; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.core.AELog; -import appeng.core.AppEng; import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mojang.authlib.GameProfile; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.storage.WorldSavedData; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Map; -import java.util.UUID; - +import appeng.core.AELog; +import appeng.core.AppEng; /** * Handles the matching between UUIDs and internal IDs for security systems. - * This whole system could be replaced by storing directly the UUID, - * using a lot more traffic though + * This whole system could be replaced by storing directly the UUID, using a lot + * more traffic though * * @author thatsIch * @version rv3 - 30.05.2015 @@ -76,7 +77,8 @@ final class PlayerData extends WorldSavedData implements IWorldPlayerData { this.mapping.put(profile.getId(), playerId); markDirty(); - AELog.info("Assigning ME player id {} to Minecraft profile {} ({})", playerId, profile.getId(), profile.getName()); + AELog.info("Assigning ME player id {} to Minecraft profile {} ({})", playerId, profile.getId(), + profile.getName()); } return playerId; @@ -88,9 +90,8 @@ final class PlayerData extends WorldSavedData implements IWorldPlayerData { long[] profileIds = nbt.getLongArray(TAG_PROFILE_IDS); if (playerIds.length * 2 != profileIds.length) { - throw new IllegalStateException("Plaer ID mapping is corrupted. " - + playerIds.length + " player IDs vs. " + profileIds.length - + " profile IDs (latter must be 2 * the former)"); + throw new IllegalStateException("Plaer ID mapping is corrupted. " + playerIds.length + " player IDs vs. " + + profileIds.length + " profile IDs (latter must be 2 * the former)"); } this.mapping.clear(); diff --git a/src/main/java/appeng/core/worlddata/StorageData.java b/src/main/java/appeng/core/worlddata/StorageData.java index 271c30100..cfe8b2de0 100644 --- a/src/main/java/appeng/core/worlddata/StorageData.java +++ b/src/main/java/appeng/core/worlddata/StorageData.java @@ -18,147 +18,143 @@ package appeng.core.worlddata; +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Nonnull; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.storage.WorldSavedData; import appeng.core.AELog; import appeng.core.AppEng; import appeng.me.GridStorage; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.storage.WorldSavedData; - -import javax.annotation.Nonnull; -import java.util.HashMap; -import java.util.Map; - /** * @author thatsIch * @version rv3 - 30.05.2015 * @since rv3 30.05.2015 */ -final class StorageData extends WorldSavedData implements IWorldGridStorageData -{ +final class StorageData extends WorldSavedData implements IWorldGridStorageData { - public static final String NAME = AppEng.MOD_ID + "_storage"; + public static final String NAME = AppEng.MOD_ID + "_storage"; - private static final String TAG_NEXT_ID = "nextId"; - public static final String TAG_ORDERED_VALUES = "orderedValues"; - public static final String TAG_STORAGE = "storage"; + private static final String TAG_NEXT_ID = "nextId"; + public static final String TAG_ORDERED_VALUES = "orderedValues"; + public static final String TAG_STORAGE = "storage"; - private final Map storage = new HashMap<>(); + private final Map storage = new HashMap<>(); - // id that will be assigned to the next new grid, this needs to be persisted - // because grids can be removed and we do not want to re-assign the same id twice - private long nextGridId; + // id that will be assigned to the next new grid, this needs to be persisted + // because grids can be removed and we do not want to re-assign the same id + // twice + private long nextGridId; - // Stores once-per-save values. I.e. which storage press to drop next in a spawned meteor - private final Map orderedValues = new HashMap<>(); + // Stores once-per-save values. I.e. which storage press to drop next in a + // spawned meteor + private final Map orderedValues = new HashMap<>(); - public StorageData() { - super(NAME); - } + public StorageData() { + super(NAME); + } - /** - * lazy loading, can load any id, even ones that don't exist anymore. - * - * @param storageID ID of grid storage - * - * @return corresponding grid storage - */ - @Override - public GridStorage getGridStorage( final long storageID ) - { - GridStorage result = storage.get(storageID); + /** + * lazy loading, can load any id, even ones that don't exist anymore. + * + * @param storageID ID of grid storage + * + * @return corresponding grid storage + */ + @Override + public GridStorage getGridStorage(final long storageID) { + GridStorage result = storage.get(storageID); - if( result == null ) - { - result = new GridStorage(storageID); - storage.put(storageID, result); - } + if (result == null) { + result = new GridStorage(storageID); + storage.put(storageID, result); + } - return result; - } + return result; + } - /** - * create a new storage - */ - @Nonnull - @Override - public GridStorage getNewGridStorage() - { - return getGridStorage(nextGridId++); - } + /** + * create a new storage + */ + @Nonnull + @Override + public GridStorage getNewGridStorage() { + return getGridStorage(nextGridId++); + } - @Override - public void destroyGridStorage( final long id ) - { - this.storage.remove(id); - } + @Override + public void destroyGridStorage(final long id) { + this.storage.remove(id); + } - @Override - public int getNextOrderedValue( final String name, int firstValue ) - { - return orderedValues.merge(name, firstValue, (oldValue, value) -> oldValue + 1); - } + @Override + public int getNextOrderedValue(final String name, int firstValue) { + return orderedValues.merge(name, firstValue, (oldValue, value) -> oldValue + 1); + } - @Override - public void read(CompoundNBT tag) { + @Override + public void read(CompoundNBT tag) { - nextGridId = tag.getLong(TAG_NEXT_ID); + nextGridId = tag.getLong(TAG_NEXT_ID); - // Load serialized grid storage - CompoundNBT storageTag = tag.getCompound(TAG_STORAGE); - for (String storageIdStr : storageTag.keySet()) { - long storageId; - try { - storageId = Long.parseLong(storageIdStr); - } catch (NumberFormatException e) { - AELog.warn("Unable to load grid storage with malformed id: '{}'", storageIdStr); - continue; - } - storage.put(storageId, new GridStorage(storageId, storageTag.getCompound(storageIdStr))); - } + // Load serialized grid storage + CompoundNBT storageTag = tag.getCompound(TAG_STORAGE); + for (String storageIdStr : storageTag.keySet()) { + long storageId; + try { + storageId = Long.parseLong(storageIdStr); + } catch (NumberFormatException e) { + AELog.warn("Unable to load grid storage with malformed id: '{}'", storageIdStr); + continue; + } + storage.put(storageId, new GridStorage(storageId, storageTag.getCompound(storageIdStr))); + } - // Load ordered values map - CompoundNBT orderedValuesTag = tag.getCompound(TAG_ORDERED_VALUES); - this.orderedValues.clear(); - for (String key : orderedValuesTag.keySet()) { - this.orderedValues.put(key, orderedValuesTag.getInt(key)); - } + // Load ordered values map + CompoundNBT orderedValuesTag = tag.getCompound(TAG_ORDERED_VALUES); + this.orderedValues.clear(); + for (String key : orderedValuesTag.keySet()) { + this.orderedValues.put(key, orderedValuesTag.getInt(key)); + } - } + } - @Override - public CompoundNBT write(CompoundNBT tag) { + @Override + public CompoundNBT write(CompoundNBT tag) { - tag.putLong(TAG_NEXT_ID, nextGridId); + tag.putLong(TAG_NEXT_ID, nextGridId); - // Save serialized grid storage - CompoundNBT storageTag = new CompoundNBT(); - for (Map.Entry entry : storage.entrySet()) { + // Save serialized grid storage + CompoundNBT storageTag = new CompoundNBT(); + for (Map.Entry entry : storage.entrySet()) { - GridStorage gridStorage = entry.getValue(); + GridStorage gridStorage = entry.getValue(); - if (gridStorage.getGrid() == null || gridStorage.getGrid().isEmpty()) { - continue; - } + if (gridStorage.getGrid() == null || gridStorage.getGrid().isEmpty()) { + continue; + } - try { - entry.getValue().saveState(); - } catch (Exception e) { - AELog.warn("Failed to save state of Grid {}, storing last known value instead.", entry.getKey(), e); - } - storageTag.put(String.valueOf(entry.getKey()), entry.getValue().dataObject()); - } - tag.put(TAG_STORAGE, storageTag); + try { + entry.getValue().saveState(); + } catch (Exception e) { + AELog.warn("Failed to save state of Grid {}, storing last known value instead.", entry.getKey(), e); + } + storageTag.put(String.valueOf(entry.getKey()), entry.getValue().dataObject()); + } + tag.put(TAG_STORAGE, storageTag); - // Save ordered values - CompoundNBT orderedValuesTag = new CompoundNBT(); - for (Map.Entry entry : orderedValues.entrySet()) { - orderedValuesTag.putInt(entry.getKey(), entry.getValue()); - } - tag.put(TAG_ORDERED_VALUES, orderedValuesTag); + // Save ordered values + CompoundNBT orderedValuesTag = new CompoundNBT(); + for (Map.Entry entry : orderedValues.entrySet()) { + orderedValuesTag.putInt(entry.getKey(), entry.getValue()); + } + tag.put(TAG_ORDERED_VALUES, orderedValuesTag); - return tag; - } + return tag; + } } diff --git a/src/main/java/appeng/core/worlddata/WorldData.java b/src/main/java/appeng/core/worlddata/WorldData.java index ea1da46c4..d33727c75 100644 --- a/src/main/java/appeng/core/worlddata/WorldData.java +++ b/src/main/java/appeng/core/worlddata/WorldData.java @@ -18,133 +18,126 @@ package appeng.core.worlddata; +import java.util.concurrent.ThreadFactory; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.services.CompassService; -import appeng.services.compass.CompassThreadFactory; import com.google.common.base.Preconditions; + import net.minecraft.server.MinecraftServer; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.concurrent.ThreadFactory; - +import appeng.services.CompassService; +import appeng.services.compass.CompassThreadFactory; /** * Singleton access to anything related to world-based data. * - * Data will change depending which world is loaded. Will probably not affect SMP at all since only one world is loaded, - * but SSP more, cause they play on + * Data will change depending which world is loaded. Will probably not affect + * SMP at all since only one world is loaded, but SSP more, cause they play on * different worlds. * * @author thatsIch * @version rv3 - 02.11.2015 * @since rv3 30.05.2015 */ -public final class WorldData implements IWorldData -{ +public final class WorldData implements IWorldData { - /** - * Is null while no MinecraftServer exists. - */ - @Nullable - private static IWorldData instance; + /** + * Is null while no MinecraftServer exists. + */ + @Nullable + private static IWorldData instance; - @Nullable - private static MinecraftServer server; + @Nullable + private static MinecraftServer server; - private final IWorldPlayerData playerData; - private final IWorldGridStorageData storageData; - private final IWorldCompassData compassData; + private final IWorldPlayerData playerData; + private final IWorldGridStorageData storageData; + private final IWorldCompassData compassData; - private WorldData( @Nonnull final ServerWorld overworld ) - { - Preconditions.checkNotNull( overworld ); + private WorldData(@Nonnull final ServerWorld overworld) { + Preconditions.checkNotNull(overworld); - // Attach shared data to the server's overworld dimension - if (overworld.getDimension().getType() != DimensionType.OVERWORLD) { - throw new IllegalStateException("The server doesn't have an Overworld dimension we could store our data on!"); - } + // Attach shared data to the server's overworld dimension + if (overworld.getDimension().getType() != DimensionType.OVERWORLD) { + throw new IllegalStateException( + "The server doesn't have an Overworld dimension we could store our data on!"); + } - final PlayerData playerData = overworld.getSavedData().getOrCreate(PlayerData::new, PlayerData.NAME); - final StorageData storageData = overworld.getSavedData().getOrCreate(StorageData::new, StorageData.NAME); + final PlayerData playerData = overworld.getSavedData().getOrCreate(PlayerData::new, PlayerData.NAME); + final StorageData storageData = overworld.getSavedData().getOrCreate(StorageData::new, StorageData.NAME); - final ThreadFactory compassThreadFactory = new CompassThreadFactory(); - final CompassService compassService = new CompassService(server, compassThreadFactory ); - final CompassData compassData = new CompassData( compassService ); + final ThreadFactory compassThreadFactory = new CompassThreadFactory(); + final CompassService compassService = new CompassService(server, compassThreadFactory); + final CompassData compassData = new CompassData(compassService); - this.playerData = playerData; - this.storageData = storageData; - this.compassData = compassData; + this.playerData = playerData; + this.storageData = storageData; + this.compassData = compassData; - } + } - /** - * @return ae2 data related to a specific world - * - * @deprecated do not use singletons which are dependent on specific world state - */ - @Deprecated - @Nonnull - public synchronized static IWorldData instance() - { - // The overworld is lazily loaded, meaning we cannot access it right away - // when the server is starting, but the first time the instance is accessed, - // we create the actual world data - if (instance == null) { - if (server == null) { - throw new IllegalStateException("No server set."); - } + /** + * @return ae2 data related to a specific world + * + * @deprecated do not use singletons which are dependent on specific world state + */ + @Deprecated + @Nonnull + public synchronized static IWorldData instance() { + // The overworld is lazily loaded, meaning we cannot access it right away + // when the server is starting, but the first time the instance is accessed, + // we create the actual world data + if (instance == null) { + if (server == null) { + throw new IllegalStateException("No server set."); + } - ServerWorld overworld = server.getWorld(DimensionType.OVERWORLD); - instance = new WorldData(overworld); - } - return instance; - } + ServerWorld overworld = server.getWorld(DimensionType.OVERWORLD); + instance = new WorldData(overworld); + } + return instance; + } - /** - * Requires to start up from external from here - * - * drawback of the singleton build style - */ - public static void onServerStarting(MinecraftServer server) - { - WorldData.server = server; - } + /** + * Requires to start up from external from here + * + * drawback of the singleton build style + */ + public static void onServerStarting(MinecraftServer server) { + WorldData.server = server; + } - @Override - public void onServerStopping() - { - compassData.service().kill(); - } + @Override + public void onServerStopping() { + compassData.service().kill(); + } - @Override - public void onServerStoppped() - { - Preconditions.checkNotNull( server ); - instance = null; - WorldData.server = null; - } + @Override + public void onServerStoppped() { + Preconditions.checkNotNull(server); + instance = null; + WorldData.server = null; + } - @Nonnull - @Override - public IWorldGridStorageData storageData() - { - return this.storageData; - } + @Nonnull + @Override + public IWorldGridStorageData storageData() { + return this.storageData; + } - @Nonnull - @Override - public IWorldPlayerData playerData() - { - return this.playerData; - } + @Nonnull + @Override + public IWorldPlayerData playerData() { + return this.playerData; + } - @Nonnull - @Override - public IWorldCompassData compassData() - { - return this.compassData; - } + @Nonnull + @Override + public IWorldCompassData compassData() { + return this.compassData; + } } diff --git a/src/main/java/appeng/crafting/CraftBranchFailure.java b/src/main/java/appeng/crafting/CraftBranchFailure.java index 090c445c1..4a92dec94 100644 --- a/src/main/java/appeng/crafting/CraftBranchFailure.java +++ b/src/main/java/appeng/crafting/CraftBranchFailure.java @@ -18,21 +18,17 @@ package appeng.crafting; - import appeng.api.storage.data.IAEItemStack; +public class CraftBranchFailure extends Exception { -public class CraftBranchFailure extends Exception -{ + private static final long serialVersionUID = 654603652836724823L; - private static final long serialVersionUID = 654603652836724823L; + private final IAEItemStack missing; - private final IAEItemStack missing; - - public CraftBranchFailure( final IAEItemStack what, final long howMany ) - { - super( "Failed: " + what.getItem().getRegistryName() + " x " + howMany ); - this.missing = what.copy(); - this.missing.setStackSize( howMany ); - } + public CraftBranchFailure(final IAEItemStack what, final long howMany) { + super("Failed: " + what.getItem().getRegistryName() + " x " + howMany); + this.missing = what.copy(); + this.missing.setStackSize(howMany); + } } diff --git a/src/main/java/appeng/crafting/CraftingCalculationFailure.java b/src/main/java/appeng/crafting/CraftingCalculationFailure.java index bfaa7ece2..bf2313a37 100644 --- a/src/main/java/appeng/crafting/CraftingCalculationFailure.java +++ b/src/main/java/appeng/crafting/CraftingCalculationFailure.java @@ -18,21 +18,17 @@ package appeng.crafting; - import appeng.api.storage.data.IAEItemStack; +public class CraftingCalculationFailure extends RuntimeException { -public class CraftingCalculationFailure extends RuntimeException -{ + private static final long serialVersionUID = 654603652836724823L; - private static final long serialVersionUID = 654603652836724823L; + private final IAEItemStack missing; - private final IAEItemStack missing; - - public CraftingCalculationFailure( final IAEItemStack what, final long howMany ) - { - super( "this should have been caught!" ); - this.missing = what.copy(); - this.missing.setStackSize( howMany ); - } + public CraftingCalculationFailure(final IAEItemStack what, final long howMany) { + super("this should have been caught!"); + this.missing = what.copy(); + this.missing.setStackSize(howMany); + } } diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index abe751200..a7fcb7594 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -18,7 +18,6 @@ package appeng.crafting; - import java.util.HashMap; import java.util.concurrent.TimeUnit; @@ -47,361 +46,300 @@ import appeng.api.util.DimensionalCoord; import appeng.core.AELog; import appeng.hooks.TickHandler; +public class CraftingJob implements Runnable, ICraftingJob { + private static final String LOG_CRAFTING_JOB = "CraftingJob (%s) issued by %s requesting [%s] using %s bytes took %s ms"; + private static final String LOG_MACHINE_SOURCE_DETAILS = "Machine[object=%s, %s]"; -public class CraftingJob implements Runnable, ICraftingJob -{ - private static final String LOG_CRAFTING_JOB = "CraftingJob (%s) issued by %s requesting [%s] using %s bytes took %s ms"; - private static final String LOG_MACHINE_SOURCE_DETAILS = "Machine[object=%s, %s]"; + private final MECraftingInventory original; + private final World world; + private final IItemList crafting = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final IItemList missing = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final HashMap opsAndMultiplier = new HashMap<>(); + private final Object monitor = new Object(); + private final Stopwatch watch = Stopwatch.createUnstarted(); + private CraftingTreeNode tree; + private final IAEItemStack output; + private boolean simulate = false; + private MECraftingInventory availableCheck; + private long bytes = 0; + private final IActionSource actionSrc; + private final ICraftingCallback callback; + private boolean running = false; + private boolean done = false; + private int time = 5; + private int incTime = Integer.MAX_VALUE; - private final MECraftingInventory original; - private final World world; - private final IItemList crafting = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final IItemList missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final HashMap opsAndMultiplier = new HashMap<>(); - private final Object monitor = new Object(); - private final Stopwatch watch = Stopwatch.createUnstarted(); - private CraftingTreeNode tree; - private final IAEItemStack output; - private boolean simulate = false; - private MECraftingInventory availableCheck; - private long bytes = 0; - private final IActionSource actionSrc; - private final ICraftingCallback callback; - private boolean running = false; - private boolean done = false; - private int time = 5; - private int incTime = Integer.MAX_VALUE; + private World wrapWorld(final World w) { + return w; + } - private World wrapWorld( final World w ) - { - return w; - } + public CraftingJob(final World w, final IGrid grid, final IActionSource actionSrc, final IAEItemStack what, + final ICraftingCallback callback) { + this.world = this.wrapWorld(w); + this.output = what.copy(); + this.actionSrc = actionSrc; - public CraftingJob( final World w, final IGrid grid, final IActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback ) - { - this.world = this.wrapWorld( w ); - this.output = what.copy(); - this.actionSrc = actionSrc; + this.callback = callback; + final ICraftingGrid cc = grid.getCache(ICraftingGrid.class); + final IStorageGrid sg = grid.getCache(IStorageGrid.class); + this.original = new MECraftingInventory( + sg.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)), actionSrc, + false, false, false); - this.callback = callback; - final ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); - final IStorageGrid sg = grid.getCache( IStorageGrid.class ); - this.original = new MECraftingInventory( sg - .getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), actionSrc, false, false, false ); + this.setTree(this.getCraftingTree(cc, what)); + this.availableCheck = null; + } - this.setTree( this.getCraftingTree( cc, what ) ); - this.availableCheck = null; - } + private CraftingTreeNode getCraftingTree(final ICraftingGrid cc, final IAEItemStack what) { + return new CraftingTreeNode(cc, this, what, null, -1, 0); + } - private CraftingTreeNode getCraftingTree( final ICraftingGrid cc, final IAEItemStack what ) - { - return new CraftingTreeNode( cc, this, what, null, -1, 0 ); - } + void refund(final IAEItemStack o) { + this.availableCheck.injectItems(o, Actionable.MODULATE, this.actionSrc); + } - void refund( final IAEItemStack o ) - { - this.availableCheck.injectItems( o, Actionable.MODULATE, this.actionSrc ); - } + IAEItemStack checkUse(final IAEItemStack available) { + return this.availableCheck.extractItems(available, Actionable.MODULATE, this.actionSrc); + } - IAEItemStack checkUse( final IAEItemStack available ) - { - return this.availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc ); - } + public void writeToNBT(final CompoundNBT out) { - public void writeToNBT( final CompoundNBT out ) - { + } - } + void addTask(IAEItemStack what, final long crafts, final ICraftingPatternDetails details, final int depth) { + if (crafts > 0) { + what = what.copy(); + what.setStackSize(what.getStackSize() * crafts); + this.crafting.add(what); + } + } - void addTask( IAEItemStack what, final long crafts, final ICraftingPatternDetails details, final int depth ) - { - if( crafts > 0 ) - { - what = what.copy(); - what.setStackSize( what.getStackSize() * crafts ); - this.crafting.add( what ); - } - } + void addMissing(IAEItemStack what) { + what = what.copy(); + this.missing.add(what); + } - void addMissing( IAEItemStack what ) - { - what = what.copy(); - this.missing.add( what ); - } + @Override + public void run() { + try { + try { + TickHandler.INSTANCE.registerCraftingSimulation(this.world, this); + this.handlePausing(); - @Override - public void run() - { - try - { - try - { - TickHandler.INSTANCE.registerCraftingSimulation( this.world, this ); - this.handlePausing(); + final Stopwatch timer = Stopwatch.createStarted(); - final Stopwatch timer = Stopwatch.createStarted(); + final MECraftingInventory craftingInventory = new MECraftingInventory(this.original, true, false, true); + craftingInventory.ignore(this.output); - final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true ); - craftingInventory.ignore( this.output ); + this.availableCheck = new MECraftingInventory(this.original, false, false, false); + this.getTree().request(craftingInventory, this.output.getStackSize(), this.actionSrc); + this.getTree().dive(this); - this.availableCheck = new MECraftingInventory( this.original, false, false, false ); - this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc ); - this.getTree().dive( this ); + for (final String s : this.opsAndMultiplier.keySet()) { + final TwoIntegers ti = this.opsAndMultiplier.get(s); + AELog.crafting(s + " * " + ti.times + " = " + (ti.perOp * ti.times)); + } - for( final String s : this.opsAndMultiplier.keySet() ) - { - final TwoIntegers ti = this.opsAndMultiplier.get( s ); - AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) ); - } + this.logCraftingJob("real", timer); + // if ( mode == Actionable.MODULATE ) + // craftingInventory.moveItemsToStorage( storage ); + } catch (final CraftBranchFailure e) { + this.simulate = true; - this.logCraftingJob( "real", timer ); - // if ( mode == Actionable.MODULATE ) - // craftingInventory.moveItemsToStorage( storage ); - } - catch( final CraftBranchFailure e ) - { - this.simulate = true; + try { + final Stopwatch timer = Stopwatch.createStarted(); + final MECraftingInventory craftingInventory = new MECraftingInventory(this.original, true, false, + true); + craftingInventory.ignore(this.output); - try - { - final Stopwatch timer = Stopwatch.createStarted(); - final MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true ); - craftingInventory.ignore( this.output ); + this.availableCheck = new MECraftingInventory(this.original, false, false, false); - this.availableCheck = new MECraftingInventory( this.original, false, false, false ); + this.getTree().setSimulate(); + this.getTree().request(craftingInventory, this.output.getStackSize(), this.actionSrc); + this.getTree().dive(this); - this.getTree().setSimulate(); - this.getTree().request( craftingInventory, this.output.getStackSize(), this.actionSrc ); - this.getTree().dive( this ); + for (final String s : this.opsAndMultiplier.keySet()) { + final TwoIntegers ti = this.opsAndMultiplier.get(s); + AELog.crafting(s + " * " + ti.times + " = " + (ti.perOp * ti.times)); + } - for( final String s : this.opsAndMultiplier.keySet() ) - { - final TwoIntegers ti = this.opsAndMultiplier.get( s ); - AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) ); - } + this.logCraftingJob("simulate", timer); + } catch (final CraftBranchFailure e1) { + AELog.debug(e1); + } catch (final CraftingCalculationFailure f) { + AELog.debug(f); + } catch (final InterruptedException e1) { + AELog.crafting("Crafting calculation canceled."); + this.finish(); + return; + } + } catch (final CraftingCalculationFailure f) { + AELog.debug(f); + } catch (final InterruptedException e1) { + AELog.crafting("Crafting calculation canceled."); + this.finish(); + return; + } - this.logCraftingJob( "simulate", timer ); - } - catch( final CraftBranchFailure e1 ) - { - AELog.debug( e1 ); - } - catch( final CraftingCalculationFailure f ) - { - AELog.debug( f ); - } - catch( final InterruptedException e1 ) - { - AELog.crafting( "Crafting calculation canceled." ); - this.finish(); - return; - } - } - catch( final CraftingCalculationFailure f ) - { - AELog.debug( f ); - } - catch( final InterruptedException e1 ) - { - AELog.crafting( "Crafting calculation canceled." ); - this.finish(); - return; - } + AELog.craftingDebug("crafting job now done"); + } catch (final Throwable t) { + this.finish(); + throw new IllegalStateException(t); + } - AELog.craftingDebug( "crafting job now done" ); - } - catch( final Throwable t ) - { - this.finish(); - throw new IllegalStateException( t ); - } + this.finish(); + } - this.finish(); - } + void handlePausing() throws InterruptedException { + if (this.incTime > 100) { + this.incTime = 0; - void handlePausing() throws InterruptedException - { - if( this.incTime > 100 ) - { - this.incTime = 0; + synchronized (this.monitor) { + if (this.watch.elapsed(TimeUnit.MICROSECONDS) > this.time) { + this.running = false; + this.watch.stop(); + this.monitor.notify(); + } - synchronized( this.monitor ) - { - if( this.watch.elapsed( TimeUnit.MICROSECONDS ) > this.time ) - { - this.running = false; - this.watch.stop(); - this.monitor.notify(); - } + if (!this.running) { + AELog.craftingDebug("crafting job will now sleep"); - if( !this.running ) - { - AELog.craftingDebug( "crafting job will now sleep" ); + while (!this.running) { + this.monitor.wait(); + } - while( !this.running ) - { - this.monitor.wait(); - } + AELog.craftingDebug("crafting job now active"); + } + } - AELog.craftingDebug( "crafting job now active" ); - } - } + if (Thread.interrupted()) { + throw new InterruptedException(); + } + } + this.incTime++; + } - if( Thread.interrupted() ) - { - throw new InterruptedException(); - } - } - this.incTime++; - } + private void finish() { + if (this.callback != null) { + this.callback.calculationComplete(this); + } - private void finish() - { - if( this.callback != null ) - { - this.callback.calculationComplete( this ); - } + this.availableCheck = null; - this.availableCheck = null; + synchronized (this.monitor) { + this.running = false; + this.done = true; + this.monitor.notify(); + } + } - synchronized( this.monitor ) - { - this.running = false; - this.done = true; - this.monitor.notify(); - } - } + @Override + public boolean isSimulation() { + return this.simulate; + } - @Override - public boolean isSimulation() - { - return this.simulate; - } + @Override + public long getByteTotal() { + return this.bytes; + } - @Override - public long getByteTotal() - { - return this.bytes; - } + @Override + public void populatePlan(final IItemList plan) { + if (this.getTree() != null) { + this.getTree().getPlan(plan); + } + } - @Override - public void populatePlan( final IItemList plan ) - { - if( this.getTree() != null ) - { - this.getTree().getPlan( plan ); - } - } + @Override + public IAEItemStack getOutput() { + return this.output; + } - @Override - public IAEItemStack getOutput() - { - return this.output; - } + public boolean isDone() { + return this.done; + } - public boolean isDone() - { - return this.done; - } + World getWorld() { + return this.world; + } - World getWorld() - { - return this.world; - } + /** + * returns true if this needs more simulation. + * + * @param milli milliseconds of simulation + * + * @return true if this needs more simulation + */ + public boolean simulateFor(final int milli) { + this.time = milli; - /** - * returns true if this needs more simulation. - * - * @param milli milliseconds of simulation - * - * @return true if this needs more simulation - */ - public boolean simulateFor( final int milli ) - { - this.time = milli; + synchronized (this.monitor) { + if (this.done) { + return false; + } - synchronized( this.monitor ) - { - if( this.done ) - { - return false; - } + this.watch.reset(); + this.watch.start(); + this.running = true; - this.watch.reset(); - this.watch.start(); - this.running = true; + AELog.craftingDebug("main thread is now going to sleep"); - AELog.craftingDebug( "main thread is now going to sleep" ); + this.monitor.notify(); - this.monitor.notify(); + while (this.running) { + try { + this.monitor.wait(); + } catch (final InterruptedException ignored) { + } + } - while( this.running ) - { - try - { - this.monitor.wait(); - } - catch( final InterruptedException ignored ) - { - } - } + AELog.craftingDebug("main thread is now active"); + } - AELog.craftingDebug( "main thread is now active" ); - } + return true; + } - return true; - } + void addBytes(final long crafts) { + this.bytes += crafts; + } - void addBytes( final long crafts ) - { - this.bytes += crafts; - } + public CraftingTreeNode getTree() { + return this.tree; + } - public CraftingTreeNode getTree() - { - return this.tree; - } + private void setTree(final CraftingTreeNode tree) { + this.tree = tree; + } - private void setTree( final CraftingTreeNode tree ) - { - this.tree = tree; - } + private void logCraftingJob(String type, Stopwatch timer) { + if (AELog.isCraftingLogEnabled()) { + final String itemToOutput = this.output.toString(); + final long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS); + final String actionSource; - private void logCraftingJob( String type, Stopwatch timer ) - { - if( AELog.isCraftingLogEnabled() ) - { - final String itemToOutput = this.output.toString(); - final long elapsedTime = timer.elapsed( TimeUnit.MILLISECONDS ); - final String actionSource; + if (this.actionSrc.player().isPresent()) { + final PlayerEntity player = this.actionSrc.player().get(); - if( this.actionSrc.player().isPresent() ) - { - final PlayerEntity player = this.actionSrc.player().get(); + actionSource = player.toString(); + } else if (this.actionSrc.machine().isPresent()) { + final IActionHost machineSource = this.actionSrc.machine().get(); + final IGridNode actionableNode = machineSource.getActionableNode(); + final IGridHost machine = actionableNode.getMachine(); + final DimensionalCoord location = actionableNode.getGridBlock().getLocation(); - actionSource = player.toString(); - } - else if( this.actionSrc.machine().isPresent() ) - { - final IActionHost machineSource = this.actionSrc.machine().get(); - final IGridNode actionableNode = machineSource.getActionableNode(); - final IGridHost machine = actionableNode.getMachine(); - final DimensionalCoord location = actionableNode.getGridBlock().getLocation(); + actionSource = String.format(LOG_MACHINE_SOURCE_DETAILS, machine, location); + } else { + actionSource = "[unknown source]"; + } - actionSource = String.format( LOG_MACHINE_SOURCE_DETAILS, machine, location ); - } - else - { - actionSource = "[unknown source]"; - } + AELog.crafting(LOG_CRAFTING_JOB, type, actionSource, itemToOutput, this.bytes, elapsedTime); + } + } - AELog.crafting( LOG_CRAFTING_JOB, type, actionSource, itemToOutput, this.bytes, elapsedTime ); - } - } - - private static class TwoIntegers - { - private final long perOp = 0; - private final long times = 0; - } + private static class TwoIntegers { + private final long perOp = 0; + private final long times = 0; + } } diff --git a/src/main/java/appeng/crafting/CraftingLink.java b/src/main/java/appeng/crafting/CraftingLink.java index 5810364b3..d19df4950 100644 --- a/src/main/java/appeng/crafting/CraftingLink.java +++ b/src/main/java/appeng/crafting/CraftingLink.java @@ -18,7 +18,6 @@ package appeng.crafting; - import net.minecraft.nbt.CompoundNBT; import appeng.api.config.Actionable; @@ -27,189 +26,157 @@ import appeng.api.networking.crafting.ICraftingLink; import appeng.api.networking.crafting.ICraftingRequester; import appeng.api.storage.data.IAEItemStack; +public class CraftingLink implements ICraftingLink { -public class CraftingLink implements ICraftingLink -{ + private final ICraftingRequester req; + private final ICraftingCPU cpu; + private final String CraftID; + private final boolean standalone; + private boolean canceled = false; + private boolean done = false; + private CraftingLinkNexus tie; - private final ICraftingRequester req; - private final ICraftingCPU cpu; - private final String CraftID; - private final boolean standalone; - private boolean canceled = false; - private boolean done = false; - private CraftingLinkNexus tie; + public CraftingLink(final CompoundNBT data, final ICraftingRequester req) { + this.CraftID = data.getString("CraftID"); + this.setCanceled(data.getBoolean("canceled")); + this.setDone(data.getBoolean("done")); + this.standalone = data.getBoolean("standalone"); - public CraftingLink( final CompoundNBT data, final ICraftingRequester req ) - { - this.CraftID = data.getString( "CraftID" ); - this.setCanceled( data.getBoolean( "canceled" ) ); - this.setDone( data.getBoolean( "done" ) ); - this.standalone = data.getBoolean( "standalone" ); + if (!data.contains("req") || !data.getBoolean("req")) { + throw new IllegalStateException("Invalid Crafting Link for Object"); + } - if( !data.contains( "req" ) || !data.getBoolean( "req" ) ) - { - throw new IllegalStateException( "Invalid Crafting Link for Object" ); - } + this.req = req; + this.cpu = null; + } - this.req = req; - this.cpu = null; - } + public CraftingLink(final CompoundNBT data, final ICraftingCPU cpu) { + this.CraftID = data.getString("CraftID"); + this.setCanceled(data.getBoolean("canceled")); + this.setDone(data.getBoolean("done")); + this.standalone = data.getBoolean("standalone"); - public CraftingLink( final CompoundNBT data, final ICraftingCPU cpu ) - { - this.CraftID = data.getString( "CraftID" ); - this.setCanceled( data.getBoolean( "canceled" ) ); - this.setDone( data.getBoolean( "done" ) ); - this.standalone = data.getBoolean( "standalone" ); + if (!data.contains("req") || data.getBoolean("req")) { + throw new IllegalStateException("Invalid Crafting Link for Object"); + } - if( !data.contains( "req" ) || data.getBoolean( "req" ) ) - { - throw new IllegalStateException( "Invalid Crafting Link for Object" ); - } + this.cpu = cpu; + this.req = null; + } - this.cpu = cpu; - this.req = null; - } + @Override + public boolean isCanceled() { + if (this.canceled) { + return true; + } - @Override - public boolean isCanceled() - { - if( this.canceled ) - { - return true; - } + if (this.done) { + return false; + } - if( this.done ) - { - return false; - } + if (this.tie == null) { + return false; + } - if( this.tie == null ) - { - return false; - } + return this.tie.isCanceled(); + } - return this.tie.isCanceled(); - } + @Override + public boolean isDone() { + if (this.done) { + return true; + } - @Override - public boolean isDone() - { - if( this.done ) - { - return true; - } + if (this.canceled) { + return false; + } - if( this.canceled ) - { - return false; - } + if (this.tie == null) { + return false; + } - if( this.tie == null ) - { - return false; - } + return this.tie.isDone(); + } - return this.tie.isDone(); - } + @Override + public void cancel() { + if (this.done) { + return; + } - @Override - public void cancel() - { - if( this.done ) - { - return; - } + this.setCanceled(true); - this.setCanceled( true ); + if (this.tie != null) { + this.tie.cancel(); + } - if( this.tie != null ) - { - this.tie.cancel(); - } + this.tie = null; + } - this.tie = null; - } + @Override + public boolean isStandalone() { + return this.standalone; + } - @Override - public boolean isStandalone() - { - return this.standalone; - } + @Override + public void writeToNBT(final CompoundNBT tag) { + tag.putString("CraftID", this.CraftID); + tag.putBoolean("canceled", this.isCanceled()); + tag.putBoolean("done", this.isDone()); + tag.putBoolean("standalone", this.standalone); + tag.putBoolean("req", this.getRequester() != null); + } - @Override - public void writeToNBT( final CompoundNBT tag ) - { - tag.putString( "CraftID", this.CraftID ); - tag.putBoolean( "canceled", this.isCanceled() ); - tag.putBoolean( "done", this.isDone() ); - tag.putBoolean( "standalone", this.standalone ); - tag.putBoolean( "req", this.getRequester() != null ); - } + @Override + public String getCraftingID() { + return this.CraftID; + } - @Override - public String getCraftingID() - { - return this.CraftID; - } + public void setNexus(final CraftingLinkNexus n) { + if (this.tie != null) { + this.tie.remove(this); + } - public void setNexus( final CraftingLinkNexus n ) - { - if( this.tie != null ) - { - this.tie.remove( this ); - } + if (this.isCanceled() && n != null) { + n.cancel(); + this.tie = null; + return; + } - if( this.isCanceled() && n != null ) - { - n.cancel(); - this.tie = null; - return; - } + this.tie = n; - this.tie = n; + if (n != null) { + n.add(this); + } + } - if( n != null ) - { - n.add( this ); - } - } + public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode) { + if (this.tie == null || this.tie.getRequest() == null || this.tie.getRequest().getRequester() == null) { + return input; + } - public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode ) - { - if( this.tie == null || this.tie.getRequest() == null || this.tie.getRequest().getRequester() == null ) - { - return input; - } + return this.tie.getRequest().getRequester().injectCraftedItems(this.tie.getRequest(), input, mode); + } - return this.tie.getRequest().getRequester().injectCraftedItems( this.tie.getRequest(), input, mode ); - } + public void markDone() { + if (this.tie != null) { + this.tie.markDone(); + } + } - public void markDone() - { - if( this.tie != null ) - { - this.tie.markDone(); - } - } + void setCanceled(final boolean canceled) { + this.canceled = canceled; + } - void setCanceled( final boolean canceled ) - { - this.canceled = canceled; - } + ICraftingRequester getRequester() { + return this.req; + } - ICraftingRequester getRequester() - { - return this.req; - } + ICraftingCPU getCpu() { + return this.cpu; + } - ICraftingCPU getCpu() - { - return this.cpu; - } - - void setDone( final boolean done ) - { - this.done = done; - } + void setDone(final boolean done) { + this.done = done; + } } diff --git a/src/main/java/appeng/crafting/CraftingLinkNexus.java b/src/main/java/appeng/crafting/CraftingLinkNexus.java index 1f8eb8a7e..604d65a72 100644 --- a/src/main/java/appeng/crafting/CraftingLinkNexus.java +++ b/src/main/java/appeng/crafting/CraftingLinkNexus.java @@ -18,157 +18,121 @@ package appeng.crafting; - import appeng.api.networking.IGrid; import appeng.api.networking.IGridHost; import appeng.me.cache.CraftingGridCache; +public class CraftingLinkNexus { -public class CraftingLinkNexus -{ + private final String craftID; + private boolean canceled = false; + private boolean done = false; + private int tickOfDeath = 0; + private CraftingLink req; + private CraftingLink cpu; - private final String craftID; - private boolean canceled = false; - private boolean done = false; - private int tickOfDeath = 0; - private CraftingLink req; - private CraftingLink cpu; + public CraftingLinkNexus(final String craftID) { + this.craftID = craftID; + } - public CraftingLinkNexus( final String craftID ) - { - this.craftID = craftID; - } + public boolean isDead(final IGrid g, final CraftingGridCache craftingGridCache) { + if (this.canceled || this.done) { + return true; + } - public boolean isDead( final IGrid g, final CraftingGridCache craftingGridCache ) - { - if( this.canceled || this.done ) - { - return true; - } + if (this.getRequest() == null || this.cpu == null) { + this.tickOfDeath++; + } else { + final boolean hasCpu = craftingGridCache.hasCpu(this.cpu.getCpu()); + final boolean hasMachine = this.getRequest().getRequester().getActionableNode().getGrid() == g; - if( this.getRequest() == null || this.cpu == null ) - { - this.tickOfDeath++; - } - else - { - final boolean hasCpu = craftingGridCache.hasCpu( this.cpu.getCpu() ); - final boolean hasMachine = this.getRequest().getRequester().getActionableNode().getGrid() == g; + if (hasCpu && hasMachine) { + this.tickOfDeath = 0; + } else { + this.tickOfDeath += 60; + } + } - if( hasCpu && hasMachine ) - { - this.tickOfDeath = 0; - } - else - { - this.tickOfDeath += 60; - } - } + if (this.tickOfDeath > 60) { + this.cancel(); + return true; + } - if( this.tickOfDeath > 60 ) - { - this.cancel(); - return true; - } + return false; + } - return false; - } + void cancel() { + this.canceled = true; - void cancel() - { - this.canceled = true; + if (this.getRequest() != null) { + this.getRequest().setCanceled(true); + if (this.getRequest().getRequester() != null) { + this.getRequest().getRequester().jobStateChange(this.getRequest()); + } + } - if( this.getRequest() != null ) - { - this.getRequest().setCanceled( true ); - if( this.getRequest().getRequester() != null ) - { - this.getRequest().getRequester().jobStateChange( this.getRequest() ); - } - } + if (this.cpu != null) { + this.cpu.setCanceled(true); + } + } - if( this.cpu != null ) - { - this.cpu.setCanceled( true ); - } - } + void remove(final CraftingLink craftingLink) { + if (this.getRequest() == craftingLink) { + this.setRequest(null); + } else if (this.cpu == craftingLink) { + this.cpu = null; + } + } - void remove( final CraftingLink craftingLink ) - { - if( this.getRequest() == craftingLink ) - { - this.setRequest( null ); - } - else if( this.cpu == craftingLink ) - { - this.cpu = null; - } - } + void add(final CraftingLink craftingLink) { + if (craftingLink.getCpu() != null) { + this.cpu = craftingLink; + } else if (craftingLink.getRequester() != null) { + this.setRequest(craftingLink); + } + } - void add( final CraftingLink craftingLink ) - { - if( craftingLink.getCpu() != null ) - { - this.cpu = craftingLink; - } - else if( craftingLink.getRequester() != null ) - { - this.setRequest( craftingLink ); - } - } + boolean isCanceled() { + return this.canceled; + } - boolean isCanceled() - { - return this.canceled; - } + boolean isDone() { + return this.done; + } - boolean isDone() - { - return this.done; - } + void markDone() { + this.done = true; - void markDone() - { - this.done = true; + if (this.getRequest() != null) { + this.getRequest().setDone(true); + if (this.getRequest().getRequester() != null) { + this.getRequest().getRequester().jobStateChange(this.getRequest()); + } + } - if( this.getRequest() != null ) - { - this.getRequest().setDone( true ); - if( this.getRequest().getRequester() != null ) - { - this.getRequest().getRequester().jobStateChange( this.getRequest() ); - } - } + if (this.cpu != null) { + this.cpu.setDone(true); + } + } - if( this.cpu != null ) - { - this.cpu.setDone( true ); - } - } + public boolean isMachine(final IGridHost machine) { + return this.getRequest() == machine; + } - public boolean isMachine( final IGridHost machine ) - { - return this.getRequest() == machine; - } + public void removeNode() { + if (this.getRequest() != null) { + this.getRequest().setNexus(null); + } - public void removeNode() - { - if( this.getRequest() != null ) - { - this.getRequest().setNexus( null ); - } + this.setRequest(null); + this.tickOfDeath = 0; + } - this.setRequest( null ); - this.tickOfDeath = 0; - } + public CraftingLink getRequest() { + return this.req; + } - public CraftingLink getRequest() - { - return this.req; - } - - public void setRequest( final CraftingLink req ) - { - this.req = req; - } + public void setRequest(final CraftingLink req) { + this.req = req; + } } diff --git a/src/main/java/appeng/crafting/CraftingTreeNode.java b/src/main/java/appeng/crafting/CraftingTreeNode.java index f62391378..03c22dfa7 100644 --- a/src/main/java/appeng/crafting/CraftingTreeNode.java +++ b/src/main/java/appeng/crafting/CraftingTreeNode.java @@ -18,7 +18,6 @@ package appeng.crafting; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -38,370 +37,309 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.me.cluster.implementations.CraftingCPUCluster; +public class CraftingTreeNode { -public class CraftingTreeNode -{ + // what slot! + private final int slot; + private final CraftingJob job; + private final IItemList used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + // parent node. + private final CraftingTreeProcess parent; + private final World world; + // what item is this? + private final IAEItemStack what; + // what are the crafting patterns for this? + private final ArrayList nodes = new ArrayList<>(); + private int bytes = 0; + private boolean canEmit = false; + private long missing = 0; + private long howManyEmitted = 0; + private boolean exhausted = false; - // what slot! - private final int slot; - private final CraftingJob job; - private final IItemList used = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - // parent node. - private final CraftingTreeProcess parent; - private final World world; - // what item is this? - private final IAEItemStack what; - // what are the crafting patterns for this? - private final ArrayList nodes = new ArrayList<>(); - private int bytes = 0; - private boolean canEmit = false; - private long missing = 0; - private long howManyEmitted = 0; - private boolean exhausted = false; + private boolean sim; - private boolean sim; + public CraftingTreeNode(final ICraftingGrid cc, final CraftingJob job, final IAEItemStack wat, + final CraftingTreeProcess par, final int slot, final int depth) { + this.what = wat; + this.parent = par; + this.slot = slot; + this.world = job.getWorld(); + this.job = job; + this.sim = false; - public CraftingTreeNode( final ICraftingGrid cc, final CraftingJob job, final IAEItemStack wat, final CraftingTreeProcess par, final int slot, final int depth ) - { - this.what = wat; - this.parent = par; - this.slot = slot; - this.world = job.getWorld(); - this.job = job; - this.sim = false; + this.canEmit = cc.canEmitFor(this.what); - this.canEmit = cc.canEmitFor( this.what ); + if (this.canEmit) { + return; // if you can emit for something, you can't make it with patterns. + } - if( this.canEmit ) - { - return; // if you can emit for something, you can't make it with patterns. - } + for (final ICraftingPatternDetails details : cc.getCraftingFor(this.what, + this.parent == null ? null : this.parent.details, slot, this.world))// in + // order. + { + if (this.parent == null || this.parent.notRecursive(details)) { + this.nodes.add(new CraftingTreeProcess(cc, job, details, this, depth + 1)); + } + } + } - for( final ICraftingPatternDetails details : cc.getCraftingFor( this.what, this.parent == null ? null : this.parent.details, slot, this.world ) )// in - // order. - { - if( this.parent == null || this.parent.notRecursive( details ) ) - { - this.nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1 ) ); - } - } - } + boolean notRecursive(final ICraftingPatternDetails details) { + IAEItemStack[] o = details.getCondensedOutputs(); - boolean notRecursive( final ICraftingPatternDetails details ) - { - IAEItemStack[] o = details.getCondensedOutputs(); + for (final IAEItemStack i : o) { + if (i.equals(this.what)) { + return false; + } + } - for( final IAEItemStack i : o ) - { - if( i.equals( this.what ) ) - { - return false; - } - } + o = details.getCondensedInputs(); - o = details.getCondensedInputs(); + for (final IAEItemStack i : o) { + if (i.equals(this.what)) { + return false; + } + } - for( final IAEItemStack i : o ) - { - if( i.equals( this.what ) ) - { - return false; - } - } + if (this.parent == null) { + return true; + } - if( this.parent == null ) - { - return true; - } + return this.parent.notRecursive(details); + } - return this.parent.notRecursive( details ); - } + IAEItemStack request(final MECraftingInventory inv, long l, final IActionSource src) + throws CraftBranchFailure, InterruptedException { + this.job.handlePausing(); - IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException - { - this.job.handlePausing(); + final List thingsUsed = new ArrayList<>(); - final List thingsUsed = new ArrayList<>(); + this.what.setStackSize(l); + if (this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable()) { + final Collection itemList; + final IItemList inventoryList = inv.getItemList(); - this.what.setStackSize( l ); - if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() ) - { - final Collection itemList; - final IItemList inventoryList = inv.getItemList(); + if (this.parent.details.canSubstitute()) { + itemList = inventoryList.findFuzzy(this.what, FuzzyMode.IGNORE_ALL); + } else { + itemList = Lists.newArrayList(); - if( this.parent.details.canSubstitute() ) - { - itemList = inventoryList.findFuzzy( this.what, FuzzyMode.IGNORE_ALL ); - } - else - { - itemList = Lists.newArrayList(); + final IAEItemStack item = inventoryList.findPrecise(this.what); - final IAEItemStack item = inventoryList.findPrecise( this.what ); + if (item != null) { + itemList.add(item); + } + } - if( item != null ) - { - itemList.add( item ); - } - } + for (IAEItemStack fuzz : itemList) { + if (this.parent.details.isValidItemForSlot(this.getSlot(), + fuzz.copy().setStackSize(1).createItemStack(), this.world)) { + fuzz = fuzz.copy(); + fuzz.setStackSize(l); - for( IAEItemStack fuzz : itemList ) - { - if( this.parent.details.isValidItemForSlot( this.getSlot(), fuzz.copy().setStackSize( 1 ).createItemStack(), this.world ) ) - { - fuzz = fuzz.copy(); - fuzz.setStackSize( l ); + final IAEItemStack available = inv.extractItems(fuzz, Actionable.MODULATE, src); - final IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src ); + if (available != null) { + if (!this.exhausted) { + final IAEItemStack is = this.job.checkUse(available); - if( available != null ) - { - if( !this.exhausted ) - { - final IAEItemStack is = this.job.checkUse( available ); + if (is != null) { + thingsUsed.add(is.copy()); + this.used.add(is); + } + } - if( is != null ) - { - thingsUsed.add( is.copy() ); - this.used.add( is ); - } - } + this.bytes += available.getStackSize(); + l -= available.getStackSize(); - this.bytes += available.getStackSize(); - l -= available.getStackSize(); + if (l == 0) { + return available; + } + } + } + } + } else { + final IAEItemStack available = inv.extractItems(this.what, Actionable.MODULATE, src); - if( l == 0 ) - { - return available; - } - } - } - } - } - else - { - final IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src ); + if (available != null) { + if (!this.exhausted) { + final IAEItemStack is = this.job.checkUse(available); - if( available != null ) - { - if( !this.exhausted ) - { - final IAEItemStack is = this.job.checkUse( available ); + if (is != null) { + thingsUsed.add(is.copy()); + this.used.add(is); + } + } - if( is != null ) - { - thingsUsed.add( is.copy() ); - this.used.add( is ); - } - } + this.bytes += available.getStackSize(); + l -= available.getStackSize(); - this.bytes += available.getStackSize(); - l -= available.getStackSize(); + if (l == 0) { + return available; + } + } + } - if( l == 0 ) - { - return available; - } - } - } + if (this.canEmit) { + final IAEItemStack wat = this.what.copy(); + wat.setStackSize(l); - if( this.canEmit ) - { - final IAEItemStack wat = this.what.copy(); - wat.setStackSize( l ); + this.howManyEmitted = wat.getStackSize(); + this.bytes += wat.getStackSize(); - this.howManyEmitted = wat.getStackSize(); - this.bytes += wat.getStackSize(); + return wat; + } - return wat; - } + this.exhausted = true; - this.exhausted = true; + if (this.nodes.size() == 1) { + final CraftingTreeProcess pro = this.nodes.get(0); - if( this.nodes.size() == 1 ) - { - final CraftingTreeProcess pro = this.nodes.get( 0 ); + while (pro.possible && l > 0) { + final IAEItemStack madeWhat = pro.getAmountCrafted(this.what); - while( pro.possible && l > 0 ) - { - final IAEItemStack madeWhat = pro.getAmountCrafted( this.what ); + pro.request(inv, pro.getTimes(l, madeWhat.getStackSize()), src); - pro.request( inv, pro.getTimes( l, madeWhat.getStackSize() ), src ); + madeWhat.setStackSize(l); - madeWhat.setStackSize( l ); + final IAEItemStack available = inv.extractItems(madeWhat, Actionable.MODULATE, src); - final IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src ); + if (available != null) { + this.bytes += available.getStackSize(); + l -= available.getStackSize(); - if( available != null ) - { - this.bytes += available.getStackSize(); - l -= available.getStackSize(); + if (l <= 0) { + return available; + } + } else { + pro.possible = false; // ;P + } + } + } else if (this.nodes.size() > 1) { + for (final CraftingTreeProcess pro : this.nodes) { + try { + while (pro.possible && l > 0) { + final MECraftingInventory subInv = new MECraftingInventory(inv, true, true, true); + pro.request(subInv, 1, src); - if( l <= 0 ) - { - return available; - } - } - else - { - pro.possible = false; // ;P - } - } - } - else if( this.nodes.size() > 1 ) - { - for( final CraftingTreeProcess pro : this.nodes ) - { - try - { - while( pro.possible && l > 0 ) - { - final MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true ); - pro.request( subInv, 1, src ); + this.what.setStackSize(l); + final IAEItemStack available = subInv.extractItems(this.what, Actionable.MODULATE, src); - this.what.setStackSize( l ); - final IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src ); + if (available != null) { + if (!subInv.commit(src)) { + throw new CraftBranchFailure(this.what, l); + } - if( available != null ) - { - if( !subInv.commit( src ) ) - { - throw new CraftBranchFailure( this.what, l ); - } + this.bytes += available.getStackSize(); + l -= available.getStackSize(); - this.bytes += available.getStackSize(); - l -= available.getStackSize(); + if (l <= 0) { + return available; + } + } else { + pro.possible = false; // ;P + } + } + } catch (final CraftBranchFailure fail) { + pro.possible = true; + } + } + } - if( l <= 0 ) - { - return available; - } - } - else - { - pro.possible = false; // ;P - } - } - } - catch( final CraftBranchFailure fail ) - { - pro.possible = true; - } - } - } + if (this.sim) { + this.missing += l; + this.bytes += l; + final IAEItemStack rv = this.what.copy(); + rv.setStackSize(l); + return rv; + } - if( this.sim ) - { - this.missing += l; - this.bytes += l; - final IAEItemStack rv = this.what.copy(); - rv.setStackSize( l ); - return rv; - } + for (final IAEItemStack o : thingsUsed) { + this.job.refund(o.copy()); + o.setStackSize(-o.getStackSize()); + this.used.add(o); + } - for( final IAEItemStack o : thingsUsed ) - { - this.job.refund( o.copy() ); - o.setStackSize( -o.getStackSize() ); - this.used.add( o ); - } + throw new CraftBranchFailure(this.what, l); + } - throw new CraftBranchFailure( this.what, l ); - } + void dive(final CraftingJob job) { + if (this.missing > 0) { + job.addMissing(this.getStack(this.missing)); + } + // missing = 0; - void dive( final CraftingJob job ) - { - if( this.missing > 0 ) - { - job.addMissing( this.getStack( this.missing ) ); - } - // missing = 0; + job.addBytes(8 + this.bytes); - job.addBytes( 8 + this.bytes ); + for (final CraftingTreeProcess pro : this.nodes) { + pro.dive(job); + } + } - for( final CraftingTreeProcess pro : this.nodes ) - { - pro.dive( job ); - } - } + IAEItemStack getStack(final long size) { + final IAEItemStack is = this.what.copy(); + is.setStackSize(size); + return is; + } - IAEItemStack getStack( final long size ) - { - final IAEItemStack is = this.what.copy(); - is.setStackSize( size ); - return is; - } + void setSimulate() { + this.sim = true; + this.missing = 0; + this.bytes = 0; + this.used.resetStatus(); + this.exhausted = false; - void setSimulate() - { - this.sim = true; - this.missing = 0; - this.bytes = 0; - this.used.resetStatus(); - this.exhausted = false; + for (final CraftingTreeProcess pro : this.nodes) { + pro.setSimulate(); + } + } - for( final CraftingTreeProcess pro : this.nodes ) - { - pro.setSimulate(); - } - } + public void setJob(final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, + final IActionSource src) throws CraftBranchFailure { + for (final IAEItemStack i : this.used) { + final IAEItemStack ex = storage.extractItems(i, Actionable.MODULATE, src); - public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure - { - for( final IAEItemStack i : this.used ) - { - final IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src ); + if (ex == null || ex.getStackSize() != i.getStackSize()) { + throw new CraftBranchFailure(i, i.getStackSize()); + } - if( ex == null || ex.getStackSize() != i.getStackSize() ) - { - throw new CraftBranchFailure( i, i.getStackSize() ); - } + craftingCPUCluster.addStorage(ex); + } - craftingCPUCluster.addStorage( ex ); - } + if (this.howManyEmitted > 0) { + final IAEItemStack i = this.what.copy().reset(); + i.setStackSize(this.howManyEmitted); + craftingCPUCluster.addEmitable(i); + } - if( this.howManyEmitted > 0 ) - { - final IAEItemStack i = this.what.copy().reset(); - i.setStackSize( this.howManyEmitted ); - craftingCPUCluster.addEmitable( i ); - } + for (final CraftingTreeProcess pro : this.nodes) { + pro.setJob(storage, craftingCPUCluster, src); + } + } - for( final CraftingTreeProcess pro : this.nodes ) - { - pro.setJob( storage, craftingCPUCluster, src ); - } - } + void getPlan(final IItemList plan) { + if (this.missing > 0) { + final IAEItemStack o = this.what.copy(); + o.setStackSize(this.missing); + plan.add(o); + } - void getPlan( final IItemList plan ) - { - if( this.missing > 0 ) - { - final IAEItemStack o = this.what.copy(); - o.setStackSize( this.missing ); - plan.add( o ); - } + if (this.howManyEmitted > 0) { + final IAEItemStack i = this.what.copy(); + i.setCountRequestable(this.howManyEmitted); + plan.addRequestable(i); + } - if( this.howManyEmitted > 0 ) - { - final IAEItemStack i = this.what.copy(); - i.setCountRequestable( this.howManyEmitted ); - plan.addRequestable( i ); - } + for (final IAEItemStack i : this.used) { + plan.add(i.copy()); + } - for( final IAEItemStack i : this.used ) - { - plan.add( i.copy() ); - } + for (final CraftingTreeProcess pro : this.nodes) { + pro.getPlan(plan); + } + } - for( final CraftingTreeProcess pro : this.nodes ) - { - pro.getPlan( plan ); - } - } - - int getSlot() - { - return this.slot; - } + int getSlot() { + return this.slot; + } } diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index 704f27e9f..4033f009c 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -18,7 +18,6 @@ package appeng.crafting; - import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -41,285 +40,241 @@ import appeng.container.ContainerNull; import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.util.Platform; +public class CraftingTreeProcess { -public class CraftingTreeProcess -{ + private final CraftingTreeNode parent; + final ICraftingPatternDetails details; + private final CraftingJob job; + private final Map nodes = new HashMap<>(); + private final int depth; + boolean possible = true; + private World world; + private long crafts = 0; + private boolean containerItems; + private boolean limitQty; + private boolean fullSimulation; + private long bytes = 0; - private final CraftingTreeNode parent; - final ICraftingPatternDetails details; - private final CraftingJob job; - private final Map nodes = new HashMap<>(); - private final int depth; - boolean possible = true; - private World world; - private long crafts = 0; - private boolean containerItems; - private boolean limitQty; - private boolean fullSimulation; - private long bytes = 0; + public CraftingTreeProcess(final ICraftingGrid cc, final CraftingJob job, final ICraftingPatternDetails details, + final CraftingTreeNode craftingTreeNode, final int depth) { + this.parent = craftingTreeNode; + this.details = details; + this.job = job; + this.depth = depth; + final World world = job.getWorld(); - public CraftingTreeProcess( final ICraftingGrid cc, final CraftingJob job, final ICraftingPatternDetails details, final CraftingTreeNode craftingTreeNode, final int depth ) - { - this.parent = craftingTreeNode; - this.details = details; - this.job = job; - this.depth = depth; - final World world = job.getWorld(); + if (details.isCraftable()) { + final IAEItemStack[] list = details.getInputs(); - if( details.isCraftable() ) - { - final IAEItemStack[] list = details.getInputs(); + final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); + final IAEItemStack[] is = details.getInputs(); + for (int x = 0; x < ic.getSizeInventory(); x++) { + ic.setInventorySlotContents(x, is[x] == null ? ItemStack.EMPTY : is[x].createItemStack()); + } - final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 ); - final IAEItemStack[] is = details.getInputs(); - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - ic.setInventorySlotContents( x, is[x] == null ? ItemStack.EMPTY : is[x].createItemStack() ); - } + BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) world), + details.getOutput(ic, world), ic); - BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) world ), details.getOutput( ic, world ), ic ); + for (int x = 0; x < ic.getSizeInventory(); x++) { + final ItemStack g = ic.getStackInSlot(x); + if (!g.isEmpty() && g.getCount() > 1) { + this.fullSimulation = true; + } + } - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - final ItemStack g = ic.getStackInSlot( x ); - if( !g.isEmpty() && g.getCount() > 1 ) - { - this.fullSimulation = true; - } - } + for (final IAEItemStack part : details.getCondensedInputs()) { + final ItemStack g = part.createItemStack(); - for( final IAEItemStack part : details.getCondensedInputs() ) - { - final ItemStack g = part.createItemStack(); + boolean isAnInput = false; + for (final IAEItemStack a : details.getCondensedOutputs()) { + if (!g.isEmpty() && a != null && a.equals(g)) { + isAnInput = true; + } + } - boolean isAnInput = false; - for( final IAEItemStack a : details.getCondensedOutputs() ) - { - if( !g.isEmpty() && a != null && a.equals( g ) ) - { - isAnInput = true; - } - } + if (isAnInput) { + this.limitQty = true; + } - if( isAnInput ) - { - this.limitQty = true; - } + if (g.getItem().hasContainerItem(g)) { + this.limitQty = this.containerItems = true; + } + } - if( g.getItem().hasContainerItem( g ) ) - { - this.limitQty = this.containerItems = true; - } - } + final boolean complicated = false; - final boolean complicated = false; + if (this.containerItems || complicated) { + for (int x = 0; x < list.length; x++) { + final IAEItemStack part = list[x]; + if (part != null) { + this.nodes.put(new CraftingTreeNode(cc, job, part.copy(), this, x, depth + 1), + part.getStackSize()); + } + } + } else { + // this is minor different then below, this slot uses the pattern, but kinda + // fudges it. + for (final IAEItemStack part : details.getCondensedInputs()) { + for (int x = 0; x < list.length; x++) { + final IAEItemStack comparePart = list[x]; + if (part != null && part.equals(comparePart)) { + // use the first slot... + this.nodes.put(new CraftingTreeNode(cc, job, part.copy(), this, x, depth + 1), + part.getStackSize()); + break; + } + } + } + } + } else { + for (final IAEItemStack part : details.getCondensedInputs()) { + final ItemStack g = part.createItemStack(); - if( this.containerItems || complicated ) - { - for( int x = 0; x < list.length; x++ ) - { - final IAEItemStack part = list[x]; - if( part != null ) - { - this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() ); - } - } - } - else - { - // this is minor different then below, this slot uses the pattern, but kinda fudges it. - for( final IAEItemStack part : details.getCondensedInputs() ) - { - for( int x = 0; x < list.length; x++ ) - { - final IAEItemStack comparePart = list[x]; - if( part != null && part.equals( comparePart ) ) - { - // use the first slot... - this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() ); - break; - } - } - } - } - } - else - { - for( final IAEItemStack part : details.getCondensedInputs() ) - { - final ItemStack g = part.createItemStack(); + boolean isAnInput = false; + for (final IAEItemStack a : details.getCondensedOutputs()) { + if (!g.isEmpty() && a != null && a.equals(g)) { + isAnInput = true; + } + } - boolean isAnInput = false; - for( final IAEItemStack a : details.getCondensedOutputs() ) - { - if( !g.isEmpty() && a != null && a.equals( g ) ) - { - isAnInput = true; - } - } + if (isAnInput) { + this.limitQty = true; + } + } - if( isAnInput ) - { - this.limitQty = true; - } - } + for (final IAEItemStack part : details.getCondensedInputs()) { + this.nodes.put(new CraftingTreeNode(cc, job, part.copy(), this, -1, depth + 1), part.getStackSize()); + } + } + } - for( final IAEItemStack part : details.getCondensedInputs() ) - { - this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, -1, depth + 1 ), part.getStackSize() ); - } - } - } + boolean notRecursive(final ICraftingPatternDetails details) { + return this.parent == null || this.parent.notRecursive(details); + } - boolean notRecursive( final ICraftingPatternDetails details ) - { - return this.parent == null || this.parent.notRecursive( details ); - } + long getTimes(final long remaining, final long stackSize) { + if (this.limitQty || this.fullSimulation) { + return 1; + } + return (remaining / stackSize) + (remaining % stackSize != 0 ? 1 : 0); + } - long getTimes( final long remaining, final long stackSize ) - { - if( this.limitQty || this.fullSimulation ) - { - return 1; - } - return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 ); - } + void request(final MECraftingInventory inv, final long i, final IActionSource src) + throws CraftBranchFailure, InterruptedException { + this.job.handlePausing(); - void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException - { - this.job.handlePausing(); + if (this.fullSimulation) { + final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3); - if( this.fullSimulation ) - { - final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 ); + for (final Entry entry : this.nodes.entrySet()) { + final IAEItemStack item = entry.getKey().getStack(entry.getValue()); + final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize(), src); - for( final Entry entry : this.nodes.entrySet() ) - { - final IAEItemStack item = entry.getKey().getStack( entry.getValue() ); - final IAEItemStack stack = entry.getKey().request( inv, item.getStackSize(), src ); + ic.setInventorySlotContents(entry.getKey().getSlot(), stack.createItemStack()); + } - ic.setInventorySlotContents( entry.getKey().getSlot(), stack.createItemStack() ); - } + BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) this.world), + this.details.getOutput(ic, this.world), ic); - BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) this.world ), this.details.getOutput( ic, this.world ), ic ); + for (int x = 0; x < ic.getSizeInventory(); x++) { + ItemStack is = ic.getStackInSlot(x); + is = Platform.getContainerItem(is); - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - ItemStack is = ic.getStackInSlot( x ); - is = Platform.getContainerItem( is ); + final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(is); + if (o != null) { + this.bytes++; + inv.injectItems(o, Actionable.MODULATE, src); + } + } + } else { + // request and remove inputs... + for (final Entry entry : this.nodes.entrySet()) { + final IAEItemStack item = entry.getKey().getStack(entry.getValue()); + final IAEItemStack stack = entry.getKey().request(inv, item.getStackSize() * i, src); - final IAEItemStack o = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( is ); - if( o != null ) - { - this.bytes++; - inv.injectItems( o, Actionable.MODULATE, src ); - } - } - } - else - { - // request and remove inputs... - for( final Entry entry : this.nodes.entrySet() ) - { - final IAEItemStack item = entry.getKey().getStack( entry.getValue() ); - final IAEItemStack stack = entry.getKey().request( inv, item.getStackSize() * i, src ); + if (this.containerItems) { + final ItemStack is = Platform.getContainerItem(stack.createItemStack()); + final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(is); + if (o != null) { + this.bytes++; + inv.injectItems(o, Actionable.MODULATE, src); + } + } + } + } - if( this.containerItems ) - { - final ItemStack is = Platform.getContainerItem( stack.createItemStack() ); - final IAEItemStack o = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( is ); - if( o != null ) - { - this.bytes++; - inv.injectItems( o, Actionable.MODULATE, src ); - } - } - } - } + // assume its possible. - // assume its possible. + // add crafting results.. + for (final IAEItemStack out : this.details.getCondensedOutputs()) { + final IAEItemStack o = out.copy(); + o.setStackSize(o.getStackSize() * i); + inv.injectItems(o, Actionable.MODULATE, src); + } - // add crafting results.. - for( final IAEItemStack out : this.details.getCondensedOutputs() ) - { - final IAEItemStack o = out.copy(); - o.setStackSize( o.getStackSize() * i ); - inv.injectItems( o, Actionable.MODULATE, src ); - } + this.crafts += i; + } - this.crafts += i; - } + void dive(final CraftingJob job) { + job.addTask(this.getAmountCrafted(this.parent.getStack(1)), this.crafts, this.details, this.depth); + for (final CraftingTreeNode pro : this.nodes.keySet()) { + pro.dive(job); + } - void dive( final CraftingJob job ) - { - job.addTask( this.getAmountCrafted( this.parent.getStack( 1 ) ), this.crafts, this.details, this.depth ); - for( final CraftingTreeNode pro : this.nodes.keySet() ) - { - pro.dive( job ); - } + job.addBytes(8 + this.crafts + this.bytes); + } - job.addBytes( 8 + this.crafts + this.bytes ); - } + IAEItemStack getAmountCrafted(IAEItemStack what2) { + for (final IAEItemStack is : this.details.getCondensedOutputs()) { + if (is.equals(what2)) { + what2 = what2.copy(); + what2.setStackSize(is.getStackSize()); + return what2; + } + } - IAEItemStack getAmountCrafted( IAEItemStack what2 ) - { - for( final IAEItemStack is : this.details.getCondensedOutputs() ) - { - if( is.equals( what2 ) ) - { - what2 = what2.copy(); - what2.setStackSize( is.getStackSize() ); - return what2; - } - } + // more fuzzy! + for (final IAEItemStack is : this.details.getCondensedOutputs()) { + if (is.getItem() == what2.getItem() + && (is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage())) { + what2 = is.copy(); + what2.setStackSize(is.getStackSize()); + return what2; + } + } - // more fuzzy! - for( final IAEItemStack is : this.details.getCondensedOutputs() ) - { - if( is.getItem() == what2.getItem() && ( is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage() ) ) - { - what2 = is.copy(); - what2.setStackSize( is.getStackSize() ); - return what2; - } - } + throw new IllegalStateException("Crafting Tree construction failed."); + } - throw new IllegalStateException( "Crafting Tree construction failed." ); - } + void setSimulate() { + this.crafts = 0; + this.bytes = 0; - void setSimulate() - { - this.crafts = 0; - this.bytes = 0; + for (final CraftingTreeNode pro : this.nodes.keySet()) { + pro.setSimulate(); + } + } - for( final CraftingTreeNode pro : this.nodes.keySet() ) - { - pro.setSimulate(); - } - } + void setJob(final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src) + throws CraftBranchFailure { + craftingCPUCluster.addCrafting(this.details, this.crafts); - void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure - { - craftingCPUCluster.addCrafting( this.details, this.crafts ); + for (final CraftingTreeNode pro : this.nodes.keySet()) { + pro.setJob(storage, craftingCPUCluster, src); + } + } - for( final CraftingTreeNode pro : this.nodes.keySet() ) - { - pro.setJob( storage, craftingCPUCluster, src ); - } - } + void getPlan(final IItemList plan) { + for (IAEItemStack i : this.details.getOutputs()) { + i = i.copy(); + i.setCountRequestable(i.getStackSize() * this.crafts); + plan.addRequestable(i); + } - void getPlan( final IItemList plan ) - { - for( IAEItemStack i : this.details.getOutputs() ) - { - i = i.copy(); - i.setCountRequestable( i.getStackSize() * this.crafts ); - plan.addRequestable( i ); - } - - for( final CraftingTreeNode pro : this.nodes.keySet() ) - { - pro.getPlan( plan ); - } - } + for (final CraftingTreeNode pro : this.nodes.keySet()) { + pro.getPlan(plan); + } + } } diff --git a/src/main/java/appeng/crafting/CraftingWatcher.java b/src/main/java/appeng/crafting/CraftingWatcher.java index 45e9ccd03..131041ce6 100644 --- a/src/main/java/appeng/crafting/CraftingWatcher.java +++ b/src/main/java/appeng/crafting/CraftingWatcher.java @@ -18,7 +18,6 @@ package appeng.crafting; - import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -28,54 +27,46 @@ import appeng.api.networking.crafting.ICraftingWatcherHost; import appeng.api.storage.data.IAEStack; import appeng.me.cache.CraftingGridCache; - /** - * Maintain my interests, and a global watch list, they should always be fully synchronized. + * Maintain my interests, and a global watch list, they should always be fully + * synchronized. */ -public class CraftingWatcher implements ICraftingWatcher -{ +public class CraftingWatcher implements ICraftingWatcher { - private final CraftingGridCache gsc; - private final ICraftingWatcherHost host; - private final Set myInterests = new HashSet<>(); + private final CraftingGridCache gsc; + private final ICraftingWatcherHost host; + private final Set myInterests = new HashSet<>(); - public CraftingWatcher( final CraftingGridCache cache, final ICraftingWatcherHost host ) - { - this.gsc = cache; - this.host = host; - } + public CraftingWatcher(final CraftingGridCache cache, final ICraftingWatcherHost host) { + this.gsc = cache; + this.host = host; + } - public ICraftingWatcherHost getHost() - { - return this.host; - } + public ICraftingWatcherHost getHost() { + return this.host; + } - @Override - public boolean add( final IAEStack e ) - { - if( this.myInterests.contains( e ) ) - { - return false; - } + @Override + public boolean add(final IAEStack e) { + if (this.myInterests.contains(e)) { + return false; + } - return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this ); - } + return this.myInterests.add(e.copy()) && this.gsc.getInterestManager().put(e, this); + } - @Override - public boolean remove( final IAEStack o ) - { - return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( o, this ); - } + @Override + public boolean remove(final IAEStack o) { + return this.myInterests.remove(o) && this.gsc.getInterestManager().remove(o, this); + } - @Override - public void reset() - { - final Iterator i = this.myInterests.iterator(); + @Override + public void reset() { + final Iterator i = this.myInterests.iterator(); - while( i.hasNext() ) - { - this.gsc.getInterestManager().remove( i.next(), this ); - i.remove(); - } - } + while (i.hasNext()) { + this.gsc.getInterestManager().remove(i.next(), this); + i.remove(); + } + } } diff --git a/src/main/java/appeng/crafting/MECraftingInventory.java b/src/main/java/appeng/crafting/MECraftingInventory.java index 06c83c038..87fe9db16 100644 --- a/src/main/java/appeng/crafting/MECraftingInventory.java +++ b/src/main/java/appeng/crafting/MECraftingInventory.java @@ -18,7 +18,6 @@ package appeng.crafting; - import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.networking.security.IActionSource; @@ -30,326 +29,266 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.util.inv.ItemListIgnoreCrafting; +public class MECraftingInventory implements IMEInventory { -public class MECraftingInventory implements IMEInventory -{ + private final MECraftingInventory par; - private final MECraftingInventory par; + private final IMEInventory target; + private final IItemList localCache; - private final IMEInventory target; - private final IItemList localCache; + private final boolean logExtracted; + private final IItemList extractedCache; - private final boolean logExtracted; - private final IItemList extractedCache; + private final boolean logInjections; + private final IItemList injectedCache; - private final boolean logInjections; - private final IItemList injectedCache; + private final boolean logMissing; + private final IItemList missingCache; - private final boolean logMissing; - private final IItemList missingCache; + public MECraftingInventory() { + this.localCache = new ItemListIgnoreCrafting<>( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + this.extractedCache = null; + this.injectedCache = null; + this.missingCache = null; + this.logExtracted = false; + this.logInjections = false; + this.logMissing = false; + this.target = null; + this.par = null; + } - public MECraftingInventory() - { - this.localCache = new ItemListIgnoreCrafting<>( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - this.extractedCache = null; - this.injectedCache = null; - this.missingCache = null; - this.logExtracted = false; - this.logInjections = false; - this.logMissing = false; - this.target = null; - this.par = null; - } + public MECraftingInventory(final MECraftingInventory parent) { + this.target = parent; + this.logExtracted = parent.logExtracted; + this.logInjections = parent.logInjections; + this.logMissing = parent.logMissing; - public MECraftingInventory( final MECraftingInventory parent ) - { - this.target = parent; - this.logExtracted = parent.logExtracted; - this.logInjections = parent.logInjections; - this.logMissing = parent.logMissing; + if (this.logMissing) { + this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.missingCache = null; + } - if( this.logMissing ) - { - this.missingCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.missingCache = null; - } + if (this.logExtracted) { + this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.extractedCache = null; + } - if( this.logExtracted ) - { - this.extractedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.extractedCache = null; - } + if (this.logInjections) { + this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.injectedCache = null; + } - if( this.logInjections ) - { - this.injectedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.injectedCache = null; - } + this.localCache = this.target.getAvailableItems(new ItemListIgnoreCrafting<>( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList())); - this.localCache = this.target - .getAvailableItems( new ItemListIgnoreCrafting<>( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ) ); + this.par = parent; + } - this.par = parent; - } + public MECraftingInventory(final IMEMonitor target, final IActionSource src, + final boolean logExtracted, final boolean logInjections, final boolean logMissing) { + this.target = target; + this.logExtracted = logExtracted; + this.logInjections = logInjections; + this.logMissing = logMissing; - public MECraftingInventory( final IMEMonitor target, final IActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing ) - { - this.target = target; - this.logExtracted = logExtracted; - this.logInjections = logInjections; - this.logMissing = logMissing; + if (logMissing) { + this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.missingCache = null; + } - if( logMissing ) - { - this.missingCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.missingCache = null; - } + if (logExtracted) { + this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.extractedCache = null; + } - if( logExtracted ) - { - this.extractedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.extractedCache = null; - } + if (logInjections) { + this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.injectedCache = null; + } - if( logInjections ) - { - this.injectedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.injectedCache = null; - } + this.localCache = new ItemListIgnoreCrafting<>( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + for (final IAEItemStack is : target.getStorageList()) { + this.localCache.add(target.extractItems(is, Actionable.SIMULATE, src)); + } - this.localCache = new ItemListIgnoreCrafting<>( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - for( final IAEItemStack is : target.getStorageList() ) - { - this.localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) ); - } + this.par = null; + } - this.par = null; - } + public MECraftingInventory(final IMEInventory target, final boolean logExtracted, + final boolean logInjections, final boolean logMissing) { + this.target = target; + this.logExtracted = logExtracted; + this.logInjections = logInjections; + this.logMissing = logMissing; - public MECraftingInventory( final IMEInventory target, final boolean logExtracted, final boolean logInjections, final boolean logMissing ) - { - this.target = target; - this.logExtracted = logExtracted; - this.logInjections = logInjections; - this.logMissing = logMissing; + if (logMissing) { + this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.missingCache = null; + } - if( logMissing ) - { - this.missingCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.missingCache = null; - } + if (logExtracted) { + this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.extractedCache = null; + } - if( logExtracted ) - { - this.extractedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.extractedCache = null; - } + if (logInjections) { + this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); + } else { + this.injectedCache = null; + } - if( logInjections ) - { - this.injectedCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - } - else - { - this.injectedCache = null; - } + this.localCache = target.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + this.par = null; + } - this.localCache = target.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - this.par = null; - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final IActionSource src) { + if (input == null) { + return null; + } - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src ) - { - if( input == null ) - { - return null; - } + if (mode == Actionable.MODULATE) { + if (this.logInjections) { + this.injectedCache.add(input); + } + this.localCache.add(input); + } - if( mode == Actionable.MODULATE ) - { - if( this.logInjections ) - { - this.injectedCache.add( input ); - } - this.localCache.add( input ); - } + return null; + } - return null; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + if (request == null) { + return null; + } - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - if( request == null ) - { - return null; - } + final IAEItemStack list = this.localCache.findPrecise(request); + if (list == null || list.getStackSize() == 0) { + return null; + } - final IAEItemStack list = this.localCache.findPrecise( request ); - if( list == null || list.getStackSize() == 0 ) - { - return null; - } + if (list.getStackSize() >= request.getStackSize()) { + if (mode == Actionable.MODULATE) { + list.decStackSize(request.getStackSize()); + if (this.logExtracted) { + this.extractedCache.add(request); + } + } - if( list.getStackSize() >= request.getStackSize() ) - { - if( mode == Actionable.MODULATE ) - { - list.decStackSize( request.getStackSize() ); - if( this.logExtracted ) - { - this.extractedCache.add( request ); - } - } + return request; + } - return request; - } + final IAEItemStack ret = request.copy(); + ret.setStackSize(list.getStackSize()); - final IAEItemStack ret = request.copy(); - ret.setStackSize( list.getStackSize() ); + if (mode == Actionable.MODULATE) { + list.reset(); + if (this.logExtracted) { + this.extractedCache.add(ret); + } + } - if( mode == Actionable.MODULATE ) - { - list.reset(); - if( this.logExtracted ) - { - this.extractedCache.add( ret ); - } - } + return ret; + } - return ret; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final IAEItemStack is : this.localCache) { + out.add(is); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final IAEItemStack is : this.localCache ) - { - out.add( is ); - } + return out; + } - return out; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + public IItemList getItemList() { + return this.localCache; + } - public IItemList getItemList() - { - return this.localCache; - } + public boolean commit(final IActionSource src) { + final IItemList added = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + final IItemList pulled = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + boolean failed = false; - public boolean commit( final IActionSource src ) - { - final IItemList added = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - final IItemList pulled = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - boolean failed = false; + if (this.logInjections) { + for (final IAEItemStack inject : this.injectedCache) { + IAEItemStack result = null; + added.add(result = this.target.injectItems(inject, Actionable.MODULATE, src)); - if( this.logInjections ) - { - for( final IAEItemStack inject : this.injectedCache ) - { - IAEItemStack result = null; - added.add( result = this.target.injectItems( inject, Actionable.MODULATE, src ) ); + if (result != null) { + failed = true; + break; + } + } + } - if( result != null ) - { - failed = true; - break; - } - } - } + if (failed) { + for (final IAEItemStack is : added) { + this.target.extractItems(is, Actionable.MODULATE, src); + } - if( failed ) - { - for( final IAEItemStack is : added ) - { - this.target.extractItems( is, Actionable.MODULATE, src ); - } + return false; + } - return false; - } + if (this.logExtracted) { + for (final IAEItemStack extra : this.extractedCache) { + IAEItemStack result = null; + pulled.add(result = this.target.extractItems(extra, Actionable.MODULATE, src)); - if( this.logExtracted ) - { - for( final IAEItemStack extra : this.extractedCache ) - { - IAEItemStack result = null; - pulled.add( result = this.target.extractItems( extra, Actionable.MODULATE, src ) ); + if (result == null || result.getStackSize() != extra.getStackSize()) { + failed = true; + break; + } + } + } - if( result == null || result.getStackSize() != extra.getStackSize() ) - { - failed = true; - break; - } - } - } + if (failed) { + for (final IAEItemStack is : added) { + this.target.extractItems(is, Actionable.MODULATE, src); + } - if( failed ) - { - for( final IAEItemStack is : added ) - { - this.target.extractItems( is, Actionable.MODULATE, src ); - } + for (final IAEItemStack is : pulled) { + this.target.injectItems(is, Actionable.MODULATE, src); + } - for( final IAEItemStack is : pulled ) - { - this.target.injectItems( is, Actionable.MODULATE, src ); - } + return false; + } - return false; - } + if (this.logMissing && this.par != null) { + for (final IAEItemStack extra : this.missingCache) { + this.par.addMissing(extra); + } + } - if( this.logMissing && this.par != null ) - { - for( final IAEItemStack extra : this.missingCache ) - { - this.par.addMissing( extra ); - } - } + return true; + } - return true; - } + private void addMissing(final IAEItemStack extra) { + this.missingCache.add(extra); + } - private void addMissing( final IAEItemStack extra ) - { - this.missingCache.add( extra ); - } - - void ignore( final IAEItemStack what ) - { - final IAEItemStack list = this.localCache.findPrecise( what ); - if( list != null ) - { - list.setStackSize( 0 ); - } - } + void ignore(final IAEItemStack what) { + final IAEItemStack list = this.localCache.findPrecise(what); + if (list != null) { + list.setStackSize(0); + } + } } diff --git a/src/main/java/appeng/debug/BlockChunkloader.java b/src/main/java/appeng/debug/BlockChunkloader.java index 586b1f8be..1a493a620 100644 --- a/src/main/java/appeng/debug/BlockChunkloader.java +++ b/src/main/java/appeng/debug/BlockChunkloader.java @@ -18,11 +18,10 @@ package appeng.debug; - -import appeng.block.AEBaseTileBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import appeng.block.AEBaseTileBlock; public class BlockChunkloader extends AEBaseTileBlock { diff --git a/src/main/java/appeng/debug/BlockCubeGenerator.java b/src/main/java/appeng/debug/BlockCubeGenerator.java index 54ea771c7..46081d3eb 100644 --- a/src/main/java/appeng/debug/BlockCubeGenerator.java +++ b/src/main/java/appeng/debug/BlockCubeGenerator.java @@ -18,7 +18,6 @@ package appeng.debug; - import javax.annotation.Nullable; import net.minecraft.block.Block; @@ -33,25 +32,21 @@ import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; +public class BlockCubeGenerator extends AEBaseTileBlock { -public class BlockCubeGenerator extends AEBaseTileBlock -{ + public BlockCubeGenerator() { + super(defaultProps(Material.IRON)); + } - public BlockCubeGenerator() - { - super(defaultProps(Material.IRON) ); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + final TileCubeGenerator tcg = this.getTileEntity(w, pos); + if (tcg != null) { + tcg.click(player); + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - final TileCubeGenerator tcg = this.getTileEntity( w, pos ); - if( tcg != null ) - { - tcg.click( player ); - } - - return ActionResultType.SUCCESS; - } + return ActionResultType.SUCCESS; + } } diff --git a/src/main/java/appeng/debug/BlockEnergyGenerator.java b/src/main/java/appeng/debug/BlockEnergyGenerator.java index 5ab2c8353..96758bbbd 100644 --- a/src/main/java/appeng/debug/BlockEnergyGenerator.java +++ b/src/main/java/appeng/debug/BlockEnergyGenerator.java @@ -18,19 +18,15 @@ package appeng.debug; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import appeng.block.AEBaseTileBlock; +public class BlockEnergyGenerator extends AEBaseTileBlock { -public class BlockEnergyGenerator extends AEBaseTileBlock -{ - - public BlockEnergyGenerator() - { - super( defaultProps(Material.IRON) ); - } + public BlockEnergyGenerator() { + super(defaultProps(Material.IRON)); + } } diff --git a/src/main/java/appeng/debug/BlockItemGen.java b/src/main/java/appeng/debug/BlockItemGen.java index 0f8ee348a..e8b1ece9d 100644 --- a/src/main/java/appeng/debug/BlockItemGen.java +++ b/src/main/java/appeng/debug/BlockItemGen.java @@ -18,19 +18,15 @@ package appeng.debug; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import appeng.block.AEBaseTileBlock; +public class BlockItemGen extends AEBaseTileBlock { -public class BlockItemGen extends AEBaseTileBlock -{ - - public BlockItemGen() - { - super( defaultProps(Material.IRON) ); - } + public BlockItemGen() { + super(defaultProps(Material.IRON)); + } } diff --git a/src/main/java/appeng/debug/BlockPhantomNode.java b/src/main/java/appeng/debug/BlockPhantomNode.java index 0984295b7..d92bf8548 100644 --- a/src/main/java/appeng/debug/BlockPhantomNode.java +++ b/src/main/java/appeng/debug/BlockPhantomNode.java @@ -18,7 +18,6 @@ package appeng.debug; - import javax.annotation.Nullable; import net.minecraft.block.Block; @@ -33,21 +32,18 @@ import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; +public class BlockPhantomNode extends AEBaseTileBlock { -public class BlockPhantomNode extends AEBaseTileBlock -{ + public BlockPhantomNode() { + super(defaultProps(Material.IRON)); + } - public BlockPhantomNode() - { - super( defaultProps(Material.IRON) ); - } - - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - final TilePhantomNode tpn = this.getTileEntity( w, pos ); - tpn.triggerCrashMode(); - return ActionResultType.SUCCESS; - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + final TilePhantomNode tpn = this.getTileEntity(w, pos); + tpn.triggerCrashMode(); + return ActionResultType.SUCCESS; + } } diff --git a/src/main/java/appeng/debug/TileChunkLoader.java b/src/main/java/appeng/debug/TileChunkLoader.java index 378a6cf61..949ddc547 100644 --- a/src/main/java/appeng/debug/TileChunkLoader.java +++ b/src/main/java/appeng/debug/TileChunkLoader.java @@ -18,15 +18,14 @@ package appeng.debug; - -import appeng.core.AELog; -import appeng.tile.AEBaseTile; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import appeng.core.AELog; +import appeng.tile.AEBaseTile; public class TileChunkLoader extends AEBaseTile implements ITickableTileEntity { @@ -63,7 +62,8 @@ public class TileChunkLoader extends AEBaseTile implements ITickableTileEntity { ServerWorld serverWorld = (ServerWorld) world; if (!serverWorld.getForcedChunks().contains(chunkPos.asLong())) { - AELog.debug("Force-loading chunk @ %d,%d in %s", chunkPos.x, chunkPos.z, serverWorld.dimension.getType().getRegistryName()); + AELog.debug("Force-loading chunk @ %d,%d in %s", chunkPos.x, chunkPos.z, + serverWorld.dimension.getType().getRegistryName()); serverWorld.forceChunk(chunkPos.x, chunkPos.z, false); } } diff --git a/src/main/java/appeng/debug/TileCubeGenerator.java b/src/main/java/appeng/debug/TileCubeGenerator.java index cc492201f..8072250b1 100644 --- a/src/main/java/appeng/debug/TileCubeGenerator.java +++ b/src/main/java/appeng/debug/TileCubeGenerator.java @@ -18,10 +18,6 @@ package appeng.debug; - -import appeng.core.AppEng; -import appeng.tile.AEBaseTile; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.DirectionalPlaceContext; import net.minecraft.item.Item; @@ -33,102 +29,84 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.StringTextComponent; +import appeng.core.AppEng; +import appeng.tile.AEBaseTile; +import appeng.util.Platform; -public class TileCubeGenerator extends AEBaseTile implements ITickableTileEntity -{ +public class TileCubeGenerator extends AEBaseTile implements ITickableTileEntity { - private int size = 3; - private ItemStack is = ItemStack.EMPTY; - private int countdown = 20 * 10; - private PlayerEntity who = null; + private int size = 3; + private ItemStack is = ItemStack.EMPTY; + private int countdown = 20 * 10; + private PlayerEntity who = null; - public TileCubeGenerator(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + public TileCubeGenerator(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - @Override - public void tick() - { - if( !this.is.isEmpty() && Platform.isServer() ) - { - this.countdown--; + @Override + public void tick() { + if (!this.is.isEmpty() && Platform.isServer()) { + this.countdown--; - if( this.countdown % 20 == 0 ) - { - for( final PlayerEntity e : AppEng.proxy.getPlayers() ) - { - e.sendMessage( new StringTextComponent( "Spawning in... " + ( this.countdown / 20 ) ) ); - } - } + if (this.countdown % 20 == 0) { + for (final PlayerEntity e : AppEng.proxy.getPlayers()) { + e.sendMessage(new StringTextComponent("Spawning in... " + (this.countdown / 20))); + } + } - if( this.countdown <= 0 ) - { - this.spawn(); - } - } - } + if (this.countdown <= 0) { + this.spawn(); + } + } + } - private void spawn() - { - this.world.removeBlock(this.pos, false); + private void spawn() { + this.world.removeBlock(this.pos, false); - final Item i = this.is.getItem(); - final Direction side = Direction.UP; + final Item i = this.is.getItem(); + final Direction side = Direction.UP; - final int half = (int) Math.floor( this.size / 2 ); + final int half = (int) Math.floor(this.size / 2); - for( int y = 0; y < this.size; y++ ) - { - for( int x = -half; x < half; x++ ) - { - for( int z = -half; z < half; z++ ) - { - final BlockPos p = this.pos.add( x, y - 1, z ); - ItemUseContext useContext = new DirectionalPlaceContext( - this.world, p, side, this.is, side.getOpposite() - ); - i.onItemUse(useContext); - } - } - } - } + for (int y = 0; y < this.size; y++) { + for (int x = -half; x < half; x++) { + for (int z = -half; z < half; z++) { + final BlockPos p = this.pos.add(x, y - 1, z); + ItemUseContext useContext = new DirectionalPlaceContext(this.world, p, side, this.is, + side.getOpposite()); + i.onItemUse(useContext); + } + } + } + } - void click( final PlayerEntity player ) - { - if( Platform.isServer() ) - { - final ItemStack hand = player.inventory.getCurrentItem(); - this.who = player; + void click(final PlayerEntity player) { + if (Platform.isServer()) { + final ItemStack hand = player.inventory.getCurrentItem(); + this.who = player; - if( hand.isEmpty() ) - { - this.is = ItemStack.EMPTY; + if (hand.isEmpty()) { + this.is = ItemStack.EMPTY; - if( player.isCrouching() ) - { - this.size--; - } - else - { - this.size++; - } + if (player.isCrouching()) { + this.size--; + } else { + this.size++; + } - if( this.size < 3 ) - { - this.size = 3; - } - if( this.size > 64 ) - { - this.size = 64; - } + if (this.size < 3) { + this.size = 3; + } + if (this.size > 64) { + this.size = 64; + } - player.sendMessage( new StringTextComponent( "Size: " + this.size ) ); - } - else - { - this.countdown = 20 * 10; - this.is = hand; - } - } - } + player.sendMessage(new StringTextComponent("Size: " + this.size)); + } else { + this.countdown = 20 * 10; + this.is = hand; + } + } + } } diff --git a/src/main/java/appeng/debug/TileEnergyGenerator.java b/src/main/java/appeng/debug/TileEnergyGenerator.java index 8694195f1..27e98e83f 100644 --- a/src/main/java/appeng/debug/TileEnergyGenerator.java +++ b/src/main/java/appeng/debug/TileEnergyGenerator.java @@ -18,7 +18,6 @@ package appeng.debug; - import java.util.EnumSet; import javax.annotation.Nullable; @@ -38,98 +37,84 @@ import net.minecraftforge.energy.IEnergyStorage; import appeng.tile.AEBaseTile; +public class TileEnergyGenerator extends AEBaseTile implements ITickableTileEntity, IEnergyStorage { + /** + * The base energy injected each tick. Adjacent TileEnergyGenerators will + * increase it to pow(base, #generators). + */ + private static final int BASE_ENERGY = 8; -public class TileEnergyGenerator extends AEBaseTile implements ITickableTileEntity, IEnergyStorage -{ - /** - * The base energy injected each tick. - * Adjacent TileEnergyGenerators will increase it to pow(base, #generators). - */ - private static final int BASE_ENERGY = 8; + public TileEnergyGenerator(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileEnergyGenerator(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void tick() { + World world = this.getWorld(); + if (world == null) { + return; + } - @Override - public void tick() - { - World world = this.getWorld(); - if (world == null) { - return; - } + int tier = 1; + for (Direction facing : Direction.values()) { + final TileEntity te = world.getTileEntity(this.getPos().offset(facing)); - int tier = 1; - for( Direction facing : Direction.values() ) - { - final TileEntity te = world.getTileEntity( this.getPos().offset( facing ) ); + if (te instanceof TileEnergyGenerator) { + tier++; + } + } - if( te instanceof TileEnergyGenerator ) - { - tier++; - } - } + final int energyToInsert = IntMath.pow(BASE_ENERGY, tier); - final int energyToInsert = IntMath.pow( BASE_ENERGY, tier ); + for (Direction facing : Direction.values()) { + final TileEntity te = this.getWorld().getTileEntity(this.getPos().offset(facing)); + final LazyOptional cap = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()); - for( Direction facing : Direction.values() ) - { - final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) ); - final LazyOptional cap = te.getCapability( CapabilityEnergy.ENERGY, facing.getOpposite() ); + cap.ifPresent(consumer -> { + if (consumer.canReceive()) { + consumer.receiveEnergy(energyToInsert, false); + } + }); + } + } - cap.ifPresent(consumer -> { - if (consumer.canReceive()) { - consumer.receiveEnergy( energyToInsert, false ); - } - }); - } - } + @SuppressWarnings("unchecked") + @Override + @Nullable + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + if (capability == CapabilityEnergy.ENERGY) { + return (LazyOptional) LazyOptional.of(() -> this); + } + return super.getCapability(capability, facing); + } - @SuppressWarnings("unchecked") - @Override - @Nullable - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - if( capability == CapabilityEnergy.ENERGY ) - { - return (LazyOptional) LazyOptional.of(() ->this); - } - return super.getCapability( capability, facing ); - } + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + return 0; + } - @Override - public int receiveEnergy( int maxReceive, boolean simulate ) - { - return 0; - } + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return maxExtract; + } - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - return maxExtract; - } + @Override + public int getEnergyStored() { + return Integer.MAX_VALUE; + } - @Override - public int getEnergyStored() - { - return Integer.MAX_VALUE; - } + @Override + public int getMaxEnergyStored() { + return Integer.MAX_VALUE; + } - @Override - public int getMaxEnergyStored() - { - return Integer.MAX_VALUE; - } + @Override + public boolean canExtract() { + return true; + } - @Override - public boolean canExtract() - { - return true; - } - - @Override - public boolean canReceive() - { - return false; - } + @Override + public boolean canReceive() { + return false; + } } diff --git a/src/main/java/appeng/debug/TileItemGen.java b/src/main/java/appeng/debug/TileItemGen.java index b3dc715bd..5064e9dc1 100644 --- a/src/main/java/appeng/debug/TileItemGen.java +++ b/src/main/java/appeng/debug/TileItemGen.java @@ -18,16 +18,15 @@ package appeng.debug; - import java.util.ArrayDeque; import java.util.Queue; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.NonNullList; @@ -36,117 +35,98 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; - -import appeng.tile.AEBaseTile; import net.minecraftforge.registries.ForgeRegistries; +import appeng.tile.AEBaseTile; -public class TileItemGen extends AEBaseTile -{ +public class TileItemGen extends AEBaseTile { - private static final Queue POSSIBLE_ITEMS = new ArrayDeque<>(); + private static final Queue POSSIBLE_ITEMS = new ArrayDeque<>(); - private final IItemHandler handler = new QueuedItemHandler(); + private final IItemHandler handler = new QueuedItemHandler(); - public TileItemGen(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - if( POSSIBLE_ITEMS.isEmpty() ) - { - for( final Item mi : ForgeRegistries.ITEMS) - { - if( mi != null && mi != Items.AIR ) - { - if( mi.isDamageable() ) - { - // FIXME: Rethink if this branch is necessary - for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ ) - { - ItemStack item = new ItemStack(mi, 1); - item.setDamage(dmg); - POSSIBLE_ITEMS.add(item); - } - } - else - { - if (mi.getGroup() == null) { - continue; - } + public TileItemGen(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + if (POSSIBLE_ITEMS.isEmpty()) { + for (final Item mi : ForgeRegistries.ITEMS) { + if (mi != null && mi != Items.AIR) { + if (mi.isDamageable()) { + // FIXME: Rethink if this branch is necessary + for (int dmg = 0; dmg < mi.getMaxDamage(); dmg++) { + ItemStack item = new ItemStack(mi, 1); + item.setDamage(dmg); + POSSIBLE_ITEMS.add(item); + } + } else { + if (mi.getGroup() == null) { + continue; + } - final NonNullList list = NonNullList.create(); - mi.fillItemGroup( mi.getGroup(), list ); - POSSIBLE_ITEMS.addAll( list ); - } - } - } - } - } + final NonNullList list = NonNullList.create(); + mi.fillItemGroup(mi.getGroup(), list); + POSSIBLE_ITEMS.addAll(list); + } + } + } + } + } - @SuppressWarnings("unchecked") - @Override - @Nullable - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - if( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability ) - { - return (LazyOptional) LazyOptional.of(() ->this.handler); - } - return super.getCapability( capability, facing ); - } + @SuppressWarnings("unchecked") + @Override + @Nullable + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + if (CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability) { + return (LazyOptional) LazyOptional.of(() -> this.handler); + } + return super.getCapability(capability, facing); + } - class QueuedItemHandler implements IItemHandler - { + class QueuedItemHandler implements IItemHandler { - @Override - @Nonnull - public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate ) - { - return stack; - } + @Override + @Nonnull + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + return stack; + } - @Override - @Nonnull - public ItemStack getStackInSlot( int slot ) - { - return POSSIBLE_ITEMS.peek() != null ? POSSIBLE_ITEMS.peek().copy() : ItemStack.EMPTY; - } + @Override + @Nonnull + public ItemStack getStackInSlot(int slot) { + return POSSIBLE_ITEMS.peek() != null ? POSSIBLE_ITEMS.peek().copy() : ItemStack.EMPTY; + } - @Override - public boolean isItemValid(int slot, @Nonnull ItemStack stack) { - return false; - } + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return false; + } - @Override - public int getSlots() - { - return 1; - } + @Override + public int getSlots() { + return 1; + } - @Override - public int getSlotLimit( int slot ) - { - return 1; - } + @Override + public int getSlotLimit(int slot) { + return 1; + } - @Override - @Nonnull - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - final ItemStack is = POSSIBLE_ITEMS.peek(); + @Override + @Nonnull + public ItemStack extractItem(int slot, int amount, boolean simulate) { + final ItemStack is = POSSIBLE_ITEMS.peek(); - if( is == null ) - { - return ItemStack.EMPTY; - } + if (is == null) { + return ItemStack.EMPTY; + } - return simulate ? is.copy() : this.getNextItem(); - } + return simulate ? is.copy() : this.getNextItem(); + } - private ItemStack getNextItem() - { - final ItemStack is = POSSIBLE_ITEMS.poll(); + private ItemStack getNextItem() { + final ItemStack is = POSSIBLE_ITEMS.poll(); - POSSIBLE_ITEMS.add( is ); - return is.copy(); - } - }; + POSSIBLE_ITEMS.add(is); + return is.copy(); + } + }; } diff --git a/src/main/java/appeng/debug/TilePhantomNode.java b/src/main/java/appeng/debug/TilePhantomNode.java index e3aaceff8..cef7f5ac9 100644 --- a/src/main/java/appeng/debug/TilePhantomNode.java +++ b/src/main/java/appeng/debug/TilePhantomNode.java @@ -18,7 +18,6 @@ package appeng.debug; - import java.util.EnumSet; import net.minecraft.tileentity.TileEntityType; @@ -29,43 +28,36 @@ import appeng.api.util.AEPartLocation; import appeng.me.helpers.AENetworkProxy; import appeng.tile.grid.AENetworkTile; +public class TilePhantomNode extends AENetworkTile { -public class TilePhantomNode extends AENetworkTile -{ + private AENetworkProxy proxy = null; + private boolean crashMode = false; - private AENetworkProxy proxy = null; - private boolean crashMode = false; + public TilePhantomNode(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TilePhantomNode(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + if (!this.crashMode) { + return super.getGridNode(dir); + } - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - if( !this.crashMode ) - { - return super.getGridNode( dir ); - } + return this.proxy.getNode(); + } - return this.proxy.getNode(); - } + @Override + public void onReady() { + super.onReady(); + this.proxy = this.createProxy(); + this.proxy.onReady(); + this.crashMode = true; + } - @Override - public void onReady() - { - super.onReady(); - this.proxy = this.createProxy(); - this.proxy.onReady(); - this.crashMode = true; - } - - void triggerCrashMode() - { - if( this.proxy != null ) - { - this.crashMode = true; - this.proxy.setValidSides( EnumSet.allOf( Direction.class ) ); - } - } + void triggerCrashMode() { + if (this.proxy != null) { + this.crashMode = true; + this.proxy.setValidSides(EnumSet.allOf(Direction.class)); + } + } } diff --git a/src/main/java/appeng/debug/ToolDebugCard.java b/src/main/java/appeng/debug/ToolDebugCard.java index 95d721a50..7c45cd686 100644 --- a/src/main/java/appeng/debug/ToolDebugCard.java +++ b/src/main/java/appeng/debug/ToolDebugCard.java @@ -18,6 +18,19 @@ package appeng.debug; +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.World; import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridHost; @@ -38,198 +51,150 @@ import appeng.me.cache.TickManagerCache; import appeng.parts.p2p.PartP2PTunnel; import appeng.tile.networking.TileController; import appeng.util.Platform; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.World; -import java.util.HashSet; -import java.util.Set; +public class ToolDebugCard extends AEBaseItem { + public ToolDebugCard(Properties properties) { + super(properties); + } -public class ToolDebugCard extends AEBaseItem -{ + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + if (context.getWorld().isRemote()) { + return ActionResultType.PASS; + } - public ToolDebugCard(Properties properties) { - super(properties); - } + PlayerEntity player = context.getPlayer(); + World world = context.getWorld(); + BlockPos pos = context.getPos(); + Direction side = context.getFace(); - @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - if( context.getWorld().isRemote() ) - { - return ActionResultType.PASS; - } + if (player == null) { + return ActionResultType.PASS; + } - PlayerEntity player = context.getPlayer(); - World world = context.getWorld(); - BlockPos pos = context.getPos(); - Direction side = context.getFace(); + if (player.isCrouching()) { + int grids = 0; + int totalNodes = 0; - if (player == null) { - return ActionResultType.PASS; - } - - if( player.isCrouching() ) - { - int grids = 0; - int totalNodes = 0; + for (final Grid g : TickHandler.INSTANCE.getGridList()) { + grids++; + totalNodes += g.getNodes().size(); + } - for( final Grid g : TickHandler.INSTANCE.getGridList() ) - { - grids++; - totalNodes += g.getNodes().size(); - } + this.outputMsg(player, "Grids: " + grids); + this.outputMsg(player, "Total Nodes: " + totalNodes); + } else { + final TileEntity te = world.getTileEntity(pos); - this.outputMsg( player, "Grids: " + grids ); - this.outputMsg( player, "Total Nodes: " + totalNodes ); - } - else - { - final TileEntity te = world.getTileEntity( pos ); + if (te instanceof IGridHost) { + final GridNode node = (GridNode) ((IGridHost) te).getGridNode(AEPartLocation.fromFacing(side)); + if (node != null) { + final Grid g = node.getInternalGrid(); + final IGridNode center = g.getPivot(); + this.outputMsg(player, "This Node: " + node.toString()); + this.outputMsg(player, "Center Node: " + center.toString()); - if( te instanceof IGridHost ) - { - final GridNode node = (GridNode) ( (IGridHost) te ).getGridNode( AEPartLocation.fromFacing( side ) ); - if( node != null ) - { - final Grid g = node.getInternalGrid(); - final IGridNode center = g.getPivot(); - this.outputMsg( player, "This Node: " + node.toString() ); - this.outputMsg( player, "Center Node: " + center.toString() ); + final IPathingGrid pg = g.getCache(IPathingGrid.class); + if (pg.getControllerState() == ControllerState.CONTROLLER_ONLINE) { - final IPathingGrid pg = g.getCache( IPathingGrid.class ); - if( pg.getControllerState() == ControllerState.CONTROLLER_ONLINE ) - { + Set next = new HashSet<>(); + next.add(node); - Set next = new HashSet<>(); - next.add( node ); + final int maxLength = 10000; - final int maxLength = 10000; + int length = 0; + outer: while (!next.isEmpty()) { + final Iterable current = next; + next = new HashSet<>(); - int length = 0; - outer: - while( !next.isEmpty() ) - { - final Iterable current = next; - next = new HashSet<>(); + for (final IGridNode n : current) { + if (n.getMachine() instanceof TileController) { + break outer; + } - for( final IGridNode n : current ) - { - if( n.getMachine() instanceof TileController ) - { - break outer; - } + for (final IGridConnection c : n.getConnections()) { + next.add(c.getOtherSide(n)); + } + } - for( final IGridConnection c : n.getConnections() ) - { - next.add( c.getOtherSide( n ) ); - } - } + length++; - length++; + if (length > maxLength) { + break; + } + } - if( length > maxLength ) - { - break; - } - } + this.outputMsg(player, "Cable Distance: " + length); + } - this.outputMsg( player, "Cable Distance: " + length ); - } + if (center.getMachine() instanceof PartP2PTunnel) { + this.outputMsg(player, "Freq: " + ((PartP2PTunnel) center.getMachine()).getFrequency()); + } - if( center.getMachine() instanceof PartP2PTunnel ) - { - this.outputMsg( player, "Freq: " + ( (PartP2PTunnel) center.getMachine() ).getFrequency() ); - } + final TickManagerCache tmc = g.getCache(ITickManager.class); + for (final Class c : g.getMachineClasses()) { + int o = 0; + long nanos = 0; + for (final IGridNode oj : g.getMachines(c)) { + o++; + nanos += tmc.getAvgNanoTime(oj); + } - final TickManagerCache tmc = g.getCache( ITickManager.class ); - for( final Class c : g.getMachineClasses() ) - { - int o = 0; - long nanos = 0; - for( final IGridNode oj : g.getMachines( c ) ) - { - o++; - nanos += tmc.getAvgNanoTime( oj ); - } + if (nanos < 0) { + this.outputMsg(player, c.getSimpleName() + " - " + o); + } else { + this.outputMsg(player, c.getSimpleName() + " - " + o + "; " + this.timeMeasurement(nanos)); + } + } + } else { + this.outputMsg(player, "No Node Available."); + } + } else { + this.outputMsg(player, "Not Networked Block"); + } - if( nanos < 0 ) - { - this.outputMsg( player, c.getSimpleName() + " - " + o ); - } - else - { - this.outputMsg( player, c.getSimpleName() + " - " + o + "; " + this.timeMeasurement( nanos ) ); - } - } - } - else - { - this.outputMsg( player, "No Node Available." ); - } - } - else - { - this.outputMsg( player, "Not Networked Block" ); - } + if (te instanceof IPartHost) { + final IPart center = ((IPartHost) te).getPart(AEPartLocation.INTERNAL); + ((IPartHost) te).markForUpdate(); + if (center != null) { + final GridNode n = (GridNode) center.getGridNode(); + this.outputMsg(player, "Node Channels: " + n.usedChannels()); + for (final IGridConnection gc : n.getConnections()) { + final AEPartLocation fd = gc.getDirection(n); + if (fd != AEPartLocation.INTERNAL) { + this.outputMsg(player, fd.toString() + ": " + gc.getUsedChannels()); + } + } + } + } - if( te instanceof IPartHost ) - { - final IPart center = ( (IPartHost) te ).getPart( AEPartLocation.INTERNAL ); - ( (IPartHost) te ).markForUpdate(); - if( center != null ) - { - final GridNode n = (GridNode) center.getGridNode(); - this.outputMsg( player, "Node Channels: " + n.usedChannels() ); - for( final IGridConnection gc : n.getConnections() ) - { - final AEPartLocation fd = gc.getDirection( n ); - if( fd != AEPartLocation.INTERNAL ) - { - this.outputMsg( player, fd.toString() + ": " + gc.getUsedChannels() ); - } - } - } - } + if (te instanceof IAEPowerStorage) { + final IAEPowerStorage ps = (IAEPowerStorage) te; + this.outputMsg(player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower()); - if( te instanceof IAEPowerStorage ) - { - final IAEPowerStorage ps = (IAEPowerStorage) te; - this.outputMsg( player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower() ); + if (te instanceof IGridHost) { + final IGridNode node = ((IGridHost) te).getGridNode(AEPartLocation.fromFacing(side)); + if (node != null && node.getGrid() != null) { + final IEnergyGrid eg = node.getGrid().getCache(IEnergyGrid.class); + this.outputMsg(player, + "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand(Double.MAX_VALUE)); + } + } + } + } + return ActionResultType.SUCCESS; + } - if( te instanceof IGridHost ) - { - final IGridNode node = ( (IGridHost) te ).getGridNode( AEPartLocation.fromFacing( side ) ); - if( node != null && node.getGrid() != null ) - { - final IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class ); - this.outputMsg( player, "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand( Double.MAX_VALUE ) ); - } - } - } - } - return ActionResultType.SUCCESS; - } + private void outputMsg(final Entity player, final String string) { + player.sendMessage(new StringTextComponent(string)); + } - private void outputMsg(final Entity player, final String string ) - { - player.sendMessage( new StringTextComponent( string ) ); - } - - private String timeMeasurement( final long nanos ) - { - final long ms = nanos / 100000; - if( nanos <= 100000 ) - { - return nanos + "ns"; - } - return ( ms / 10.0f ) + "ms"; - } + private String timeMeasurement(final long nanos) { + final long ms = nanos / 100000; + if (nanos <= 100000) { + return nanos + "ns"; + } + return (ms / 10.0f) + "ms"; + } } diff --git a/src/main/java/appeng/debug/ToolDebugPartPlacer.java b/src/main/java/appeng/debug/ToolDebugPartPlacer.java index b2fea1e46..6500fc583 100644 --- a/src/main/java/appeng/debug/ToolDebugPartPlacer.java +++ b/src/main/java/appeng/debug/ToolDebugPartPlacer.java @@ -1,12 +1,7 @@ package appeng.debug; -import appeng.api.parts.IPart; -import appeng.api.parts.IPartHost; -import appeng.api.parts.PartItemStack; -import appeng.api.util.AEPartLocation; -import appeng.items.AEBaseItem; -import appeng.items.parts.ColoredPartItem; -import appeng.items.parts.ItemPart; +import java.util.Arrays; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,11 +15,18 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistries; -import java.util.Arrays; +import appeng.api.parts.IPart; +import appeng.api.parts.IPartHost; +import appeng.api.parts.PartItemStack; +import appeng.api.util.AEPartLocation; +import appeng.items.AEBaseItem; +import appeng.items.parts.ColoredPartItem; +import appeng.items.parts.ItemPart; /** - * This tool will try to place anything that is registered as a {@link ItemPart} (and not a colored one) - * onto an existing cable to quickly test parts and their rendering. + * This tool will try to place anything that is registered as a {@link ItemPart} + * (and not a colored one) onto an existing cable to quickly test parts and + * their rendering. */ public class ToolDebugPartPlacer extends AEBaseItem { @@ -89,7 +91,8 @@ public class ToolDebugPartPlacer extends AEBaseItem { } IPartHost partHost = (IPartHost) t; - if (partHost.addPart(cable.getItemStack(PartItemStack.PICK), AEPartLocation.INTERNAL, player, null) == null) { + if (partHost.addPart(cable.getItemStack(PartItemStack.PICK), AEPartLocation.INTERNAL, player, + null) == null) { continue; } for (Direction dir : perpendicularFaces) { diff --git a/src/main/java/appeng/debug/ToolEraser.java b/src/main/java/appeng/debug/ToolEraser.java index 3748fc32a..ddedfd148 100644 --- a/src/main/java/appeng/debug/ToolEraser.java +++ b/src/main/java/appeng/debug/ToolEraser.java @@ -18,10 +18,9 @@ package appeng.debug; +import java.util.ArrayList; +import java.util.List; -import appeng.core.AELog; -import appeng.items.AEBaseItem; -import appeng.util.Platform; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -30,66 +29,61 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.List; +import appeng.core.AELog; +import appeng.items.AEBaseItem; +import appeng.util.Platform; +public class ToolEraser extends AEBaseItem { -public class ToolEraser extends AEBaseItem -{ + private static final int BLOCK_ERASE_LIMIT = 90000; - private static final int BLOCK_ERASE_LIMIT = 90000; + public ToolEraser(Properties properties) { + super(properties); + } - public ToolEraser(Properties properties) { - super(properties); - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + if (context.getWorld().isRemote()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - if( context.getWorld().isRemote() ) - { - return ActionResultType.PASS; - } + PlayerEntity player = context.getPlayer(); + World world = context.getWorld(); + BlockPos pos = context.getPos(); - PlayerEntity player = context.getPlayer(); - World world = context.getWorld(); - BlockPos pos = context.getPos(); + if (player == null) { + return ActionResultType.PASS; + } - if (player == null) { - return ActionResultType.PASS; - } + final BlockState state = world.getBlockState(pos); - final BlockState state = world.getBlockState( pos ); + List next = new ArrayList<>(); + next.add(pos); - List next = new ArrayList<>(); - next.add( pos ); + int blocks = 0; + while (blocks < BLOCK_ERASE_LIMIT && !next.isEmpty()) { + final List c = next; + next = new ArrayList<>(); - int blocks = 0; - while( blocks < BLOCK_ERASE_LIMIT && !next.isEmpty() ) - { - final List c = next; - next = new ArrayList<>(); + for (final BlockPos wc : c) { + final BlockState c_state = world.getBlockState(wc); - for( final BlockPos wc : c ) - { - final BlockState c_state = world.getBlockState( wc ); + if (state == c_state) { + blocks++; + world.removeBlock(wc, false); - if( state == c_state ) - { - blocks++; - world.removeBlock(wc, false); + next.add(wc.add(1, 0, 0)); + next.add(wc.add(-1, 0, 0)); + next.add(wc.add(0, 1, 0)); + next.add(wc.add(0, -1, 0)); + next.add(wc.add(0, 0, 1)); + next.add(wc.add(0, 0, -1)); + } + } + } - next.add( wc.add( 1, 0, 0 ) ); - next.add( wc.add( -1, 0, 0 ) ); - next.add( wc.add( 0, 1, 0 ) ); - next.add( wc.add( 0, -1, 0 ) ); - next.add( wc.add( 0, 0, 1 ) ); - next.add( wc.add( 0, 0, -1 ) ); - } - } - } + AELog.info("Delete " + blocks + " blocks"); - AELog.info( "Delete " + blocks + " blocks" ); - - return ActionResultType.SUCCESS; - } + return ActionResultType.SUCCESS; + } } diff --git a/src/main/java/appeng/debug/ToolMeteoritePlacer.java b/src/main/java/appeng/debug/ToolMeteoritePlacer.java index 454d31dc5..458d025c3 100644 --- a/src/main/java/appeng/debug/ToolMeteoritePlacer.java +++ b/src/main/java/appeng/debug/ToolMeteoritePlacer.java @@ -18,11 +18,6 @@ package appeng.debug; - -import appeng.worldgen.MeteoritePlacer; -import appeng.worldgen.MeteoriteSpawner; -import appeng.worldgen.PlacedMeteoriteSettings; -import appeng.worldgen.meteorite.StandardWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; @@ -33,55 +28,55 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; - -import appeng.items.AEBaseItem; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.server.ServerWorld; +import appeng.items.AEBaseItem; +import appeng.worldgen.MeteoritePlacer; +import appeng.worldgen.MeteoriteSpawner; +import appeng.worldgen.PlacedMeteoriteSettings; +import appeng.worldgen.meteorite.StandardWorld; -public class ToolMeteoritePlacer extends AEBaseItem -{ +public class ToolMeteoritePlacer extends AEBaseItem { - public ToolMeteoritePlacer(Properties properties) { - super(properties); - } + public ToolMeteoritePlacer(Properties properties) { + super(properties); + } - @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - if( context.getWorld().isRemote() ) - { - return ActionResultType.PASS; - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + if (context.getWorld().isRemote()) { + return ActionResultType.PASS; + } - ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer(); - ServerWorld world = (ServerWorld) context.getWorld(); - BlockPos pos = context.getPos(); + ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer(); + ServerWorld world = (ServerWorld) context.getWorld(); + BlockPos pos = context.getPos(); - if (player == null) { - return ActionResultType.PASS; - } + if (player == null) { + return ActionResultType.PASS; + } - final MeteoriteSpawner ms = new MeteoriteSpawner(); - PlacedMeteoriteSettings spawned = ms.trySpawnMeteorite(world, pos); + final MeteoriteSpawner ms = new MeteoriteSpawner(); + PlacedMeteoriteSettings spawned = ms.trySpawnMeteorite(world, pos); - if( spawned == null ) - { - player.sendMessage( new StringTextComponent( "Un-suitable Location." ) ); - return ActionResultType.FAIL; - } + if (spawned == null) { + player.sendMessage(new StringTextComponent("Un-suitable Location.")); + return ActionResultType.FAIL; + } - final MeteoritePlacer placer = new MeteoritePlacer(world, spawned); - placer.place(); + final MeteoritePlacer placer = new MeteoritePlacer(world, spawned); + placer.place(); - // The placer will not send chunks to the player since it's used as part - // of world-gen normally, so we'll have to do it ourselves. Since this - // is a debug tool, we'll not care about being terribly efficient here - ChunkPos.getAllInBox(new ChunkPos(spawned.getPos()), 1).forEach(cp -> { - Chunk c = world.getChunk(cp.x, cp.z); - player.connection.sendPacket(new SChunkDataPacket(c, 65535)); // 65535 == full chunk - }); + // The placer will not send chunks to the player since it's used as part + // of world-gen normally, so we'll have to do it ourselves. Since this + // is a debug tool, we'll not care about being terribly efficient here + ChunkPos.getAllInBox(new ChunkPos(spawned.getPos()), 1).forEach(cp -> { + Chunk c = world.getChunk(cp.x, cp.z); + player.connection.sendPacket(new SChunkDataPacket(c, 65535)); // 65535 == full chunk + }); - return ActionResultType.SUCCESS; - } + return ActionResultType.SUCCESS; + } } diff --git a/src/main/java/appeng/debug/ToolReplicatorCard.java b/src/main/java/appeng/debug/ToolReplicatorCard.java index 891d62324..01fbf9834 100644 --- a/src/main/java/appeng/debug/ToolReplicatorCard.java +++ b/src/main/java/appeng/debug/ToolReplicatorCard.java @@ -18,15 +18,6 @@ package appeng.debug; - -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridHost; -import appeng.api.networking.IGridNode; -import appeng.api.networking.spatial.ISpatialCache; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.items.AEBaseItem; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -43,155 +34,135 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; +import appeng.api.networking.IGrid; +import appeng.api.networking.IGridHost; +import appeng.api.networking.IGridNode; +import appeng.api.networking.spatial.ISpatialCache; +import appeng.api.util.AEPartLocation; +import appeng.api.util.DimensionalCoord; +import appeng.items.AEBaseItem; +import appeng.util.Platform; -public class ToolReplicatorCard extends AEBaseItem -{ +public class ToolReplicatorCard extends AEBaseItem { - public ToolReplicatorCard(Properties properties) { - super(properties); - } + public ToolReplicatorCard(Properties properties) { + super(properties); + } - @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - if( context.getWorld().isRemote() ) - { - return ActionResultType.PASS; - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + if (context.getWorld().isRemote()) { + return ActionResultType.PASS; + } - PlayerEntity player = context.getPlayer(); - World world = context.getWorld(); - BlockPos pos = context.getPos(); - Direction side = context.getFace(); - Hand hand = context.getHand(); + PlayerEntity player = context.getPlayer(); + World world = context.getWorld(); + BlockPos pos = context.getPos(); + Direction side = context.getFace(); + Hand hand = context.getHand(); - if (player == null) { - return ActionResultType.PASS; - } + if (player == null) { + return ActionResultType.PASS; + } - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); - if( player.isCrouching() ) - { - if( world.getTileEntity( pos ) instanceof IGridHost ) - { - final CompoundNBT tag = new CompoundNBT(); - tag.putInt( "x", x ); - tag.putInt( "y", y ); - tag.putInt( "z", z ); - tag.putInt( "side", side.ordinal() ); - tag.putInt( "dimid", world.getDimension().getType().getId() ); - player.getHeldItem( hand ).setTag( tag ); - } - else - { - this.outputMsg( player, "This is not a Grid Tile." ); - } - } - else - { - final CompoundNBT ish = player.getHeldItem( hand ).getTag(); - if( ish != null ) - { - final int src_x = ish.getInt( "x" ); - final int src_y = ish.getInt( "y" ); - final int src_z = ish.getInt( "z" ); - final int src_side = ish.getInt( "side" ); - final int dimid = ish.getInt( "dimid" ); - final World src_w = world.getServer().getWorld(DimensionType.getById(dimid)); + if (player.isCrouching()) { + if (world.getTileEntity(pos) instanceof IGridHost) { + final CompoundNBT tag = new CompoundNBT(); + tag.putInt("x", x); + tag.putInt("y", y); + tag.putInt("z", z); + tag.putInt("side", side.ordinal()); + tag.putInt("dimid", world.getDimension().getType().getId()); + player.getHeldItem(hand).setTag(tag); + } else { + this.outputMsg(player, "This is not a Grid Tile."); + } + } else { + final CompoundNBT ish = player.getHeldItem(hand).getTag(); + if (ish != null) { + final int src_x = ish.getInt("x"); + final int src_y = ish.getInt("y"); + final int src_z = ish.getInt("z"); + final int src_side = ish.getInt("side"); + final int dimid = ish.getInt("dimid"); + final World src_w = world.getServer().getWorld(DimensionType.getById(dimid)); - final TileEntity te = src_w.getTileEntity( new BlockPos( src_x, src_y, src_z ) ); - if( te instanceof IGridHost ) - { - final IGridHost gh = (IGridHost) te; - final Direction sideOff = Direction.values()[src_side]; - final Direction currentSideOff = side; - final IGridNode n = gh.getGridNode( AEPartLocation.fromFacing( sideOff ) ); - if( n != null ) - { - final IGrid g = n.getGrid(); - if( g != null ) - { - final ISpatialCache sc = g.getCache( ISpatialCache.class ); - if( sc.isValidRegion() ) - { - final DimensionalCoord min = sc.getMin(); - final DimensionalCoord max = sc.getMax(); + final TileEntity te = src_w.getTileEntity(new BlockPos(src_x, src_y, src_z)); + if (te instanceof IGridHost) { + final IGridHost gh = (IGridHost) te; + final Direction sideOff = Direction.values()[src_side]; + final Direction currentSideOff = side; + final IGridNode n = gh.getGridNode(AEPartLocation.fromFacing(sideOff)); + if (n != null) { + final IGrid g = n.getGrid(); + if (g != null) { + final ISpatialCache sc = g.getCache(ISpatialCache.class); + if (sc.isValidRegion()) { + final DimensionalCoord min = sc.getMin(); + final DimensionalCoord max = sc.getMax(); - x += currentSideOff.getXOffset(); - y += currentSideOff.getYOffset(); - z += currentSideOff.getZOffset(); + x += currentSideOff.getXOffset(); + y += currentSideOff.getYOffset(); + z += currentSideOff.getZOffset(); - final int min_x = min.x; - final int min_y = min.y; - final int min_z = min.z; + final int min_x = min.x; + final int min_y = min.y; + final int min_z = min.z; - final int rel_x = min.x - src_x + x; - final int rel_y = min.y - src_y + y; - final int rel_z = min.z - src_z + z; + final int rel_x = min.x - src_x + x; + final int rel_y = min.y - src_y + y; + final int rel_z = min.z - src_z + z; - final int scale_x = max.x - min.x; - final int scale_y = max.y - min.y; - final int scale_z = max.z - min.z; + final int scale_x = max.x - min.x; + final int scale_y = max.y - min.y; + final 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++ ) - { - final BlockPos p = new BlockPos( min_x + i, min_y + j, min_z + k ); - final BlockPos d = new BlockPos( i + rel_x, j + rel_y, k + rel_z ); - final BlockState state = src_w.getBlockState( p ); - final Block blk = state.getBlock(); - final BlockState prev = world.getBlockState( d ); + for (int i = 1; i < scale_x; i++) { + for (int j = 1; j < scale_y; j++) { + for (int k = 1; k < scale_z; k++) { + final BlockPos p = new BlockPos(min_x + i, min_y + j, min_z + k); + final BlockPos d = new BlockPos(i + rel_x, j + rel_y, k + rel_z); + final BlockState state = src_w.getBlockState(p); + final Block blk = state.getBlock(); + final BlockState prev = world.getBlockState(d); - world.setBlockState( d, state ); - if( blk != null && blk.hasTileEntity( state ) ) - { - final TileEntity ote = src_w.getTileEntity( p ); - final TileEntity nte = blk.createTileEntity( state, world ); - final CompoundNBT data = new CompoundNBT(); - ote.write( data ); - nte.read( data.copy() ); - world.setTileEntity( d, nte ); - } - world.notifyBlockUpdate( d, prev, state, 3 ); - } - } - } - } - else - { - this.outputMsg( player, "requires valid spatial pylon setup." ); - } - } - else - { - this.outputMsg( player, "no grid?" ); - } - } - else - { - this.outputMsg( player, "No grid node?" ); - } - } - else - { - this.outputMsg( player, "Src is no longer a grid block?" ); - } - } - else - { - this.outputMsg( player, "No Source Defined" ); - } - } - return ActionResultType.SUCCESS; - } + world.setBlockState(d, state); + if (blk != null && blk.hasTileEntity(state)) { + final TileEntity ote = src_w.getTileEntity(p); + final TileEntity nte = blk.createTileEntity(state, world); + final CompoundNBT data = new CompoundNBT(); + ote.write(data); + nte.read(data.copy()); + world.setTileEntity(d, nte); + } + world.notifyBlockUpdate(d, prev, state, 3); + } + } + } + } else { + this.outputMsg(player, "requires valid spatial pylon setup."); + } + } else { + this.outputMsg(player, "no grid?"); + } + } else { + this.outputMsg(player, "No grid node?"); + } + } else { + this.outputMsg(player, "Src is no longer a grid block?"); + } + } else { + this.outputMsg(player, "No Source Defined"); + } + } + return ActionResultType.SUCCESS; + } - private void outputMsg(final Entity player, final String string ) - { - player.sendMessage( new StringTextComponent( string ) ); - } + private void outputMsg(final Entity player, final String string) { + player.sendMessage(new StringTextComponent(string)); + } } diff --git a/src/main/java/appeng/decorative/AEDecorativeBlock.java b/src/main/java/appeng/decorative/AEDecorativeBlock.java index f815e9c97..ba029e816 100644 --- a/src/main/java/appeng/decorative/AEDecorativeBlock.java +++ b/src/main/java/appeng/decorative/AEDecorativeBlock.java @@ -18,13 +18,10 @@ package appeng.decorative; - import appeng.block.AEBaseBlock; - -public class AEDecorativeBlock extends AEBaseBlock -{ - public AEDecorativeBlock(Properties props) { - super(props); - } +public class AEDecorativeBlock extends AEBaseBlock { + public AEDecorativeBlock(Properties props) { + super(props); + } } diff --git a/src/main/java/appeng/decorative/solid/BlockChargedQuartzOre.java b/src/main/java/appeng/decorative/solid/BlockChargedQuartzOre.java index 5fada1490..dab3248bd 100644 --- a/src/main/java/appeng/decorative/solid/BlockChargedQuartzOre.java +++ b/src/main/java/appeng/decorative/solid/BlockChargedQuartzOre.java @@ -18,10 +18,8 @@ package appeng.decorative.solid; +import java.util.Random; -import appeng.client.render.effects.ChargedOreFX; -import appeng.core.AEConfig; -import appeng.core.AppEng; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.util.math.BlockPos; @@ -29,16 +27,16 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.Random; +import appeng.client.render.effects.ChargedOreFX; +import appeng.core.AEConfig; +import appeng.core.AppEng; +public class BlockChargedQuartzOre extends BlockQuartzOre { + public BlockChargedQuartzOre(Properties props) { + super(props); + } -public class BlockChargedQuartzOre extends BlockQuartzOre -{ - public BlockChargedQuartzOre(Properties props) { - super(props); - } - - // FIXME: Loot tables + // FIXME: Loot tables // @Override // public Item getItemDropped( final BlockState state, final Random rand, final int fortune ) // { @@ -73,47 +71,44 @@ public class BlockChargedQuartzOre extends BlockQuartzOre // .orElseThrow( () -> new MissingDefinitionException( "Tried to access charged certus quartz ore, even though they are disabled" ) ); // } - @Override - @OnlyIn( Dist.CLIENT ) - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - double xOff = ( r.nextFloat() ); - double yOff = ( r.nextFloat() ); - double zOff = ( r.nextFloat() ); + double xOff = (r.nextFloat()); + double yOff = (r.nextFloat()); + double zOff = (r.nextFloat()); - switch( r.nextInt( 6 ) ) - { - case 0: - xOff = -0.01; - break; - case 1: - yOff = -0.01; - break; - case 2: - xOff = -0.01; - break; - case 3: - zOff = -0.01; - break; - case 4: - xOff = 1.01; - break; - case 5: - yOff = 1.01; - break; - case 6: - zOff = 1.01; - break; - } + switch (r.nextInt(6)) { + case 0: + xOff = -0.01; + break; + case 1: + yOff = -0.01; + break; + case 2: + xOff = -0.01; + break; + case 3: + zOff = -0.01; + break; + case 4: + xOff = 1.01; + break; + case 5: + yOff = 1.01; + break; + case 6: + zOff = 1.01; + break; + } - if( AppEng.proxy.shouldAddParticles( r ) ) - { - Minecraft.getInstance().particles.addParticle(ChargedOreFX.TYPE, pos.getX() + xOff, pos.getY() + yOff, pos.getZ() + zOff, 0.0f, 0.0f, 0.0f); - } - } + if (AppEng.proxy.shouldAddParticles(r)) { + Minecraft.getInstance().particles.addParticle(ChargedOreFX.TYPE, pos.getX() + xOff, pos.getY() + yOff, + pos.getZ() + zOff, 0.0f, 0.0f, 0.0f); + } + } } diff --git a/src/main/java/appeng/decorative/solid/BlockQuartzGlass.java b/src/main/java/appeng/decorative/solid/BlockQuartzGlass.java index af1f42456..37d0e055f 100644 --- a/src/main/java/appeng/decorative/solid/BlockQuartzGlass.java +++ b/src/main/java/appeng/decorative/solid/BlockQuartzGlass.java @@ -18,8 +18,6 @@ package appeng.decorative.solid; - -import appeng.helpers.AEGlassMaterial; import net.minecraft.block.AbstractGlassBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -27,22 +25,24 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.Direction; +import appeng.helpers.AEGlassMaterial; + public class BlockQuartzGlass extends AbstractGlassBlock { - public BlockQuartzGlass(Properties props) { - super(props); - } + public BlockQuartzGlass(Properties props) { + super(props); + } - @Override - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { - final Material mat = adjacentBlockState.getMaterial(); - if (mat == Material.GLASS || mat == AEGlassMaterial.INSTANCE) { - if (adjacentBlockState.getRenderType() == state.getRenderType()) { - return true; - } - } + @Override + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + final Material mat = adjacentBlockState.getMaterial(); + if (mat == Material.GLASS || mat == AEGlassMaterial.INSTANCE) { + if (adjacentBlockState.getRenderType() == state.getRenderType()) { + return true; + } + } - return super.isSideInvisible(state, adjacentBlockState, side); - } + return super.isSideInvisible(state, adjacentBlockState, side); + } } diff --git a/src/main/java/appeng/decorative/solid/BlockQuartzLamp.java b/src/main/java/appeng/decorative/solid/BlockQuartzLamp.java index 415c18b72..08b88c56f 100644 --- a/src/main/java/appeng/decorative/solid/BlockQuartzLamp.java +++ b/src/main/java/appeng/decorative/solid/BlockQuartzLamp.java @@ -18,7 +18,6 @@ package appeng.decorative.solid; - import java.util.Random; import net.minecraft.block.BlockState; @@ -31,30 +30,25 @@ import appeng.client.render.effects.VibrantFX; import appeng.core.AEConfig; import appeng.core.AppEng; +public class BlockQuartzLamp extends BlockQuartzGlass { -public class BlockQuartzLamp extends BlockQuartzGlass -{ + public BlockQuartzLamp(Properties props) { + super(props); + } - public BlockQuartzLamp(Properties props) { - super(props); - } + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) { + if (!AEConfig.instance().isEnableEffects()) { + return; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r ) - { - if( !AEConfig.instance().isEnableEffects() ) - { - return; - } + if (AppEng.proxy.shouldAddParticles(r)) { + final double d0 = (r.nextFloat() - 0.5F) * 0.96D; + final double d1 = (r.nextFloat() - 0.5F) * 0.96D; + final double d2 = (r.nextFloat() - 0.5F) * 0.96D; - if( AppEng.proxy.shouldAddParticles( r ) ) - { - final double d0 = ( r.nextFloat() - 0.5F ) * 0.96D; - final double d1 = ( r.nextFloat() - 0.5F ) * 0.96D; - final double d2 = ( r.nextFloat() - 0.5F ) * 0.96D; - - w.addParticle(VibrantFX.TYPE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0, 0, 0); - } - } + w.addParticle(VibrantFX.TYPE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0, 0, 0); + } + } } diff --git a/src/main/java/appeng/decorative/solid/BlockQuartzOre.java b/src/main/java/appeng/decorative/solid/BlockQuartzOre.java index 84a515eae..ae1d2a4a8 100644 --- a/src/main/java/appeng/decorative/solid/BlockQuartzOre.java +++ b/src/main/java/appeng/decorative/solid/BlockQuartzOre.java @@ -18,20 +18,18 @@ package appeng.decorative.solid; - -import appeng.block.AEBaseBlock; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import appeng.block.AEBaseBlock; -public class BlockQuartzOre extends AEBaseBlock -{ - public BlockQuartzOre(Properties props) { - super(props); - } +public class BlockQuartzOre extends AEBaseBlock { + public BlockQuartzOre(Properties props) { + super(props); + } - // FIXME: Loot Tables + // FIXME: Loot Tables // @Override // public int quantityDropped( BlockState state, int fortune, Random rand ) // { @@ -59,12 +57,13 @@ public class BlockQuartzOre extends AEBaseBlock // } // - @Override - public int getExpDrop(BlockState state, net.minecraft.world.IWorldReader reader, BlockPos pos, int fortune, int silktouch) { - return silktouch == 0 ? MathHelper.nextInt(RANDOM, 2, 5) : 0; - } + @Override + public int getExpDrop(BlockState state, net.minecraft.world.IWorldReader reader, BlockPos pos, int fortune, + int silktouch) { + return silktouch == 0 ? MathHelper.nextInt(RANDOM, 2, 5) : 0; + } - // FIXME: loot tables + // FIXME: loot tables // @Override // public Item getItemDropped( final BlockState state, final Random rand, final int fortune ) // { @@ -76,7 +75,7 @@ public class BlockQuartzOre extends AEBaseBlock // .orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) ); // } - // FIXME: loot tables + // FIXME: loot tables // @Override // public int damageDropped( final BlockState state ) // { diff --git a/src/main/java/appeng/decorative/solid/BlockQuartzPillar.java b/src/main/java/appeng/decorative/solid/BlockQuartzPillar.java index 96be9e9e7..32da88cc1 100644 --- a/src/main/java/appeng/decorative/solid/BlockQuartzPillar.java +++ b/src/main/java/appeng/decorative/solid/BlockQuartzPillar.java @@ -18,8 +18,6 @@ package appeng.decorative.solid; - -import appeng.decorative.AEDecorativeBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.state.EnumProperty; @@ -31,30 +29,28 @@ import net.minecraft.world.IBlockReader; import appeng.api.util.IOrientable; import appeng.api.util.IOrientableBlock; +import appeng.decorative.AEDecorativeBlock; import appeng.helpers.MetaRotation; +public class BlockQuartzPillar extends AEDecorativeBlock implements IOrientableBlock { + public static final EnumProperty AXIS = BlockStateProperties.AXIS; -public class BlockQuartzPillar extends AEDecorativeBlock implements IOrientableBlock -{ - public static final EnumProperty AXIS = BlockStateProperties.AXIS; + public BlockQuartzPillar(Properties props) { + super(props); - public BlockQuartzPillar(Properties props) { - super(props); + // The upwards facing pillar is the default (i.e. for the item model) + this.setDefaultState(this.getDefaultState().with(AXIS, Direction.Axis.Y)); + } - // The upwards facing pillar is the default (i.e. for the item model) - this.setDefaultState( this.getDefaultState().with( AXIS, Direction.Axis.Y ) ); - } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(AXIS); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(AXIS); - } - - @Override - public IOrientable getOrientable( final IBlockReader w, final BlockPos pos ) - { - return new MetaRotation( w, pos, null ); - } + @Override + public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) { + return new MetaRotation(w, pos, null); + } } diff --git a/src/main/java/appeng/decorative/solid/BlockSkyStone.java b/src/main/java/appeng/decorative/solid/BlockSkyStone.java index 8598e80b2..9803096d5 100644 --- a/src/main/java/appeng/decorative/solid/BlockSkyStone.java +++ b/src/main/java/appeng/decorative/solid/BlockSkyStone.java @@ -18,8 +18,6 @@ package appeng.decorative.solid; - -import appeng.core.worlddata.WorldData; import net.minecraft.block.BlockState; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; @@ -34,68 +32,63 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import appeng.block.AEBaseBlock; +import appeng.core.worlddata.WorldData; import appeng.util.Platform; +public class BlockSkyStone extends AEBaseBlock { + private static final float BREAK_SPEAK_SCALAR = 0.1f; + private static final double BREAK_SPEAK_THRESHOLD = 7.0; + private final SkystoneType type; -public class BlockSkyStone extends AEBaseBlock -{ - private static final float BREAK_SPEAK_SCALAR = 0.1f; - private static final double BREAK_SPEAK_THRESHOLD = 7.0; - private final SkystoneType type; + public BlockSkyStone(SkystoneType type, Properties props) { + super(props); + this.type = type; - public BlockSkyStone(SkystoneType type, Properties props) { - super(props); - this.type = type; + MinecraftForge.EVENT_BUS.register(this); + } - MinecraftForge.EVENT_BUS.register( this ); - } + @SubscribeEvent + public void breakFaster(final PlayerEvent.BreakSpeed event) { + if (event.getState().getBlock() == this && event.getPlayer() != null) { + final ItemStack is = event.getPlayer().getItemStackFromSlot(EquipmentSlotType.MAINHAND); + int level = -1; - @SubscribeEvent - public void breakFaster( final PlayerEvent.BreakSpeed event ) - { - if( event.getState().getBlock() == this && event.getPlayer() != null ) - { - final ItemStack is = event.getPlayer().getItemStackFromSlot( EquipmentSlotType.MAINHAND ); - int level = -1; + if (!is.isEmpty()) { + level = is.getItem().getHarvestLevel(is, ToolType.PICKAXE, event.getPlayer(), event.getState()); + } - if( !is.isEmpty() ) - { - level = is.getItem().getHarvestLevel( is, ToolType.PICKAXE, event.getPlayer(), event.getState() ); - } + if (this.type != SkystoneType.STONE || level >= 3 || event.getOriginalSpeed() > BREAK_SPEAK_THRESHOLD) { + event.setNewSpeed(event.getNewSpeed() / BREAK_SPEAK_SCALAR); + } + } + } - if( this.type != SkystoneType.STONE || level >= 3 || event.getOriginalSpeed() > BREAK_SPEAK_THRESHOLD ) - { - event.setNewSpeed( event.getNewSpeed() / BREAK_SPEAK_SCALAR ); - } - } - } + @Override + public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + BlockPos currentPos, BlockPos facingPos) { + if (worldIn instanceof ServerWorld) { + WorldData.instance().compassData().service().updateArea((ServerWorld) worldIn, currentPos.getX(), + currentPos.getY(), currentPos.getZ()); + } - @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { - if( worldIn instanceof ServerWorld) - { - WorldData.instance().compassData().service().updateArea((ServerWorld) worldIn, currentPos.getX(), currentPos.getY(), currentPos.getZ() ); - } + return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos); + } - return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos); - } + @Override + public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { + if (newState.getBlock() == state.getBlock()) { + return; // Just a block state change + } - @Override - public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) { - if (newState.getBlock() == state.getBlock()) { - return; // Just a block state change - } + super.onReplaced(state, w, pos, newState, isMoving); - super.onReplaced(state, w, pos, newState, isMoving); + if (w instanceof ServerWorld) { + WorldData.instance().compassData().service().updateArea((ServerWorld) w, pos.getX(), pos.getY(), + pos.getZ()); + } + } - if( w instanceof ServerWorld ) - { - WorldData.instance().compassData().service().updateArea((ServerWorld) w, pos.getX(), pos.getY(), pos.getZ() ); - } - } - - public enum SkystoneType - { - STONE, BLOCK, BRICK, SMALL_BRICK - } + public enum SkystoneType { + STONE, BLOCK, BRICK, SMALL_BRICK + } } diff --git a/src/main/java/appeng/decorative/solid/GlassState.java b/src/main/java/appeng/decorative/solid/GlassState.java index 15c213d85..432c86419 100644 --- a/src/main/java/appeng/decorative/solid/GlassState.java +++ b/src/main/java/appeng/decorative/solid/GlassState.java @@ -18,51 +18,43 @@ package appeng.decorative.solid; - import java.util.EnumSet; import net.minecraft.util.Direction; - /** - * Immutable (and thus thread-safe) class that encapsulates the rendering state required for a connected texture - * glass block. + * Immutable (and thus thread-safe) class that encapsulates the rendering state + * required for a connected texture glass block. */ -public final class GlassState -{ +public final class GlassState { - private final int x; - private final int y; - private final int z; + private final int x; + private final int y; + private final int z; - private final EnumSet flushWith = EnumSet.noneOf( Direction.class ); + private final EnumSet flushWith = EnumSet.noneOf(Direction.class); - public GlassState( int x, int y, int z, EnumSet flushWith ) - { - this.x = x; - this.y = y; - this.z = z; - this.flushWith.addAll( flushWith ); - } + public GlassState(int x, int y, int z, EnumSet flushWith) { + this.x = x; + this.y = y; + this.z = z; + this.flushWith.addAll(flushWith); + } - public int getX() - { - return this.x; - } + public int getX() { + return this.x; + } - public int getY() - { - return this.y; - } + public int getY() { + return this.y; + } - public int getZ() - { - return this.z; - } + public int getZ() { + return this.z; + } - public boolean isFlushWith( Direction side ) - { - return this.flushWith.contains( side ); - } + public boolean isFlushWith(Direction side) { + return this.flushWith.contains(side); + } } diff --git a/src/main/java/appeng/entity/AEBaseEntityItem.java b/src/main/java/appeng/entity/AEBaseEntityItem.java index 47a1aadd0..056027c5b 100644 --- a/src/main/java/appeng/entity/AEBaseEntityItem.java +++ b/src/main/java/appeng/entity/AEBaseEntityItem.java @@ -18,7 +18,6 @@ package appeng.entity; - import java.util.List; import net.minecraft.entity.Entity; @@ -30,33 +29,29 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +public abstract class AEBaseEntityItem extends ItemEntity { -public abstract class AEBaseEntityItem extends ItemEntity -{ + protected AEBaseEntityItem(EntityType entityType, final World world) { + super(entityType, world); + } - protected AEBaseEntityItem( EntityType entityType, final World world ) - { - super( entityType, world ); - } + protected AEBaseEntityItem(EntityType entityType, final World world, final double x, + final double y, final double z, final ItemStack stack) { + this(entityType, world); + this.setPosition(x, y, z); + this.rotationYaw = this.rand.nextFloat() * 360.0F; + this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D); + this.setItem(stack); + this.lifespan = stack.getEntityLifespan(world); + } - protected AEBaseEntityItem( EntityType entityType, final World world, final double x, final double y, final double z, final ItemStack stack ) - { - this(entityType, world); - this.setPosition(x, y, z); - this.rotationYaw = this.rand.nextFloat() * 360.0F; - this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D); - this.setItem(stack); - this.lifespan = stack.getEntityLifespan(world); - } + protected List getCheckedEntitiesWithinAABBExcludingEntity(final AxisAlignedBB region) { + return this.world.getEntitiesWithinAABBExcludingEntity(this, region); + } - protected List getCheckedEntitiesWithinAABBExcludingEntity( final AxisAlignedBB region ) - { - return this.world.getEntitiesWithinAABBExcludingEntity( this, region ); - } - - @Override - public IPacket createSpawnPacket() { - return NetworkHooks.getEntitySpawningPacket(this); - } + @Override + public IPacket createSpawnPacket() { + return NetworkHooks.getEntitySpawningPacket(this); + } } diff --git a/src/main/java/appeng/entity/EntityChargedQuartz.java b/src/main/java/appeng/entity/EntityChargedQuartz.java index ec8c97f48..847f3331a 100644 --- a/src/main/java/appeng/entity/EntityChargedQuartz.java +++ b/src/main/java/appeng/entity/EntityChargedQuartz.java @@ -18,7 +18,6 @@ package appeng.entity; - import java.util.List; import net.minecraft.block.BlockState; @@ -35,138 +34,117 @@ import net.minecraft.world.World; import appeng.api.AEApi; import appeng.api.definitions.IMaterials; +import appeng.api.features.AEFeature; import appeng.client.EffectType; import appeng.core.AEConfig; import appeng.core.AppEng; -import appeng.api.features.AEFeature; import appeng.util.Platform; +public final class EntityChargedQuartz extends AEBaseEntityItem { -public final class EntityChargedQuartz extends AEBaseEntityItem -{ + public static EntityType TYPE; - public static EntityType TYPE; + private int delay = 0; + private int transformTime = 0; - private int delay = 0; - private int transformTime = 0; + public EntityChargedQuartz(EntityType entityType, World world) { + super(entityType, world); + } - public EntityChargedQuartz(EntityType entityType, World world) { - super(entityType, world); - } + public EntityChargedQuartz(final World w, final double x, final double y, final double z, final ItemStack is) { + super(TYPE, w, x, y, z, is); + } - public EntityChargedQuartz(final World w, final double x, final double y, final double z, final ItemStack is ) - { - super( TYPE, w, x, y, z, is ); - } + @Override + public void tick() { + super.tick(); - @Override - public void tick() - { - super.tick(); + if (this.removed || !AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) { + return; + } - if( this.removed || !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) ) - { - return; - } + if (world.isRemote && this.delay > 30 && AEConfig.instance().isEnableEffects()) { + AppEng.proxy.spawnEffect(EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(), + null); + this.delay = 0; + } - if( world.isRemote && this.delay > 30 && AEConfig.instance().isEnableEffects() ) - { - AppEng.proxy.spawnEffect( EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(), null ); - this.delay = 0; - } + this.delay++; - this.delay++; + final int j = MathHelper.floor(this.getPosX()); + final int i = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D); + final int k = MathHelper.floor(this.getPosZ()); - final int j = MathHelper.floor( this.getPosX() ); - final int i = MathHelper.floor( ( this.getBoundingBox().minY + this.getBoundingBox().maxY ) / 2.0D ); - final int k = MathHelper.floor( this.getPosZ() ); + BlockState state = this.world.getBlockState(new BlockPos(j, i, k)); + final Material mat = state.getMaterial(); - BlockState state = this.world.getBlockState( new BlockPos( j, i, k ) ); - final Material mat = state.getMaterial(); + if (Platform.isServer() && mat.isLiquid()) { + this.transformTime++; + if (this.transformTime > 60) { + if (!this.transform()) { + this.transformTime = 0; + } + } + } else { + this.transformTime = 0; + } + } - if( Platform.isServer() && mat.isLiquid() ) - { - this.transformTime++; - if( this.transformTime > 60 ) - { - if( !this.transform() ) - { - this.transformTime = 0; - } - } - } - else - { - this.transformTime = 0; - } - } + private boolean transform() { + final ItemStack item = this.getItem(); + final IMaterials materials = AEApi.instance().definitions().materials(); - private boolean transform() - { - final ItemStack item = this.getItem(); - final IMaterials materials = AEApi.instance().definitions().materials(); + if (materials.certusQuartzCrystalCharged().isSameAs(item)) { + final AxisAlignedBB region = new AxisAlignedBB(this.getPosX() - 1, this.getPosY() - 1, this.getPosZ() - 1, + this.getPosX() + 1, this.getPosY() + 1, this.getPosZ() + 1); + final List l = this.getCheckedEntitiesWithinAABBExcludingEntity(region); - if( materials.certusQuartzCrystalCharged().isSameAs( item ) ) - { - final AxisAlignedBB region = new AxisAlignedBB( this.getPosX() - 1, this.getPosY() - 1, this - .getPosZ() - 1, this.getPosX() + 1, this.getPosY() + 1, this.getPosZ() + 1 ); - final List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); + ItemEntity redstone = null; + ItemEntity netherQuartz = null; - ItemEntity redstone = null; - ItemEntity netherQuartz = null; + for (final Entity e : l) { + if (e instanceof ItemEntity && !e.removed) { + final ItemStack other = ((ItemEntity) e).getItem(); + if (!other.isEmpty()) { + if (ItemStack.areItemsEqual(other, new ItemStack(Items.REDSTONE))) { + redstone = (ItemEntity) e; + } - for( final Entity e : l ) - { - if( e instanceof ItemEntity && !e.removed ) - { - final ItemStack other = ( (ItemEntity) e ).getItem(); - if( !other.isEmpty() ) - { - if( ItemStack.areItemsEqual( other, new ItemStack( Items.REDSTONE ) ) ) - { - redstone = (ItemEntity) e; - } + if (ItemStack.areItemsEqual(other, new ItemStack(Items.QUARTZ))) { + netherQuartz = (ItemEntity) e; + } + } + } + } - if( ItemStack.areItemsEqual( other, new ItemStack( Items.QUARTZ ) ) ) - { - netherQuartz = (ItemEntity) e; - } - } - } - } + if (redstone != null && netherQuartz != null) { + this.getItem().grow(-1); + redstone.getItem().grow(-1); + netherQuartz.getItem().grow(-1); - if( redstone != null && netherQuartz != null ) - { - this.getItem().grow( -1 ); - redstone.getItem().grow( -1 ); - netherQuartz.getItem().grow( -1 ); + if (this.getItem().getCount() <= 0) { + this.remove(); + } - if( this.getItem().getCount() <= 0 ) - { - this.remove(); - } + if (redstone.getItem().getCount() <= 0) { + redstone.remove(); + } - if( redstone.getItem().getCount() <= 0 ) - { - redstone.remove(); - } + if (netherQuartz.getItem().getCount() <= 0) { + netherQuartz.remove(); + } - if( netherQuartz.getItem().getCount() <= 0 ) - { - netherQuartz.remove(); - } + materials.fluixCrystal().maybeStack(2).ifPresent(is -> { + final ItemEntity entity = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), + is); - materials.fluixCrystal().maybeStack( 2 ).ifPresent( is -> - { - final ItemEntity entity = new ItemEntity( this.world, this.getPosX(), this.getPosY(), this.getPosZ(), is ); + this.world.addEntity(entity); + }); - this.world.addEntity( entity ); - } ); + return true; + } + } - return true; - } - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/entity/EntityFloatingItem.java b/src/main/java/appeng/entity/EntityFloatingItem.java index d91a6fb08..81ceea95d 100644 --- a/src/main/java/appeng/entity/EntityFloatingItem.java +++ b/src/main/java/appeng/entity/EntityFloatingItem.java @@ -18,62 +18,54 @@ package appeng.entity; - import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; // This is not supposed to ever spawn on the server-side -public final class EntityFloatingItem extends AEBaseEntityItem -{ +public final class EntityFloatingItem extends AEBaseEntityItem { - public static EntityType TYPE; + public static EntityType TYPE; - private ICanDie parent; - private int superDeath = 0; - private float progress = 0; + private ICanDie parent; + private int superDeath = 0; + private float progress = 0; - public EntityFloatingItem(EntityType entityType, World world) { - super(entityType, world); - } + public EntityFloatingItem(EntityType entityType, World world) { + super(entityType, world); + } - public EntityFloatingItem(final ICanDie parent, final World world, final double x, final double y, final double z, final ItemStack stack ) - { - super( TYPE, world, x, y, z, stack ); - this.setMotion( 0, 0, 0 ); - this.rotationYaw = 0; - this.parent = parent; - } + public EntityFloatingItem(final ICanDie parent, final World world, final double x, final double y, final double z, + final ItemStack stack) { + super(TYPE, world, x, y, z, stack); + this.setMotion(0, 0, 0); + this.rotationYaw = 0; + this.parent = parent; + } - @Override - public void tick() - { - if( !this.removed && this.parent.isDead() ) - { - this.remove(); - } + @Override + public void tick() { + if (!this.removed && this.parent.isDead()) { + this.remove(); + } - if( this.superDeath > 100 ) - { - this.remove(); - } - this.superDeath++; + if (this.superDeath > 100) { + this.remove(); + } + this.superDeath++; - this.setNoDespawn(); - } + this.setNoDespawn(); + } - public void setProgress( final float progress ) - { - this.progress = progress; - if( this.progress > 0.99 ) - { - this.remove(); - } - } + public void setProgress(final float progress) { + this.progress = progress; + if (this.progress > 0.99) { + this.remove(); + } + } - float getProgress() - { - return this.progress; - } + float getProgress() { + return this.progress; + } } diff --git a/src/main/java/appeng/entity/EntityGrowingCrystal.java b/src/main/java/appeng/entity/EntityGrowingCrystal.java index 07318c309..7e623ae8b 100644 --- a/src/main/java/appeng/entity/EntityGrowingCrystal.java +++ b/src/main/java/appeng/entity/EntityGrowingCrystal.java @@ -18,8 +18,6 @@ package appeng.entity; - -import appeng.items.misc.ItemCrystalSeed; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityType; @@ -31,185 +29,157 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; +import appeng.api.features.AEFeature; import appeng.api.implementations.items.IGrowableCrystal; import appeng.api.implementations.tiles.ICrystalGrowthAccelerator; import appeng.client.EffectType; import appeng.core.AEConfig; import appeng.core.AppEng; -import appeng.api.features.AEFeature; +import appeng.items.misc.ItemCrystalSeed; import appeng.util.Platform; +public final class EntityGrowingCrystal extends AEBaseEntityItem { -public final class EntityGrowingCrystal extends AEBaseEntityItem -{ + public static EntityType TYPE; - public static EntityType TYPE; + private int progress_1000 = 0; - private int progress_1000 = 0; + public EntityGrowingCrystal(EntityType type, World world) { + super(type, world); + } - public EntityGrowingCrystal(EntityType type, World world) { - super(type, world); - } + public EntityGrowingCrystal(final World w, final double x, final double y, final double z, final ItemStack is) { + super(TYPE, w, x, y, z, is); + this.setNoDespawn(); + } - public EntityGrowingCrystal(final World w, final double x, final double y, final double z, final ItemStack is ) - { - super( TYPE, w, x, y, z, is ); - this.setNoDespawn(); - } + @Override + public void tick() { + super.tick(); - @Override - public void tick() - { - super.tick(); + if (!AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) { + return; + } - if( !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) ) - { - return; - } + final ItemStack is = this.getItem(); + final Item gc = is.getItem(); - final ItemStack is = this.getItem(); - final Item gc = is.getItem(); + if (gc instanceof IGrowableCrystal) // if it changes this just stops being an issue... + { + final int j = MathHelper.floor(this.getPosX()); + final int i = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D); + final int k = MathHelper.floor(this.getPosZ()); - if( gc instanceof IGrowableCrystal ) // if it changes this just stops being an issue... - { - final int j = MathHelper.floor( this.getPosX() ); - final int i = MathHelper.floor( ( this.getBoundingBox().minY + this.getBoundingBox().maxY ) / 2.0D ); - final int k = MathHelper.floor( this.getPosZ() ); + final BlockState state = this.world.getBlockState(new BlockPos(j, i, k)); + final Material mat = state.getMaterial(); + final IGrowableCrystal cry = (IGrowableCrystal) is.getItem(); - final BlockState state = this.world.getBlockState( new BlockPos( j, i, k ) ); - final Material mat = state.getMaterial(); - final IGrowableCrystal cry = (IGrowableCrystal) is.getItem(); + final float multiplier = cry.getMultiplier(state.getBlock(), mat); + final int speed = (int) Math.max(1, this.getSpeed(j, i, k) * multiplier); - final float multiplier = cry.getMultiplier( state.getBlock(), mat ); - final int speed = (int) Math.max( 1, this.getSpeed( j, i, k ) * multiplier ); + final boolean isClient = Platform.isClient(); - final boolean isClient = Platform.isClient(); + if (mat.isLiquid()) { + if (isClient) { + this.progress_1000++; + } else { + this.progress_1000 += speed; + } + } else { + this.progress_1000 = 0; + } - if( mat.isLiquid() ) - { - if( isClient ) - { - this.progress_1000++; - } - else - { - this.progress_1000 += speed; - } - } - else - { - this.progress_1000 = 0; - } + if (isClient) { + int len = 40; - if( isClient ) - { - int len = 40; + if (speed > 2) { + len = 20; + } - if( speed > 2 ) - { - len = 20; - } + if (speed > 90) { + len = 15; + } - if( speed > 90 ) - { - len = 15; - } + if (speed > 150) { + len = 10; + } - if( speed > 150 ) - { - len = 10; - } + if (speed > 240) { + len = 7; + } - if( speed > 240 ) - { - len = 7; - } + if (speed > 360) { + len = 3; + } - if( speed > 360 ) - { - len = 3; - } + if (speed > 500) { + len = 1; + } - if( speed > 500 ) - { - len = 1; - } + if (this.progress_1000 >= len) { + this.progress_1000 = 0; + AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2, + this.getPosZ(), null); + } + } else { + if (this.progress_1000 > 1000) { + this.progress_1000 -= 1000; + // We need to copy the stack or the change detection will not work and not sync + // this new stack to the client + ItemStack newItem = cry.triggerGrowth(is.copy()); + this.setItem(newItem); + } + } + } + } - if( this.progress_1000 >= len ) - { - this.progress_1000 = 0; - AppEng.proxy.spawnEffect( EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2, this.getPosZ(), null ); - } - } - else - { - if( this.progress_1000 > 1000 ) - { - this.progress_1000 -= 1000; - // We need to copy the stack or the change detection will not work and not sync - // this new stack to the client - ItemStack newItem = cry.triggerGrowth(is.copy()); - this.setItem(newItem); - } - } - } - } + private int getSpeed(final int x, final int y, final int z) { + final int per = 80; + final float mul = 0.3f; - private int getSpeed( final int x, final int y, final int z ) - { - final int per = 80; - final float mul = 0.3f; + int qty = 0; - int qty = 0; + if (this.isAccelerated(x + 1, y, z)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x + 1, y, z ) ) - { - qty += per + qty * mul; - } + if (this.isAccelerated(x, y + 1, z)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x, y + 1, z ) ) - { - qty += per + qty * mul; - } + if (this.isAccelerated(x, y, z + 1)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x, y, z + 1 ) ) - { - qty += per + qty * mul; - } + if (this.isAccelerated(x - 1, y, z)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x - 1, y, z ) ) - { - qty += per + qty * mul; - } + if (this.isAccelerated(x, y - 1, z)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x, y - 1, z ) ) - { - qty += per + qty * mul; - } + if (this.isAccelerated(x, y, z - 1)) { + qty += per + qty * mul; + } - if( this.isAccelerated( x, y, z - 1 ) ) - { - qty += per + qty * mul; - } + return qty; + } - return qty; - } + private boolean isAccelerated(final int x, final int y, final int z) { + final TileEntity te = this.world.getTileEntity(new BlockPos(x, y, z)); - private boolean isAccelerated( final int x, final int y, final int z ) - { - final TileEntity te = this.world.getTileEntity( new BlockPos( x, y, z ) ); + return te instanceof ICrystalGrowthAccelerator && ((ICrystalGrowthAccelerator) te).isPowered(); + } - return te instanceof ICrystalGrowthAccelerator && ( (ICrystalGrowthAccelerator) te ).isPowered(); - } - - // Don't let seeds "float" on water surface - @Override - protected void applyFloatMotion() { - ItemStack item = getItem(); - if (item.getItem() instanceof ItemCrystalSeed) { - return; - } - super.applyFloatMotion(); - } + // Don't let seeds "float" on water surface + @Override + protected void applyFloatMotion() { + ItemStack item = getItem(); + if (item.getItem() instanceof ItemCrystalSeed) { + return; + } + super.applyFloatMotion(); + } } diff --git a/src/main/java/appeng/entity/EntitySingularity.java b/src/main/java/appeng/entity/EntitySingularity.java index fed2dfd98..2e35dc1ce 100644 --- a/src/main/java/appeng/entity/EntitySingularity.java +++ b/src/main/java/appeng/entity/EntitySingularity.java @@ -18,7 +18,6 @@ package appeng.entity; - import java.util.Date; import java.util.List; @@ -33,104 +32,86 @@ import net.minecraft.world.World; import appeng.api.AEApi; import appeng.api.definitions.IMaterials; -import appeng.core.AEConfig; import appeng.api.features.AEFeature; +import appeng.core.AEConfig; import appeng.helpers.Reflected; import appeng.util.Platform; +public final class EntitySingularity extends AEBaseEntityItem { -public final class EntitySingularity extends AEBaseEntityItem -{ + public static EntityType TYPE; - public static EntityType TYPE; + private static int randTickSeed = 0; - private static int randTickSeed = 0; + public EntitySingularity(EntityType entityType, final World w) { + super(entityType, w); + } - public EntitySingularity(EntityType entityType, final World w ) - { - super( entityType, w ); - } + public EntitySingularity(final World w, final double x, final double y, final double z, final ItemStack is) { + super(TYPE, w, x, y, z, is); + } - public EntitySingularity( final World w, final double x, final double y, final double z, final ItemStack is ) - { - super( TYPE, w, x, y, z, is ); - } + @Override + public boolean attackEntityFrom(final DamageSource src, final float dmg) { + if (src.isExplosion()) { + this.doExplosion(); + return false; + } - @Override - public boolean attackEntityFrom( final DamageSource src, final float dmg ) - { - if( src.isExplosion() ) - { - this.doExplosion(); - return false; - } + return super.attackEntityFrom(src, dmg); + } - return super.attackEntityFrom( src, dmg ); - } + private void doExplosion() { + if (Platform.isClient()) { + return; + } - private void doExplosion() - { - if( Platform.isClient() ) - { - return; - } + if (!AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) { + return; + } - if( !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) ) - { - return; - } + final ItemStack item = this.getItem(); - final ItemStack item = this.getItem(); + final IMaterials materials = AEApi.instance().definitions().materials(); - final IMaterials materials = AEApi.instance().definitions().materials(); + if (materials.singularity().isSameAs(item)) { + final AxisAlignedBB region = new AxisAlignedBB(this.getPosX() - 4, this.getPosY() - 4, this.getPosZ() - 4, + this.getPosX() + 4, this.getPosY() + 4, this.getPosZ() + 4); + final List l = this.getCheckedEntitiesWithinAABBExcludingEntity(region); - if( materials.singularity().isSameAs( item ) ) - { - final AxisAlignedBB region = new AxisAlignedBB( this.getPosX() - 4, this.getPosY() - 4, this.getPosZ() - 4, this.getPosX() + 4, this - .getPosY() + 4, this.getPosZ() + 4 ); - final List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); + for (final Entity e : l) { + if (e instanceof ItemEntity) { + final ItemStack other = ((ItemEntity) e).getItem(); + if (!other.isEmpty()) { + boolean matches = false; - for( final Entity e : l ) - { - if( e instanceof ItemEntity ) - { - final ItemStack other = ( (ItemEntity) e ).getItem(); - if( !other.isEmpty() ) - { - boolean matches = false; + if (matches) { + while (item.getCount() > 0 && other.getCount() > 0) { + other.grow(-1); + ; + if (other.getCount() == 0) { + e.remove(); + } - if( matches ) - { - while( item.getCount() > 0 && other.getCount() > 0 ) - { - other.grow( -1 ); - ; - if( other.getCount() == 0 ) - { - e.remove(); - } + materials.qESingularity().maybeStack(2).ifPresent(singularityStack -> { + final CompoundNBT cmp = singularityStack.getOrCreateTag(); + cmp.putLong("freq", (new Date()).getTime() * 100 + (randTickSeed) % 100); + randTickSeed++; + item.grow(-1); - materials.qESingularity().maybeStack( 2 ).ifPresent( singularityStack -> - { - final CompoundNBT cmp = singularityStack.getOrCreateTag(); - cmp.putLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 ); - randTickSeed++; - item.grow( -1 ); + final EntitySingularity entity = new EntitySingularity(this.world, this.getPosX(), + this.getPosY(), this.getPosZ(), singularityStack); + this.world.addEntity(entity); + }); + } - final EntitySingularity entity = new EntitySingularity( this.world, this.getPosX(), this.getPosY(), this - .getPosZ(), singularityStack ); - this.world.addEntity( entity ); - } ); - } - - if( item.getCount() <= 0 ) - { - this.remove(); - } - } - } - } - } - } - } + if (item.getCount() <= 0) { + this.remove(); + } + } + } + } + } + } + } } diff --git a/src/main/java/appeng/entity/EntityTinyTNTPrimed.java b/src/main/java/appeng/entity/EntityTinyTNTPrimed.java index 9e47d7499..a174b8204 100644 --- a/src/main/java/appeng/entity/EntityTinyTNTPrimed.java +++ b/src/main/java/appeng/entity/EntityTinyTNTPrimed.java @@ -18,7 +18,6 @@ package appeng.entity; - import java.util.List; import net.minecraft.block.Block; @@ -42,161 +41,143 @@ import net.minecraft.world.Explosion.Mode; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; -import appeng.core.AEConfig; -import appeng.core.AppEng; import appeng.api.AEApi; import appeng.api.features.AEFeature; +import appeng.core.AEConfig; +import appeng.core.AppEng; import appeng.core.sync.packets.PacketMockExplosion; import appeng.helpers.Reflected; import appeng.util.Platform; +public final class EntityTinyTNTPrimed extends TNTEntity implements IEntityAdditionalSpawnData { -public final class EntityTinyTNTPrimed extends TNTEntity implements IEntityAdditionalSpawnData -{ + public static EntityType TYPE; - public static EntityType TYPE; + public EntityTinyTNTPrimed(EntityType type, World worldIn) { + super(type, worldIn); + this.preventEntitySpawning = true; + } - public EntityTinyTNTPrimed( EntityType type, World worldIn ) - { - super( type, worldIn ); - this.preventEntitySpawning = true; - } + public EntityTinyTNTPrimed(final World w, final double x, final double y, final double z, + final LivingEntity igniter) { + super(w, x, y, z, igniter); + } - public EntityTinyTNTPrimed( final World w, final double x, final double y, final double z, final LivingEntity igniter ) - { - super( w, x, y, z, igniter ); - } + /** + * Called to update the entity's position/logic. + */ + @Override + public void tick() { + this.handleWaterMovement(); - /** - * Called to update the entity's position/logic. - */ - @Override - public void tick() - { - this.handleWaterMovement(); + this.prevPosX = this.getPosX(); + this.prevPosY = this.getPosY(); + this.prevPosZ = this.getPosZ(); + this.setMotion(this.getMotion().subtract(0, 0.03999999910593033D, 0)); + this.move(MoverType.SELF, this.getMotion()); + this.setMotion(this.getMotion().mul(0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D)); - this.prevPosX = this.getPosX(); - this.prevPosY = this.getPosY(); - this.prevPosZ = this.getPosZ(); - this.setMotion( this.getMotion().subtract( 0, 0.03999999910593033D, 0 ) ); - this.move( MoverType.SELF, this.getMotion() ); - this.setMotion( this.getMotion().mul( 0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D ) ); + if (this.onGround) { + this.setMotion(this.getMotion().mul(0.699999988079071D, 0.699999988079071D, -0.5D)); + } - if( this.onGround ) - { - this.setMotion( this.getMotion().mul( 0.699999988079071D, 0.699999988079071D, -0.5D ) ); - } + if (this.isInWater() && Platform.isServer()) // put out the fuse. + { + AEApi.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> { + final ItemEntity item = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), + tntStack); - if( this.isInWater() && Platform.isServer() ) // put out the fuse. - { - AEApi.instance().definitions().blocks().tinyTNT().maybeStack( 1 ).ifPresent( tntStack -> - { - final ItemEntity item = new ItemEntity( this.world, this.getPosX(), this.getPosY(), this.getPosZ(), tntStack ); + item.setMotion(this.getMotion()); + item.prevPosX = this.prevPosX; + item.prevPosY = this.prevPosY; + item.prevPosZ = this.prevPosZ; - item.setMotion( this.getMotion() ); - item.prevPosX = this.prevPosX; - item.prevPosY = this.prevPosY; - item.prevPosZ = this.prevPosZ; + this.world.addEntity(item); + this.remove(); + }); + } - this.world.addEntity( item ); - this.remove(); - } ); - } + if (this.getFuse() <= 0) { + this.remove(); - if( this.getFuse() <= 0 ) - { - this.remove(); + if (!this.world.isRemote) { + this.explode(); + } + } else { + this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, + 0.0D); + } + this.setFuse(this.getFuse() - 1); + } - if( !this.world.isRemote ) - { - this.explode(); - } - } - else - { - this.world.addParticle( ParticleTypes.SMOKE, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D ); - } - this.setFuse( this.getFuse() - 1 ); - } + // override :P + @Override + protected void explode() { + this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, + SoundCategory.BLOCKS, 4.0F, + (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 32.9F); - // override :P - @Override - protected void explode() - { - this.world.playSound( null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, - ( 1.0F + ( this.world.rand.nextFloat() - this.world.rand.nextFloat() ) * 0.2F ) * 32.9F ); + if (this.isInWater()) { + return; + } - if( this.isInWater() ) - { - return; - } + final Explosion ex = new Explosion(this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f, + false, Mode.BREAK); + final AxisAlignedBB area = new AxisAlignedBB(this.getPosX() - 1.5, this.getPosY() - 1.5f, this.getPosZ() - 1.5, + this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5); + final List list = this.world.getEntitiesWithinAABBExcludingEntity(this, area); - final Explosion ex = new Explosion( this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f, false, Mode.BREAK ); - final AxisAlignedBB area = new AxisAlignedBB( this.getPosX() - 1.5, this.getPosY() - 1.5f, this - .getPosZ() - 1.5, this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5 ); - final List list = this.world.getEntitiesWithinAABBExcludingEntity( this, area ); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, ex, list, 0.2f * 2d); - net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate( this.world, ex, list, 0.2f * 2d ); + for (final Entity e : list) { + e.attackEntityFrom(DamageSource.causeExplosionDamage(ex), 6); + } - for( final Entity e : list ) - { - e.attackEntityFrom( DamageSource.causeExplosionDamage( ex ), 6 ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.TINY_TNT_BLOCK_DAMAGE)) { + this.setPosition(this.getPosX(), this.getPosY() - 0.25, this.getPosZ()); - if( AEConfig.instance().isFeatureEnabled( AEFeature.TINY_TNT_BLOCK_DAMAGE ) ) - { - this.setPosition( this.getPosX(), this.getPosY() - 0.25, this.getPosZ() ); + for (int x = (int) (this.getPosX() - 2); x <= this.getPosX() + 2; x++) { + for (int y = (int) (this.getPosY() - 2); y <= this.getPosY() + 2; y++) { + for (int z = (int) (this.getPosZ() - 2); z <= this.getPosZ() + 2; z++) { + final BlockPos point = new BlockPos(x, y, z); + final BlockState state = this.world.getBlockState(point); + final Block block = state.getBlock(); - for( int x = (int) ( this.getPosX() - 2 ); x <= this.getPosX() + 2; x++ ) - { - for( int y = (int) ( this.getPosY() - 2 ); y <= this.getPosY() + 2; y++ ) - { - for( int z = (int) ( this.getPosZ() - 2 ); z <= this.getPosZ() + 2; z++ ) - { - final BlockPos point = new BlockPos( x, y, z ); - final BlockState state = this.world.getBlockState( point ); - final Block block = state.getBlock(); + if (block != null && !block.isAir(state, this.world, point)) { + float strength = (float) (2.3f + - (((x + 0.5f) - this.getPosX()) * ((x + 0.5f) - this.getPosX()) + + ((y + 0.5f) - this.getPosY()) * ((y + 0.5f) - this.getPosY()) + + ((z + 0.5f) - this.getPosZ()) * ((z + 0.5f) - this.getPosZ()))); - if( block != null && !block.isAir( state, this.world, point ) ) - { - float strength = (float) ( 2.3f - ( ( ( x + 0.5f ) - this.getPosX() ) * ( ( x + 0.5f ) - this - .getPosX() ) + ( ( y + 0.5f ) - this.getPosY() ) * ( ( y + 0.5f ) - this.getPosY() ) + ( ( z + 0.5f ) - this - .getPosZ() ) * ( ( z + 0.5f ) - this.getPosZ() ) ) ); + final float resistance = block.getExplosionResistance(state, this.world, point, this, ex); + strength -= (resistance + 0.3F) * 0.11f; - final float resistance = block.getExplosionResistance( state, this.world, point, this, ex ); - strength -= ( resistance + 0.3F ) * 0.11f; + if (strength > 0.01) { + if (block.getMaterial(state) != Material.AIR) { + if (block.canDropFromExplosion(ex)) { + block.spawnDrops(state, this.world, point); + } - if( strength > 0.01 ) - { - if( block.getMaterial( state ) != Material.AIR ) - { - if( block.canDropFromExplosion( ex ) ) - { - block.spawnDrops( state, this.world, point ); - } + block.onBlockExploded(null, this.world, point, ex); + } + } + } + } + } + } + } - block.onBlockExploded( null, this.world, point, ex ); - } - } - } - } - } - } - } + AppEng.proxy.sendToAllNearExcept(null, this.getPosX(), this.getPosY(), this.getPosZ(), 64, this.world, + new PacketMockExplosion(this.getPosX(), this.getPosY(), this.getPosZ())); + } - AppEng.proxy.sendToAllNearExcept( null, this.getPosX(), this.getPosY(), this.getPosZ(), 64, this.world, - new PacketMockExplosion( this.getPosX(), this.getPosY(), this.getPosZ() ) ); - } + @Override + public void writeSpawnData(PacketBuffer buffer) { + buffer.writeByte(this.getFuse()); + } - @Override - public void writeSpawnData( PacketBuffer buffer ) - { - buffer.writeByte( this.getFuse() ); - } - - @Override - public void readSpawnData( PacketBuffer additionalData ) - { - this.setFuse( additionalData.readByte() ); - } + @Override + public void readSpawnData(PacketBuffer additionalData) { + this.setFuse(additionalData.readByte()); + } } diff --git a/src/main/java/appeng/entity/ICanDie.java b/src/main/java/appeng/entity/ICanDie.java index d46048724..5bba27b98 100644 --- a/src/main/java/appeng/entity/ICanDie.java +++ b/src/main/java/appeng/entity/ICanDie.java @@ -18,10 +18,8 @@ package appeng.entity; +public interface ICanDie { -public interface ICanDie -{ - - public boolean isDead(); + public boolean isDead(); } diff --git a/src/main/java/appeng/entity/RenderFloatingItem.java b/src/main/java/appeng/entity/RenderFloatingItem.java index c8f27274d..7ef0ac69b 100644 --- a/src/main/java/appeng/entity/RenderFloatingItem.java +++ b/src/main/java/appeng/entity/RenderFloatingItem.java @@ -18,7 +18,6 @@ package appeng.entity; - import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; @@ -30,45 +29,36 @@ import net.minecraft.item.BlockItem; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +@OnlyIn(Dist.CLIENT) +public class RenderFloatingItem extends ItemRenderer { -@OnlyIn( Dist.CLIENT ) -public class RenderFloatingItem extends ItemRenderer -{ + public RenderFloatingItem(final EntityRendererManager manager) { + super(manager, Minecraft.getInstance().getItemRenderer()); + this.shadowOpaque = 0.0F; + } - public RenderFloatingItem( final EntityRendererManager manager ) - { - super( manager, Minecraft.getInstance().getItemRenderer() ); - this.shadowOpaque = 0.0F; - } + @Override + public void render(ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack mStack, + IRenderTypeBuffer buffers, int packedLightIn) { + if (entityIn instanceof EntityFloatingItem) { + final EntityFloatingItem efi = (EntityFloatingItem) entityIn; + if (efi.getProgress() > 0.0) { + mStack.push(); - @Override - public void render( ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack mStack, IRenderTypeBuffer buffers, int packedLightIn ) - { - if( entityIn instanceof EntityFloatingItem ) - { - final EntityFloatingItem efi = (EntityFloatingItem) entityIn; - if( efi.getProgress() > 0.0 ) - { - mStack.push(); + if (!(efi.getItem().getItem() instanceof BlockItem)) { + mStack.translate(0, -0.3f, 0); + } else { + mStack.translate(0, -0.2f, 0); + } - if( !( efi.getItem().getItem() instanceof BlockItem ) ) - { - mStack.translate( 0, -0.3f, 0 ); - } - else - { - mStack.translate( 0, -0.2f, 0 ); - } + super.render(entityIn, entityYaw, 0, mStack, buffers, packedLightIn); + mStack.pop(); + } + } + } - super.render( entityIn, entityYaw, 0, mStack, buffers, packedLightIn ); - mStack.pop(); - } - } - } - - @Override - public boolean shouldBob() - { - return false; - } + @Override + public boolean shouldBob() { + return false; + } } diff --git a/src/main/java/appeng/entity/RenderTinyTNTPrimed.java b/src/main/java/appeng/entity/RenderTinyTNTPrimed.java index 9f737034c..682eba61a 100644 --- a/src/main/java/appeng/entity/RenderTinyTNTPrimed.java +++ b/src/main/java/appeng/entity/RenderTinyTNTPrimed.java @@ -18,7 +18,6 @@ package appeng.entity; - import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.block.Blocks; @@ -34,58 +33,52 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +@OnlyIn(Dist.CLIENT) +public class RenderTinyTNTPrimed extends EntityRenderer { -@OnlyIn( Dist.CLIENT ) -public class RenderTinyTNTPrimed extends EntityRenderer -{ + public RenderTinyTNTPrimed(final EntityRendererManager manager) { + super(manager); + this.shadowSize = 0.5F; + } - public RenderTinyTNTPrimed( final EntityRendererManager manager ) - { - super( manager ); - this.shadowSize = 0.5F; - } + @Override + public void render(EntityTinyTNTPrimed tnt, float entityYaw, float partialTicks, MatrixStack mStack, + IRenderTypeBuffer buffers, int packedLight) { + final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + mStack.push(); + mStack.translate(0, 0.25F, 0); + float f2; - @Override - public void render( EntityTinyTNTPrimed tnt, float entityYaw, float partialTicks, MatrixStack mStack, IRenderTypeBuffer buffers, int packedLight ) - { - final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); - mStack.push(); - mStack.translate( 0, 0.25F, 0 ); - float f2; + if (tnt.getFuse() - partialTicks + 1.0F < 10.0F) { + f2 = 1.0F - (tnt.getFuse() - partialTicks + 1.0F) / 10.0F; - if( tnt.getFuse() - partialTicks + 1.0F < 10.0F ) - { - f2 = 1.0F - ( tnt.getFuse() - partialTicks + 1.0F ) / 10.0F; + if (f2 < 0.0F) { + f2 = 0.0F; + } - if( f2 < 0.0F ) - { - f2 = 0.0F; - } + if (f2 > 1.0F) { + f2 = 1.0F; + } - if( f2 > 1.0F ) - { - f2 = 1.0F; - } + f2 *= f2; + f2 *= f2; + final float f3 = 1.0F + f2 * 0.3F; + mStack.scale(f3, f3, f3); + } - f2 *= f2; - f2 *= f2; - final float f3 = 1.0F + f2 * 0.3F; - mStack.scale( f3, f3, f3 ); - } + mStack.scale(0.5f, 0.5f, 0.5f); + f2 = (1.0F - (tnt.getFuse() - partialTicks + 1.0F) / 100.0F) * 0.8F; + mStack.rotate(Vector3f.YP.rotationDegrees(-90.0F)); + mStack.translate(-0.5D, -0.5D, 0.5D); + mStack.rotate(Vector3f.YP.rotationDegrees(90.0F)); + TNTMinecartRenderer.renderTntFlash(Blocks.TNT.getDefaultState(), mStack, buffers, packedLight, + tnt.getFuse() / 5 % 2 == 0); + mStack.pop(); + super.render(tnt, entityYaw, partialTicks, mStack, buffers, packedLight); + } - mStack.scale( 0.5f, 0.5f, 0.5f ); - f2 = ( 1.0F - ( tnt.getFuse() - partialTicks + 1.0F ) / 100.0F ) * 0.8F; - mStack.rotate( Vector3f.YP.rotationDegrees( -90.0F ) ); - mStack.translate( -0.5D, -0.5D, 0.5D ); - mStack.rotate( Vector3f.YP.rotationDegrees( 90.0F ) ); - TNTMinecartRenderer.renderTntFlash( Blocks.TNT.getDefaultState(), mStack, buffers, packedLight, tnt.getFuse() / 5 % 2 == 0 ); - mStack.pop(); - super.render( tnt, entityYaw, partialTicks, mStack, buffers, packedLight ); - } - - @Override - public ResourceLocation getEntityTexture( final EntityTinyTNTPrimed entity ) - { - return AtlasTexture.LOCATION_BLOCKS_TEXTURE; - } + @Override + public ResourceLocation getEntityTexture(final EntityTinyTNTPrimed entity) { + return AtlasTexture.LOCATION_BLOCKS_TEXTURE; + } } diff --git a/src/main/java/appeng/facade/FacadeContainer.java b/src/main/java/appeng/facade/FacadeContainer.java index 234c306da..36e8a42fd 100644 --- a/src/main/java/appeng/facade/FacadeContainer.java +++ b/src/main/java/appeng/facade/FacadeContainer.java @@ -18,7 +18,6 @@ package appeng.facade; - import java.io.IOException; import java.util.Optional; @@ -34,179 +33,146 @@ import appeng.api.util.AEPartLocation; import appeng.items.parts.ItemFacade; import appeng.parts.CableBusStorage; +public class FacadeContainer implements IFacadeContainer { -public class FacadeContainer implements IFacadeContainer -{ + private final int facades = 6; + private final CableBusStorage storage; - private final int facades = 6; - private final CableBusStorage storage; + public FacadeContainer(final CableBusStorage cbs) { + this.storage = cbs; + } - public FacadeContainer( final CableBusStorage cbs ) - { - this.storage = cbs; - } + @Override + public boolean addFacade(final IFacadePart a) { + if (this.getFacade(a.getSide()) == null) { + this.storage.setFacade(a.getSide().ordinal(), a); + return true; + } + return false; + } - @Override - public boolean addFacade( final IFacadePart a ) - { - if( this.getFacade( a.getSide() ) == null ) - { - this.storage.setFacade( a.getSide().ordinal(), a ); - return true; - } - return false; - } + @Override + public void removeFacade(final IPartHost host, final AEPartLocation side) { + if (side != null && side != AEPartLocation.INTERNAL) { + if (this.storage.getFacade(side.ordinal()) != null) { + this.storage.setFacade(side.ordinal(), null); + if (host != null) { + host.markForUpdate(); + } + } + } + } - @Override - public void removeFacade( final IPartHost host, final AEPartLocation side ) - { - if( side != null && side != AEPartLocation.INTERNAL ) - { - if( this.storage.getFacade( side.ordinal() ) != null ) - { - this.storage.setFacade( side.ordinal(), null ); - if( host != null ) - { - host.markForUpdate(); - } - } - } - } + @Override + public IFacadePart getFacade(final AEPartLocation s) { + return this.storage.getFacade(s.ordinal()); + } - @Override - public IFacadePart getFacade( final AEPartLocation s ) - { - return this.storage.getFacade( s.ordinal() ); - } + @Override + public void rotateLeft() { + final IFacadePart[] newFacades = new FacadePart[6]; - @Override - public void rotateLeft() - { - final IFacadePart[] newFacades = new FacadePart[6]; + newFacades[AEPartLocation.UP.ordinal()] = this.storage.getFacade(AEPartLocation.UP.ordinal()); + newFacades[AEPartLocation.DOWN.ordinal()] = this.storage.getFacade(AEPartLocation.DOWN.ordinal()); - newFacades[AEPartLocation.UP.ordinal()] = this.storage.getFacade( AEPartLocation.UP.ordinal() ); - newFacades[AEPartLocation.DOWN.ordinal()] = this.storage.getFacade( AEPartLocation.DOWN.ordinal() ); + newFacades[AEPartLocation.EAST.ordinal()] = this.storage.getFacade(AEPartLocation.NORTH.ordinal()); + newFacades[AEPartLocation.SOUTH.ordinal()] = this.storage.getFacade(AEPartLocation.EAST.ordinal()); - newFacades[AEPartLocation.EAST.ordinal()] = this.storage.getFacade( AEPartLocation.NORTH.ordinal() ); - newFacades[AEPartLocation.SOUTH.ordinal()] = this.storage.getFacade( AEPartLocation.EAST.ordinal() ); + newFacades[AEPartLocation.WEST.ordinal()] = this.storage.getFacade(AEPartLocation.SOUTH.ordinal()); + newFacades[AEPartLocation.NORTH.ordinal()] = this.storage.getFacade(AEPartLocation.WEST.ordinal()); - newFacades[AEPartLocation.WEST.ordinal()] = this.storage.getFacade( AEPartLocation.SOUTH.ordinal() ); - newFacades[AEPartLocation.NORTH.ordinal()] = this.storage.getFacade( AEPartLocation.WEST.ordinal() ); + for (int x = 0; x < this.facades; x++) { + this.storage.setFacade(x, newFacades[x]); + } + } - for( int x = 0; x < this.facades; x++ ) - { - this.storage.setFacade( x, newFacades[x] ); - } - } + @Override + public void writeToNBT(final CompoundNBT c) { + for (int x = 0; x < this.facades; x++) { + if (this.storage.getFacade(x) != null) { + final CompoundNBT data = new CompoundNBT(); + this.storage.getFacade(x).getItemStack().write(data); + c.put("facade:" + x, data); + } + } + } - @Override - public void writeToNBT( final CompoundNBT c ) - { - for( int x = 0; x < this.facades; x++ ) - { - if( this.storage.getFacade( x ) != null ) - { - final CompoundNBT data = new CompoundNBT(); - this.storage.getFacade( x ).getItemStack().write( data ); - c.put( "facade:" + x, data ); - } - } - } + @Override + public boolean readFromStream(final PacketBuffer out) throws IOException { + final int facadeSides = out.readByte(); - @Override - public boolean readFromStream( final PacketBuffer out ) throws IOException - { - final int facadeSides = out.readByte(); + boolean changed = false; - boolean changed = false; + for (int x = 0; x < this.facades; x++) { + final AEPartLocation side = AEPartLocation.fromOrdinal(x); + final int ix = (1 << x); + if ((facadeSides & ix) == ix) { + final int id = Math.abs(out.readInt()); - for( int x = 0; x < this.facades; x++ ) - { - final AEPartLocation side = AEPartLocation.fromOrdinal( x ); - final int ix = ( 1 << x ); - if( ( facadeSides & ix ) == ix ) - { - final int id = Math.abs( out.readInt() ); + Optional maybeFacadeItem = AEApi.instance().definitions().items().facade() + .maybeItem(); + if (maybeFacadeItem.isPresent()) { + final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get(); + final ItemStack facade = ifa.createFromID(id); + if (facade != null) { + changed = changed || this.storage.getFacade(x) == null; + this.storage.setFacade(x, ifa.createPartFromItemStack(facade, side)); + } + } + } else { + changed = changed || this.storage.getFacade(x) != null; + this.storage.setFacade(x, null); + } + } - Optional maybeFacadeItem = AEApi.instance().definitions().items().facade().maybeItem(); - if( maybeFacadeItem.isPresent() ) - { - final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get(); - final ItemStack facade = ifa.createFromID( id ); - if( facade != null ) - { - changed = changed || this.storage.getFacade( x ) == null; - this.storage.setFacade( x, ifa.createPartFromItemStack( facade, side ) ); - } - } - } - else - { - changed = changed || this.storage.getFacade( x ) != null; - this.storage.setFacade( x, null ); - } - } + return changed; + } - return changed; - } + @Override + public void readFromNBT(final CompoundNBT c) { + for (int x = 0; x < this.facades; x++) { + this.storage.setFacade(x, null); - @Override - public void readFromNBT( final CompoundNBT c ) - { - for( int x = 0; x < this.facades; x++ ) - { - this.storage.setFacade( x, null ); + final CompoundNBT t = c.getCompound("facade:" + x); + if (t != null) { + final ItemStack is = ItemStack.read(t); + if (!is.isEmpty()) { + final net.minecraft.item.Item i = is.getItem(); + if (i instanceof IFacadeItem) { + this.storage.setFacade(x, + ((IFacadeItem) i).createPartFromItemStack(is, AEPartLocation.fromOrdinal(x))); + } + } + } + } + } - final CompoundNBT t = c.getCompound( "facade:" + x ); - if( t != null ) - { - final ItemStack is = ItemStack.read( t ); - if( !is.isEmpty() ) - { - final net.minecraft.item.Item i = is.getItem(); - if( i instanceof IFacadeItem ) - { - this.storage.setFacade( x, ( (IFacadeItem) i ).createPartFromItemStack( is, AEPartLocation.fromOrdinal( x ) ) ); - } - } - } - } - } + @Override + public void writeToStream(final PacketBuffer out) throws IOException { + int facadeSides = 0; + for (int x = 0; x < this.facades; x++) { + if (this.getFacade(AEPartLocation.fromOrdinal(x)) != null) { + facadeSides |= (1 << x); + } + } + out.writeByte((byte) facadeSides); - @Override - public void writeToStream( final PacketBuffer out ) throws IOException - { - int facadeSides = 0; - for( int x = 0; x < this.facades; x++ ) - { - if( this.getFacade( AEPartLocation.fromOrdinal( x ) ) != null ) - { - facadeSides |= ( 1 << x ); - } - } - out.writeByte( (byte) facadeSides ); + for (int x = 0; x < this.facades; x++) { + final IFacadePart part = this.getFacade(AEPartLocation.fromOrdinal(x)); + if (part != null) { + final int itemID = net.minecraft.item.Item.getIdFromItem(part.getItem()); + out.writeInt(itemID * (part.notAEFacade() ? -1 : 1)); + } + } + } - for( int x = 0; x < this.facades; x++ ) - { - final IFacadePart part = this.getFacade( AEPartLocation.fromOrdinal( x ) ); - if( part != null ) - { - final int itemID = net.minecraft.item.Item.getIdFromItem( part.getItem() ); - out.writeInt( itemID * ( part.notAEFacade() ? -1 : 1 ) ); - } - } - } - - @Override - public boolean isEmpty() - { - for( int x = 0; x < this.facades; x++ ) - { - if( this.storage.getFacade( x ) != null ) - { - return false; - } - } - return true; - } + @Override + public boolean isEmpty() { + for (int x = 0; x < this.facades; x++) { + if (this.storage.getFacade(x) != null) { + return false; + } + } + return true; + } } diff --git a/src/main/java/appeng/facade/FacadePart.java b/src/main/java/appeng/facade/FacadePart.java index fbce6decf..c5b9ac397 100644 --- a/src/main/java/appeng/facade/FacadePart.java +++ b/src/main/java/appeng/facade/FacadePart.java @@ -18,7 +18,6 @@ package appeng.facade; - import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -33,119 +32,98 @@ import appeng.api.parts.IFacadePart; import appeng.api.parts.IPartCollisionHelper; import appeng.api.util.AEPartLocation; +public class FacadePart implements IFacadePart, IBoxProvider { -public class FacadePart implements IFacadePart, IBoxProvider -{ + private final ItemStack facade; + private final AEPartLocation side; - private final ItemStack facade; - private final AEPartLocation side; + public FacadePart(final ItemStack facade, final AEPartLocation side) { + if (facade == null) { + throw new IllegalArgumentException("Facade Part constructed on null item."); + } + this.facade = facade.copy(); + this.facade.setCount(1); + this.side = side; + } - public FacadePart( final ItemStack facade, final AEPartLocation side ) - { - if( facade == null ) - { - throw new IllegalArgumentException( "Facade Part constructed on null item." ); - } - this.facade = facade.copy(); - this.facade.setCount( 1 ); - this.side = side; - } + public static boolean isFacade(final ItemStack is) { + return is.getItem() instanceof IFacadeItem; + } - public static boolean isFacade( final ItemStack is ) - { - return is.getItem() instanceof IFacadeItem; - } + @Override + public ItemStack getItemStack() { + return this.facade; + } - @Override - public ItemStack getItemStack() - { - return this.facade; - } + @Override + public void getBoxes(final IPartCollisionHelper ch, final Entity e) { + if (e instanceof LivingEntity) { + // prevent weird snag behavior + ch.addBox(0.0, 0.0, 14, 16.0, 16.0, 16.0); + } else { + // the box is 15.9 for transition planes to pick up collision events. + ch.addBox(0.0, 0.0, 14, 16.0, 16.0, 15.9); + } + } - @Override - public void getBoxes( final IPartCollisionHelper ch, final Entity e ) - { - if( e instanceof LivingEntity ) - { - // prevent weird snag behavior - ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 16.0 ); - } - else - { - // the box is 15.9 for transition planes to pick up collision events. - ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 ); - } - } + @Override + public AEPartLocation getSide() { + return this.side; + } - @Override - public AEPartLocation getSide() - { - return this.side; - } + @Override + public Item getItem() { + final ItemStack is = this.getTextureItem(); + if (is.isEmpty()) { + return Items.AIR; + } + return is.getItem(); + } - @Override - public Item getItem() - { - final ItemStack is = this.getTextureItem(); - if( is.isEmpty() ) - { - return Items.AIR; - } - return is.getItem(); - } + @Override + public boolean notAEFacade() { + return !(this.facade.getItem() instanceof IFacadeItem); + } - @Override - public boolean notAEFacade() - { - return !( this.facade.getItem() instanceof IFacadeItem ); - } + @Override + public boolean isTransparent() { + if (AEApi.instance().partHelper().getCableRenderMode().transparentFacades) { + return true; + } - @Override - public boolean isTransparent() - { - if( AEApi.instance().partHelper().getCableRenderMode().transparentFacades ) - { - return true; - } + return false; // FIXME this.getBlockState().isOpaqueCube(); + } - return false; // FIXME this.getBlockState().isOpaqueCube(); - } + @Override + public ItemStack getTextureItem() { + final Item maybeFacade = this.facade.getItem(); - @Override - public ItemStack getTextureItem() - { - final Item maybeFacade = this.facade.getItem(); + // AE Facade + if (maybeFacade instanceof IFacadeItem) { + final IFacadeItem facade = (IFacadeItem) maybeFacade; - // AE Facade - if( maybeFacade instanceof IFacadeItem ) - { - final IFacadeItem facade = (IFacadeItem) maybeFacade; + return facade.getTextureItem(this.facade); + } - return facade.getTextureItem( this.facade ); - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + public BlockState getBlockState() { + final Item maybeFacade = this.facade.getItem(); - @Override - public BlockState getBlockState() - { - final Item maybeFacade = this.facade.getItem(); + // AE Facade + if (maybeFacade instanceof IFacadeItem) { + final IFacadeItem facade = (IFacadeItem) maybeFacade; - // AE Facade - if( maybeFacade instanceof IFacadeItem ) - { - final IFacadeItem facade = (IFacadeItem) maybeFacade; + return facade.getTextureBlockState(this.facade); + } - return facade.getTextureBlockState( this.facade ); - } + return Blocks.GLASS.getDefaultState(); + } - return Blocks.GLASS.getDefaultState(); - } - - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - this.getBoxes( bch, null ); - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + this.getBoxes(bch, null); + } } diff --git a/src/main/java/appeng/facade/IFacadeItem.java b/src/main/java/appeng/facade/IFacadeItem.java index 4a179c462..7252f4de1 100644 --- a/src/main/java/appeng/facade/IFacadeItem.java +++ b/src/main/java/appeng/facade/IFacadeItem.java @@ -18,20 +18,17 @@ package appeng.facade; - import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import appeng.api.util.AEPartLocation; +public interface IFacadeItem { -public interface IFacadeItem -{ + FacadePart createPartFromItemStack(ItemStack is, AEPartLocation side); - FacadePart createPartFromItemStack( ItemStack is, AEPartLocation side ); + ItemStack getTextureItem(ItemStack is); - ItemStack getTextureItem( ItemStack is ); - - BlockState getTextureBlockState( ItemStack is ); + BlockState getTextureBlockState(ItemStack is); } diff --git a/src/main/java/appeng/fluids/block/BlockFluidInterface.java b/src/main/java/appeng/fluids/block/BlockFluidInterface.java index 2bdf2991a..6ead8a0e6 100644 --- a/src/main/java/appeng/fluids/block/BlockFluidInterface.java +++ b/src/main/java/appeng/fluids/block/BlockFluidInterface.java @@ -18,12 +18,8 @@ package appeng.fluids.block; - import javax.annotation.Nullable; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.fluids.container.ContainerFluidInterface; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -35,35 +31,32 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; import appeng.block.AEBaseTileBlock; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.tile.TileFluidInterface; import appeng.util.Platform; +public class BlockFluidInterface extends AEBaseTileBlock { + public BlockFluidInterface() { + super(defaultProps(Material.IRON)); + } -public class BlockFluidInterface extends AEBaseTileBlock -{ - public BlockFluidInterface() - { - super(defaultProps( Material.IRON )); - } + @Override + public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, + final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { + if (p.isCrouching()) { + return ActionResultType.PASS; + } - @Override - public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) - { - if( p.isCrouching() ) - { - return ActionResultType.PASS; - } - - final TileEntity tg = this.getTileEntity( w, pos ); - if( tg != null ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidInterface.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace())); - } - return ActionResultType.SUCCESS; - } - return ActionResultType.PASS; - } + final TileEntity tg = this.getTileEntity(w, pos); + if (tg != null) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidInterface.TYPE, p, + ContainerLocator.forTileEntitySide(tg, hit.getFace())); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidFormationPlane.java b/src/main/java/appeng/fluids/client/gui/GuiFluidFormationPlane.java index 0eac89646..b535917d0 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidFormationPlane.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidFormationPlane.java @@ -1,6 +1,8 @@ package appeng.fluids.client.gui; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.client.gui.implementations.GuiUpgradeable; import appeng.client.gui.widgets.GuiTabButton; @@ -12,64 +14,52 @@ import appeng.fluids.client.gui.widgets.GuiFluidSlot; import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot; import appeng.fluids.container.ContainerFluidFormationPlane; import appeng.fluids.util.IAEFluidTank; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; +public class GuiFluidFormationPlane extends GuiUpgradeable { + public GuiFluidFormationPlane(ContainerFluidFormationPlane container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 251; + } -public class GuiFluidFormationPlane extends GuiUpgradeable -{ - public GuiFluidFormationPlane(ContainerFluidFormationPlane container, PlayerInventory playerInventory, ITextComponent title) - { - super(container, playerInventory, title); - this.ySize = 251; - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + final int xo = 8; + final int yo = 23 + 6; - final int xo = 8; - final int yo = 23 + 6; + final IAEFluidTank config = container.getFluidConfigInventory(); - final IAEFluidTank config = container.getFluidConfigInventory(); + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 9; x++) { + final int idx = y * 9 + x; + if (y < 2) { + this.guiSlots.add(new GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18)); + } else { + this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y)); + } + } + } + } - for( int y = 0; y < 7; y++ ) - { - for( int x = 0; x < 9; x++ ) - { - final int idx = y * 9 + x; - if( y < 2 ) - { - this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) ); - } - else - { - this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) ); - } - } - } - } + @Override + protected void addButtons() { + this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.itemRenderer, btn -> openPriorityGui())); + } - @Override - protected void addButtons() - { - this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + @Override + protected String getBackground() { + return "guis/storagebus.png"; + } - @Override - protected String getBackground() - { - return "guis/storagebus.png"; - } - - @Override - protected GuiText getName() - { - return GuiText.FluidFormationPlane; - } + @Override + protected GuiText getName() { + return GuiText.FluidFormationPlane; + } } diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidIO.java b/src/main/java/appeng/fluids/client/gui/GuiFluidIO.java index 5d9ce36d6..997a6e33e 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidIO.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidIO.java @@ -18,6 +18,8 @@ package appeng.fluids.client.gui; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.client.gui.implementations.GuiUpgradeable; import appeng.core.localization.GuiText; @@ -26,47 +28,40 @@ import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot; import appeng.fluids.container.ContainerFluidIO; import appeng.fluids.parts.PartFluidImportBus; import appeng.fluids.util.IAEFluidTank; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; - /** * @author BrockWS * @version rv5 - 1/05/2018 * @since rv5 1/05/2018 */ -public class GuiFluidIO extends GuiUpgradeable -{ +public class GuiFluidIO extends GuiUpgradeable { - public GuiFluidIO(ContainerFluidIO container, PlayerInventory playerInventory, ITextComponent title) - { - super(container, playerInventory, title); - } + public GuiFluidIO(ContainerFluidIO container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + } - @Override - public void init() - { - super.init(); + @Override + public void init() { + super.init(); - final IAEFluidTank inv = this.container.getFluidConfigInventory(); - final int y = 40; - final int x = 80; + final IAEFluidTank inv = this.container.getFluidConfigInventory(); + final int y = 40; + final int x = 80; - this.guiSlots.add( new GuiFluidSlot( inv, 0, 0, x, y ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 1, 1, 1, x, y, -1, 0 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 2, 2, 1, x, y, 1, 0 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 3, 3, 1, x, y, 0, -1 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 4, 4, 1, x, y, 0, 1 ) ); + this.guiSlots.add(new GuiFluidSlot(inv, 0, 0, x, y)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 1, 1, 1, x, y, -1, 0)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 2, 2, 1, x, y, 1, 0)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 3, 3, 1, x, y, 0, -1)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 4, 4, 1, x, y, 0, 1)); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 5, 5, 2, x, y, -1, -1 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 6, 6, 2, x, y, 1, -1 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 7, 7, 2, x, y, -1, 1 ) ); - this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 8, 8, 2, x, y, 1, 1 ) ); - } + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 5, 5, 2, x, y, -1, -1)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 6, 6, 2, x, y, 1, -1)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 7, 7, 2, x, y, -1, 1)); + this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 8, 8, 2, x, y, 1, 1)); + } - @Override - protected GuiText getName() - { - return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids; - } + @Override + protected GuiText getName() { + return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids; + } } diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidInterface.java b/src/main/java/appeng/fluids/client/gui/GuiFluidInterface.java index 3dc212ee2..32682473f 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidInterface.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidInterface.java @@ -18,6 +18,9 @@ package appeng.fluids.client.gui; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.client.gui.implementations.GuiUpgradeable; import appeng.client.gui.widgets.GuiTabButton; @@ -30,65 +33,55 @@ import appeng.fluids.client.gui.widgets.GuiFluidTank; import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.helper.DualityFluidInterface; import appeng.fluids.util.IAEFluidTank; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; -public class GuiFluidInterface extends GuiUpgradeable -{ - public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory playerInventory, ITextComponent title) - { - super(container, playerInventory, title); - this.ySize = 231; - } +public class GuiFluidInterface extends GuiUpgradeable { + public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 231; + } - @Override - public void init() - { - super.init(); + @Override + public void init() { + super.init(); - final IAEFluidTank configFluids = this.container.getFluidConfigInventory(); - final IAEFluidTank fluidTank = this.container.getTanks(); + final IAEFluidTank configFluids = this.container.getFluidConfigInventory(); + final IAEFluidTank fluidTank = this.container.getTanks(); - for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i ) - { - final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, this.getGuiLeft() + 35 + 18 * i, this - .getGuiTop() + 53, 16, 68 ); - this.addButton( guiTank ); - this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) ); - } + for (int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i) { + final GuiFluidTank guiTank = new GuiFluidTank(fluidTank, i, this.getGuiLeft() + 35 + 18 * i, + this.getGuiTop() + 53, 16, 68); + this.addButton(guiTank); + this.guiSlots.add(new GuiFluidSlot(configFluids, i, i, 35 + 18 * i, 35)); + } - this.addButton( new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ); - } + this.addButton(new GuiTabButton(this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, + GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui())); + } - @Override - protected void addButtons() - { - } + @Override + protected void addButtons() { + } - @Override - public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( GuiText.FluidInterface.getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752 ); - this.font.drawString( GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { + this.font.drawString(this.getGuiDisplayName(GuiText.FluidInterface.getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752); + this.font.drawString(GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } - @Override - public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) - { - this.bindTexture( "guis/interfacefluid.png" ); - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ ); - } + @Override + public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) { + this.bindTexture("guis/interfacefluid.png"); + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ ); + } - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } - @Override - protected boolean drawUpgrades() - { - return false; - } + @Override + protected boolean drawUpgrades() { + return false; + } } diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidLevelEmitter.java b/src/main/java/appeng/fluids/client/gui/GuiFluidLevelEmitter.java index bbe05b48f..6f22e3862 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidLevelEmitter.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidLevelEmitter.java @@ -1,204 +1,180 @@ package appeng.fluids.client.gui; - - -import appeng.client.gui.widgets.GuiServerSettingToggleButton; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.util.InputMappings; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; import appeng.client.gui.implementations.GuiUpgradeable; import appeng.client.gui.widgets.GuiNumberBox; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketValueConfig; import appeng.fluids.client.gui.widgets.GuiFluidSlot; import appeng.fluids.container.ContainerFluidLevelEmitter; -import net.minecraft.util.text.ITextComponent; +public class GuiFluidLevelEmitter extends GuiUpgradeable { + private GuiNumberBox level; -public class GuiFluidLevelEmitter extends GuiUpgradeable -{ - private GuiNumberBox level; + public GuiFluidLevelEmitter(ContainerFluidLevelEmitter container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + } - public GuiFluidLevelEmitter(ContainerFluidLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - } + @Override + public void init() { + super.init(); - @Override - public void init() - { - super.init(); + this.level = new GuiNumberBox(this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, + Long.class); + this.level.setEnableBackgroundDrawing(false); + this.level.setMaxStringLength(16); + this.level.setTextColor(0xFFFFFF); + this.level.setVisible(true); + this.level.changeFocus(true); + container.setTextField(this.level); - this.level = new GuiNumberBox( this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, Long.class ); - this.level.setEnableBackgroundDrawing( false ); - this.level.setMaxStringLength( 16 ); - this.level.setTextColor( 0xFFFFFF ); - this.level.setVisible( true ); - this.level.changeFocus( true ); - container.setTextField( this.level ); + final int y = 40; + final int x = 80 + 44; + this.guiSlots.add(new GuiFluidSlot(this.container.getFluidConfigInventory(), 0, 0, x, y)); + } - final int y = 40; - final int x = 80 + 44; - this.guiSlots.add( new GuiFluidSlot( this.container.getFluidConfigInventory(), 0, 0, x, y ) ); - } + @Override + protected void addButtons() { + this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, + Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL); - @Override - protected void addButtons() - { - this.redstoneMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL ); + final int a = AEConfig.instance().levelByMillyBuckets(0); + final int b = AEConfig.instance().levelByMillyBuckets(1); + final int c = AEConfig.instance().levelByMillyBuckets(2); + final int d = AEConfig.instance().levelByMillyBuckets(3); - final int a = AEConfig.instance().levelByMillyBuckets( 0 ); - final int b = AEConfig.instance().levelByMillyBuckets( 1 ); - final int c = AEConfig.instance().levelByMillyBuckets( 2 ); - final int d = AEConfig.instance().levelByMillyBuckets( 3 ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) ); + this.addButton(new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a))); + this.addButton(new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b))); + this.addButton(new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c))); + this.addButton(new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d))); - this.addButton( new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) ); - this.addButton( new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) ); - this.addButton( new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) ); - this.addButton( new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) ); + this.addButton(this.redstoneMode); + } - this.addButton( this.redstoneMode ); - } + @Override + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { + super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks); + this.level.render(mouseX, mouseY, partialTicks); + } - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) - { - super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks); - this.level.render(mouseX, mouseY, partialTicks); - } + @Override + protected boolean drawUpgrades() { + return false; + } - @Override - protected boolean drawUpgrades() - { - return false; - } + @Override + protected String getBackground() { + return "guis/lvlemitter.png"; + } - @Override - protected String getBackground() - { - return "guis/lvlemitter.png"; - } + @Override + protected GuiText getName() { + return GuiText.FluidLevelEmitter; + } - @Override - protected GuiText getName() - { - return GuiText.FluidLevelEmitter; - } + @Override + protected void handleButtonVisibility() { + } - @Override - protected void handleButtonVisibility() - { - } + private void addQty(final long i) { + try { + String Out = this.level.getText(); - private void addQty( final long i ) - { - try - { - String Out = this.level.getText(); + boolean Fixed = false; + while (Out.startsWith("0") && Out.length() > 1) { + Out = Out.substring(1); + Fixed = true; + } - boolean Fixed = false; - while( Out.startsWith( "0" ) && Out.length() > 1 ) - { - Out = Out.substring( 1 ); - Fixed = true; - } + if (Fixed) { + this.level.setText(Out); + } - if( Fixed ) - { - this.level.setText( Out ); - } + if (Out.isEmpty()) { + Out = "0"; + } - if( Out.isEmpty() ) - { - Out = "0"; - } + long result = Long.parseLong(Out); + result += i; + if (result < 0) { + result = 0; + } - long result = Long.parseLong( Out ); - result += i; - if( result < 0 ) - { - result = 0; - } + this.level.setText(Out = Long.toString(result)); - this.level.setText( Out = Long.toString( result ) ); + NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out)); + } catch (final NumberFormatException e) { + // nope.. + this.level.setText("0"); + } + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) ); - } - catch( final NumberFormatException e ) - { - // nope.. - this.level.setText( "0" ); - } - } + @Override + public boolean charTyped(char character, int keyCode) { + if (level.charTyped(character, keyCode)) { + String Out = this.level.getText(); - @Override - public boolean charTyped(char character, int keyCode) { - if (level.charTyped(character, keyCode)) { - String Out = this.level.getText(); + boolean Fixed = false; + while (Out.startsWith("0") && Out.length() > 1) { + Out = Out.substring(1); + Fixed = true; + } - boolean Fixed = false; - while( Out.startsWith( "0" ) && Out.length() > 1 ) - { - Out = Out.substring( 1 ); - Fixed = true; - } + if (Fixed) { + this.level.setText(Out); + } - if( Fixed ) - { - this.level.setText( Out ); - } + if (Out.isEmpty()) { + Out = "0"; + } - if( Out.isEmpty() ) - { - Out = "0"; - } + NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out)); + return true; + } + return super.charTyped(character, keyCode); + } - NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) ); - return true; - } - return super.charTyped(character, keyCode); - } + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) { + if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) + && this.level.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + String Out = this.level.getText(); - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) ) - { - if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.level.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) ) - { - String Out = this.level.getText(); + boolean Fixed = false; + while (Out.startsWith("0") && Out.length() > 1) { + Out = Out.substring(1); + Fixed = true; + } - boolean Fixed = false; - while( Out.startsWith( "0" ) && Out.length() > 1 ) - { - Out = Out.substring( 1 ); - Fixed = true; - } + if (Fixed) { + this.level.setText(Out); + } - if( Fixed ) - { - this.level.setText( Out ); - } + if (Out.isEmpty()) { + Out = "0"; + } - if( Out.isEmpty() ) - { - Out = "0"; - } - - NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) ); - return true; - } - } - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } + NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out)); + return true; + } + } + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } } diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidStorageBus.java b/src/main/java/appeng/fluids/client/gui/GuiFluidStorageBus.java index 47a572d2d..ca72e0210 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidStorageBus.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidStorageBus.java @@ -1,150 +1,138 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.fluids.client.gui; - - -import appeng.client.gui.widgets.GuiActionButton; -import appeng.client.gui.widgets.GuiServerSettingToggleButton; -import appeng.container.implementations.ContainerPriority; -import net.minecraft.entity.player.PlayerInventory; - -import appeng.api.config.AccessRestriction; -import appeng.api.config.ActionItems; -import appeng.api.config.FuzzyMode; -import appeng.api.config.Settings; -import appeng.api.config.StorageFilter; -import appeng.client.gui.implementations.GuiUpgradeable; -import appeng.client.gui.widgets.GuiSettingToggleButton; -import appeng.client.gui.widgets.GuiTabButton; -import appeng.core.localization.GuiText; - -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketSwitchGuis; -import appeng.core.sync.packets.PacketValueConfig; -import appeng.fluids.client.gui.widgets.GuiFluidSlot; -import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot; -import appeng.fluids.container.ContainerFluidStorageBus; -import appeng.fluids.util.IAEFluidTank; -import net.minecraft.util.text.ITextComponent; - - -/** - * @author BrockWS - * @version rv6 - 22/05/2018 - * @since rv6 22/05/2018 - */ -public class GuiFluidStorageBus extends GuiUpgradeable -{ - private GuiSettingToggleButton rwMode; - private GuiSettingToggleButton storageFilter; - - public GuiFluidStorageBus(ContainerFluidStorageBus container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.ySize = 251; - } - - @Override - public void init() - { - super.init(); - - final int xo = 8; - final int yo = 23 + 6; - - final IAEFluidTank config = this.container.getFluidConfigInventory(); - - for( int y = 0; y < 7; y++ ) - { - for( int x = 0; x < 9; x++ ) - { - final int idx = y * 9 + x; - if( y < 2 ) - { - this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) ); - } - else - { - this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) ); - } - } - } - } - - @Override - protected void addButtons() - { - addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear() ) ); - addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition() ) ); - this.rwMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE ); - this.storageFilter = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY ); - this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - - addButton( this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ) ); - - this.addButton( this.storageFilter ); - this.addButton( this.fuzzyMode ); - this.addButton( this.rwMode ); - } - - @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - - if( this.fuzzyMode != null ) - { - this.fuzzyMode.set( this.cvb.getFuzzyMode() ); - } - - if( this.storageFilter != null ) - { - this.storageFilter.set( ( (ContainerFluidStorageBus) this.cvb ).getStorageFilter() ); - } - - if( this.rwMode != null ) - { - this.rwMode.set( ( (ContainerFluidStorageBus) this.cvb ).getReadWriteMode() ); - } - } - - @Override - protected String getBackground() - { - return "guis/storagebus.png"; - } - - private void partition() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) ); - } - - private void clear() { - NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) ); - } - - private void openPriorityGui() { - NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) ); - } - - @Override - protected GuiText getName() - { - return GuiText.StorageBusFluids; - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.fluids.client.gui; + +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; + +import appeng.api.config.AccessRestriction; +import appeng.api.config.ActionItems; +import appeng.api.config.FuzzyMode; +import appeng.api.config.Settings; +import appeng.api.config.StorageFilter; +import appeng.client.gui.implementations.GuiUpgradeable; +import appeng.client.gui.widgets.GuiActionButton; +import appeng.client.gui.widgets.GuiServerSettingToggleButton; +import appeng.client.gui.widgets.GuiSettingToggleButton; +import appeng.client.gui.widgets.GuiTabButton; +import appeng.container.implementations.ContainerPriority; +import appeng.core.localization.GuiText; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketSwitchGuis; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.fluids.client.gui.widgets.GuiFluidSlot; +import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot; +import appeng.fluids.container.ContainerFluidStorageBus; +import appeng.fluids.util.IAEFluidTank; + +/** + * @author BrockWS + * @version rv6 - 22/05/2018 + * @since rv6 22/05/2018 + */ +public class GuiFluidStorageBus extends GuiUpgradeable { + private GuiSettingToggleButton rwMode; + private GuiSettingToggleButton storageFilter; + + public GuiFluidStorageBus(ContainerFluidStorageBus container, PlayerInventory playerInventory, + ITextComponent title) { + super(container, playerInventory, title); + this.ySize = 251; + } + + @Override + public void init() { + super.init(); + + final int xo = 8; + final int yo = 23 + 6; + + final IAEFluidTank config = this.container.getFluidConfigInventory(); + + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 9; x++) { + final int idx = y * 9 + x; + if (y < 2) { + this.guiSlots.add(new GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18)); + } else { + this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y)); + } + } + } + } + + @Override + protected void addButtons() { + addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear())); + addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition())); + this.rwMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, + AccessRestriction.READ_WRITE); + this.storageFilter = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, + Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY); + this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, + FuzzyMode.IGNORE_ALL); + + addButton(this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, + GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui()))); + + this.addButton(this.storageFilter); + this.addButton(this.fuzzyMode); + this.addButton(this.rwMode); + } + + @Override + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.font.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + + if (this.fuzzyMode != null) { + this.fuzzyMode.set(this.cvb.getFuzzyMode()); + } + + if (this.storageFilter != null) { + this.storageFilter.set(((ContainerFluidStorageBus) this.cvb).getStorageFilter()); + } + + if (this.rwMode != null) { + this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode()); + } + } + + @Override + protected String getBackground() { + return "guis/storagebus.png"; + } + + private void partition() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition")); + } + + private void clear() { + NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Clear")); + } + + private void openPriorityGui() { + NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE)); + } + + @Override + protected GuiText getName() { + return GuiText.StorageBusFluids; + } +} diff --git a/src/main/java/appeng/fluids/client/gui/GuiFluidTerminal.java b/src/main/java/appeng/fluids/client/gui/GuiFluidTerminal.java index 06d9f92ed..6ffc04c1e 100644 --- a/src/main/java/appeng/fluids/client/gui/GuiFluidTerminal.java +++ b/src/main/java/appeng/fluids/client/gui/GuiFluidTerminal.java @@ -1,340 +1,312 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.fluids.client.gui; - - -import appeng.api.config.Settings; -import appeng.api.config.SortDir; -import appeng.api.config.SortOrder; -import appeng.api.config.ViewItems; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.util.IConfigManager; -import appeng.client.gui.AEBaseMEGui; -import appeng.client.gui.widgets.GuiSettingToggleButton; -import appeng.client.gui.widgets.GuiScrollbar; -import appeng.client.gui.widgets.ISortSource; -import appeng.client.gui.widgets.MEGuiTextField; -import appeng.client.me.FluidRepo; -import appeng.client.me.InternalFluidSlotME; -import appeng.client.me.SlotFluidME; -import appeng.core.AELog; -import appeng.core.localization.GuiText; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketInventoryAction; -import appeng.core.sync.packets.PacketValueConfig; -import appeng.fluids.container.ContainerFluidTerminal; -import appeng.fluids.container.slots.IMEFluidSlot; -import appeng.helpers.InventoryAction; -import appeng.util.IConfigManagerHost; -import appeng.util.Platform; -import net.minecraft.client.util.InputMappings; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.client.gui.GuiUtils; - -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - - -/** - * @author BrockWS - * @version rv6 - 12/05/2018 - * @since rv6 12/05/2018 - */ -public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfigManagerHost -{ - private final List meFluidSlots = new LinkedList<>(); - private final FluidRepo repo; - private final IConfigManager configSrc; - private final int offsetX = 9; - private int rows = 6; - private int perRow = 9; - - private MEGuiTextField searchField; - private GuiSettingToggleButton sortByBox; - private GuiSettingToggleButton sortDirBox; - - public GuiFluidTerminal(ContainerFluidTerminal container, PlayerInventory playerInventory, ITextComponent title) { - super(container, playerInventory, title); - this.xSize = 185; - this.ySize = 222; - final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - this.repo = new FluidRepo( scrollbar, this ); - this.configSrc = container.getConfigManager(); - this.container.setGui( this ); - } - - @Override - public void init() - { - this.guiLeft = ( this.width - this.xSize ) / 2; - this.guiTop = ( this.height - this.ySize ) / 2; - - this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 ); - this.searchField.setEnableBackgroundDrawing( false ); - this.searchField.setMaxStringLength( 25 ); - this.searchField.setTextColor( 0xFFFFFF ); - this.searchField.setSelectionColor( 0xFF99FF99 ); - this.searchField.setVisible( true ); - - int offset = this.guiTop; - - this.sortByBox = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_BY, getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting ) ); - offset += 20; - - this.sortDirBox = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting ) ); - - for( int y = 0; y < this.rows; y++ ) - { - for( int x = 0; x < this.perRow; x++ ) - { - SlotFluidME slot = new SlotFluidME( new InternalFluidSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) ); - this.getMeFluidSlots().add( slot ); - this.container.inventorySlots.add( slot ); - } - } - this.setScrollBar(); - } - - @Override - public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY ) - { - this.font.drawString( this.getGuiDisplayName( "Fluid Terminal" ), 8, 6, 4210752 ); - this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); - } - - @Override - public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) - { - this.bindTexture( this.getBackground() ); - final int x_width = 197; - GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18, getBlitOffset() ); - - for( int x = 0; x < 6; x++ ) - { - GuiUtils.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, getBlitOffset() ); - } - - GuiUtils.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77, getBlitOffset() ); - - if( this.searchField != null ) - { - this.searchField.render(mouseX, mouseY, partialTicks); - } - } - - @Override - public void tick() - { - this.repo.setPower( this.container.isPowered() ); - super.tick(); - } - - @Override - protected void renderHoveredToolTip( int mouseX, int mouseY ) - { - final Slot slot = this.getSlot( mouseX, mouseY ); - - if( slot instanceof IMEFluidSlot && slot.isEnabled() ) - { - final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot; - - if( fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid() ) - { - final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack(); - final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() / 1000.0 ) + " B"; - - final String modName = Platform.getModName( Platform.getModId( fluidStack ) ); - - final List list = new ArrayList<>(); - - list.add( fluidStack.getFluidStack().getDisplayName().getFormattedText() ); - list.add( formattedAmount ); - list.add( modName ); - - this.renderTooltip( list, mouseX, mouseY ); - - return; - } - } - super.renderHoveredToolTip( mouseX, mouseY ); - } - - private > void toggleServerSetting(GuiSettingToggleButton btn, boolean backwards) { - S next = btn.getNextValue(backwards); - NetworkHandler.instance().sendToServer( new PacketValueConfig( btn.getSetting().name(), next.name() ) ); - btn.set( next ); - } - - @Override - protected void handleMouseClick( Slot slot, int slotIdx, int mouseButton, ClickType clickType ) - { - if( slot instanceof SlotFluidME ) - { - final SlotFluidME meSlot = (SlotFluidME) slot; - - if( clickType == ClickType.PICKUP ) - { - // TODO: Allow more options - if( mouseButton == 0 && meSlot.getHasStack() ) - { - this.container.setTargetStack( meSlot.getAEFluidStack() ); - AELog.debug( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() ); - NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) ); - } - else - { - this.container.setTargetStack( meSlot.getAEFluidStack() ); - if( meSlot.getAEFluidStack() != null ) - { - AELog.debug( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() ); - } - NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) ); - } - } - return; - } - super.handleMouseClick( slot, slotIdx, mouseButton, clickType ); - } - - @Override - public boolean charTyped(char character, int keyCode) { - if (character == ' ' && this.searchField.getText().isEmpty()) - { - // Swallow spaces if the text field is still empty - return true; - } - - if (this.searchField.charTyped(character, keyCode)) { - this.repo.setSearchString( this.searchField.getText() ); - this.repo.updateView(); - this.setScrollBar(); - return true; - } - - return super.charTyped(character, keyCode); - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) - { - InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode); - if( !this.checkHotbarKeys(input) ) - { - if( this.searchField.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) ) - { - this.repo.setSearchString( this.searchField.getText() ); - this.repo.updateView(); - this.setScrollBar(); - } - return true; - } - - return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); - } - - @Override - public boolean mouseClicked( final double xCoord, final double yCoord, final int btn ) - { - if (this.searchField.mouseClicked( xCoord, yCoord, btn )) { - if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { - this.searchField.setText(""); - this.repo.setSearchString(""); - this.repo.updateView(); - this.setScrollBar(); - } - return true; - } - - return super.mouseClicked( xCoord, yCoord, btn ); - } - - public void postUpdate( final List list ) - { - for( final IAEFluidStack is : list ) - { - this.repo.postUpdate( is ); - } - - this.repo.updateView(); - this.setScrollBar(); - } - - private void setScrollBar() - { - this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 ); - this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) ); - } - - @Override - public SortOrder getSortBy() - { - return (SortOrder) this.configSrc.getSetting( Settings.SORT_BY ); - } - - @Override - public SortDir getSortDir() - { - return (SortDir) this.configSrc.getSetting( Settings.SORT_DIRECTION ); - } - - @Override - public ViewItems getSortDisplay() - { - return (ViewItems) this.configSrc.getSetting( Settings.VIEW_MODE ); - } - - @Override - public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue ) - { - if( this.sortByBox != null ) - { - this.sortByBox.set( getSortBy() ); - } - - if( this.sortDirBox != null ) - { - this.sortDirBox.set( getSortDir() ); - } - - this.repo.updateView(); - } - - protected List getMeFluidSlots() - { - return this.meFluidSlots; - } - - @Override - protected boolean isPowered() - { - return this.repo.hasPower(); - } - - protected String getBackground() - { - return "guis/terminal.png"; - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.fluids.client.gui; + +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ClickType; +import net.minecraft.inventory.container.Slot; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.gui.GuiUtils; + +import appeng.api.config.Settings; +import appeng.api.config.SortDir; +import appeng.api.config.SortOrder; +import appeng.api.config.ViewItems; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.util.IConfigManager; +import appeng.client.gui.AEBaseMEGui; +import appeng.client.gui.widgets.GuiScrollbar; +import appeng.client.gui.widgets.GuiSettingToggleButton; +import appeng.client.gui.widgets.ISortSource; +import appeng.client.gui.widgets.MEGuiTextField; +import appeng.client.me.FluidRepo; +import appeng.client.me.InternalFluidSlotME; +import appeng.client.me.SlotFluidME; +import appeng.core.AELog; +import appeng.core.localization.GuiText; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketInventoryAction; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.fluids.container.ContainerFluidTerminal; +import appeng.fluids.container.slots.IMEFluidSlot; +import appeng.helpers.InventoryAction; +import appeng.util.IConfigManagerHost; +import appeng.util.Platform; + +/** + * @author BrockWS + * @version rv6 - 12/05/2018 + * @since rv6 12/05/2018 + */ +public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfigManagerHost { + private final List meFluidSlots = new LinkedList<>(); + private final FluidRepo repo; + private final IConfigManager configSrc; + private final int offsetX = 9; + private int rows = 6; + private int perRow = 9; + + private MEGuiTextField searchField; + private GuiSettingToggleButton sortByBox; + private GuiSettingToggleButton sortDirBox; + + public GuiFluidTerminal(ContainerFluidTerminal container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); + this.xSize = 185; + this.ySize = 222; + final GuiScrollbar scrollbar = new GuiScrollbar(); + this.setScrollBar(scrollbar); + this.repo = new FluidRepo(scrollbar, this); + this.configSrc = container.getConfigManager(); + this.container.setGui(this); + } + + @Override + public void init() { + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + + this.searchField = new MEGuiTextField(this.font, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, + 12); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setMaxStringLength(25); + this.searchField.setTextColor(0xFFFFFF); + this.searchField.setSelectionColor(0xFF99FF99); + this.searchField.setVisible(true); + + int offset = this.guiTop; + + this.sortByBox = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, Settings.SORT_BY, + getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting)); + offset += 20; + + this.sortDirBox = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, offset, + Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting)); + + for (int y = 0; y < this.rows; y++) { + for (int x = 0; x < this.perRow; x++) { + SlotFluidME slot = new SlotFluidME( + new InternalFluidSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); + this.getMeFluidSlots().add(slot); + this.container.inventorySlots.add(slot); + } + } + this.setScrollBar(); + } + + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { + this.font.drawString(this.getGuiDisplayName("Fluid Terminal"), 8, 6, 4210752); + this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); + } + + @Override + public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) { + this.bindTexture(this.getBackground()); + final int x_width = 197; + GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18, getBlitOffset()); + + for (int x = 0; x < 6; x++) { + GuiUtils.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, getBlitOffset()); + } + + GuiUtils.drawTexturedModalRect(offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77, + getBlitOffset()); + + if (this.searchField != null) { + this.searchField.render(mouseX, mouseY, partialTicks); + } + } + + @Override + public void tick() { + this.repo.setPower(this.container.isPowered()); + super.tick(); + } + + @Override + protected void renderHoveredToolTip(int mouseX, int mouseY) { + final Slot slot = this.getSlot(mouseX, mouseY); + + if (slot instanceof IMEFluidSlot && slot.isEnabled()) { + final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot; + + if (fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid()) { + final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack(); + final String formattedAmount = NumberFormat.getNumberInstance(Locale.US) + .format(fluidStack.getStackSize() / 1000.0) + " B"; + + final String modName = Platform.getModName(Platform.getModId(fluidStack)); + + final List list = new ArrayList<>(); + + list.add(fluidStack.getFluidStack().getDisplayName().getFormattedText()); + list.add(formattedAmount); + list.add(modName); + + this.renderTooltip(list, mouseX, mouseY); + + return; + } + } + super.renderHoveredToolTip(mouseX, mouseY); + } + + private > void toggleServerSetting(GuiSettingToggleButton btn, boolean backwards) { + S next = btn.getNextValue(backwards); + NetworkHandler.instance().sendToServer(new PacketValueConfig(btn.getSetting().name(), next.name())); + btn.set(next); + } + + @Override + protected void handleMouseClick(Slot slot, int slotIdx, int mouseButton, ClickType clickType) { + if (slot instanceof SlotFluidME) { + final SlotFluidME meSlot = (SlotFluidME) slot; + + if (clickType == ClickType.PICKUP) { + // TODO: Allow more options + if (mouseButton == 0 && meSlot.getHasStack()) { + this.container.setTargetStack(meSlot.getAEFluidStack()); + AELog.debug("mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize()); + NetworkHandler.instance() + .sendToServer(new PacketInventoryAction(InventoryAction.FILL_ITEM, slot.slotNumber, 0)); + } else { + this.container.setTargetStack(meSlot.getAEFluidStack()); + if (meSlot.getAEFluidStack() != null) { + AELog.debug("mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize()); + } + NetworkHandler.instance() + .sendToServer(new PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot.slotNumber, 0)); + } + } + return; + } + super.handleMouseClick(slot, slotIdx, mouseButton, clickType); + } + + @Override + public boolean charTyped(char character, int keyCode) { + if (character == ' ' && this.searchField.getText().isEmpty()) { + // Swallow spaces if the text field is still empty + return true; + } + + if (this.searchField.charTyped(character, keyCode)) { + this.repo.setSearchString(this.searchField.getText()); + this.repo.updateView(); + this.setScrollBar(); + return true; + } + + return super.charTyped(character, keyCode); + } + + @Override + public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) { + InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode); + if (!this.checkHotbarKeys(input)) { + if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { + this.repo.setSearchString(this.searchField.getText()); + this.repo.updateView(); + this.setScrollBar(); + } + return true; + } + + return super.keyPressed(keyCode, scanCode, p_keyPressed_3_); + } + + @Override + public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) { + if (this.searchField.mouseClicked(xCoord, yCoord, btn)) { + if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) { + this.searchField.setText(""); + this.repo.setSearchString(""); + this.repo.updateView(); + this.setScrollBar(); + } + return true; + } + + return super.mouseClicked(xCoord, yCoord, btn); + } + + public void postUpdate(final List list) { + for (final IAEFluidStack is : list) { + this.repo.postUpdate(is); + } + + this.repo.updateView(); + this.setScrollBar(); + } + + private void setScrollBar() { + this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2); + this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, + Math.max(1, this.rows / 6)); + } + + @Override + public SortOrder getSortBy() { + return (SortOrder) this.configSrc.getSetting(Settings.SORT_BY); + } + + @Override + public SortDir getSortDir() { + return (SortDir) this.configSrc.getSetting(Settings.SORT_DIRECTION); + } + + @Override + public ViewItems getSortDisplay() { + return (ViewItems) this.configSrc.getSetting(Settings.VIEW_MODE); + } + + @Override + public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue) { + if (this.sortByBox != null) { + this.sortByBox.set(getSortBy()); + } + + if (this.sortDirBox != null) { + this.sortDirBox.set(getSortDir()); + } + + this.repo.updateView(); + } + + protected List getMeFluidSlots() { + return this.meFluidSlots; + } + + @Override + protected boolean isPowered() { + return this.repo.hasPower(); + } + + protected String getBackground() { + return "guis/terminal.png"; + } +} diff --git a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java index a15b0c535..a0b5e0e0d 100644 --- a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidSlot.java @@ -1,6 +1,5 @@ package appeng.fluids.client.gui.widgets; - import java.util.Collections; import com.mojang.blaze3d.systems.RenderSystem; @@ -17,6 +16,7 @@ import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.storage.data.IAEFluidStack; import appeng.client.gui.widgets.GuiCustomSlot; @@ -24,92 +24,79 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketFluidSlot; import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.IAEFluidTank; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiFluidSlot extends GuiCustomSlot { + private final IAEFluidTank fluids; + private final int slot; -public class GuiFluidSlot extends GuiCustomSlot -{ - private final IAEFluidTank fluids; - private final int slot; + public GuiFluidSlot(final IAEFluidTank fluids, final int slot, final int id, final int x, final int y) { + super(id, x, y); + this.fluids = fluids; + this.slot = slot; + } - public GuiFluidSlot( final IAEFluidTank fluids, final int slot, final int id, final int x, final int y ) - { - super( id, x, y ); - this.fluids = fluids; - this.slot = slot; - } + @Override + public void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) { + final IAEFluidStack fs = this.getFluidStack(); + if (fs != null) { + RenderSystem.disableBlend(); + final Fluid fluid = fs.getFluid(); + final FluidAttributes attributes = fluid.getAttributes(); + mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE) + .apply(attributes.getStillTexture(fs.getFluidStack())); - @Override - public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ) - { - final IAEFluidStack fs = this.getFluidStack(); - if( fs != null ) - { - RenderSystem.disableBlend(); - final Fluid fluid = fs.getFluid(); - final FluidAttributes attributes = fluid.getAttributes(); - mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE ); - final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fs.getFluidStack()) ); + // Set color for dynamic fluids + // Convert int color to RGB + final float red = (attributes.getColor() >> 16 & 255) / 255.0F; + final float green = (attributes.getColor() >> 8 & 255) / 255.0F; + final float blue = (attributes.getColor() & 255) / 255.0F; + RenderSystem.color3f(red, green, blue); - // Set color for dynamic fluids - // Convert int color to RGB - final float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F; - final float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F; - final float blue = ( attributes.getColor() & 255 ) / 255.0F; - RenderSystem.color3f( red, green, blue ); + blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite); + } + } - blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite); - } - } + @Override + public boolean canClick(final PlayerEntity player) { + final ItemStack mouseStack = player.inventory.getItemStack(); + return mouseStack.isEmpty() + || mouseStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent(); + } - @Override - public boolean canClick( final PlayerEntity player ) - { - final ItemStack mouseStack = player.inventory.getItemStack(); - return mouseStack.isEmpty() || mouseStack.getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ).isPresent(); - } + @Override + public void slotClicked(final ItemStack clickStack, int mouseButton) { + if (clickStack.isEmpty() || mouseButton == 1) { + this.setFluidStack(null); + } else if (mouseButton == 0) { + final LazyOptional fluidOpt = FluidUtil.getFluidContained(clickStack); + fluidOpt.ifPresent(fluid -> { + this.setFluidStack(AEFluidStack.fromFluidStack(fluid)); + }); + } + } - @Override - public void slotClicked( final ItemStack clickStack, int mouseButton ) - { - if( clickStack.isEmpty() || mouseButton == 1 ) - { - this.setFluidStack( null ); - } - else if( mouseButton == 0 ) - { - final LazyOptional fluidOpt = FluidUtil.getFluidContained( clickStack ); - fluidOpt.ifPresent( fluid -> { - this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) ); - } ); - } - } + @Override + public String getMessage() { + final IAEFluidStack fluid = this.getFluidStack(); + if (fluid != null) { + return I18n.format(fluid.getFluidStack().getTranslationKey()); + } + return null; + } - @Override - public String getMessage() - { - final IAEFluidStack fluid = this.getFluidStack(); - if( fluid != null ) - { - return I18n.format( fluid.getFluidStack().getTranslationKey() ); - } - return null; - } + @Override + public boolean isVisible() { + return true; + } - @Override - public boolean isVisible() - { - return true; - } + public IAEFluidStack getFluidStack() { + return this.fluids.getFluidInSlot(this.slot); + } - public IAEFluidStack getFluidStack() - { - return this.fluids.getFluidInSlot( this.slot ); - } - - public void setFluidStack( final IAEFluidStack stack ) - { - this.fluids.setFluidInSlot( this.slot, stack ); - NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.getId(), this.getFluidStack() ) ) ); - } + public void setFluidStack(final IAEFluidStack stack) { + this.fluids.setFluidInSlot(this.slot, stack); + NetworkHandler.instance() + .sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack()))); + } } diff --git a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java index 021df69f6..7ede56bc3 100644 --- a/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/GuiFluidTank.java @@ -18,12 +18,8 @@ package appeng.fluids.client.gui.widgets; - -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.util.AEColor; -import appeng.client.gui.widgets.ITooltip; -import appeng.fluids.util.IAEFluidTank; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.renderer.texture.AtlasTexture; @@ -33,101 +29,96 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidAttributes; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.util.AEColor; +import appeng.client.gui.widgets.ITooltip; +import appeng.fluids.util.IAEFluidTank; -@OnlyIn( Dist.CLIENT ) -public class GuiFluidTank extends Widget implements ITooltip -{ - private final IAEFluidTank tank; - private final int slot; +@OnlyIn(Dist.CLIENT) +public class GuiFluidTank extends Widget implements ITooltip { + private final IAEFluidTank tank; + private final int slot; - public GuiFluidTank(IAEFluidTank tank, int slot, int x, int y, int w, int h) - { - super( x, y, w, h, "" ); - this.tank = tank; - this.slot = slot; - } + public GuiFluidTank(IAEFluidTank tank, int slot, int x, int y, int w, int h) { + super(x, y, w, h, ""); + this.tank = tank; + this.slot = slot; + } - @Override - public void renderButton(int mouseX, int mouseY, float partialTicks) { - if( this.visible ) - { - RenderSystem.disableBlend(); + @Override + public void renderButton(int mouseX, int mouseY, float partialTicks) { + if (this.visible) { + RenderSystem.disableBlend(); - fill( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 ); + fill(this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000); - final IAEFluidStack fluidStack = this.tank.getFluidInSlot( this.slot ); - if( fluidStack != null && fluidStack.getStackSize() > 0 ) - { - Fluid fluid = fluidStack.getFluid(); - FluidAttributes attributes = fluid.getAttributes(); + final IAEFluidStack fluidStack = this.tank.getFluidInSlot(this.slot); + if (fluidStack != null && fluidStack.getStackSize() > 0) { + Fluid fluid = fluidStack.getFluid(); + FluidAttributes attributes = fluid.getAttributes(); - float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F; - float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F; - float blue = ( attributes.getColor() & 255 ) / 255.0F; - RenderSystem.color3f( red, green, blue ); + float red = (attributes.getColor() >> 16 & 255) / 255.0F; + float green = (attributes.getColor() >> 8 & 255) / 255.0F; + float blue = (attributes.getColor() & 255) / 255.0F; + RenderSystem.color3f(red, green, blue); - Minecraft mc = Minecraft.getInstance(); - mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE ); - final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fluidStack.getFluidStack()) ); + Minecraft mc = Minecraft.getInstance(); + mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE) + .apply(attributes.getStillTexture(fluidStack.getFluidStack())); - final int scaledHeight = (int) ( this.height * ( (float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot) ) ); + final int scaledHeight = (int) (this.height + * ((float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot))); - int iconHeightRemainder = scaledHeight % 16; - if( iconHeightRemainder > 0 ) - { - blit(this.x, this.y + this.height - iconHeightRemainder, getBlitOffset(), 16, iconHeightRemainder, sprite ); - } - for( int i = 0; i < scaledHeight / 16; i++ ) - { - blit( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, getBlitOffset(), 16, 16, sprite ); - } - } + int iconHeightRemainder = scaledHeight % 16; + if (iconHeightRemainder > 0) { + blit(this.x, this.y + this.height - iconHeightRemainder, getBlitOffset(), 16, iconHeightRemainder, + sprite); + } + for (int i = 0; i < scaledHeight / 16; i++) { + blit(this.x, this.y + this.height - iconHeightRemainder - (i + 1) * 16, getBlitOffset(), 16, 16, + sprite); + } + } - } - } + } + } - @Override - public String getMessage() - { - final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot ); - if( fluid != null && fluid.getStackSize() > 0 ) - { - String desc = fluid.getFluid().getAttributes().getDisplayName( fluid.getFluidStack() ).getFormattedText(); - String amountToText = fluid.getStackSize() + "mB"; + @Override + public String getMessage() { + final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot); + if (fluid != null && fluid.getStackSize() > 0) { + String desc = fluid.getFluid().getAttributes().getDisplayName(fluid.getFluidStack()).getFormattedText(); + String amountToText = fluid.getStackSize() + "mB"; - return desc + "\n" + amountToText; - } - return null; - } + return desc + "\n" + amountToText; + } + return null; + } - @Override - public int xPos() - { - return this.x - 2; - } + @Override + public int xPos() { + return this.x - 2; + } - @Override - public int yPos() - { - return this.y - 2; - } + @Override + public int yPos() { + return this.y - 2; + } - @Override - public int getWidth() - { - return this.width + 4; - } + @Override + public int getWidth() { + return this.width + 4; + } - @Override - public int getHeight() - { - return this.height + 4; - } + @Override + public int getHeight() { + return this.height + 4; + } - @Override - public boolean isVisible() - { - return true; - } + @Override + public boolean isVisible() { + return true; + } } diff --git a/src/main/java/appeng/fluids/client/gui/widgets/GuiOptionalFluidSlot.java b/src/main/java/appeng/fluids/client/gui/widgets/GuiOptionalFluidSlot.java index 09bcd6dc8..9c4bb38f8 100644 --- a/src/main/java/appeng/fluids/client/gui/widgets/GuiOptionalFluidSlot.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/GuiOptionalFluidSlot.java @@ -1,63 +1,54 @@ package appeng.fluids.client.gui.widgets; +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraftforge.fml.client.gui.GuiUtils; import appeng.api.storage.data.IAEFluidStack; import appeng.container.slot.IOptionalSlotHost; import appeng.fluids.util.IAEFluidTank; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraftforge.fml.client.gui.GuiUtils; +public class GuiOptionalFluidSlot extends GuiFluidSlot { + private final IOptionalSlotHost containerBus; + private final int groupNum; + private final int srcX; + private final int srcY; -public class GuiOptionalFluidSlot extends GuiFluidSlot -{ - private final IOptionalSlotHost containerBus; - private final int groupNum; - private final int srcX; - private final int srcY; + public GuiOptionalFluidSlot(IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, + int groupNum, int x, int y, int xoffs, int yoffs) { + super(fluids, slot, id, x + xoffs * 18, y + yoffs * 18); + this.containerBus = containerBus; + this.groupNum = groupNum; + this.srcX = x; + this.srcY = y; + } - public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs ) - { - super( fluids, slot, id, x + xoffs * 18, y + yoffs * 18 ); - this.containerBus = containerBus; - this.groupNum = groupNum; - this.srcX = x; - this.srcY = y; - } + @Override + public boolean isSlotEnabled() { + if (this.containerBus == null) { + return false; + } + return this.containerBus.isSlotEnabled(this.groupNum); + } - @Override - public boolean isSlotEnabled() - { - if( this.containerBus == null ) - { - return false; - } - return this.containerBus.isSlotEnabled( this.groupNum ); - } + @Override + public IAEFluidStack getFluidStack() { + if (!this.isSlotEnabled() && super.getFluidStack() != null) { + this.setFluidStack(null); + } + return super.getFluidStack(); + } - @Override - public IAEFluidStack getFluidStack() - { - if( !this.isSlotEnabled() && super.getFluidStack() != null ) - { - this.setFluidStack( null ); - } - return super.getFluidStack(); - } - - @Override - public void drawBackground( int guileft, int guitop, int currentZIndex ) - { - RenderSystem.enableBlend(); - if( this.isSlotEnabled() ) - { - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - } - else - { - RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 0.4F ); - } - GuiUtils.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2, - this.getHeight() + 2, currentZIndex ); - } + @Override + public void drawBackground(int guileft, int guitop, int currentZIndex) { + RenderSystem.enableBlend(); + if (this.isSlotEnabled()) { + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + } else { + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F); + } + GuiUtils.drawTexturedModalRect(guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, + this.srcY - 1, this.getWidth() + 2, this.getHeight() + 2, currentZIndex); + } } diff --git a/src/main/java/appeng/fluids/client/render/FluidStackSizeRenderer.java b/src/main/java/appeng/fluids/client/render/FluidStackSizeRenderer.java index 35ade69f1..f5e90cfaa 100644 --- a/src/main/java/appeng/fluids/client/render/FluidStackSizeRenderer.java +++ b/src/main/java/appeng/fluids/client/render/FluidStackSizeRenderer.java @@ -18,22 +18,21 @@ package appeng.fluids.client.render; - import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import appeng.client.render.StackSizeRenderer; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.gui.FontRenderer; import appeng.api.storage.data.IAEFluidStack; +import appeng.client.render.StackSizeRenderer; import appeng.core.AEConfig; import appeng.util.ISlimReadableNumberConverter; import appeng.util.IWideReadableNumberConverter; import appeng.util.ReadableNumberConverter; - /** * @author AlgorithmX2 * @author thatsIch @@ -41,70 +40,59 @@ import appeng.util.ReadableNumberConverter; * @version rv6 * @since rv6 */ -public class FluidStackSizeRenderer -{ +public class FluidStackSizeRenderer { - private static final String[] NUMBER_FORMATS = new String[] { "#.000", "#.00", "#.0", "#" }; + private static final String[] NUMBER_FORMATS = new String[] { "#.000", "#.00", "#.0", "#" }; - private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE; - private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE; + private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE; + private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE; - public void renderStackSize( FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos ) - { - if (aeStack != null && aeStack.getStackSize() > 0) { - final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize()); - StackSizeRenderer.renderSizeLabel(fontRenderer, xPos, yPos, stackSize); - } - } + public void renderStackSize(FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos) { + if (aeStack != null && aeStack.getStackSize() > 0) { + final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize()); + StackSizeRenderer.renderSizeLabel(fontRenderer, xPos, yPos, stackSize); + } + } - private String getToBeRenderedStackSize( final long originalSize ) - { - // Handle any value below 100 (large font) or 1000 (small font) Buckets with a custom formatter, - // otherwise pass it to the normal number converter - if( originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont() ) - { - return this.getSlimRenderedStacksize( originalSize ); - } - else if( originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont() ) - { - return this.getWideRenderedStacksize( originalSize ); - } + private String getToBeRenderedStackSize(final long originalSize) { + // Handle any value below 100 (large font) or 1000 (small font) Buckets with a + // custom formatter, + // otherwise pass it to the normal number converter + if (originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont()) { + return this.getSlimRenderedStacksize(originalSize); + } else if (originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont()) { + return this.getWideRenderedStacksize(originalSize); + } - if( AEConfig.instance().useTerminalUseLargeFont() ) - { - return SLIM_CONVERTER.toSlimReadableForm( originalSize / 1000 ); - } - else - { - return WIDE_CONVERTER.toWideReadableForm( originalSize / 1000 ); - } - } + if (AEConfig.instance().useTerminalUseLargeFont()) { + return SLIM_CONVERTER.toSlimReadableForm(originalSize / 1000); + } else { + return WIDE_CONVERTER.toWideReadableForm(originalSize / 1000); + } + } - private String getSlimRenderedStacksize( final long originalSize ) - { - final int log = 1 + (int) Math.floor( Math.log10( originalSize ) ) / 2; + private String getSlimRenderedStacksize(final long originalSize) { + final int log = 1 + (int) Math.floor(Math.log10(originalSize)) / 2; - return this.getRenderedFluidStackSize( originalSize, log ); - } + return this.getRenderedFluidStackSize(originalSize, log); + } - private String getWideRenderedStacksize( final long originalSize ) - { - final int log = (int) Math.floor( Math.log10( originalSize ) ) / 2; + private String getWideRenderedStacksize(final long originalSize) { + final int log = (int) Math.floor(Math.log10(originalSize)) / 2; - return this.getRenderedFluidStackSize( originalSize, log ); - } + return this.getRenderedFluidStackSize(originalSize, log); + } - private String getRenderedFluidStackSize( final long originalSize, final int log ) - { - final int index = Math.max( 0, Math.min( 3, log ) ); + private String getRenderedFluidStackSize(final long originalSize, final int log) { + final int index = Math.max(0, Math.min(3, log)); - final DecimalFormatSymbols symbols = new DecimalFormatSymbols(); - symbols.setDecimalSeparator( '.' ); - final DecimalFormat format = new DecimalFormat( NUMBER_FORMATS[index] ); - format.setDecimalFormatSymbols( symbols ); - format.setRoundingMode( RoundingMode.DOWN ); + final DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + final DecimalFormat format = new DecimalFormat(NUMBER_FORMATS[index]); + format.setDecimalFormatSymbols(symbols); + format.setRoundingMode(RoundingMode.DOWN); - return format.format( originalSize / 1000d ); - } + return format.format(originalSize / 1000d); + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidConfigurable.java b/src/main/java/appeng/fluids/container/ContainerFluidConfigurable.java index 13fac3594..363733d82 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidConfigurable.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidConfigurable.java @@ -1,7 +1,6 @@ package appeng.fluids.container; - import java.util.Collections; import java.util.Map; @@ -22,98 +21,79 @@ import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.IAEFluidTank; import appeng.util.Platform; +public abstract class ContainerFluidConfigurable extends ContainerUpgradeable implements IFluidSyncContainer { + private FluidSyncHelper sync = null; -public abstract class ContainerFluidConfigurable extends ContainerUpgradeable implements IFluidSyncContainer -{ - private FluidSyncHelper sync = null; + public ContainerFluidConfigurable(ContainerType containerType, int id, PlayerInventory ip, IUpgradeableHost te) { + super(containerType, id, ip, te); + } - public ContainerFluidConfigurable(ContainerType containerType, int id, PlayerInventory ip, IUpgradeableHost te ) - { - super( containerType, id, ip, te ); - } + public abstract IAEFluidTank getFluidConfigInventory(); - public abstract IAEFluidTank getFluidConfigInventory(); + private FluidSyncHelper getSyncHelper() { + if (this.sync == null) { + this.sync = new FluidSyncHelper(this.getFluidConfigInventory(), 0); + } + return this.sync; + } - private FluidSyncHelper getSyncHelper() - { - if( this.sync == null ) - { - this.sync = new FluidSyncHelper( this.getFluidConfigInventory(), 0 ); - } - return this.sync; - } + @Override + protected ItemStack transferStackToContainer(ItemStack input) { + LazyOptional fsOpt = FluidUtil.getFluidContained(input); + if (fsOpt.isPresent()) { + final IAEFluidTank t = this.getFluidConfigInventory(); + final IAEFluidStack stack = AEFluidStack.fromFluidStack(fsOpt.orElse(null)); + for (int i = 0; i < t.getSlots(); ++i) { + if (t.getFluidInSlot(i) == null && this.isValidForConfig(i, stack)) { + t.setFluidInSlot(i, stack); + break; + } + } + } + return input; + } - @Override - protected ItemStack transferStackToContainer( ItemStack input ) - { - LazyOptional fsOpt = FluidUtil.getFluidContained( input ); - if( fsOpt.isPresent() ) - { - final IAEFluidTank t = this.getFluidConfigInventory(); - final IAEFluidStack stack = AEFluidStack.fromFluidStack( fsOpt.orElse( null ) ); - for( int i = 0; i < t.getSlots(); ++i ) - { - if( t.getFluidInSlot( i ) == null && this.isValidForConfig( i, stack ) ) - { - t.setFluidInSlot( i, stack ); - break; - } - } - } - return input; - } + protected boolean isValidForConfig(int slot, IAEFluidStack fs) { + if (this.supportCapacity()) { + // assumes 4 slots per upgrade + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - protected boolean isValidForConfig( int slot, IAEFluidStack fs ) - { - if( this.supportCapacity() ) - { - // assumes 4 slots per upgrade - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + if (slot > 0 && upgrades < 1) { + return false; + } + if (slot > 4 && upgrades < 2) { + return false; + } + } - if( slot > 0 && upgrades < 1 ) - { - return false; - } - if( slot > 4 && upgrades < 2 ) - { - return false; - } - } + return true; + } - return true; - } + @Override + protected void standardDetectAndSendChanges() { + if (Platform.isServer()) { + this.getSyncHelper().sendDiff(this.listeners); - @Override - protected void standardDetectAndSendChanges() - { - if( Platform.isServer() ) - { - this.getSyncHelper().sendDiff( this.listeners ); + // clear out config items that are no longer valid (eg capacity upgrade removed) + final IAEFluidTank t = this.getFluidConfigInventory(); + for (int i = 0; i < t.getSlots(); ++i) { + if (t.getFluidInSlot(i) != null && !this.isValidForConfig(i, t.getFluidInSlot(i))) { + t.setFluidInSlot(i, null); + } + } + } + super.standardDetectAndSendChanges(); + } - // clear out config items that are no longer valid (eg capacity upgrade removed) - final IAEFluidTank t = this.getFluidConfigInventory(); - for( int i = 0; i < t.getSlots(); ++i ) - { - if( t.getFluidInSlot( i ) != null && !this.isValidForConfig( i, t.getFluidInSlot( i ) ) ) - { - t.setFluidInSlot( i, null ); - } - } - } - super.standardDetectAndSendChanges(); - } + @Override + public void addListener(IContainerListener listener) { + super.addListener(listener); + this.getSyncHelper().sendFull(Collections.singleton(listener)); + } - @Override - public void addListener( IContainerListener listener ) - { - super.addListener( listener ); - this.getSyncHelper().sendFull( Collections.singleton( listener ) ); - } - - @Override - public void receiveFluidSlots( Map fluids ) - { - this.getSyncHelper().readPacket( fluids ); - } + @Override + public void receiveFluidSlots(Map fluids) { + this.getSyncHelper().readPacket(fluids); + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidFormationPlane.java b/src/main/java/appeng/fluids/container/ContainerFluidFormationPlane.java index bb5567762..6b92a68c3 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidFormationPlane.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidFormationPlane.java @@ -1,9 +1,6 @@ package appeng.fluids.container; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ContainerType; @@ -13,110 +10,95 @@ import net.minecraftforge.items.IItemHandler; import appeng.api.config.SecurityPermissions; import appeng.api.config.Upgrades; import appeng.api.storage.data.IAEFluidStack; +import appeng.container.ContainerLocator; +import appeng.container.implementations.ContainerHelper; import appeng.container.slot.SlotRestrictedInput; import appeng.fluids.parts.PartFluidFormationPlane; import appeng.fluids.util.IAEFluidTank; +public class ContainerFluidFormationPlane extends ContainerFluidConfigurable { -public class ContainerFluidFormationPlane extends ContainerFluidConfigurable -{ + public static ContainerType TYPE; - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidFormationPlane::new, PartFluidFormationPlane.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidFormationPlane::new, PartFluidFormationPlane.class, SecurityPermissions.BUILD); + public static ContainerFluidFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerFluidFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final PartFluidFormationPlane plane; - private final PartFluidFormationPlane plane; + public ContainerFluidFormationPlane(int id, final PlayerInventory ip, final PartFluidFormationPlane te) { + super(TYPE, id, ip, te); + this.plane = te; + } - public ContainerFluidFormationPlane(int id, final PlayerInventory ip, final PartFluidFormationPlane te ) - { - super( TYPE, id,ip, te ); - this.plane = te; - } + @Override + protected int getHeight() { + return 251; + } - @Override - protected int getHeight() - { - return 251; - } + @Override + public IAEFluidTank getFluidConfigInventory() { + return this.plane.getConfig(); + } - @Override - public IAEFluidTank getFluidConfigInventory() - { - return this.plane.getConfig(); - } + @Override + protected void setupConfig() { + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, + 8 + 18 * 4, this.getPlayerInventory())).setNotDraggable()); + } - @Override - protected void setupConfig() - { - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); + this.checkToolbox(); + this.standardDetectAndSendChanges(); + } - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); - this.checkToolbox(); - this.standardDetectAndSendChanges(); - } + @Override + protected boolean isValidForConfig(int slot, IAEFluidStack fs) { + if (this.supportCapacity()) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - @Override - protected boolean isValidForConfig( int slot, IAEFluidStack fs ) - { - if( this.supportCapacity() ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + final int y = slot / 9; - final int y = slot / 9; + if (y >= upgrades + 2) { + return false; + } + } - if( y >= upgrades + 2 ) - { - return false; - } - } + return true; + } - return true; - } + @Override + public boolean isSlotEnabled(final int idx) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); - @Override - public boolean isSlotEnabled( final int idx ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); + return upgrades > idx; + } - return upgrades > idx; - } + @Override + protected boolean supportCapacity() { + return true; + } - @Override - protected boolean supportCapacity() - { - return true; - } - - @Override - public int availableUpgrades() - { - return 5; - } + @Override + public int availableUpgrades() { + return 5; + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidIO.java b/src/main/java/appeng/fluids/container/ContainerFluidIO.java index 72585e221..94e444dd2 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidIO.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidIO.java @@ -18,57 +18,51 @@ package appeng.fluids.container; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; import appeng.api.config.SecurityPermissions; import appeng.container.ContainerLocator; import appeng.container.implementations.ContainerHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; - import appeng.fluids.parts.PartSharedFluidBus; import appeng.fluids.util.IAEFluidTank; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; - /** * @author BrockWS * @version rv5 - 1/05/2018 * @since rv5 1/05/2018 */ -public class ContainerFluidIO extends ContainerFluidConfigurable -{ +public class ContainerFluidIO extends ContainerFluidConfigurable { - public static ContainerType TYPE; + public static ContainerType TYPE; - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidIO::new, PartSharedFluidBus.class, SecurityPermissions.BUILD); + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidIO::new, PartSharedFluidBus.class, SecurityPermissions.BUILD); - public static ContainerFluidIO fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static ContainerFluidIO fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - private final PartSharedFluidBus bus; + private final PartSharedFluidBus bus; - public ContainerFluidIO(int id, PlayerInventory ip, PartSharedFluidBus te ) - { - super( TYPE, id,ip, te ); - this.bus = te; - } + public ContainerFluidIO(int id, PlayerInventory ip, PartSharedFluidBus te) { + super(TYPE, id, ip, te); + this.bus = te; + } - @Override - public IAEFluidTank getFluidConfigInventory() - { - return this.bus.getConfig(); - } + @Override + public IAEFluidTank getFluidConfigInventory() { + return this.bus.getConfig(); + } - @Override - protected void setupConfig() - { - this.setupUpgrades(); - } + @Override + protected void setupConfig() { + this.setupUpgrades(); + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidInterface.java b/src/main/java/appeng/fluids/container/ContainerFluidInterface.java index 49eed60ec..33bc66947 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidInterface.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidInterface.java @@ -18,6 +18,14 @@ package appeng.fluids.container; +import java.util.Collections; +import java.util.Map; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.IContainerListener; +import net.minecraft.network.PacketBuffer; import appeng.api.config.SecurityPermissions; import appeng.api.storage.data.IAEFluidStack; @@ -29,111 +37,89 @@ import appeng.fluids.helper.FluidSyncHelper; import appeng.fluids.helper.IFluidInterfaceHost; import appeng.fluids.util.IAEFluidTank; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.IContainerListener; -import net.minecraft.network.PacketBuffer; -import java.util.Collections; -import java.util.Map; +public class ContainerFluidInterface extends ContainerFluidConfigurable { + public static ContainerType TYPE; -public class ContainerFluidInterface extends ContainerFluidConfigurable -{ + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidInterface::new, IFluidInterfaceHost.class, SecurityPermissions.BUILD); - public static ContainerType TYPE; + public static ContainerFluidInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidInterface::new, IFluidInterfaceHost.class, SecurityPermissions.BUILD); + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static ContainerFluidInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + private final DualityFluidInterface myDuality; + private final FluidSyncHelper tankSync; - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + public ContainerFluidInterface(int id, final PlayerInventory ip, final IFluidInterfaceHost te) { + super(TYPE, id, ip, te.getDualityFluidInterface().getHost()); - private final DualityFluidInterface myDuality; - private final FluidSyncHelper tankSync; + this.myDuality = te.getDualityFluidInterface(); + this.tankSync = new FluidSyncHelper(this.myDuality.getTanks(), DualityFluidInterface.NUMBER_OF_TANKS); + } - public ContainerFluidInterface(int id, final PlayerInventory ip, final IFluidInterfaceHost te ) - { - super( TYPE, id,ip, te.getDualityFluidInterface().getHost() ); + @Override + protected int getHeight() { + return 231; + } - this.myDuality = te.getDualityFluidInterface(); - this.tankSync = new FluidSyncHelper( this.myDuality.getTanks(), DualityFluidInterface.NUMBER_OF_TANKS ); - } + public IAEFluidTank getTanks() { + return myDuality.getTanks(); + } - @Override - protected int getHeight() - { - return 231; - } + @Override + public IAEFluidTank getFluidConfigInventory() { + return this.myDuality.getConfig(); + } - public IAEFluidTank getTanks() { - return myDuality.getTanks(); - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public IAEFluidTank getFluidConfigInventory() - { - return this.myDuality.getConfig(); - } + if (Platform.isServer()) { + this.tankSync.sendDiff(this.listeners); + } - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + super.detectAndSendChanges(); + } - if( Platform.isServer() ) - { - this.tankSync.sendDiff( this.listeners ); - } + @Override + protected void setupConfig() { + } - super.detectAndSendChanges(); - } + @Override + protected void loadSettingsFromHost(final IConfigManager cm) { + } - @Override - protected void setupConfig() - { - } + @Override + public void addListener(IContainerListener listener) { + super.addListener(listener); + this.tankSync.sendFull(Collections.singleton(listener)); + } - @Override - protected void loadSettingsFromHost( final IConfigManager cm ) - { - } + @Override + public void receiveFluidSlots(Map fluids) { + super.receiveFluidSlots(fluids); + this.tankSync.readPacket(fluids); + } - @Override - public void addListener( IContainerListener listener ) - { - super.addListener( listener ); - this.tankSync.sendFull( Collections.singleton( listener ) ); - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - public void receiveFluidSlots( Map fluids ) - { - super.receiveFluidSlots( fluids ); - this.tankSync.readPacket( fluids ); - } + @Override + public int availableUpgrades() { + return 0; + } - @Override - protected boolean supportCapacity() - { - return false; - } - - @Override - public int availableUpgrades() - { - return 0; - } - - @Override - public boolean hasToolbox() - { - return false; - } + @Override + public boolean hasToolbox() { + return false; + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidLevelEmitter.java b/src/main/java/appeng/fluids/container/ContainerFluidLevelEmitter.java index 9ad549c95..224d0f002 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidLevelEmitter.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidLevelEmitter.java @@ -1,8 +1,5 @@ package appeng.fluids.container; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -14,100 +11,89 @@ import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.config.RedstoneMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; +import appeng.container.ContainerLocator; import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; import appeng.fluids.parts.PartFluidLevelEmitter; import appeng.fluids.util.IAEFluidTank; import appeng.util.Platform; +public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable { + public static ContainerType TYPE; -public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable -{ - public static ContainerType TYPE; + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidLevelEmitter::new, PartFluidLevelEmitter.class, SecurityPermissions.BUILD); - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidLevelEmitter::new, PartFluidLevelEmitter.class, SecurityPermissions.BUILD); + public static ContainerFluidLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } - public static ContainerFluidLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } + private final PartFluidLevelEmitter lvlEmitter; - private final PartFluidLevelEmitter lvlEmitter; + @OnlyIn(Dist.CLIENT) + private TextFieldWidget textField; + @GuiSync(3) + public long EmitterValue = -1; - @OnlyIn( Dist.CLIENT ) - private TextFieldWidget textField; - @GuiSync( 3 ) - public long EmitterValue = -1; + public ContainerFluidLevelEmitter(int id, final PlayerInventory ip, final PartFluidLevelEmitter te) { + super(TYPE, id, ip, te); + this.lvlEmitter = te; + } - public ContainerFluidLevelEmitter(int id, final PlayerInventory ip, final PartFluidLevelEmitter te ) - { - super( TYPE, id,ip, te ); - this.lvlEmitter = te; - } + @OnlyIn(Dist.CLIENT) + public void setTextField(final TextFieldWidget level) { + this.textField = level; + this.textField.setText(String.valueOf(this.EmitterValue)); + } - @OnlyIn( Dist.CLIENT ) - public void setTextField( final TextFieldWidget level ) - { - this.textField = level; - this.textField.setText( String.valueOf( this.EmitterValue ) ); - } + public void setLevel(final long l, final PlayerEntity player) { + this.lvlEmitter.setReportingValue(l); + this.EmitterValue = l; + } - public void setLevel( final long l, final PlayerEntity player ) - { - this.lvlEmitter.setReportingValue( l ); - this.EmitterValue = l; - } + @Override + protected void setupConfig() { + } - @Override - protected void setupConfig() - { - } + @Override + protected boolean supportCapacity() { + return false; + } - @Override - protected boolean supportCapacity() - { - return false; - } + @Override + public int availableUpgrades() { - @Override - public int availableUpgrades() - { + return 0; + } - return 0; - } + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); + if (Platform.isServer()) { + this.EmitterValue = this.lvlEmitter.getReportingValue(); + this.setRedStoneMode( + (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_EMITTER)); + } - if( Platform.isServer() ) - { - this.EmitterValue = this.lvlEmitter.getReportingValue(); - this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) ); - } + this.standardDetectAndSendChanges(); + } - this.standardDetectAndSendChanges(); - } + @Override + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("EmitterValue")) { + if (this.textField != null) { + this.textField.setText(String.valueOf(this.EmitterValue)); + } + } + } - @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "EmitterValue" ) ) - { - if( this.textField != null ) - { - this.textField.setText( String.valueOf( this.EmitterValue ) ); - } - } - } - - @Override - public IAEFluidTank getFluidConfigInventory() - { - return this.lvlEmitter.getConfig(); - } + @Override + public IAEFluidTank getFluidConfigInventory() { + return this.lvlEmitter.getConfig(); + } } diff --git a/src/main/java/appeng/fluids/container/ContainerFluidStorageBus.java b/src/main/java/appeng/fluids/container/ContainerFluidStorageBus.java index 78558233d..2ead9e4d5 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidStorageBus.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidStorageBus.java @@ -1,228 +1,199 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.fluids.container; - - -import java.util.Iterator; - -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.items.IItemHandler; - -import appeng.api.AEApi; -import appeng.api.config.AccessRestriction; -import appeng.api.config.FuzzyMode; -import appeng.api.config.SecurityPermissions; -import appeng.api.config.Settings; -import appeng.api.config.StorageFilter; -import appeng.api.config.Upgrades; -import appeng.api.storage.IMEInventory; -import appeng.api.storage.channels.IFluidStorageChannel; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IItemList; -import appeng.container.guisync.GuiSync; -import appeng.container.slot.SlotRestrictedInput; -import appeng.fluids.parts.PartFluidStorageBus; -import appeng.fluids.util.IAEFluidTank; -import appeng.util.Platform; -import appeng.util.iterators.NullIterator; - - -/** - * @author BrockWS - * @version rv6 - 22/05/2018 - * @since rv6 22/05/2018 - */ -public class ContainerFluidStorageBus extends ContainerFluidConfigurable -{ - - public static ContainerType TYPE; - - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidStorageBus::new, PartFluidStorageBus.class); - - public static ContainerFluidStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } - - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - private final PartFluidStorageBus storageBus; - - @GuiSync( 3 ) - public AccessRestriction rwMode = AccessRestriction.READ_WRITE; - - @GuiSync( 4 ) - public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY; - - public ContainerFluidStorageBus(int id, PlayerInventory ip, PartFluidStorageBus te ) - { - super( TYPE, id,ip, te ); - this.storageBus = te; - } - - @Override - protected int getHeight() - { - return 251; - } - - @Override - protected void setupConfig() - { - final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" ); - this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) ) - .setNotDraggable() ); - this.addSlot( - ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) ) - .setNotDraggable() ); - } - - @Override - protected boolean isValidForConfig( int slot, IAEFluidStack fs ) - { - if( this.supportCapacity() ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); - - final int y = slot / 9; - - if( y >= upgrades + 2 ) - { - return false; - } - } - - return true; - } - - @Override - protected boolean supportCapacity() - { - return true; - } - - @Override - public int availableUpgrades() - { - return 5; - } - - @Override - public void detectAndSendChanges() - { - this.verifyPermissions( SecurityPermissions.BUILD, false ); - - if( Platform.isServer() ) - { - this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) ); - this.setReadWriteMode( (AccessRestriction) this.getUpgradeable().getConfigManager().getSetting( Settings.ACCESS ) ); - this.setStorageFilter( (StorageFilter) this.getUpgradeable().getConfigManager().getSetting( Settings.STORAGE_FILTER ) ); - } - - this.standardDetectAndSendChanges(); - } - - @Override - public boolean isSlotEnabled( final int idx ) - { - final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY ); - - return upgrades > idx; - } - - public void clear() - { - IAEFluidTank h = this.storageBus.getConfig(); - for( int i = 0; i < h.getSlots(); ++i ) - { - h.setFluidInSlot( i, null ); - } - this.detectAndSendChanges(); - } - - public void partition() - { - IAEFluidTank h = this.storageBus.getConfig(); - - final IMEInventory cellInv = this.storageBus.getInternalHandler(); - - Iterator i = new NullIterator<>(); - if( cellInv != null ) - { - final IItemList list = cellInv - .getAvailableItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList() ); - i = list.iterator(); - } - - for( int x = 0; x < h.getSlots(); x++ ) - { - if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) ) - { - h.setFluidInSlot( x, i.next() ); - } - else - { - h.setFluidInSlot( x, null ); - } - } - this.detectAndSendChanges(); - } - - public AccessRestriction getReadWriteMode() - { - return this.rwMode; - } - - private void setReadWriteMode( final AccessRestriction rwMode ) - { - this.rwMode = rwMode; - } - - public StorageFilter getStorageFilter() - { - return this.storageFilter; - } - - private void setStorageFilter( final StorageFilter storageFilter ) - { - this.storageFilter = storageFilter; - } - - @Override - public IAEFluidTank getFluidConfigInventory() - { - return this.storageBus.getConfig(); - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.fluids.container; + +import java.util.Iterator; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.IItemHandler; + +import appeng.api.AEApi; +import appeng.api.config.AccessRestriction; +import appeng.api.config.FuzzyMode; +import appeng.api.config.SecurityPermissions; +import appeng.api.config.Settings; +import appeng.api.config.StorageFilter; +import appeng.api.config.Upgrades; +import appeng.api.storage.IMEInventory; +import appeng.api.storage.channels.IFluidStorageChannel; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IItemList; +import appeng.container.ContainerLocator; +import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; +import appeng.container.slot.SlotRestrictedInput; +import appeng.fluids.parts.PartFluidStorageBus; +import appeng.fluids.util.IAEFluidTank; +import appeng.util.Platform; +import appeng.util.iterators.NullIterator; + +/** + * @author BrockWS + * @version rv6 - 22/05/2018 + * @since rv6 22/05/2018 + */ +public class ContainerFluidStorageBus extends ContainerFluidConfigurable { + + public static ContainerType TYPE; + + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidStorageBus::new, PartFluidStorageBus.class); + + public static ContainerFluidStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } + + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } + + private final PartFluidStorageBus storageBus; + + @GuiSync(3) + public AccessRestriction rwMode = AccessRestriction.READ_WRITE; + + @GuiSync(4) + public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY; + + public ContainerFluidStorageBus(int id, PlayerInventory ip, PartFluidStorageBus te) { + super(TYPE, id, ip, te); + this.storageBus = te; + } + + @Override + protected int getHeight() { + return 251; + } + + @Override + protected void setupConfig() { + final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, + this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, + 8 + 18 * 2, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, + 8 + 18 * 3, this.getPlayerInventory())).setNotDraggable()); + this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, + 8 + 18 * 4, this.getPlayerInventory())).setNotDraggable()); + } + + @Override + protected boolean isValidForConfig(int slot, IAEFluidStack fs) { + if (this.supportCapacity()) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); + + final int y = slot / 9; + + if (y >= upgrades + 2) { + return false; + } + } + + return true; + } + + @Override + protected boolean supportCapacity() { + return true; + } + + @Override + public int availableUpgrades() { + return 5; + } + + @Override + public void detectAndSendChanges() { + this.verifyPermissions(SecurityPermissions.BUILD, false); + + if (Platform.isServer()) { + this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE)); + this.setReadWriteMode( + (AccessRestriction) this.getUpgradeable().getConfigManager().getSetting(Settings.ACCESS)); + this.setStorageFilter( + (StorageFilter) this.getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER)); + } + + this.standardDetectAndSendChanges(); + } + + @Override + public boolean isSlotEnabled(final int idx) { + final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY); + + return upgrades > idx; + } + + public void clear() { + IAEFluidTank h = this.storageBus.getConfig(); + for (int i = 0; i < h.getSlots(); ++i) { + h.setFluidInSlot(i, null); + } + this.detectAndSendChanges(); + } + + public void partition() { + IAEFluidTank h = this.storageBus.getConfig(); + + final IMEInventory cellInv = this.storageBus.getInternalHandler(); + + Iterator i = new NullIterator<>(); + if (cellInv != null) { + final IItemList list = cellInv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList()); + i = list.iterator(); + } + + for (int x = 0; x < h.getSlots(); x++) { + if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) { + h.setFluidInSlot(x, i.next()); + } else { + h.setFluidInSlot(x, null); + } + } + this.detectAndSendChanges(); + } + + public AccessRestriction getReadWriteMode() { + return this.rwMode; + } + + private void setReadWriteMode(final AccessRestriction rwMode) { + this.rwMode = rwMode; + } + + public StorageFilter getStorageFilter() { + return this.storageFilter; + } + + private void setStorageFilter(final StorageFilter storageFilter) { + this.storageFilter = storageFilter; + } + + @Override + public IAEFluidTank getFluidConfigInventory() { + return this.storageBus.getConfig(); + } +} diff --git a/src/main/java/appeng/fluids/container/ContainerFluidTerminal.java b/src/main/java/appeng/fluids/container/ContainerFluidTerminal.java index 6074e3e71..b4d05d868 100644 --- a/src/main/java/appeng/fluids/container/ContainerFluidTerminal.java +++ b/src/main/java/appeng/fluids/container/ContainerFluidTerminal.java @@ -1,504 +1,429 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.fluids.container; - - -import java.io.IOException; -import java.nio.BufferOverflowException; -import javax.annotation.Nonnull; - -import appeng.api.AEApi; -import appeng.api.config.*; -import appeng.container.ContainerLocator; -import appeng.container.implementations.ContainerHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.IContainerListener; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; -import net.minecraftforge.fluids.capability.IFluidHandlerItem; - -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridHost; -import appeng.api.networking.IGridNode; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.energy.IEnergySource; -import appeng.api.networking.security.IActionHost; -import appeng.api.networking.security.IActionSource; -import appeng.api.networking.storage.IBaseMonitor; -import appeng.api.storage.IMEMonitor; -import appeng.api.storage.IMEMonitorHandlerReceiver; -import appeng.api.storage.ITerminalHost; -import appeng.api.storage.channels.IFluidStorageChannel; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IItemList; -import appeng.api.util.AEPartLocation; -import appeng.api.util.IConfigManager; -import appeng.api.util.IConfigurableObject; -import appeng.container.AEBaseContainer; -import appeng.container.guisync.GuiSync; -import appeng.core.AELog; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketMEFluidInventoryUpdate; -import appeng.core.sync.packets.PacketTargetFluidStack; -import appeng.core.sync.packets.PacketValueConfig; -import appeng.fluids.util.AEFluidStack; -import appeng.helpers.InventoryAction; -import appeng.me.helpers.ChannelPowerSrc; -import appeng.util.ConfigManager; -import appeng.util.IConfigManagerHost; -import appeng.util.Platform; - - -/** - * @author BrockWS - * @version rv6 - 12/05/2018 - * @since rv6 12/05/2018 - */ -public class ContainerFluidTerminal extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver -{ - - public static ContainerType TYPE; - - private static final ContainerHelper helper - = new ContainerHelper<>(ContainerFluidTerminal::new, ITerminalHost.class, SecurityPermissions.BUILD); - - public static ContainerFluidTerminal fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { - return helper.fromNetwork(windowId, inv, buf); - } - - public static boolean open(PlayerEntity player, ContainerLocator locator) { - return helper.open(player, locator); - } - - private final IConfigManager clientCM; - private final IMEMonitor monitor; - private final IItemList fluids = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); - @GuiSync( 99 ) - public boolean hasPower = false; - private ITerminalHost terminal; - private IConfigManager serverCM; - private IConfigManagerHost gui; - private IGridNode networkNode; - // Holds the fluid the client wishes to extract, or null for insert - private IAEFluidStack clientRequestedTargetFluid = null; - - public ContainerFluidTerminal(int id, PlayerInventory ip, ITerminalHost terminal) { - super(TYPE, id, ip, terminal); - this.terminal = terminal; - this.clientCM = new ConfigManager( this ); - - this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); - this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - if( Platform.isServer() ) - { - this.serverCM = terminal.getConfigManager(); - this.monitor = terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); - - if( this.monitor != null ) - { - this.monitor.addListener( this, null ); - - if( terminal instanceof IEnergySource ) - { - this.setPowerSource( (IEnergySource) terminal ); - } - else if( terminal instanceof IGridHost || terminal instanceof IActionHost ) - { - final IGridNode node; - if( terminal instanceof IGridHost ) - { - node = ( (IGridHost) terminal ).getGridNode( AEPartLocation.INTERNAL ); - } - else if( terminal instanceof IActionHost ) - { - node = ( (IActionHost) terminal ).getActionableNode(); - } - else - { - node = null; - } - - if( node != null ) - { - this.networkNode = node; - final IGrid g = node.getGrid(); - if( g != null ) - { - this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) ); - } - } - } - } - } - else - { - this.monitor = null; - } - this.bindPlayerInventory( ip, 0, 222 - 82 ); - } - - @Override - public boolean isValid( Object verificationToken ) - { - return true; - } - - @Override - public void postChange( IBaseMonitor monitor, Iterable change, IActionSource actionSource ) - { - for( final IAEFluidStack is : change ) - { - this.fluids.add( is ); - } - } - - @Override - public void onListUpdate() - { - for( final IContainerListener c : this.listeners ) - { - this.queueInventory( c ); - } - } - - @Override - public void addListener( IContainerListener listener ) - { - super.addListener( listener ); - - this.queueInventory( listener ); - } - - @Override - public void onContainerClosed( final PlayerEntity player ) - { - super.onContainerClosed( player ); - if( this.monitor != null ) - { - this.monitor.removeListener( this ); - } - } - - private void queueInventory( final IContainerListener c ) - { - if( Platform.isServer() && c instanceof PlayerEntity && this.monitor != null ) - { - try - { - PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate(); - final IItemList monitorCache = this.monitor.getStorageList(); - - for( final IAEFluidStack send : monitorCache ) - { - try - { - piu.appendFluid( send ); - } - catch( final BufferOverflowException boe ) - { - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - - piu = new PacketMEFluidInventoryUpdate(); - piu.appendFluid( send ); - } - } - - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - } - catch( final IOException e ) - { - AELog.debug( e ); - } - } - } - - @Override - public IConfigManager getConfigManager() - { - if( Platform.isServer() ) - { - return this.serverCM; - } - return this.clientCM; - } - - public void setTargetStack( final IAEFluidStack stack ) - { - if( Platform.isClient() ) - { - if( stack == null && this.clientRequestedTargetFluid == null ) - { - return; - } - if( stack != null && this.clientRequestedTargetFluid != null && stack.getFluidStack() - .isFluidEqual( this.clientRequestedTargetFluid.getFluidStack() ) ) - { - return; - } - NetworkHandler.instance().sendToServer( new PacketTargetFluidStack( (AEFluidStack) stack ) ); - } - - this.clientRequestedTargetFluid = stack == null ? null : stack.copy(); - } - - @Override - public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue ) - { - if( this.getGui() != null ) - { - this.getGui().updateSetting( manager, settingName, newValue ); - } - } - - @Override - public void detectAndSendChanges() - { - if( Platform.isServer() ) - { - if( this.monitor != this.terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) ) - { - this.setValidContainer( false ); - } - - for( final Settings set : this.serverCM.getSettings() ) - { - final Enum sideLocal = this.serverCM.getSetting( set ); - final Enum sideRemote = this.clientCM.getSetting( set ); - - if( sideLocal != sideRemote ) - { - this.clientCM.putSetting( set, sideLocal ); - for( final IContainerListener crafter : this.listeners ) - { - if( crafter instanceof ServerPlayerEntity ) - { - NetworkHandler.instance().sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (ServerPlayerEntity) crafter ); - } - } - } - } - - if( !this.fluids.isEmpty() ) - { - try - { - final IItemList monitorCache = this.monitor.getStorageList(); - - final PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate(); - - for( final IAEFluidStack is : this.fluids ) - { - final IAEFluidStack send = monitorCache.findPrecise( is ); - if( send == null ) - { - is.setStackSize( 0 ); - piu.appendFluid( is ); - } - else - { - piu.appendFluid( send ); - } - } - - if( !piu.isEmpty() ) - { - this.fluids.resetStatus(); - - for( final Object c : this.listeners ) - { - if( c instanceof PlayerEntity ) - { - NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c ); - } - } - } - } - catch( final IOException e ) - { - AELog.debug( e ); - } - } - this.updatePowerStatus(); - - super.detectAndSendChanges(); - } - } - - @Override - public void doAction( ServerPlayerEntity player, InventoryAction action, int slot, long id ) - { - if( action != InventoryAction.FILL_ITEM && action != InventoryAction.EMPTY_ITEM ) - { - super.doAction( player, action, slot, id ); - return; - } - - final ItemStack held = player.inventory.getItemStack(); - if( held.getCount() != 1 ) - { - // only support stacksize 1 for now - return; - } - - final LazyOptional fhOpt = FluidUtil.getFluidHandler( held ); - if( !fhOpt.isPresent() ) - { - // only fluid handlers items - return; - } - IFluidHandlerItem fh = fhOpt.orElse( null ); - - if( action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null ) - { - final IAEFluidStack stack = this.clientRequestedTargetFluid.copy(); - - // Check how much we can store in the item - stack.setStackSize( Integer.MAX_VALUE ); - int amountAllowed = fh.fill( stack.getFluidStack(), FluidAction.SIMULATE ); - stack.setStackSize( amountAllowed ); - - // Check if we can pull out of the system - final IAEFluidStack canPull = Platform.poweredExtraction( this.getPowerSource(), this.monitor, stack, this.getActionSource(), Actionable.SIMULATE ); - if( canPull == null || canPull.getStackSize() < 1 ) - { - return; - } - - // How much could fit into the container - final int canFill = fh.fill( canPull.getFluidStack(), FluidAction.SIMULATE ); - if( canFill == 0 ) - { - return; - } - - // Now actually pull out of the system - stack.setStackSize( canFill ); - final IAEFluidStack pulled = Platform.poweredExtraction( this.getPowerSource(), this.monitor, stack, this.getActionSource() ); - if( pulled == null || pulled.getStackSize() < 1 ) - { - // Something went wrong - AELog.error( "Unable to pull fluid out of the ME system even though the simulation said yes " ); - return; - } - - // Actually fill - final int used = fh.fill( pulled.getFluidStack(), FluidAction.EXECUTE ); - - if( used != canFill ) - { - AELog.error( "Fluid item [%s] reported a different possible amount than it actually accepted.", held.getDisplayName() ); - } - - player.inventory.setItemStack( fh.getContainer() ); - this.updateHeld( player ); - } - else if( action == InventoryAction.EMPTY_ITEM ) - { - // See how much we can drain from the item - final FluidStack extract = fh.drain( Integer.MAX_VALUE, FluidAction.SIMULATE ); - if( extract == null || extract.getAmount() < 1 ) - { - return; - } - - // Check if we can push into the system - final IAEFluidStack notStorable = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), this.getActionSource(), Actionable.SIMULATE ); - - if( notStorable != null && notStorable.getStackSize() > 0 ) - { - final int toStore = (int) ( extract.getAmount() - notStorable.getStackSize() ); - final FluidStack storable = fh.drain( toStore, FluidAction.SIMULATE ); - - if( storable == null || storable.getAmount() == 0 ) - { - return; - } - else - { - extract.setAmount( storable.getAmount() ); - } - } - - // Actually drain - final FluidStack drained = fh.drain( extract, FluidAction.EXECUTE ); - extract.setAmount( drained.getAmount() ); - - final IAEFluidStack notInserted = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), this.getActionSource() ); - - if( notInserted != null && notInserted.getStackSize() > 0 ) - { - AELog.error( "Fluid item [%s] reported a different possible amount to drain than it actually provided.", held.getDisplayName() ); - } - - player.inventory.setItemStack( fh.getContainer() ); - this.updateHeld( player ); - } - } - - protected void updatePowerStatus() - { - try - { - if( this.networkNode != null ) - { - this.setPowered( this.networkNode.isActive() ); - } - else if( this.getPowerSource() instanceof IEnergyGrid ) - { - this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() ); - } - else - { - this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 ); - } - } - catch( final Exception ignore ) - { - // :P - } - } - - private IConfigManagerHost getGui() - { - return this.gui; - } - - public void setGui( @Nonnull final IConfigManagerHost gui ) - { - this.gui = gui; - } - - public boolean isPowered() - { - return this.hasPower; - } - - private void setPowered( final boolean isPowered ) - { - this.hasPower = isPowered; - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.fluids.container; + +import java.io.IOException; +import java.nio.BufferOverflowException; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.IContainerListener; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidUtil; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; + +import appeng.api.AEApi; +import appeng.api.config.*; +import appeng.api.networking.IGrid; +import appeng.api.networking.IGridHost; +import appeng.api.networking.IGridNode; +import appeng.api.networking.energy.IEnergyGrid; +import appeng.api.networking.energy.IEnergySource; +import appeng.api.networking.security.IActionHost; +import appeng.api.networking.security.IActionSource; +import appeng.api.networking.storage.IBaseMonitor; +import appeng.api.storage.IMEMonitor; +import appeng.api.storage.IMEMonitorHandlerReceiver; +import appeng.api.storage.ITerminalHost; +import appeng.api.storage.channels.IFluidStorageChannel; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IItemList; +import appeng.api.util.AEPartLocation; +import appeng.api.util.IConfigManager; +import appeng.api.util.IConfigurableObject; +import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerHelper; +import appeng.core.AELog; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketMEFluidInventoryUpdate; +import appeng.core.sync.packets.PacketTargetFluidStack; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.fluids.util.AEFluidStack; +import appeng.helpers.InventoryAction; +import appeng.me.helpers.ChannelPowerSrc; +import appeng.util.ConfigManager; +import appeng.util.IConfigManagerHost; +import appeng.util.Platform; + +/** + * @author BrockWS + * @version rv6 - 12/05/2018 + * @since rv6 12/05/2018 + */ +public class ContainerFluidTerminal extends AEBaseContainer + implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver { + + public static ContainerType TYPE; + + private static final ContainerHelper helper = new ContainerHelper<>( + ContainerFluidTerminal::new, ITerminalHost.class, SecurityPermissions.BUILD); + + public static ContainerFluidTerminal fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { + return helper.fromNetwork(windowId, inv, buf); + } + + public static boolean open(PlayerEntity player, ContainerLocator locator) { + return helper.open(player, locator); + } + + private final IConfigManager clientCM; + private final IMEMonitor monitor; + private final IItemList fluids = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createList(); + @GuiSync(99) + public boolean hasPower = false; + private ITerminalHost terminal; + private IConfigManager serverCM; + private IConfigManagerHost gui; + private IGridNode networkNode; + // Holds the fluid the client wishes to extract, or null for insert + private IAEFluidStack clientRequestedTargetFluid = null; + + public ContainerFluidTerminal(int id, PlayerInventory ip, ITerminalHost terminal) { + super(TYPE, id, ip, terminal); + this.terminal = terminal; + this.clientCM = new ConfigManager(this); + + this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); + this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + if (Platform.isServer()) { + this.serverCM = terminal.getConfigManager(); + this.monitor = terminal + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + + if (this.monitor != null) { + this.monitor.addListener(this, null); + + if (terminal instanceof IEnergySource) { + this.setPowerSource((IEnergySource) terminal); + } else if (terminal instanceof IGridHost || terminal instanceof IActionHost) { + final IGridNode node; + if (terminal instanceof IGridHost) { + node = ((IGridHost) terminal).getGridNode(AEPartLocation.INTERNAL); + } else if (terminal instanceof IActionHost) { + node = ((IActionHost) terminal).getActionableNode(); + } else { + node = null; + } + + if (node != null) { + this.networkNode = node; + final IGrid g = node.getGrid(); + if (g != null) { + this.setPowerSource(new ChannelPowerSrc(this.networkNode, + (IEnergySource) g.getCache(IEnergyGrid.class))); + } + } + } + } + } else { + this.monitor = null; + } + this.bindPlayerInventory(ip, 0, 222 - 82); + } + + @Override + public boolean isValid(Object verificationToken) { + return true; + } + + @Override + public void postChange(IBaseMonitor monitor, Iterable change, + IActionSource actionSource) { + for (final IAEFluidStack is : change) { + this.fluids.add(is); + } + } + + @Override + public void onListUpdate() { + for (final IContainerListener c : this.listeners) { + this.queueInventory(c); + } + } + + @Override + public void addListener(IContainerListener listener) { + super.addListener(listener); + + this.queueInventory(listener); + } + + @Override + public void onContainerClosed(final PlayerEntity player) { + super.onContainerClosed(player); + if (this.monitor != null) { + this.monitor.removeListener(this); + } + } + + private void queueInventory(final IContainerListener c) { + if (Platform.isServer() && c instanceof PlayerEntity && this.monitor != null) { + try { + PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate(); + final IItemList monitorCache = this.monitor.getStorageList(); + + for (final IAEFluidStack send : monitorCache) { + try { + piu.appendFluid(send); + } catch (final BufferOverflowException boe) { + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + + piu = new PacketMEFluidInventoryUpdate(); + piu.appendFluid(send); + } + } + + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + } catch (final IOException e) { + AELog.debug(e); + } + } + } + + @Override + public IConfigManager getConfigManager() { + if (Platform.isServer()) { + return this.serverCM; + } + return this.clientCM; + } + + public void setTargetStack(final IAEFluidStack stack) { + if (Platform.isClient()) { + if (stack == null && this.clientRequestedTargetFluid == null) { + return; + } + if (stack != null && this.clientRequestedTargetFluid != null + && stack.getFluidStack().isFluidEqual(this.clientRequestedTargetFluid.getFluidStack())) { + return; + } + NetworkHandler.instance().sendToServer(new PacketTargetFluidStack((AEFluidStack) stack)); + } + + this.clientRequestedTargetFluid = stack == null ? null : stack.copy(); + } + + @Override + public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue) { + if (this.getGui() != null) { + this.getGui().updateSetting(manager, settingName, newValue); + } + } + + @Override + public void detectAndSendChanges() { + if (Platform.isServer()) { + if (this.monitor != this.terminal + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) { + this.setValidContainer(false); + } + + for (final Settings set : this.serverCM.getSettings()) { + final Enum sideLocal = this.serverCM.getSetting(set); + final Enum sideRemote = this.clientCM.getSetting(set); + + if (sideLocal != sideRemote) { + this.clientCM.putSetting(set, sideLocal); + for (final IContainerListener crafter : this.listeners) { + if (crafter instanceof ServerPlayerEntity) { + NetworkHandler.instance().sendTo(new PacketValueConfig(set.name(), sideLocal.name()), + (ServerPlayerEntity) crafter); + } + } + } + } + + if (!this.fluids.isEmpty()) { + try { + final IItemList monitorCache = this.monitor.getStorageList(); + + final PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate(); + + for (final IAEFluidStack is : this.fluids) { + final IAEFluidStack send = monitorCache.findPrecise(is); + if (send == null) { + is.setStackSize(0); + piu.appendFluid(is); + } else { + piu.appendFluid(send); + } + } + + if (!piu.isEmpty()) { + this.fluids.resetStatus(); + + for (final Object c : this.listeners) { + if (c instanceof PlayerEntity) { + NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c); + } + } + } + } catch (final IOException e) { + AELog.debug(e); + } + } + this.updatePowerStatus(); + + super.detectAndSendChanges(); + } + } + + @Override + public void doAction(ServerPlayerEntity player, InventoryAction action, int slot, long id) { + if (action != InventoryAction.FILL_ITEM && action != InventoryAction.EMPTY_ITEM) { + super.doAction(player, action, slot, id); + return; + } + + final ItemStack held = player.inventory.getItemStack(); + if (held.getCount() != 1) { + // only support stacksize 1 for now + return; + } + + final LazyOptional fhOpt = FluidUtil.getFluidHandler(held); + if (!fhOpt.isPresent()) { + // only fluid handlers items + return; + } + IFluidHandlerItem fh = fhOpt.orElse(null); + + if (action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null) { + final IAEFluidStack stack = this.clientRequestedTargetFluid.copy(); + + // Check how much we can store in the item + stack.setStackSize(Integer.MAX_VALUE); + int amountAllowed = fh.fill(stack.getFluidStack(), FluidAction.SIMULATE); + stack.setStackSize(amountAllowed); + + // Check if we can pull out of the system + final IAEFluidStack canPull = Platform.poweredExtraction(this.getPowerSource(), this.monitor, stack, + this.getActionSource(), Actionable.SIMULATE); + if (canPull == null || canPull.getStackSize() < 1) { + return; + } + + // How much could fit into the container + final int canFill = fh.fill(canPull.getFluidStack(), FluidAction.SIMULATE); + if (canFill == 0) { + return; + } + + // Now actually pull out of the system + stack.setStackSize(canFill); + final IAEFluidStack pulled = Platform.poweredExtraction(this.getPowerSource(), this.monitor, stack, + this.getActionSource()); + if (pulled == null || pulled.getStackSize() < 1) { + // Something went wrong + AELog.error("Unable to pull fluid out of the ME system even though the simulation said yes "); + return; + } + + // Actually fill + final int used = fh.fill(pulled.getFluidStack(), FluidAction.EXECUTE); + + if (used != canFill) { + AELog.error("Fluid item [%s] reported a different possible amount than it actually accepted.", + held.getDisplayName()); + } + + player.inventory.setItemStack(fh.getContainer()); + this.updateHeld(player); + } else if (action == InventoryAction.EMPTY_ITEM) { + // See how much we can drain from the item + final FluidStack extract = fh.drain(Integer.MAX_VALUE, FluidAction.SIMULATE); + if (extract == null || extract.getAmount() < 1) { + return; + } + + // Check if we can push into the system + final IAEFluidStack notStorable = Platform.poweredInsert(this.getPowerSource(), this.monitor, + AEFluidStack.fromFluidStack(extract), this.getActionSource(), Actionable.SIMULATE); + + if (notStorable != null && notStorable.getStackSize() > 0) { + final int toStore = (int) (extract.getAmount() - notStorable.getStackSize()); + final FluidStack storable = fh.drain(toStore, FluidAction.SIMULATE); + + if (storable == null || storable.getAmount() == 0) { + return; + } else { + extract.setAmount(storable.getAmount()); + } + } + + // Actually drain + final FluidStack drained = fh.drain(extract, FluidAction.EXECUTE); + extract.setAmount(drained.getAmount()); + + final IAEFluidStack notInserted = Platform.poweredInsert(this.getPowerSource(), this.monitor, + AEFluidStack.fromFluidStack(extract), this.getActionSource()); + + if (notInserted != null && notInserted.getStackSize() > 0) { + AELog.error("Fluid item [%s] reported a different possible amount to drain than it actually provided.", + held.getDisplayName()); + } + + player.inventory.setItemStack(fh.getContainer()); + this.updateHeld(player); + } + } + + protected void updatePowerStatus() { + try { + if (this.networkNode != null) { + this.setPowered(this.networkNode.isActive()); + } else if (this.getPowerSource() instanceof IEnergyGrid) { + this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered()); + } else { + this.setPowered( + this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8); + } + } catch (final Exception ignore) { + // :P + } + } + + private IConfigManagerHost getGui() { + return this.gui; + } + + public void setGui(@Nonnull final IConfigManagerHost gui) { + this.gui = gui; + } + + public boolean isPowered() { + return this.hasPower; + } + + private void setPowered(final boolean isPowered) { + this.hasPower = isPowered; + } +} diff --git a/src/main/java/appeng/fluids/container/IFluidSyncContainer.java b/src/main/java/appeng/fluids/container/IFluidSyncContainer.java index ef3307bf4..c07a0fe8c 100644 --- a/src/main/java/appeng/fluids/container/IFluidSyncContainer.java +++ b/src/main/java/appeng/fluids/container/IFluidSyncContainer.java @@ -1,13 +1,10 @@ package appeng.fluids.container; - import java.util.Map; import appeng.api.storage.data.IAEFluidStack; - -public interface IFluidSyncContainer -{ - void receiveFluidSlots( final Map fluids ); +public interface IFluidSyncContainer { + void receiveFluidSlots(final Map fluids); } diff --git a/src/main/java/appeng/fluids/container/slots/IMEFluidSlot.java b/src/main/java/appeng/fluids/container/slots/IMEFluidSlot.java index b8addaf30..d13504f78 100644 --- a/src/main/java/appeng/fluids/container/slots/IMEFluidSlot.java +++ b/src/main/java/appeng/fluids/container/slots/IMEFluidSlot.java @@ -18,21 +18,17 @@ package appeng.fluids.container.slots; - import appeng.api.storage.data.IAEFluidStack; - /** * @author yueh * @version rv6 * @since rv6 */ -public interface IMEFluidSlot -{ - IAEFluidStack getAEFluidStack(); +public interface IMEFluidSlot { + IAEFluidStack getAEFluidStack(); - default boolean shouldRenderAsFluid() - { - return true; - } + default boolean shouldRenderAsFluid() { + return true; + } } diff --git a/src/main/java/appeng/fluids/helper/DualityFluidInterface.java b/src/main/java/appeng/fluids/helper/DualityFluidInterface.java index 2c0f78eef..e8b36d9db 100644 --- a/src/main/java/appeng/fluids/helper/DualityFluidInterface.java +++ b/src/main/java/appeng/fluids/helper/DualityFluidInterface.java @@ -18,10 +18,8 @@ package appeng.fluids.helper; - import java.util.Optional; -import appeng.api.config.Settings; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -34,6 +32,7 @@ import net.minecraftforge.items.IItemHandler; import appeng.api.AEApi; import appeng.api.config.Actionable; +import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.implementations.IUpgradeableHost; import appeng.api.networking.GridFlags; @@ -73,547 +72,440 @@ import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; import appeng.util.Platform; - -public class DualityFluidInterface implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost -{ - public static final int NUMBER_OF_TANKS = 6; - public static final int TANK_CAPACITY = FluidAttributes.BUCKET_VOLUME * 4; - - private final ConfigManager cm = new ConfigManager( this ); - private final AENetworkProxy gridProxy; - private final IFluidInterfaceHost iHost; - private final IActionSource mySource; - private final IActionSource interfaceRequestSource; - private boolean hasConfig = false; - private final IStorageMonitorableAccessor accessor = this::getMonitorable; - private final AEFluidInventory tanks = new AEFluidInventory( this, NUMBER_OF_TANKS, TANK_CAPACITY ); - private final AEFluidInventory config = new AEFluidInventory( this, NUMBER_OF_TANKS ); - private final IAEFluidStack[] requireWork; - private int isWorking = -1; - private int priority; - - private final MEMonitorPassThrough items = new MEMonitorPassThrough<>( new NullInventory(), AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ) ); - private final MEMonitorPassThrough fluids = new MEMonitorPassThrough<>( new NullInventory(), AEApi.instance() - .storage() - .getStorageChannel( IFluidStorageChannel.class ) ); - - public DualityFluidInterface( final AENetworkProxy networkProxy, final IFluidInterfaceHost ih ) - { - this.gridProxy = networkProxy; - this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); - this.iHost = ih; - - this.mySource = new MachineSource( this.iHost ); - this.interfaceRequestSource = new InterfaceRequestSource( this.iHost ); - - this.fluids.setChangeSource( this.mySource ); - this.items.setChangeSource( this.mySource ); - - this.requireWork = new IAEFluidStack[NUMBER_OF_TANKS]; - for( int i = 0; i < NUMBER_OF_TANKS; ++i ) - { - this.requireWork[i] = null; - } - } - - public IUpgradeableHost getHost() - { - if( this.iHost instanceof IUpgradeableHost ) - { - return this.iHost; - } - if( this.iHost instanceof IUpgradeableHost ) - { - return this.iHost; - } - return null; - } - - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - if( this.hasConfig() ) - { - return null; - } - - return (IMEMonitor) this.items; - } - else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) - { - if( this.hasConfig() ) - { - return (IMEMonitor) new InterfaceInventory( this ); - } - - return (IMEMonitor) this.fluids; - } - - return null; - } - - public IStorageMonitorable getMonitorable( final IActionSource src ) - { - if( Platform.canAccess( this.gridProxy, src ) ) - { - return this; - } - - return null; - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( !this.gridProxy.isActive() ) - { - return TickRateModulation.SLEEP; - } - - final boolean couldDoWork = this.updateStorage(); - return this.hasWorkToDo() ? ( couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER ) : TickRateModulation.SLEEP; - } - - public void notifyNeighbors() - { - if( this.gridProxy.isActive() ) - { - try - { - this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - final TileEntity te = this.iHost.getTileEntity(); - if( te != null && te.getWorld() != null ) - { - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() ); - } - } - - public void gridChanged() - { - try - { - this.items.setInternal( this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - this.fluids.setInternal( this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) ); - } - catch( final GridAccessException gae ) - { - this.items.setInternal( new NullInventory() ); - this.fluids.setInternal( new NullInventory() ); - } - - this.notifyNeighbors(); - } - - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } - - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this.iHost.getTileEntity() ); - } - - @SuppressWarnings( "unchecked" ) - public LazyOptional getCapability( Capability capabilityClass, Direction facing ) - { - if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() -> this.tanks); - } - else if( capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR ) - { - return (LazyOptional) LazyOptional.of(() -> this.accessor); - } - return null; - } - - private boolean hasConfig() - { - return this.hasConfig; - } - - private void readConfig() - { - this.hasConfig = false; - - for( int i = 0; i < this.config.getSlots(); i++ ) - { - if( this.config.getFluidInSlot( i ) != null ) - { - this.hasConfig = true; - break; - } - } - - final boolean had = this.hasWorkToDo(); - - for( int x = 0; x < NUMBER_OF_TANKS; x++ ) - { - this.updatePlan( x ); - } - - final boolean has = this.hasWorkToDo(); - - if( had != has ) - { - try - { - if( has ) - { - this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); - } - else - { - this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - - this.notifyNeighbors(); - } - - private boolean updateStorage() - { - boolean didSomething = false; - for( int x = 0; x < NUMBER_OF_TANKS; x++ ) - { - if( this.requireWork[x] != null ) - { - didSomething = this.usePlan( x ) || didSomething; - } - } - return didSomething; - } - - private boolean hasWorkToDo() - { - for( final IAEFluidStack requiredWork : this.requireWork ) - { - if( requiredWork != null ) - { - return true; - } - } - - return false; - } - - private void updatePlan( final int slot ) - { - final IAEFluidStack req = this.config.getFluidInSlot( slot ); - final IAEFluidStack stored = this.tanks.getFluidInSlot( slot ); - - if( req == null && ( stored != null && stored.getStackSize() > 0 ) ) - { - final IAEFluidStack work = stored.copy(); - this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); - return; - } - else if( req != null ) - { - if( stored == null || stored.getStackSize() == 0 ) // need to add stuff! - { - this.requireWork[slot] = req.copy(); - this.requireWork[slot].setStackSize( TANK_CAPACITY ); - return; - } - else if( req.equals( stored ) ) // same type ( qty different? )! - { - if( stored.getStackSize() < TANK_CAPACITY ) - { - this.requireWork[slot] = req.copy(); - this.requireWork[slot].setStackSize( TANK_CAPACITY - stored.getStackSize() ); - return; - } - } - else - // Stored != null; dispose! - { - final IAEFluidStack work = stored.copy(); - this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); - return; - } - } - - this.requireWork[slot] = null; - } - - private boolean usePlan( final int slot ) - { - IAEFluidStack work = this.requireWork[slot]; - this.isWorking = slot; - - boolean changed = false; - try - { - final IMEInventory dest = this.gridProxy.getStorage() - .getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); - final IEnergySource src = this.gridProxy.getEnergy(); - - if( work.getStackSize() > 0 ) - { - // make sure strange things didn't happen... - if( this.tanks.fill( slot, work.getFluidStack(), false ) != work.getStackSize() ) - { - changed = true; - } - else - { - final IAEFluidStack acquired = Platform.poweredExtraction( src, dest, work, this.interfaceRequestSource ); - if( acquired != null ) - { - changed = true; - final int filled = this.tanks.fill( slot, acquired.getFluidStack(), true ); - if( filled != acquired.getStackSize() ) - { - throw new IllegalStateException( "bad attempt at managing tanks. ( fill )" ); - } - } - } - } - else if( work.getStackSize() < 0 ) - { - IAEFluidStack toStore = work.copy(); - toStore.setStackSize( -toStore.getStackSize() ); - - // make sure strange things didn't happen... - final FluidStack canExtract = this.tanks.drain( slot, toStore.getFluidStack(), false ); - if( canExtract == null || canExtract.getAmount() != toStore.getStackSize() ) - { - changed = true; - } - else - { - IAEFluidStack notStored = Platform.poweredInsert( src, dest, toStore, this.interfaceRequestSource ); - toStore.setStackSize( toStore.getStackSize() - ( notStored == null ? 0 : notStored.getStackSize() ) ); - - if( toStore.getStackSize() > 0 ) - { - // extract items! - changed = true; - final FluidStack removed = this.tanks.drain( slot, toStore.getFluidStack(), true ); - if( removed == null || toStore.getStackSize() != removed.getAmount() ) - { - throw new IllegalStateException( "bad attempt at managing tanks. ( drain )" ); - } - } - } - } - } - catch( final GridAccessException e ) - { - // :P - } - - if( changed ) - { - this.updatePlan( slot ); - } - - this.isWorking = -1; - return changed; - } - - @Override - public void onFluidInventoryChanged( final IAEFluidTank inventory, final int slot ) - { - if( this.isWorking == slot ) - { - return; - } - - if( inventory == this.config ) - { - this.readConfig(); - } - else if( inventory == this.tanks ) - { - this.saveChanges(); - - final boolean had = this.hasWorkToDo(); - - this.updatePlan( slot ); - - final boolean now = this.hasWorkToDo(); - - if( had != now ) - { - try - { - if( now ) - { - this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); - } - else - { - this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - } - } - - public int getPriority() - { - return this.priority; - } - - public void setPriority( final int newValue ) - { - this.priority = newValue; - } - - public void writeToNBT( final CompoundNBT data ) - { - data.putInt( "priority", this.priority ); - this.tanks.writeToNBT( data, "storage" ); - this.config.writeToNBT( data, "config" ); - } - - public void readFromNBT( final CompoundNBT data ) - { - this.config.readFromNBT( data, "config" ); - this.tanks.readFromNBT( data, "storage" ); - this.priority = data.getInt( "priority" ); - this.readConfig(); - } - - public IAEFluidTank getConfig() - { - return this.config; - } - - public IAEFluidTank getTanks() - { - return this.tanks; - } - - private class InterfaceRequestSource extends MachineSource - { - private final InterfaceRequestContext context; - - InterfaceRequestSource( IActionHost v ) - { - super( v ); - this.context = new InterfaceRequestContext(); - } - - @Override - public Optional context( Class key ) - { - if( key == InterfaceRequestContext.class ) - { - return (Optional) Optional.of( this.context ); - } - - return super.context( key ); - } - } - - private class InterfaceRequestContext implements Comparable - { - @Override - public int compareTo( Integer o ) - { - return Integer.compare( DualityFluidInterface.this.priority, o ); - } - } - - private class InterfaceInventory extends MEMonitorIFluidHandler - { - - InterfaceInventory( final DualityFluidInterface tileInterface ) - { - super( tileInterface.tanks ); - this.setActionSource( new MachineSource( tileInterface.iHost ) ); - } - - @Override - public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable type, final IActionSource src ) - { - final Optional context = src.context( InterfaceRequestContext.class ); - final boolean isInterface = context.isPresent(); - - if( isInterface ) - { - return input; - } - - return super.injectItems( input, type, src ); - } - - @Override - public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable type, final IActionSource src ) - { - final Optional context = src.context( InterfaceRequestContext.class ); - final boolean hasLowerOrEqualPriority = context.map( c -> c.compareTo( DualityFluidInterface.this.priority ) <= 0 ).orElse( false ); - - if( hasLowerOrEqualPriority ) - { - return null; - } - - return super.extractItems( request, type, src ); - } - } - - public void saveChanges() - { - this.iHost.saveChanges(); - } - - @Override - public IConfigManager getConfigManager() - { - return this.cm; - } - - @Override - public IItemHandler getInventoryByName( String name ) - { - return null; - } - - @Override - public int getInstalledUpgrades( Upgrades u ) - { - return 0; - } - - @Override - public TileEntity getTile() - { - return (TileEntity) ( this.iHost instanceof TileEntity ? this.iHost : null ); - } - - @Override - public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue ) - { - } +public class DualityFluidInterface + implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost { + public static final int NUMBER_OF_TANKS = 6; + public static final int TANK_CAPACITY = FluidAttributes.BUCKET_VOLUME * 4; + + private final ConfigManager cm = new ConfigManager(this); + private final AENetworkProxy gridProxy; + private final IFluidInterfaceHost iHost; + private final IActionSource mySource; + private final IActionSource interfaceRequestSource; + private boolean hasConfig = false; + private final IStorageMonitorableAccessor accessor = this::getMonitorable; + private final AEFluidInventory tanks = new AEFluidInventory(this, NUMBER_OF_TANKS, TANK_CAPACITY); + private final AEFluidInventory config = new AEFluidInventory(this, NUMBER_OF_TANKS); + private final IAEFluidStack[] requireWork; + private int isWorking = -1; + private int priority; + + private final MEMonitorPassThrough items = new MEMonitorPassThrough<>( + new NullInventory(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + private final MEMonitorPassThrough fluids = new MEMonitorPassThrough<>( + new NullInventory(), + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + + public DualityFluidInterface(final AENetworkProxy networkProxy, final IFluidInterfaceHost ih) { + this.gridProxy = networkProxy; + this.gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL); + this.iHost = ih; + + this.mySource = new MachineSource(this.iHost); + this.interfaceRequestSource = new InterfaceRequestSource(this.iHost); + + this.fluids.setChangeSource(this.mySource); + this.items.setChangeSource(this.mySource); + + this.requireWork = new IAEFluidStack[NUMBER_OF_TANKS]; + for (int i = 0; i < NUMBER_OF_TANKS; ++i) { + this.requireWork[i] = null; + } + } + + public IUpgradeableHost getHost() { + if (this.iHost instanceof IUpgradeableHost) { + return this.iHost; + } + if (this.iHost instanceof IUpgradeableHost) { + return this.iHost; + } + return null; + } + + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + if (this.hasConfig()) { + return null; + } + + return (IMEMonitor) this.items; + } else if (channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) { + if (this.hasConfig()) { + return (IMEMonitor) new InterfaceInventory(this); + } + + return (IMEMonitor) this.fluids; + } + + return null; + } + + public IStorageMonitorable getMonitorable(final IActionSource src) { + if (Platform.canAccess(this.gridProxy, src)) { + return this; + } + + return null; + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), + true); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (!this.gridProxy.isActive()) { + return TickRateModulation.SLEEP; + } + + final boolean couldDoWork = this.updateStorage(); + return this.hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) + : TickRateModulation.SLEEP; + } + + public void notifyNeighbors() { + if (this.gridProxy.isActive()) { + try { + this.gridProxy.getTick().wakeDevice(this.gridProxy.getNode()); + } catch (final GridAccessException e) { + // :P + } + } + + final TileEntity te = this.iHost.getTileEntity(); + if (te != null && te.getWorld() != null) { + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos()); + } + } + + public void gridChanged() { + try { + this.items.setInternal(this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + this.fluids.setInternal(this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))); + } catch (final GridAccessException gae) { + this.items.setInternal(new NullInventory()); + this.fluids.setInternal(new NullInventory()); + } + + this.notifyNeighbors(); + } + + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } + + public DimensionalCoord getLocation() { + return new DimensionalCoord(this.iHost.getTileEntity()); + } + + @SuppressWarnings("unchecked") + public LazyOptional getCapability(Capability capabilityClass, Direction facing) { + if (capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this.tanks); + } else if (capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR) { + return (LazyOptional) LazyOptional.of(() -> this.accessor); + } + return null; + } + + private boolean hasConfig() { + return this.hasConfig; + } + + private void readConfig() { + this.hasConfig = false; + + for (int i = 0; i < this.config.getSlots(); i++) { + if (this.config.getFluidInSlot(i) != null) { + this.hasConfig = true; + break; + } + } + + final boolean had = this.hasWorkToDo(); + + for (int x = 0; x < NUMBER_OF_TANKS; x++) { + this.updatePlan(x); + } + + final boolean has = this.hasWorkToDo(); + + if (had != has) { + try { + if (has) { + this.gridProxy.getTick().alertDevice(this.gridProxy.getNode()); + } else { + this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + + this.notifyNeighbors(); + } + + private boolean updateStorage() { + boolean didSomething = false; + for (int x = 0; x < NUMBER_OF_TANKS; x++) { + if (this.requireWork[x] != null) { + didSomething = this.usePlan(x) || didSomething; + } + } + return didSomething; + } + + private boolean hasWorkToDo() { + for (final IAEFluidStack requiredWork : this.requireWork) { + if (requiredWork != null) { + return true; + } + } + + return false; + } + + private void updatePlan(final int slot) { + final IAEFluidStack req = this.config.getFluidInSlot(slot); + final IAEFluidStack stored = this.tanks.getFluidInSlot(slot); + + if (req == null && (stored != null && stored.getStackSize() > 0)) { + final IAEFluidStack work = stored.copy(); + this.requireWork[slot] = work.setStackSize(-work.getStackSize()); + return; + } else if (req != null) { + if (stored == null || stored.getStackSize() == 0) // need to add stuff! + { + this.requireWork[slot] = req.copy(); + this.requireWork[slot].setStackSize(TANK_CAPACITY); + return; + } else if (req.equals(stored)) // same type ( qty different? )! + { + if (stored.getStackSize() < TANK_CAPACITY) { + this.requireWork[slot] = req.copy(); + this.requireWork[slot].setStackSize(TANK_CAPACITY - stored.getStackSize()); + return; + } + } else + // Stored != null; dispose! + { + final IAEFluidStack work = stored.copy(); + this.requireWork[slot] = work.setStackSize(-work.getStackSize()); + return; + } + } + + this.requireWork[slot] = null; + } + + private boolean usePlan(final int slot) { + IAEFluidStack work = this.requireWork[slot]; + this.isWorking = slot; + + boolean changed = false; + try { + final IMEInventory dest = this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + final IEnergySource src = this.gridProxy.getEnergy(); + + if (work.getStackSize() > 0) { + // make sure strange things didn't happen... + if (this.tanks.fill(slot, work.getFluidStack(), false) != work.getStackSize()) { + changed = true; + } else { + final IAEFluidStack acquired = Platform.poweredExtraction(src, dest, work, + this.interfaceRequestSource); + if (acquired != null) { + changed = true; + final int filled = this.tanks.fill(slot, acquired.getFluidStack(), true); + if (filled != acquired.getStackSize()) { + throw new IllegalStateException("bad attempt at managing tanks. ( fill )"); + } + } + } + } else if (work.getStackSize() < 0) { + IAEFluidStack toStore = work.copy(); + toStore.setStackSize(-toStore.getStackSize()); + + // make sure strange things didn't happen... + final FluidStack canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false); + if (canExtract == null || canExtract.getAmount() != toStore.getStackSize()) { + changed = true; + } else { + IAEFluidStack notStored = Platform.poweredInsert(src, dest, toStore, this.interfaceRequestSource); + toStore.setStackSize(toStore.getStackSize() - (notStored == null ? 0 : notStored.getStackSize())); + + if (toStore.getStackSize() > 0) { + // extract items! + changed = true; + final FluidStack removed = this.tanks.drain(slot, toStore.getFluidStack(), true); + if (removed == null || toStore.getStackSize() != removed.getAmount()) { + throw new IllegalStateException("bad attempt at managing tanks. ( drain )"); + } + } + } + } + } catch (final GridAccessException e) { + // :P + } + + if (changed) { + this.updatePlan(slot); + } + + this.isWorking = -1; + return changed; + } + + @Override + public void onFluidInventoryChanged(final IAEFluidTank inventory, final int slot) { + if (this.isWorking == slot) { + return; + } + + if (inventory == this.config) { + this.readConfig(); + } else if (inventory == this.tanks) { + this.saveChanges(); + + final boolean had = this.hasWorkToDo(); + + this.updatePlan(slot); + + final boolean now = this.hasWorkToDo(); + + if (had != now) { + try { + if (now) { + this.gridProxy.getTick().alertDevice(this.gridProxy.getNode()); + } else { + this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + } + } + + public int getPriority() { + return this.priority; + } + + public void setPriority(final int newValue) { + this.priority = newValue; + } + + public void writeToNBT(final CompoundNBT data) { + data.putInt("priority", this.priority); + this.tanks.writeToNBT(data, "storage"); + this.config.writeToNBT(data, "config"); + } + + public void readFromNBT(final CompoundNBT data) { + this.config.readFromNBT(data, "config"); + this.tanks.readFromNBT(data, "storage"); + this.priority = data.getInt("priority"); + this.readConfig(); + } + + public IAEFluidTank getConfig() { + return this.config; + } + + public IAEFluidTank getTanks() { + return this.tanks; + } + + private class InterfaceRequestSource extends MachineSource { + private final InterfaceRequestContext context; + + InterfaceRequestSource(IActionHost v) { + super(v); + this.context = new InterfaceRequestContext(); + } + + @Override + public Optional context(Class key) { + if (key == InterfaceRequestContext.class) { + return (Optional) Optional.of(this.context); + } + + return super.context(key); + } + } + + private class InterfaceRequestContext implements Comparable { + @Override + public int compareTo(Integer o) { + return Integer.compare(DualityFluidInterface.this.priority, o); + } + } + + private class InterfaceInventory extends MEMonitorIFluidHandler { + + InterfaceInventory(final DualityFluidInterface tileInterface) { + super(tileInterface.tanks); + this.setActionSource(new MachineSource(tileInterface.iHost)); + } + + @Override + public IAEFluidStack injectItems(final IAEFluidStack input, final Actionable type, final IActionSource src) { + final Optional context = src.context(InterfaceRequestContext.class); + final boolean isInterface = context.isPresent(); + + if (isInterface) { + return input; + } + + return super.injectItems(input, type, src); + } + + @Override + public IAEFluidStack extractItems(final IAEFluidStack request, final Actionable type, final IActionSource src) { + final Optional context = src.context(InterfaceRequestContext.class); + final boolean hasLowerOrEqualPriority = context + .map(c -> c.compareTo(DualityFluidInterface.this.priority) <= 0).orElse(false); + + if (hasLowerOrEqualPriority) { + return null; + } + + return super.extractItems(request, type, src); + } + } + + public void saveChanges() { + this.iHost.saveChanges(); + } + + @Override + public IConfigManager getConfigManager() { + return this.cm; + } + + @Override + public IItemHandler getInventoryByName(String name) { + return null; + } + + @Override + public int getInstalledUpgrades(Upgrades u) { + return 0; + } + + @Override + public TileEntity getTile() { + return (TileEntity) (this.iHost instanceof TileEntity ? this.iHost : null); + } + + @Override + public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue) { + } } diff --git a/src/main/java/appeng/fluids/helper/FluidCellConfig.java b/src/main/java/appeng/fluids/helper/FluidCellConfig.java index 220825af4..bf155b7ed 100644 --- a/src/main/java/appeng/fluids/helper/FluidCellConfig.java +++ b/src/main/java/appeng/fluids/helper/FluidCellConfig.java @@ -18,11 +18,10 @@ package appeng.fluids.helper; - import javax.annotation.Nonnull; -import net.minecraft.item.ItemStack; import net.minecraft.fluid.Fluid; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; @@ -32,81 +31,72 @@ import appeng.api.AEApi; import appeng.fluids.items.FluidDummyItem; import appeng.items.contents.CellConfig; - /** * @author DrummerMC * @version rv6 - 2018-01-22 * @since rv6 2018-01-22 */ -public class FluidCellConfig extends CellConfig -{ - public FluidCellConfig( ItemStack is ) - { - super( is ); - } +public class FluidCellConfig extends CellConfig { + public FluidCellConfig(ItemStack is) { + super(is); + } - @Override - @Nonnull - public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate ) - { - if( stack.isEmpty() || stack.getItem() instanceof FluidDummyItem ) - { - super.insertItem( slot, stack, simulate ); - } - LazyOptional fluidOpt = FluidUtil.getFluidContained( stack ); - if( !fluidOpt.isPresent() || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) - { - return stack; - } - FluidStack fluid = fluidOpt.orElse( null ); + @Override + @Nonnull + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { + super.insertItem(slot, stack, simulate); + } + LazyOptional fluidOpt = FluidUtil.getFluidContained(stack); + if (!fluidOpt.isPresent() + || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { + return stack; + } + FluidStack fluid = fluidOpt.orElse(null); - fluid.setAmount( FluidAttributes.BUCKET_VOLUME ); - ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).get(); - FluidDummyItem item = (FluidDummyItem) is.getItem(); - item.setFluidStack( is, fluid ); - return super.insertItem( slot, is, simulate ); - } + fluid.setAmount(FluidAttributes.BUCKET_VOLUME); + ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).get(); + FluidDummyItem item = (FluidDummyItem) is.getItem(); + item.setFluidStack(is, fluid); + return super.insertItem(slot, is, simulate); + } - @Override - public void setStackInSlot( int slot, @Nonnull ItemStack stack ) - { - if( stack.isEmpty() || stack.getItem() instanceof FluidDummyItem ) - { - super.setStackInSlot( slot, stack ); - } - LazyOptional fluidOpt = FluidUtil.getFluidContained( stack ); - if( !fluidOpt.isPresent() || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) - { - return; - } - FluidStack fluid = fluidOpt.orElse( null ); + @Override + public void setStackInSlot(int slot, @Nonnull ItemStack stack) { + if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { + super.setStackInSlot(slot, stack); + } + LazyOptional fluidOpt = FluidUtil.getFluidContained(stack); + if (!fluidOpt.isPresent() + || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { + return; + } + FluidStack fluid = fluidOpt.orElse(null); - fluid.setAmount( FluidAttributes.BUCKET_VOLUME ); - ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).get(); - FluidDummyItem item = (FluidDummyItem) is.getItem(); - item.setFluidStack( is, fluid ); - super.setStackInSlot( slot, is ); - } + fluid.setAmount(FluidAttributes.BUCKET_VOLUME); + ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).get(); + FluidDummyItem item = (FluidDummyItem) is.getItem(); + item.setFluidStack(is, fluid); + super.setStackInSlot(slot, is); + } - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - if( stack.isEmpty() || stack.getItem() instanceof FluidDummyItem ) - { - super.isItemValid( slot, stack ); - } - LazyOptional fluidOpt = FluidUtil.getFluidContained( stack ); - if( !fluidOpt.isPresent() || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) - { - return false; - } - FluidStack fluid = fluidOpt.orElse( null ); + @Override + public boolean isItemValid(int slot, ItemStack stack) { + if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { + super.isItemValid(slot, stack); + } + LazyOptional fluidOpt = FluidUtil.getFluidContained(stack); + if (!fluidOpt.isPresent() + || !AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { + return false; + } + FluidStack fluid = fluidOpt.orElse(null); - fluid.setAmount( FluidAttributes.BUCKET_VOLUME ); - ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).get(); - FluidDummyItem item = (FluidDummyItem) is.getItem(); - item.setFluidStack( is, fluid ); - return super.isItemValid( slot, is ); - } + fluid.setAmount(FluidAttributes.BUCKET_VOLUME); + ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).get(); + FluidDummyItem item = (FluidDummyItem) is.getItem(); + item.setFluidStack(is, fluid); + return super.isItemValid(slot, is); + } } diff --git a/src/main/java/appeng/fluids/helper/FluidSyncHelper.java b/src/main/java/appeng/fluids/helper/FluidSyncHelper.java index 1690bff14..a1442250f 100644 --- a/src/main/java/appeng/fluids/helper/FluidSyncHelper.java +++ b/src/main/java/appeng/fluids/helper/FluidSyncHelper.java @@ -1,7 +1,6 @@ package appeng.fluids.helper; - import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -15,84 +14,66 @@ import appeng.core.sync.packets.PacketFluidSlot; import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.IAEFluidTank; +public class FluidSyncHelper { + private final IAEFluidTank inv; + private final IAEFluidTank cache; + private final int idOffset; -public class FluidSyncHelper -{ - private final IAEFluidTank inv; - private final IAEFluidTank cache; - private final int idOffset; + public FluidSyncHelper(final IAEFluidTank inv, final int idOffset) { + this.inv = inv; + this.cache = new AEFluidInventory(null, inv.getSlots()); + this.idOffset = idOffset; + } - public FluidSyncHelper( final IAEFluidTank inv, final int idOffset ) - { - this.inv = inv; - this.cache = new AEFluidInventory( null, inv.getSlots() ); - this.idOffset = idOffset; - } + public void sendFull(final Iterable listeners) { + this.sendDiffMap(this.createDiffMap(true), listeners); + } - public void sendFull( final Iterable listeners ) - { - this.sendDiffMap( this.createDiffMap( true ), listeners ); - } + public void sendDiff(final Iterable listeners) { + this.sendDiffMap(this.createDiffMap(false), listeners); + } - public void sendDiff( final Iterable listeners ) - { - this.sendDiffMap( this.createDiffMap( false ), listeners ); - } + public void readPacket(final Map data) { + for (int i = 0; i < this.inv.getSlots(); ++i) { + if (data.containsKey(i + this.idOffset)) { + this.inv.setFluidInSlot(i, data.get(i + this.idOffset)); + } + } + } - public void readPacket( final Map data ) - { - for( int i = 0; i < this.inv.getSlots(); ++i ) - { - if( data.containsKey( i + this.idOffset ) ) - { - this.inv.setFluidInSlot( i, data.get( i + this.idOffset ) ); - } - } - } + private void sendDiffMap(final Map data, final Iterable listeners) { + if (data.isEmpty()) { + return; + } - private void sendDiffMap( final Map data, final Iterable listeners ) - { - if( data.isEmpty() ) - { - return; - } + for (final IContainerListener l : listeners) { + if (l instanceof ServerPlayerEntity) { + NetworkHandler.instance().sendTo(new PacketFluidSlot(data), (ServerPlayerEntity) l); + } + } + } - for( final IContainerListener l : listeners ) - { - if( l instanceof ServerPlayerEntity ) - { - NetworkHandler.instance().sendTo( new PacketFluidSlot( data ), (ServerPlayerEntity) l ); - } - } - } + private final Map createDiffMap(final boolean full) { + final Map ret = new HashMap<>(); + for (int i = 0; i < this.inv.getSlots(); ++i) { + if (full || !this.equalsSlot(i)) { + ret.put(i + this.idOffset, this.inv.getFluidInSlot(i)); + } + if (!full) { + this.cache.setFluidInSlot(i, this.inv.getFluidInSlot(i)); + } + } + return ret; + } - private final Map createDiffMap( final boolean full ) - { - final Map ret = new HashMap<>(); - for( int i = 0; i < this.inv.getSlots(); ++i ) - { - if( full || !this.equalsSlot( i ) ) - { - ret.put( i + this.idOffset, this.inv.getFluidInSlot( i ) ); - } - if( !full ) - { - this.cache.setFluidInSlot( i, this.inv.getFluidInSlot( i ) ); - } - } - return ret; - } + private final boolean equalsSlot(int slot) { + final IAEFluidStack stackA = this.inv.getFluidInSlot(slot); + final IAEFluidStack stackB = this.cache.getFluidInSlot(slot); - private final boolean equalsSlot( int slot ) - { - final IAEFluidStack stackA = this.inv.getFluidInSlot( slot ); - final IAEFluidStack stackB = this.cache.getFluidInSlot( slot ); + if (!Objects.equals(stackA, stackB)) { + return false; + } - if( !Objects.equals( stackA, stackB ) ) - { - return false; - } - - return stackA == null || stackA.getStackSize() == stackB.getStackSize(); - } + return stackA == null || stackA.getStackSize() == stackB.getStackSize(); + } } diff --git a/src/main/java/appeng/fluids/helper/IFluidInterfaceHost.java b/src/main/java/appeng/fluids/helper/IFluidInterfaceHost.java index 82a30e161..20a416c19 100644 --- a/src/main/java/appeng/fluids/helper/IFluidInterfaceHost.java +++ b/src/main/java/appeng/fluids/helper/IFluidInterfaceHost.java @@ -18,7 +18,6 @@ package appeng.fluids.helper; - import java.util.EnumSet; import net.minecraft.tileentity.TileEntity; @@ -28,14 +27,12 @@ import appeng.api.implementations.IUpgradeableHost; import appeng.api.networking.security.IActionHost; import appeng.me.helpers.IGridProxyable; +public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgradeableHost { + DualityFluidInterface getDualityFluidInterface(); -public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgradeableHost -{ - DualityFluidInterface getDualityFluidInterface(); + EnumSet getTargets(); - EnumSet getTargets(); + TileEntity getTileEntity(); - TileEntity getTileEntity(); - - void saveChanges(); + void saveChanges(); } diff --git a/src/main/java/appeng/fluids/items/BasicFluidStorageCell.java b/src/main/java/appeng/fluids/items/BasicFluidStorageCell.java index 07797d794..52f4de6a8 100644 --- a/src/main/java/appeng/fluids/items/BasicFluidStorageCell.java +++ b/src/main/java/appeng/fluids/items/BasicFluidStorageCell.java @@ -18,7 +18,6 @@ package appeng.fluids.items; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -32,86 +31,74 @@ import appeng.items.materials.MaterialType; import appeng.items.storage.AbstractStorageCell; import appeng.util.InventoryAdaptor; - /** * @author DrummerMC * @version rv6 - 2018-01-17 * @since rv6 2018-01-17 */ -public final class BasicFluidStorageCell extends AbstractStorageCell -{ +public final class BasicFluidStorageCell extends AbstractStorageCell { - private final int perType; - private final double idleDrain; + private final int perType; + private final double idleDrain; - public BasicFluidStorageCell(Properties props, final MaterialType whichCell, final int kilobytes ) - { - super( props, whichCell, kilobytes ); - switch( whichCell ) - { - case FLUID_1K_CELL_COMPONENT: - this.idleDrain = 0.5; - this.perType = 8; - break; - case FLUID_4K_CELL_COMPONENT: - this.idleDrain = 1.0; - this.perType = 32; - break; - case FLUID_16K_CELL_COMPONENT: - this.idleDrain = 1.5; - this.perType = 128; - break; - case FLUID_64K_CELL_COMPONENT: - this.idleDrain = 2.0; - this.perType = 512; - break; - default: - this.idleDrain = 0.0; - this.perType = 8; - } + public BasicFluidStorageCell(Properties props, final MaterialType whichCell, final int kilobytes) { + super(props, whichCell, kilobytes); + switch (whichCell) { + case FLUID_1K_CELL_COMPONENT: + this.idleDrain = 0.5; + this.perType = 8; + break; + case FLUID_4K_CELL_COMPONENT: + this.idleDrain = 1.0; + this.perType = 32; + break; + case FLUID_16K_CELL_COMPONENT: + this.idleDrain = 1.5; + this.perType = 128; + break; + case FLUID_64K_CELL_COMPONENT: + this.idleDrain = 2.0; + this.perType = 512; + break; + default: + this.idleDrain = 0.0; + this.perType = 8; + } - } + } - @Override - public int getBytesPerType( ItemStack cellItem ) - { - return this.perType; - } + @Override + public int getBytesPerType(ItemStack cellItem) { + return this.perType; + } - @Override - public double getIdleDrain() - { - return this.idleDrain; - } + @Override + public double getIdleDrain() { + return this.idleDrain; + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public int getTotalTypes( final ItemStack cellItem ) - { - return 5; - } + @Override + public int getTotalTypes(final ItemStack cellItem) { + return 5; + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new FluidCellConfig( is ); - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new FluidCellConfig(is); + } - @Override - protected void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player ) - { - AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is -> - { - final ItemStack extraA = ia.addItems( is ); - if( !extraA.isEmpty() ) - { - player.dropItem( extraA, false ); - } - } ); - } + @Override + protected void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player) { + AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1).ifPresent(is -> { + final ItemStack extraA = ia.addItems(is); + if (!extraA.isEmpty()) { + player.dropItem(extraA, false); + } + }); + } } diff --git a/src/main/java/appeng/fluids/items/FluidDummyItem.java b/src/main/java/appeng/fluids/items/FluidDummyItem.java index 56c61964c..c5938ff93 100644 --- a/src/main/java/appeng/fluids/items/FluidDummyItem.java +++ b/src/main/java/appeng/fluids/items/FluidDummyItem.java @@ -18,7 +18,6 @@ package appeng.fluids.items; - import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -29,7 +28,6 @@ import net.minecraftforge.fluids.FluidStack; import appeng.items.AEBaseItem; - /** * Dummy item to display the fluid Icon * @@ -37,49 +35,41 @@ import appeng.items.AEBaseItem; * @version rv6 - 2018-01-22 * @since rv6 2018-01-22 */ -public class FluidDummyItem extends AEBaseItem -{ +public class FluidDummyItem extends AEBaseItem { - public FluidDummyItem(Properties properties) { - super(properties); - } + public FluidDummyItem(Properties properties) { + super(properties); + } - @Override - public String getTranslationKey(ItemStack stack) { - FluidStack fluidStack = this.getFluidStack( stack ); - if( fluidStack == null ) - { - fluidStack = new FluidStack( Fluids.WATER, FluidAttributes.BUCKET_VOLUME ); - } - return fluidStack.getTranslationKey(); - } + @Override + public String getTranslationKey(ItemStack stack) { + FluidStack fluidStack = this.getFluidStack(stack); + if (fluidStack == null) { + fluidStack = new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME); + } + return fluidStack.getTranslationKey(); + } - public FluidStack getFluidStack( ItemStack is ) - { - if( is.hasTag() ) - { - CompoundNBT tag = is.getTag(); - return FluidStack.loadFluidStackFromNBT( tag ); - } - return null; - } + public FluidStack getFluidStack(ItemStack is) { + if (is.hasTag()) { + CompoundNBT tag = is.getTag(); + return FluidStack.loadFluidStackFromNBT(tag); + } + return null; + } - public void setFluidStack( ItemStack is, FluidStack fs ) - { - if( fs == null ) - { - is.setTag( null ); - } - else - { - CompoundNBT tag = new CompoundNBT(); - fs.writeToNBT( tag ); - is.setTag( tag ); - } - } + public void setFluidStack(ItemStack is, FluidStack fs) { + if (fs == null) { + is.setTag(null); + } else { + CompoundNBT tag = new CompoundNBT(); + fs.writeToNBT(tag); + is.setTag(tag); + } + } - @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - // Don't show this item in CreativeTabs - } + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + // Don't show this item in CreativeTabs + } } diff --git a/src/main/java/appeng/fluids/items/FluidDummyItemRendering.java b/src/main/java/appeng/fluids/items/FluidDummyItemRendering.java index 8ccb6a7ce..fb8e6b51b 100644 --- a/src/main/java/appeng/fluids/items/FluidDummyItemRendering.java +++ b/src/main/java/appeng/fluids/items/FluidDummyItemRendering.java @@ -18,21 +18,18 @@ package appeng.fluids.items; - import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; - /** * @author DrummerMC * @version rv6 - 2018-01-22 * @since rv6 2018-01-22 */ -public class FluidDummyItemRendering extends ItemRenderingCustomizer -{ - @Override - public void customize( IItemRendering rendering ) - { - // FIXME rendering.builtInModel( "models/item/dummy_fluid_item", new DummyFluidItemModel() ); - } +public class FluidDummyItemRendering extends ItemRenderingCustomizer { + @Override + public void customize(IItemRendering rendering) { + // FIXME rendering.builtInModel( "models/item/dummy_fluid_item", new + // DummyFluidItemModel() ); + } } diff --git a/src/main/java/appeng/fluids/parts/FluidHandlerAdapter.java b/src/main/java/appeng/fluids/parts/FluidHandlerAdapter.java index ebe96c45d..b20955e32 100644 --- a/src/main/java/appeng/fluids/parts/FluidHandlerAdapter.java +++ b/src/main/java/appeng/fluids/parts/FluidHandlerAdapter.java @@ -18,7 +18,6 @@ package appeng.fluids.parts; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -45,253 +44,213 @@ import appeng.me.GridAccessException; import appeng.me.helpers.IGridProxyable; import appeng.me.storage.ITickingMonitor; - /** - * Wraps an Fluid Handler in such a way that it can be used as an IMEInventory for fluids. + * Wraps an Fluid Handler in such a way that it can be used as an IMEInventory + * for fluids. * * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class FluidHandlerAdapter implements IMEInventory, IBaseMonitor, ITickingMonitor -{ - private final Map, Object> listeners = new HashMap<>(); - private IActionSource source; - private final IFluidHandler fluidHandler; - private final IGridProxyable proxyable; - private final FluidHandlerAdapter.InventoryCache cache; +public class FluidHandlerAdapter implements IMEInventory, IBaseMonitor, ITickingMonitor { + private final Map, Object> listeners = new HashMap<>(); + private IActionSource source; + private final IFluidHandler fluidHandler; + private final IGridProxyable proxyable; + private final FluidHandlerAdapter.InventoryCache cache; - FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy ) - { - this.fluidHandler = fluidHandler; - this.proxyable = proxy; - this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler ); - } + FluidHandlerAdapter(IFluidHandler fluidHandler, IGridProxyable proxy) { + this.fluidHandler = fluidHandler; + this.proxyable = proxy; + this.cache = new FluidHandlerAdapter.InventoryCache(this.fluidHandler); + } - @Override - public IAEFluidStack injectItems( IAEFluidStack input, Actionable type, IActionSource src ) - { - FluidStack fluidStack = input.getFluidStack(); + @Override + public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, IActionSource src) { + FluidStack fluidStack = input.getFluidStack(); - // Insert - int wasFillled = this.fluidHandler.fill( fluidStack, type.getFluidAction() ); - int remaining = fluidStack.getAmount() - wasFillled; - if( fluidStack.getAmount() == remaining ) - { - // The stack was unmodified, target tank is full - return input; - } + // Insert + int wasFillled = this.fluidHandler.fill(fluidStack, type.getFluidAction()); + int remaining = fluidStack.getAmount() - wasFillled; + if (fluidStack.getAmount() == remaining) { + // The stack was unmodified, target tank is full + return input; + } - if( type == Actionable.MODULATE ) - { - try - { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); - } - catch( GridAccessException ignore ) - { - // meh - } - } + if (type == Actionable.MODULATE) { + try { + this.proxyable.getProxy().getTick().alertDevice(this.proxyable.getProxy().getNode()); + } catch (GridAccessException ignore) { + // meh + } + } - fluidStack.setAmount( remaining ); + fluidStack.setAmount(remaining); - return AEFluidStack.fromFluidStack( fluidStack ); - } + return AEFluidStack.fromFluidStack(fluidStack); + } - @Override - public IAEFluidStack extractItems( IAEFluidStack request, Actionable mode, IActionSource src ) - { - FluidStack requestedFluidStack = request.getFluidStack(); + @Override + public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, IActionSource src) { + FluidStack requestedFluidStack = request.getFluidStack(); - // Drain the fluid from the tank - FluidStack gathered = this.fluidHandler.drain( requestedFluidStack, mode.getFluidAction() ); - if( gathered == null ) - { - // If nothing was pulled from the tank, return null - return null; - } + // Drain the fluid from the tank + FluidStack gathered = this.fluidHandler.drain(requestedFluidStack, mode.getFluidAction()); + if (gathered == null) { + // If nothing was pulled from the tank, return null + return null; + } - if( mode == Actionable.MODULATE ) - { - try - { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); - } - catch( GridAccessException ignore ) - { - // meh - } - } - return AEFluidStack.fromFluidStack( gathered ); - } + if (mode == Actionable.MODULATE) { + try { + this.proxyable.getProxy().getTick().alertDevice(this.proxyable.getProxy().getNode()); + } catch (GridAccessException ignore) { + // meh + } + } + return AEFluidStack.fromFluidStack(gathered); + } - @Override - public TickRateModulation onTick() - { - List changes = this.cache.update(); - if( !changes.isEmpty() ) - { - this.postDifference( changes ); - return TickRateModulation.URGENT; - } - else - { - return TickRateModulation.SLOWER; - } - } + @Override + public TickRateModulation onTick() { + List changes = this.cache.update(); + if (!changes.isEmpty()) { + this.postDifference(changes); + return TickRateModulation.URGENT; + } else { + return TickRateModulation.SLOWER; + } + } - @Override - public IItemList getAvailableItems( IItemList out ) - { - return this.cache.getAvailableItems( out ); - } + @Override + public IItemList getAvailableItems(IItemList out) { + return this.cache.getAvailableItems(out); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public void setActionSource( IActionSource source ) - { - this.source = source; - } + @Override + public void setActionSource(IActionSource source) { + this.source = source; + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - private void postDifference( Iterable a ) - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Map.Entry, Object> l = i.next(); - final IMEMonitorHandlerReceiver key = l.getKey(); - if( key.isValid( l.getValue() ) ) - { - key.postChange( this, a, this.source ); - } - else - { - i.remove(); - } - } - } + private void postDifference(Iterable a) { + final Iterator, Object>> i = this.listeners.entrySet() + .iterator(); + while (i.hasNext()) { + final Map.Entry, Object> l = i.next(); + final IMEMonitorHandlerReceiver key = l.getKey(); + if (key.isValid(l.getValue())) { + key.postChange(this, a, this.source); + } else { + i.remove(); + } + } + } - private static class InventoryCache - { - private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0]; - private final IFluidHandler fluidHandler; + private static class InventoryCache { + private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0]; + private final IFluidHandler fluidHandler; - public InventoryCache( IFluidHandler fluidHandler ) - { - this.fluidHandler = fluidHandler; - } + public InventoryCache(IFluidHandler fluidHandler) { + this.fluidHandler = fluidHandler; + } - public List update() - { - final List changes = new ArrayList<>(); - final int slots = fluidHandler.getTanks(); + public List update() { + final List changes = new ArrayList<>(); + final int slots = fluidHandler.getTanks(); - // Make room for new slots - if( slots > this.cachedAeStacks.length ) - { - this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); - } + // Make room for new slots + if (slots > this.cachedAeStacks.length) { + this.cachedAeStacks = Arrays.copyOf(this.cachedAeStacks, slots); + } - for( int slot = 0; slot < slots; slot++ ) - { - // Save the old stuff - final IAEFluidStack oldAEFS = this.cachedAeStacks[slot]; - final FluidStack newFS = fluidHandler.getFluidInTank( slot ); + for (int slot = 0; slot < slots; slot++) { + // Save the old stuff + final IAEFluidStack oldAEFS = this.cachedAeStacks[slot]; + final FluidStack newFS = fluidHandler.getFluidInTank(slot); - this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes ); - } + this.handlePossibleSlotChanges(slot, oldAEFS, newFS, changes); + } - // Handle cases where the number of slots actually is lower now than before - if( slots < this.cachedAeStacks.length ) - { - for( int slot = slots; slot < this.cachedAeStacks.length; slot++ ) - { - final IAEFluidStack aeStack = this.cachedAeStacks[slot]; + // Handle cases where the number of slots actually is lower now than before + if (slots < this.cachedAeStacks.length) { + for (int slot = slots; slot < this.cachedAeStacks.length; slot++) { + final IAEFluidStack aeStack = this.cachedAeStacks[slot]; - if( aeStack != null ) - { - final IAEFluidStack a = aeStack.copy(); - a.setStackSize( -a.getStackSize() ); - changes.add( a ); - } - } + if (aeStack != null) { + final IAEFluidStack a = aeStack.copy(); + a.setStackSize(-a.getStackSize()); + changes.add(a); + } + } - this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); - } - return changes; - } + this.cachedAeStacks = Arrays.copyOf(this.cachedAeStacks, slots); + } + return changes; + } - public IItemList getAvailableItems( IItemList out ) - { - Arrays.stream( this.cachedAeStacks ).forEach( out::add ); - return out; - } + public IItemList getAvailableItems(IItemList out) { + Arrays.stream(this.cachedAeStacks).forEach(out::add); + return out; + } - private void handlePossibleSlotChanges( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List changes ) - { - if( oldAeFS != null && oldAeFS.getFluidStack().isFluidEqual( newFS ) ) - { - this.handleStackSizeChanged( slot, oldAeFS, newFS, changes ); - } - else - { - this.handleFluidChanged( slot, oldAeFS, newFS, changes ); - } - } + private void handlePossibleSlotChanges(int slot, IAEFluidStack oldAeFS, FluidStack newFS, + List changes) { + if (oldAeFS != null && oldAeFS.getFluidStack().isFluidEqual(newFS)) { + this.handleStackSizeChanged(slot, oldAeFS, newFS, changes); + } else { + this.handleFluidChanged(slot, oldAeFS, newFS, changes); + } + } - private void handleStackSizeChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List changes ) - { - // Still the same fluid, but amount might have changed - final long diff = newFS.getAmount() - oldAeFS.getStackSize(); + private void handleStackSizeChanged(int slot, IAEFluidStack oldAeFS, FluidStack newFS, + List changes) { + // Still the same fluid, but amount might have changed + final long diff = newFS.getAmount() - oldAeFS.getStackSize(); - if( diff != 0 ) - { - final IAEFluidStack stack = oldAeFS.copy(); - stack.setStackSize( newFS.getAmount() ); + if (diff != 0) { + final IAEFluidStack stack = oldAeFS.copy(); + stack.setStackSize(newFS.getAmount()); - this.cachedAeStacks[slot] = stack; + this.cachedAeStacks[slot] = stack; - final IAEFluidStack a = stack.copy(); - a.setStackSize( diff ); - changes.add( a ); - } - } + final IAEFluidStack a = stack.copy(); + a.setStackSize(diff); + changes.add(a); + } + } - private void handleFluidChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List changes ) - { - // Completely different fluid - this.cachedAeStacks[slot] = AEFluidStack.fromFluidStack( newFS ); + private void handleFluidChanged(int slot, IAEFluidStack oldAeFS, FluidStack newFS, + List changes) { + // Completely different fluid + this.cachedAeStacks[slot] = AEFluidStack.fromFluidStack(newFS); - // If we had a stack previously in this slot, notify the network about its disappearance - if( oldAeFS != null ) - { - oldAeFS.setStackSize( -oldAeFS.getStackSize() ); - changes.add( oldAeFS ); - } + // If we had a stack previously in this slot, notify the network about its + // disappearance + if (oldAeFS != null) { + oldAeFS.setStackSize(-oldAeFS.getStackSize()); + changes.add(oldAeFS); + } - // Notify the network about the new stack. Note that this is null if newFS was null - if( this.cachedAeStacks[slot] != null ) - { - changes.add( this.cachedAeStacks[slot] ); - } - } - } + // Notify the network about the new stack. Note that this is null if newFS was + // null + if (this.cachedAeStacks[slot] != null) { + changes.add(this.cachedAeStacks[slot]); + } + } + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidAnnihilationPlane.java b/src/main/java/appeng/fluids/parts/PartFluidAnnihilationPlane.java index 4d0aa4cbd..5339bc44c 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidAnnihilationPlane.java +++ b/src/main/java/appeng/fluids/parts/PartFluidAnnihilationPlane.java @@ -1,10 +1,10 @@ package appeng.fluids.parts; - import java.util.List; -import appeng.parts.automation.PlaneModelData; +import javax.annotation.Nonnull; + import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -63,289 +63,255 @@ import appeng.me.GridAccessException; import appeng.me.helpers.MachineSource; import appeng.parts.PartBasicState; import appeng.parts.automation.PlaneConnections; +import appeng.parts.automation.PlaneModelData; import appeng.parts.automation.PlaneModels; import appeng.util.Platform; -import javax.annotation.Nonnull; +public class PartFluidAnnihilationPlane extends PartBasicState implements IGridTickable { + private static final PlaneModels MODELS = new PlaneModels("part/fluid_annihilation_plane", + "part/fluid_annihilation_plane_on"); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } -public class PartFluidAnnihilationPlane extends PartBasicState implements IGridTickable -{ - private static final PlaneModels MODELS = new PlaneModels( "part/fluid_annihilation_plane", "part/fluid_annihilation_plane_on" ); + private final IActionSource mySrc = new MachineSource(this); - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + public PartFluidAnnihilationPlane(final ItemStack is) { + super(is); + } - private final IActionSource mySrc = new MachineSource( this ); + @Override + public void getBoxes(final IPartCollisionHelper bch) { + int minX = 1; + int minY = 1; + int maxX = 15; + int maxY = 15; - public PartFluidAnnihilationPlane( final ItemStack is ) - { - super( is ); - } + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - int minX = 1; - int minY = 1; - int maxX = 15; - int maxY = 15; + final BlockPos pos = te.getPos(); - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); + final Direction e = bch.getWorldX(); + final Direction u = bch.getWorldY(); - final BlockPos pos = te.getPos(); + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) { + minX = 0; + } - final Direction e = bch.getWorldX(); - final Direction u = bch.getWorldY(); + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) { + maxX = 16; + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.getSide() ) ) - { - minX = 0; - } + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) { + minY = 0; + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) ) - { - maxX = 16; - } + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) { + maxY = 16; + } + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.getSide() ) ) - { - minY = 0; - } + bch.addBox(5, 5, 14, 11, 11, 15); + bch.addBox(minX, minY, 15, maxX, maxY, 16); + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) ) - { - maxY = 16; - } - } + public PlaneConnections getConnections() { - bch.addBox( 5, 5, 14, 11, 11, 15 ); - bch.addBox( minX, minY, 15, maxX, maxY, 16 ); - } + final Direction facingRight, facingUp; + AEPartLocation location = this.getSide(); + switch (location) { + case UP: + facingRight = Direction.EAST; + facingUp = Direction.NORTH; + break; + case DOWN: + facingRight = Direction.WEST; + facingUp = Direction.NORTH; + break; + case NORTH: + facingRight = Direction.WEST; + facingUp = Direction.UP; + break; + case SOUTH: + facingRight = Direction.EAST; + facingUp = Direction.UP; + break; + case WEST: + facingRight = Direction.SOUTH; + facingUp = Direction.UP; + break; + case EAST: + facingRight = Direction.NORTH; + facingUp = Direction.UP; + break; + default: + case INTERNAL: + return PlaneConnections.of(false, false, false, false); + } - public PlaneConnections getConnections() - { + boolean left = false, right = false, down = false, up = false; - final Direction facingRight, facingUp; - AEPartLocation location = this.getSide(); - switch( location ) - { - case UP: - facingRight = Direction.EAST; - facingUp = Direction.NORTH; - break; - case DOWN: - facingRight = Direction.WEST; - facingUp = Direction.NORTH; - break; - case NORTH: - facingRight = Direction.WEST; - facingUp = Direction.UP; - break; - case SOUTH: - facingRight = Direction.EAST; - facingUp = Direction.UP; - break; - case WEST: - facingRight = Direction.SOUTH; - facingUp = Direction.UP; - break; - case EAST: - facingRight = Direction.NORTH; - facingUp = Direction.UP; - break; - default: - case INTERNAL: - return PlaneConnections.of( false, false, false, false ); - } + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); - boolean left = false, right = false, down = false, up = false; + final BlockPos pos = te.getPos(); - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())), + this.getSide())) { + left = true; + } - final BlockPos pos = te.getPos(); + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) { + right = true; + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) ) - { - left = true; - } + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())), + this.getSide())) { + down = true; + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) ) - { - right = true; - } + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) { + up = true; + } + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) ) - { - down = true; - } + return PlaneConnections.of(up, right, down, left); + } - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) ) - { - up = true; - } - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + this.refresh(); + } + } - return PlaneConnections.of( up, right, down, left ); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 1; + } - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - this.refresh(); - } - } + private boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) { + if (blockTileEntity instanceof IPartHost) { + final IPart p = ((IPartHost) blockTileEntity).getPart(side); + return p != null && p.getClass() == this.getClass(); + } + return false; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 1; - } + private void refresh() { + try { + this.getProxy().getTick().alertDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } - private boolean isAnnihilationPlane( final TileEntity blockTileEntity, final AEPartLocation side ) - { - if( blockTileEntity instanceof IPartHost ) - { - final IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); - return p != null && p.getClass() == this.getClass(); - } - return false; - } + @Override + @MENetworkEventSubscribe + public void chanRender(final MENetworkChannelsChanged c) { + this.refresh(); + this.getHost().markForUpdate(); + } - private void refresh() - { - try - { - this.getProxy().getTick().alertDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.refresh(); + this.getHost().markForUpdate(); + } - @Override - @MENetworkEventSubscribe - public void chanRender( final MENetworkChannelsChanged c ) - { - this.refresh(); - this.getHost().markForUpdate(); - } + private TickRateModulation pickupFluid() { + if (!this.getProxy().isActive()) { + return TickRateModulation.SLEEP; + } - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.refresh(); - this.getHost().markForUpdate(); - } + final TileEntity te = this.getTile(); + final World w = te.getWorld(); + final BlockPos pos = te.getPos().offset(this.getSide().getFacing()); - private TickRateModulation pickupFluid() - { - if( !this.getProxy().isActive() ) - { - return TickRateModulation.SLEEP; - } + BlockState blockstate = w.getBlockState(pos); + if (blockstate.getBlock() instanceof IBucketPickupHandler) { + IFluidState fluidState = blockstate.getFluidState(); - final TileEntity te = this.getTile(); - final World w = te.getWorld(); - final BlockPos pos = te.getPos().offset( this.getSide().getFacing() ); + Fluid fluid = fluidState.getFluid(); + if (fluid != Fluids.EMPTY && fluidState.isSource()) { - BlockState blockstate = w.getBlockState(pos); - if (blockstate.getBlock() instanceof IBucketPickupHandler) { - IFluidState fluidState = blockstate.getFluidState(); + // Attempt to store the fluid in the network + final IAEFluidStack blockFluid = AEFluidStack + .fromFluidStack(new FluidStack(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME)); + if (this.storeFluid(blockFluid, false)) { + // If that would succeed, actually slurp up the liquid as if we were using a + // bucket + // This _MIGHT_ change the liquid, and if it does, and we dont have enough + // space, + // tough luck. you loose the source block. + fluid = ((IBucketPickupHandler) blockstate.getBlock()).pickupFluid(w, pos, blockstate); + this.storeFluid(AEFluidStack.fromFluidStack(new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME)), + true); - Fluid fluid = fluidState.getFluid(); - if (fluid != Fluids.EMPTY && fluidState.isSource()) { + AppEng.proxy.sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, w, + new PacketTransitionEffect(pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true)); - // Attempt to store the fluid in the network - final IAEFluidStack blockFluid = AEFluidStack.fromFluidStack( new FluidStack(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME) ); - if( this.storeFluid( blockFluid, false ) ) - { - // If that would succeed, actually slurp up the liquid as if we were using a bucket - // This _MIGHT_ change the liquid, and if it does, and we dont have enough space, - // tough luck. you loose the source block. - fluid = ((IBucketPickupHandler)blockstate.getBlock()).pickupFluid(w, pos, blockstate); - this.storeFluid( AEFluidStack.fromFluidStack( new FluidStack( fluid, FluidAttributes.BUCKET_VOLUME) ), true ); + return TickRateModulation.URGENT; + } + return TickRateModulation.IDLE; + } + } - AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w, - new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) ); + // nothing to do here :) + return TickRateModulation.SLEEP; + } - return TickRateModulation.URGENT; - } - return TickRateModulation.IDLE; - } - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.AnnihilationPlane.getMin(), TickRates.AnnihilationPlane.getMax(), false, + true); + } - // nothing to do here :) - return TickRateModulation.SLEEP; - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.pickupFluid(); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.AnnihilationPlane.getMin(), TickRates.AnnihilationPlane.getMax(), false, true ); - } + private boolean storeFluid(IAEFluidStack stack, boolean modulate) { + try { + final IStorageGrid storage = this.getProxy().getStorage(); + final IMEInventory inv = storage + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.pickupFluid(); - } + if (modulate) { + final IEnergyGrid energy = this.getProxy().getEnergy(); + return Platform.poweredInsert(energy, inv, stack, this.mySrc) == null; + } else { + final float requiredPower = stack.getStackSize() / Math.min(1.0f, stack.getChannel().transferFactor()); + final IEnergyGrid energy = this.getProxy().getEnergy(); - private boolean storeFluid( IAEFluidStack stack, boolean modulate ) - { - try - { - final IStorageGrid storage = this.getProxy().getStorage(); - final IMEInventory inv = storage.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); + if (energy.extractAEPower(requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG) < requiredPower) { + return false; + } + final IAEFluidStack leftOver = inv.injectItems(stack, Actionable.SIMULATE, this.mySrc); + return leftOver == null || leftOver.getStackSize() == 0; + } + } catch (final GridAccessException e) { + // :P + } + return false; + } - if( modulate ) - { - final IEnergyGrid energy = this.getProxy().getEnergy(); - return Platform.poweredInsert( energy, inv, stack, this.mySrc ) == null; - } - else - { - final float requiredPower = stack.getStackSize() / Math.min( 1.0f, stack.getChannel().transferFactor() ); - final IEnergyGrid energy = this.getProxy().getEnergy(); + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - if( energy.extractAEPower( requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG ) < requiredPower ) - { - return false; - } - final IAEFluidStack leftOver = inv.injectItems( stack, Actionable.SIMULATE, this.mySrc ); - return leftOver == null || leftOver.getStackSize() == 0; - } - } - catch( final GridAccessException e ) - { - // :P - } - return false; - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } - - @Nonnull - @Override - public IModelData getModelData() { - return new PlaneModelData(getConnections()); - } + @Nonnull + @Override + public IModelData getModelData() { + return new PlaneModelData(getConnections()); + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidExportBus.java b/src/main/java/appeng/fluids/parts/PartFluidExportBus.java index ccab1e581..a727e368f 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidExportBus.java +++ b/src/main/java/appeng/fluids/parts/PartFluidExportBus.java @@ -18,7 +18,6 @@ package appeng.fluids.parts; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -50,143 +49,121 @@ import appeng.me.GridAccessException; import appeng.me.helpers.MachineSource; import appeng.parts.PartModel; - /** * @author BrockWS * @version rv6 - 30/04/2018 * @since rv6 30/04/2018 */ -public class PartFluidExportBus extends PartSharedFluidBus -{ - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_export_bus_base" ); - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_export_bus_off" ) ); - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_export_bus_on" ) ); - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_export_bus_has_channel" ) ); +public class PartFluidExportBus extends PartSharedFluidBus { + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/fluid_export_bus_base"); + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_export_bus_off")); + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_export_bus_on")); + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_export_bus_has_channel")); - private final IActionSource source; + private final IActionSource source; - public PartFluidExportBus( ItemStack is ) - { - 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.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - this.source = new MachineSource( this ); - } + public PartFluidExportBus(ItemStack is) { + 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.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + this.source = new MachineSource(this); + } - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( TickRates.FluidExportBus.getMin(), TickRates.FluidExportBus.getMax(), this.isSleeping(), false ); - } + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(TickRates.FluidExportBus.getMin(), TickRates.FluidExportBus.getMax(), + this.isSleeping(), false); + } - @Override - public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall ) - { - return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; - } + @Override + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { + return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; + } - @Override - protected boolean canDoBusWork() - { - return this.getProxy().isActive(); - } + @Override + protected boolean canDoBusWork() { + return this.getProxy().isActive(); + } - @Override - protected TickRateModulation doBusWork() - { - if( !this.canDoBusWork() ) - { - return TickRateModulation.IDLE; - } + @Override + protected TickRateModulation doBusWork() { + if (!this.canDoBusWork()) { + return TickRateModulation.IDLE; + } - final TileEntity te = this.getConnectedTE(); - LazyOptional fhOpt = LazyOptional.empty(); - if( te != null ) - { - te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ); - } - if( fhOpt.isPresent() ) - { - try - { - final IFluidHandler fh = fhOpt.orElse( null ); - final IMEMonitor inv = this.getProxy().getStorage().getInventory( this.getChannel() ); + final TileEntity te = this.getConnectedTE(); + LazyOptional fhOpt = LazyOptional.empty(); + if (te != null) { + te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite()); + } + if (fhOpt.isPresent()) { + try { + final IFluidHandler fh = fhOpt.orElse(null); + final IMEMonitor inv = this.getProxy().getStorage().getInventory(this.getChannel()); - if( fh != null ) - { - for( int i = 0; i < this.getConfig().getSlots(); i++ ) - { - IAEFluidStack fluid = this.getConfig().getFluidInSlot( i ); - if( fluid != null ) - { - final IAEFluidStack toExtract = fluid.copy(); + if (fh != null) { + for (int i = 0; i < this.getConfig().getSlots(); i++) { + IAEFluidStack fluid = this.getConfig().getFluidInSlot(i); + if (fluid != null) { + final IAEFluidStack toExtract = fluid.copy(); - toExtract.setStackSize( this.calculateAmountToSend() ); + toExtract.setStackSize(this.calculateAmountToSend()); - final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source ); + final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source); - if( out != null ) - { - int wasInserted = fh.fill( out.getFluidStack(), FluidAction.EXECUTE ); + if (out != null) { + int wasInserted = fh.fill(out.getFluidStack(), FluidAction.EXECUTE); - if( wasInserted > 0 ) - { - toExtract.setStackSize( wasInserted ); - inv.extractItems( toExtract, Actionable.MODULATE, this.source ); + if (wasInserted > 0) { + toExtract.setStackSize(wasInserted); + inv.extractItems(toExtract, Actionable.MODULATE, this.source); - return TickRateModulation.FASTER; - } - } - } - } + return TickRateModulation.FASTER; + } + } + } + } - return TickRateModulation.SLOWER; - } - } - catch( GridAccessException e ) - { - // Ignore - } - } + return TickRateModulation.SLOWER; + } + } catch (GridAccessException e) { + // Ignore + } + } - return TickRateModulation.SLEEP; - } + return TickRateModulation.SLEEP; + } - @Override - public void getBoxes( final 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 void getBoxes(final 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 RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); - } + @Override + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); + } - @Nonnull - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Nonnull + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidFormationPlane.java b/src/main/java/appeng/fluids/parts/PartFluidFormationPlane.java index 66627ccc3..5e5f75cee 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidFormationPlane.java +++ b/src/main/java/appeng/fluids/parts/PartFluidFormationPlane.java @@ -1,19 +1,16 @@ package appeng.fluids.parts; - import java.util.ArrayList; import java.util.Collections; import java.util.List; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerFormationPlane; -import appeng.fluids.container.ContainerFluidFormationPlane; -import appeng.parts.automation.PlaneModelData; +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluid; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -22,7 +19,6 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraft.fluid.Fluid; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; @@ -47,7 +43,10 @@ import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IItemList; import appeng.api.util.AEPartLocation; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerFormationPlane; +import appeng.fluids.container.ContainerFluidFormationPlane; import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidTank; @@ -55,197 +54,168 @@ import appeng.items.parts.PartModels; import appeng.me.GridAccessException; import appeng.me.storage.MEInventoryHandler; import appeng.parts.automation.PartAbstractFormationPlane; +import appeng.parts.automation.PlaneModelData; import appeng.parts.automation.PlaneModels; import appeng.util.Platform; import appeng.util.prioritylist.PrecisePriorityList; -import javax.annotation.Nonnull; +public class PartFluidFormationPlane extends PartAbstractFormationPlane implements IAEFluidInventory { + private static final PlaneModels MODELS = new PlaneModels("part/fluid_formation_plane", + "part/fluid_formation_plane_on"); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } -public class PartFluidFormationPlane extends PartAbstractFormationPlane implements IAEFluidInventory -{ - private static final PlaneModels MODELS = new PlaneModels( "part/fluid_formation_plane", "part/fluid_formation_plane_on" ); + private final MEInventoryHandler myHandler = new MEInventoryHandler<>(this, + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + private final AEFluidInventory config = new AEFluidInventory(this, 63); - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + public PartFluidFormationPlane(final ItemStack is) { + super(is); + this.updateHandler(); + } - private final MEInventoryHandler myHandler = new MEInventoryHandler<>( this, AEApi.instance() - .storage() - .getStorageChannel( IFluidStorageChannel.class ) ); - private final AEFluidInventory config = new AEFluidInventory( this, 63 ); + @Override + protected void updateHandler() { + this.myHandler.setBaseAccess(AccessRestriction.WRITE); + this.myHandler.setWhitelist( + this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST); + this.myHandler.setPriority(this.getPriority()); - public PartFluidFormationPlane( final ItemStack is ) - { - super( is ); - this.updateHandler(); - } + final IItemList priorityList = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createList(); - @Override - protected void updateHandler() - { - this.myHandler.setBaseAccess( AccessRestriction.WRITE ); - this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); - this.myHandler.setPriority( this.getPriority() ); + final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9; + for (int x = 0; x < this.config.getSlots() && x < slotsToUse; x++) { + final IAEFluidStack is = this.config.getFluidInSlot(x); + if (is != null) { + priorityList.add(is); + } + } + this.myHandler.setPartitionList(new PrecisePriorityList(priorityList)); - final IItemList priorityList = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } - final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; - for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ ) - { - final IAEFluidStack is = this.config.getFluidInSlot( x ); - if( is != null ) - { - priorityList.add( is ); - } - } - this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) ); + @Override + public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, IActionSource src) { + if (this.blocked || input == null || input.getStackSize() < FluidAttributes.BUCKET_VOLUME) { + // need a full bucket + return input; + } - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + final TileEntity te = this.getHost().getTile(); + final World w = te.getWorld(); + final AEPartLocation side = this.getSide(); + final BlockPos pos = te.getPos().offset(side.getFacing()); + final BlockState state = w.getBlockState(pos); - @Override - public IAEFluidStack injectItems( IAEFluidStack input, Actionable type, IActionSource src ) - { - if( this.blocked || input == null || input.getStackSize() < FluidAttributes.BUCKET_VOLUME ) - { - // need a full bucket - return input; - } + if (this.canReplace(w, state, pos)) { + if (type == Actionable.MODULATE) { + final FluidStack fs = input.getFluidStack(); + fs.setAmount(FluidAttributes.BUCKET_VOLUME); - final TileEntity te = this.getHost().getTile(); - final World w = te.getWorld(); - final AEPartLocation side = this.getSide(); - final BlockPos pos = te.getPos().offset( side.getFacing() ); - final BlockState state = w.getBlockState( pos ); + final FluidTank tank = new FluidTank(FluidAttributes.BUCKET_VOLUME, e -> e.isFluidEqual(fs)); + if (!FluidUtil.tryPlaceFluid(null, w, Hand.MAIN_HAND, pos, tank, fs)) { + return input; + } + } + final IAEFluidStack ret = input.copy(); + ret.setStackSize(input.getStackSize() - FluidAttributes.BUCKET_VOLUME); + return ret.getStackSize() == 0 ? null : ret; + } + this.blocked = true; + return input; + } - if( this.canReplace( w, state, pos ) ) - { - if( type == Actionable.MODULATE ) - { - final FluidStack fs = input.getFluidStack(); - fs.setAmount( FluidAttributes.BUCKET_VOLUME ); + private boolean canReplace(World w, BlockState state, BlockPos pos) { + return state.getMaterial().isReplaceable() && w.getFluidState(pos).isEmpty() && !state.getMaterial().isLiquid(); + } - final FluidTank tank = new FluidTank( FluidAttributes.BUCKET_VOLUME, e -> e.isFluidEqual( fs ) ); - if( !FluidUtil.tryPlaceFluid( null, w, Hand.MAIN_HAND, pos, tank, fs ) ) - { - return input; - } - } - final IAEFluidStack ret = input.copy(); - ret.setStackSize( input.getStackSize() - FluidAttributes.BUCKET_VOLUME ); - return ret.getStackSize() == 0 ? null : ret; - } - this.blocked = true; - return input; - } + @Override + public void onFluidInventoryChanged(IAEFluidTank inv, int slot) { + if (inv == this.config) { + this.updateHandler(); + } + } - private boolean canReplace( World w, BlockState state, BlockPos pos ) - { - return state.getMaterial().isReplaceable() && w.getFluidState(pos).isEmpty() && !state.getMaterial().isLiquid(); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.config.readFromNBT(data, "config"); + this.updateHandler(); + } - @Override - public void onFluidInventoryChanged( IAEFluidTank inv, int slot ) - { - if( inv == this.config ) - { - this.updateHandler(); - } - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.config.writeToNBT(data, "config"); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.config.readFromNBT( data, "config" ); - this.updateHandler(); - } + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.stateChanged(); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.config.writeToNBT( data, "config" ); - } + @MENetworkEventSubscribe + public void updateChannels(final MENetworkChannelsChanged changedChannels) { + this.stateChanged(); + } - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.stateChanged(); - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidFormationPlane.TYPE, player, ContainerLocator.forPart(this)); + } - @MENetworkEventSubscribe - public void updateChannels( final MENetworkChannelsChanged changedChannels ) - { - this.stateChanged(); - } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidFormationPlane.TYPE, player, ContainerLocator.forPart(this)); - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - return true; - } + @Override + public List getCellArray(final IStorageChannel channel) { + if (this.getProxy().isActive() + && channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) { + final List handler = new ArrayList<>(1); + handler.add(this.myHandler); + return handler; + } + return Collections.emptyList(); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) - { - final List handler = new ArrayList<>( 1 ); - handler.add( this.myHandler ); - return handler; - } - return Collections.emptyList(); - } + @Nonnull + @Override + public IModelData getModelData() { + return new PlaneModelData(getConnections()); + } - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + public IAEFluidTank getConfig() { + return this.config; + } - @Nonnull - @Override - public IModelData getModelData() { - return new PlaneModelData(getConnections()); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().fluidFormationnPlane().maybeStack(1).orElse(ItemStack.EMPTY); + } - public IAEFluidTank getConfig() - { - return this.config; - } - - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().fluidFormationnPlane().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerFluidFormationPlane.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerFluidFormationPlane.TYPE; + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidImportBus.java b/src/main/java/appeng/fluids/parts/PartFluidImportBus.java index 02638e052..5e3ef25b1 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidImportBus.java +++ b/src/main/java/appeng/fluids/parts/PartFluidImportBus.java @@ -18,7 +18,6 @@ package appeng.fluids.parts; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -51,157 +50,132 @@ import appeng.me.GridAccessException; import appeng.me.helpers.MachineSource; import appeng.parts.PartModel; - /** * @author BrockWS * @version rv6 - 30/04/2018 * @since rv6 30/04/2018 */ -public class PartFluidImportBus extends PartSharedFluidBus -{ - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_import_bus_base" ); - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_import_bus_off" ) ); - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_import_bus_on" ) ); - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_import_bus_has_channel" ) ); +public class PartFluidImportBus extends PartSharedFluidBus { + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/fluid_import_bus_base"); + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_import_bus_off")); + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_import_bus_on")); + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_import_bus_has_channel")); - private final IActionSource source; + private final IActionSource source; - public PartFluidImportBus( ItemStack is ) - { - 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.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - this.source = new MachineSource( this ); - } + public PartFluidImportBus(ItemStack is) { + 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.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + this.source = new MachineSource(this); + } - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( TickRates.FluidImportBus.getMin(), TickRates.FluidImportBus.getMax(), this.isSleeping(), false ); - } + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(TickRates.FluidImportBus.getMin(), TickRates.FluidImportBus.getMax(), + this.isSleeping(), false); + } - @Override - public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall ) - { - return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; - } + @Override + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { + return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; + } - @Override - protected TickRateModulation doBusWork() - { - if( !this.canDoBusWork() ) - { - return TickRateModulation.IDLE; - } + @Override + protected TickRateModulation doBusWork() { + if (!this.canDoBusWork()) { + return TickRateModulation.IDLE; + } - final TileEntity te = this.getConnectedTE(); - LazyOptional fhOpt = LazyOptional.empty(); - if( te != null ) - { - te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ); - } - if( fhOpt.isPresent() ) - { - try - { - final IFluidHandler fh = fhOpt.orElse( null ); - final IMEMonitor inv = this.getProxy().getStorage().getInventory( this.getChannel() ); + final TileEntity te = this.getConnectedTE(); + LazyOptional fhOpt = LazyOptional.empty(); + if (te != null) { + te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite()); + } + if (fhOpt.isPresent()) { + try { + final IFluidHandler fh = fhOpt.orElse(null); + final IMEMonitor inv = this.getProxy().getStorage().getInventory(this.getChannel()); - if( fh != null ) - { - final FluidStack fluidStack = fh.drain( this.calculateAmountToSend(), FluidAction.SIMULATE ); + if (fh != null) { + final FluidStack fluidStack = fh.drain(this.calculateAmountToSend(), FluidAction.SIMULATE); - if( this.filterEnabled() && !this.isInFilter( fluidStack ) ) - { - return TickRateModulation.SLOWER; - } + if (this.filterEnabled() && !this.isInFilter(fluidStack)) { + return TickRateModulation.SLOWER; + } - final AEFluidStack aeFluidStack = AEFluidStack.fromFluidStack( fluidStack ); + final AEFluidStack aeFluidStack = AEFluidStack.fromFluidStack(fluidStack); - if( aeFluidStack != null ) - { - final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source ); + if (aeFluidStack != null) { + final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, + this.source); - if( notInserted != null && notInserted.getStackSize() > 0 ) - { - aeFluidStack.decStackSize( notInserted.getStackSize() ); - } + if (notInserted != null && notInserted.getStackSize() > 0) { + aeFluidStack.decStackSize(notInserted.getStackSize()); + } - fh.drain( aeFluidStack.getFluidStack(), FluidAction.EXECUTE ); + fh.drain(aeFluidStack.getFluidStack(), FluidAction.EXECUTE); - return TickRateModulation.FASTER; - } + return TickRateModulation.FASTER; + } - return TickRateModulation.IDLE; - } - } - catch( GridAccessException e ) - { - e.printStackTrace(); - } - } + return TickRateModulation.IDLE; + } + } catch (GridAccessException e) { + e.printStackTrace(); + } + } - return TickRateModulation.SLEEP; - } + return TickRateModulation.SLEEP; + } - @Override - protected boolean canDoBusWork() - { - return this.getProxy().isActive(); - } + @Override + protected boolean canDoBusWork() { + return this.getProxy().isActive(); + } - private boolean isInFilter( FluidStack fluid ) - { - for( int i = 0; i < this.getConfig().getSlots(); i++ ) - { - final IAEFluidStack stack = this.getConfig().getFluidInSlot( i ); - if( stack != null && stack.equals( fluid ) ) - { - return true; - } - } - return false; - } + private boolean isInFilter(FluidStack fluid) { + for (int i = 0; i < this.getConfig().getSlots(); i++) { + final IAEFluidStack stack = this.getConfig().getFluidInSlot(i); + if (stack != null && stack.equals(fluid)) { + return true; + } + } + return false; + } - private boolean filterEnabled() - { - for( int i = 0; i < this.getConfig().getSlots(); i++ ) - { - final IAEFluidStack stack = this.getConfig().getFluidInSlot( i ); - if( stack != null ) - { - return true; - } - } - return false; - } + private boolean filterEnabled() { + for (int i = 0; i < this.getConfig().getSlots(); i++) { + final IAEFluidStack stack = this.getConfig().getFluidInSlot(i); + if (stack != null) { + return true; + } + } + return false; + } - @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); - } + @Override + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); + } - @Nonnull - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Nonnull + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidInterface.java b/src/main/java/appeng/fluids/parts/PartFluidInterface.java index 7b6aac268..8397f506a 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidInterface.java +++ b/src/main/java/appeng/fluids/parts/PartFluidInterface.java @@ -18,12 +18,8 @@ package appeng.fluids.parts; - import java.util.EnumSet; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.fluids.container.ContainerFluidInterface; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -54,8 +50,10 @@ import appeng.api.storage.IStorageMonitorable; import appeng.api.storage.data.IAEStack; import appeng.api.util.AECableType; import appeng.api.util.IConfigManager; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; import appeng.core.AppEng; - +import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.helper.DualityFluidInterface; import appeng.fluids.helper.IFluidInterfaceHost; import appeng.helpers.IPriorityHost; @@ -65,182 +63,154 @@ import appeng.parts.PartBasicState; import appeng.parts.PartModel; import appeng.util.Platform; +public class PartFluidInterface extends PartBasicState + implements IGridTickable, IStorageMonitorable, IFluidInterfaceHost, IPriorityHost { + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/fluid_interface_base"); -public class PartFluidInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IFluidInterfaceHost, IPriorityHost -{ - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_interface_base" ); + @PartModels + public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_interface_off")); - @PartModels - public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_interface_off" ) ); + @PartModels + public static final PartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_interface_on")); - @PartModels - public static final PartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_interface_on" ) ); + @PartModels + public static final PartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_interface_has_channel")); - @PartModels - public static final PartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_interface_has_channel" ) ); + private final DualityFluidInterface duality = new DualityFluidInterface(this.getProxy(), this); - private final DualityFluidInterface duality = new DualityFluidInterface( this.getProxy(), this ); + @Reflected + public PartFluidInterface(final ItemStack is) { + super(is); + } - @Reflected - public PartFluidInterface( final ItemStack is ) - { - super( is ); - } + @Override + public DualityFluidInterface getDualityFluidInterface() { + return this.duality; + } - @Override - public DualityFluidInterface getDualityFluidInterface() - { - return this.duality; - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkChannelsChanged c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkChannelsChanged c ) - { - this.duality.notifyNeighbors(); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkPowerStatusChange c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkPowerStatusChange c ) - { - this.duality.notifyNeighbors(); - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(2, 2, 14, 14, 14, 16); + bch.addBox(5, 5, 12, 11, 11, 14); + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 2, 2, 14, 14, 14, 16 ); - bch.addBox( 5, 5, 12, 11, 11, 14 ); - } + @Override + public void gridChanged() { + this.duality.gridChanged(); + } - @Override - public void gridChanged() - { - this.duality.gridChanged(); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.duality.readFromNBT(data); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.duality.readFromNBT( data ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.duality.writeToNBT(data); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.duality.writeToNBT( data ); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 4; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 4; - } + @Override + public boolean onPartActivate(final PlayerEntity p, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidInterface.TYPE, p, ContainerLocator.forPart(this)); + } - @Override - public boolean onPartActivate( final PlayerEntity p, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidInterface.TYPE, p, ContainerLocator.forPart(this)); - } + return true; + } - return true; - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + return this.duality.getInventory(channel); + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - return this.duality.getInventory( channel ); - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return this.duality.getTickingRequest(node); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return this.duality.getTickingRequest( node ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.duality.tickingRequest(node, ticksSinceLastCall); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.duality.tickingRequest( node, ticksSinceLastCall ); - } + @Override + public EnumSet getTargets() { + return EnumSet.of(this.getSide().getFacing()); + } - @Override - public EnumSet getTargets() - { - return EnumSet.of( this.getSide().getFacing() ); - } + @Override + public TileEntity getTileEntity() { + return super.getHost().getTile(); + } - @Override - public TileEntity getTileEntity() - { - return super.getHost().getTile(); - } + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public int getPriority() { + return this.duality.getPriority(); + } - @Override - public int getPriority() - { - return this.duality.getPriority(); - } + @Override + public void setPriority(final int newValue) { + this.duality.setPriority(newValue); + } - @Override - public void setPriority( final int newValue ) - { - this.duality.setPriority( newValue ); - } + @Override + public LazyOptional getCapability(Capability capabilityClass) { + return this.duality.getCapability(capabilityClass, this.getSide().getFacing()); + } - @Override - public LazyOptional getCapability(Capability capabilityClass ) - { - return this.duality.getCapability( capabilityClass, this.getSide().getFacing() ); - } + @Override + public int getInstalledUpgrades(Upgrades u) { + return this.duality.getInstalledUpgrades(u); + } - @Override - public int getInstalledUpgrades( Upgrades u ) - { - return this.duality.getInstalledUpgrades( u ); - } + @Override + public IConfigManager getConfigManager() { + return this.duality.getConfigManager(); + } - @Override - public IConfigManager getConfigManager() - { - return this.duality.getConfigManager(); - } + @Override + public IItemHandler getInventoryByName(String name) { + return this.duality.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( String name ) - { - return this.duality.getInventoryByName( name ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().fluidIface().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().fluidIface().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerFluidInterface.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerFluidInterface.TYPE; + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidLevelEmitter.java b/src/main/java/appeng/fluids/parts/PartFluidLevelEmitter.java index 32dabfa48..5d7227b43 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidLevelEmitter.java +++ b/src/main/java/appeng/fluids/parts/PartFluidLevelEmitter.java @@ -1,12 +1,8 @@ package appeng.fluids.parts; - import java.util.Random; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.fluids.container.ContainerFluidLevelEmitter; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -39,8 +35,10 @@ import appeng.api.storage.data.IItemList; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.IConfigManager; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; import appeng.core.AppEng; - +import appeng.fluids.container.ContainerFluidLevelEmitter; import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidTank; @@ -51,329 +49,276 @@ import appeng.parts.automation.PartUpgradeable; import appeng.util.IConfigManagerHost; import appeng.util.Platform; +public class PartFluidLevelEmitter extends PartUpgradeable + implements IStackWatcherHost, IConfigManagerHost, IAEFluidInventory, IMEMonitorHandlerReceiver { + @PartModels + public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_base_off"); + @PartModels + public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_base_on"); + @PartModels + public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_off"); + @PartModels + public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_on"); + @PartModels + public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_has_channel"); -public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatcherHost, IConfigManagerHost, IAEFluidInventory, IMEMonitorHandlerReceiver -{ - @PartModels - public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_off" ); - @PartModels - public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_on" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_off" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_on" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_has_channel" ); + public static final PartModel MODEL_OFF_OFF = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_OFF); + public static final PartModel MODEL_OFF_ON = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_ON); + public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL); + public static final PartModel MODEL_ON_OFF = new PartModel(MODEL_BASE_ON, MODEL_STATUS_OFF); + public static final PartModel MODEL_ON_ON = new PartModel(MODEL_BASE_ON, MODEL_STATUS_ON); + public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel(MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL); - public static final PartModel MODEL_OFF_OFF = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_OFF ); - public static final PartModel MODEL_OFF_ON = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_ON ); - public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL ); - public static final PartModel MODEL_ON_OFF = new PartModel( MODEL_BASE_ON, MODEL_STATUS_OFF ); - public static final PartModel MODEL_ON_ON = new PartModel( MODEL_BASE_ON, MODEL_STATUS_ON ); - public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL ); + private static final int FLAG_ON = 4; - private static final int FLAG_ON = 4; + private boolean prevState = false; + private long lastReportedValue = 0; + private long reportingValue = 0; + private IStackWatcher stackWatcher = null; + private final AEFluidInventory config = new AEFluidInventory(this, 1); - private boolean prevState = false; - private long lastReportedValue = 0; - private long reportingValue = 0; - private IStackWatcher stackWatcher = null; - private final AEFluidInventory config = new AEFluidInventory( this, 1 ); + public PartFluidLevelEmitter(ItemStack is) { + super(is); - public PartFluidLevelEmitter( ItemStack is ) - { - super( is ); + this.getConfigManager().registerSetting(Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL); + } - this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL ); - } + public long getReportingValue() { + return this.reportingValue; + } - public long getReportingValue() - { - return this.reportingValue; - } + public void setReportingValue(final long v) { + this.reportingValue = v; + this.updateState(); + } - public void setReportingValue( final long v ) - { - this.reportingValue = v; - this.updateState(); - } + @Override + public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue) { + this.configureWatchers(); + } - @Override - public void updateSetting(IConfigManager manager, Settings settingName, Enum newValue ) - { - this.configureWatchers(); - } + @Override + public void updateWatcher(IStackWatcher newWatcher) { + this.stackWatcher = newWatcher; + this.configureWatchers(); + } - @Override - public void updateWatcher( IStackWatcher newWatcher ) - { - this.stackWatcher = newWatcher; - this.configureWatchers(); - } + @Override + public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, + IStorageChannel chan) { + if (chan == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class) + && fullStack.equals(this.config.getFluidInSlot(0))) { + this.lastReportedValue = fullStack.getStackSize(); + this.updateState(); + } + } - @Override - public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan ) - { - if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && fullStack.equals( this.config.getFluidInSlot( 0 ) ) ) - { - this.lastReportedValue = fullStack.getStackSize(); - this.updateState(); - } - } + @Override + public void onFluidInventoryChanged(IAEFluidTank inv, int slot) { + this.configureWatchers(); + } - @Override - public void onFluidInventoryChanged( IAEFluidTank inv, int slot ) - { - this.configureWatchers(); - } + @MENetworkEventSubscribe + public void channelChanged(final MENetworkChannelsChanged c) { + this.updateState(); + } - @MENetworkEventSubscribe - public void channelChanged( final MENetworkChannelsChanged c ) - { - this.updateState(); - } + @MENetworkEventSubscribe + public void powerChanged(final MENetworkPowerStatusChange c) { + this.updateState(); + } - @MENetworkEventSubscribe - public void powerChanged( final MENetworkPowerStatusChange c ) - { - this.updateState(); - } + @Override + public int isProvidingStrongPower() { + return this.prevState ? 15 : 0; + } - @Override - public int isProvidingStrongPower() - { - return this.prevState ? 15 : 0; - } + @Override + public int isProvidingWeakPower() { + return this.prevState ? 15 : 0; + } - @Override - public int isProvidingWeakPower() - { - return this.prevState ? 15 : 0; - } + @Override + protected int populateFlags(final int cf) { + return cf | (this.prevState ? FLAG_ON : 0); + } - @Override - protected int populateFlags( final int cf ) - { - return cf | ( this.prevState ? FLAG_ON : 0 ); - } + @Override + public boolean isValid(final Object effectiveGrid) { + try { + return this.getProxy().getGrid() == effectiveGrid; + } catch (final GridAccessException e) { + return false; + } + } - @Override - public boolean isValid( final Object effectiveGrid ) - { - try - { - return this.getProxy().getGrid() == effectiveGrid; - } - catch( final GridAccessException e ) - { - return false; - } - } + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource actionSource) { + this.updateReportingValue((IMEMonitor) monitor); + } - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource actionSource ) - { - this.updateReportingValue( (IMEMonitor) monitor ); - } + @Override + public void onListUpdate() { + try { + final IStorageChannel channel = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class); + final IMEMonitor inventory = this.getProxy().getStorage().getInventory(channel); - @Override - public void onListUpdate() - { - try - { - final IStorageChannel channel = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - final IMEMonitor inventory = this.getProxy().getStorage().getInventory( channel ); + this.updateReportingValue(inventory); + } catch (final GridAccessException e) { + // ;P + } + } - this.updateReportingValue( inventory ); - } - catch( final GridAccessException e ) - { - // ;P - } - } + private void updateState() { + final boolean isOn = this.isLevelEmitterOn(); + if (this.prevState != isOn) { + this.getHost().markForUpdate(); + final TileEntity te = this.getHost().getTile(); + this.prevState = isOn; + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos()); + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos().offset(this.getSide().getFacing())); + } + } - private void updateState() - { - final boolean isOn = this.isLevelEmitterOn(); - if( this.prevState != isOn ) - { - this.getHost().markForUpdate(); - final TileEntity te = this.getHost().getTile(); - this.prevState = isOn; - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() ); - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos().offset( this.getSide().getFacing() ) ); - } - } + private void configureWatchers() { + final IFluidStorageChannel channel = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); - private void configureWatchers() - { - final IFluidStorageChannel channel = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); + if (this.stackWatcher != null) { + this.stackWatcher.reset(); - if( this.stackWatcher != null ) - { - this.stackWatcher.reset(); + final IAEFluidStack myStack = this.config.getFluidInSlot(0); - final IAEFluidStack myStack = this.config.getFluidInSlot( 0 ); + try { + if (myStack != null) { + this.getProxy().getStorage().getInventory(channel).removeListener(this); + this.stackWatcher.add(myStack); + } else { + this.getProxy().getStorage().getInventory(channel).addListener(this, this.getProxy().getGrid()); + } - try - { - if( myStack != null ) - { - this.getProxy().getStorage().getInventory( channel ).removeListener( this ); - this.stackWatcher.add( myStack ); - } - else - { - this.getProxy() - .getStorage() - .getInventory( channel ) - .addListener( this, this.getProxy().getGrid() ); - } + final IMEMonitor inventory = this.getProxy().getStorage().getInventory(channel); - final IMEMonitor inventory = this.getProxy().getStorage().getInventory( channel ); + this.updateReportingValue(inventory); + } catch (GridAccessException e) { + // NOP + } + } + } - this.updateReportingValue( inventory ); - } - catch( GridAccessException e ) - { - // NOP - } - } - } + private void updateReportingValue(final IMEMonitor monitor) { + final IAEFluidStack myStack = this.config.getFluidInSlot(0); - private void updateReportingValue( final IMEMonitor monitor ) - { - final IAEFluidStack myStack = this.config.getFluidInSlot( 0 ); + if (myStack == null) { + this.lastReportedValue = 0; + for (final IAEFluidStack st : monitor.getStorageList()) { + this.lastReportedValue += st.getStackSize(); + } + } else { + final IAEFluidStack r = monitor.getStorageList().findPrecise(myStack); + if (r == null) { + this.lastReportedValue = 0; + } else { + this.lastReportedValue = r.getStackSize(); + } + } + this.updateState(); + } - if( myStack == null ) - { - this.lastReportedValue = 0; - for( final IAEFluidStack st : monitor.getStorageList() ) - { - this.lastReportedValue += st.getStackSize(); - } - } - else - { - final IAEFluidStack r = monitor.getStorageList().findPrecise( myStack ); - if( r == null ) - { - this.lastReportedValue = 0; - } - else - { - this.lastReportedValue = r.getStackSize(); - } - } - this.updateState(); - } + private boolean isLevelEmitterOn() { + if (Platform.isClient()) { + return (this.getClientFlags() & FLAG_ON) == FLAG_ON; + } - private boolean isLevelEmitterOn() - { - if( Platform.isClient() ) - { - return ( this.getClientFlags() & FLAG_ON ) == FLAG_ON; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !this.getProxy().isActive() ) - { - return false; - } + final boolean flipState = this.getConfigManager() + .getSetting(Settings.REDSTONE_EMITTER) == RedstoneMode.LOW_SIGNAL; + return flipState ? this.reportingValue > this.lastReportedValue : this.reportingValue <= this.lastReportedValue; + } - final boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL; - return flipState ? this.reportingValue > this.lastReportedValue : this.reportingValue <= this.lastReportedValue; - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 16; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 16; - } + @Override + public boolean canConnectRedstone() { + return true; + } - @Override - public boolean canConnectRedstone() - { - return true; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(7, 7, 11, 9, 9, 16); + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 7, 7, 11, 9, 9, 16 ); - } + @Override + public void animateTick(final World world, final BlockPos pos, final Random r) { + if (this.isLevelEmitterOn()) { + final AEPartLocation d = this.getSide(); - @Override - public void animateTick( final World world, final BlockPos pos, final Random r ) - { - if( this.isLevelEmitterOn() ) - { - final AEPartLocation d = this.getSide(); + final double d0 = d.xOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; + final double d1 = d.yOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; + final double d2 = d.zOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; - final double d0 = d.xOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - final double d1 = d.yOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - final double d2 = d.zOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; + // FIXME world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, + // 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D, + // FIXME new int[0] ); + } + } - // FIXME world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D, - // FIXME new int[0] ); - } - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidLevelEmitter.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidLevelEmitter.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return this.isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL; + } else if (this.isPowered()) { + return this.isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON; + } else { + return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; + } + } - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return this.isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return this.isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON; - } - else - { - return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; - } - } + public IAEFluidTank getConfig() { + return this.config; + } - public IAEFluidTank getConfig() - { - return this.config; - } + @Override + public void readFromNBT(final CompoundNBT 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 void readFromNBT( final CompoundNBT 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 void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putLong( "lastReportedValue", this.lastReportedValue ); - data.putLong( "reportingValue", this.reportingValue ); - data.putBoolean("prevState", this.prevState); - this.config.writeToNBT( data, "config" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putLong("lastReportedValue", this.lastReportedValue); + data.putLong("reportingValue", this.reportingValue); + data.putBoolean("prevState", this.prevState); + this.config.writeToNBT(data, "config"); + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidStorageBus.java b/src/main/java/appeng/fluids/parts/PartFluidStorageBus.java index 88c3d775d..f7288c24b 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidStorageBus.java +++ b/src/main/java/appeng/fluids/parts/PartFluidStorageBus.java @@ -18,16 +18,12 @@ package appeng.fluids.parts; - import java.util.Collections; import java.util.List; import java.util.Objects; + import javax.annotation.Nonnull; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.fluids.container.ContainerFluidInterface; -import appeng.fluids.container.ContainerFluidStorageBus; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -68,9 +64,12 @@ import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IItemList; import appeng.api.util.AEPartLocation; import appeng.capabilities.Capabilities; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; import appeng.core.AppEng; import appeng.core.settings.TickRates; - +import appeng.fluids.container.ContainerFluidInterface; +import appeng.fluids.container.ContainerFluidStorageBus; import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidTank; @@ -86,417 +85,361 @@ import appeng.util.Platform; import appeng.util.prioritylist.FuzzyPriorityList; import appeng.util.prioritylist.PrecisePriorityList; - /** * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMonitorHandlerReceiver, IAEFluidInventory -{ - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_base" ); - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_off" ) ); - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_on" ) ); - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_has_channel" ) ); +public class PartFluidStorageBus extends PartSharedStorageBus + implements IMEMonitorHandlerReceiver, IAEFluidInventory { + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, + "part/fluid_storage_bus_base"); + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_off")); + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_on")); + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_has_channel")); - private final IActionSource source; - private final AEFluidInventory config = new AEFluidInventory( this, 63 ); - private boolean cached = false; - private ITickingMonitor monitor = null; - private MEInventoryHandler handler = null; - private int handlerHash = 0; - private byte resetCacheLogic = 0; + private final IActionSource source; + private final AEFluidInventory config = new AEFluidInventory(this, 63); + private boolean cached = false; + private ITickingMonitor monitor = null; + private MEInventoryHandler handler = null; + private int handlerHash = 0; + private byte resetCacheLogic = 0; - public PartFluidStorageBus( ItemStack 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.source = new MachineSource( this ); - } + public PartFluidStorageBus(ItemStack 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.source = new MachineSource(this); + } - private IMEInventory getInventoryWrapper( TileEntity target ) - { - Direction targetSide = this.getSide().getFacing().getOpposite(); - // Prioritize a handler to directly link to another ME network - IStorageMonitorableAccessor accessor = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ).orElse( null ); - if( accessor != null ) - { - IStorageMonitorable inventory = accessor.getInventory( this.source ); - if( inventory != null ) - { - return inventory.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); - } + private IMEInventory getInventoryWrapper(TileEntity target) { + Direction targetSide = this.getSide().getFacing().getOpposite(); + // Prioritize a handler to directly link to another ME network + IStorageMonitorableAccessor accessor = target + .getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide).orElse(null); + if (accessor != null) { + IStorageMonitorable inventory = accessor.getInventory(this.source); + if (inventory != null) { + return inventory.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + } - // So this could / can be a design decision. If the tile does support our custom capability, - // but it does not return an inventory for the action source, we do NOT fall back to using - // IItemHandler's, as that might circumvent the security setings, and might also cause - // performance issues. - return null; - } + // So this could / can be a design decision. If the tile does support our custom + // capability, + // but it does not return an inventory for the action source, we do NOT fall + // back to using + // IItemHandler's, as that might circumvent the security setings, and might also + // cause + // performance issues. + return null; + } - // Check via cap for IItemHandler - IFluidHandler handlerExt = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ).orElse( null ); - if( handlerExt != null ) - { - return new FluidHandlerAdapter( handlerExt, this ); - } + // Check via cap for IItemHandler + IFluidHandler handlerExt = target.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide) + .orElse(null); + if (handlerExt != null) { + return new FluidHandlerAdapter(handlerExt, this); + } - return null; - } + return null; + } - @Override - public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall ) - { - if( this.resetCacheLogic != 0 ) - { - this.resetCache(); - } + @Override + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { + if (this.resetCacheLogic != 0) { + this.resetCache(); + } - if( this.monitor != null ) - { - return this.monitor.onTick(); - } + if (this.monitor != null) { + return this.monitor.onTick(); + } - return TickRateModulation.SLEEP; - } + return TickRateModulation.SLEEP; + } - @Override - protected void resetCache() - { - final boolean fullReset = this.resetCacheLogic == 2; - this.resetCacheLogic = 0; + @Override + protected void resetCache() { + final boolean fullReset = this.resetCacheLogic == 2; + this.resetCacheLogic = 0; - final IMEInventory in = this.getInternalHandler(); - IItemList before = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); - if( in != null ) - { - before = in.getAvailableItems( before ); - } + final IMEInventory in = this.getInternalHandler(); + IItemList before = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class) + .createList(); + if (in != null) { + before = in.getAvailableItems(before); + } - this.cached = false; - if( fullReset ) - { - this.handlerHash = 0; - } + this.cached = false; + if (fullReset) { + this.handlerHash = 0; + } - final IMEInventory out = this.getInternalHandler(); + final IMEInventory out = this.getInternalHandler(); - if( in != out ) - { - IItemList after = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); - if( out != null ) - { - after = out.getAvailableItems( after ); - } - Platform.postListChanges( before, after, this, this.source ); - } - } + if (in != out) { + IItemList after = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class) + .createList(); + if (out != null) { + after = out.getAvailableItems(after); + } + Platform.postListChanges(before, after, this, this.source); + } + } - @Override - protected void resetCache( final boolean fullReset ) - { - if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote ) - { - return; - } + @Override + protected void resetCache(final boolean fullReset) { + if (this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null + || this.getHost().getTile().getWorld().isRemote) { + return; + } - if( fullReset ) - { - this.resetCacheLogic = 2; - } - else - { - this.resetCacheLogic = 1; - } + if (fullReset) { + this.resetCacheLogic = 2; + } else { + this.resetCacheLogic = 1; + } - try - { - this.getProxy().getTick().alertDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + try { + this.getProxy().getTick().alertDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidStorageBus.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidStorageBus.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } - @Override - public void onFluidInventoryChanged( IAEFluidTank inv, int slot ) - { - if( inv == this.config ) - { - this.resetCache( true ); - } - } + @Override + public void onFluidInventoryChanged(IAEFluidTank inv, int slot) { + if (inv == this.config) { + this.resetCache(true); + } + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.config.readFromNBT( data, "config" ); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.config.readFromNBT(data, "config"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.config.writeToNBT( data, "config" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.config.writeToNBT(data, "config"); + } - @Override - public boolean isValid( final Object verificationToken ) - { - return this.handler == verificationToken; - } + @Override + public boolean isValid(final Object verificationToken) { + return this.handler == verificationToken; + } - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource source ) - { - try - { - if( this.getProxy().isActive() ) - { - this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source ); - } - } - catch( final GridAccessException e ) - { - // :( - } - } + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource source) { + try { + if (this.getProxy().isActive()) { + this.getProxy().getStorage().postAlterationOfStoredItems( + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, this.source); + } + } catch (final GridAccessException e) { + // :( + } + } - public MEInventoryHandler getInternalHandler() - { - if( this.cached ) - { - return this.handler; - } + public MEInventoryHandler getInternalHandler() { + if (this.cached) { + return this.handler; + } - final boolean wasSleeping = this.monitor == null; + final boolean wasSleeping = this.monitor == null; - this.cached = true; - final TileEntity self = this.getHost().getTile(); - final TileEntity target = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) ); - final int newHandlerHash = this.createHandlerHash( target ); + this.cached = true; + final TileEntity self = this.getHost().getTile(); + final TileEntity target = self.getWorld().getTileEntity(self.getPos().offset(this.getSide().getFacing())); + final int newHandlerHash = this.createHandlerHash(target); - if( newHandlerHash != 0 && newHandlerHash == this.handlerHash ) - { - return this.handler; - } + if (newHandlerHash != 0 && newHandlerHash == this.handlerHash) { + return this.handler; + } - this.handlerHash = newHandlerHash; - this.handler = null; - this.monitor = null; - if( target != null ) - { - IMEInventory inv = this.getInventoryWrapper( target ); - if( inv instanceof ITickingMonitor ) - { - this.monitor = (ITickingMonitor) inv; - this.monitor.setActionSource( new MachineSource( this ) ); - } + this.handlerHash = newHandlerHash; + this.handler = null; + this.monitor = null; + if (target != null) { + IMEInventory inv = this.getInventoryWrapper(target); + if (inv instanceof ITickingMonitor) { + this.monitor = (ITickingMonitor) inv; + this.monitor.setActionSource(new MachineSource(this)); + } - if( inv != null ) - { - this.checkInterfaceVsStorageBus( target, this.getSide().getOpposite() ); + if (inv != null) { + this.checkInterfaceVsStorageBus(target, this.getSide().getOpposite()); - this.handler = new MEInventoryHandler<>( inv, AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ); + this.handler = new MEInventoryHandler<>(inv, + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); - this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) ); - this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); - this.handler.setPriority( this.getPriority() ); + this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS)); + this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST + : IncludeExclude.WHITELIST); + this.handler.setPriority(this.getPriority()); - final IItemList priorityList = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); + final IItemList priorityList = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createList(); - final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; - for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ ) - { - final IAEFluidStack is = this.config.getFluidInSlot( x ); - if( is != null ) - { - priorityList.add( is ); - } - } + final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9; + for (int x = 0; x < this.config.getSlots() && x < slotsToUse; x++) { + final IAEFluidStack is = this.config.getFluidInSlot(x); + if (is != null) { + priorityList.add(is); + } + } - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); - } - else - { - this.handler.setPartitionList( new PrecisePriorityList( priorityList ) ); - } + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + this.handler.setPartitionList(new FuzzyPriorityList(priorityList, + (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE))); + } else { + this.handler.setPartitionList(new PrecisePriorityList(priorityList)); + } - if( inv instanceof IBaseMonitor ) - { - ( (IBaseMonitor) inv ).addListener( this, this.handler ); - } - } - } + if (inv instanceof IBaseMonitor) { + ((IBaseMonitor) inv).addListener(this, this.handler); + } + } + } - // update sleep state... - if( wasSleeping != ( this.monitor == null ) ) - { - try - { - final ITickManager tm = this.getProxy().getTick(); - if( this.monitor == null ) - { - tm.sleepDevice( this.getProxy().getNode() ); - } - else - { - tm.wakeDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException ignore ) - { - // :( - } - } + // update sleep state... + if (wasSleeping != (this.monitor == null)) { + try { + final ITickManager tm = this.getProxy().getTick(); + if (this.monitor == null) { + tm.sleepDevice(this.getProxy().getNode()); + } else { + tm.wakeDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException ignore) { + // :( + } + } - try - { - // force grid to update handlers... - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException ignore ) - { - // :3 - } + try { + // force grid to update handlers... + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException ignore) { + // :3 + } - return this.handler; - } + return this.handler; + } - private void checkInterfaceVsStorageBus( final TileEntity target, final AEPartLocation side ) - { - IInterfaceHost achievement = null; + private void checkInterfaceVsStorageBus(final TileEntity target, final AEPartLocation side) { + IInterfaceHost achievement = null; - if( target instanceof IInterfaceHost ) - { - achievement = (IInterfaceHost) target; - } + if (target instanceof IInterfaceHost) { + achievement = (IInterfaceHost) target; + } - if( target instanceof IPartHost ) - { - final Object part = ( (IPartHost) target ).getPart( side ); - if( part instanceof IInterfaceHost ) - { - achievement = (IInterfaceHost) part; - } - } + if (target instanceof IPartHost) { + final Object part = ((IPartHost) target).getPart(side); + if (part instanceof IInterfaceHost) { + achievement = (IInterfaceHost) part; + } + } - if( achievement != null && achievement.getActionableNode() != null ) - { - // Platform.addStat( achievement.getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() - // ); - // Platform.addStat( getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() ); - } - } + if (achievement != null && achievement.getActionableNode() != null) { + // Platform.addStat( achievement.getActionableNode().getPlayerID(), + // Achievements.Recursive.getAchievement() + // ); + // Platform.addStat( getActionableNode().getPlayerID(), + // Achievements.Recursive.getAchievement() ); + } + } - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( channel == this.getStorageChannel() ) - { - final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() : null; - if( out != null ) - { - return Collections.singletonList( out ); - } - } - return super.getCellArray( channel ); - } + @Override + public List getCellArray(final IStorageChannel channel) { + if (channel == this.getStorageChannel()) { + final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() + : null; + if (out != null) { + return Collections.singletonList(out); + } + } + return super.getCellArray(channel); + } - private int createHandlerHash( TileEntity target ) - { - if( target == null ) - { - return 0; - } + private int createHandlerHash(TileEntity target) { + if (target == null) { + return 0; + } - final Direction targetSide = this.getSide().getFacing().getOpposite(); + final Direction targetSide = this.getSide().getFacing().getOpposite(); - LazyOptional accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ); - if( accessorOpt.isPresent() ) - { - return Objects.hash( target, accessorOpt.orElse( null ) ); - } + LazyOptional accessorOpt = target + .getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide); + if (accessorOpt.isPresent()) { + return Objects.hash(target, accessorOpt.orElse(null)); + } - final IFluidHandler fluidHandler = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ).orElse( null ); + final IFluidHandler fluidHandler = target + .getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide).orElse(null); - if( fluidHandler != null ) - { - return Objects.hash( target, fluidHandler, fluidHandler.getTanks() ); - } + if (fluidHandler != null) { + return Objects.hash(target, fluidHandler, fluidHandler.getTanks()); + } - return 0; - } + return 0; + } - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( TickRates.FluidStorageBus.getMin(), TickRates.FluidStorageBus.getMax(), this.isSleeping(), true ); - } + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(TickRates.FluidStorageBus.getMin(), TickRates.FluidStorageBus.getMax(), + this.isSleeping(), true); + } - @Override - public void onListUpdate() - { - // not used here. - } + @Override + public void onListUpdate() { + // not used here. + } - @Override - public IStorageChannel getStorageChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public IStorageChannel getStorageChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - public IAEFluidTank getConfig() - { - return this.config; - } + public IAEFluidTank getConfig() { + return this.config; + } - @Nonnull - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Nonnull + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().fluidStorageBus().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().fluidStorageBus().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ContainerType getContainerType() - { - return ContainerFluidStorageBus.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerFluidStorageBus.TYPE; + } } diff --git a/src/main/java/appeng/fluids/parts/PartFluidTerminal.java b/src/main/java/appeng/fluids/parts/PartFluidTerminal.java index a23bae118..633df35c5 100644 --- a/src/main/java/appeng/fluids/parts/PartFluidTerminal.java +++ b/src/main/java/appeng/fluids/parts/PartFluidTerminal.java @@ -18,8 +18,6 @@ package appeng.fluids.parts; - -import appeng.fluids.container.ContainerFluidTerminal; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -27,43 +25,38 @@ import net.minecraft.util.ResourceLocation; import appeng.api.parts.IPartModel; import appeng.core.AppEng; - +import appeng.fluids.container.ContainerFluidTerminal; import appeng.items.parts.PartModels; import appeng.parts.PartModel; import appeng.parts.reporting.AbstractPartTerminal; - /** * @author BrockWS * @version rv6 - 12/05/2018 * @since rv6 12/05/2018 */ -public class PartFluidTerminal extends AbstractPartTerminal -{ +public class PartFluidTerminal extends AbstractPartTerminal { - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/fluid_terminal_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/fluid_terminal_on" ); + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/fluid_terminal_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/fluid_terminal_on"); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public PartFluidTerminal( ItemStack is ) - { - super( is ); - } + public PartFluidTerminal(ItemStack is) { + super(is); + } - @Override - public ContainerType getContainerType(PlayerEntity player ) - { - return ContainerFluidTerminal.TYPE; - } + @Override + public ContainerType getContainerType(PlayerEntity player) { + return ContainerFluidTerminal.TYPE; + } - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/fluids/parts/PartSharedFluidBus.java b/src/main/java/appeng/fluids/parts/PartSharedFluidBus.java index 12254d820..4159de88c 100644 --- a/src/main/java/appeng/fluids/parts/PartSharedFluidBus.java +++ b/src/main/java/appeng/fluids/parts/PartSharedFluidBus.java @@ -18,11 +18,6 @@ package appeng.fluids.parts; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.fluids.container.ContainerFluidIO; -import appeng.fluids.container.ContainerFluidInterface; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -43,156 +38,132 @@ import appeng.api.networking.ticking.TickRateModulation; import appeng.api.parts.IPartCollisionHelper; import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.util.AECableType; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.fluids.container.ContainerFluidIO; +import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.IAEFluidTank; import appeng.me.GridAccessException; import appeng.parts.automation.PartUpgradeable; import appeng.util.Platform; - /** * @author BrockWS * @version rv6 - 30/04/2018 * @since rv6 30/04/2018 */ -public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable -{ +public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable { - private final AEFluidInventory config = new AEFluidInventory( null, 9 ); - private boolean lastRedstone; + private final AEFluidInventory config = new AEFluidInventory(null, 9); + private boolean lastRedstone; - public PartSharedFluidBus( ItemStack is ) - { - super( is ); - } + public PartSharedFluidBus(ItemStack is) { + super(is); + } - @Override - public void upgradesChanged() - { - this.updateState(); - } + @Override + public void upgradesChanged() { + this.updateState(); + } - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - this.updateState(); - if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) ) - { - this.lastRedstone = !this.lastRedstone; - if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE ) - { - this.doBusWork(); - } - } - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + this.updateState(); + if (this.lastRedstone != this.getHost().hasRedstone(this.getSide())) { + this.lastRedstone = !this.lastRedstone; + if (this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE) { + this.doBusWork(); + } + } + } - private void updateState() - { - try - { - if( !this.isSleeping() ) - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - else - { - this.getProxy().getTick().sleepDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } + private void updateState() { + try { + if (!this.isSleeping()) { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } else { + this.getProxy().getTick().sleepDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFluidIO.TYPE, player, ContainerLocator.forPart(this)); - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFluidIO.TYPE, player, ContainerLocator.forPart(this)); + } - return true; - } + return true; + } - @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 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); + } - protected TileEntity getConnectedTE() - { - TileEntity self = this.getHost().getTile(); - return this.getTileEntity( self, self.getPos().offset( this.getSide().getFacing() ) ); - } + protected TileEntity getConnectedTE() { + TileEntity self = this.getHost().getTile(); + return this.getTileEntity(self, self.getPos().offset(this.getSide().getFacing())); + } - private TileEntity getTileEntity( final TileEntity self, final BlockPos pos ) - { - final World w = self.getWorld(); + private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) { + final World w = self.getWorld(); - if( w.getChunkProvider().isChunkLoaded( new ChunkPos( pos ) ) ) - { - return w.getTileEntity( pos ); - } + if (w.getChunkProvider().isChunkLoaded(new ChunkPos(pos))) { + return w.getTileEntity(pos); + } - return null; - } + return null; + } - protected int calculateAmountToSend() - { - double amount = this.getChannel().transferFactor(); - switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) - { - case 4: - amount = amount * 1.5; - case 3: - amount = amount * 2; - case 2: - amount = amount * 4; - case 1: - amount = amount * 8; - case 0: - default: - return MathHelper.floor( amount ); - } - } + protected int calculateAmountToSend() { + double amount = this.getChannel().transferFactor(); + switch (this.getInstalledUpgrades(Upgrades.SPEED)) { + case 4: + amount = amount * 1.5; + case 3: + amount = amount * 2; + case 2: + amount = amount * 4; + case 1: + amount = amount * 8; + case 0: + default: + return MathHelper.floor(amount); + } + } - @Override - public void readFromNBT( CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.config.readFromNBT( extra, "config" ); - } + @Override + public void readFromNBT(CompoundNBT extra) { + super.readFromNBT(extra); + this.config.readFromNBT(extra, "config"); + } - @Override - public void writeToNBT( CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.config.writeToNBT( extra, "config" ); - } + @Override + public void writeToNBT(CompoundNBT extra) { + super.writeToNBT(extra); + this.config.writeToNBT(extra, "config"); + } - public IAEFluidTank getConfig() - { - return this.config; - } + public IAEFluidTank getConfig() { + return this.config; + } - protected IFluidStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + protected IFluidStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 5; - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 5; + } - protected abstract TickRateModulation doBusWork(); + protected abstract TickRateModulation doBusWork(); - protected abstract boolean canDoBusWork(); + protected abstract boolean canDoBusWork(); } diff --git a/src/main/java/appeng/fluids/registries/BasicFluidCellGuiHandler.java b/src/main/java/appeng/fluids/registries/BasicFluidCellGuiHandler.java index d24482e2b..cab4876a1 100644 --- a/src/main/java/appeng/fluids/registries/BasicFluidCellGuiHandler.java +++ b/src/main/java/appeng/fluids/registries/BasicFluidCellGuiHandler.java @@ -18,11 +18,6 @@ package appeng.fluids.registries; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerFormationPlane; -import appeng.fluids.container.ContainerFluidTerminal; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -36,22 +31,23 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.util.AEPartLocation; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerFormationPlane; +import appeng.fluids.container.ContainerFluidTerminal; import appeng.util.Platform; +public class BasicFluidCellGuiHandler implements ICellGuiHandler { -public class BasicFluidCellGuiHandler implements ICellGuiHandler -{ + @Override + public > boolean isHandlerFor(final IStorageChannel channel) { + return channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public > boolean isHandlerFor( final IStorageChannel channel ) - { - return channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } - - @Override - public void openChestGui( final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan ) - { - ContainerOpener.openContainer(ContainerFluidTerminal.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp())); - } + @Override + public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, + final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) { + ContainerOpener.openContainer(ContainerFluidTerminal.TYPE, player, + ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp())); + } } diff --git a/src/main/java/appeng/fluids/tile/TileFluidInterface.java b/src/main/java/appeng/fluids/tile/TileFluidInterface.java index 1ef1bd6bc..3501523f9 100644 --- a/src/main/java/appeng/fluids/tile/TileFluidInterface.java +++ b/src/main/java/appeng/fluids/tile/TileFluidInterface.java @@ -18,12 +18,10 @@ package appeng.fluids.tile; - import java.util.EnumSet; import javax.annotation.Nullable; -import appeng.fluids.container.ContainerFluidInterface; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -47,146 +45,123 @@ import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; - +import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.helper.DualityFluidInterface; import appeng.fluids.helper.IFluidInterfaceHost; import appeng.helpers.IPriorityHost; import appeng.tile.grid.AENetworkTile; +public class TileFluidInterface extends AENetworkTile implements IGridTickable, IFluidInterfaceHost, IPriorityHost { + private final DualityFluidInterface duality = new DualityFluidInterface(this.getProxy(), this); -public class TileFluidInterface extends AENetworkTile implements IGridTickable, IFluidInterfaceHost, IPriorityHost -{ - private final DualityFluidInterface duality = new DualityFluidInterface( this.getProxy(), this ); + public TileFluidInterface(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileFluidInterface(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkChannelsChanged c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkChannelsChanged c ) - { - this.duality.notifyNeighbors(); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkPowerStatusChange c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkPowerStatusChange c ) - { - this.duality.notifyNeighbors(); - } + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return this.duality.getTickingRequest(node); + } - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return this.duality.getTickingRequest( node ); - } + @Override + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { + return this.duality.tickingRequest(node, ticksSinceLastCall); + } - @Override - public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall ) - { - return this.duality.tickingRequest( node, ticksSinceLastCall ); - } + @Override + public DualityFluidInterface getDualityFluidInterface() { + return this.duality; + } - @Override - public DualityFluidInterface getDualityFluidInterface() - { - return this.duality; - } + @Override + public TileEntity getTileEntity() { + return this; + } - @Override - public TileEntity getTileEntity() - { - return this; - } + @Override + public void gridChanged() { + this.duality.gridChanged(); + } - @Override - public void gridChanged() - { - this.duality.gridChanged(); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.duality.writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.duality.writeToNBT( data ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.duality.readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.duality.readFromNBT( data ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return this.duality.getCableConnectionType(dir); + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return this.duality.getCableConnectionType( dir ); - } + @Override + public DimensionalCoord getLocation() { + return this.duality.getLocation(); + } - @Override - public DimensionalCoord getLocation() - { - return this.duality.getLocation(); - } + @Override + public EnumSet getTargets() { + return EnumSet.allOf(Direction.class); + } - @Override - public EnumSet getTargets() - { - return EnumSet.allOf( Direction.class ); - } + @Override + public int getPriority() { + return this.duality.getPriority(); + } - @Override - public int getPriority() - { - return this.duality.getPriority(); - } + @Override + public void setPriority(final int newValue) { + this.duality.setPriority(newValue); + } - @Override - public void setPriority( final int newValue ) - { - this.duality.setPriority( newValue ); - } + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + LazyOptional result = this.duality.getCapability(capability, facing); + if (result.isPresent()) { + return result; + } + return super.getCapability(capability, facing); + } - @Override - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - LazyOptional result = this.duality.getCapability( capability, facing ); - if( result.isPresent() ) - { - return result; - } - return super.getCapability( capability, facing ); - } + @Override + public int getInstalledUpgrades(Upgrades u) { + return this.duality.getInstalledUpgrades(u); + } - @Override - public int getInstalledUpgrades( Upgrades u ) - { - return this.duality.getInstalledUpgrades( u ); - } + @Override + public IConfigManager getConfigManager() { + return this.duality.getConfigManager(); + } - @Override - public IConfigManager getConfigManager() - { - return this.duality.getConfigManager(); - } + @Override + public IItemHandler getInventoryByName(String name) { + return this.duality.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( String name ) - { - return this.duality.getInventoryByName( name ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().blocks().fluidIface().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().blocks().fluidIface().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerFluidInterface.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerFluidInterface.TYPE; + } } diff --git a/src/main/java/appeng/fluids/util/AEFluidInventory.java b/src/main/java/appeng/fluids/util/AEFluidInventory.java index 54328b2ca..97ec331a4 100644 --- a/src/main/java/appeng/fluids/util/AEFluidInventory.java +++ b/src/main/java/appeng/fluids/util/AEFluidInventory.java @@ -1,9 +1,10 @@ package appeng.fluids.util; - import java.util.Objects; +import javax.annotation.Nonnull; + import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.fluids.FluidStack; @@ -11,373 +12,300 @@ import appeng.api.storage.data.IAEFluidStack; import appeng.core.AELog; import appeng.util.Platform; -import javax.annotation.Nonnull; +public class AEFluidInventory implements IAEFluidTank { + private final IAEFluidStack[] fluids; + private final IAEFluidInventory handler; + private final int capacity; + public AEFluidInventory(final IAEFluidInventory handler, final int slots, final int capacity) { + this.fluids = new IAEFluidStack[slots]; + this.handler = handler; + this.capacity = capacity; + } -public class AEFluidInventory implements IAEFluidTank -{ - private final IAEFluidStack[] fluids; - private final IAEFluidInventory handler; - private final int capacity; + public AEFluidInventory(final IAEFluidInventory handler, final int slots) { + this(handler, slots, Integer.MAX_VALUE); + } - public AEFluidInventory( final IAEFluidInventory handler, final int slots, final int capacity ) - { - this.fluids = new IAEFluidStack[slots]; - this.handler = handler; - this.capacity = capacity; - } + @Override + public void setFluidInSlot(final int slot, final IAEFluidStack fluid) { + if (slot >= 0 && slot < this.getSlots()) { + if (Objects.equals(this.fluids[slot], fluid)) { + if (fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize()) { + this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity)); + this.onContentChanged(slot); + } + } else { + if (fluid == null) { + this.fluids[slot] = null; + } else { + this.fluids[slot] = fluid.copy(); + this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity)); + } - public AEFluidInventory( final IAEFluidInventory handler, final int slots ) - { - this( handler, slots, Integer.MAX_VALUE ); - } + this.onContentChanged(slot); + } + } + } - @Override - public void setFluidInSlot( final int slot, final IAEFluidStack fluid ) - { - if( slot >= 0 && slot < this.getSlots() ) - { - if( Objects.equals( this.fluids[slot], fluid ) ) - { - if( fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize() ) - { - this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); - this.onContentChanged( slot ); - } - } - else - { - if( fluid == null ) - { - this.fluids[slot] = null; - } - else - { - this.fluids[slot] = fluid.copy(); - this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); - } + private void onContentChanged(final int slot) { + if (this.handler != null && Platform.isServer()) { + this.handler.onFluidInventoryChanged(this, slot); + } + } - this.onContentChanged( slot ); - } - } - } + @Override + public IAEFluidStack getFluidInSlot(final int slot) { + if (slot >= 0 && slot < this.getSlots()) { + return this.fluids[slot]; + } + return null; + } - private void onContentChanged( final int slot ) - { - if( this.handler != null && Platform.isServer() ) - { - this.handler.onFluidInventoryChanged( this, slot ); - } - } + @Override + public int getSlots() { + return this.fluids.length; + } - @Override - public IAEFluidStack getFluidInSlot( final int slot ) - { - if( slot >= 0 && slot < this.getSlots() ) - { - return this.fluids[slot]; - } - return null; - } + @Override + public int getTanks() { + return this.fluids.length; + } - @Override - public int getSlots() - { - return this.fluids.length; - } + @Nonnull + @Override + public FluidStack getFluidInTank(int tank) { + if (tank < 0 || tank >= fluids.length) { + return FluidStack.EMPTY; + } + return fluids[tank] == null ? FluidStack.EMPTY : fluids[tank].getFluidStack(); + } - @Override - public int getTanks() { - return this.fluids.length; - } + @Override + public int getTankCapacity(int tank) { + return Math.min(this.capacity, Integer.MAX_VALUE); + } - @Nonnull - @Override - public FluidStack getFluidInTank(int tank) { - if (tank < 0 || tank >= fluids.length) { - return FluidStack.EMPTY; - } - return fluids[tank] == null ? FluidStack.EMPTY : fluids[tank].getFluidStack(); - } + @Override + public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { + return stack != FluidStack.EMPTY; + } - @Override - public int getTankCapacity(int tank) { - return Math.min( this.capacity, Integer.MAX_VALUE ); - } + public int fill(final int slot, final FluidStack resource, final boolean doFill) { + if (resource.isEmpty() || resource.getAmount() <= 0) { + return 0; + } - @Override - public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { - return stack != FluidStack.EMPTY; - } + final IAEFluidStack fluid = this.fluids[slot]; - public int fill( final int slot, final FluidStack resource, final boolean doFill ) - { - if( resource.isEmpty()|| resource.getAmount() <= 0 ) - { - return 0; - } + if (fluid != null && !fluid.getFluidStack().equals(resource)) { + return 0; + } - final IAEFluidStack fluid = this.fluids[slot]; + int amountToStore = this.capacity; - if( fluid != null && !fluid.getFluidStack().equals( resource ) ) - { - return 0; - } + if (fluid != null) { + amountToStore -= fluid.getStackSize(); + } - int amountToStore = this.capacity; + amountToStore = Math.min(amountToStore, resource.getAmount()); - if( fluid != null ) - { - amountToStore -= fluid.getStackSize(); - } + if (doFill) { + if (fluid == null) { + this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource)); + } else { + fluid.setStackSize(fluid.getStackSize() + amountToStore); + this.onContentChanged(slot); + } + } - amountToStore = Math.min( amountToStore, resource.getAmount() ); + return amountToStore; + } - if( doFill ) - { - if( fluid == null ) - { - this.setFluidInSlot( slot, AEFluidStack.fromFluidStack( resource ) ); - } - else - { - fluid.setStackSize( fluid.getStackSize() + amountToStore ); - this.onContentChanged( slot ); - } - } + @Override + public int fill(FluidStack resource, FluidAction action) { + if (resource == null || resource.isEmpty() || resource.getAmount() <= 0) { + return 0; + } - return amountToStore; - } + // Find a suitable slot + int slot = indexOfFluid(resource); + if (slot == -1) { + slot = indexOfEmptySlot(); + if (slot == -1) { + return 0; + } + } - @Override - public int fill(FluidStack resource, FluidAction action) { - if( resource == null || resource.isEmpty() || resource.getAmount() <= 0 ) - { - return 0; - } + final IAEFluidStack fluid = this.fluids[slot]; - // Find a suitable slot - int slot = indexOfFluid(resource); - if (slot == -1) { - slot = indexOfEmptySlot(); - if (slot == -1) { - return 0; - } - } + int amountToStore = this.capacity; - final IAEFluidStack fluid = this.fluids[slot]; + if (fluid != null) { + amountToStore -= fluid.getStackSize(); + } - int amountToStore = this.capacity; + amountToStore = Math.min(amountToStore, resource.getAmount()); - if( fluid != null ) - { - amountToStore -= fluid.getStackSize(); - } + if (action == FluidAction.EXECUTE) { + if (fluid == null) { + this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource)); + } else { + fluid.setStackSize(fluid.getStackSize() + amountToStore); + this.onContentChanged(slot); + } + } - amountToStore = Math.min( amountToStore, resource.getAmount() ); + return amountToStore; + } - if( action == FluidAction.EXECUTE ) - { - if( fluid == null ) - { - this.setFluidInSlot( slot, AEFluidStack.fromFluidStack( resource ) ); - } - else - { - fluid.setStackSize( fluid.getStackSize() + amountToStore ); - this.onContentChanged( slot ); - } - } + @Override + public FluidStack drain(final FluidStack fluid, final FluidAction action) { + if (fluid == null || fluid.getAmount() <= 0) { + return FluidStack.EMPTY; + } - return amountToStore; - } + final FluidStack resource = fluid.copy(); - @Override - public FluidStack drain( final FluidStack fluid, final FluidAction action ) - { - if( fluid == null || fluid.getAmount() <= 0 ) - { - return FluidStack.EMPTY; - } + FluidStack totalDrained = FluidStack.EMPTY; + for (int slot = 0; slot < this.getSlots(); ++slot) { + FluidStack drain = this.drain(slot, resource, action == FluidAction.EXECUTE); + if (drain != null) { + if (totalDrained.isEmpty()) { + totalDrained = drain; + } else { + totalDrained.setAmount(totalDrained.getAmount() + drain.getAmount()); + } - final FluidStack resource = fluid.copy(); + resource.setAmount(resource.getAmount() - drain.getAmount()); + if (resource.getAmount() <= 0) { + break; + } + } + } + return totalDrained; + } - FluidStack totalDrained = FluidStack.EMPTY; - for( int slot = 0; slot < this.getSlots(); ++slot ) - { - FluidStack drain = this.drain( slot, resource, action == FluidAction.EXECUTE ); - if( drain != null ) - { - if( totalDrained.isEmpty() ) - { - totalDrained = drain; - } - else - { - totalDrained.setAmount(totalDrained.getAmount() + drain.getAmount()); - } + @Override + public FluidStack drain(final int maxDrain, final FluidAction action) { + if (maxDrain == 0) { + return FluidStack.EMPTY; + } - resource.setAmount(resource.getAmount() - drain.getAmount()); - if( resource.getAmount() <= 0 ) - { - break; - } - } - } - return totalDrained; - } + FluidStack totalDrained = FluidStack.EMPTY; + int toDrain = maxDrain; - @Override - public FluidStack drain( final int maxDrain, final FluidAction action ) - { - if( maxDrain == 0 ) - { - return FluidStack.EMPTY; - } + for (int slot = 0; slot < this.getSlots(); ++slot) { + if (totalDrained.isEmpty()) { + totalDrained = this.drain(slot, toDrain, action == FluidAction.EXECUTE); + if (totalDrained.isEmpty()) { + toDrain -= totalDrained.getAmount(); + } + } else { + FluidStack copy = totalDrained.copy(); + copy.setAmount(toDrain); + FluidStack drain = this.drain(slot, copy, action == FluidAction.EXECUTE); + if (drain != null) { + totalDrained.setAmount(totalDrained.getAmount() + drain.getAmount()); + toDrain -= drain.getAmount(); + } + } - FluidStack totalDrained = FluidStack.EMPTY; - int toDrain = maxDrain; + if (toDrain <= 0) { + break; + } + } + return totalDrained; + } - for( int slot = 0; slot < this.getSlots(); ++slot ) - { - if( totalDrained.isEmpty() ) - { - totalDrained = this.drain( slot, toDrain, action == FluidAction.EXECUTE ); - if( totalDrained.isEmpty() ) - { - toDrain -= totalDrained.getAmount(); - } - } - else - { - FluidStack copy = totalDrained.copy(); - copy.setAmount(toDrain); - FluidStack drain = this.drain( slot, copy, action == FluidAction.EXECUTE ); - if( drain != null ) - { - totalDrained.setAmount(totalDrained.getAmount() + drain.getAmount()); - toDrain -= drain.getAmount(); - } - } + private int indexOfFluid(FluidStack resource) { + for (int slot = 0; slot < fluids.length; slot++) { + if (fluids[slot] != null && fluids[slot].getFluidStack().isFluidEqual(resource)) { + return slot; + } + } + return -1; + } - if( toDrain <= 0 ) - { - break; - } - } - return totalDrained; - } + private int indexOfEmptySlot() { + for (int slot = 0; slot < fluids.length; slot++) { + if (fluids[slot] == null) { + return slot; + } + } + return -1; + } - private int indexOfFluid(FluidStack resource) { - for (int slot = 0; slot < fluids.length; slot++) { - if (fluids[slot] != null && fluids[slot].getFluidStack().isFluidEqual(resource)) { - return slot; - } - } - return -1; - } + public FluidStack drain(final int slot, final FluidStack resource, final boolean doDrain) { + final IAEFluidStack fluid = this.fluids[slot]; + if (resource.isEmpty() || fluid == null || !fluid.getFluidStack().equals(resource)) { + return null; + } + return this.drain(slot, resource.getAmount(), doDrain); + } - private int indexOfEmptySlot() { - for (int slot = 0; slot < fluids.length; slot++) { - if (fluids[slot] == null) { - return slot; - } - } - return -1; - } + public FluidStack drain(final int slot, final int maxDrain, boolean doDrain) { + final IAEFluidStack fluid = this.fluids[slot]; + if (fluid == null || maxDrain <= 0) { + return null; + } - public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain ) - { - final IAEFluidStack fluid = this.fluids[slot]; - if( resource.isEmpty() || fluid == null || !fluid.getFluidStack().equals( resource ) ) - { - return null; - } - return this.drain( slot, resource.getAmount(), doDrain ); - } + int drained = maxDrain; + if (fluid.getStackSize() < drained) { + drained = (int) fluid.getStackSize(); + } - public FluidStack drain( final int slot, final int maxDrain, boolean doDrain ) - { - final IAEFluidStack fluid = this.fluids[slot]; - if( fluid == null || maxDrain <= 0 ) - { - return null; - } + FluidStack stack = new FluidStack(fluid.getFluid(), drained); + if (doDrain) { + fluid.setStackSize(fluid.getStackSize() - drained); + if (fluid.getStackSize() <= 0) { + this.fluids[slot] = null; + } + this.onContentChanged(slot); + } + return stack; + } - int drained = maxDrain; - if( fluid.getStackSize() < drained ) - { - drained = (int) fluid.getStackSize(); - } + public void writeToNBT(final CompoundNBT data, final String name) { + final CompoundNBT c = new CompoundNBT(); + this.writeToNBT(c); + data.put(name, c); + } - FluidStack stack = new FluidStack( fluid.getFluid(), drained ); - if( doDrain ) - { - fluid.setStackSize( fluid.getStackSize() - drained ); - if( fluid.getStackSize() <= 0 ) - { - this.fluids[slot] = null; - } - this.onContentChanged( slot ); - } - return stack; - } + private void writeToNBT(final CompoundNBT target) { + for (int x = 0; x < this.fluids.length; x++) { + try { + final CompoundNBT c = new CompoundNBT(); - public void writeToNBT( final CompoundNBT data, final String name ) - { - final CompoundNBT c = new CompoundNBT(); - this.writeToNBT( c ); - data.put( name, c ); - } + if (this.fluids[x] != null) { + this.fluids[x].writeToNBT(c); + } - private void writeToNBT( final CompoundNBT target ) - { - for( int x = 0; x < this.fluids.length; x++ ) - { - try - { - final CompoundNBT c = new CompoundNBT(); + target.put("#" + x, c); + } catch (final Exception ignored) { + } + } + } - if( this.fluids[x] != null ) - { - this.fluids[x].writeToNBT( c ); - } + public void readFromNBT(final CompoundNBT data, final String name) { + final CompoundNBT c = data.getCompound(name); + if (!c.isEmpty()) { + this.readFromNBT(c); + } + } - target.put( "#" + x, c ); - } - catch( final Exception ignored ) - { - } - } - } + private void readFromNBT(final CompoundNBT target) { + for (int x = 0; x < this.fluids.length; x++) { + try { + final CompoundNBT c = target.getCompound("#" + x); - public void readFromNBT( final CompoundNBT data, final String name ) - { - final CompoundNBT c = data.getCompound( name ); - if( !c.isEmpty() ) - { - this.readFromNBT( c ); - } - } - - private void readFromNBT( final CompoundNBT target ) - { - for( int x = 0; x < this.fluids.length; x++ ) - { - try - { - final CompoundNBT c = target.getCompound( "#" + x ); - - if( !c.isEmpty() ) - { - this.fluids[x] = AEFluidStack.fromNBT( c ); - } - } - catch( final Exception e ) - { - AELog.debug( e ); - } - } - } + if (!c.isEmpty()) { + this.fluids[x] = AEFluidStack.fromNBT(c); + } + } catch (final Exception e) { + AELog.debug(e); + } + } + } } diff --git a/src/main/java/appeng/fluids/util/AEFluidStack.java b/src/main/java/appeng/fluids/util/AEFluidStack.java index 7082f4578..8c1d432ce 100644 --- a/src/main/java/appeng/fluids/util/AEFluidStack.java +++ b/src/main/java/appeng/fluids/util/AEFluidStack.java @@ -18,7 +18,6 @@ package appeng.fluids.util; - import javax.annotation.Nonnull; import net.minecraft.fluid.Fluid; @@ -36,261 +35,221 @@ import appeng.fluids.items.FluidDummyItem; import appeng.util.Platform; import appeng.util.item.AEStack; +public final class AEFluidStack extends AEStack implements IAEFluidStack, Comparable { + private static final String NBT_STACKSIZE = "cnt"; + private static final String NBT_REQUESTABLE = "req"; + private static final String NBT_CRAFTABLE = "craft"; + private static final String NBT_FLUIDSTACK = "fs"; -public final class AEFluidStack extends AEStack implements IAEFluidStack, Comparable -{ - private static final String NBT_STACKSIZE = "cnt"; - private static final String NBT_REQUESTABLE = "req"; - private static final String NBT_CRAFTABLE = "craft"; - private static final String NBT_FLUIDSTACK = "fs"; + private final Fluid fluid; + private CompoundNBT tagCompound; - private final Fluid fluid; - private CompoundNBT tagCompound; + private AEFluidStack(final AEFluidStack fluidStack) { + this.fluid = fluidStack.fluid; + this.setStackSize(fluidStack.getStackSize()); - private AEFluidStack( final AEFluidStack fluidStack ) - { - this.fluid = fluidStack.fluid; - this.setStackSize( fluidStack.getStackSize() ); + // priority = is.priority; + this.setCraftable(fluidStack.isCraftable()); + this.setCountRequestable(fluidStack.getCountRequestable()); - // priority = is.priority; - this.setCraftable( fluidStack.isCraftable() ); - this.setCountRequestable( fluidStack.getCountRequestable() ); + if (fluidStack.hasTagCompound()) { + this.tagCompound = fluidStack.tagCompound.copy(); + } + } - if( fluidStack.hasTagCompound() ) - { - this.tagCompound = fluidStack.tagCompound.copy(); - } - } + private AEFluidStack(@Nonnull final FluidStack fluidStack) { + this.fluid = fluidStack.getFluid(); - private AEFluidStack( @Nonnull final FluidStack fluidStack ) - { - this.fluid = fluidStack.getFluid(); + if (this.fluid == null) { + throw new IllegalArgumentException("Fluid is null."); + } - if( this.fluid == null ) - { - throw new IllegalArgumentException( "Fluid is null." ); - } + this.setStackSize(fluidStack.getAmount()); + this.setCraftable(false); + this.setCountRequestable(0); - this.setStackSize( fluidStack.getAmount() ); - this.setCraftable( false ); - this.setCountRequestable( 0 ); + if (fluidStack.getTag() != null) { + this.tagCompound = fluidStack.getTag().copy(); + } + } - if( fluidStack.getTag() != null ) - { - this.tagCompound = fluidStack.getTag().copy(); - } - } + public static AEFluidStack fromFluidStack(final FluidStack input) { + if (input == null) { + return null; + } - public static AEFluidStack fromFluidStack( final FluidStack input ) - { - if( input == null ) - { - return null; - } + return new AEFluidStack(input); + } - return new AEFluidStack( input ); - } + public static IAEFluidStack fromNBT(final CompoundNBT data) { + final FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(data.getCompound(NBT_FLUIDSTACK)); - public static IAEFluidStack fromNBT( final CompoundNBT data ) - { - final FluidStack fluidStack = FluidStack.loadFluidStackFromNBT( data.getCompound( NBT_FLUIDSTACK ) ); + if (fluidStack == null) { + return null; + } - if( fluidStack == null ) - { - return null; - } + final AEFluidStack fluid = AEFluidStack.fromFluidStack(fluidStack); + fluid.setStackSize(data.getLong(NBT_STACKSIZE)); + fluid.setCountRequestable(data.getLong(NBT_REQUESTABLE)); + fluid.setCraftable(data.getBoolean(NBT_CRAFTABLE)); - final AEFluidStack fluid = AEFluidStack.fromFluidStack( fluidStack ); - fluid.setStackSize( data.getLong( NBT_STACKSIZE ) ); - fluid.setCountRequestable( data.getLong( NBT_REQUESTABLE ) ); - fluid.setCraftable( data.getBoolean( NBT_CRAFTABLE ) ); + if (fluid.hasTagCompound()) { + fluid.tagCompound = fluid.tagCompound.copy(); + } - if( fluid.hasTagCompound() ) - { - fluid.tagCompound = fluid.tagCompound.copy(); - } + return fluid; + } - return fluid; - } + @Override + public void add(final IAEFluidStack option) { + if (option == null) { + return; + } + this.incStackSize(option.getStackSize()); + this.setCountRequestable(this.getCountRequestable() + option.getCountRequestable()); + this.setCraftable(this.isCraftable() || option.isCraftable()); + } - @Override - public void add( final IAEFluidStack option ) - { - if( option == null ) - { - return; - } - this.incStackSize( option.getStackSize() ); - this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() ); - this.setCraftable( this.isCraftable() || option.isCraftable() ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + data.getCompound(NBT_FLUIDSTACK).putString("FluidName", this.fluid.getRegistryName().toString()); + data.getCompound(NBT_FLUIDSTACK).putInt("Amount", 0); + if (this.hasTagCompound()) { + data.getCompound(NBT_FLUIDSTACK).put("Tag", this.tagCompound); + } else { + data.getCompound(NBT_FLUIDSTACK).remove("Tag"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - data.getCompound( NBT_FLUIDSTACK ).putString( "FluidName", this.fluid.getRegistryName().toString() ); - data.getCompound( NBT_FLUIDSTACK ).putInt( "Amount", 0 ); - if( this.hasTagCompound() ) - { - data.getCompound( NBT_FLUIDSTACK ).put( "Tag", this.tagCompound ); - } - else - { - data.getCompound( NBT_FLUIDSTACK ).remove( "Tag" ); - } + data.putLong(NBT_STACKSIZE, this.getStackSize()); + data.putLong(NBT_REQUESTABLE, this.getCountRequestable()); + data.putBoolean(NBT_CRAFTABLE, this.isCraftable()); + } - data.putLong( NBT_STACKSIZE, this.getStackSize() ); - data.putLong( NBT_REQUESTABLE, this.getCountRequestable() ); - data.putBoolean( NBT_CRAFTABLE, this.isCraftable() ); - } + @Override + public boolean fuzzyComparison(final IAEFluidStack other, final FuzzyMode mode) { + return this.fluid == other.getFluid(); + } - @Override - public boolean fuzzyComparison( final IAEFluidStack other, final FuzzyMode mode ) - { - return this.fluid == other.getFluid(); - } + @Override + public IAEFluidStack copy() { + return new AEFluidStack(this); + } - @Override - public IAEFluidStack copy() - { - return new AEFluidStack( this ); - } + @Override + public IAEFluidStack empty() { + final IAEFluidStack dup = this.copy(); + dup.reset(); + return dup; + } - @Override - public IAEFluidStack empty() - { - final IAEFluidStack dup = this.copy(); - dup.reset(); - return dup; - } + @Override + public boolean isItem() { + return false; + } - @Override - public boolean isItem() - { - return false; - } + @Override + public boolean isFluid() { + return true; + } - @Override - public boolean isFluid() - { - return true; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public int compareTo(final AEFluidStack other) { + if (this.fluid != other.fluid) { + return this.fluid.getRegistryName().compareTo(other.fluid.getRegistryName()); + } - @Override - public int compareTo( final AEFluidStack other ) - { - if( this.fluid != other.fluid ) - { - return this.fluid.getRegistryName().compareTo( other.fluid.getRegistryName() ); - } + if (Platform.itemComparisons().isNbtTagEqual(this.tagCompound, other.tagCompound)) { + return 0; + } - if( Platform.itemComparisons().isNbtTagEqual( this.tagCompound, other.tagCompound ) ) - { - return 0; - } + return this.tagCompound.hashCode() - other.tagCompound.hashCode(); + } - return this.tagCompound.hashCode() - other.tagCompound.hashCode(); - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.fluid == null) ? 0 : this.fluid.hashCode()); + result = prime * result + ((this.tagCompound == null) ? 0 : this.tagCompound.hashCode()); - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( this.fluid == null ) ? 0 : this.fluid.hashCode() ); - result = prime * result + ( ( this.tagCompound == null ) ? 0 : this.tagCompound.hashCode() ); + return result; + } - return result; - } + @Override + public boolean equals(final Object other) { + if (other instanceof AEFluidStack) { + final AEFluidStack is = (AEFluidStack) other; + return is.fluid == this.fluid && Platform.itemComparisons().isNbtTagEqual(this.tagCompound, is.tagCompound); + } else if (other instanceof FluidStack) { + final FluidStack is = (FluidStack) other; + return is.getFluid() == this.fluid + && Platform.itemComparisons().isNbtTagEqual(this.tagCompound, is.getTag()); + } + return false; + } - @Override - public boolean equals( final Object other ) - { - if( other instanceof AEFluidStack ) - { - final AEFluidStack is = (AEFluidStack) other; - return is.fluid == this.fluid && Platform.itemComparisons().isNbtTagEqual( this.tagCompound, is.tagCompound ); - } - else if( other instanceof FluidStack ) - { - final FluidStack is = (FluidStack) other; - return is.getFluid() == this.fluid && Platform.itemComparisons().isNbtTagEqual( this.tagCompound, is.getTag() ); - } - return false; - } + @Override + public String toString() { + return this.getStackSize() + "x" + this.getFluidStack().getFluid().getRegistryName() + " " + this.tagCompound; + } - @Override - public String toString() - { - return this.getStackSize() + "x" + this.getFluidStack().getFluid().getRegistryName() + " " + this.tagCompound; - } + @Override + public boolean hasTagCompound() { + return this.tagCompound != null; + } - @Override - public boolean hasTagCompound() - { - return this.tagCompound != null; - } + @Override + public FluidStack getFluidStack() { + final int amount = (int) Math.min(Integer.MAX_VALUE, this.getStackSize()); + final FluidStack is = new FluidStack(this.fluid, amount, this.tagCompound); - @Override - public FluidStack getFluidStack() - { - final int amount = (int) Math.min( Integer.MAX_VALUE, this.getStackSize() ); - final FluidStack is = new FluidStack( this.fluid, amount, this.tagCompound ); + return is; + } - return is; - } + @Override + public Fluid getFluid() { + return this.fluid; + } - @Override - public Fluid getFluid() - { - return this.fluid; - } + @Override + public ItemStack asItemStackRepresentation() { + ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).orElse(ItemStack.EMPTY); + if (!is.isEmpty()) { + FluidDummyItem item = (FluidDummyItem) is.getItem(); + item.setFluidStack(is, this.getFluidStack()); + return is; + } + return ItemStack.EMPTY; + } - @Override - public ItemStack asItemStackRepresentation() - { - ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - if( !is.isEmpty() ) - { - FluidDummyItem item = (FluidDummyItem) is.getItem(); - item.setFluidStack( is, this.getFluidStack() ); - return is; - } - return ItemStack.EMPTY; - } + public static IAEFluidStack fromPacket(final PacketBuffer buffer) { + final boolean isCraftable = buffer.readBoolean(); + final FluidStack fluidStack = buffer.readFluidStack(); - public static IAEFluidStack fromPacket( final PacketBuffer buffer ) - { - final boolean isCraftable = buffer.readBoolean(); - final FluidStack fluidStack = buffer.readFluidStack(); + final long stackSize = buffer.readVarLong(); + final long countRequestable = buffer.readVarLong(); - final long stackSize = buffer.readVarLong(); - final long countRequestable = buffer.readVarLong(); + if (fluidStack == null) { + return null; + } - if( fluidStack == null ) - { - return null; - } + final AEFluidStack fluid = AEFluidStack.fromFluidStack(fluidStack); + fluid.setStackSize(stackSize); + fluid.setCountRequestable(countRequestable); + fluid.setCraftable(isCraftable); + return fluid; + } - final AEFluidStack fluid = AEFluidStack.fromFluidStack( fluidStack ); - fluid.setStackSize( stackSize ); - fluid.setCountRequestable( countRequestable ); - fluid.setCraftable( isCraftable ); - return fluid; - } - - @Override - public void writeToPacket( final PacketBuffer buffer ) - { - buffer.writeBoolean( this.isCraftable() ); - buffer.writeFluidStack( this.getFluidStack() ); - buffer.writeVarLong( this.getStackSize() ); - buffer.writeVarLong( this.getCountRequestable() ); - } + @Override + public void writeToPacket(final PacketBuffer buffer) { + buffer.writeBoolean(this.isCraftable()); + buffer.writeFluidStack(this.getFluidStack()); + buffer.writeVarLong(this.getStackSize()); + buffer.writeVarLong(this.getCountRequestable()); + } } diff --git a/src/main/java/appeng/fluids/util/AEFluidTank.java b/src/main/java/appeng/fluids/util/AEFluidTank.java index 6c3b32ccd..ce3e8370a 100644 --- a/src/main/java/appeng/fluids/util/AEFluidTank.java +++ b/src/main/java/appeng/fluids/util/AEFluidTank.java @@ -18,60 +18,50 @@ package appeng.fluids.util; +import net.minecraftforge.fluids.capability.templates.FluidTank; import appeng.api.storage.data.IAEFluidStack; import appeng.util.Platform; -import net.minecraftforge.fluids.capability.templates.FluidTank; +public class AEFluidTank extends FluidTank implements IAEFluidTank { + private final IAEFluidInventory host; -public class AEFluidTank extends FluidTank implements IAEFluidTank -{ - private final IAEFluidInventory host; - - public AEFluidTank( IAEFluidInventory host, int capacity ) - { - super( capacity ); - this.host = host; + public AEFluidTank(IAEFluidInventory host, int capacity) { + super(capacity); + this.host = host; // FIXME if( host instanceof TileEntity ) // FIXME { // FIXME this.setTileEntity( (TileEntity) host ); // FIXME } - } + } - @Override - protected void onContentsChanged() - { - if( this.host != null && Platform.isServer() ) - { - this.host.onFluidInventoryChanged( this, 0 ); - } - super.onContentsChanged(); - } + @Override + protected void onContentsChanged() { + if (this.host != null && Platform.isServer()) { + this.host.onFluidInventoryChanged(this, 0); + } + super.onContentsChanged(); + } - @Override - public void setFluidInSlot( int slot, IAEFluidStack fluid ) - { - if( slot == 0 ) - { - this.setFluid( fluid == null ? null : fluid.getFluidStack() ); - this.onContentsChanged(); - } - } + @Override + public void setFluidInSlot(int slot, IAEFluidStack fluid) { + if (slot == 0) { + this.setFluid(fluid == null ? null : fluid.getFluidStack()); + this.onContentsChanged(); + } + } - @Override - public IAEFluidStack getFluidInSlot( int slot ) - { - if( slot == 0 ) - { - return AEFluidStack.fromFluidStack( this.getFluid() ); - } - return null; - } + @Override + public IAEFluidStack getFluidInSlot(int slot) { + if (slot == 0) { + return AEFluidStack.fromFluidStack(this.getFluid()); + } + return null; + } - @Override - public int getSlots() - { - return 1; - } + @Override + public int getSlots() { + return 1; + } } diff --git a/src/main/java/appeng/fluids/util/FluidList.java b/src/main/java/appeng/fluids/util/FluidList.java index bc3ffaf3e..9a459717d 100644 --- a/src/main/java/appeng/fluids/util/FluidList.java +++ b/src/main/java/appeng/fluids/util/FluidList.java @@ -18,7 +18,6 @@ package appeng.fluids.util; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -29,173 +28,147 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IItemList; +public final class FluidList implements IItemList { -public final class FluidList implements IItemList -{ + private final Map records = new HashMap<>(); - private final Map records = new HashMap<>(); + @Override + public void add(final IAEFluidStack option) { + if (option == null) { + return; + } - @Override - public void add( final IAEFluidStack option ) - { - if( option == null ) - { - return; - } + final IAEFluidStack st = this.getFluidRecord(option); - final IAEFluidStack st = this.getFluidRecord( option ); + if (st != null) { + st.add(option); + return; + } - if( st != null ) - { - st.add( option ); - return; - } + final IAEFluidStack opt = option.copy(); - final IAEFluidStack opt = option.copy(); + this.putFluidRecord(opt); + } - this.putFluidRecord( opt ); - } + @Override + public IAEFluidStack findPrecise(final IAEFluidStack fluidStack) { + if (fluidStack == null) { + return null; + } - @Override - public IAEFluidStack findPrecise( final IAEFluidStack fluidStack ) - { - if( fluidStack == null ) - { - return null; - } + return this.getFluidRecord(fluidStack); + } - return this.getFluidRecord( fluidStack ); - } + @Override + public Collection findFuzzy(final IAEFluidStack filter, final FuzzyMode fuzzy) { + if (filter == null) { + return Collections.emptyList(); + } - @Override - public Collection findFuzzy( final IAEFluidStack filter, final FuzzyMode fuzzy ) - { - if( filter == null ) - { - return Collections.emptyList(); - } + return Collections.singletonList(this.findPrecise(filter)); + } - return Collections.singletonList( this.findPrecise( filter ) ); - } + @Override + public boolean isEmpty() { + return !this.iterator().hasNext(); + } - @Override - public boolean isEmpty() - { - return !this.iterator().hasNext(); - } + @Override + public void addStorage(final IAEFluidStack option) { + if (option == null) { + return; + } - @Override - public void addStorage( final IAEFluidStack option ) - { - if( option == null ) - { - return; - } + final IAEFluidStack st = this.getFluidRecord(option); - final IAEFluidStack st = this.getFluidRecord( option ); + if (st != null) { + st.incStackSize(option.getStackSize()); + return; + } - if( st != null ) - { - st.incStackSize( option.getStackSize() ); - return; - } + final IAEFluidStack opt = option.copy(); - final IAEFluidStack opt = option.copy(); + this.putFluidRecord(opt); + } - this.putFluidRecord( opt ); - } + /* + * public synchronized void clean() { Iterator i = iterator(); while + * (i.hasNext()) { StackType AEI = i.next(); if ( !AEI.isMeaningful() ) + * i.remove(); } } + */ - /* - * public synchronized void clean() { Iterator i = iterator(); while (i.hasNext()) { StackType AEI = - * i.next(); if ( !AEI.isMeaningful() ) i.remove(); } } - */ + @Override + public void addCrafting(final IAEFluidStack option) { + if (option == null) { + return; + } - @Override - public void addCrafting( final IAEFluidStack option ) - { - if( option == null ) - { - return; - } + final IAEFluidStack st = this.getFluidRecord(option); - final IAEFluidStack st = this.getFluidRecord( option ); + if (st != null) { + st.setCraftable(true); + return; + } - if( st != null ) - { - st.setCraftable( true ); - return; - } + final IAEFluidStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(true); - final IAEFluidStack opt = option.copy(); - opt.setStackSize( 0 ); - opt.setCraftable( true ); + this.putFluidRecord(opt); + } - this.putFluidRecord( opt ); - } + @Override + public void addRequestable(final IAEFluidStack option) { + if (option == null) { + return; + } - @Override - public void addRequestable( final IAEFluidStack option ) - { - if( option == null ) - { - return; - } + final IAEFluidStack st = this.getFluidRecord(option); - final IAEFluidStack st = this.getFluidRecord( option ); + if (st != null) { + st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable()); + return; + } - if( st != null ) - { - st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() ); - return; - } + final IAEFluidStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(false); + opt.setCountRequestable(option.getCountRequestable()); - final IAEFluidStack opt = option.copy(); - opt.setStackSize( 0 ); - opt.setCraftable( false ); - opt.setCountRequestable( option.getCountRequestable() ); + this.putFluidRecord(opt); + } - this.putFluidRecord( opt ); - } + @Override + public IAEFluidStack getFirstItem() { + for (final IAEFluidStack stackType : this) { + return stackType; + } - @Override - public IAEFluidStack getFirstItem() - { - for( final IAEFluidStack stackType : this ) - { - return stackType; - } + return null; + } - return null; - } + @Override + public int size() { + return this.records.values().size(); + } - @Override - public int size() - { - return this.records.values().size(); - } + @Override + public Iterator iterator() { + return new MeaningfulFluidIterator<>(this.records.values().iterator()); + } - @Override - public Iterator iterator() - { - return new MeaningfulFluidIterator<>( this.records.values().iterator() ); - } + @Override + public void resetStatus() { + for (final IAEFluidStack i : this) { + i.reset(); + } + } - @Override - public void resetStatus() - { - for( final IAEFluidStack i : this ) - { - i.reset(); - } - } + private IAEFluidStack getFluidRecord(final IAEFluidStack fluid) { + return this.records.get(fluid); + } - private IAEFluidStack getFluidRecord( final IAEFluidStack fluid ) - { - return this.records.get( fluid ); - } - - private IAEFluidStack putFluidRecord( final IAEFluidStack fluid ) - { - return this.records.put( fluid, fluid ); - } + private IAEFluidStack putFluidRecord(final IAEFluidStack fluid) { + return this.records.put(fluid, fluid); + } } diff --git a/src/main/java/appeng/fluids/util/FluidSorters.java b/src/main/java/appeng/fluids/util/FluidSorters.java index a48386168..239226266 100644 --- a/src/main/java/appeng/fluids/util/FluidSorters.java +++ b/src/main/java/appeng/fluids/util/FluidSorters.java @@ -18,77 +18,68 @@ package appeng.fluids.util; - import java.util.Comparator; import appeng.api.config.SortDir; import appeng.api.storage.data.IAEFluidStack; import appeng.util.Platform; - /** * @author BrockWS * @version rv6 - 22/05/2018 * @since rv6 22/05/2018 */ -public class FluidSorters -{ - private static SortDir Direction = SortDir.ASCENDING; +public class FluidSorters { + private static SortDir Direction = SortDir.ASCENDING; - public static final Comparator CONFIG_BASED_SORT_BY_NAME = ( o1, o2 ) -> - { - // FIXME: Calling .getString() to compare two untranslated strings is a problem, we need to investigate how to do this better - if( getDirection() == SortDir.ASCENDING ) - { - return Platform.getFluidDisplayName( o1 ).getString().compareToIgnoreCase( Platform.getFluidDisplayName( o2 ).getString() ); - } - return Platform.getFluidDisplayName( o2 ).getString().compareToIgnoreCase( Platform.getFluidDisplayName( o1 ).getString() ); - }; + public static final Comparator CONFIG_BASED_SORT_BY_NAME = (o1, o2) -> { + // FIXME: Calling .getString() to compare two untranslated strings is a problem, + // we need to investigate how to do this better + if (getDirection() == SortDir.ASCENDING) { + return Platform.getFluidDisplayName(o1).getString() + .compareToIgnoreCase(Platform.getFluidDisplayName(o2).getString()); + } + return Platform.getFluidDisplayName(o2).getString() + .compareToIgnoreCase(Platform.getFluidDisplayName(o1).getString()); + }; - public static final Comparator CONFIG_BASED_SORT_BY_MOD = new Comparator() - { + public static final Comparator CONFIG_BASED_SORT_BY_MOD = new Comparator() { - @Override - public int compare( final IAEFluidStack o1, final IAEFluidStack o2 ) - { - final AEFluidStack op1 = (AEFluidStack) o1; - final AEFluidStack op2 = (AEFluidStack) o2; + @Override + public int compare(final IAEFluidStack o1, final IAEFluidStack o2) { + final AEFluidStack op1 = (AEFluidStack) o1; + final AEFluidStack op2 = (AEFluidStack) o2; - if( getDirection() == SortDir.ASCENDING ) - { - return this.secondarySort( Platform.getModId( op1 ).compareToIgnoreCase( Platform.getModId( op2 ) ), o2, o1 ); - } - return this.secondarySort( Platform.getModId( op2 ).compareToIgnoreCase( Platform.getModId( op1 ) ), o1, o2 ); - } + if (getDirection() == SortDir.ASCENDING) { + return this.secondarySort(Platform.getModId(op1).compareToIgnoreCase(Platform.getModId(op2)), o2, o1); + } + return this.secondarySort(Platform.getModId(op2).compareToIgnoreCase(Platform.getModId(op1)), o1, o2); + } - private int secondarySort( final int compareToIgnoreCase, final IAEFluidStack o1, final IAEFluidStack o2 ) - { - if( compareToIgnoreCase == 0 ) - { - // FIXME: Calling .getString() to compare two untranslated strings is a problem, we need to investigate how to do this better - return Platform.getFluidDisplayName( o2 ).getString().compareToIgnoreCase( Platform.getFluidDisplayName( o1 ).getString() ); - } + private int secondarySort(final int compareToIgnoreCase, final IAEFluidStack o1, final IAEFluidStack o2) { + if (compareToIgnoreCase == 0) { + // FIXME: Calling .getString() to compare two untranslated strings is a problem, + // we need to investigate how to do this better + return Platform.getFluidDisplayName(o2).getString() + .compareToIgnoreCase(Platform.getFluidDisplayName(o1).getString()); + } - return compareToIgnoreCase; - } - }; + return compareToIgnoreCase; + } + }; - public static final Comparator CONFIG_BASED_SORT_BY_SIZE = ( o1, o2 ) -> - { - if( getDirection() == SortDir.ASCENDING ) - { - return Long.compare( o2.getStackSize(), o1.getStackSize() ); - } - return Long.compare( o1.getStackSize(), o2.getStackSize() ); - }; + public static final Comparator CONFIG_BASED_SORT_BY_SIZE = (o1, o2) -> { + if (getDirection() == SortDir.ASCENDING) { + return Long.compare(o2.getStackSize(), o1.getStackSize()); + } + return Long.compare(o1.getStackSize(), o2.getStackSize()); + }; - private static SortDir getDirection() - { - return Direction; - } + private static SortDir getDirection() { + return Direction; + } - public static void setDirection( final SortDir direction ) - { - Direction = direction; - } + public static void setDirection(final SortDir direction) { + Direction = direction; + } } diff --git a/src/main/java/appeng/fluids/util/IAEFluidInventory.java b/src/main/java/appeng/fluids/util/IAEFluidInventory.java index 08c9c7d1a..b2ed7191d 100644 --- a/src/main/java/appeng/fluids/util/IAEFluidInventory.java +++ b/src/main/java/appeng/fluids/util/IAEFluidInventory.java @@ -18,9 +18,7 @@ package appeng.fluids.util; - @FunctionalInterface -public interface IAEFluidInventory -{ - void onFluidInventoryChanged( final IAEFluidTank inv, final int slot ); +public interface IAEFluidInventory { + void onFluidInventoryChanged(final IAEFluidTank inv, final int slot); } diff --git a/src/main/java/appeng/fluids/util/IAEFluidTank.java b/src/main/java/appeng/fluids/util/IAEFluidTank.java index 8469d55c5..3eddab5b5 100644 --- a/src/main/java/appeng/fluids/util/IAEFluidTank.java +++ b/src/main/java/appeng/fluids/util/IAEFluidTank.java @@ -1,18 +1,15 @@ package appeng.fluids.util; - import net.minecraftforge.fluids.capability.IFluidHandler; import appeng.api.storage.data.IAEFluidStack; +public interface IAEFluidTank extends IFluidHandler { + void setFluidInSlot(final int slot, final IAEFluidStack fluid); -public interface IAEFluidTank extends IFluidHandler -{ - void setFluidInSlot( final int slot, final IAEFluidStack fluid ); + IAEFluidStack getFluidInSlot(final int slot); - IAEFluidStack getFluidInSlot( final int slot ); - - int getSlots(); + int getSlots(); } diff --git a/src/main/java/appeng/fluids/util/MeaningfulFluidIterator.java b/src/main/java/appeng/fluids/util/MeaningfulFluidIterator.java index b92e7f6bc..f9309cbce 100644 --- a/src/main/java/appeng/fluids/util/MeaningfulFluidIterator.java +++ b/src/main/java/appeng/fluids/util/MeaningfulFluidIterator.java @@ -18,58 +18,46 @@ package appeng.fluids.util; - import java.util.Iterator; import java.util.NoSuchElementException; import appeng.api.storage.data.IAEStack; +public class MeaningfulFluidIterator implements Iterator { -public class MeaningfulFluidIterator implements Iterator -{ + private final Iterator parent; + private T next; - private final Iterator parent; - private T next; + public MeaningfulFluidIterator(final Iterator iterator) { + this.parent = iterator; + } - public MeaningfulFluidIterator( final Iterator iterator ) - { - this.parent = iterator; - } + @Override + public boolean hasNext() { + while (this.parent.hasNext()) { + this.next = this.parent.next(); + if (this.next.isMeaningful()) { + return true; + } else { + this.parent.remove(); // self cleaning :3 + } + } - @Override - public boolean hasNext() - { - while( this.parent.hasNext() ) - { - this.next = this.parent.next(); - if( this.next.isMeaningful() ) - { - return true; - } - else - { - this.parent.remove(); // self cleaning :3 - } - } + this.next = null; + return false; + } - this.next = null; - return false; - } + @Override + public T next() { + if (this.next == null) { + throw new NoSuchElementException(); + } - @Override - public T next() - { - if( this.next == null ) - { - throw new NoSuchElementException(); - } + return this.next; + } - return this.next; - } - - @Override - public void remove() - { - this.parent.remove(); - } + @Override + public void remove() { + this.parent.remove(); + } } diff --git a/src/main/java/appeng/forge/data/AE2DataGenerators.java b/src/main/java/appeng/forge/data/AE2DataGenerators.java index 8deae5d63..2678b34ab 100644 --- a/src/main/java/appeng/forge/data/AE2DataGenerators.java +++ b/src/main/java/appeng/forge/data/AE2DataGenerators.java @@ -1,32 +1,28 @@ package appeng.forge.data; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; import appeng.core.AppEng; import appeng.forge.data.providers.loot.BlockDropProvider; import appeng.forge.data.providers.recipes.QuartzToolRecipes; import appeng.forge.data.providers.recipes.SlabStairRecipes; import appeng.forge.data.providers.recipes.SpecialRecipes; -import net.minecraft.data.DataGenerator; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +@Mod.EventBusSubscriber(modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +public class AE2DataGenerators { -@Mod.EventBusSubscriber( modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD ) -public class AE2DataGenerators -{ - - @SubscribeEvent - public static void onGatherData( GatherDataEvent dataEvent ) - { - DataGenerator generator = dataEvent.getGenerator(); - if( dataEvent.includeServer() ) - { - generator.addProvider( new BlockDropProvider( dataEvent ) ); - generator.addProvider( new SlabStairRecipes( generator ) ); - generator.addProvider( new QuartzToolRecipes( generator ) ); - generator.addProvider( new SpecialRecipes( generator ) ); - } - } + @SubscribeEvent + public static void onGatherData(GatherDataEvent dataEvent) { + DataGenerator generator = dataEvent.getGenerator(); + if (dataEvent.includeServer()) { + generator.addProvider(new BlockDropProvider(dataEvent)); + generator.addProvider(new SlabStairRecipes(generator)); + generator.addProvider(new QuartzToolRecipes(generator)); + generator.addProvider(new SpecialRecipes(generator)); + } + } } diff --git a/src/main/java/appeng/forge/data/providers/IAE2DataProvider.java b/src/main/java/appeng/forge/data/providers/IAE2DataProvider.java index 6ba3e0350..acd0bfb3e 100644 --- a/src/main/java/appeng/forge/data/providers/IAE2DataProvider.java +++ b/src/main/java/appeng/forge/data/providers/IAE2DataProvider.java @@ -1,12 +1,11 @@ package appeng.forge.data.providers; +import java.nio.file.Path; + +import javax.annotation.Nonnull; -import appeng.api.AEApi; -import appeng.api.definitions.IBlocks; -import appeng.api.definitions.IItems; -import appeng.api.definitions.IMaterials; -import appeng.core.AppEng; import com.google.gson.JsonElement; + import net.minecraft.data.IDataProvider; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootParameterSet; @@ -14,13 +13,14 @@ import net.minecraft.world.storage.loot.LootParameterSets; import net.minecraft.world.storage.loot.LootTable; import net.minecraft.world.storage.loot.LootTableManager; -import javax.annotation.Nonnull; -import java.nio.file.Path; +import appeng.api.AEApi; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IMaterials; +import appeng.core.AppEng; - -public interface IAE2DataProvider extends IDataProvider -{ - IBlocks BLOCKS = AEApi.instance().definitions().blocks(); - IItems ITEMS = AEApi.instance().definitions().items(); - IMaterials MATERIALS = AEApi.instance().definitions().materials(); +public interface IAE2DataProvider extends IDataProvider { + IBlocks BLOCKS = AEApi.instance().definitions().blocks(); + IItems ITEMS = AEApi.instance().definitions().items(); + IMaterials MATERIALS = AEApi.instance().definitions().materials(); } diff --git a/src/main/java/appeng/forge/data/providers/loot/BlockDropProvider.java b/src/main/java/appeng/forge/data/providers/loot/BlockDropProvider.java index aa013fb38..41da17154 100644 --- a/src/main/java/appeng/forge/data/providers/loot/BlockDropProvider.java +++ b/src/main/java/appeng/forge/data/providers/loot/BlockDropProvider.java @@ -1,12 +1,17 @@ package appeng.forge.data.providers.loot; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Map; +import java.util.function.Function; + +import javax.annotation.Nonnull; -import appeng.core.AppEng; -import appeng.forge.data.providers.IAE2DataProvider; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; + import net.minecraft.block.Block; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; @@ -20,98 +25,71 @@ import net.minecraft.world.storage.loot.functions.SetCount; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.ForgeRegistries; -import javax.annotation.Nonnull; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Map; -import java.util.function.Function; +import appeng.core.AppEng; +import appeng.forge.data.providers.IAE2DataProvider; +public class BlockDropProvider extends BlockLootTables implements IAE2DataProvider { + private Map> overrides = ImmutableMap.>builder() + .put(BLOCKS.matrixFrame().block(), $ -> LootTable.builder()) + .put(BLOCKS.quartzOre().block(), + b -> droppingWithSilkTouch(BLOCKS.quartzOre().block(), + withExplosionDecay(BLOCKS.quartzOre().block(), + ItemLootEntry.builder(MATERIALS.certusQuartzCrystal().item()) + .acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F))) + .acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE))))) + .put(BLOCKS.quartzOreCharged().block(), + b -> droppingWithSilkTouch(BLOCKS.quartzOreCharged().block(), + withExplosionDecay(BLOCKS.quartzOreCharged().block(), + ItemLootEntry.builder(MATERIALS.certusQuartzCrystalCharged().item()) + .acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F))) + .acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE))))) + .build(); -public class BlockDropProvider extends BlockLootTables implements IAE2DataProvider -{ - private Map> overrides = ImmutableMap.>builder() - .put( BLOCKS.matrixFrame().block(), $ -> LootTable.builder() ) - .put( BLOCKS.quartzOre().block(), b -> - droppingWithSilkTouch(BLOCKS.quartzOre().block(), - withExplosionDecay( - BLOCKS.quartzOre().block(), - ItemLootEntry.builder(MATERIALS.certusQuartzCrystal().item()) - .acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F))) - .acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE)) - ) - ) - ) - .put( BLOCKS.quartzOreCharged().block(), b -> - droppingWithSilkTouch(BLOCKS.quartzOreCharged().block(), - withExplosionDecay( - BLOCKS.quartzOreCharged().block(), - ItemLootEntry.builder(MATERIALS.certusQuartzCrystalCharged().item()) - .acceptFunction(SetCount.builder(RandomValueRange.of(1.0F, 2.0F))) - .acceptFunction(ApplyBonus.uniformBonusCount(Enchantments.FORTUNE)) - ) - ) - ) - .build(); + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private final Path outputFolder; - private final Path outputFolder; + public BlockDropProvider(GatherDataEvent dataEvent) { + outputFolder = dataEvent.getGenerator().getOutputFolder(); + } - public BlockDropProvider( GatherDataEvent dataEvent ) - { - outputFolder = dataEvent.getGenerator().getOutputFolder(); - } + @Override + public void act(@Nonnull DirectoryCache cache) throws IOException { + for (Map.Entry entry : ForgeRegistries.BLOCKS.getEntries()) { + LootTable.Builder builder; + if (entry.getKey().getNamespace().equals(AppEng.MOD_ID)) { + builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue()); - @Override - public void act( @Nonnull DirectoryCache cache ) throws IOException - { - for( Map.Entry entry : ForgeRegistries.BLOCKS.getEntries() ) - { - LootTable.Builder builder; - if( entry.getKey().getNamespace().equals( AppEng.MOD_ID ) ) - { - builder = overrides.getOrDefault( entry.getValue(), this::defaultBuilder ) - .apply( entry.getValue() ); + IDataProvider.save(GSON, cache, toJson(builder), getPath(outputFolder, entry.getKey())); + } + } + } - IDataProvider.save( GSON, cache, toJson( builder ), getPath( outputFolder, entry.getKey() ) ); - } - } - } + private LootTable.Builder defaultBuilder(Block block) { + LootEntry.Builder entry = ItemLootEntry.builder(block); + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) + .acceptCondition(SurvivesExplosion.builder()); - private LootTable.Builder defaultBuilder( Block block ) - { - LootEntry.Builder entry = ItemLootEntry.builder( block ); - LootPool.Builder pool = LootPool.builder() - .name( "main" ) - .rolls( ConstantRange.of( 1 ) ) - .addEntry( entry ) - .acceptCondition( SurvivesExplosion.builder() ); + return LootTable.builder().addLootPool(pool); + } - return LootTable.builder() - .addLootPool( pool ); - } + private Path getPath(Path root, ResourceLocation id) { + return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json"); + } - private Path getPath( Path root, ResourceLocation id ) - { - return root.resolve( "data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json" ); - } + public JsonElement toJson(LootTable.Builder builder) { + return LootTableManager.toJson(finishBuilding(builder)); + } - public JsonElement toJson( LootTable.Builder builder ) - { - return LootTableManager.toJson( finishBuilding( builder ) ); - } + @Nonnull + public LootTable finishBuilding(LootTable.Builder builder) { + return builder.setParameterSet(LootParameterSets.BLOCK).build(); + } - @Nonnull - public LootTable finishBuilding( LootTable.Builder builder ) - { - return builder.setParameterSet( LootParameterSets.BLOCK ).build(); - } - - @Nonnull - @Override - public String getName() - { - return AppEng.MOD_NAME + " Block Drops"; - } + @Nonnull + @Override + public String getName() { + return AppEng.MOD_NAME + " Block Drops"; + } } diff --git a/src/main/java/appeng/forge/data/providers/recipes/QuartzToolRecipes.java b/src/main/java/appeng/forge/data/providers/recipes/QuartzToolRecipes.java index c6e978ab8..06ed50adb 100644 --- a/src/main/java/appeng/forge/data/providers/recipes/QuartzToolRecipes.java +++ b/src/main/java/appeng/forge/data/providers/recipes/QuartzToolRecipes.java @@ -1,15 +1,12 @@ package appeng.forge.data.providers.recipes; +import java.util.Map; +import java.util.function.Consumer; + +import javax.annotation.Nonnull; -import appeng.api.definitions.IItemDefinition; -import appeng.core.AppEng; -import appeng.forge.data.providers.IAE2DataProvider; -import appeng.recipes.conditions.FeaturesEnabled; import com.google.common.collect.ImmutableMap; -import it.unimi.dsi.fastutil.chars.Char2ObjectArrayMap; -import it.unimi.dsi.fastutil.chars.Char2ObjectMap; -import it.unimi.dsi.fastutil.chars.CharOpenHashSet; -import it.unimi.dsi.fastutil.chars.CharSet; + import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; @@ -19,119 +16,70 @@ import net.minecraft.tags.Tag; import net.minecraftforge.common.Tags; import net.minecraftforge.common.crafting.ConditionalRecipe; -import javax.annotation.Nonnull; -import java.util.Map; -import java.util.function.Consumer; +import it.unimi.dsi.fastutil.chars.Char2ObjectArrayMap; +import it.unimi.dsi.fastutil.chars.Char2ObjectMap; +import it.unimi.dsi.fastutil.chars.CharOpenHashSet; +import it.unimi.dsi.fastutil.chars.CharSet; +import appeng.api.definitions.IItemDefinition; +import appeng.core.AppEng; +import appeng.forge.data.providers.IAE2DataProvider; +import appeng.recipes.conditions.FeaturesEnabled; -public class QuartzToolRecipes extends RecipeProvider implements IAE2DataProvider -{ +public class QuartzToolRecipes extends RecipeProvider implements IAE2DataProvider { - private Map, IItemDefinition[]> items = ImmutableMap.of( - Tags.Items.GEMS_QUARTZ, - new IItemDefinition[] { - ITEMS.netherQuartzAxe(), - ITEMS.netherQuartzHoe(), - ITEMS.netherQuartzShovel(), - ITEMS.netherQuartzPick(), - ITEMS.netherQuartzSword(), - ITEMS.netherQuartzWrench(), - ITEMS.netherQuartzKnife() - } - // FIXME certus quartz - ); + private Map, IItemDefinition[]> items = ImmutableMap.of(Tags.Items.GEMS_QUARTZ, + new IItemDefinition[] { ITEMS.netherQuartzAxe(), ITEMS.netherQuartzHoe(), ITEMS.netherQuartzShovel(), + ITEMS.netherQuartzPick(), ITEMS.netherQuartzSword(), ITEMS.netherQuartzWrench(), + ITEMS.netherQuartzKnife() } + // FIXME certus quartz + ); - private String[][] patterns = { - { - "XX ", - "X/ ", - " / " - }, - { - "XX ", - " / ", - " / " - }, - { - " X ", - " / ", - " / " - }, - { - "XXX", - " / ", - " / " - }, - { - " X ", - " X ", - " / " - }, - { - "X X", - " X ", - "X X" - }, - { - " /", - "I/ ", - "XX " - } - }; + private String[][] patterns = { { "XX ", "X/ ", " / " }, { "XX ", " / ", " / " }, { " X ", " / ", " / " }, + { "XXX", " / ", " / " }, { " X ", " X ", " / " }, { "X X", " X ", "X X" }, { " /", "I/ ", "XX " } }; - private Char2ObjectMap> keys = new Char2ObjectArrayMap<>( - new char[] { 'I', '/' }, - new Tag[] { Tags.Items.INGOTS_IRON, Tags.Items.RODS_WOODEN } - ); + private Char2ObjectMap> keys = new Char2ObjectArrayMap<>(new char[] { 'I', '/' }, + new Tag[] { Tags.Items.INGOTS_IRON, Tags.Items.RODS_WOODEN }); - public QuartzToolRecipes( DataGenerator generatorIn ) - { - super( generatorIn ); - } + public QuartzToolRecipes(DataGenerator generatorIn) { + super(generatorIn); + } - @Override - protected void registerRecipes( @Nonnull Consumer consumer ) - { - for( Map.Entry, IItemDefinition[]> entry : items.entrySet() ) - { - Tag tag = entry.getKey(); - IItemDefinition[] tools = entry.getValue(); + @Override + protected void registerRecipes(@Nonnull Consumer consumer) { + for (Map.Entry, IItemDefinition[]> entry : items.entrySet()) { + Tag tag = entry.getKey(); + IItemDefinition[] tools = entry.getValue(); - for( int i = 0; i < tools.length; i++ ) - { - CharSet keySet = new CharOpenHashSet( new char[] { 'X', ' ' } ); + for (int i = 0; i < tools.length; i++) { + CharSet keySet = new CharOpenHashSet(new char[] { 'X', ' ' }); - ShapedRecipeBuilder shapedBuilder = ShapedRecipeBuilder.shapedRecipe( tools[i].item() ); - for( String s : patterns[i] ) - { - shapedBuilder.patternLine( s ); + ShapedRecipeBuilder shapedBuilder = ShapedRecipeBuilder.shapedRecipe(tools[i].item()); + for (String s : patterns[i]) { + shapedBuilder.patternLine(s); - for( int j = 0; j < s.length(); j++ ) - { - char c = s.charAt( j ); - if( !keySet.contains( c ) ) - { - keySet.add( c ); - shapedBuilder.key( c, keys.get( c ) ); - } - } - } + for (int j = 0; j < s.length(); j++) { + char c = s.charAt(j); + if (!keySet.contains(c)) { + keySet.add(c); + shapedBuilder.key(c, keys.get(c)); + } + } + } - shapedBuilder.key( 'X', tag ) - .addCriterion( "has_" + tag.getId(), hasItem( tag ) ); + shapedBuilder.key('X', tag).addCriterion("has_" + tag.getId(), hasItem(tag)); - ConditionalRecipe.builder() - .addCondition( new FeaturesEnabled( tools[i].features() ) ) - .addRecipe( shapedBuilder::build ) - .build( consumer, AppEng.MOD_ID, "tools/" + tools[i].identifier() ); - } + ConditionalRecipe.builder().addCondition(new FeaturesEnabled(tools[i].features())) + .addRecipe(shapedBuilder::build) + .build(consumer, AppEng.MOD_ID, "tools/" + tools[i].identifier()); + } - } - } + } + } - @Override public String getName() - { - return AppEng.MOD_NAME + " Quartz Tools"; - } + @Override + public String getName() { + return AppEng.MOD_NAME + " Quartz Tools"; + } } diff --git a/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java b/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java index 3e2c2f459..f59b806ba 100644 --- a/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java +++ b/src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java @@ -1,117 +1,92 @@ package appeng.forge.data.providers.recipes; +import java.nio.file.Path; +import java.util.function.Consumer; + +import javax.annotation.Nonnull; -import appeng.api.definitions.IBlockDefinition; -import appeng.core.AppEng; -import appeng.forge.data.providers.IAE2DataProvider; -import appeng.recipes.conditions.FeaturesEnabled; import com.google.common.collect.Sets; + import net.minecraft.block.Block; import net.minecraft.data.*; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.ConditionalRecipe; -import javax.annotation.Nonnull; -import java.nio.file.Path; -import java.util.function.Consumer; +import appeng.api.definitions.IBlockDefinition; +import appeng.core.AppEng; +import appeng.forge.data.providers.IAE2DataProvider; +import appeng.recipes.conditions.FeaturesEnabled; +public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider { -public class SlabStairRecipes extends RecipeProvider implements IAE2DataProvider -{ + IBlockDefinition[][] blocks = { { BLOCKS.skyStoneBlock(), BLOCKS.skyStoneSlab(), BLOCKS.skyStoneStairs() }, + { BLOCKS.smoothSkyStoneBlock(), BLOCKS.smoothSkyStoneSlab(), BLOCKS.smoothSkyStoneStairs() }, + { BLOCKS.skyStoneBrick(), BLOCKS.skyStoneBrickSlab(), BLOCKS.skyStoneBrickStairs() }, + { BLOCKS.skyStoneSmallBrick(), BLOCKS.skyStoneSmallBrickSlab(), BLOCKS.skyStoneSmallBrickStairs() }, + { BLOCKS.fluixBlock(), BLOCKS.fluixSlab(), BLOCKS.fluixStairs() }, + { BLOCKS.quartzBlock(), BLOCKS.quartzSlab(), BLOCKS.quartzStairs() }, + { BLOCKS.chiseledQuartzBlock(), BLOCKS.chiseledQuartzSlab(), BLOCKS.chiseledQuartzStairs() }, + { BLOCKS.quartzPillar(), BLOCKS.quartzPillarSlab(), BLOCKS.quartzPillarStairs() }, }; - IBlockDefinition[][] blocks = { - { BLOCKS.skyStoneBlock(), BLOCKS.skyStoneSlab(), BLOCKS.skyStoneStairs() }, - { BLOCKS.smoothSkyStoneBlock(), BLOCKS.smoothSkyStoneSlab(), BLOCKS.smoothSkyStoneStairs() }, - { BLOCKS.skyStoneBrick(), BLOCKS.skyStoneBrickSlab(), BLOCKS.skyStoneBrickStairs() }, - { BLOCKS.skyStoneSmallBrick(), BLOCKS.skyStoneSmallBrickSlab(), BLOCKS.skyStoneSmallBrickStairs() }, - { BLOCKS.fluixBlock(), BLOCKS.fluixSlab(), BLOCKS.fluixStairs() }, - { BLOCKS.quartzBlock(), BLOCKS.quartzSlab(), BLOCKS.quartzStairs() }, - { BLOCKS.chiseledQuartzBlock(), BLOCKS.chiseledQuartzSlab(), BLOCKS.chiseledQuartzStairs() }, - { BLOCKS.quartzPillar(), BLOCKS.quartzPillarSlab(), BLOCKS.quartzPillarStairs() }, - }; + public SlabStairRecipes(DataGenerator generatorIn) { + super(generatorIn); + } - public SlabStairRecipes( DataGenerator generatorIn ) - { - super( generatorIn ); - } + @Override + public void registerRecipes(@Nonnull Consumer consumer) { + for (IBlockDefinition[] block : blocks) { + slabRecipe(consumer, block[0], block[1]); + stairRecipe(consumer, block[0], block[2]); + } + } - @Override - public void registerRecipes( @Nonnull Consumer consumer ) - { - for( IBlockDefinition[] block : blocks ) - { - slabRecipe( consumer, block[0], block[1] ); - stairRecipe( consumer, block[0], block[2] ); - } - } + private void slabRecipe(Consumer consumer, IBlockDefinition block, IBlockDefinition slabs) { + Block inputBlock = block.block(); + Block outputBlock = slabs.block(); - private void slabRecipe( Consumer consumer, IBlockDefinition block, IBlockDefinition slabs ) - { - Block inputBlock = block.block(); - Block outputBlock = slabs.block(); + FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), slabs.features())); + ConditionalRecipe.builder().addCondition(condition) + .addRecipe(ShapedRecipeBuilder.shapedRecipe(slabs.block(), 6).patternLine("###").key('#', inputBlock) + .addCriterion(criterionName(block), hasItem(inputBlock))::build) + .build(consumer, AppEng.MOD_ID, "slabs/" + block.identifier()); - FeaturesEnabled condition = new FeaturesEnabled( Sets.union( block.features(), slabs.features() ) ); - ConditionalRecipe.builder() - .addCondition( condition ) - .addRecipe( - ShapedRecipeBuilder.shapedRecipe( slabs.block(), 6 ) - .patternLine( "###" ) - .key( '#', inputBlock ) - .addCriterion( criterionName( block ), hasItem( inputBlock ) ) - ::build - ) - .build( consumer, AppEng.MOD_ID, "slabs/" + block.identifier() ); + ConditionalRecipe.builder().addCondition(condition) + .addRecipe(c -> SingleItemRecipeBuilder + .stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock, 2) + .addCriterion(criterionName(block), hasItem(inputBlock)) + .build(c, new ResourceLocation(AppEng.MOD_ID, slabs.identifier()))) + .build(consumer, AppEng.MOD_ID, "slabs/block_cutter/" + block.identifier()); - ConditionalRecipe.builder() - .addCondition( condition ) - .addRecipe( - c -> SingleItemRecipeBuilder.stonecuttingRecipe( Ingredient.fromItems( inputBlock ), outputBlock, 2 ) - .addCriterion( criterionName( block ), hasItem( inputBlock ) ) - .build( c, new ResourceLocation( AppEng.MOD_ID, slabs.identifier() ) ) - ) - .build( consumer, AppEng.MOD_ID, "slabs/block_cutter/" + block.identifier() ); + } - } + private void stairRecipe(Consumer consumer, IBlockDefinition block, IBlockDefinition stairs) { + Block inputBlock = block.block(); + Block outputBlock = stairs.block(); - private void stairRecipe( Consumer consumer, IBlockDefinition block, IBlockDefinition stairs ) - { - Block inputBlock = block.block(); - Block outputBlock = stairs.block(); + FeaturesEnabled condition = new FeaturesEnabled(Sets.union(block.features(), stairs.features())); + ConditionalRecipe.builder().addCondition(condition) + .addRecipe(ShapedRecipeBuilder.shapedRecipe(outputBlock, 4).patternLine("# ").patternLine("## ") + .patternLine("###").key('#', inputBlock) + .addCriterion(criterionName(block), hasItem(inputBlock))::build) + .build(consumer, AppEng.MOD_ID, "stairs/" + block.identifier()); - FeaturesEnabled condition = new FeaturesEnabled( Sets.union( block.features(), stairs.features() ) ); - ConditionalRecipe.builder() - .addCondition( condition ) - .addRecipe( - ShapedRecipeBuilder.shapedRecipe( outputBlock, 4 ) - .patternLine( "# " ) - .patternLine( "## " ) - .patternLine( "###" ) - .key( '#', inputBlock ) - .addCriterion( criterionName( block ), hasItem( inputBlock ) ) - ::build - ) - .build( consumer, AppEng.MOD_ID, "stairs/" + block.identifier() ); + ConditionalRecipe.builder().addCondition(condition) + .addRecipe( + c -> SingleItemRecipeBuilder.stonecuttingRecipe(Ingredient.fromItems(inputBlock), outputBlock) + .addCriterion(criterionName(block), hasItem(inputBlock)) + .build(c, new ResourceLocation(AppEng.MOD_ID, stairs.identifier()))) + .build(consumer, AppEng.MOD_ID, "stairs/block_cutter/" + block.identifier()); - ConditionalRecipe.builder() - .addCondition( condition ) - .addRecipe( - c -> SingleItemRecipeBuilder.stonecuttingRecipe( Ingredient.fromItems( inputBlock ), outputBlock ) - .addCriterion( criterionName( block ), hasItem( inputBlock ) ) - .build( c, new ResourceLocation( AppEng.MOD_ID, stairs.identifier() ) ) - ) - .build( consumer, AppEng.MOD_ID, "stairs/block_cutter/" + block.identifier() ); + } - } + private String criterionName(IBlockDefinition block) { + return String.format("has_%s", block.identifier()); + } - private String criterionName( IBlockDefinition block ) - { - return String.format( "has_%s", block.identifier() ); - } - - @Override public String getName() - { - return AppEng.MOD_NAME + " Slabs and Stairs"; - } + @Override + public String getName() { + return AppEng.MOD_NAME + " Slabs and Stairs"; + } } diff --git a/src/main/java/appeng/forge/data/providers/recipes/SpecialRecipes.java b/src/main/java/appeng/forge/data/providers/recipes/SpecialRecipes.java index 7679744fc..dde9c6012 100644 --- a/src/main/java/appeng/forge/data/providers/recipes/SpecialRecipes.java +++ b/src/main/java/appeng/forge/data/providers/recipes/SpecialRecipes.java @@ -1,32 +1,30 @@ package appeng.forge.data.providers.recipes; +import java.util.Objects; +import java.util.function.Consumer; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.core.AppEng; -import appeng.forge.data.providers.IAE2DataProvider; import com.google.gson.JsonObject; + import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.util.ResourceLocation; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Objects; -import java.util.function.Consumer; +import appeng.core.AppEng; +import appeng.forge.data.providers.IAE2DataProvider; +public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider { -public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider -{ + public SpecialRecipes(DataGenerator generatorIn) { + super(generatorIn); + } - public SpecialRecipes( DataGenerator generatorIn ) - { - super( generatorIn ); - } - - @Override - protected void registerRecipes( @Nonnull Consumer consumer ) - { + @Override + protected void registerRecipes(@Nonnull Consumer consumer) { // ConditionalRecipe.builder() FIXME this works, but NPEs at runtime // .addCondition( new FeaturesEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) ) // .addRecipe( new FinishedRecipe( DisassembleRecipe.SERIALIZER ) ) @@ -36,57 +34,50 @@ public class SpecialRecipes extends RecipeProvider implements IAE2DataProvider // .addCondition( new FeaturesEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) ) // .addRecipe( new FinishedRecipe( FacadeRecipe.SERIALIZER ) ) // .build( consumer, AppEng.MOD_ID, "special/facade" ); - } + } - private static class FinishedRecipe implements IFinishedRecipe - { + private static class FinishedRecipe implements IFinishedRecipe { - private final IRecipeSerializer serializer; + private final IRecipeSerializer serializer; - public FinishedRecipe( IRecipeSerializer serializer ) - { - this.serializer = serializer; - } + public FinishedRecipe(IRecipeSerializer serializer) { + this.serializer = serializer; + } - @Override public void serialize( @Nonnull JsonObject json ) - { - } + @Override + public void serialize(@Nonnull JsonObject json) { + } - @Nonnull - @Override - public ResourceLocation getID() - { - return Objects.requireNonNull( serializer.getRegistryName() ); - } + @Nonnull + @Override + public ResourceLocation getID() { + return Objects.requireNonNull(serializer.getRegistryName()); + } - @Nonnull - @Override - public IRecipeSerializer getSerializer() - { - return serializer; - } + @Nonnull + @Override + public IRecipeSerializer getSerializer() { + return serializer; + } - @Nullable - @Override - public JsonObject getAdvancementJson() - { - return null; - } + @Nullable + @Override + public JsonObject getAdvancementJson() { + return null; + } - @Nullable - @Override - public ResourceLocation getAdvancementID() - { - return null; - } + @Nullable + @Override + public ResourceLocation getAdvancementID() { + return null; + } - } + } - @Nonnull - @Override - public String getName() - { - return AppEng.MOD_NAME + " Special Crafting Recipes"; - } + @Nonnull + @Override + public String getName() { + return AppEng.MOD_NAME + " Special Crafting Recipes"; + } } diff --git a/src/main/java/appeng/helpers/AEGlassMaterial.java b/src/main/java/appeng/helpers/AEGlassMaterial.java index b0e86ec67..f5b5b91d1 100644 --- a/src/main/java/appeng/helpers/AEGlassMaterial.java +++ b/src/main/java/appeng/helpers/AEGlassMaterial.java @@ -18,15 +18,13 @@ package appeng.helpers; - import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.block.material.PushReaction; +public class AEGlassMaterial { -public class AEGlassMaterial -{ - - public static final Material INSTANCE = new Material( MaterialColor.AIR, false, false, true, false, true, false, false, PushReaction.NORMAL ); + public static final Material INSTANCE = new Material(MaterialColor.AIR, false, false, true, false, true, false, + false, PushReaction.NORMAL); } diff --git a/src/main/java/appeng/helpers/AEMultiTile.java b/src/main/java/appeng/helpers/AEMultiTile.java index de8165324..9d6229a2c 100644 --- a/src/main/java/appeng/helpers/AEMultiTile.java +++ b/src/main/java/appeng/helpers/AEMultiTile.java @@ -18,13 +18,10 @@ package appeng.helpers; - import appeng.api.implementations.tiles.IColorableTile; import appeng.api.networking.IGridHost; import appeng.api.parts.IPartHost; - -public interface AEMultiTile extends IGridHost, IPartHost, IColorableTile -{ +public interface AEMultiTile extends IGridHost, IPartHost, IColorableTile { } diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index d109a97fb..bdfd3a176 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -18,7 +18,6 @@ package appeng.helpers; - import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; @@ -113,1251 +112,1009 @@ import appeng.util.inv.IInventoryDestination; import appeng.util.inv.InvOperation; import appeng.util.item.AEItemStack; - -public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost -{ - - public static final int NUMBER_OF_STORAGE_SLOTS = 9; - public static final int NUMBER_OF_CONFIG_SLOTS = 9; - public static final int NUMBER_OF_PATTERN_SLOTS = 9; - - private static final Collection BAD_BLOCKS = new HashSet<>( 100 ); - private final IAEItemStack[] requireWork = { null, null, null, null, null, null, null, null, null }; - private final MultiCraftingTracker craftingTracker; - private final AENetworkProxy gridProxy; - private final IInterfaceHost iHost; - private final IActionSource mySource; - private final IActionSource interfaceRequestSource; - private final ConfigManager cm = new ConfigManager( this ); - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, NUMBER_OF_CONFIG_SLOTS ); - private final AppEngInternalInventory storage = new AppEngInternalInventory( this, NUMBER_OF_STORAGE_SLOTS ); - private final AppEngInternalInventory patterns = new AppEngInternalInventory( this, NUMBER_OF_PATTERN_SLOTS ); - private final MEMonitorPassThrough items = new MEMonitorPassThrough<>( new NullInventory(), AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ) ); - private final MEMonitorPassThrough fluids = new MEMonitorPassThrough<>( new NullInventory(), AEApi.instance() - .storage() - .getStorageChannel( IFluidStorageChannel.class ) ); - private final UpgradeInventory upgrades; - private boolean hasConfig = false; - private int priority; - private List craftingList = null; - private List waitingToSend = null; - private IMEInventory destination; - private int isWorking = -1; - private final Accessor accessor = new Accessor(); - - public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih ) - { - this.gridProxy = networkProxy; - this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); - - this.upgrades = new StackUpgradeInventory( this.gridProxy.getMachineRepresentation(), this, 1 ); - this.cm.registerSetting( Settings.BLOCK, YesNo.NO ); - this.cm.registerSetting( Settings.INTERFACE_TERMINAL, YesNo.YES ); - - this.iHost = ih; - this.craftingTracker = new MultiCraftingTracker( this.iHost, 9 ); - - final MachineSource actionSource = new MachineSource( this.iHost ); - this.mySource = actionSource; - this.fluids.setChangeSource( actionSource ); - this.items.setChangeSource( actionSource ); - - this.interfaceRequestSource = new InterfaceRequestSource( this.iHost ); - } - - @Override - public void saveChanges() - { - this.iHost.saveChanges(); - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( this.isWorking == slot ) - { - return; - } - - if( inv == this.config ) - { - this.readConfig(); - } - else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) ) - { - this.updateCraftingList(); - } - else if( inv == this.storage && slot >= 0 ) - { - final boolean had = this.hasWorkToDo(); - - this.updatePlan( slot ); - - final boolean now = this.hasWorkToDo(); - - if( had != now ) - { - try - { - if( now ) - { - this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); - } - else - { - this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - } - } - - public void writeToNBT( final CompoundNBT data ) - { - this.config.writeToNBT( data, "config" ); - this.patterns.writeToNBT( data, "patterns" ); - this.storage.writeToNBT( data, "storage" ); - this.upgrades.writeToNBT( data, "upgrades" ); - this.cm.writeToNBT( data ); - this.craftingTracker.writeToNBT( data ); - data.putInt( "priority", this.priority ); - - final ListNBT waitingToSend = new ListNBT(); - if( this.waitingToSend != null ) - { - for( final ItemStack is : this.waitingToSend ) - { - final CompoundNBT item = new CompoundNBT(); - is.write( item ); - waitingToSend.add( item ); - } - } - data.put( "waitingToSend", waitingToSend ); - } - - public void readFromNBT( final CompoundNBT data ) - { - this.waitingToSend = null; - final ListNBT waitingList = data.getList( "waitingToSend", 10 ); - if( waitingList != null ) - { - for( int x = 0; x < waitingList.size(); x++ ) - { - final CompoundNBT c = waitingList.getCompound( x ); - if( c != null ) - { - final ItemStack is = ItemStack.read( c ); - this.addToSendList( is ); - } - } - } - - this.craftingTracker.readFromNBT( data ); - this.upgrades.readFromNBT( data, "upgrades" ); - this.config.readFromNBT( data, "config" ); - this.patterns.readFromNBT( data, "patterns" ); - this.storage.readFromNBT( data, "storage" ); - this.priority = data.getInt( "priority" ); - this.cm.readFromNBT( data ); - this.readConfig(); - this.updateCraftingList(); - } - - private void addToSendList( final ItemStack is ) - { - if( is.isEmpty() ) - { - return; - } - - if( this.waitingToSend == null ) - { - this.waitingToSend = new ArrayList<>(); - } - - this.waitingToSend.add( is ); - - try - { - this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - private void readConfig() - { - this.hasConfig = false; - - for( final ItemStack p : this.config ) - { - if( !p.isEmpty() ) - { - this.hasConfig = true; - break; - } - } - - final boolean had = this.hasWorkToDo(); - - for( int x = 0; x < NUMBER_OF_CONFIG_SLOTS; x++ ) - { - this.updatePlan( x ); - } - - final boolean has = this.hasWorkToDo(); - - if( had != has ) - { - try - { - if( has ) - { - this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); - } - else - { - this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - - this.notifyNeighbors(); - } - - private void updateCraftingList() - { - final Boolean[] accountedFor = { false, false, false, false, false, false, false, false, false }; // 9... - - assert ( accountedFor.length == this.patterns.getSlots() ); - - if( !this.gridProxy.isReady() ) - { - return; - } - - if( this.craftingList != null ) - { - final Iterator i = this.craftingList.iterator(); - while( i.hasNext() ) - { - final ICraftingPatternDetails details = i.next(); - boolean found = false; - - for( int x = 0; x < accountedFor.length; x++ ) - { - final ItemStack is = this.patterns.getStackInSlot( x ); - if( details.getPattern() == is ) - { - accountedFor[x] = found = true; - } - } - - if( !found ) - { - i.remove(); - } - } - } - - for( int x = 0; x < accountedFor.length; x++ ) - { - if( !accountedFor[x] ) - { - this.addToCraftingList( this.patterns.getStackInSlot( x ) ); - } - } - - try - { - this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - private boolean hasWorkToDo() - { - if( this.hasItemsToSend() ) - { - return true; - } - else - { - for( final IAEItemStack requiredWork : this.requireWork ) - { - if( requiredWork != null ) - { - return true; - } - } - - return false; - } - } - - private void updatePlan( final int slot ) - { - IAEItemStack req = this.config.getAEStackInSlot( slot ); - if( req != null && req.getStackSize() <= 0 ) - { - this.config.setStackInSlot( slot, ItemStack.EMPTY ); - req = null; - } - - final ItemStack stored = this.storage.getStackInSlot( slot ); - - if( req == null && !stored.isEmpty() ) - { - final IAEItemStack work = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stored ); - this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); - return; - } - else if( req != null ) - { - if( stored.isEmpty() ) // need to add stuff! - { - this.requireWork[slot] = req.copy(); - return; - } - else if( req.isSameType( stored ) ) // same type ( qty different? )! - { - if( req.getStackSize() != stored.getCount() ) - { - this.requireWork[slot] = req.copy(); - this.requireWork[slot].setStackSize( req.getStackSize() - stored.getCount() ); - return; - } - } - else - // Stored != null; dispose! - { - final IAEItemStack work = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stored ); - this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); - return; - } - } - - // else - - this.requireWork[slot] = null; - } - - public void notifyNeighbors() - { - if( this.gridProxy.isActive() ) - { - try - { - this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) ); - this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - final TileEntity te = this.iHost.getTileEntity(); - if( te != null && te.getWorld() != null ) - { - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() ); - } - } - - private void addToCraftingList( final ItemStack is ) - { - if( is.isEmpty() ) - { - return; - } - - if( is.getItem() instanceof ICraftingPatternItem ) - { - final ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem(); - final ICraftingPatternDetails details = cpi.getPatternForItem( is, this.iHost.getTileEntity().getWorld() ); - - if( details != null ) - { - if( this.craftingList == null ) - { - this.craftingList = new ArrayList<>(); - } - - this.craftingList.add( details ); - } - } - } - - private boolean hasItemsToSend() - { - return this.waitingToSend != null && !this.waitingToSend.isEmpty(); - } - - @Override - public boolean canInsert( final ItemStack stack ) - { - final IAEItemStack out = this.destination.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), - Actionable.SIMULATE, null ); - if( out == null ) - { - return true; - } - return out.getStackSize() != stack.getCount(); - // ItemStack after = adaptor.simulateAdd( stack ); - // if ( after == null ) - // return true; - // return after.stackSize != stack.stackSize; - } - - public IItemHandler getConfig() - { - return this.config; - } - - public IItemHandler getPatterns() - { - return this.patterns; - } - - public void gridChanged() - { - try - { - this.items.setInternal( this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - this.fluids.setInternal( this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) ); - } - catch( final GridAccessException gae ) - { - this.items.setInternal( new NullInventory() ); - this.fluids.setInternal( new NullInventory() ); - } - - this.notifyNeighbors(); - } - - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } - - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this.iHost.getTileEntity() ); - } - - public IItemHandler getInternalInventory() - { - return this.storage; - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( !this.gridProxy.isActive() ) - { - return TickRateModulation.SLEEP; - } - - if( this.hasItemsToSend() ) - { - this.pushItemsOut( this.iHost.getTargets() ); - } - - final boolean couldDoWork = this.updateStorage(); - return this.hasWorkToDo() ? ( couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER ) : TickRateModulation.SLEEP; - } - - private void pushItemsOut( final EnumSet possibleDirections ) - { - if( !this.hasItemsToSend() ) - { - return; - } - - final TileEntity tile = this.iHost.getTileEntity(); - final World w = tile.getWorld(); - - final Iterator i = this.waitingToSend.iterator(); - while( i.hasNext() ) - { - ItemStack whatToSend = i.next(); - - for( final Direction s : possibleDirections ) - { - final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) ); - if( te == null ) - { - continue; - } - - final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); - if( ad != null ) - { - final ItemStack result = ad.addItems( whatToSend ); - - if( result.isEmpty() ) - { - whatToSend = ItemStack.EMPTY; - } - else - { - whatToSend.setCount( whatToSend.getCount() - ( whatToSend.getCount() - result.getCount() ) ); - } - - if( whatToSend.isEmpty() ) - { - break; - } - } - } - - if( whatToSend.isEmpty() ) - { - i.remove(); - } - } - - if( this.waitingToSend.isEmpty() ) - { - this.waitingToSend = null; - } - } - - private boolean updateStorage() - { - boolean didSomething = false; - - for( int x = 0; x < NUMBER_OF_STORAGE_SLOTS; x++ ) - { - if( this.requireWork[x] != null ) - { - didSomething = this.usePlan( x, this.requireWork[x] ) || didSomething; - } - } - - return didSomething; - } - - private boolean usePlan( final int x, final IAEItemStack itemStack ) - { - final InventoryAdaptor adaptor = this.getAdaptor( x ); - this.isWorking = x; - - boolean changed = false; - try - { - this.destination = this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final IEnergySource src = this.gridProxy.getEnergy(); - - if( this.craftingTracker.isBusy( x ) ) - { - changed = this.handleCrafting( x, adaptor, itemStack ) || changed; - } - else if( itemStack.getStackSize() > 0 ) - { - // make sure strange things didn't happen... - if( !adaptor.simulateAdd( itemStack.createItemStack() ).isEmpty() ) - { - changed = true; - throw new GridAccessException(); - } - - final IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource ); - if( acquired != null ) - { - changed = true; - final ItemStack issue = adaptor.addItems( acquired.createItemStack() ); - if( !issue.isEmpty() ) - { - throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" ); - } - } - else - { - changed = this.handleCrafting( x, adaptor, itemStack ) || changed; - } - } - else if( itemStack.getStackSize() < 0 ) - { - IAEItemStack toStore = itemStack.copy(); - toStore.setStackSize( -toStore.getStackSize() ); - - long diff = toStore.getStackSize(); - - // make sure strange things didn't happen... - // TODO: check if OK - final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getDefinition(), null ); - if( canExtract.isEmpty() || canExtract.getCount() != diff ) - { - changed = true; - throw new GridAccessException(); - } - - toStore = Platform.poweredInsert( src, this.destination, toStore, this.interfaceRequestSource ); - - if( toStore != null ) - { - diff -= toStore.getStackSize(); - } - - if( diff != 0 ) - { - // extract items! - changed = true; - final ItemStack removed = adaptor.removeItems( (int) diff, ItemStack.EMPTY, null ); - if( removed.isEmpty() ) - { - throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); - } - else if( removed.getCount() != diff ) - { - throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); - } - } - } - // else wtf? - } - catch( final GridAccessException e ) - { - // :P - } - - if( changed ) - { - this.updatePlan( x ); - } - - this.isWorking = -1; - return changed; - } - - private InventoryAdaptor getAdaptor( final int slot ) - { - return new AdaptorItemHandler( new RangedWrapper( this.storage, slot, slot + 1 ) ); - } - - private boolean handleCrafting( final int x, final InventoryAdaptor d, final IAEItemStack itemStack ) - { - try - { - if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null ) - { - return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), - this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource ); - } - } - catch( final GridAccessException e ) - { - // :P - } - - return false; - } - - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - if( this.upgrades == null ) - { - return 0; - } - return this.upgrades.getInstalledUpgrades( u ); - } - - @Override - public TileEntity getTile() - { - return (TileEntity) ( this.iHost instanceof TileEntity ? this.iHost : null ); - } - - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - if( this.hasConfig() ) - { - return (IMEMonitor) new InterfaceInventory( this ); - } - - return (IMEMonitor) this.items; - } - else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) - { - if( this.hasConfig() ) - { - return null; - } - - return (IMEMonitor) this.fluids; - } - - return null; - } - - private boolean hasConfig() - { - return this.hasConfig; - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "storage" ) ) - { - return this.storage; - } - - if( name.equals( "patterns" ) ) - { - return this.patterns; - } - - if( name.equals( "config" ) ) - { - return this.config; - } - - if( name.equals( "upgrades" ) ) - { - return this.upgrades; - } - - return null; - } - - public IItemHandler getStorage() - { - return this.storage; - } - - @Override - public appeng.api.util.IConfigManager getConfigManager() - { - return this.cm; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - if( this.getInstalledUpgrades( Upgrades.CRAFTING ) == 0 ) - { - this.cancelCrafting(); - } - this.iHost.saveChanges(); - } - - private void cancelCrafting() - { - this.craftingTracker.cancel(); - } - - public IStorageMonitorable getMonitorable( final IActionSource src, final IStorageMonitorable myInterface ) - { - if( Platform.canAccess( this.gridProxy, src ) ) - { - return myInterface; - } - - final DualityInterface di = this; - - return new IStorageMonitorable() - { - - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - return (IMEMonitor) new InterfaceInventory( di ); - } - return null; - } - }; - } - - @Override - public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table ) - { - if( this.hasItemsToSend() || !this.gridProxy.isActive() || !this.craftingList.contains( patternDetails ) ) - { - return false; - } - - final TileEntity tile = this.iHost.getTileEntity(); - final World w = tile.getWorld(); - - final EnumSet possibleDirections = this.iHost.getTargets(); - for( final Direction s : possibleDirections ) - { - final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) ); - if( te instanceof IInterfaceHost ) - { - try - { - if( ( (IInterfaceHost) te ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) - { - continue; - } - } - catch( final GridAccessException e ) - { - continue; - } - } - - if( te instanceof ICraftingMachine ) - { - final ICraftingMachine cm = (ICraftingMachine) te; - if( cm.acceptsPlans() ) - { - if( cm.pushPattern( patternDetails, table, s.getOpposite() ) ) - { - return true; - } - continue; - } - } - - final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); - if( ad != null ) - { - if( this.isBlocking() ) - { - if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() ) - { - continue; - } - } - - if( this.acceptsItems( ad, table ) ) - { - for( int x = 0; x < table.getSizeInventory(); x++ ) - { - final ItemStack is = table.getStackInSlot( x ); - if( !is.isEmpty() ) - { - final ItemStack added = ad.addItems( is ); - this.addToSendList( added ); - } - } - this.pushItemsOut( possibleDirections ); - return true; - } - } - } - - return false; - } - - @Override - public boolean isBusy() - { - if( this.hasItemsToSend() ) - { - return true; - } - - boolean busy = false; - - if( this.isBlocking() ) - { - final EnumSet possibleDirections = this.iHost.getTargets(); - final TileEntity tile = this.iHost.getTileEntity(); - final World w = tile.getWorld(); - - boolean allAreBusy = true; - - for( final Direction s : possibleDirections ) - { - final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) ); - - final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); - if( ad != null ) - { - if( ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() ) - { - allAreBusy = false; - break; - } - } - } - - busy = allAreBusy; - } - - return busy; - } - - private boolean sameGrid( final IGrid grid ) throws GridAccessException - { - return grid == this.gridProxy.getGrid(); - } - - private boolean isBlocking() - { - return this.cm.getSetting( Settings.BLOCK ) == YesNo.YES; - } - - private boolean acceptsItems( final InventoryAdaptor ad, final CraftingInventory table ) - { - for( int x = 0; x < table.getSizeInventory(); x++ ) - { - final ItemStack is = table.getStackInSlot( x ); - if( is.isEmpty() ) - { - continue; - } - - if( !ad.simulateAdd( is.copy() ).isEmpty() ) - { - return false; - } - } - - return true; - } - - @Override - public void provideCrafting( final ICraftingProviderHelper craftingTracker ) - { - if( this.gridProxy.isActive() && this.craftingList != null ) - { - for( final ICraftingPatternDetails details : this.craftingList ) - { - details.setPriority( this.priority ); - craftingTracker.addCraftingOption( this, details ); - } - } - } - - public void addDrops( final List drops ) - { - if( this.waitingToSend != null ) - { - for( final ItemStack is : this.waitingToSend ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } - - for( final ItemStack is : this.upgrades ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - - for( final ItemStack is : this.storage ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - - for( final ItemStack is : this.patterns ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } - - public IUpgradeableHost getHost() - { - if( this.getPart() instanceof IUpgradeableHost ) - { - return (IUpgradeableHost) this.getPart(); - } - if( this.getTile() instanceof IUpgradeableHost ) - { - return (IUpgradeableHost) this.getTile(); - } - return null; - } - - private IPart getPart() - { - return (IPart) ( this.iHost instanceof IPart ? this.iHost : null ); - } - - public ImmutableSet getRequestedJobs() - { - return this.craftingTracker.getRequestedJobs(); - } - - public IAEItemStack injectCraftedItems( final ICraftingLink link, final IAEItemStack acquired, final Actionable mode ) - { - final int slot = this.craftingTracker.getSlot( link ); - - if( acquired != null && slot >= 0 && slot <= this.requireWork.length ) - { - final InventoryAdaptor adaptor = this.getAdaptor( slot ); - - if( mode == Actionable.SIMULATE ) - { - return AEItemStack.fromItemStack( adaptor.simulateAdd( acquired.createItemStack() ) ); - } - else - { - final IAEItemStack is = AEItemStack.fromItemStack( adaptor.addItems( acquired.createItemStack() ) ); - this.updatePlan( slot ); - return is; - } - } - - return acquired; - } - - public void jobStateChange( final ICraftingLink link ) - { - this.craftingTracker.jobStateChange( link ); - } - - public ITextComponent getTermName() - { - final TileEntity hostTile = this.iHost.getTileEntity(); - final World hostWorld = hostTile.getWorld(); - - if( ( (ICustomNameObject) this.iHost ).hasCustomInventoryName() ) - { - return ( (ICustomNameObject) this.iHost ).getCustomInventoryName(); - } - - final EnumSet possibleDirections = this.iHost.getTargets(); - for( final Direction direction : possibleDirections ) - { - final BlockPos targ = hostTile.getPos().offset( direction ); - final TileEntity directedTile = hostWorld.getTileEntity( targ ); - - if( directedTile == null ) - { - continue; - } - - if( directedTile instanceof IInterfaceHost ) - { - try - { - if( ( (IInterfaceHost) directedTile ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) - { - continue; - } - } - catch( final GridAccessException e ) - { - continue; - } - } - - final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( directedTile, direction.getOpposite() ); - if( directedTile instanceof ICraftingMachine || adaptor != null ) - { - if( adaptor != null && !adaptor.hasSlots() ) - { - continue; - } - - final BlockState directedBlockState = hostWorld.getBlockState( targ ); - final Block directedBlock = directedBlockState.getBlock(); - ItemStack what = new ItemStack( directedBlock, 1 ); - try - { - Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 ); - from = from.add( direction.getXOffset() * 0.501, direction.getYOffset() * 0.501, direction.getZOffset() * 0.501 ); - final Vec3d to = from.add( direction.getXOffset(), direction.getYOffset(), direction.getZOffset() ); - final BlockRayTraceResult hit = null;//hostWorld.rayTraceBlocks( from, to ); //FIXME: https://github.com/MinecraftForge/MinecraftForge/pull/6708 - if( hit != null && !BAD_BLOCKS.contains( directedBlock ) ) - { - if( hit.getPos().equals( directedTile.getPos() ) ) - { - final ItemStack g = directedBlock.getPickBlock( directedBlockState, hit, hostWorld, directedTile.getPos(), null ); - if( !g.isEmpty() ) - { - what = g; - } - } - } - } - catch( final Throwable t ) - { - BAD_BLOCKS.add( directedBlock ); // nope! - } - - if( what.getItem() != Items.AIR ) - { - return new TranslationTextComponent(what.getTranslationKey()); - } - - final Item item = Item.getItemFromBlock( directedBlock ); - if( item == Items.AIR ) - { - return new TranslationTextComponent(directedBlock.getTranslationKey()); - } - } - } - - return new StringTextComponent("Nothing"); - } - - public long getSortValue() - { - final TileEntity te = this.iHost.getTileEntity(); - return ( te.getPos().getZ() << 24 ) ^ ( te.getPos().getX() << 8 ) ^ te.getPos().getY(); - } - - public void initialize() - { - this.updateCraftingList(); - } - - public int getPriority() - { - return this.priority; - } - - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.iHost.saveChanges(); - - try - { - this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - public boolean hasCapability( Capability capabilityClass, Direction facing ) - { - return capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR; - } - - @SuppressWarnings( "unchecked" ) - public LazyOptional getCapability(Capability capabilityClass, Direction facing ) - { - if( capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() -> this.storage); - } - else if( capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR ) - { - return (LazyOptional) LazyOptional.of(() -> this.accessor); - } - return LazyOptional.empty(); - } - - private class InterfaceRequestSource extends MachineSource - { - private final InterfaceRequestContext context; - - public InterfaceRequestSource( IActionHost v ) - { - super( v ); - this.context = new InterfaceRequestContext(); - } - - @Override - public Optional context( Class key ) - { - if( key == InterfaceRequestContext.class ) - { - return (Optional) Optional.of( this.context ); - } - - return super.context( key ); - } - - } - - private class InterfaceRequestContext implements Comparable - { - - @Override - public int compareTo( Integer o ) - { - return Integer.compare( DualityInterface.this.priority, o ); - } - } - - private class InterfaceInventory extends MEMonitorIInventory - { - - public InterfaceInventory( final DualityInterface tileInterface ) - { - super( new AdaptorItemHandler( tileInterface.storage ) ); - this.setActionSource( new MachineSource( DualityInterface.this.iHost ) ); - } - - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - final Optional context = src.context( InterfaceRequestContext.class ); - final boolean isInterface = context.isPresent(); - - if( isInterface ) - { - return input; - } - - return super.injectItems( input, type, src ); - } - - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src ) - { - final Optional context = src.context( InterfaceRequestContext.class ); - final boolean hasLowerOrEqualPriority = context.map( c -> c.compareTo( DualityInterface.this.priority ) <= 0 ).orElse( false ); - - if( hasLowerOrEqualPriority ) - { - return null; - } - - return super.extractItems( request, type, src ); - } - } - - private class Accessor implements IStorageMonitorableAccessor - { - - @Nullable - @Override - public IStorageMonitorable getInventory( IActionSource src ) - { - return DualityInterface.this.getMonitorable( src, DualityInterface.this ); - } - - } +public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, + IConfigManagerHost, ICraftingProvider, IUpgradeableHost { + + public static final int NUMBER_OF_STORAGE_SLOTS = 9; + public static final int NUMBER_OF_CONFIG_SLOTS = 9; + public static final int NUMBER_OF_PATTERN_SLOTS = 9; + + private static final Collection BAD_BLOCKS = new HashSet<>(100); + private final IAEItemStack[] requireWork = { null, null, null, null, null, null, null, null, null }; + private final MultiCraftingTracker craftingTracker; + private final AENetworkProxy gridProxy; + private final IInterfaceHost iHost; + private final IActionSource mySource; + private final IActionSource interfaceRequestSource; + private final ConfigManager cm = new ConfigManager(this); + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS); + private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS); + private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS); + private final MEMonitorPassThrough items = new MEMonitorPassThrough<>( + new NullInventory(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + private final MEMonitorPassThrough fluids = new MEMonitorPassThrough<>( + new NullInventory(), + AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); + private final UpgradeInventory upgrades; + private boolean hasConfig = false; + private int priority; + private List craftingList = null; + private List waitingToSend = null; + private IMEInventory destination; + private int isWorking = -1; + private final Accessor accessor = new Accessor(); + + public DualityInterface(final AENetworkProxy networkProxy, final IInterfaceHost ih) { + this.gridProxy = networkProxy; + this.gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL); + + this.upgrades = new StackUpgradeInventory(this.gridProxy.getMachineRepresentation(), this, 1); + this.cm.registerSetting(Settings.BLOCK, YesNo.NO); + this.cm.registerSetting(Settings.INTERFACE_TERMINAL, YesNo.YES); + + this.iHost = ih; + this.craftingTracker = new MultiCraftingTracker(this.iHost, 9); + + final MachineSource actionSource = new MachineSource(this.iHost); + this.mySource = actionSource; + this.fluids.setChangeSource(actionSource); + this.items.setChangeSource(actionSource); + + this.interfaceRequestSource = new InterfaceRequestSource(this.iHost); + } + + @Override + public void saveChanges() { + this.iHost.saveChanges(); + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (this.isWorking == slot) { + return; + } + + if (inv == this.config) { + this.readConfig(); + } else if (inv == this.patterns && (!removed.isEmpty() || !added.isEmpty())) { + this.updateCraftingList(); + } else if (inv == this.storage && slot >= 0) { + final boolean had = this.hasWorkToDo(); + + this.updatePlan(slot); + + final boolean now = this.hasWorkToDo(); + + if (had != now) { + try { + if (now) { + this.gridProxy.getTick().alertDevice(this.gridProxy.getNode()); + } else { + this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + } + } + + public void writeToNBT(final CompoundNBT data) { + this.config.writeToNBT(data, "config"); + this.patterns.writeToNBT(data, "patterns"); + this.storage.writeToNBT(data, "storage"); + this.upgrades.writeToNBT(data, "upgrades"); + this.cm.writeToNBT(data); + this.craftingTracker.writeToNBT(data); + data.putInt("priority", this.priority); + + final ListNBT waitingToSend = new ListNBT(); + if (this.waitingToSend != null) { + for (final ItemStack is : this.waitingToSend) { + final CompoundNBT item = new CompoundNBT(); + is.write(item); + waitingToSend.add(item); + } + } + data.put("waitingToSend", waitingToSend); + } + + public void readFromNBT(final CompoundNBT data) { + this.waitingToSend = null; + final ListNBT waitingList = data.getList("waitingToSend", 10); + if (waitingList != null) { + for (int x = 0; x < waitingList.size(); x++) { + final CompoundNBT c = waitingList.getCompound(x); + if (c != null) { + final ItemStack is = ItemStack.read(c); + this.addToSendList(is); + } + } + } + + this.craftingTracker.readFromNBT(data); + this.upgrades.readFromNBT(data, "upgrades"); + this.config.readFromNBT(data, "config"); + this.patterns.readFromNBT(data, "patterns"); + this.storage.readFromNBT(data, "storage"); + this.priority = data.getInt("priority"); + this.cm.readFromNBT(data); + this.readConfig(); + this.updateCraftingList(); + } + + private void addToSendList(final ItemStack is) { + if (is.isEmpty()) { + return; + } + + if (this.waitingToSend == null) { + this.waitingToSend = new ArrayList<>(); + } + + this.waitingToSend.add(is); + + try { + this.gridProxy.getTick().wakeDevice(this.gridProxy.getNode()); + } catch (final GridAccessException e) { + // :P + } + } + + private void readConfig() { + this.hasConfig = false; + + for (final ItemStack p : this.config) { + if (!p.isEmpty()) { + this.hasConfig = true; + break; + } + } + + final boolean had = this.hasWorkToDo(); + + for (int x = 0; x < NUMBER_OF_CONFIG_SLOTS; x++) { + this.updatePlan(x); + } + + final boolean has = this.hasWorkToDo(); + + if (had != has) { + try { + if (has) { + this.gridProxy.getTick().alertDevice(this.gridProxy.getNode()); + } else { + this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + + this.notifyNeighbors(); + } + + private void updateCraftingList() { + final Boolean[] accountedFor = { false, false, false, false, false, false, false, false, false }; // 9... + + assert (accountedFor.length == this.patterns.getSlots()); + + if (!this.gridProxy.isReady()) { + return; + } + + if (this.craftingList != null) { + final Iterator i = this.craftingList.iterator(); + while (i.hasNext()) { + final ICraftingPatternDetails details = i.next(); + boolean found = false; + + for (int x = 0; x < accountedFor.length; x++) { + final ItemStack is = this.patterns.getStackInSlot(x); + if (details.getPattern() == is) { + accountedFor[x] = found = true; + } + } + + if (!found) { + i.remove(); + } + } + } + + for (int x = 0; x < accountedFor.length; x++) { + if (!accountedFor[x]) { + this.addToCraftingList(this.patterns.getStackInSlot(x)); + } + } + + try { + this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode())); + } catch (final GridAccessException e) { + // :P + } + } + + private boolean hasWorkToDo() { + if (this.hasItemsToSend()) { + return true; + } else { + for (final IAEItemStack requiredWork : this.requireWork) { + if (requiredWork != null) { + return true; + } + } + + return false; + } + } + + private void updatePlan(final int slot) { + IAEItemStack req = this.config.getAEStackInSlot(slot); + if (req != null && req.getStackSize() <= 0) { + this.config.setStackInSlot(slot, ItemStack.EMPTY); + req = null; + } + + final ItemStack stored = this.storage.getStackInSlot(slot); + + if (req == null && !stored.isEmpty()) { + final IAEItemStack work = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(stored); + this.requireWork[slot] = work.setStackSize(-work.getStackSize()); + return; + } else if (req != null) { + if (stored.isEmpty()) // need to add stuff! + { + this.requireWork[slot] = req.copy(); + return; + } else if (req.isSameType(stored)) // same type ( qty different? )! + { + if (req.getStackSize() != stored.getCount()) { + this.requireWork[slot] = req.copy(); + this.requireWork[slot].setStackSize(req.getStackSize() - stored.getCount()); + return; + } + } else + // Stored != null; dispose! + { + final IAEItemStack work = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(stored); + this.requireWork[slot] = work.setStackSize(-work.getStackSize()); + return; + } + } + + // else + + this.requireWork[slot] = null; + } + + public void notifyNeighbors() { + if (this.gridProxy.isActive()) { + try { + this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode())); + this.gridProxy.getTick().wakeDevice(this.gridProxy.getNode()); + } catch (final GridAccessException e) { + // :P + } + } + + final TileEntity te = this.iHost.getTileEntity(); + if (te != null && te.getWorld() != null) { + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos()); + } + } + + private void addToCraftingList(final ItemStack is) { + if (is.isEmpty()) { + return; + } + + if (is.getItem() instanceof ICraftingPatternItem) { + final ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem(); + final ICraftingPatternDetails details = cpi.getPatternForItem(is, this.iHost.getTileEntity().getWorld()); + + if (details != null) { + if (this.craftingList == null) { + this.craftingList = new ArrayList<>(); + } + + this.craftingList.add(details); + } + } + } + + private boolean hasItemsToSend() { + return this.waitingToSend != null && !this.waitingToSend.isEmpty(); + } + + @Override + public boolean canInsert(final ItemStack stack) { + final IAEItemStack out = this.destination.injectItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack), + Actionable.SIMULATE, null); + if (out == null) { + return true; + } + return out.getStackSize() != stack.getCount(); + // ItemStack after = adaptor.simulateAdd( stack ); + // if ( after == null ) + // return true; + // return after.stackSize != stack.stackSize; + } + + public IItemHandler getConfig() { + return this.config; + } + + public IItemHandler getPatterns() { + return this.patterns; + } + + public void gridChanged() { + try { + this.items.setInternal(this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + this.fluids.setInternal(this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))); + } catch (final GridAccessException gae) { + this.items.setInternal(new NullInventory()); + this.fluids.setInternal(new NullInventory()); + } + + this.notifyNeighbors(); + } + + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } + + public DimensionalCoord getLocation() { + return new DimensionalCoord(this.iHost.getTileEntity()); + } + + public IItemHandler getInternalInventory() { + return this.storage; + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), + true); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (!this.gridProxy.isActive()) { + return TickRateModulation.SLEEP; + } + + if (this.hasItemsToSend()) { + this.pushItemsOut(this.iHost.getTargets()); + } + + final boolean couldDoWork = this.updateStorage(); + return this.hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) + : TickRateModulation.SLEEP; + } + + private void pushItemsOut(final EnumSet possibleDirections) { + if (!this.hasItemsToSend()) { + return; + } + + final TileEntity tile = this.iHost.getTileEntity(); + final World w = tile.getWorld(); + + final Iterator i = this.waitingToSend.iterator(); + while (i.hasNext()) { + ItemStack whatToSend = i.next(); + + for (final Direction s : possibleDirections) { + final TileEntity te = w.getTileEntity(tile.getPos().offset(s)); + if (te == null) { + continue; + } + + final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite()); + if (ad != null) { + final ItemStack result = ad.addItems(whatToSend); + + if (result.isEmpty()) { + whatToSend = ItemStack.EMPTY; + } else { + whatToSend.setCount(whatToSend.getCount() - (whatToSend.getCount() - result.getCount())); + } + + if (whatToSend.isEmpty()) { + break; + } + } + } + + if (whatToSend.isEmpty()) { + i.remove(); + } + } + + if (this.waitingToSend.isEmpty()) { + this.waitingToSend = null; + } + } + + private boolean updateStorage() { + boolean didSomething = false; + + for (int x = 0; x < NUMBER_OF_STORAGE_SLOTS; x++) { + if (this.requireWork[x] != null) { + didSomething = this.usePlan(x, this.requireWork[x]) || didSomething; + } + } + + return didSomething; + } + + private boolean usePlan(final int x, final IAEItemStack itemStack) { + final InventoryAdaptor adaptor = this.getAdaptor(x); + this.isWorking = x; + + boolean changed = false; + try { + this.destination = this.gridProxy.getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final IEnergySource src = this.gridProxy.getEnergy(); + + if (this.craftingTracker.isBusy(x)) { + changed = this.handleCrafting(x, adaptor, itemStack) || changed; + } else if (itemStack.getStackSize() > 0) { + // make sure strange things didn't happen... + if (!adaptor.simulateAdd(itemStack.createItemStack()).isEmpty()) { + changed = true; + throw new GridAccessException(); + } + + final IAEItemStack acquired = Platform.poweredExtraction(src, this.destination, itemStack, + this.interfaceRequestSource); + if (acquired != null) { + changed = true; + final ItemStack issue = adaptor.addItems(acquired.createItemStack()); + if (!issue.isEmpty()) { + throw new IllegalStateException("bad attempt at managing inventory. ( addItems )"); + } + } else { + changed = this.handleCrafting(x, adaptor, itemStack) || changed; + } + } else if (itemStack.getStackSize() < 0) { + IAEItemStack toStore = itemStack.copy(); + toStore.setStackSize(-toStore.getStackSize()); + + long diff = toStore.getStackSize(); + + // make sure strange things didn't happen... + // TODO: check if OK + final ItemStack canExtract = adaptor.simulateRemove((int) diff, toStore.getDefinition(), null); + if (canExtract.isEmpty() || canExtract.getCount() != diff) { + changed = true; + throw new GridAccessException(); + } + + toStore = Platform.poweredInsert(src, this.destination, toStore, this.interfaceRequestSource); + + if (toStore != null) { + diff -= toStore.getStackSize(); + } + + if (diff != 0) { + // extract items! + changed = true; + final ItemStack removed = adaptor.removeItems((int) diff, ItemStack.EMPTY, null); + if (removed.isEmpty()) { + throw new IllegalStateException("bad attempt at managing inventory. ( removeItems )"); + } else if (removed.getCount() != diff) { + throw new IllegalStateException("bad attempt at managing inventory. ( removeItems )"); + } + } + } + // else wtf? + } catch (final GridAccessException e) { + // :P + } + + if (changed) { + this.updatePlan(x); + } + + this.isWorking = -1; + return changed; + } + + private InventoryAdaptor getAdaptor(final int slot) { + return new AdaptorItemHandler(new RangedWrapper(this.storage, slot, slot + 1)); + } + + private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) { + try { + if (this.getInstalledUpgrades(Upgrades.CRAFTING) > 0 && itemStack != null) { + return this.craftingTracker.handleCrafting(x, itemStack.getStackSize(), itemStack, d, + this.iHost.getTileEntity().getWorld(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), + this.mySource); + } + } catch (final GridAccessException e) { + // :P + } + + return false; + } + + @Override + public int getInstalledUpgrades(final Upgrades u) { + if (this.upgrades == null) { + return 0; + } + return this.upgrades.getInstalledUpgrades(u); + } + + @Override + public TileEntity getTile() { + return (TileEntity) (this.iHost instanceof TileEntity ? this.iHost : null); + } + + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + if (this.hasConfig()) { + return (IMEMonitor) new InterfaceInventory(this); + } + + return (IMEMonitor) this.items; + } else if (channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) { + if (this.hasConfig()) { + return null; + } + + return (IMEMonitor) this.fluids; + } + + return null; + } + + private boolean hasConfig() { + return this.hasConfig; + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("storage")) { + return this.storage; + } + + if (name.equals("patterns")) { + return this.patterns; + } + + if (name.equals("config")) { + return this.config; + } + + if (name.equals("upgrades")) { + return this.upgrades; + } + + return null; + } + + public IItemHandler getStorage() { + return this.storage; + } + + @Override + public appeng.api.util.IConfigManager getConfigManager() { + return this.cm; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + if (this.getInstalledUpgrades(Upgrades.CRAFTING) == 0) { + this.cancelCrafting(); + } + this.iHost.saveChanges(); + } + + private void cancelCrafting() { + this.craftingTracker.cancel(); + } + + public IStorageMonitorable getMonitorable(final IActionSource src, final IStorageMonitorable myInterface) { + if (Platform.canAccess(this.gridProxy, src)) { + return myInterface; + } + + final DualityInterface di = this; + + return new IStorageMonitorable() { + + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + return (IMEMonitor) new InterfaceInventory(di); + } + return null; + } + }; + } + + @Override + public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table) { + if (this.hasItemsToSend() || !this.gridProxy.isActive() || !this.craftingList.contains(patternDetails)) { + return false; + } + + final TileEntity tile = this.iHost.getTileEntity(); + final World w = tile.getWorld(); + + final EnumSet possibleDirections = this.iHost.getTargets(); + for (final Direction s : possibleDirections) { + final TileEntity te = w.getTileEntity(tile.getPos().offset(s)); + if (te instanceof IInterfaceHost) { + try { + if (((IInterfaceHost) te).getInterfaceDuality().sameGrid(this.gridProxy.getGrid())) { + continue; + } + } catch (final GridAccessException e) { + continue; + } + } + + if (te instanceof ICraftingMachine) { + final ICraftingMachine cm = (ICraftingMachine) te; + if (cm.acceptsPlans()) { + if (cm.pushPattern(patternDetails, table, s.getOpposite())) { + return true; + } + continue; + } + } + + final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite()); + if (ad != null) { + if (this.isBlocking()) { + if (!ad.simulateRemove(1, ItemStack.EMPTY, null).isEmpty()) { + continue; + } + } + + if (this.acceptsItems(ad, table)) { + for (int x = 0; x < table.getSizeInventory(); x++) { + final ItemStack is = table.getStackInSlot(x); + if (!is.isEmpty()) { + final ItemStack added = ad.addItems(is); + this.addToSendList(added); + } + } + this.pushItemsOut(possibleDirections); + return true; + } + } + } + + return false; + } + + @Override + public boolean isBusy() { + if (this.hasItemsToSend()) { + return true; + } + + boolean busy = false; + + if (this.isBlocking()) { + final EnumSet possibleDirections = this.iHost.getTargets(); + final TileEntity tile = this.iHost.getTileEntity(); + final World w = tile.getWorld(); + + boolean allAreBusy = true; + + for (final Direction s : possibleDirections) { + final TileEntity te = w.getTileEntity(tile.getPos().offset(s)); + + final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite()); + if (ad != null) { + if (ad.simulateRemove(1, ItemStack.EMPTY, null).isEmpty()) { + allAreBusy = false; + break; + } + } + } + + busy = allAreBusy; + } + + return busy; + } + + private boolean sameGrid(final IGrid grid) throws GridAccessException { + return grid == this.gridProxy.getGrid(); + } + + private boolean isBlocking() { + return this.cm.getSetting(Settings.BLOCK) == YesNo.YES; + } + + private boolean acceptsItems(final InventoryAdaptor ad, final CraftingInventory table) { + for (int x = 0; x < table.getSizeInventory(); x++) { + final ItemStack is = table.getStackInSlot(x); + if (is.isEmpty()) { + continue; + } + + if (!ad.simulateAdd(is.copy()).isEmpty()) { + return false; + } + } + + return true; + } + + @Override + public void provideCrafting(final ICraftingProviderHelper craftingTracker) { + if (this.gridProxy.isActive() && this.craftingList != null) { + for (final ICraftingPatternDetails details : this.craftingList) { + details.setPriority(this.priority); + craftingTracker.addCraftingOption(this, details); + } + } + } + + public void addDrops(final List drops) { + if (this.waitingToSend != null) { + for (final ItemStack is : this.waitingToSend) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } + + for (final ItemStack is : this.upgrades) { + if (!is.isEmpty()) { + drops.add(is); + } + } + + for (final ItemStack is : this.storage) { + if (!is.isEmpty()) { + drops.add(is); + } + } + + for (final ItemStack is : this.patterns) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } + + public IUpgradeableHost getHost() { + if (this.getPart() instanceof IUpgradeableHost) { + return (IUpgradeableHost) this.getPart(); + } + if (this.getTile() instanceof IUpgradeableHost) { + return (IUpgradeableHost) this.getTile(); + } + return null; + } + + private IPart getPart() { + return (IPart) (this.iHost instanceof IPart ? this.iHost : null); + } + + public ImmutableSet getRequestedJobs() { + return this.craftingTracker.getRequestedJobs(); + } + + public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack acquired, + final Actionable mode) { + final int slot = this.craftingTracker.getSlot(link); + + if (acquired != null && slot >= 0 && slot <= this.requireWork.length) { + final InventoryAdaptor adaptor = this.getAdaptor(slot); + + if (mode == Actionable.SIMULATE) { + return AEItemStack.fromItemStack(adaptor.simulateAdd(acquired.createItemStack())); + } else { + final IAEItemStack is = AEItemStack.fromItemStack(adaptor.addItems(acquired.createItemStack())); + this.updatePlan(slot); + return is; + } + } + + return acquired; + } + + public void jobStateChange(final ICraftingLink link) { + this.craftingTracker.jobStateChange(link); + } + + public ITextComponent getTermName() { + final TileEntity hostTile = this.iHost.getTileEntity(); + final World hostWorld = hostTile.getWorld(); + + if (((ICustomNameObject) this.iHost).hasCustomInventoryName()) { + return ((ICustomNameObject) this.iHost).getCustomInventoryName(); + } + + final EnumSet possibleDirections = this.iHost.getTargets(); + for (final Direction direction : possibleDirections) { + final BlockPos targ = hostTile.getPos().offset(direction); + final TileEntity directedTile = hostWorld.getTileEntity(targ); + + if (directedTile == null) { + continue; + } + + if (directedTile instanceof IInterfaceHost) { + try { + if (((IInterfaceHost) directedTile).getInterfaceDuality().sameGrid(this.gridProxy.getGrid())) { + continue; + } + } catch (final GridAccessException e) { + continue; + } + } + + final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(directedTile, direction.getOpposite()); + if (directedTile instanceof ICraftingMachine || adaptor != null) { + if (adaptor != null && !adaptor.hasSlots()) { + continue; + } + + final BlockState directedBlockState = hostWorld.getBlockState(targ); + final Block directedBlock = directedBlockState.getBlock(); + ItemStack what = new ItemStack(directedBlock, 1); + try { + Vec3d from = new Vec3d(hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, + hostTile.getPos().getZ() + 0.5); + from = from.add(direction.getXOffset() * 0.501, direction.getYOffset() * 0.501, + direction.getZOffset() * 0.501); + final Vec3d to = from.add(direction.getXOffset(), direction.getYOffset(), direction.getZOffset()); + final BlockRayTraceResult hit = null;// hostWorld.rayTraceBlocks( from, to ); //FIXME: + // https://github.com/MinecraftForge/MinecraftForge/pull/6708 + if (hit != null && !BAD_BLOCKS.contains(directedBlock)) { + if (hit.getPos().equals(directedTile.getPos())) { + final ItemStack g = directedBlock.getPickBlock(directedBlockState, hit, hostWorld, + directedTile.getPos(), null); + if (!g.isEmpty()) { + what = g; + } + } + } + } catch (final Throwable t) { + BAD_BLOCKS.add(directedBlock); // nope! + } + + if (what.getItem() != Items.AIR) { + return new TranslationTextComponent(what.getTranslationKey()); + } + + final Item item = Item.getItemFromBlock(directedBlock); + if (item == Items.AIR) { + return new TranslationTextComponent(directedBlock.getTranslationKey()); + } + } + } + + return new StringTextComponent("Nothing"); + } + + public long getSortValue() { + final TileEntity te = this.iHost.getTileEntity(); + return (te.getPos().getZ() << 24) ^ (te.getPos().getX() << 8) ^ te.getPos().getY(); + } + + public void initialize() { + this.updateCraftingList(); + } + + public int getPriority() { + return this.priority; + } + + public void setPriority(final int newValue) { + this.priority = newValue; + this.iHost.saveChanges(); + + try { + this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode())); + } catch (final GridAccessException e) { + // :P + } + } + + public boolean hasCapability(Capability capabilityClass, Direction facing) { + return capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY + || capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR; + } + + @SuppressWarnings("unchecked") + public LazyOptional getCapability(Capability capabilityClass, Direction facing) { + if (capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this.storage); + } else if (capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR) { + return (LazyOptional) LazyOptional.of(() -> this.accessor); + } + return LazyOptional.empty(); + } + + private class InterfaceRequestSource extends MachineSource { + private final InterfaceRequestContext context; + + public InterfaceRequestSource(IActionHost v) { + super(v); + this.context = new InterfaceRequestContext(); + } + + @Override + public Optional context(Class key) { + if (key == InterfaceRequestContext.class) { + return (Optional) Optional.of(this.context); + } + + return super.context(key); + } + + } + + private class InterfaceRequestContext implements Comparable { + + @Override + public int compareTo(Integer o) { + return Integer.compare(DualityInterface.this.priority, o); + } + } + + private class InterfaceInventory extends MEMonitorIInventory { + + public InterfaceInventory(final DualityInterface tileInterface) { + super(new AdaptorItemHandler(tileInterface.storage)); + this.setActionSource(new MachineSource(DualityInterface.this.iHost)); + } + + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + final Optional context = src.context(InterfaceRequestContext.class); + final boolean isInterface = context.isPresent(); + + if (isInterface) { + return input; + } + + return super.injectItems(input, type, src); + } + + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable type, final IActionSource src) { + final Optional context = src.context(InterfaceRequestContext.class); + final boolean hasLowerOrEqualPriority = context.map(c -> c.compareTo(DualityInterface.this.priority) <= 0) + .orElse(false); + + if (hasLowerOrEqualPriority) { + return null; + } + + return super.extractItems(request, type, src); + } + } + + private class Accessor implements IStorageMonitorableAccessor { + + @Nullable + @Override + public IStorageMonitorable getInventory(IActionSource src) { + return DualityInterface.this.getMonitorable(src, DualityInterface.this); + } + + } } diff --git a/src/main/java/appeng/helpers/IContainerCraftingPacket.java b/src/main/java/appeng/helpers/IContainerCraftingPacket.java index 338062b12..da43192cb 100644 --- a/src/main/java/appeng/helpers/IContainerCraftingPacket.java +++ b/src/main/java/appeng/helpers/IContainerCraftingPacket.java @@ -18,41 +18,38 @@ package appeng.helpers; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionSource; +public interface IContainerCraftingPacket { -public interface IContainerCraftingPacket -{ + /** + * @return gain access to network infrastructure. + */ + IGridNode getNetworkNode(); - /** - * @return gain access to network infrastructure. - */ - IGridNode getNetworkNode(); + /** + * @param string name of inventory + * + * @return the inventory of the part/tile by name. + */ + IItemHandler getInventoryByName(String string); - /** - * @param string name of inventory - * - * @return the inventory of the part/tile by name. - */ - IItemHandler getInventoryByName( String string ); + /** + * @return who are we? + */ + IActionSource getActionSource(); - /** - * @return who are we? - */ - IActionSource getActionSource(); + /** + * @return consume items? + */ + boolean useRealItems(); - /** - * @return consume items? - */ - boolean useRealItems(); - - /** - * @return array of view cells - */ - ItemStack[] getViewCells(); + /** + * @return array of view cells + */ + ItemStack[] getViewCells(); } diff --git a/src/main/java/appeng/helpers/ICustomNameObject.java b/src/main/java/appeng/helpers/ICustomNameObject.java index e9db7a058..e6cbd0b14 100644 --- a/src/main/java/appeng/helpers/ICustomNameObject.java +++ b/src/main/java/appeng/helpers/ICustomNameObject.java @@ -18,13 +18,11 @@ package appeng.helpers; - import net.minecraft.util.text.ITextComponent; -public interface ICustomNameObject -{ +public interface ICustomNameObject { - ITextComponent getCustomInventoryName(); + ITextComponent getCustomInventoryName(); - boolean hasCustomInventoryName(); + boolean hasCustomInventoryName(); } diff --git a/src/main/java/appeng/helpers/IInterfaceHost.java b/src/main/java/appeng/helpers/IInterfaceHost.java index 522ed0963..8d8dff9bd 100644 --- a/src/main/java/appeng/helpers/IInterfaceHost.java +++ b/src/main/java/appeng/helpers/IInterfaceHost.java @@ -18,7 +18,6 @@ package appeng.helpers; - import java.util.EnumSet; import net.minecraft.tileentity.TileEntity; @@ -28,15 +27,13 @@ import appeng.api.implementations.IUpgradeableHost; import appeng.api.networking.crafting.ICraftingProvider; import appeng.api.networking.crafting.ICraftingRequester; +public interface IInterfaceHost extends ICraftingProvider, IUpgradeableHost, ICraftingRequester { -public interface IInterfaceHost extends ICraftingProvider, IUpgradeableHost, ICraftingRequester -{ + DualityInterface getInterfaceDuality(); - DualityInterface getInterfaceDuality(); + EnumSet getTargets(); - EnumSet getTargets(); + TileEntity getTileEntity(); - TileEntity getTileEntity(); - - void saveChanges(); + void saveChanges(); } diff --git a/src/main/java/appeng/helpers/IMouseWheelItem.java b/src/main/java/appeng/helpers/IMouseWheelItem.java index cc223005d..16294b70e 100644 --- a/src/main/java/appeng/helpers/IMouseWheelItem.java +++ b/src/main/java/appeng/helpers/IMouseWheelItem.java @@ -18,12 +18,9 @@ package appeng.helpers; - import net.minecraft.item.ItemStack; +public interface IMouseWheelItem { -public interface IMouseWheelItem -{ - - void onWheel( ItemStack is, boolean up ); + void onWheel(ItemStack is, boolean up); } diff --git a/src/main/java/appeng/helpers/IPriorityHost.java b/src/main/java/appeng/helpers/IPriorityHost.java index 0e5c0ee0c..25bdd4dda 100644 --- a/src/main/java/appeng/helpers/IPriorityHost.java +++ b/src/main/java/appeng/helpers/IPriorityHost.java @@ -18,31 +18,27 @@ package appeng.helpers; - import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; +public interface IPriorityHost { + /** + * get current priority. + */ + int getPriority(); + /** + * set new priority + */ + void setPriority(int newValue); -public interface IPriorityHost -{ + ItemStack getItemStackRepresentation(); - /** - * get current priority. - */ - int getPriority(); - - /** - * set new priority - */ - void setPriority( int newValue ); - - ItemStack getItemStackRepresentation(); - - /** - * Used to show the user interface of this part when returning from the priority GUI. - */ - ContainerType getContainerType(); + /** + * Used to show the user interface of this part when returning from the priority + * GUI. + */ + ContainerType getContainerType(); } diff --git a/src/main/java/appeng/helpers/InvalidPatternHelper.java b/src/main/java/appeng/helpers/InvalidPatternHelper.java index 851fa7715..b1d1d90e9 100644 --- a/src/main/java/appeng/helpers/InvalidPatternHelper.java +++ b/src/main/java/appeng/helpers/InvalidPatternHelper.java @@ -18,8 +18,9 @@ package appeng.helpers; +import java.util.ArrayList; +import java.util.List; -import appeng.util.Platform; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; @@ -27,133 +28,110 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; -import java.util.ArrayList; -import java.util.List; +import appeng.util.Platform; +public class InvalidPatternHelper { -public class InvalidPatternHelper -{ + private final List outputs = new ArrayList<>(); + private final List inputs = new ArrayList<>(); + private final boolean isCrafting; + private final boolean canSubstitute; - private final List outputs = new ArrayList<>(); - private final List inputs = new ArrayList<>(); - private final boolean isCrafting; - private final boolean canSubstitute; + public InvalidPatternHelper(final ItemStack is) { + final CompoundNBT encodedValue = is.getTag(); - public InvalidPatternHelper( final ItemStack is ) - { - final CompoundNBT encodedValue = is.getTag(); + if (encodedValue == null) { + throw new IllegalArgumentException("No pattern here!"); + } - if( encodedValue == null ) - { - throw new IllegalArgumentException( "No pattern here!" ); - } + final ListNBT inTag = encodedValue.getList("in", 10); + final ListNBT outTag = encodedValue.getList("out", 10); + this.isCrafting = encodedValue.getBoolean("crafting"); - final ListNBT inTag = encodedValue.getList( "in", 10 ); - final ListNBT outTag = encodedValue.getList( "out", 10 ); - this.isCrafting = encodedValue.getBoolean( "crafting" ); + this.canSubstitute = this.isCrafting && encodedValue.getBoolean("substitute"); - this.canSubstitute = this.isCrafting && encodedValue.getBoolean( "substitute" ); + for (int i = 0; i < outTag.size(); i++) { + this.outputs.add(new PatternIngredient(outTag.getCompound(i))); + } - for( int i = 0; i < outTag.size(); i++ ) - { - this.outputs.add( new PatternIngredient( outTag.getCompound( i ) ) ); - } + for (int i = 0; i < inTag.size(); i++) { + CompoundNBT in = inTag.getCompound(i); - for( int i = 0; i < inTag.size(); i++ ) - { - CompoundNBT in = inTag.getCompound( i ); + // skip empty slots in the crafting grid + if (in.isEmpty()) { + continue; + } - // skip empty slots in the crafting grid - if( in.isEmpty() ) - { - continue; - } + this.inputs.add(new PatternIngredient(in)); + } + } - this.inputs.add( new PatternIngredient( in ) ); - } - } + public List getOutputs() { + return this.outputs; + } - public List getOutputs() - { - return this.outputs; - } + public List getInputs() { + return this.inputs; + } - public List getInputs() - { - return this.inputs; - } + public boolean isCraftable() { + return this.isCrafting; + } - public boolean isCraftable() - { - return this.isCrafting; - } + public boolean canSubstitute() { + return this.canSubstitute; + } - public boolean canSubstitute() - { - return this.canSubstitute; - } + public class PatternIngredient { + private String id; + private int count; + private int damage; - public class PatternIngredient - { - private String id; - private int count; - private int damage; + private ItemStack stack; - private ItemStack stack; + public PatternIngredient(CompoundNBT tag) { + this.stack = ItemStack.read(tag); - public PatternIngredient( CompoundNBT tag ) - { - this.stack = ItemStack.read( tag ); + if (this.stack.isEmpty()) { + this.id = tag.getString("id"); + this.count = tag.getByte("Count"); + this.damage = Math.max(0, tag.getShort("Damage")); + } + } - if( this.stack.isEmpty() ) - { - this.id = tag.getString( "id" ); - this.count = tag.getByte( "Count" ); - this.damage = Math.max( 0, tag.getShort( "Damage" ) ); - } - } + public boolean isValid() { + return !this.stack.isEmpty(); + } - public boolean isValid() - { - return !this.stack.isEmpty(); - } + public ITextComponent getName() { + return this.isValid() ? Platform.getItemDisplayName(this.stack) + : new StringTextComponent(this.id + '@' + this.getDamage()); + } - public ITextComponent getName() - { - return this.isValid() ? Platform.getItemDisplayName( this.stack ) - : new StringTextComponent(this.id + '@' + this.getDamage()); - } + public int getDamage() { + return this.isValid() ? this.stack.getDamage() : this.damage; + } - public int getDamage() - { - return this.isValid() ? this.stack.getDamage() : this.damage; - } + public int getCount() { + return this.isValid() ? this.stack.getCount() : this.count; + } - public int getCount() - { - return this.isValid() ? this.stack.getCount() : this.count; - } + public ItemStack getItem() { + if (!this.isValid()) { + throw new IllegalArgumentException("There is no valid ItemStack for this PatternIngredient"); + } - public ItemStack getItem() - { - if( !this.isValid() ) - { - throw new IllegalArgumentException( "There is no valid ItemStack for this PatternIngredient" ); - } + return this.stack; + } - return this.stack; - } + public ITextComponent getFormattedToolTip() { + ITextComponent result = new StringTextComponent(this.getCount() + " ").appendSibling(this.getName()); - public ITextComponent getFormattedToolTip() - { - ITextComponent result = new StringTextComponent( this.getCount() + " " ).appendSibling( this.getName() ); + if (!this.isValid()) { + result.applyTextStyle(TextFormatting.RED); + } - if( !this.isValid() ) - { - result.applyTextStyle(TextFormatting.RED); - } - - return result; - } - } + return result; + } + } } diff --git a/src/main/java/appeng/helpers/InventoryAction.java b/src/main/java/appeng/helpers/InventoryAction.java index 697ea0b08..fa268909b 100644 --- a/src/main/java/appeng/helpers/InventoryAction.java +++ b/src/main/java/appeng/helpers/InventoryAction.java @@ -18,30 +18,16 @@ package appeng.helpers; +public enum InventoryAction { + // standard vanilla mechanics. + PICKUP_OR_SET_DOWN, SPLIT_OR_PLACE_SINGLE, CREATIVE_DUPLICATE, SHIFT_CLICK, -public enum InventoryAction -{ - // standard vanilla mechanics. - PICKUP_OR_SET_DOWN, - SPLIT_OR_PLACE_SINGLE, - CREATIVE_DUPLICATE, - SHIFT_CLICK, + // crafting term + CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, - // crafting term - CRAFT_STACK, - CRAFT_ITEM, - CRAFT_SHIFT, + // fluid term + FILL_ITEM, EMPTY_ITEM, - // fluid term - FILL_ITEM, - EMPTY_ITEM, - - // extra... - MOVE_REGION, - PICKUP_SINGLE, - UPDATE_HAND, - ROLL_UP, - ROLL_DOWN, - AUTO_CRAFT, - PLACE_SINGLE + // extra... + MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLL_UP, ROLL_DOWN, AUTO_CRAFT, PLACE_SINGLE } diff --git a/src/main/java/appeng/helpers/LocationRotation.java b/src/main/java/appeng/helpers/LocationRotation.java index 0b83274b6..d2b4cc499 100644 --- a/src/main/java/appeng/helpers/LocationRotation.java +++ b/src/main/java/appeng/helpers/LocationRotation.java @@ -18,55 +18,46 @@ package appeng.helpers; - import net.minecraft.util.Direction; import net.minecraft.world.IBlockReader; import appeng.api.util.IOrientable; +public class LocationRotation implements IOrientable { -public class LocationRotation implements IOrientable -{ + private final IBlockReader w; + private final int x; + private final int y; + private final int z; - private final IBlockReader w; - private final int x; - private final int y; - private final int z; + public LocationRotation(final IBlockReader world, final int x, final int y, final int z) { + this.w = world; + this.x = x; + this.y = y; + this.z = z; + } - public LocationRotation( final IBlockReader world, final int x, final int y, final int z ) - { - this.w = world; - this.x = x; - this.y = y; - this.z = z; - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public Direction getForward() { + if (this.getUp().getYOffset() == 0) { + return Direction.UP; + } + return Direction.SOUTH; + } - @Override - public Direction getForward() - { - if( this.getUp().getYOffset() == 0 ) - { - return Direction.UP; - } - return Direction.SOUTH; - } + @Override + public Direction getUp() { + final int num = Math.abs(this.x + this.y + this.z) % 6; + return Direction.values()[num]; + } - @Override - public Direction getUp() - { - final int num = Math.abs( this.x + this.y + this.z ) % 6; - return Direction.values()[num]; - } + @Override + public void setOrientation(final Direction forward, final Direction up) { - @Override - public void setOrientation( final Direction forward, final Direction up ) - { - - } + } } diff --git a/src/main/java/appeng/helpers/MetaRotation.java b/src/main/java/appeng/helpers/MetaRotation.java index 3b3ec9ede..6b297beea 100644 --- a/src/main/java/appeng/helpers/MetaRotation.java +++ b/src/main/java/appeng/helpers/MetaRotation.java @@ -18,7 +18,6 @@ package appeng.helpers; - import net.minecraft.block.BlockState; import net.minecraft.state.Property; import net.minecraft.util.Direction; @@ -30,82 +29,68 @@ import net.minecraft.world.World; import appeng.api.util.IOrientable; import appeng.decorative.solid.BlockQuartzPillar; +public class MetaRotation implements IOrientable { -public class MetaRotation implements IOrientable -{ + private final Property facingProp; + private final IBlockReader w; + private final BlockPos pos; - private final Property facingProp; - private final IBlockReader w; - private final BlockPos pos; + public MetaRotation(final IBlockReader world, final BlockPos pos, final Property facingProp) { + this.w = world; + this.pos = pos; + this.facingProp = facingProp; + } - public MetaRotation( final IBlockReader world, final BlockPos pos, final Property facingProp ) - { - this.w = world; - this.pos = pos; - this.facingProp = facingProp; - } + @Override + public boolean canBeRotated() { + return true; + } - @Override - public boolean canBeRotated() - { - return true; - } + @Override + public Direction getForward() { + if (this.getUp().getYOffset() == 0) { + return Direction.UP; + } + return Direction.SOUTH; + } - @Override - public Direction getForward() - { - if( this.getUp().getYOffset() == 0 ) - { - return Direction.UP; - } - return Direction.SOUTH; - } + @Override + public Direction getUp() { + final BlockState state = this.w.getBlockState(this.pos); - @Override - public Direction getUp() - { - final BlockState state = this.w.getBlockState( this.pos ); + if (this.facingProp != null && state.has(this.facingProp)) { + return state.get(this.facingProp); + } - if( this.facingProp != null && state.has(this.facingProp) ) - { - return state.get( this.facingProp ); - } + // TODO 1.10.2-R - Temp + if (state.has(BlockQuartzPillar.AXIS)) { + Axis a = state.get(BlockQuartzPillar.AXIS); + switch (a) { + case X: + return Direction.EAST; + case Z: + return Direction.SOUTH; + default: + case Y: + return Direction.UP; + } + } - // TODO 1.10.2-R - Temp - if (state.has(BlockQuartzPillar.AXIS)) { - Axis a = state.get(BlockQuartzPillar.AXIS); - switch (a) { - case X: - return Direction.EAST; - case Z: - return Direction.SOUTH; - default: - case Y: - return Direction.UP; - } - } + return Direction.UP; + } - return Direction.UP; - } - - @Override - public void setOrientation( final Direction forward, final Direction up ) - { - if( this.w instanceof World ) - { - if( this.facingProp != null ) - { - ( (World) this.w ).setBlockState( this.pos, this.w.getBlockState( this.pos ).with( this.facingProp, up ) ); - } - else - { - // TODO 1.10.2-R - Temp - ( (World) this.w ).setBlockState( this.pos, this.w.getBlockState( this.pos ).with( BlockQuartzPillar.AXIS, up.getAxis() ) ); - } - } - else - { - throw new IllegalStateException( this.w.getClass().getName() + " received, expected World" ); - } - } + @Override + public void setOrientation(final Direction forward, final Direction up) { + if (this.w instanceof World) { + if (this.facingProp != null) { + ((World) this.w).setBlockState(this.pos, this.w.getBlockState(this.pos).with(this.facingProp, up)); + } else { + // TODO 1.10.2-R - Temp + ((World) this.w).setBlockState(this.pos, + this.w.getBlockState(this.pos).with(BlockQuartzPillar.AXIS, up.getAxis())); + } + } else { + throw new IllegalStateException(this.w.getClass().getName() + " received, expected World"); + } + } } diff --git a/src/main/java/appeng/helpers/MultiCraftingTracker.java b/src/main/java/appeng/helpers/MultiCraftingTracker.java index 9e8021a35..e8edf1ae9 100644 --- a/src/main/java/appeng/helpers/MultiCraftingTracker.java +++ b/src/main/java/appeng/helpers/MultiCraftingTracker.java @@ -18,7 +18,6 @@ package appeng.helpers; - import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -37,255 +36,197 @@ import appeng.api.networking.security.IActionSource; import appeng.api.storage.data.IAEItemStack; import appeng.util.InventoryAdaptor; +public class MultiCraftingTracker { -public class MultiCraftingTracker -{ + private final int size; + private final ICraftingRequester owner; - private final int size; - private final ICraftingRequester owner; + private Future[] jobs = null; + private ICraftingLink[] links = null; - private Future[] jobs = null; - private ICraftingLink[] links = null; + public MultiCraftingTracker(final ICraftingRequester o, final int size) { + this.owner = o; + this.size = size; + } - public MultiCraftingTracker( final ICraftingRequester o, final int size ) - { - this.owner = o; - this.size = size; - } + public void readFromNBT(final CompoundNBT extra) { + for (int x = 0; x < this.size; x++) { + final CompoundNBT link = extra.getCompound("links-" + x); - public void readFromNBT( final CompoundNBT extra ) - { - for( int x = 0; x < this.size; x++ ) - { - final CompoundNBT link = extra.getCompound( "links-" + x ); + if (link != null && !link.isEmpty()) { + this.setLink(x, AEApi.instance().storage().loadCraftingLink(link, this.owner)); + } + } + } - if( link != null && !link.isEmpty() ) - { - this.setLink( x, AEApi.instance().storage().loadCraftingLink( link, this.owner ) ); - } - } - } + public void writeToNBT(final CompoundNBT extra) { + for (int x = 0; x < this.size; x++) { + final ICraftingLink link = this.getLink(x); - public void writeToNBT( final CompoundNBT extra ) - { - for( int x = 0; x < this.size; x++ ) - { - final ICraftingLink link = this.getLink( x ); + if (link != null) { + final CompoundNBT ln = new CompoundNBT(); + link.writeToNBT(ln); + extra.put("links-" + x, ln); + } + } + } - if( link != null ) - { - final CompoundNBT ln = new CompoundNBT(); - link.writeToNBT( ln ); - extra.put( "links-" + x, ln ); - } - } - } + public boolean handleCrafting(final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, + final World w, final IGrid g, final ICraftingGrid cg, final IActionSource mySrc) { + if (ais != null && d.simulateAdd(ais.createItemStack()).isEmpty()) { + final Future craftingJob = this.getJob(x); - public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final IActionSource mySrc ) - { - if( ais != null && d.simulateAdd( ais.createItemStack() ).isEmpty() ) - { - final Future craftingJob = this.getJob( x ); + if (this.getLink(x) != null) { + return false; + } else if (craftingJob != null) { - if( this.getLink( x ) != null ) - { - return false; - } - else if( craftingJob != null ) - { + try { + ICraftingJob job = null; + if (craftingJob.isDone()) { + job = craftingJob.get(); + } - try - { - ICraftingJob job = null; - if( craftingJob.isDone() ) - { - job = craftingJob.get(); - } + if (job != null) { + final ICraftingLink link = cg.submitJob(job, this.owner, null, false, mySrc); - if( job != null ) - { - final ICraftingLink link = cg.submitJob( job, this.owner, null, false, mySrc ); + this.setJob(x, null); - this.setJob( x, null ); + if (link != null) { + this.setLink(x, link); - if( link != null ) - { - this.setLink( x, link ); + return true; + } + } + } catch (final InterruptedException e) { + // :P + } catch (final ExecutionException e) { + // :P + } + } else { + if (this.getLink(x) == null) { + final IAEItemStack aisC = ais.copy(); + aisC.setStackSize(itemToCraft); - return true; - } - } - } - catch( final InterruptedException e ) - { - // :P - } - catch( final ExecutionException e ) - { - // :P - } - } - else - { - if( this.getLink( x ) == null ) - { - final IAEItemStack aisC = ais.copy(); - aisC.setStackSize( itemToCraft ); + this.setJob(x, cg.beginCraftingJob(w, g, mySrc, aisC, null)); + } + } + } + return false; + } - this.setJob( x, cg.beginCraftingJob( w, g, mySrc, aisC, null ) ); - } - } - } - return false; - } + public ImmutableSet getRequestedJobs() { + if (this.links == null) { + return ImmutableSet.of(); + } - public ImmutableSet getRequestedJobs() - { - if( this.links == null ) - { - return ImmutableSet.of(); - } + return ImmutableSet.copyOf(new NonNullArrayIterator<>(this.links)); + } - return ImmutableSet.copyOf( new NonNullArrayIterator<>( this.links ) ); - } + public void jobStateChange(final ICraftingLink link) { + if (this.links != null) { + for (int x = 0; x < this.links.length; x++) { + if (this.links[x] == link) { + this.setLink(x, null); + return; + } + } + } + } - public void jobStateChange( final ICraftingLink link ) - { - if( this.links != null ) - { - for( int x = 0; x < this.links.length; x++ ) - { - if( this.links[x] == link ) - { - this.setLink( x, null ); - return; - } - } - } - } + int getSlot(final ICraftingLink link) { + if (this.links != null) { + for (int x = 0; x < this.links.length; x++) { + if (this.links[x] == link) { + return x; + } + } + } - int getSlot( final ICraftingLink link ) - { - if( this.links != null ) - { - for( int x = 0; x < this.links.length; x++ ) - { - if( this.links[x] == link ) - { - return x; - } - } - } + return -1; + } - return -1; - } + void cancel() { + if (this.links != null) { + for (final ICraftingLink l : this.links) { + if (l != null) { + l.cancel(); + } + } - void cancel() - { - if( this.links != null ) - { - for( final ICraftingLink l : this.links ) - { - if( l != null ) - { - l.cancel(); - } - } + this.links = null; + } - this.links = null; - } + if (this.jobs != null) { + for (final Future l : this.jobs) { + if (l != null) { + l.cancel(true); + } + } - if( this.jobs != null ) - { - for( final Future l : this.jobs ) - { - if( l != null ) - { - l.cancel( true ); - } - } + this.jobs = null; + } + } - this.jobs = null; - } - } + boolean isBusy(final int slot) { + return this.getLink(slot) != null || this.getJob(slot) != null; + } - boolean isBusy( final int slot ) - { - return this.getLink( slot ) != null || this.getJob( slot ) != null; - } + private ICraftingLink getLink(final int slot) { + if (this.links == null) { + return null; + } - private ICraftingLink getLink( final int slot ) - { - if( this.links == null ) - { - return null; - } + return this.links[slot]; + } - return this.links[slot]; - } + private void setLink(final int slot, final ICraftingLink l) { + if (this.links == null) { + this.links = new ICraftingLink[this.size]; + } - private void setLink( final int slot, final ICraftingLink l ) - { - if( this.links == null ) - { - this.links = new ICraftingLink[this.size]; - } + this.links[slot] = l; - this.links[slot] = l; + boolean hasStuff = false; + for (int x = 0; x < this.links.length; x++) { + final ICraftingLink g = this.links[x]; - boolean hasStuff = false; - for( int x = 0; x < this.links.length; x++ ) - { - final ICraftingLink g = this.links[x]; + if (g == null || g.isCanceled() || g.isDone()) { + this.links[x] = null; + } else { + hasStuff = true; + } + } - if( g == null || g.isCanceled() || g.isDone() ) - { - this.links[x] = null; - } - else - { - hasStuff = true; - } - } + if (!hasStuff) { + this.links = null; + } + } - if( !hasStuff ) - { - this.links = null; - } - } + private Future getJob(final int slot) { + if (this.jobs == null) { + return null; + } - private Future getJob( final int slot ) - { - if( this.jobs == null ) - { - return null; - } + return this.jobs[slot]; + } - return this.jobs[slot]; - } + private void setJob(final int slot, final Future l) { + if (this.jobs == null) { + this.jobs = new Future[this.size]; + } - private void setJob( final int slot, final Future l ) - { - if( this.jobs == null ) - { - this.jobs = new Future[this.size]; - } + this.jobs[slot] = l; - this.jobs[slot] = l; + boolean hasStuff = false; - boolean hasStuff = false; + for (final Future job : this.jobs) { + if (job != null) { + hasStuff = true; + } + } - for( final Future job : this.jobs ) - { - if( job != null ) - { - hasStuff = true; - } - } - - if( !hasStuff ) - { - this.jobs = null; - } - } + if (!hasStuff) { + this.jobs = null; + } + } } diff --git a/src/main/java/appeng/helpers/NonNullArrayIterator.java b/src/main/java/appeng/helpers/NonNullArrayIterator.java index 7c964168b..48fd54ce6 100644 --- a/src/main/java/appeng/helpers/NonNullArrayIterator.java +++ b/src/main/java/appeng/helpers/NonNullArrayIterator.java @@ -18,44 +18,36 @@ package appeng.helpers; - import java.util.Iterator; +public class NonNullArrayIterator implements Iterator { -public class NonNullArrayIterator implements Iterator -{ + private final E[] g; + private int offset = 0; - private final E[] g; - private int offset = 0; + public NonNullArrayIterator(final E[] o) { + this.g = o; + } - public NonNullArrayIterator( final E[] o ) - { - this.g = o; - } + @Override + public boolean hasNext() { + while (this.offset < this.g.length && this.g[this.offset] == null) { + this.offset++; + } - @Override - public boolean hasNext() - { - while( this.offset < this.g.length && this.g[this.offset] == null ) - { - this.offset++; - } + return this.offset != this.g.length; + } - return this.offset != this.g.length; - } + @Override + public E next() { + final E result = this.g[this.offset]; + this.offset++; - @Override - public E next() - { - final E result = this.g[this.offset]; - this.offset++; + return result; + } - return result; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/helpers/NullRotation.java b/src/main/java/appeng/helpers/NullRotation.java index c8abc4305..233f7ada3 100644 --- a/src/main/java/appeng/helpers/NullRotation.java +++ b/src/main/java/appeng/helpers/NullRotation.java @@ -18,41 +18,33 @@ package appeng.helpers; - import net.minecraft.util.Direction; import appeng.api.util.IOrientable; +public class NullRotation implements IOrientable { -public class NullRotation implements IOrientable -{ + public NullRotation() { - public NullRotation() - { + } - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public Direction getForward() { + return Direction.SOUTH; + } - @Override - public Direction getForward() - { - return Direction.SOUTH; - } + @Override + public Direction getUp() { + return Direction.UP; + } - @Override - public Direction getUp() - { - return Direction.UP; - } + @Override + public void setOrientation(final Direction forward, final Direction up) { - @Override - public void setOrientation( final Direction forward, final Direction up ) - { - - } + } } diff --git a/src/main/java/appeng/helpers/PatternHelper.java b/src/main/java/appeng/helpers/PatternHelper.java index 0fe45c2e8..0ddb16cc8 100644 --- a/src/main/java/appeng/helpers/PatternHelper.java +++ b/src/main/java/appeng/helpers/PatternHelper.java @@ -18,14 +18,8 @@ package appeng.helpers; +import java.util.*; -import appeng.api.AEApi; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEItemStack; -import appeng.container.ContainerNull; -import appeng.util.Platform; -import appeng.util.item.AEItemStack; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,417 +29,352 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; import net.minecraft.world.World; -import java.util.*; - - -public class PatternHelper implements ICraftingPatternDetails, Comparable -{ - - private final ItemStack patternItem; - private final CraftingInventory crafting = new CraftingInventory( new ContainerNull(), 3, 3 ); - private final CraftingInventory testFrame = new CraftingInventory( new ContainerNull(), 3, 3 ); - private final ItemStack correctOutput; - private final ICraftingRecipe standardRecipe; - private final IAEItemStack[] condensedInputs; - private final IAEItemStack[] condensedOutputs; - private final IAEItemStack[] inputs; - private final IAEItemStack[] outputs; - private final boolean isCrafting; - private final boolean canSubstitute; - private final Set failCache = new HashSet<>(); - private final Set passCache = new HashSet<>(); - private final IAEItemStack pattern; - private int priority = 0; - - public PatternHelper( final ItemStack is, final World w ) - { - final CompoundNBT encodedValue = is.getTag(); - - if( encodedValue == null ) - { - throw new IllegalArgumentException( "No pattern here!" ); - } - - final ListNBT inTag = encodedValue.getList( "in", 10 ); - final ListNBT outTag = encodedValue.getList( "out", 10 ); - this.isCrafting = encodedValue.getBoolean( "crafting" ); - - this.canSubstitute = this.isCrafting && encodedValue.getBoolean( "substitute" ); - this.patternItem = is; - this.pattern = AEItemStack.fromItemStack( is ); - - final List in = new ArrayList<>(); - final List out = new ArrayList<>(); - - for( int x = 0; x < inTag.size(); x++ ) - { - CompoundNBT ingredient = inTag.getCompound( x ); - final ItemStack gs = ItemStack.read( ingredient ); - - if( !ingredient.isEmpty() && gs.isEmpty() ) - { - throw new IllegalArgumentException( "No pattern here!" ); - } - - this.crafting.setInventorySlotContents( x, gs ); - - if( !gs.isEmpty() && ( !this.isCrafting || !gs.hasTag() ) ) - { - this.markItemAs( x, gs, TestStatus.ACCEPT ); - } - - in.add( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( gs ) ); - this.testFrame.setInventorySlotContents( x, gs ); - } - - if( this.isCrafting ) - { - this.standardRecipe = w.getRecipeManager().getRecipe( IRecipeType.CRAFTING, this.crafting, w ).orElse( null ); - - if( this.standardRecipe != null ) - { - this.correctOutput = this.standardRecipe.getCraftingResult( this.crafting ); - out.add( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.correctOutput ) ); - } - else - { - throw new IllegalStateException( "No pattern here!" ); - } - } - else - { - this.standardRecipe = null; - this.correctOutput = ItemStack.EMPTY; - - for( int x = 0; x < outTag.size(); x++ ) - { - CompoundNBT resultItemTag = outTag.getCompound( x ); - final ItemStack gs = ItemStack.read( resultItemTag ); - - if( !resultItemTag.isEmpty() && gs.isEmpty() ) - { - throw new IllegalArgumentException( "No pattern here!" ); - } - - if( !gs.isEmpty() ) - { - out.add( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( gs ) ); - } - } - } - - this.outputs = out.toArray(new IAEItemStack[0]); - this.inputs = in.toArray(new IAEItemStack[0]); - - final Map tmpOutputs = new HashMap<>(); - - for( final IAEItemStack io : this.outputs ) - { - if( io == null ) - { - continue; - } - - final IAEItemStack g = tmpOutputs.get( io ); - - if( g == null ) - { - tmpOutputs.put( io, io.copy() ); - } - else - { - g.add( io ); - } - } - - final Map tmpInputs = new HashMap<>(); - - for( final IAEItemStack io : this.inputs ) - { - if( io == null ) - { - continue; - } - - final IAEItemStack g = tmpInputs.get( io ); - - if( g == null ) - { - tmpInputs.put( io, io.copy() ); - } - else - { - g.add( io ); - } - } - - if( tmpOutputs.isEmpty() || tmpInputs.isEmpty() ) - { - throw new IllegalStateException( "No pattern here!" ); - } - - this.condensedInputs = new IAEItemStack[tmpInputs.size()]; - int offset = 0; - - for( final IAEItemStack io : tmpInputs.values() ) - { - this.condensedInputs[offset] = io; - offset++; - } - - offset = 0; - this.condensedOutputs = new IAEItemStack[tmpOutputs.size()]; - - for( final IAEItemStack io : tmpOutputs.values() ) - { - this.condensedOutputs[offset] = io; - offset++; - } - } - - private void markItemAs( final int slotIndex, final ItemStack i, final TestStatus b ) - { - if( b == TestStatus.TEST || i.hasTag() ) - { - return; - } - - ( b == TestStatus.ACCEPT ? this.passCache : this.failCache ).add( new TestLookup( slotIndex, i ) ); - } - - @Override - public ItemStack getPattern() - { - return this.patternItem; - } - - @Override - public synchronized boolean isValidItemForSlot( final int slotIndex, final ItemStack i, final World w ) - { - if( !this.isCrafting ) - { - throw new IllegalStateException( "Only crafting recipes supported." ); - } - - final TestStatus result = this.getStatus( slotIndex, i ); - - switch( result ) - { - case ACCEPT: - return true; - case DECLINE: - return false; - case TEST: - default: - break; - } - - for( int x = 0; x < this.crafting.getSizeInventory(); x++ ) - { - this.testFrame.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) ); - } - - this.testFrame.setInventorySlotContents( slotIndex, i ); - - if( this.standardRecipe.matches( this.testFrame, w ) ) - { - final ItemStack testOutput = this.standardRecipe.getCraftingResult( this.testFrame ); - - if( Platform.itemComparisons().isSameItem( this.correctOutput, testOutput ) ) - { - this.testFrame.setInventorySlotContents( slotIndex, this.crafting.getStackInSlot( slotIndex ) ); - this.markItemAs( slotIndex, i, TestStatus.ACCEPT ); - return true; - } - } - - this.markItemAs( slotIndex, i, TestStatus.DECLINE ); - return false; - } - - @Override - public boolean isCraftable() - { - return this.isCrafting; - } - - @Override - public IAEItemStack[] getInputs() - { - return this.inputs; - } - - @Override - public IAEItemStack[] getCondensedInputs() - { - return this.condensedInputs; - } - - @Override - public IAEItemStack[] getCondensedOutputs() - { - return this.condensedOutputs; - } - - @Override - public IAEItemStack[] getOutputs() - { - return this.outputs; - } - - @Override - public boolean canSubstitute() - { - return this.canSubstitute; - } - - @Override - public ItemStack getOutput( final CraftingInventory craftingInv, final World w ) - { - if( !this.isCrafting ) - { - throw new IllegalStateException( "Only crafting recipes supported." ); - } - - for( int x = 0; x < craftingInv.getSizeInventory(); x++ ) - { - if( !this.isValidItemForSlot( x, craftingInv.getStackInSlot( x ), w ) ) - { - return ItemStack.EMPTY; - } - } - - if( this.outputs != null && this.outputs.length > 0 ) - { - return this.outputs[0].createItemStack(); - } - - return ItemStack.EMPTY; - } - - private TestStatus getStatus( final int slotIndex, final ItemStack i ) - { - if( this.crafting.getStackInSlot( slotIndex ).isEmpty() ) - { - return i.isEmpty() ? TestStatus.ACCEPT : TestStatus.DECLINE; - } - - if( i.isEmpty() ) - { - return TestStatus.DECLINE; - } - - if( i.hasTag() ) - { - return TestStatus.TEST; - } - - if( this.passCache.contains( new TestLookup( slotIndex, i ) ) ) - { - return TestStatus.ACCEPT; - } - - if( this.failCache.contains( new TestLookup( slotIndex, i ) ) ) - { - return TestStatus.DECLINE; - } - - return TestStatus.TEST; - } - - @Override - public int getPriority() - { - return this.priority; - } - - @Override - public void setPriority( final int priority ) - { - this.priority = priority; - } - - @Override - public int compareTo( final PatternHelper o ) - { - return Integer.compare( o.priority, this.priority ); - } - - @Override - public int hashCode() - { - return this.pattern.hashCode(); - } - - @Override - public boolean equals( final Object obj ) - { - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } - - final PatternHelper other = (PatternHelper) obj; - - if( this.pattern != null && other.pattern != null ) - { - return this.pattern.equals( other.pattern ); - } - return false; - } - - private enum TestStatus - { - ACCEPT, DECLINE, TEST - } - - private static final class TestLookup - { - - private final int slot; - private final int ref; - private final int hash; - - public TestLookup( final int slot, final ItemStack i ) - { - this( slot, i.getItem(), i.getDamage() ); - } - - public TestLookup( final int slot, final Item item, final int dmg ) - { - this.slot = slot; - this.ref = ( dmg << Platform.DEF_OFFSET ) | ( Item.getIdFromItem( item ) & 0xffff ); - final int offset = 3 * slot; - this.hash = ( this.ref << offset ) | ( this.ref >> ( offset + 32 ) ); - } - - @Override - public int hashCode() - { - return this.hash; - } - - @Override - public boolean equals( final Object obj ) - { - final boolean equality; - - if( obj instanceof TestLookup ) - { - final TestLookup b = (TestLookup) obj; - - equality = b.slot == this.slot && b.ref == this.ref; - } - else - { - equality = false; - } - - return equality; - } - } +import appeng.api.AEApi; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.api.storage.channels.IItemStorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.container.ContainerNull; +import appeng.util.Platform; +import appeng.util.item.AEItemStack; + +public class PatternHelper implements ICraftingPatternDetails, Comparable { + + private final ItemStack patternItem; + private final CraftingInventory crafting = new CraftingInventory(new ContainerNull(), 3, 3); + private final CraftingInventory testFrame = new CraftingInventory(new ContainerNull(), 3, 3); + private final ItemStack correctOutput; + private final ICraftingRecipe standardRecipe; + private final IAEItemStack[] condensedInputs; + private final IAEItemStack[] condensedOutputs; + private final IAEItemStack[] inputs; + private final IAEItemStack[] outputs; + private final boolean isCrafting; + private final boolean canSubstitute; + private final Set failCache = new HashSet<>(); + private final Set passCache = new HashSet<>(); + private final IAEItemStack pattern; + private int priority = 0; + + public PatternHelper(final ItemStack is, final World w) { + final CompoundNBT encodedValue = is.getTag(); + + if (encodedValue == null) { + throw new IllegalArgumentException("No pattern here!"); + } + + final ListNBT inTag = encodedValue.getList("in", 10); + final ListNBT outTag = encodedValue.getList("out", 10); + this.isCrafting = encodedValue.getBoolean("crafting"); + + this.canSubstitute = this.isCrafting && encodedValue.getBoolean("substitute"); + this.patternItem = is; + this.pattern = AEItemStack.fromItemStack(is); + + final List in = new ArrayList<>(); + final List out = new ArrayList<>(); + + for (int x = 0; x < inTag.size(); x++) { + CompoundNBT ingredient = inTag.getCompound(x); + final ItemStack gs = ItemStack.read(ingredient); + + if (!ingredient.isEmpty() && gs.isEmpty()) { + throw new IllegalArgumentException("No pattern here!"); + } + + this.crafting.setInventorySlotContents(x, gs); + + if (!gs.isEmpty() && (!this.isCrafting || !gs.hasTag())) { + this.markItemAs(x, gs, TestStatus.ACCEPT); + } + + in.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs)); + this.testFrame.setInventorySlotContents(x, gs); + } + + if (this.isCrafting) { + this.standardRecipe = w.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, w).orElse(null); + + if (this.standardRecipe != null) { + this.correctOutput = this.standardRecipe.getCraftingResult(this.crafting); + out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(this.correctOutput)); + } else { + throw new IllegalStateException("No pattern here!"); + } + } else { + this.standardRecipe = null; + this.correctOutput = ItemStack.EMPTY; + + for (int x = 0; x < outTag.size(); x++) { + CompoundNBT resultItemTag = outTag.getCompound(x); + final ItemStack gs = ItemStack.read(resultItemTag); + + if (!resultItemTag.isEmpty() && gs.isEmpty()) { + throw new IllegalArgumentException("No pattern here!"); + } + + if (!gs.isEmpty()) { + out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs)); + } + } + } + + this.outputs = out.toArray(new IAEItemStack[0]); + this.inputs = in.toArray(new IAEItemStack[0]); + + final Map tmpOutputs = new HashMap<>(); + + for (final IAEItemStack io : this.outputs) { + if (io == null) { + continue; + } + + final IAEItemStack g = tmpOutputs.get(io); + + if (g == null) { + tmpOutputs.put(io, io.copy()); + } else { + g.add(io); + } + } + + final Map tmpInputs = new HashMap<>(); + + for (final IAEItemStack io : this.inputs) { + if (io == null) { + continue; + } + + final IAEItemStack g = tmpInputs.get(io); + + if (g == null) { + tmpInputs.put(io, io.copy()); + } else { + g.add(io); + } + } + + if (tmpOutputs.isEmpty() || tmpInputs.isEmpty()) { + throw new IllegalStateException("No pattern here!"); + } + + this.condensedInputs = new IAEItemStack[tmpInputs.size()]; + int offset = 0; + + for (final IAEItemStack io : tmpInputs.values()) { + this.condensedInputs[offset] = io; + offset++; + } + + offset = 0; + this.condensedOutputs = new IAEItemStack[tmpOutputs.size()]; + + for (final IAEItemStack io : tmpOutputs.values()) { + this.condensedOutputs[offset] = io; + offset++; + } + } + + private void markItemAs(final int slotIndex, final ItemStack i, final TestStatus b) { + if (b == TestStatus.TEST || i.hasTag()) { + return; + } + + (b == TestStatus.ACCEPT ? this.passCache : this.failCache).add(new TestLookup(slotIndex, i)); + } + + @Override + public ItemStack getPattern() { + return this.patternItem; + } + + @Override + public synchronized boolean isValidItemForSlot(final int slotIndex, final ItemStack i, final World w) { + if (!this.isCrafting) { + throw new IllegalStateException("Only crafting recipes supported."); + } + + final TestStatus result = this.getStatus(slotIndex, i); + + switch (result) { + case ACCEPT: + return true; + case DECLINE: + return false; + case TEST: + default: + break; + } + + for (int x = 0; x < this.crafting.getSizeInventory(); x++) { + this.testFrame.setInventorySlotContents(x, this.crafting.getStackInSlot(x)); + } + + this.testFrame.setInventorySlotContents(slotIndex, i); + + if (this.standardRecipe.matches(this.testFrame, w)) { + final ItemStack testOutput = this.standardRecipe.getCraftingResult(this.testFrame); + + if (Platform.itemComparisons().isSameItem(this.correctOutput, testOutput)) { + this.testFrame.setInventorySlotContents(slotIndex, this.crafting.getStackInSlot(slotIndex)); + this.markItemAs(slotIndex, i, TestStatus.ACCEPT); + return true; + } + } + + this.markItemAs(slotIndex, i, TestStatus.DECLINE); + return false; + } + + @Override + public boolean isCraftable() { + return this.isCrafting; + } + + @Override + public IAEItemStack[] getInputs() { + return this.inputs; + } + + @Override + public IAEItemStack[] getCondensedInputs() { + return this.condensedInputs; + } + + @Override + public IAEItemStack[] getCondensedOutputs() { + return this.condensedOutputs; + } + + @Override + public IAEItemStack[] getOutputs() { + return this.outputs; + } + + @Override + public boolean canSubstitute() { + return this.canSubstitute; + } + + @Override + public ItemStack getOutput(final CraftingInventory craftingInv, final World w) { + if (!this.isCrafting) { + throw new IllegalStateException("Only crafting recipes supported."); + } + + for (int x = 0; x < craftingInv.getSizeInventory(); x++) { + if (!this.isValidItemForSlot(x, craftingInv.getStackInSlot(x), w)) { + return ItemStack.EMPTY; + } + } + + if (this.outputs != null && this.outputs.length > 0) { + return this.outputs[0].createItemStack(); + } + + return ItemStack.EMPTY; + } + + private TestStatus getStatus(final int slotIndex, final ItemStack i) { + if (this.crafting.getStackInSlot(slotIndex).isEmpty()) { + return i.isEmpty() ? TestStatus.ACCEPT : TestStatus.DECLINE; + } + + if (i.isEmpty()) { + return TestStatus.DECLINE; + } + + if (i.hasTag()) { + return TestStatus.TEST; + } + + if (this.passCache.contains(new TestLookup(slotIndex, i))) { + return TestStatus.ACCEPT; + } + + if (this.failCache.contains(new TestLookup(slotIndex, i))) { + return TestStatus.DECLINE; + } + + return TestStatus.TEST; + } + + @Override + public int getPriority() { + return this.priority; + } + + @Override + public void setPriority(final int priority) { + this.priority = priority; + } + + @Override + public int compareTo(final PatternHelper o) { + return Integer.compare(o.priority, this.priority); + } + + @Override + public int hashCode() { + return this.pattern.hashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + + final PatternHelper other = (PatternHelper) obj; + + if (this.pattern != null && other.pattern != null) { + return this.pattern.equals(other.pattern); + } + return false; + } + + private enum TestStatus { + ACCEPT, DECLINE, TEST + } + + private static final class TestLookup { + + private final int slot; + private final int ref; + private final int hash; + + public TestLookup(final int slot, final ItemStack i) { + this(slot, i.getItem(), i.getDamage()); + } + + public TestLookup(final int slot, final Item item, final int dmg) { + this.slot = slot; + this.ref = (dmg << Platform.DEF_OFFSET) | (Item.getIdFromItem(item) & 0xffff); + final int offset = 3 * slot; + this.hash = (this.ref << offset) | (this.ref >> (offset + 32)); + } + + @Override + public int hashCode() { + return this.hash; + } + + @Override + public boolean equals(final Object obj) { + final boolean equality; + + if (obj instanceof TestLookup) { + final TestLookup b = (TestLookup) obj; + + equality = b.slot == this.slot && b.ref == this.ref; + } else { + equality = false; + } + + return equality; + } + } } diff --git a/src/main/java/appeng/helpers/PlayerSecurityWrapper.java b/src/main/java/appeng/helpers/PlayerSecurityWrapper.java index a79e4207d..4905f8bc4 100644 --- a/src/main/java/appeng/helpers/PlayerSecurityWrapper.java +++ b/src/main/java/appeng/helpers/PlayerSecurityWrapper.java @@ -18,27 +18,22 @@ package appeng.helpers; - import java.util.EnumSet; import java.util.Map; import appeng.api.config.SecurityPermissions; import appeng.api.networking.security.ISecurityRegistry; +public class PlayerSecurityWrapper implements ISecurityRegistry { -public class PlayerSecurityWrapper implements ISecurityRegistry -{ + private final Map> target; - private final Map> target; + public PlayerSecurityWrapper(final Map> playerPerms) { + this.target = playerPerms; + } - public PlayerSecurityWrapper( final Map> playerPerms ) - { - this.target = playerPerms; - } - - @Override - public void addPlayer( final int playerID, final EnumSet permissions ) - { - this.target.put( playerID, permissions ); - } + @Override + public void addPlayer(final int playerID, final EnumSet permissions) { + this.target.put(playerID, permissions); + } } diff --git a/src/main/java/appeng/helpers/Reflected.java b/src/main/java/appeng/helpers/Reflected.java index 7d12ac499..48cccac49 100644 --- a/src/main/java/appeng/helpers/Reflected.java +++ b/src/main/java/appeng/helpers/Reflected.java @@ -18,19 +18,16 @@ 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, ElementType.TYPE, ElementType.METHOD } ) -public @interface Reflected -{ +@Retention(RetentionPolicy.SOURCE) +@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE, ElementType.METHOD }) +public @interface Reflected { } diff --git a/src/main/java/appeng/helpers/Splotch.java b/src/main/java/appeng/helpers/Splotch.java index b4aa0502c..37397b7b7 100644 --- a/src/main/java/appeng/helpers/Splotch.java +++ b/src/main/java/appeng/helpers/Splotch.java @@ -18,101 +18,86 @@ package appeng.helpers; - import net.minecraft.network.PacketBuffer; import net.minecraft.util.Direction; import net.minecraft.util.math.Vec3d; import appeng.api.util.AEColor; +public class Splotch { -public class Splotch -{ + private final Direction side; + private final boolean lumen; + private final AEColor color; + private final int pos; - private final Direction side; - private final boolean lumen; - private final AEColor color; - private final int pos; + public Splotch(final AEColor col, final boolean lit, final Direction side, final Vec3d position) { + this.color = col; + this.lumen = lit; - public Splotch( final AEColor col, final boolean lit, final Direction side, final Vec3d position ) - { - this.color = col; - this.lumen = lit; + final double x; + final double y; - final double x; - final double y; + if (side == Direction.SOUTH || side == Direction.NORTH) { + x = position.x; + y = position.y; + } - if( side == Direction.SOUTH || side == Direction.NORTH ) - { - x = position.x; - y = position.y; - } + else if (side == Direction.UP || side == Direction.DOWN) { + x = position.x; + y = position.z; + } - else if( side == Direction.UP || side == Direction.DOWN ) - { - x = position.x; - y = position.z; - } + else { + x = position.y; + y = position.z; + } - else - { - x = position.y; - y = position.z; - } + final int a = (int) (x * 0xF); + final int b = (int) (y * 0xF); + this.pos = a | (b << 4); - final int a = (int) ( x * 0xF ); - final int b = (int) ( y * 0xF ); - this.pos = a | ( b << 4 ); + this.side = side; + } - this.side = side; - } + public Splotch(final PacketBuffer data) { - public Splotch( final PacketBuffer data ) - { + this.pos = data.readByte(); + final int val = data.readByte(); - this.pos = data.readByte(); - final int val = data.readByte(); + this.side = Direction.values()[val & 0x07]; + this.color = AEColor.values()[(val >> 3) & 0x0F]; + this.lumen = ((val >> 7) & 0x01) > 0; + } - this.side = Direction.values()[val & 0x07]; - this.color = AEColor.values()[( val >> 3 ) & 0x0F]; - this.lumen = ( ( val >> 7 ) & 0x01 ) > 0; - } + public void writeToStream(final PacketBuffer stream) { + stream.writeByte(this.pos); + final int val = this.getSide().ordinal() | (this.getColor().ordinal() << 3) | (this.isLumen() ? 0x80 : 0x00); + stream.writeByte(val); + } - public void writeToStream( final PacketBuffer stream ) - { - stream.writeByte( this.pos ); - final int val = this.getSide().ordinal() | ( this.getColor().ordinal() << 3 ) | ( this.isLumen() ? 0x80 : 0x00 ); - stream.writeByte( val ); - } + public float x() { + return (this.pos & 0x0f) / 15.0f; + } - public float x() - { - return ( this.pos & 0x0f ) / 15.0f; - } + public float y() { + return ((this.pos >> 4) & 0x0f) / 15.0f; + } - public float y() - { - return ( ( this.pos >> 4 ) & 0x0f ) / 15.0f; - } + public int getSeed() { + final int val = this.getSide().ordinal() | (this.getColor().ordinal() << 3) | (this.isLumen() ? 0x80 : 0x00); + return Math.abs(this.pos + val); + } - public int getSeed() - { - final int val = this.getSide().ordinal() | ( this.getColor().ordinal() << 3 ) | ( this.isLumen() ? 0x80 : 0x00 ); - return Math.abs( this.pos + val ); - } + public Direction getSide() { + return this.side; + } - public Direction getSide() - { - return this.side; - } + public AEColor getColor() { + return this.color; + } - public AEColor getColor() - { - return this.color; - } - - public boolean isLumen() - { - return this.lumen; - } + public boolean isLumen() { + return this.lumen; + } } diff --git a/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java b/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java index 984c01207..69c13b080 100644 --- a/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java +++ b/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java @@ -18,7 +18,6 @@ package appeng.helpers; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -49,299 +48,245 @@ import appeng.api.util.IConfigManager; import appeng.container.interfaces.IInventorySlotAware; import appeng.tile.networking.TileWireless; +public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware { -public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware -{ + private final ItemStack effectiveItem; + private final IWirelessTermHandler wth; + private final String encryptionKey; + private final PlayerEntity myPlayer; + private IGrid targetGrid; + private IStorageGrid sg; + private IMEMonitor itemStorage; + private IWirelessAccessPoint myWap; + private double sqRange = Double.MAX_VALUE; + private double myRange = Double.MAX_VALUE; + private final int inventorySlot; - private final ItemStack effectiveItem; - private final IWirelessTermHandler wth; - private final String encryptionKey; - private final PlayerEntity myPlayer; - private IGrid targetGrid; - private IStorageGrid sg; - private IMEMonitor itemStorage; - private IWirelessAccessPoint myWap; - private double sqRange = Double.MAX_VALUE; - private double myRange = Double.MAX_VALUE; - private final int inventorySlot; + public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final PlayerEntity ep, + int inventorySlot) { + this.encryptionKey = wh.getEncryptionKey(is); + this.effectiveItem = is; + this.myPlayer = ep; + this.wth = wh; + this.inventorySlot = inventorySlot; - public WirelessTerminalGuiObject( final IWirelessTermHandler wh, final ItemStack is, final PlayerEntity ep, int inventorySlot ) - { - this.encryptionKey = wh.getEncryptionKey( is ); - this.effectiveItem = is; - this.myPlayer = ep; - this.wth = wh; - this.inventorySlot = inventorySlot; + ILocatable obj = null; - ILocatable obj = null; + try { + final long encKey = Long.parseLong(this.encryptionKey); + obj = AEApi.instance().registries().locatable().getLocatableBy(encKey); + } catch (final NumberFormatException err) { + // :P + } - try - { - final long encKey = Long.parseLong( this.encryptionKey ); - obj = AEApi.instance().registries().locatable().getLocatableBy( encKey ); - } - catch( final NumberFormatException err ) - { - // :P - } + if (obj instanceof IActionHost) { + final IGridNode n = ((IActionHost) obj).getActionableNode(); + if (n != null) { + this.targetGrid = n.getGrid(); + if (this.targetGrid != null) { + this.sg = this.targetGrid.getCache(IStorageGrid.class); + if (this.sg != null) { + this.itemStorage = this.sg + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + } + } + } + } + } - if( obj instanceof IActionHost ) - { - final IGridNode n = ( (IActionHost) obj ).getActionableNode(); - if( n != null ) - { - this.targetGrid = n.getGrid(); - if( this.targetGrid != null ) - { - this.sg = this.targetGrid.getCache( IStorageGrid.class ); - if( this.sg != null ) - { - this.itemStorage = this.sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - } - } - } - } - } + public double getRange() { + return this.myRange; + } - public double getRange() - { - return this.myRange; - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + return this.sg.getInventory(channel); + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - return this.sg.getInventory( channel ); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + if (this.itemStorage != null) { + this.itemStorage.addListener(l, verificationToken); + } + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - if( this.itemStorage != null ) - { - this.itemStorage.addListener( l, verificationToken ); - } - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + if (this.itemStorage != null) { + this.itemStorage.removeListener(l); + } + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - if( this.itemStorage != null ) - { - this.itemStorage.removeListener( l ); - } - } + @Override + public IItemList getAvailableItems(final IItemList out) { + if (this.itemStorage != null) { + return this.itemStorage.getAvailableItems(out); + } + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - if( this.itemStorage != null ) - { - return this.itemStorage.getAvailableItems( out ); - } - return out; - } + @Override + public IItemList getStorageList() { + if (this.itemStorage != null) { + return this.itemStorage.getStorageList(); + } + return null; + } - @Override - public IItemList getStorageList() - { - if( this.itemStorage != null ) - { - return this.itemStorage.getStorageList(); - } - return null; - } + @Override + public AccessRestriction getAccess() { + if (this.itemStorage != null) { + return this.itemStorage.getAccess(); + } + return AccessRestriction.NO_ACCESS; + } - @Override - public AccessRestriction getAccess() - { - if( this.itemStorage != null ) - { - return this.itemStorage.getAccess(); - } - return AccessRestriction.NO_ACCESS; - } + @Override + public boolean isPrioritized(final IAEItemStack input) { + if (this.itemStorage != null) { + return this.itemStorage.isPrioritized(input); + } + return false; + } - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - if( this.itemStorage != null ) - { - return this.itemStorage.isPrioritized( input ); - } - return false; - } + @Override + public boolean canAccept(final IAEItemStack input) { + if (this.itemStorage != null) { + return this.itemStorage.canAccept(input); + } + return false; + } - @Override - public boolean canAccept( final IAEItemStack input ) - { - if( this.itemStorage != null ) - { - return this.itemStorage.canAccept( input ); - } - return false; - } + @Override + public int getPriority() { + if (this.itemStorage != null) { + return this.itemStorage.getPriority(); + } + return 0; + } - @Override - public int getPriority() - { - if( this.itemStorage != null ) - { - return this.itemStorage.getPriority(); - } - return 0; - } + @Override + public int getSlot() { + if (this.itemStorage != null) { + return this.itemStorage.getSlot(); + } + return 0; + } - @Override - public int getSlot() - { - if( this.itemStorage != null ) - { - return this.itemStorage.getSlot(); - } - return 0; - } + @Override + public boolean validForPass(final int i) { + return this.itemStorage.validForPass(i); + } - @Override - public boolean validForPass( final int i ) - { - return this.itemStorage.validForPass( i ); - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + if (this.itemStorage != null) { + return this.itemStorage.injectItems(input, type, src); + } + return input; + } - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - if( this.itemStorage != null ) - { - return this.itemStorage.injectItems( input, type, src ); - } - return input; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + if (this.itemStorage != null) { + return this.itemStorage.extractItems(request, mode, src); + } + return null; + } - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - if( this.itemStorage != null ) - { - return this.itemStorage.extractItems( request, mode, src ); - } - return null; - } + @Override + public IStorageChannel getChannel() { + if (this.itemStorage != null) { + return this.itemStorage.getChannel(); + } + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - if( this.itemStorage != null ) - { - return this.itemStorage.getChannel(); - } - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) { + if (this.wth != null && this.effectiveItem != null) { + if (mode == Actionable.SIMULATE) { + return this.wth.hasPower(this.myPlayer, amt, this.effectiveItem) ? amt : 0; + } + return this.wth.usePower(this.myPlayer, amt, this.effectiveItem) ? amt : 0; + } + return 0.0; + } - @Override - public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier ) - { - if( this.wth != null && this.effectiveItem != null ) - { - if( mode == Actionable.SIMULATE ) - { - return this.wth.hasPower( this.myPlayer, amt, this.effectiveItem ) ? amt : 0; - } - return this.wth.usePower( this.myPlayer, amt, this.effectiveItem ) ? amt : 0; - } - return 0.0; - } + @Override + public ItemStack getItemStack() { + return this.effectiveItem; + } - @Override - public ItemStack getItemStack() - { - return this.effectiveItem; - } + @Override + public IConfigManager getConfigManager() { + return this.wth.getConfigManager(this.effectiveItem); + } - @Override - public IConfigManager getConfigManager() - { - return this.wth.getConfigManager( this.effectiveItem ); - } + @Override + public IGridNode getActionableNode() { + this.rangeCheck(); + if (this.myWap != null) { + return this.myWap.getActionableNode(); + } + return null; + } - @Override - public IGridNode getActionableNode() - { - this.rangeCheck(); - if( this.myWap != null ) - { - return this.myWap.getActionableNode(); - } - return null; - } + public boolean rangeCheck() { + this.sqRange = this.myRange = Double.MAX_VALUE; - public boolean rangeCheck() - { - this.sqRange = this.myRange = Double.MAX_VALUE; + if (this.targetGrid != null && this.itemStorage != null) { + if (this.myWap != null) { + if (this.myWap.getGrid() == this.targetGrid) { + if (this.testWap(this.myWap)) { + return true; + } + } + return false; + } - if( this.targetGrid != null && this.itemStorage != null ) - { - if( this.myWap != null ) - { - if( this.myWap.getGrid() == this.targetGrid ) - { - if( this.testWap( this.myWap ) ) - { - return true; - } - } - return false; - } + final IMachineSet tw = this.targetGrid.getMachines(TileWireless.class); - final IMachineSet tw = this.targetGrid.getMachines( TileWireless.class ); + this.myWap = null; - this.myWap = null; + for (final IGridNode n : tw) { + final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine(); + if (this.testWap(wap)) { + this.myWap = wap; + } + } - for( final IGridNode n : tw ) - { - final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine(); - if( this.testWap( wap ) ) - { - this.myWap = wap; - } - } + return this.myWap != null; + } + return false; + } - return this.myWap != null; - } - return false; - } + private boolean testWap(final IWirelessAccessPoint wap) { + double rangeLimit = wap.getRange(); + rangeLimit *= rangeLimit; - private boolean testWap( final IWirelessAccessPoint wap ) - { - double rangeLimit = wap.getRange(); - rangeLimit *= rangeLimit; + final DimensionalCoord dc = wap.getLocation(); - final DimensionalCoord dc = wap.getLocation(); + if (dc.getWorld() == this.myPlayer.world) { + final double offX = dc.x - this.myPlayer.getPosX(); + final double offY = dc.y - this.myPlayer.getPosY(); + final double offZ = dc.z - this.myPlayer.getPosZ(); - if( dc.getWorld() == this.myPlayer.world ) - { - final double offX = dc.x - this.myPlayer.getPosX(); - final double offY = dc.y - this.myPlayer.getPosY(); - final double offZ = dc.z - this.myPlayer.getPosZ(); + final double r = offX * offX + offY * offY + offZ * offZ; + if (r < rangeLimit && this.sqRange > r) { + if (wap.isActive()) { + this.sqRange = r; + this.myRange = Math.sqrt(r); + return true; + } + } + } + return false; + } - final double r = offX * offX + offY * offY + offZ * offZ; - if( r < rangeLimit && this.sqRange > r ) - { - if( wap.isActive() ) - { - this.sqRange = r; - this.myRange = Math.sqrt( r ); - return true; - } - } - } - return false; - } - - @Override - public int getInventorySlot() - { - return this.inventorySlot; - } + @Override + public int getInventorySlot() { + return this.inventorySlot; + } } diff --git a/src/main/java/appeng/hooks/AETrading.java b/src/main/java/appeng/hooks/AETrading.java index 20ba43120..e31913bfb 100644 --- a/src/main/java/appeng/hooks/AETrading.java +++ b/src/main/java/appeng/hooks/AETrading.java @@ -18,82 +18,44 @@ package appeng.hooks; - // TODO Villager Trading!??!?! -public class AETrading -{ +public class AETrading { - /* - * @Override - * public void manipulateTradesForVillager( EntityVillager villager, MerchantRecipeList recipeList, Random random ) - * { - * final IMaterials materials = AEApi.instance().definitions().materials(); - * 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 ); - * } - * private void addMerchant( MerchantRecipeList list, IItemDefinition item, int emera, Random rand, int greed ) - * { - * for( ItemStack itemStack : item.maybeStack( 1 ).asSet() ) - * { - * // 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 ); - * } - * } - * private void addTrade( MerchantRecipeList list, IItemDefinition inputDefinition, IItemDefinition - * outputDefinition, Random rand, int conversionVariance ) - * { - * final Optional maybeInputStack = inputDefinition.maybeStack( 1 ); - * final Optional maybeOutputStack = outputDefinition.maybeStack( 1 ); - * if( maybeInputStack.isPresent() && maybeOutputStack.isPresent() ) - * { - * // Sell - * ItemStack inputStack = maybeInputStack.get().copy(); - * ItemStack outputStack = maybeOutputStack.get().copy(); - * inputStack.stackSize = 1 + ( Math.abs( rand.nextInt() ) % ( 1 + conversionVariance ) ); - * outputStack.stackSize = 1; - * this.addToList( list, inputStack, outputStack ); - * } - * } - * private void addToList( MerchantRecipeList l, ItemStack a, ItemStack b ) - * { - * if( a.stackSize < 1 ) - * { - * a.stackSize = 1; - * } - * if( b.stackSize < 1 ) - * { - * b.stackSize = 1; - * } - * if( a.stackSize > a.getMaxStackSize() ) - * { - * a.stackSize = a.getMaxStackSize(); - * } - * if( b.stackSize > b.getMaxStackSize() ) - * { - * b.stackSize = b.getMaxStackSize(); - * } - * l.add( new MerchantRecipe( a, b ) ); - * } - */ + /* + * @Override public void manipulateTradesForVillager( EntityVillager villager, + * MerchantRecipeList recipeList, Random random ) { final IMaterials materials = + * AEApi.instance().definitions().materials(); 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 ); } private void addMerchant( MerchantRecipeList list, + * IItemDefinition item, int emera, Random rand, int greed ) { for( ItemStack + * itemStack : item.maybeStack( 1 ).asSet() ) { // 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 ); } } private void addTrade( + * MerchantRecipeList list, IItemDefinition inputDefinition, IItemDefinition + * outputDefinition, Random rand, int conversionVariance ) { final + * Optional maybeInputStack = inputDefinition.maybeStack( 1 ); final + * Optional maybeOutputStack = outputDefinition.maybeStack( 1 ); if( + * maybeInputStack.isPresent() && maybeOutputStack.isPresent() ) { // Sell + * ItemStack inputStack = maybeInputStack.get().copy(); ItemStack outputStack = + * maybeOutputStack.get().copy(); inputStack.stackSize = 1 + ( Math.abs( + * rand.nextInt() ) % ( 1 + conversionVariance ) ); outputStack.stackSize = 1; + * this.addToList( list, inputStack, outputStack ); } } private void addToList( + * MerchantRecipeList l, ItemStack a, ItemStack b ) { if( a.stackSize < 1 ) { + * a.stackSize = 1; } if( b.stackSize < 1 ) { b.stackSize = 1; } if( a.stackSize + * > a.getMaxStackSize() ) { a.stackSize = a.getMaxStackSize(); } if( + * b.stackSize > b.getMaxStackSize() ) { b.stackSize = b.getMaxStackSize(); } + * l.add( new MerchantRecipe( a, b ) ); } + */ } diff --git a/src/main/java/appeng/hooks/CompassManager.java b/src/main/java/appeng/hooks/CompassManager.java index 25379ed2f..51ac7b42d 100644 --- a/src/main/java/appeng/hooks/CompassManager.java +++ b/src/main/java/appeng/hooks/CompassManager.java @@ -18,105 +18,88 @@ package appeng.hooks; - import java.util.HashMap; import java.util.Iterator; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketCompassRequest; +public class CompassManager { -public class CompassManager -{ + public static final CompassManager INSTANCE = new CompassManager(); + private final HashMap requests = new HashMap<>(); - public static final CompassManager INSTANCE = new CompassManager(); - private final HashMap requests = new HashMap<>(); + public void postResult(final long attunement, final int x, final int y, final int z, final CompassResult result) { + final CompassRequest r = new CompassRequest(attunement, x, y, z); + this.requests.put(r, result); + } - public void postResult( final long attunement, final int x, final int y, final int z, final CompassResult result ) - { - final CompassRequest r = new CompassRequest( attunement, x, y, z ); - this.requests.put( r, result ); - } + public CompassResult getCompassDirection(final long attunement, final int x, final int y, final int z) { + final long now = System.currentTimeMillis(); - public CompassResult getCompassDirection( final long attunement, final int x, final int y, final int z ) - { - final long now = System.currentTimeMillis(); + final Iterator i = this.requests.values().iterator(); + while (i.hasNext()) { + final CompassResult res = i.next(); + final long diff = now - res.getTime(); + if (diff > 20000) { + i.remove(); + } + } - final Iterator i = this.requests.values().iterator(); - while( i.hasNext() ) - { - final CompassResult res = i.next(); - final long diff = now - res.getTime(); - if( diff > 20000 ) - { - i.remove(); - } - } + final CompassRequest r = new CompassRequest(attunement, x, y, z); + CompassResult res = this.requests.get(r); - final CompassRequest r = new CompassRequest( attunement, x, y, z ); - CompassResult res = this.requests.get( r ); + if (res == null) { + res = new CompassResult(false, true, 0); + this.requests.put(r, res); + this.requestUpdate(r); + } else if (now - res.getTime() > 1000 * 3) { + if (!res.isRequested()) { + res.setRequested(true); + this.requestUpdate(r); + } + } - if( res == null ) - { - res = new CompassResult( false, true, 0 ); - this.requests.put( r, res ); - this.requestUpdate( r ); - } - else if( now - res.getTime() > 1000 * 3 ) - { - if( !res.isRequested() ) - { - res.setRequested( true ); - this.requestUpdate( r ); - } - } + return res; + } - return res; - } + private void requestUpdate(final CompassRequest r) { + NetworkHandler.instance().sendToServer(new PacketCompassRequest(r.attunement, r.cx, r.cz, r.cdy)); + } - private void requestUpdate( final CompassRequest r ) - { - NetworkHandler.instance().sendToServer( new PacketCompassRequest( r.attunement, r.cx, r.cz, r.cdy ) ); - } + private static class CompassRequest { - private static class CompassRequest - { + private final int hash; + private final long attunement; + private final int cx; + private final int cdy; + private final int cz; - private final int hash; - private final long attunement; - private final int cx; - private final int cdy; - private final int cz; + public CompassRequest(final long attunement, final int x, final int y, final int z) { + this.attunement = attunement; + this.cx = x >> 4; + this.cdy = y >> 5; + this.cz = z >> 4; + this.hash = ((Integer) this.cx).hashCode() ^ ((Integer) this.cdy).hashCode() + ^ ((Integer) this.cz).hashCode() ^ ((Long) attunement).hashCode(); + } - public CompassRequest( final long attunement, final int x, final int y, final int z ) - { - this.attunement = attunement; - this.cx = x >> 4; - this.cdy = y >> 5; - this.cz = z >> 4; - this.hash = ( (Integer) this.cx ).hashCode() ^ ( (Integer) this.cdy ).hashCode() ^ ( (Integer) this.cz ).hashCode() ^ ( (Long) attunement ) - .hashCode(); - } + @Override + public int hashCode() { + return this.hash; + } - @Override - public int hashCode() - { - return this.hash; - } - - @Override - public boolean equals( final Object obj ) - { - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } - final CompassRequest other = (CompassRequest) obj; - return this.attunement == other.attunement && this.cx == other.cx && this.cdy == other.cdy && this.cz == other.cz; - } - } + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final CompassRequest other = (CompassRequest) obj; + return this.attunement == other.attunement && this.cx == other.cx && this.cdy == other.cdy + && this.cz == other.cz; + } + } } diff --git a/src/main/java/appeng/hooks/CompassResult.java b/src/main/java/appeng/hooks/CompassResult.java index 53c0982cb..a4bce671c 100644 --- a/src/main/java/appeng/hooks/CompassResult.java +++ b/src/main/java/appeng/hooks/CompassResult.java @@ -18,51 +18,42 @@ package appeng.hooks; +public class CompassResult { -public class CompassResult -{ + private final boolean hasResult; + private final boolean spin; + private final double rad; + private final long time; + private boolean requested = false; - private final boolean hasResult; - private final boolean spin; - private final double rad; - private final long time; - private boolean requested = false; + public CompassResult(final boolean hasResult, final boolean spin, final double rad) { + this.hasResult = hasResult; + this.spin = spin; + this.rad = rad; + this.time = System.currentTimeMillis(); + } - public CompassResult( final boolean hasResult, final boolean spin, final double rad ) - { - this.hasResult = hasResult; - this.spin = spin; - this.rad = rad; - this.time = System.currentTimeMillis(); - } + public boolean isValidResult() { + return this.hasResult; + } - public boolean isValidResult() - { - return this.hasResult; - } + public boolean isSpin() { + return this.spin; + } - public boolean isSpin() - { - return this.spin; - } + public double getRad() { + return this.rad; + } - public double getRad() - { - return this.rad; - } + boolean isRequested() { + return this.requested; + } - boolean isRequested() - { - return this.requested; - } + void setRequested(final boolean requested) { + this.requested = requested; + } - void setRequested( final boolean requested ) - { - this.requested = requested; - } - - long getTime() - { - return this.time; - } + long getTime() { + return this.time; + } } diff --git a/src/main/java/appeng/hooks/DispenserBehaviorTinyTNT.java b/src/main/java/appeng/hooks/DispenserBehaviorTinyTNT.java index 50fc94dd1..f13ebb1d7 100644 --- a/src/main/java/appeng/hooks/DispenserBehaviorTinyTNT.java +++ b/src/main/java/appeng/hooks/DispenserBehaviorTinyTNT.java @@ -18,7 +18,6 @@ package appeng.hooks; - import net.minecraft.block.DispenserBlock; import net.minecraft.dispenser.DefaultDispenseItemBehavior; import net.minecraft.dispenser.IBlockSource; @@ -28,21 +27,19 @@ import net.minecraft.world.World; import appeng.entity.EntityTinyTNTPrimed; +public final class DispenserBehaviorTinyTNT extends DefaultDispenseItemBehavior { -public final class DispenserBehaviorTinyTNT extends DefaultDispenseItemBehavior -{ - - @Override - protected ItemStack dispenseStack( final IBlockSource dispenser, final ItemStack dispensedItem ) - { - final Direction Direction = dispenser.getBlockState().get( DispenserBlock.FACING ); - final World world = dispenser.getWorld(); - final int i = dispenser.getBlockPos().getX() + Direction.getXOffset(); - final int j = dispenser.getBlockPos().getY() + Direction.getYOffset(); - final int k = dispenser.getBlockPos().getZ() + Direction.getZOffset(); - final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( world, i + 0.5F, j + 0.5F, k + 0.5F, null ); - world.addEntity( primedTinyTNTEntity ); - dispensedItem.setCount( dispensedItem.getCount() - 1 ); - return dispensedItem; - } + @Override + protected ItemStack dispenseStack(final IBlockSource dispenser, final ItemStack dispensedItem) { + final Direction Direction = dispenser.getBlockState().get(DispenserBlock.FACING); + final World world = dispenser.getWorld(); + final int i = dispenser.getBlockPos().getX() + Direction.getXOffset(); + final int j = dispenser.getBlockPos().getY() + Direction.getYOffset(); + final int k = dispenser.getBlockPos().getZ() + Direction.getZOffset(); + final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(world, i + 0.5F, j + 0.5F, k + 0.5F, + null); + world.addEntity(primedTinyTNTEntity); + dispensedItem.setCount(dispensedItem.getCount() - 1); + return dispensedItem; + } } diff --git a/src/main/java/appeng/hooks/DispenserBlockTool.java b/src/main/java/appeng/hooks/DispenserBlockTool.java index fa92cb33f..f95307046 100644 --- a/src/main/java/appeng/hooks/DispenserBlockTool.java +++ b/src/main/java/appeng/hooks/DispenserBlockTool.java @@ -18,7 +18,6 @@ package appeng.hooks; - import net.minecraft.block.DispenserBlock; import net.minecraft.dispenser.DefaultDispenseItemBehavior; import net.minecraft.dispenser.IBlockSource; @@ -31,26 +30,21 @@ import net.minecraft.world.server.ServerWorld; import appeng.util.Platform; +public final class DispenserBlockTool extends DefaultDispenseItemBehavior { -public final class DispenserBlockTool extends DefaultDispenseItemBehavior -{ + @Override + protected ItemStack dispenseStack(final IBlockSource dispenser, final ItemStack dispensedItem) { + final Item i = dispensedItem.getItem(); + if (i instanceof IBlockTool) { + final Direction Direction = dispenser.getBlockState().get(DispenserBlock.FACING); + final IBlockTool tm = (IBlockTool) i; - @Override - protected ItemStack dispenseStack( final IBlockSource dispenser, final ItemStack dispensedItem ) - { - final Item i = dispensedItem.getItem(); - if( i instanceof IBlockTool ) - { - final Direction Direction = dispenser.getBlockState().get( DispenserBlock.FACING ); - final IBlockTool tm = (IBlockTool) i; - - final World w = dispenser.getWorld(); - if( w instanceof ServerWorld ) - { - tm.onItemUse( dispensedItem, Platform.getPlayer( (ServerWorld) w ), w, dispenser.getBlockPos().offset( Direction ), Hand.MAIN_HAND, - Direction, 0.5f, 0.5f, 0.5f ); - } - } - return dispensedItem; - } + final World w = dispenser.getWorld(); + if (w instanceof ServerWorld) { + tm.onItemUse(dispensedItem, Platform.getPlayer((ServerWorld) w), w, + dispenser.getBlockPos().offset(Direction), Hand.MAIN_HAND, Direction, 0.5f, 0.5f, 0.5f); + } + } + return dispensedItem; + } } diff --git a/src/main/java/appeng/hooks/DispenserMatterCannon.java b/src/main/java/appeng/hooks/DispenserMatterCannon.java index c69e88344..45d30a368 100644 --- a/src/main/java/appeng/hooks/DispenserMatterCannon.java +++ b/src/main/java/appeng/hooks/DispenserMatterCannon.java @@ -18,7 +18,6 @@ package appeng.hooks; - import net.minecraft.block.DispenserBlock; import net.minecraft.dispenser.DefaultDispenseItemBehavior; import net.minecraft.dispenser.IBlockSource; @@ -33,39 +32,33 @@ import appeng.api.util.AEPartLocation; import appeng.items.tools.powered.ToolMatterCannon; import appeng.util.Platform; +public final class DispenserMatterCannon extends DefaultDispenseItemBehavior { -public final class DispenserMatterCannon extends DefaultDispenseItemBehavior -{ + @Override + protected ItemStack dispenseStack(final IBlockSource dispenser, ItemStack dispensedItem) { + final Item i = dispensedItem.getItem(); + if (i instanceof ToolMatterCannon) { + final Direction Direction = dispenser.getBlockState().get(DispenserBlock.FACING); + AEPartLocation dir = AEPartLocation.INTERNAL; + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + if (Direction.getXOffset() == d.xOffset && Direction.getYOffset() == d.yOffset + && Direction.getZOffset() == d.zOffset) { + dir = d; + } + } - @Override - protected ItemStack dispenseStack( final IBlockSource dispenser, ItemStack dispensedItem ) - { - final Item i = dispensedItem.getItem(); - if( i instanceof ToolMatterCannon ) - { - final Direction Direction = dispenser.getBlockState().get( DispenserBlock.FACING ); - AEPartLocation dir = AEPartLocation.INTERNAL; - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - if( Direction.getXOffset() == d.xOffset && Direction.getYOffset() == d.yOffset && Direction.getZOffset() == d.zOffset ) - { - dir = d; - } - } + final ToolMatterCannon tm = (ToolMatterCannon) i; - final ToolMatterCannon tm = (ToolMatterCannon) i; + final World w = dispenser.getWorld(); + if (w instanceof ServerWorld) { + final PlayerEntity p = Platform.getPlayer((ServerWorld) w); + Platform.configurePlayer(p, dir, dispenser.getBlockTileEntity()); - final World w = dispenser.getWorld(); - if( w instanceof ServerWorld ) - { - final PlayerEntity p = Platform.getPlayer( (ServerWorld) w ); - Platform.configurePlayer( p, dir, dispenser.getBlockTileEntity() ); + p.setPosition(p.getPosX() + dir.xOffset, p.getPosY() + dir.yOffset, p.getPosZ() + dir.zOffset); - p.setPosition( p.getPosX() + dir.xOffset, p.getPosY() + dir.yOffset, p.getPosZ() + dir.zOffset ); - - dispensedItem = tm.onItemRightClick( w, p, null ).getResult(); - } - } - return dispensedItem; - } + dispensedItem = tm.onItemRightClick(w, p, null).getResult(); + } + } + return dispensedItem; + } } diff --git a/src/main/java/appeng/hooks/IBlockTool.java b/src/main/java/appeng/hooks/IBlockTool.java index 6c3cab929..685adfadc 100644 --- a/src/main/java/appeng/hooks/IBlockTool.java +++ b/src/main/java/appeng/hooks/IBlockTool.java @@ -18,7 +18,6 @@ package appeng.hooks; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; @@ -27,13 +26,13 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +public interface IBlockTool { + // Workaround for dispenser logic. + // TODO ItemUseContext + ActionResultType onItemUse(ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, + float hitX, float hitY, float hitZ); -public interface IBlockTool -{ - // Workaround for dispenser logic. - //TODO ItemUseContext - ActionResultType onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ); - - ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ); + ActionResultType onItemUse(PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, + float hitZ); } diff --git a/src/main/java/appeng/hooks/TickHandler.java b/src/main/java/appeng/hooks/TickHandler.java index c1545eb83..adb20a24f 100644 --- a/src/main/java/appeng/hooks/TickHandler.java +++ b/src/main/java/appeng/hooks/TickHandler.java @@ -18,7 +18,6 @@ package appeng.hooks; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -58,297 +57,244 @@ import appeng.tile.AEBaseTile; import appeng.util.IWorldCallable; import appeng.util.Platform; +public class TickHandler { -public class TickHandler -{ + public static final TickHandler INSTANCE = new TickHandler(); + private final Queue> serverQueue = new ArrayDeque<>(); + private final Multimap craftingJobs = LinkedListMultimap.create(); + private final WeakHashMap>> callQueue = new WeakHashMap<>(); + private final HandlerRep server = new HandlerRep(); + private final HandlerRep client = new HandlerRep(); + private final HashMap cliPlayerColors = new HashMap<>(); + private final HashMap srvPlayerColors = new HashMap<>(); + private CableRenderMode crm = CableRenderMode.STANDARD; - public static final TickHandler INSTANCE = new TickHandler(); - private final Queue> serverQueue = new ArrayDeque<>(); - private final Multimap craftingJobs = LinkedListMultimap.create(); - private final WeakHashMap>> callQueue = new WeakHashMap<>(); - private final HandlerRep server = new HandlerRep(); - private final HandlerRep client = new HandlerRep(); - private final HashMap cliPlayerColors = new HashMap<>(); - private final HashMap srvPlayerColors = new HashMap<>(); - private CableRenderMode crm = CableRenderMode.STANDARD; + public HashMap getPlayerColors() { + if (Platform.isServer()) { + return this.srvPlayerColors; + } + return this.cliPlayerColors; + } - public HashMap getPlayerColors() - { - if( Platform.isServer() ) - { - return this.srvPlayerColors; - } - return this.cliPlayerColors; - } + public void addCallable(final IWorld w, final IWorldCallable c) { + if (w == null) { + this.serverQueue.add(c); + } else { + Queue> queue = this.callQueue.get(w); - public void addCallable( final IWorld w, final IWorldCallable c ) - { - if( w == null ) - { - this.serverQueue.add( c ); - } - else - { - Queue> queue = this.callQueue.get( w ); + if (queue == null) { + queue = new ArrayDeque<>(); + this.callQueue.put(w, queue); + } - if( queue == null ) - { - queue = new ArrayDeque<>(); - this.callQueue.put( w, queue ); - } + queue.add(c); + } + } - queue.add( c ); - } - } + public void addInit(final AEBaseTile tile) { + if (Platform.isServer()) // for no there is no reason to care about this on the client... + { + this.getRepo().tiles.add(tile); + } + } - public void addInit( final AEBaseTile tile ) - { - if( Platform.isServer() ) // for no there is no reason to care about this on the client... - { - this.getRepo().tiles.add( tile ); - } - } + private HandlerRep getRepo() { + if (Platform.isServer()) { + return this.server; + } + return this.client; + } - private HandlerRep getRepo() - { - if( Platform.isServer() ) - { - return this.server; - } - return this.client; - } + public void addNetwork(final Grid grid) { + if (Platform.isServer()) // for no there is no reason to care about this on the client... + { + this.getRepo().addNetwork(grid); + } + } - public void addNetwork( final Grid grid ) - { - if( Platform.isServer() ) // for no there is no reason to care about this on the client... - { - this.getRepo().addNetwork( grid ); - } - } + public void removeNetwork(final Grid grid) { + if (Platform.isServer()) // for no there is no reason to care about this on the client... + { + this.getRepo().removeNetwork(grid); + } + } - public void removeNetwork( final Grid grid ) - { - if( Platform.isServer() ) // for no there is no reason to care about this on the client... - { - this.getRepo().removeNetwork( grid ); - } - } + public Iterable getGridList() { + return this.getRepo().networks; + } - public Iterable getGridList() - { - return this.getRepo().networks; - } + public void shutdown() { + this.getRepo().clear(); + } - public void shutdown() - { - this.getRepo().clear(); - } + public void unloadWorld(final WorldEvent.Unload ev) { + if (Platform.isServer()) // for no there is no reason to care about this on the client... + { + final List toDestroy = new ArrayList<>(); - public void unloadWorld( final WorldEvent.Unload ev ) - { - if( Platform.isServer() ) // for no there is no reason to care about this on the client... - { - final List toDestroy = new ArrayList<>(); + this.getRepo().updateNetworks(); + for (final Grid g : this.getRepo().networks) { + for (final IGridNode n : g.getNodes()) { + if (n.getWorld() == ev.getWorld()) { + toDestroy.add(n); + } + } + } - this.getRepo().updateNetworks(); - for( final Grid g : this.getRepo().networks ) - { - for( final IGridNode n : g.getNodes() ) - { - if( n.getWorld() == ev.getWorld() ) - { - toDestroy.add( n ); - } - } - } + for (final IGridNode n : toDestroy) { + n.destroy(); + } + } + } - for( final IGridNode n : toDestroy ) - { - n.destroy(); - } - } - } + public void onTick(final TickEvent ev) { - public void onTick( final TickEvent ev ) - { + if (ev.type == Type.CLIENT && ev.phase == Phase.START) { + this.tickColors(this.cliPlayerColors); + final CableRenderMode currentMode = AEApi.instance().partHelper().getCableRenderMode(); + if (currentMode != this.crm) { + this.crm = currentMode; + AppEng.proxy.triggerUpdates(); + } + } - if( ev.type == Type.CLIENT && ev.phase == Phase.START ) - { - this.tickColors( this.cliPlayerColors ); - final CableRenderMode currentMode = AEApi.instance().partHelper().getCableRenderMode(); - if( currentMode != this.crm ) - { - this.crm = currentMode; - AppEng.proxy.triggerUpdates(); - } - } + if (ev.type == Type.WORLD && ev.phase == Phase.END) { + final WorldTickEvent wte = (WorldTickEvent) ev; + synchronized (this.craftingJobs) { + final Collection jobSet = this.craftingJobs.get(wte.world); + if (!jobSet.isEmpty()) { + final int simTime = Math.max(1, + AEConfig.instance().getCraftingCalculationTimePerTick() / jobSet.size()); + final Iterator i = jobSet.iterator(); + while (i.hasNext()) { + final CraftingJob cj = i.next(); + if (!cj.simulateFor(simTime)) { + i.remove(); + } + } + } + } + } - if( ev.type == Type.WORLD && ev.phase == Phase.END ) - { - final WorldTickEvent wte = (WorldTickEvent) ev; - synchronized( this.craftingJobs ) - { - final Collection jobSet = this.craftingJobs.get( wte.world ); - if( !jobSet.isEmpty() ) - { - final int simTime = Math.max( 1, AEConfig.instance().getCraftingCalculationTimePerTick() / jobSet.size() ); - final Iterator i = jobSet.iterator(); - while( i.hasNext() ) - { - final CraftingJob cj = i.next(); - if( !cj.simulateFor( simTime ) ) - { - i.remove(); - } - } - } - } - } + // for no there is no reason to care about this on the client... + else if (ev.type == Type.SERVER && ev.phase == Phase.END) { + this.tickColors(this.srvPlayerColors); + // ready tiles. + final HandlerRep repo = this.getRepo(); + while (!repo.tiles.isEmpty()) { + final AEBaseTile bt = repo.tiles.poll(); + if (!bt.isRemoved()) { + bt.onReady(); + } + } - // for no there is no reason to care about this on the client... - else if( ev.type == Type.SERVER && ev.phase == Phase.END ) - { - this.tickColors( this.srvPlayerColors ); - // ready tiles. - final HandlerRep repo = this.getRepo(); - while( !repo.tiles.isEmpty() ) - { - final AEBaseTile bt = repo.tiles.poll(); - if( !bt.isRemoved() ) - { - bt.onReady(); - } - } + // tick networks. + this.getRepo().updateNetworks(); + for (final Grid g : this.getRepo().networks) { + g.update(); + } - // tick networks. - this.getRepo().updateNetworks(); - for( final Grid g : this.getRepo().networks ) - { - g.update(); - } + // cross world queue. + this.processQueue(this.serverQueue, null); + } - // cross world queue. - this.processQueue( this.serverQueue, null ); - } + // world synced queue(s) + if (ev.type == Type.WORLD && ev.phase == Phase.START) { + final World world = ((WorldTickEvent) ev).world; + final Queue> queue = this.callQueue.get(world); + this.processQueue(queue, world); + } + } - // world synced queue(s) - if( ev.type == Type.WORLD && ev.phase == Phase.START ) - { - final World world = ( (WorldTickEvent) ev ).world; - final Queue> queue = this.callQueue.get( world ); - this.processQueue( queue, world ); - } - } + private void tickColors(final HashMap playerSet) { + final Iterator i = playerSet.values().iterator(); + while (i.hasNext()) { + final PlayerColor pc = i.next(); + if (pc.ticksLeft <= 0) { + i.remove(); + } + pc.ticksLeft--; + } + } - private void tickColors( final HashMap playerSet ) - { - final Iterator i = playerSet.values().iterator(); - while( i.hasNext() ) - { - final PlayerColor pc = i.next(); - if( pc.ticksLeft <= 0 ) - { - i.remove(); - } - pc.ticksLeft--; - } - } + private void processQueue(final Queue> queue, final World world) { + if (queue == null) { + return; + } - private void processQueue( final Queue> queue, final World world ) - { - if( queue == null ) - { - return; - } + final Stopwatch sw = Stopwatch.createStarted(); - final Stopwatch sw = Stopwatch.createStarted(); + IWorldCallable c = null; + while ((c = queue.poll()) != null) { + try { + c.call(world); - IWorldCallable c = null; - while( ( c = queue.poll() ) != null ) - { - try - { - c.call( world ); + if (sw.elapsed(TimeUnit.MILLISECONDS) > 50) { + break; + } + } catch (final Exception e) { + AELog.debug(e); + } + } - if( sw.elapsed( TimeUnit.MILLISECONDS ) > 50 ) - { - break; - } - } - catch( final Exception e ) - { - AELog.debug( e ); - } - } + // long time = sw.elapsed( TimeUnit.MILLISECONDS ); + // if ( time > 0 ) + // AELog.info( "processQueue Time: " + time + "ms" ); + } - // long time = sw.elapsed( TimeUnit.MILLISECONDS ); - // if ( time > 0 ) - // AELog.info( "processQueue Time: " + time + "ms" ); - } + public void registerCraftingSimulation(final World world, final CraftingJob craftingJob) { + synchronized (this.craftingJobs) { + this.craftingJobs.put(world, craftingJob); + } + } - public void registerCraftingSimulation( final World world, final CraftingJob craftingJob ) - { - synchronized( this.craftingJobs ) - { - this.craftingJobs.put( world, craftingJob ); - } - } + private static class HandlerRep { - private static class HandlerRep - { + private Queue tiles = new ArrayDeque<>(); + private Set networks = new HashSet<>(); + private Set toAdd = new HashSet<>(); + private Set toRemove = new HashSet<>(); - private Queue tiles = new ArrayDeque<>(); - private Set networks = new HashSet<>(); - private Set toAdd = new HashSet<>(); - private Set toRemove = new HashSet<>(); + private void clear() { + this.tiles = new ArrayDeque<>(); + this.networks = new HashSet<>(); + this.toAdd = new HashSet<>(); + this.toRemove = new HashSet<>(); + } - private void clear() - { - this.tiles = new ArrayDeque<>(); - this.networks = new HashSet<>(); - this.toAdd = new HashSet<>(); - this.toRemove = new HashSet<>(); - } + private synchronized void addNetwork(Grid g) { + this.toAdd.add(g); + this.toRemove.remove(g); + } - private synchronized void addNetwork( Grid g ) - { - this.toAdd.add( g ); - this.toRemove.remove( g ); - } + private synchronized void removeNetwork(Grid g) { + this.toRemove.add(g); + this.toAdd.remove(g); + } - private synchronized void removeNetwork( Grid g ) - { - this.toRemove.add( g ); - this.toAdd.remove( g ); - } + private synchronized void updateNetworks() { + this.networks.removeAll(this.toRemove); + this.toRemove.clear(); - private synchronized void updateNetworks() - { - this.networks.removeAll( this.toRemove ); - this.toRemove.clear(); + this.networks.addAll(this.toAdd); + this.toAdd.clear(); + } + } - this.networks.addAll( this.toAdd ); - this.toAdd.clear(); - } - } + public static class PlayerColor { - public static class PlayerColor - { + public final AEColor myColor; + private final int myEntity; + private int ticksLeft; - public final AEColor myColor; - private final int myEntity; - private int ticksLeft; + public PlayerColor(final int id, final AEColor col, final int ticks) { + this.myEntity = id; + this.myColor = col; + this.ticksLeft = ticks; + } - public PlayerColor( final int id, final AEColor col, final int ticks ) - { - this.myEntity = id; - this.myColor = col; - this.ticksLeft = ticks; - } - - public PacketPaintedEntity getPacket() - { - return new PacketPaintedEntity( this.myEntity, this.myColor, this.ticksLeft ); - } - } + public PacketPaintedEntity getPacket() { + return new PacketPaintedEntity(this.myEntity, this.myColor, this.ticksLeft); + } + } } diff --git a/src/main/java/appeng/integration/IIntegrationModule.java b/src/main/java/appeng/integration/IIntegrationModule.java index 89f9fdd66..156a3886d 100644 --- a/src/main/java/appeng/integration/IIntegrationModule.java +++ b/src/main/java/appeng/integration/IIntegrationModule.java @@ -18,21 +18,16 @@ package appeng.integration; +public interface IIntegrationModule { -public interface IIntegrationModule -{ + default boolean isEnabled() { + return true; + } - default boolean isEnabled() - { - return true; - } - - class Stub implements IIntegrationModule - { - @Override - public boolean isEnabled() - { - return false; - } - } + class Stub implements IIntegrationModule { + @Override + public boolean isEnabled() { + return false; + } + } } diff --git a/src/main/java/appeng/integration/abstraction/IJEI.java b/src/main/java/appeng/integration/abstraction/IJEI.java index 7f934ebae..17199941b 100644 --- a/src/main/java/appeng/integration/abstraction/IJEI.java +++ b/src/main/java/appeng/integration/abstraction/IJEI.java @@ -18,26 +18,20 @@ package appeng.integration.abstraction; - import appeng.integration.IIntegrationModule; - /** * Abstracts access to the JEI API functionality. */ -public interface IJEI extends IIntegrationModule -{ +public interface IJEI extends IIntegrationModule { - default String getSearchText() - { - return ""; - } + default String getSearchText() { + return ""; + } - default void setSearchText( String searchText ) - { - } + default void setSearchText(String searchText) { + } - class Stub extends IIntegrationModule.Stub implements IJEI - { - } + class Stub extends IIntegrationModule.Stub implements IJEI { + } } diff --git a/src/main/java/appeng/integration/modules/jei/CondenserCategory.java b/src/main/java/appeng/integration/modules/jei/CondenserCategory.java index e3141203b..351f13b02 100644 --- a/src/main/java/appeng/integration/modules/jei/CondenserCategory.java +++ b/src/main/java/appeng/integration/modules/jei/CondenserCategory.java @@ -18,15 +18,15 @@ package appeng.integration.modules.jei; +import java.util.*; -import appeng.api.AEApi; -import appeng.api.config.CondenserOutput; -import appeng.api.definitions.IMaterials; -import appeng.api.implementations.items.IStorageComponent; -import appeng.core.Api; -import appeng.core.AppEng; -import appeng.tile.misc.TileCondenser; import com.google.common.base.Splitter; + +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.gui.HoverChecker; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; @@ -36,178 +36,169 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.gui.HoverChecker; -import java.util.*; +import appeng.api.AEApi; +import appeng.api.config.CondenserOutput; +import appeng.api.definitions.IMaterials; +import appeng.api.implementations.items.IStorageComponent; +import appeng.core.Api; +import appeng.core.AppEng; +import appeng.tile.misc.TileCondenser; +class CondenserCategory implements IRecipeCategory { -class CondenserCategory implements IRecipeCategory -{ + public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "condenser"); - public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "condenser"); + private final String localizedName; - private final String localizedName; + private final IDrawable background; - private final IDrawable background; + private final IDrawable iconTrash; - private final IDrawable iconTrash; + private final IDrawableAnimated progress; - private final IDrawableAnimated progress; + private final IDrawable iconButton; - private final IDrawable iconButton; + private final IDrawable icon; - private final IDrawable icon; + private final HoverChecker buttonHoverChecker; - private final HoverChecker buttonHoverChecker; + private final Map buttonIcons; - private final Map buttonIcons; + public CondenserCategory(IGuiHelper guiHelper) { + this.localizedName = I18n.format("gui.appliedenergistics2.Condenser"); + this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().condenser().stack(1)); - public CondenserCategory( IGuiHelper guiHelper ) - { - this.localizedName = I18n.format( "gui.appliedenergistics2.Condenser" ); - this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().condenser().stack(1)); + ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/condenser.png"); + this.background = guiHelper.createDrawable(location, 50, 25, 94, 48); - ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/condenser.png" ); - this.background = guiHelper.createDrawable( location, 50, 25, 94, 48 ); + ResourceLocation statesLocation = new ResourceLocation(AppEng.MOD_ID, "textures/guis/states.png"); + this.iconTrash = guiHelper.drawableBuilder(statesLocation, 241, 81, 14, 14).addPadding(28, 0, 2, 0).build(); + this.iconButton = guiHelper.drawableBuilder(statesLocation, 240, 240, 16, 16).addPadding(28, 0, 78, 0).build(); - ResourceLocation statesLocation = new ResourceLocation( AppEng.MOD_ID, "textures/guis/states.png" ); - this.iconTrash = guiHelper.drawableBuilder( statesLocation, 241, 81, 14, 14 ) - .addPadding(28, 0, 2, 0) - .build(); - this.iconButton = guiHelper.drawableBuilder( statesLocation, 240, 240, 16, 16 ) - .addPadding(28, 0, 78, 0) - .build(); + IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 178, 25, 6, 18).addPadding(0, 0, 70, 0) + .build(); + this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, + false); - IDrawableStatic progressDrawable = guiHelper.drawableBuilder( location, 178, 25, 6, 18 ) - .addPadding(0, 0, 70, 0) - .build(); - this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false ); + this.buttonIcons = new EnumMap<>(CondenserOutput.class); - this.buttonIcons = new EnumMap<>(CondenserOutput.class); + this.buttonIcons.put(CondenserOutput.MATTER_BALLS, + guiHelper.drawableBuilder(statesLocation, 16, 112, 14, 14).addPadding(28, 0, 78, 0).build()); + this.buttonIcons.put(CondenserOutput.SINGULARITY, + guiHelper.drawableBuilder(statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build()); + this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16, 0); + } - this.buttonIcons.put(CondenserOutput.MATTER_BALLS, guiHelper.drawableBuilder( statesLocation, 16, 112, 14, 14 ).addPadding(28, 0, 78, 0).build()); - this.buttonIcons.put(CondenserOutput.SINGULARITY, guiHelper.drawableBuilder( statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build()); - this.buttonHoverChecker = new HoverChecker( 28, 28 + 16, 78, 78 + 16, 0 ); - } + private ItemStack getOutput(CondenserOutput recipe) { + switch (recipe) { + case MATTER_BALLS: + return Api.INSTANCE.definitions().materials().matterBall().stack(1); + case SINGULARITY: + return Api.INSTANCE.definitions().materials().singularity().stack(1); + default: + return ItemStack.EMPTY; + } + } - private ItemStack getOutput( CondenserOutput recipe ) - { - switch( recipe ) - { - case MATTER_BALLS: - return Api.INSTANCE.definitions().materials().matterBall().stack(1); - case SINGULARITY: - return Api.INSTANCE.definitions().materials().singularity().stack(1); - default: - return ItemStack.EMPTY; - } - } + @Override + public ResourceLocation getUid() { + return CondenserCategory.UID; + } - @Override - public ResourceLocation getUid() - { - return CondenserCategory.UID; - } + @Override + public Class getRecipeClass() { + return CondenserOutput.class; + } - @Override - public Class getRecipeClass() { - return CondenserOutput.class; - } + @Override + public String getTitle() { + return this.localizedName; + } - @Override - public String getTitle() - { - return this.localizedName; - } + @Override + public IDrawable getBackground() { + return this.background; + } - @Override - public IDrawable getBackground() - { - return this.background; - } + @Override + public IDrawable getIcon() { + return icon; + } - @Override - public IDrawable getIcon() { - return icon; - } + @Override + public void setIngredients(CondenserOutput recipe, IIngredients ingredients) { + ingredients.setOutput(VanillaTypes.ITEM, getOutput(recipe)); + } - @Override - public void setIngredients(CondenserOutput recipe, IIngredients ingredients) { - ingredients.setOutput(VanillaTypes.ITEM, getOutput(recipe) ); - } + @Override + public void draw(CondenserOutput recipe, double mouseX, double mouseY) { + this.progress.draw(); + this.iconTrash.draw(); + this.iconButton.draw(); - @Override - public void draw(CondenserOutput recipe, double mouseX, double mouseY) { - this.progress.draw(); - this.iconTrash.draw(); - this.iconButton.draw(); + IDrawable buttonIcon = this.buttonIcons.get(recipe); + if (buttonIcon != null) { + buttonIcon.draw(); + } + } - IDrawable buttonIcon = this.buttonIcons.get(recipe); - if (buttonIcon != null) { - buttonIcon.draw(); - } - } + @Override + public void setRecipe(IRecipeLayout recipeLayout, CondenserOutput output, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, false, 54, 26); - @Override - public void setRecipe(IRecipeLayout recipeLayout, CondenserOutput output, IIngredients ingredients ) - { - IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - itemStacks.init( 0, false, 54, 26 ); + // Get all storage cells and cycle them through a fake input slot + itemStacks.init(1, true, 50, 0); + itemStacks.set(1, this.getViableStorageComponents(output)); - // Get all storage cells and cycle them through a fake input slot - itemStacks.init( 1, true, 50, 0 ); - itemStacks.set( 1, this.getViableStorageComponents( output ) ); + // This only sets the output + itemStacks.set(ingredients); + } - // This only sets the output - itemStacks.set( ingredients ); - } + private List getViableStorageComponents(CondenserOutput condenserOutput) { + IMaterials materials = AEApi.instance().definitions().materials(); + List viableComponents = new ArrayList<>(); + materials.cell1kPart().maybeStack(1) + .ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack)); + materials.cell4kPart().maybeStack(1) + .ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack)); + materials.cell16kPart().maybeStack(1) + .ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack)); + materials.cell64kPart().maybeStack(1) + .ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack)); + return viableComponents; + } - private List getViableStorageComponents(CondenserOutput condenserOutput ) - { - IMaterials materials = AEApi.instance().definitions().materials(); - List viableComponents = new ArrayList<>(); - materials.cell1kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) ); - materials.cell4kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) ); - materials.cell16kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) ); - materials.cell64kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) ); - return viableComponents; - } + private void addViableComponent(CondenserOutput condenserOutput, List viableComponents, + ItemStack itemStack) { + IStorageComponent comp = (IStorageComponent) itemStack.getItem(); + int storage = comp.getBytes(itemStack) * TileCondenser.BYTE_MULTIPLIER; + if (storage >= condenserOutput.requiredPower) { + viableComponents.add(itemStack); + } + } - private void addViableComponent(CondenserOutput condenserOutput, List viableComponents, ItemStack itemStack ) - { - IStorageComponent comp = (IStorageComponent) itemStack.getItem(); - int storage = comp.getBytes( itemStack ) * TileCondenser.BYTE_MULTIPLIER; - if( storage >= condenserOutput.requiredPower ) - { - viableComponents.add( itemStack ); - } - } + @Override + public List getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) { - @Override - public List getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) { + if (this.buttonHoverChecker.checkHover((int) mouseX, (int) mouseY)) { + String key; - if( this.buttonHoverChecker.checkHover( (int) mouseX, (int) mouseY ) ) - { - String key; + switch (output) { + case MATTER_BALLS: + key = "gui.tooltips.appliedenergistics2.MatterBalls"; + break; + case SINGULARITY: + key = "gui.tooltips.appliedenergistics2.Singularity"; + break; + default: + return Collections.emptyList(); + } - switch( output ) - { - case MATTER_BALLS: - key = "gui.tooltips.appliedenergistics2.MatterBalls"; - break; - case SINGULARITY: - key = "gui.tooltips.appliedenergistics2.Singularity"; - break; - default: - return Collections.emptyList(); - } - - return Splitter.on( "\\n" ).splitToList( I18n.format( key, output.requiredPower ) ); - } - return Collections.emptyList(); - } + return Splitter.on("\\n").splitToList(I18n.format(key, output.requiredPower)); + } + return Collections.emptyList(); + } } diff --git a/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java b/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java index 945b569bc..7e903dbad 100644 --- a/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java +++ b/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java @@ -18,11 +18,15 @@ package appeng.integration.modules.jei; +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; -import appeng.core.Api; -import appeng.core.AppEng; -import appeng.recipes.handlers.GrinderOptionalResult; -import appeng.recipes.handlers.GrinderRecipe; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; @@ -30,88 +34,78 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import appeng.core.Api; +import appeng.core.AppEng; +import appeng.recipes.handlers.GrinderOptionalResult; +import appeng.recipes.handlers.GrinderRecipe; +class GrinderRecipeCategory implements IRecipeCategory { -class GrinderRecipeCategory implements IRecipeCategory -{ + public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "grinder"); - public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "grinder"); + private final String localizedName; - private final String localizedName; + private final IDrawable background; - private final IDrawable background; + private final IDrawable icon; - private final IDrawable icon; + public GrinderRecipeCategory(IGuiHelper guiHelper) { + this.localizedName = I18n.format("block.appliedenergistics2.grindstone"); - public GrinderRecipeCategory( IGuiHelper guiHelper ) - { - this.localizedName = I18n.format( "block.appliedenergistics2.grindstone" ); + ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/grinder.png"); + this.background = guiHelper.createDrawable(location, 11, 16, 154, 70); - ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/grinder.png" ); - this.background = guiHelper.createDrawable( location, 11, 16, 154, 70 ); + this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().grindstone().stack(1)); + } - this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().grindstone().stack(1)); - } + @Override + public ResourceLocation getUid() { + return GrinderRecipeCategory.UID; + } - @Override - public ResourceLocation getUid() - { - return GrinderRecipeCategory.UID; - } + @Override + public String getTitle() { + return this.localizedName; + } - @Override - public String getTitle() - { - return this.localizedName; - } + @Override + public IDrawable getBackground() { + return this.background; + } - @Override - public IDrawable getBackground() - { - return this.background; - } + @Override + public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipe recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - @Override - public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipe recipe, IIngredients ingredients ) - { - IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, true, 0, 0); + itemStacks.init(1, false, 100, 46); + itemStacks.init(2, false, 118, 46); + itemStacks.init(3, false, 136, 46); - itemStacks.init( 0, true, 0, 0 ); - itemStacks.init( 1, false, 100, 46 ); - itemStacks.init( 2, false, 118, 46 ); - itemStacks.init( 3, false, 136, 46 ); + itemStacks.set(ingredients); + } - itemStacks.set( ingredients ); - } + @Override + public Class getRecipeClass() { + return GrinderRecipe.class; + } - @Override - public Class getRecipeClass() { - return GrinderRecipe.class; - } + @Override + public IDrawable getIcon() { + return icon; + } - @Override - public IDrawable getIcon() { - return icon; - } - - @Override - public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) { - ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient())); - List outputs = new ArrayList<>( 3 ); - outputs.add( recipe.getRecipeOutput() ); - for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) { - outputs.add(optionalResult.getResult()); - } - ingredients.setOutputs( VanillaTypes.ITEM, outputs ); - } + @Override + public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient())); + List outputs = new ArrayList<>(3); + outputs.add(recipe.getRecipeOutput()); + for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) { + outputs.add(optionalResult.getResult()); + } + ingredients.setOutputs(VanillaTypes.ITEM, outputs); + } // FIXME USE SPECIAL INGREDIENT TYPE // FIXME @Override diff --git a/src/main/java/appeng/integration/modules/jei/InscriberRecipeCategory.java b/src/main/java/appeng/integration/modules/jei/InscriberRecipeCategory.java index c0abaaf91..3700db074 100644 --- a/src/main/java/appeng/integration/modules/jei/InscriberRecipeCategory.java +++ b/src/main/java/appeng/integration/modules/jei/InscriberRecipeCategory.java @@ -18,10 +18,13 @@ package appeng.integration.modules.jei; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.resources.I18n; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; -import appeng.core.Api; -import appeng.core.AppEng; -import appeng.recipes.handlers.InscriberRecipe; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.*; import mezz.jei.api.gui.drawable.IDrawable; @@ -31,95 +34,86 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import java.util.ArrayList; -import java.util.List; +import appeng.core.Api; +import appeng.core.AppEng; +import appeng.recipes.handlers.InscriberRecipe; +class InscriberRecipeCategory implements IRecipeCategory { -class InscriberRecipeCategory implements IRecipeCategory -{ + private static final int SLOT_INPUT_TOP = 0; + private static final int SLOT_INPUT_MIDDLE = 1; + private static final int SLOT_INPUT_BOTTOM = 2; + private static final int SLOT_OUTPUT = 3; - private static final int SLOT_INPUT_TOP = 0; - private static final int SLOT_INPUT_MIDDLE = 1; - private static final int SLOT_INPUT_BOTTOM = 2; - private static final int SLOT_OUTPUT = 3; + static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "appliedenergistics2.inscriber"); - static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "appliedenergistics2.inscriber"); + private final IDrawable background; - private final IDrawable background; + private final String localizedName; - private final String localizedName; + private final IDrawableAnimated progress; - private final IDrawableAnimated progress; + private final IDrawable icon; - private final IDrawable icon; + public InscriberRecipeCategory(IGuiHelper guiHelper) { + ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/inscriber.png"); + this.background = guiHelper.createDrawable(location, 44, 15, 97, 64); + this.localizedName = I18n.format("block.appliedenergistics2.inscriber"); - public InscriberRecipeCategory( IGuiHelper guiHelper ) - { - ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/inscriber.png" ); - this.background = guiHelper.createDrawable( location, 44, 15, 97, 64 ); - this.localizedName = I18n.format( "block.appliedenergistics2.inscriber" ); + IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 135, 177, 6, 18).addPadding(24, 0, 91, 0) + .build(); + this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, + false); - IDrawableStatic progressDrawable = guiHelper.drawableBuilder( location, 135, 177, 6, 18 ) - .addPadding(24, 0, 91, 0) - .build(); - this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false ); + this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().inscriber().stack(1)); + } - this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().inscriber().stack(1)); - } + @Override + public ResourceLocation getUid() { + return UID; + } - @Override - public ResourceLocation getUid() - { - return UID; - } + @Override + public String getTitle() { + return this.localizedName; + } - @Override - public String getTitle() - { - return this.localizedName; - } + @Override + public IDrawable getBackground() { + return this.background; + } - @Override - public IDrawable getBackground() - { - return this.background; - } + @Override + public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipe recipeWrapper, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - @Override - public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipe recipeWrapper, IIngredients ingredients ) - { - IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(SLOT_INPUT_TOP, true, 0, 0); + itemStacks.init(SLOT_INPUT_MIDDLE, true, 18, 23); + itemStacks.init(SLOT_INPUT_BOTTOM, true, 0, 46); + itemStacks.init(SLOT_OUTPUT, false, 68, 24); - itemStacks.init( SLOT_INPUT_TOP, true, 0, 0 ); - itemStacks.init( SLOT_INPUT_MIDDLE, true, 18, 23 ); - itemStacks.init( SLOT_INPUT_BOTTOM, true, 0, 46 ); - itemStacks.init( SLOT_OUTPUT, false, 68, 24 ); + itemStacks.set(ingredients); + } - itemStacks.set( ingredients ); - } + @Override + public Class getRecipeClass() { + return InscriberRecipe.class; + } - @Override - public Class getRecipeClass() { - return InscriberRecipe.class; - } + @Override + public IDrawable getIcon() { + return this.icon; + } - @Override - public IDrawable getIcon() { - return this.icon; - } + @Override + public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput()); + } - @Override - public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) { - ingredients.setInputIngredients(recipe.getIngredients()); - ingredients.setOutput( VanillaTypes.ITEM, recipe.getOutput() ); - } - - @Override - public void draw(InscriberRecipe recipe, double mouseX, double mouseY) { - this.progress.draw(); - } + @Override + public void draw(InscriberRecipe recipe, double mouseX, double mouseY) { + this.progress.draw(); + } } diff --git a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java index 0e0e13246..0e67ba5ad 100644 --- a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java @@ -18,6 +18,22 @@ package appeng.integration.modules.jei; +import java.util.Optional; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.RecipeManager; +import net.minecraft.util.ResourceLocation; + +import mezz.jei.api.IModPlugin; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.constants.VanillaRecipeCategoryUid; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.registration.*; +import mezz.jei.api.runtime.IJeiRuntime; import appeng.api.AEApi; import appeng.api.config.CondenserOutput; @@ -33,62 +49,42 @@ import appeng.core.localization.GuiText; import appeng.integration.abstraction.JEIFacade; import appeng.recipes.handlers.GrinderRecipe; import appeng.recipes.handlers.InscriberRecipe; -import com.google.common.collect.ImmutableList; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.JeiPlugin; -import mezz.jei.api.constants.VanillaRecipeCategoryUid; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.registration.*; -import mezz.jei.api.runtime.IJeiRuntime; -import net.minecraft.client.Minecraft; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.util.ResourceLocation; - -import java.util.Optional; - @JeiPlugin -public class JEIPlugin implements IModPlugin -{ - private static final ResourceLocation ID = new ResourceLocation(AppEng.MOD_ID, "core"); +public class JEIPlugin implements IModPlugin { + private static final ResourceLocation ID = new ResourceLocation(AppEng.MOD_ID, "core"); - @Override - public ResourceLocation getPluginUid() { - return ID; - } + @Override + public ResourceLocation getPluginUid() { + return ID; + } - @Override - public void registerItemSubtypes( ISubtypeRegistration subtypeRegistry ) - { - final Optional maybeFacade = AEApi.instance().definitions().items().facade().maybeItem(); - maybeFacade.ifPresent( subtypeRegistry::useNbtForSubtypes ); - } + @Override + public void registerItemSubtypes(ISubtypeRegistration subtypeRegistry) { + final Optional maybeFacade = AEApi.instance().definitions().items().facade().maybeItem(); + maybeFacade.ifPresent(subtypeRegistry::useNbtForSubtypes); + } - @Override - public void registerCategories( IRecipeCategoryRegistration registry ) - { - registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ), - new CondenserCategory( registry.getJeiHelpers().getGuiHelper() ), - new InscriberRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) ); - } + @Override + public void registerCategories(IRecipeCategoryRegistration registry) { + registry.addRecipeCategories(new GrinderRecipeCategory(registry.getJeiHelpers().getGuiHelper()), + new CondenserCategory(registry.getJeiHelpers().getGuiHelper()), + new InscriberRecipeCategory(registry.getJeiHelpers().getGuiHelper())); + } - @Override - public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) { - // Allow recipe transfer from JEI to crafting and pattern terminal - registration - .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ), - VanillaRecipeCategoryUid.CRAFTING ); - registration - .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), - VanillaRecipeCategoryUid.CRAFTING ); - } + @Override + public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) { + // Allow recipe transfer from JEI to crafting and pattern terminal + registration.addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerCraftingTerm.class), + VanillaRecipeCategoryUid.CRAFTING); + registration.addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerPatternTerm.class), + VanillaRecipeCategoryUid.CRAFTING); + } - @Override - public void registerRecipes(IRecipeRegistration registration) { + @Override + public void registerRecipes(IRecipeRegistration registration) { - IDefinitions definitions = AEApi.instance().definitions(); + IDefinitions definitions = AEApi.instance().definitions(); // FIXME Optional itemFacade = definitions.items().facade().maybeItem(); // FIXME Optional cableAnchor = definitions.parts().cableAnchor().maybeStack( 1 ); @@ -97,77 +93,75 @@ public class JEIPlugin implements IModPlugin // FIXME registration.addRecipeRegistryPlugin( new FacadeRegistryPlugin( (ItemFacade) itemFacade.get(), cableAnchor.get() ) ); // FIXME } - RecipeManager recipeManager = Minecraft.getInstance().world.getRecipeManager(); - registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID); - registration.addRecipes(recipeManager.getRecipes(InscriberRecipe.TYPE).values(), InscriberRecipeCategory.UID ); - registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY), CondenserCategory.UID); + RecipeManager recipeManager = Minecraft.getInstance().world.getRecipeManager(); + registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID); + registration.addRecipes(recipeManager.getRecipes(InscriberRecipe.TYPE).values(), InscriberRecipeCategory.UID); + registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY), + CondenserCategory.UID); - registerDescriptions(definitions, registration); - } + registerDescriptions(definitions, registration); + } - @Override - public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - IDefinitions definitions = AEApi.instance().definitions(); + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { + IDefinitions definitions = AEApi.instance().definitions(); - ItemStack grindstone = definitions.blocks().grindstone().stack(1); - registration.addRecipeCatalyst( grindstone, GrinderRecipeCategory.UID ); + ItemStack grindstone = definitions.blocks().grindstone().stack(1); + registration.addRecipeCatalyst(grindstone, GrinderRecipeCategory.UID); - ItemStack condenser = definitions.blocks().condenser().stack(1); - registration.addRecipeCatalyst(condenser, CondenserCategory.UID); + ItemStack condenser = definitions.blocks().condenser().stack(1); + registration.addRecipeCatalyst(condenser, CondenserCategory.UID); - ItemStack inscriber = definitions.blocks().inscriber().stack(1); - registration.addRecipeCatalyst( inscriber, InscriberRecipeCategory.UID ); - } + ItemStack inscriber = definitions.blocks().inscriber().stack(1); + registration.addRecipeCatalyst(inscriber, InscriberRecipeCategory.UID); + } - private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry ) - { - IMaterials materials = definitions.materials(); + private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry) { + IMaterials materials = definitions.materials(); - final String[] message; - if( AEConfig.instance().isFeatureEnabled( AEFeature.CERTUS_QUARTZ_WORLD_GEN ) ) - { - message = new String[]{GuiText.ChargedQuartz.getTranslationKey(), "", GuiText.ChargedQuartzFind.getTranslationKey()}; - } - else - { - message = new String[]{GuiText.ChargedQuartzFind.getTranslationKey()}; - } - this.addDescription( registry, materials.certusQuartzCrystalCharged(), message ); + final String[] message; + if (AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) { + message = new String[] { GuiText.ChargedQuartz.getTranslationKey(), "", + GuiText.ChargedQuartzFind.getTranslationKey() }; + } else { + message = new String[] { GuiText.ChargedQuartzFind.getTranslationKey() }; + } + this.addDescription(registry, materials.certusQuartzCrystalCharged(), message); - if( AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN ) ) - { - this.addDescription( registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() ); - this.addDescription( registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() ); - this.addDescription( registry, materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) { + this.addDescription(registry, materials.logicProcessorPress(), + GuiText.inWorldCraftingPresses.getTranslationKey()); + this.addDescription(registry, materials.calcProcessorPress(), + GuiText.inWorldCraftingPresses.getTranslationKey()); + this.addDescription(registry, materials.engProcessorPress(), + GuiText.inWorldCraftingPresses.getTranslationKey()); + } - if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) ) - { - this.addDescription( registry, materials.fluixCrystal(), GuiText.inWorldFluix.getTranslationKey() ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) { + this.addDescription(registry, materials.fluixCrystal(), GuiText.inWorldFluix.getTranslationKey()); + } - if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) ) - { - this.addDescription( registry, materials.qESingularity(), GuiText.inWorldSingularity.getTranslationKey() ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) { + this.addDescription(registry, materials.qESingularity(), GuiText.inWorldSingularity.getTranslationKey()); + } - if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) ) - { - this.addDescription( registry, materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getTranslationKey() ); - this.addDescription( registry, materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getTranslationKey() ); - this.addDescription( registry, materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getTranslationKey() ); - } + if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) { + this.addDescription(registry, materials.purifiedCertusQuartzCrystal(), + GuiText.inWorldPurificationCertus.getTranslationKey()); + this.addDescription(registry, materials.purifiedNetherQuartzCrystal(), + GuiText.inWorldPurificationNether.getTranslationKey()); + this.addDescription(registry, materials.purifiedFluixCrystal(), + GuiText.inWorldPurificationFluix.getTranslationKey()); + } - } + } - private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String... message ) - { - registry.addIngredientInfo( itemDefinition.stack(1), VanillaTypes.ITEM, message ); - } + private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String... message) { + registry.addIngredientInfo(itemDefinition.stack(1), VanillaTypes.ITEM, message); + } - @Override - public void onRuntimeAvailable( IJeiRuntime jeiRuntime ) - { - JEIFacade.setInstance(new JeiRuntimeAdapter(jeiRuntime)); - } + @Override + public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { + JEIFacade.setInstance(new JeiRuntimeAdapter(jeiRuntime)); + } } diff --git a/src/main/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java b/src/main/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java index 25ffbc162..d6e62787f 100644 --- a/src/main/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java +++ b/src/main/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java @@ -18,36 +18,32 @@ package appeng.integration.modules.jei; - -import appeng.integration.abstraction.IJEI; import com.google.common.base.Strings; + import mezz.jei.api.runtime.IJeiRuntime; -class JeiRuntimeAdapter implements IJEI -{ +import appeng.integration.abstraction.IJEI; - private final IJeiRuntime runtime; +class JeiRuntimeAdapter implements IJEI { - JeiRuntimeAdapter( IJeiRuntime jeiRuntime ) - { - this.runtime = jeiRuntime; - } + private final IJeiRuntime runtime; - @Override - public boolean isEnabled() - { - return true; - } + JeiRuntimeAdapter(IJeiRuntime jeiRuntime) { + this.runtime = jeiRuntime; + } - @Override - public String getSearchText() - { - return Strings.nullToEmpty( this.runtime.getIngredientFilter().getFilterText() ); - } + @Override + public boolean isEnabled() { + return true; + } - @Override - public void setSearchText( String searchText ) - { - this.runtime.getIngredientFilter().setFilterText( Strings.nullToEmpty( searchText ) ); - } + @Override + public String getSearchText() { + return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText()); + } + + @Override + public void setSearchText(String searchText) { + this.runtime.getIngredientFilter().setFilterText(Strings.nullToEmpty(searchText)); + } } diff --git a/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java b/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java index aca900b17..813dffd16 100644 --- a/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java +++ b/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java @@ -18,17 +18,12 @@ package appeng.integration.modules.jei; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; -import appeng.container.slot.SlotCraftingMatrix; -import appeng.container.slot.SlotFakeCraftingMatrix; -import appeng.core.AELog; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketJEIRecipe; -import appeng.util.Platform; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.gui.ingredient.IGuiIngredient; -import mezz.jei.api.recipe.transfer.IRecipeTransferError; -import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; @@ -36,96 +31,89 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ingredient.IGuiIngredient; +import mezz.jei.api.recipe.transfer.IRecipeTransferError; +import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotFakeCraftingMatrix; +import appeng.core.AELog; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketJEIRecipe; +import appeng.util.Platform; -class RecipeTransferHandler implements IRecipeTransferHandler -{ +class RecipeTransferHandler implements IRecipeTransferHandler { - private final Class containerClass; + private final Class containerClass; - RecipeTransferHandler( Class containerClass ) - { - this.containerClass = containerClass; - } + RecipeTransferHandler(Class containerClass) { + this.containerClass = containerClass; + } - @Override - public Class getContainerClass() - { - return this.containerClass; - } + @Override + public Class getContainerClass() { + return this.containerClass; + } - @Nullable - @Override - public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer, boolean doTransfer) { - if( !doTransfer ) - { - return null; - } + @Nullable + @Override + public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player, + boolean maxTransfer, boolean doTransfer) { + if (!doTransfer) { + return null; + } - Map> ingredients = recipeLayout.getItemStacks().getGuiIngredients(); + Map> ingredients = recipeLayout.getItemStacks() + .getGuiIngredients(); - final CompoundNBT recipe = new CompoundNBT(); + final CompoundNBT recipe = new CompoundNBT(); - int slotIndex = 0; - for( Map.Entry> ingredientEntry : ingredients.entrySet() ) - { - IGuiIngredient ingredient = ingredientEntry.getValue(); - if( !ingredient.isInput() ) - { - continue; - } + int slotIndex = 0; + for (Map.Entry> ingredientEntry : ingredients.entrySet()) { + IGuiIngredient ingredient = ingredientEntry.getValue(); + if (!ingredient.isInput()) { + continue; + } - for( final Slot slot : container.inventorySlots ) - { - if( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix) - { - if( slot.getSlotIndex() == slotIndex ) - { - final ListNBT tags = new ListNBT(); - final List list = new ArrayList<>(); - final ItemStack displayed = ingredient.getDisplayedIngredient(); + for (final Slot slot : container.inventorySlots) { + if (slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix) { + if (slot.getSlotIndex() == slotIndex) { + final ListNBT tags = new ListNBT(); + final List list = new ArrayList<>(); + final ItemStack displayed = ingredient.getDisplayedIngredient(); - // prefer currently displayed item - if( displayed != null && !displayed.isEmpty() ) - { - list.add( displayed ); - } + // prefer currently displayed item + if (displayed != null && !displayed.isEmpty()) { + list.add(displayed); + } - // prefer pure crystals. - for( ItemStack stack : ingredient.getAllIngredients() ) - { - if( Platform.isRecipePrioritized( stack ) ) - { - list.add( 0, stack ); - } - else - { - list.add( stack ); - } - } + // prefer pure crystals. + for (ItemStack stack : ingredient.getAllIngredients()) { + if (Platform.isRecipePrioritized(stack)) { + list.add(0, stack); + } else { + list.add(stack); + } + } - for( final ItemStack is : list ) - { - final CompoundNBT tag = new CompoundNBT(); - is.write( tag ); - tags.add( tag ); - } + for (final ItemStack is : list) { + final CompoundNBT tag = new CompoundNBT(); + is.write(tag); + tags.add(tag); + } - recipe.put( "#" + slot.getSlotIndex(), tags ); - break; - } - } - } + recipe.put("#" + slot.getSlotIndex(), tags); + break; + } + } + } - slotIndex++; - } + slotIndex++; + } - NetworkHandler.instance().sendToServer( new PacketJEIRecipe( recipe ) ); + NetworkHandler.instance().sendToServer(new PacketJEIRecipe(recipe)); - return null; - } + return null; + } } diff --git a/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java index d7bdbc743..310b32b1b 100644 --- a/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java @@ -18,11 +18,8 @@ package appeng.integration.modules.waila; +import java.util.List; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -30,8 +27,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; - +import mcp.mobius.waila.api.IComponentProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.IServerDataProvider; /** * Base implementation for {@link mcp.mobius.waila.api.IComponentProvider} @@ -40,33 +39,32 @@ import java.util.List; * @version rv2 * @since rv2 */ -public abstract class BaseWailaDataProvider implements IComponentProvider, IServerDataProvider -{ +public abstract class BaseWailaDataProvider implements IComponentProvider, IServerDataProvider { - @Override - public ItemStack getStack( final IDataAccessor accessor, final IPluginConfig config ) - { - return ItemStack.EMPTY; - } + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + return ItemStack.EMPTY; + } - @Override - public void appendServerData(CompoundNBT compoundNBT, ServerPlayerEntity serverPlayerEntity, World world, TileEntity tileEntity) { + @Override + public void appendServerData(CompoundNBT compoundNBT, ServerPlayerEntity serverPlayerEntity, World world, + TileEntity tileEntity) { - } + } - @Override - public void appendHead(List tooltip, IDataAccessor accessor, IPluginConfig config) { + @Override + public void appendHead(List tooltip, IDataAccessor accessor, IPluginConfig config) { - } + } - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - } + } - @Override - public void appendTail(List tooltip, IDataAccessor accessor, IPluginConfig config) { + @Override + public void appendTail(List tooltip, IDataAccessor accessor, IPluginConfig config) { - } + } } diff --git a/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java index aa4db838b..7d84cc2ae 100644 --- a/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java @@ -18,14 +18,11 @@ package appeng.integration.modules.waila; +import java.util.List; +import java.util.Optional; -import appeng.api.parts.IPart; -import appeng.integration.modules.waila.part.*; import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; + import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -34,9 +31,13 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; -import java.util.Optional; +import mcp.mobius.waila.api.IComponentProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.IServerDataProvider; +import appeng.api.parts.IPart; +import appeng.integration.modules.waila.part.*; /** * Delegation provider for parts through {@link IPartWailaDataProvider} @@ -45,135 +46,119 @@ import java.util.Optional; * @version rv2 * @since rv2 */ -public final class PartWailaDataProvider implements IComponentProvider, IServerDataProvider -{ - /** - * Contains all providers - */ - private final List providers; +public final class PartWailaDataProvider implements IComponentProvider, IServerDataProvider { + /** + * Contains all providers + */ + private final List providers; - /** - * Can access parts through view-hits - */ - private final PartAccessor accessor = new PartAccessor(); + /** + * Can access parts through view-hits + */ + private final PartAccessor accessor = new PartAccessor(); - /** - * Traces views hit on blocks - */ - private final Tracer tracer = new Tracer(); + /** + * Traces views hit on blocks + */ + private final Tracer tracer = new Tracer(); - /** - * Initializes the provider list with all wanted providers - */ - public PartWailaDataProvider() - { - final IPartWailaDataProvider channel = new ChannelWailaDataProvider(); - final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider(); - final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider(); - final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider(); - final IPartWailaDataProvider partStack = new PartStackWailaDataProvider(); + /** + * Initializes the provider list with all wanted providers + */ + public PartWailaDataProvider() { + final IPartWailaDataProvider channel = new ChannelWailaDataProvider(); + final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider(); + final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider(); + final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider(); + final IPartWailaDataProvider partStack = new PartStackWailaDataProvider(); - this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack, p2pState ); - } + this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState); + } - @Override - public ItemStack getStack( final IDataAccessor accessor, final IPluginConfig config ) - { - final TileEntity te = accessor.getTileEntity(); - final RayTraceResult mop = accessor.getHitResult(); + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); + final RayTraceResult mop = accessor.getHitResult(); - final Optional maybePart = this.accessor.getMaybePart( te, mop ); + final Optional maybePart = this.accessor.getMaybePart(te, mop); - if( maybePart.isPresent() ) - { - final IPart part = maybePart.get(); + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); - ItemStack wailaStack = ItemStack.EMPTY; + ItemStack wailaStack = ItemStack.EMPTY; - for( final IPartWailaDataProvider provider : this.providers ) - { - wailaStack = provider.getStack( part, config, wailaStack ); - } - return wailaStack; - } + for (final IPartWailaDataProvider provider : this.providers) { + wailaStack = provider.getStack(part, config, wailaStack); + } + return wailaStack; + } - return ItemStack.EMPTY; - } + return ItemStack.EMPTY; + } - @Override - public void appendHead( List currentToolTip, final IDataAccessor accessor, final IPluginConfig config ) - { - final TileEntity te = accessor.getTileEntity(); - final RayTraceResult mop = accessor.getHitResult(); + @Override + public void appendHead(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); + final RayTraceResult mop = accessor.getHitResult(); - final Optional maybePart = this.accessor.getMaybePart( te, mop ); + final Optional maybePart = this.accessor.getMaybePart(te, mop); - if( maybePart.isPresent() ) - { - final IPart part = maybePart.get(); + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); - for( final IPartWailaDataProvider provider : this.providers ) - { - provider.appendHead( part, currentToolTip, accessor, config ); - } - } - } + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendHead(part, currentToolTip, accessor, config); + } + } + } - @Override - public void appendBody(List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - final TileEntity te = accessor.getTileEntity(); - final RayTraceResult mop = accessor.getHitResult(); + @Override + public void appendBody(List tooltip, final IDataAccessor accessor, final IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); + final RayTraceResult mop = accessor.getHitResult(); - final Optional maybePart = this.accessor.getMaybePart( te, mop ); + final Optional maybePart = this.accessor.getMaybePart(te, mop); - if( maybePart.isPresent() ) - { - final IPart part = maybePart.get(); + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); - for( final IPartWailaDataProvider provider : this.providers ) - { - provider.appendBody( part, tooltip, accessor, config ); - } - } - } + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendBody(part, tooltip, accessor, config); + } + } + } - @Override - public void appendTail( List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - final TileEntity te = accessor.getTileEntity(); - final RayTraceResult mop = accessor.getHitResult(); + @Override + public void appendTail(List tooltip, final IDataAccessor accessor, final IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); + final RayTraceResult mop = accessor.getHitResult(); - final Optional maybePart = this.accessor.getMaybePart( te, mop ); + final Optional maybePart = this.accessor.getMaybePart(te, mop); - if( maybePart.isPresent() ) - { - final IPart part = maybePart.get(); + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); - for( final IPartWailaDataProvider provider : this.providers ) - { - provider.appendTail( part, tooltip, accessor, config ); - } - } - } + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendTail(part, tooltip, accessor, config); + } + } + } - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) { - final RayTraceResult mop = this.tracer.retraceBlock( world, player, te.getPos() ); + @Override + public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) { + final RayTraceResult mop = this.tracer.retraceBlock(world, player, te.getPos()); - if( mop != null ) - { - final Optional maybePart = this.accessor.getMaybePart( te, mop ); + if (mop != null) { + final Optional maybePart = this.accessor.getMaybePart(te, mop); - if( maybePart.isPresent() ) - { - final IPart part = maybePart.get(); + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); - for( final IPartWailaDataProvider provider : this.providers ) - { - provider.appendServerData( player, part, te, tag, world, te.getPos() ); - } - } - } - } + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendServerData(player, part, te, tag, world, te.getPos()); + } + } + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java index 5bd61f102..4cc28a67b 100644 --- a/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java @@ -18,16 +18,10 @@ package appeng.integration.modules.waila; +import java.util.List; -import appeng.integration.modules.waila.tile.ChargerWailaDataProvider; -import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider; -import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider; -import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider; import com.google.common.collect.Lists; -import mcp.mobius.waila.api.IComponentProvider; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; -import mcp.mobius.waila.api.IServerDataProvider; + import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -35,75 +29,76 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; +import mcp.mobius.waila.api.IComponentProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.IServerDataProvider; +import appeng.integration.modules.waila.tile.ChargerWailaDataProvider; +import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider; +import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider; +import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider; /** - * Delegation provider for tiles through {@link mcp.mobius.waila.api.IComponentProvider} + * Delegation provider for tiles through + * {@link mcp.mobius.waila.api.IComponentProvider} * * @author thatsIch * @version rv2 * @since rv2 */ -public final class TileWailaDataProvider implements IComponentProvider, IServerDataProvider -{ - /** - * Contains all providers - */ - private final List providers; +public final class TileWailaDataProvider implements IComponentProvider, IServerDataProvider { + /** + * Contains all providers + */ + private final List providers; - /** - * Initializes the provider list with all wanted providers - */ - public TileWailaDataProvider() - { - final BaseWailaDataProvider charger = new ChargerWailaDataProvider(); - final BaseWailaDataProvider energyCell = new PowerStorageWailaDataProvider(); - final BaseWailaDataProvider craftingBlock = new PowerStateWailaDataProvider(); - final BaseWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider(); + /** + * Initializes the provider list with all wanted providers + */ + public TileWailaDataProvider() { + final BaseWailaDataProvider charger = new ChargerWailaDataProvider(); + final BaseWailaDataProvider energyCell = new PowerStorageWailaDataProvider(); + final BaseWailaDataProvider craftingBlock = new PowerStateWailaDataProvider(); + final BaseWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider(); - this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor ); - } + this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor); + } - @Override - public ItemStack getStack( final IDataAccessor accessor, final IPluginConfig config ) - { - return ItemStack.EMPTY; - } + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + return ItemStack.EMPTY; + } - @Override - public void appendHead(List currentToolTip, final IDataAccessor accessor, final IPluginConfig config ) - { - for( final BaseWailaDataProvider provider : this.providers ) - { - provider.appendHead(currentToolTip, accessor, config); - } - } + @Override + public void appendHead(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendHead(currentToolTip, accessor, config); + } + } - @Override - public void appendBody( List currentToolTip, final IDataAccessor accessor, final IPluginConfig config ) - { - for( final BaseWailaDataProvider provider : this.providers ) - { - provider.appendBody(currentToolTip, accessor, config); - } - } + @Override + public void appendBody(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendBody(currentToolTip, accessor, config); + } + } - @Override - public void appendTail( List currentToolTip, final IDataAccessor accessor, final IPluginConfig config ) - { - for( final BaseWailaDataProvider provider : this.providers ) - { - provider.appendTail(currentToolTip, accessor, config); - } - } + @Override + public void appendTail(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendTail(currentToolTip, accessor, config); + } + } - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) { + @Override + public void appendServerData(CompoundNBT tag, ServerPlayerEntity player, World world, TileEntity te) { - for( final BaseWailaDataProvider provider : this.providers ) - { - provider.appendServerData(tag, player, world, te); - } - } + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendServerData(tag, player, world, te); + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/WailaModule.java b/src/main/java/appeng/integration/modules/waila/WailaModule.java index b14466798..a54000946 100644 --- a/src/main/java/appeng/integration/modules/waila/WailaModule.java +++ b/src/main/java/appeng/integration/modules/waila/WailaModule.java @@ -18,32 +18,31 @@ package appeng.integration.modules.waila; +import java.util.List; -import appeng.entity.EntityGrowingCrystal; -import appeng.items.misc.ItemCrystalSeed; -import mcp.mobius.waila.api.*; -import appeng.tile.AEBaseTile; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; -import java.util.List; +import mcp.mobius.waila.api.*; + +import appeng.entity.EntityGrowingCrystal; +import appeng.items.misc.ItemCrystalSeed; +import appeng.tile.AEBaseTile; @WailaPlugin -public class WailaModule implements IWailaPlugin -{ +public class WailaModule implements IWailaPlugin { - public void register( final IRegistrar registrar ) - { - final PartWailaDataProvider partHost = new PartWailaDataProvider(); + public void register(final IRegistrar registrar) { + final PartWailaDataProvider partHost = new PartWailaDataProvider(); - registrar.registerStackProvider( partHost, AEBaseTile.class ); - registrar.registerComponentProvider( partHost, TooltipPosition.BODY, AEBaseTile.class ); - registrar.registerBlockDataProvider( partHost, AEBaseTile.class ); + registrar.registerStackProvider(partHost, AEBaseTile.class); + registrar.registerComponentProvider(partHost, TooltipPosition.BODY, AEBaseTile.class); + registrar.registerBlockDataProvider(partHost, AEBaseTile.class); - final TileWailaDataProvider tile = new TileWailaDataProvider(); - registrar.registerComponentProvider( tile, TooltipPosition.BODY, AEBaseTile.class ); - registrar.registerBlockDataProvider( tile, AEBaseTile.class ); - } + final TileWailaDataProvider tile = new TileWailaDataProvider(); + registrar.registerComponentProvider(tile, TooltipPosition.BODY, AEBaseTile.class); + registrar.registerBlockDataProvider(tile, AEBaseTile.class); + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java index f8a76a6fe..9d63e3b53 100644 --- a/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java @@ -18,10 +18,8 @@ package appeng.integration.modules.waila.part; +import java.util.List; -import appeng.api.parts.IPart; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -30,40 +28,42 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import appeng.api.parts.IPart; /** - * Default implementation of {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} + * Default implementation of + * {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} * * @author thatsIch * @version rv2 * @since rv2 */ -public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider -{ - @Override - public ItemStack getStack( final IPart part, final IPluginConfig config, final ItemStack partStack ) - { - return ItemStack.EMPTY; - } +public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider { + @Override + public ItemStack getStack(final IPart part, final IPluginConfig config, final ItemStack partStack) { + return ItemStack.EMPTY; + } - @Override - public void appendHead(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - } + @Override + public void appendHead(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } - @Override - public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - } + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } - @Override - public void appendTail(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - } + @Override + public void appendTail(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } - @Override - public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, BlockPos pos) { - } + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, + BlockPos pos) { + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java index cd6fb08fc..3bcbbe7f2 100644 --- a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java @@ -18,15 +18,8 @@ package appeng.integration.modules.waila.part; +import java.util.List; -import appeng.api.parts.IPart; -import appeng.core.localization.WailaText; -import appeng.parts.networking.PartCableSmart; -import appeng.parts.networking.PartDenseCableSmart; -import it.unimi.dsi.fastutil.objects.Object2ByteMap; -import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -34,8 +27,15 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; +import it.unimi.dsi.fastutil.objects.Object2ByteMap; +import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import appeng.api.parts.IPart; +import appeng.core.localization.WailaText; +import appeng.parts.networking.PartCableSmart; +import appeng.parts.networking.PartDenseCableSmart; /** * Channel-information provider for WAILA @@ -44,110 +44,102 @@ import java.util.List; * @version rv2 * @since rv2 */ -public final class ChannelWailaDataProvider extends BasePartWailaDataProvider -{ - /** - * Channel key used for the transferred {@link net.minecraft.nbt.CompoundNBT} - */ - private static final String ID_USED_CHANNELS = "usedChannels"; +public final class ChannelWailaDataProvider extends BasePartWailaDataProvider { + /** + * Channel key used for the transferred {@link net.minecraft.nbt.CompoundNBT} + */ + private static final String ID_USED_CHANNELS = "usedChannels"; - /** - * Used cache for channels if the channel was not transmitted through the server. - *

- * This is useful, when a player just started to look at a tile and thus just requested the new information from the - * server. - *

- * The cache will be updated from the server. - */ - private final Object2ByteMap cache = new Object2ByteOpenHashMap<>(); + /** + * Used cache for channels if the channel was not transmitted through the + * server. + *

+ * This is useful, when a player just started to look at a tile and thus just + * requested the new information from the server. + *

+ * The cache will be updated from the server. + */ + private final Object2ByteMap cache = new Object2ByteOpenHashMap<>(); - /** - * Adds the used and max channel to the tool tip - * - * @param part being looked at part - * @param tooltip current tool tip - * @param accessor wrapper for various world information - * @param config config to react to various settings - */ - @Override - public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart ) - { - final CompoundNBT tag = accessor.getServerData(); + /** + * Adds the used and max channel to the tool tip + * + * @param part being looked at part + * @param tooltip current tool tip + * @param accessor wrapper for various world information + * @param config config to react to various settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) { + final CompoundNBT tag = accessor.getServerData(); - final byte usedChannels = this.getUsedChannels( part, tag, this.cache ); + final byte usedChannels = this.getUsedChannels(part, tag, this.cache); - if( usedChannels >= 0 ) - { - final byte maxChannels = (byte) ( ( part instanceof PartDenseCableSmart ) ? 32 : 8 ); + if (usedChannels >= 0) { + final byte maxChannels = (byte) ((part instanceof PartDenseCableSmart) ? 32 : 8); - final ITextComponent formattedToolTip = WailaText.Channels.textComponent(usedChannels, maxChannels); - tooltip.add( formattedToolTip ); - } - } - } + final ITextComponent formattedToolTip = WailaText.Channels.textComponent(usedChannels, maxChannels); + tooltip.add(formattedToolTip); + } + } + } - /** - * Determines the source of the channel. - *

- * If the client received information of the channels on the server, they are used, else if the cache contains a - * previous stored value, this will be used. Default value is 0. - * - * @param part part to be looked at - * @param tag tag maybe containing the channel information - * @param cache cache with previous knowledge - * - * @return used channels on the cable - */ - private byte getUsedChannels( final IPart part, final CompoundNBT tag, final Object2ByteMap cache ) - { - final byte usedChannels; + /** + * Determines the source of the channel. + *

+ * If the client received information of the channels on the server, they are + * used, else if the cache contains a previous stored value, this will be used. + * Default value is 0. + * + * @param part part to be looked at + * @param tag tag maybe containing the channel information + * @param cache cache with previous knowledge + * + * @return used channels on the cable + */ + private byte getUsedChannels(final IPart part, final CompoundNBT tag, final Object2ByteMap cache) { + final byte usedChannels; - if( tag.contains( ID_USED_CHANNELS ) ) - { - usedChannels = tag.getByte( ID_USED_CHANNELS ); - this.cache.put( part, usedChannels ); - } - else if( this.cache.containsKey( part ) ) - { - usedChannels = this.cache.get( part ); - } - else - { - usedChannels = -1; - } + if (tag.contains(ID_USED_CHANNELS)) { + usedChannels = tag.getByte(ID_USED_CHANNELS); + this.cache.put(part, usedChannels); + } else if (this.cache.containsKey(part)) { + usedChannels = this.cache.get(part); + } else { + usedChannels = -1; + } - return usedChannels; - } + return usedChannels; + } - /** - * Called on server to transfer information from server to client. - *

- * If the part is a cable, it writes the channel information in the {@code #tag} using the {@code ID_USED_CHANNELS} - * key. - * - * @param player player looking at the part - * @param part part being looked at - * @param te host of the part - * @param tag transferred tag which is send to the client - * @param world world of the part - * @param pos pos of the part - */ - @Override - public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, BlockPos pos) { - if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart ) - { - final CompoundNBT tempTag = new CompoundNBT(); + /** + * Called on server to transfer information from server to client. + *

+ * If the part is a cable, it writes the channel information in the {@code #tag} + * using the {@code ID_USED_CHANNELS} key. + * + * @param player player looking at the part + * @param part part being looked at + * @param te host of the part + * @param tag transferred tag which is send to the client + * @param world world of the part + * @param pos pos of the part + */ + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, + BlockPos pos) { + if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) { + final CompoundNBT tempTag = new CompoundNBT(); - part.writeToNBT( tempTag ); + part.writeToNBT(tempTag); - if( tempTag.contains( ID_USED_CHANNELS ) ) - { - final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS ); + if (tempTag.contains(ID_USED_CHANNELS)) { + final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS); - tag.putByte( ID_USED_CHANNELS, usedChannels ); - } - } - } + tag.putByte(ID_USED_CHANNELS, usedChannels); + } + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java index 89a8fd532..2ef47291b 100644 --- a/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java @@ -18,10 +18,8 @@ package appeng.integration.modules.waila.part; +import java.util.List; -import appeng.api.parts.IPart; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -30,26 +28,29 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import appeng.api.parts.IPart; /** - * An abstraction layer of the {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for + * An abstraction layer of the + * {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for * {@link appeng.api.parts.IPart}. * * @author thatsIch * @version rv2 * @since rv2 */ -public interface IPartWailaDataProvider -{ - ItemStack getStack( IPart part, IPluginConfig config, ItemStack partStack ); +public interface IPartWailaDataProvider { + ItemStack getStack(IPart part, IPluginConfig config, ItemStack partStack); - void appendHead(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config ); + void appendHead(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); - void appendBody(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config ); + void appendBody(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); - void appendTail(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config ); + void appendTail(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); - void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, BlockPos pos ); + void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, + BlockPos pos); } diff --git a/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java index 9c2462b88..e953953f0 100644 --- a/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java @@ -18,15 +18,10 @@ package appeng.integration.modules.waila.part; +import java.util.List; -import appeng.api.parts.IPart; -import appeng.core.localization.WailaText; -import appeng.me.GridAccessException; -import appeng.parts.p2p.PartP2PTunnel; -import appeng.util.Platform; import com.google.common.collect.Iterators; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; + import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -35,132 +30,116 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; -import java.util.List; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import appeng.api.parts.IPart; +import appeng.core.localization.WailaText; +import appeng.me.GridAccessException; +import appeng.parts.p2p.PartP2PTunnel; +import appeng.util.Platform; /** * Provides information about a P2P tunnel to WAILA. */ -public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider -{ +public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider { - private static final int STATE_UNLINKED = 0; - private static final int STATE_OUTPUT = 1; - private static final int STATE_INPUT = 2; - public static final String TAG_P2P_STATE = "p2p_state"; - public static final String TAG_P2P_FREQUENCY = "p2p_frequency"; + private static final int STATE_UNLINKED = 0; + private static final int STATE_OUTPUT = 1; + private static final int STATE_INPUT = 2; + public static final String TAG_P2P_STATE = "p2p_state"; + public static final String TAG_P2P_FREQUENCY = "p2p_frequency"; - /** - * Adds state to the tooltip - * - * @param part part with state - * @param tooltip to be added to tooltip - * @param accessor wrapper for various information - * @param config config settings - */ - @Override - public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - if( part instanceof PartP2PTunnel ) - { - CompoundNBT nbtData = accessor.getServerData(); - if( nbtData.contains( TAG_P2P_STATE ) ) - { - int[] stateArr = nbtData.getIntArray( TAG_P2P_STATE ); - if( stateArr.length == 2 ) - { - int state = stateArr[0]; - int outputs = stateArr[1]; + /** + * Adds state to the tooltip + * + * @param part part with state + * @param tooltip to be added to tooltip + * @param accessor wrapper for various information + * @param config config settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof PartP2PTunnel) { + CompoundNBT nbtData = accessor.getServerData(); + if (nbtData.contains(TAG_P2P_STATE)) { + int[] stateArr = nbtData.getIntArray(TAG_P2P_STATE); + if (stateArr.length == 2) { + int state = stateArr[0]; + int outputs = stateArr[1]; - switch( state ) - { - case STATE_UNLINKED: - tooltip.add( WailaText.P2PUnlinked.textComponent() ); - break; - case STATE_OUTPUT: - tooltip.add( WailaText.P2POutput.textComponent() ); - break; - case STATE_INPUT: - tooltip.add( getOutputText( outputs ) ); - break; - } - } + switch (state) { + case STATE_UNLINKED: + tooltip.add(WailaText.P2PUnlinked.textComponent()); + break; + case STATE_OUTPUT: + tooltip.add(WailaText.P2POutput.textComponent()); + break; + case STATE_INPUT: + tooltip.add(getOutputText(outputs)); + break; + } + } - final short freq = nbtData.getShort( TAG_P2P_FREQUENCY ); - final String freqTooltip = Platform.p2p().toHexString( freq ); - tooltip.add( new TranslationTextComponent( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) ); - } - } - } + final short freq = nbtData.getShort(TAG_P2P_FREQUENCY); + final String freqTooltip = Platform.p2p().toHexString(freq); + tooltip.add(new TranslationTextComponent("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip)); + } + } + } - @Override - public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, BlockPos pos) { - if( part instanceof PartP2PTunnel ) - { - final PartP2PTunnel tunnel = (PartP2PTunnel) part; + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, TileEntity te, CompoundNBT tag, World world, + BlockPos pos) { + if (part instanceof PartP2PTunnel) { + final PartP2PTunnel tunnel = (PartP2PTunnel) part; - if( !tunnel.isPowered() ) - { - return; - } + if (!tunnel.isPowered()) { + return; + } - // Frquency - final short frequency = tunnel.getFrequency(); - tag.putShort( TAG_P2P_FREQUENCY, frequency ); + // Frquency + final short frequency = tunnel.getFrequency(); + tag.putShort(TAG_P2P_FREQUENCY, frequency); - // The default state - int state = STATE_UNLINKED; - int outputCount = 0; + // The default state + int state = STATE_UNLINKED; + int outputCount = 0; - if( !tunnel.isOutput() ) - { - outputCount = getOutputCount( tunnel ); - if( outputCount > 0 ) - { - // Only set it to INPUT if we know there are any outputs - state = STATE_INPUT; - } - } - else - { - PartP2PTunnel input = tunnel.getInput(); - if( input != null ) - { - state = STATE_OUTPUT; - } - } + if (!tunnel.isOutput()) { + outputCount = getOutputCount(tunnel); + if (outputCount > 0) { + // Only set it to INPUT if we know there are any outputs + state = STATE_INPUT; + } + } else { + PartP2PTunnel input = tunnel.getInput(); + if (input != null) { + state = STATE_OUTPUT; + } + } - tag.putIntArray( TAG_P2P_STATE, new int[] { - state, - outputCount - } ); + tag.putIntArray(TAG_P2P_STATE, new int[] { state, outputCount }); - } - } + } + } - private static int getOutputCount( PartP2PTunnel tunnel ) - { - try - { - return Iterators.size( tunnel.getOutputs().iterator() ); - } - catch( GridAccessException e ) - { - // Well... unknown size it is! - return 0; - } - } + private static int getOutputCount(PartP2PTunnel tunnel) { + try { + return Iterators.size(tunnel.getOutputs().iterator()); + } catch (GridAccessException e) { + // Well... unknown size it is! + return 0; + } + } - private static ITextComponent getOutputText( int outputs ) - { - if( outputs <= 1 ) - { - return WailaText.P2PInputOneOutput.textComponent(); - } - else - { - return WailaText.P2PInputManyOutputs.textComponent(outputs); - } - } + private static ITextComponent getOutputText(int outputs) { + if (outputs <= 1) { + return WailaText.P2PInputOneOutput.textComponent(); + } else { + return WailaText.P2PInputManyOutputs.textComponent(outputs); + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java b/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java index 890c9f713..2b6b6b46e 100644 --- a/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java +++ b/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java @@ -18,7 +18,6 @@ package appeng.integration.modules.waila.part; - import java.util.Optional; import net.minecraft.tileentity.TileEntity; @@ -31,7 +30,6 @@ import appeng.api.parts.IPart; import appeng.api.parts.IPartHost; import appeng.api.parts.SelectedPart; - /** * Accessor to access specific parts for WAILA * @@ -39,34 +37,30 @@ import appeng.api.parts.SelectedPart; * @version rv2 * @since rv2 */ -public final class PartAccessor -{ - /** - * Hits a {@link IPartHost} with {@link BlockPos}. - *

- * You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is - * defined as being absent. - * - * @param te being looked at {@link TileEntity} - * @param rtr type of ray-trace - * - * @return maybe the looked at {@link IPart} - */ - public Optional getMaybePart( final TileEntity te, final RayTraceResult rtr ) - { - if( te instanceof IPartHost && rtr instanceof BlockRayTraceResult) - { - BlockPos pos = ((BlockRayTraceResult) rtr).getPos(); - final Vec3d position = rtr.getHitVec().add( -pos.getX(), -pos.getY(), -pos.getZ() ); - final IPartHost host = (IPartHost) te; - final SelectedPart sp = host.selectPart( position ); +public final class PartAccessor { + /** + * Hits a {@link IPartHost} with {@link BlockPos}. + *

+ * You can derive the looked at {@link IPart} by doing that. If a facade is + * being looked at, it is defined as being absent. + * + * @param te being looked at {@link TileEntity} + * @param rtr type of ray-trace + * + * @return maybe the looked at {@link IPart} + */ + public Optional getMaybePart(final TileEntity te, final RayTraceResult rtr) { + if (te instanceof IPartHost && rtr instanceof BlockRayTraceResult) { + BlockPos pos = ((BlockRayTraceResult) rtr).getPos(); + final Vec3d position = rtr.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ()); + final IPartHost host = (IPartHost) te; + final SelectedPart sp = host.selectPart(position); - if( sp.part != null ) - { - return Optional.of( sp.part ); - } - } + if (sp.part != null) { + return Optional.of(sp.part); + } + } - return Optional.empty(); - } + return Optional.empty(); + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java index f54ad05f8..61639e595 100644 --- a/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java @@ -18,7 +18,6 @@ package appeng.integration.modules.waila.part; - import net.minecraft.item.ItemStack; import mcp.mobius.waila.api.IPluginConfig; @@ -26,7 +25,6 @@ import mcp.mobius.waila.api.IPluginConfig; import appeng.api.parts.IPart; import appeng.api.parts.PartItemStack; - /** * Part ItemStack provider for WAILA * @@ -34,14 +32,12 @@ import appeng.api.parts.PartItemStack; * @version rv2 * @since rv2 */ -public class PartStackWailaDataProvider extends BasePartWailaDataProvider -{ +public class PartStackWailaDataProvider extends BasePartWailaDataProvider { - @Override - public ItemStack getStack( final IPart part, final IPluginConfig config, ItemStack partStack ) - { - partStack = part.getItemStack( PartItemStack.PICK ); - return partStack; - } + @Override + public ItemStack getStack(final IPart part, final IPluginConfig config, ItemStack partStack) { + partStack = part.getItemStack(PartItemStack.PICK); + return partStack; + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java index 30df2ee63..0ffcaf767 100644 --- a/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java @@ -18,17 +18,16 @@ package appeng.integration.modules.waila.part; - import java.util.List; -import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.util.text.ITextComponent; + import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; import appeng.api.implementations.IPowerChannelState; import appeng.api.parts.IPart; import appeng.core.localization.WailaText; -import net.minecraft.util.text.ITextComponent; - /** * Power state provider for WAILA @@ -37,48 +36,41 @@ import net.minecraft.util.text.ITextComponent; * @version rv2 * @since rv2 */ -public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider -{ - /** - * Adds state to the tooltip - * - * @param part part with state - * @param tooltip to be added to tooltip - * @param accessor wrapper for various information - * @param config config settings - */ - @Override - public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - if( part instanceof IPowerChannelState ) - { - final IPowerChannelState state = (IPowerChannelState) part; +public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider { + /** + * Adds state to the tooltip + * + * @param part part with state + * @param tooltip to be added to tooltip + * @param accessor wrapper for various information + * @param config config settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) part; - tooltip.add( this.getToolTip( state.isActive(), state.isPowered() ) ); - } - } + tooltip.add(this.getToolTip(state.isActive(), state.isPowered())); + } + } - /** - * Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered} - * - * @param isActive if part is active - * @param isPowered if part is powered - * - * @return tooltip of the state - */ - private ITextComponent getToolTip( final boolean isActive, final boolean isPowered ) - { - if( isActive && isPowered ) - { - return WailaText.DeviceOnline.textComponent(); - } - else if( isPowered ) - { - return WailaText.DeviceMissingChannel.textComponent(); - } - else - { - return WailaText.DeviceOffline.textComponent(); - } - } + /** + * Gets the corresponding tool tip for different values of {@code #isActive} and + * {@code #isPowered} + * + * @param isActive if part is active + * @param isPowered if part is powered + * + * @return tooltip of the state + */ + private ITextComponent getToolTip(final boolean isActive, final boolean isPowered) { + if (isActive && isPowered) { + return WailaText.DeviceOnline.textComponent(); + } else if (isPowered) { + return WailaText.DeviceMissingChannel.textComponent(); + } else { + return WailaText.DeviceOffline.textComponent(); + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java index 4ba12525d..90b4030b7 100644 --- a/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java @@ -18,11 +18,12 @@ package appeng.integration.modules.waila.part; - import java.util.List; -import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.util.text.ITextComponent; + import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; import appeng.api.implementations.parts.IPartStorageMonitor; import appeng.api.parts.IPart; @@ -30,8 +31,6 @@ import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.core.localization.WailaText; -import net.minecraft.util.text.ITextComponent; - /** * Storage monitor provider for WAILA @@ -40,40 +39,37 @@ import net.minecraft.util.text.ITextComponent; * @version rv2 * @since rv2 */ -public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider -{ - /** - * Displays the stack if present and if the monitor is locked. - * Can handle fluids and items. - * - * @param part maybe storage monitor - * @param tooltip to be written to tooltip - * @param accessor information wrapper - * @param config config option - */ - @Override - public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, final IPluginConfig config ) - { - if( part instanceof IPartStorageMonitor ) - { - final IPartStorageMonitor monitor = (IPartStorageMonitor) part; +public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider { + /** + * Displays the stack if present and if the monitor is locked. Can handle fluids + * and items. + * + * @param part maybe storage monitor + * @param tooltip to be written to tooltip + * @param accessor information wrapper + * @param config config option + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof IPartStorageMonitor) { + final IPartStorageMonitor monitor = (IPartStorageMonitor) part; - final IAEStack displayed = monitor.getDisplayed(); - final boolean isLocked = monitor.isLocked(); + final IAEStack displayed = monitor.getDisplayed(); + final boolean isLocked = monitor.isLocked(); - // TODO: generalize - if( displayed instanceof IAEItemStack ) - { - final IAEItemStack ais = (IAEItemStack) displayed; - tooltip.add( WailaText.Showing.textComponent().appendText(": ").appendSibling(ais.asItemStackRepresentation().getDisplayName()) ); - } - else if( displayed instanceof IAEFluidStack ) - { - final IAEFluidStack ais = (IAEFluidStack) displayed; - tooltip.add( WailaText.Showing.textComponent().appendText(": ").appendSibling(ais.getFluid().getAttributes().getDisplayName( ais.getFluidStack() )) ); - } + // TODO: generalize + if (displayed instanceof IAEItemStack) { + final IAEItemStack ais = (IAEItemStack) displayed; + tooltip.add(WailaText.Showing.textComponent().appendText(": ") + .appendSibling(ais.asItemStackRepresentation().getDisplayName())); + } else if (displayed instanceof IAEFluidStack) { + final IAEFluidStack ais = (IAEFluidStack) displayed; + tooltip.add(WailaText.Showing.textComponent().appendText(": ") + .appendSibling(ais.getFluid().getAttributes().getDisplayName(ais.getFluidStack()))); + } - tooltip.add( ( isLocked ) ? WailaText.Locked.textComponent() : WailaText.Unlocked.textComponent() ); - } - } + tooltip.add((isLocked) ? WailaText.Locked.textComponent() : WailaText.Unlocked.textComponent()); + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/part/Tracer.java b/src/main/java/appeng/integration/modules/waila/part/Tracer.java index c3bff2341..6d5a7ebd3 100644 --- a/src/main/java/appeng/integration/modules/waila/part/Tracer.java +++ b/src/main/java/appeng/integration/modules/waila/part/Tracer.java @@ -18,7 +18,6 @@ package appeng.integration.modules.waila.part; - import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -27,7 +26,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; - /** * Tracer for players hitting blocks * @@ -35,66 +33,57 @@ import net.minecraft.world.World; * @version rv2 * @since rv2 */ -public final class Tracer -{ - /** - * Trace view of players to blocks. - * Ignore all which are out of reach. - * - * @param world word of block - * @param player player viewing block - * @param pos pos of block - * - * @return trace movement. Can be null - */ - public RayTraceResult retraceBlock(final World world, final PlayerEntity player, BlockPos pos ) - { - BlockState blockState = world.getBlockState( pos ); +public final class Tracer { + /** + * Trace view of players to blocks. Ignore all which are out of reach. + * + * @param world word of block + * @param player player viewing block + * @param pos pos of block + * + * @return trace movement. Can be null + */ + public RayTraceResult retraceBlock(final World world, final PlayerEntity player, BlockPos pos) { + BlockState blockState = world.getBlockState(pos); - final Vec3d headVec = this.getCorrectedHeadVec( player ); - final Vec3d lookVec = player.getLook( 1.0F ); - final double reach = this.getBlockReachDistance_server( player ); - final Vec3d endVec = headVec.add( lookVec.x * reach, lookVec.y * reach, lookVec.z * reach ); + final Vec3d headVec = this.getCorrectedHeadVec(player); + final Vec3d lookVec = player.getLook(1.0F); + final double reach = this.getBlockReachDistance_server(player); + final Vec3d endVec = headVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach); - return blockState.getCollisionShape(world, pos).rayTrace( headVec, endVec, pos ); - } + return blockState.getCollisionShape(world, pos).rayTrace(headVec, endVec, pos); + } - /** - * Gets the view point of a player - * - * @param player player with head - * - * @return view point of player - */ - private Vec3d getCorrectedHeadVec( final PlayerEntity player ) - { - double x = player.getPosX(); - double y = player.getPosY(); - double z = player.getPosZ(); + /** + * Gets the view point of a player + * + * @param player player with head + * + * @return view point of player + */ + private Vec3d getCorrectedHeadVec(final PlayerEntity player) { + double x = player.getPosX(); + double y = player.getPosY(); + double z = player.getPosZ(); - if( player.world.isRemote ) - { - // compatibility with eye height changing mods - y += player.getEyeHeight() - player.getEyeHeight(); - } - else - { - y += player.getEyeHeight(); - if( player instanceof ServerPlayerEntity && player.isSneaking() ) - { - y -= 0.08; - } - } - return new Vec3d( x, y, z ); - } + if (player.world.isRemote) { + // compatibility with eye height changing mods + y += player.getEyeHeight() - player.getEyeHeight(); + } else { + y += player.getEyeHeight(); + if (player instanceof ServerPlayerEntity && player.isSneaking()) { + y -= 0.08; + } + } + return new Vec3d(x, y, z); + } - /** - * @param player multi-player player - * - * @return block reach distance of player - */ - private double getBlockReachDistance_server( final PlayerEntity player ) - { - return player.getAttribute(net.minecraft.entity.player.PlayerEntity.REACH_DISTANCE).getValue(); - } + /** + * @param player multi-player player + * + * @return block reach distance of player + */ + private double getBlockReachDistance_server(final PlayerEntity player) { + return player.getAttribute(net.minecraft.entity.player.PlayerEntity.REACH_DISTANCE).getValue(); + } } diff --git a/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java index 75f5b770c..1f207fa07 100644 --- a/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java @@ -18,7 +18,6 @@ package appeng.integration.modules.waila.tile; - import java.util.List; import javax.annotation.Nonnull; @@ -31,14 +30,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.items.IItemHandler; -import mcp.mobius.waila.api.IPluginConfig; import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; import appeng.core.localization.WailaText; import appeng.integration.modules.waila.BaseWailaDataProvider; import appeng.tile.misc.TileCharger; - /** * Charger provider for WAILA * @@ -46,31 +44,28 @@ import appeng.tile.misc.TileCharger; * @version rv2 * @since rv2 */ -public final class ChargerWailaDataProvider extends BaseWailaDataProvider -{ +public final class ChargerWailaDataProvider extends BaseWailaDataProvider { - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - final TileEntity te = accessor.getTileEntity(); - if( te instanceof TileCharger ) - { - final TileCharger charger = (TileCharger) te; - final IItemHandler chargerInventory = charger.getInternalInventory(); - final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 ); + final TileEntity te = accessor.getTileEntity(); + if (te instanceof TileCharger) { + final TileCharger charger = (TileCharger) te; + final IItemHandler chargerInventory = charger.getInternalInventory(); + final ItemStack chargingItem = chargerInventory.getStackInSlot(0); - if( !chargingItem.isEmpty() ) - { - final ITextComponent currentInventory = chargingItem.getDisplayName(); - final PlayerEntity player = accessor.getPlayer(); + if (!chargingItem.isEmpty()) { + final ITextComponent currentInventory = chargingItem.getDisplayName(); + final PlayerEntity player = accessor.getPlayer(); - tooltip.add( WailaText.Contains.textComponent().appendText(": ") - .appendSibling(currentInventory) ); - ITooltipFlag.TooltipFlags tooltipFlag = Minecraft - .getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL; - chargingItem.getItem().addInformation( chargingItem, player.world, tooltip, tooltipFlag ); - } - } + tooltip.add(WailaText.Contains.textComponent().appendText(": ").appendSibling(currentInventory)); + ITooltipFlag.TooltipFlags tooltipFlag = Minecraft.getInstance().gameSettings.advancedItemTooltips + ? ITooltipFlag.TooltipFlags.ADVANCED + : ITooltipFlag.TooltipFlags.NORMAL; + chargingItem.getItem().addInformation(chargingItem, player.world, tooltip, tooltipFlag); + } + } - } + } } diff --git a/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java index 898af082b..0b4e7ecca 100644 --- a/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java @@ -18,21 +18,19 @@ package appeng.integration.modules.waila.tile; - import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.text.ITextComponent; -import mcp.mobius.waila.api.IPluginConfig; import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; import appeng.api.storage.data.IAEItemStack; import appeng.core.localization.WailaText; import appeng.integration.modules.waila.BaseWailaDataProvider; import appeng.tile.crafting.TileCraftingMonitorTile; -import net.minecraft.util.text.ITextComponent; - /** * Crafting-monitor provider for WAILA @@ -41,23 +39,20 @@ import net.minecraft.util.text.ITextComponent; * @version rv2 * @since rv2 */ -public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider -{ +public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider { - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - final TileEntity te = accessor.getTileEntity(); - if( te instanceof TileCraftingMonitorTile ) - { - final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te; - final IAEItemStack displayStack = monitor.getJobProgress(); + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); + if (te instanceof TileCraftingMonitorTile) { + final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te; + final IAEItemStack displayStack = monitor.getJobProgress(); - if( displayStack != null ) - { - final ITextComponent currentCrafting = displayStack.asItemStackRepresentation().getDisplayName(); + if (displayStack != null) { + final ITextComponent currentCrafting = displayStack.asItemStackRepresentation().getDisplayName(); - tooltip.add( WailaText.Crafting.textComponent().appendText(": ").appendSibling(currentCrafting) ); - } - } - } + tooltip.add(WailaText.Crafting.textComponent().appendText(": ").appendSibling(currentCrafting)); + } + } + } } diff --git a/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java index 8d281ba74..17709e968 100644 --- a/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java @@ -18,20 +18,18 @@ package appeng.integration.modules.waila.tile; - import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.text.ITextComponent; -import mcp.mobius.waila.api.IPluginConfig; import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; import appeng.api.implementations.IPowerChannelState; import appeng.core.localization.WailaText; import appeng.integration.modules.waila.BaseWailaDataProvider; -import net.minecraft.util.text.ITextComponent; - /** * Power state provider for WAILA @@ -40,33 +38,26 @@ import net.minecraft.util.text.ITextComponent; * @version rv2 * @since rv2 */ -public final class PowerStateWailaDataProvider extends BaseWailaDataProvider -{ +public final class PowerStateWailaDataProvider extends BaseWailaDataProvider { - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - final TileEntity te = accessor.getTileEntity(); + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + final TileEntity te = accessor.getTileEntity(); - if( te instanceof IPowerChannelState ) - { - final IPowerChannelState state = (IPowerChannelState) te; + if (te instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) te; - final boolean isActive = state.isActive(); - final boolean isPowered = state.isPowered(); + final boolean isActive = state.isActive(); + final boolean isPowered = state.isPowered(); - if( isActive && isPowered ) - { - tooltip.add( WailaText.DeviceOnline.textComponent() ); - } - else if( isPowered ) - { - tooltip.add( WailaText.DeviceMissingChannel.textComponent() ); - } - else - { - tooltip.add( WailaText.DeviceOffline.textComponent() ); - } - } + if (isActive && isPowered) { + tooltip.add(WailaText.DeviceOnline.textComponent()); + } else if (isPowered) { + tooltip.add(WailaText.DeviceMissingChannel.textComponent()); + } else { + tooltip.add(WailaText.DeviceOffline.textComponent()); + } + } - } + } } \ No newline at end of file diff --git a/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java index a427402b2..4867a910e 100644 --- a/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java @@ -18,23 +18,23 @@ package appeng.integration.modules.waila.tile; +import java.util.List; -import appeng.api.networking.energy.IAEPowerStorage; -import appeng.core.localization.WailaText; -import appeng.integration.modules.waila.BaseWailaDataProvider; -import appeng.util.Platform; -import it.unimi.dsi.fastutil.objects.Object2LongMap; -import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; -import mcp.mobius.waila.api.IDataAccessor; -import mcp.mobius.waila.api.IPluginConfig; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; -import java.util.List; +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import appeng.api.networking.energy.IAEPowerStorage; +import appeng.core.localization.WailaText; +import appeng.integration.modules.waila.BaseWailaDataProvider; +import appeng.util.Platform; /** * Power storage provider for WAILA @@ -43,109 +43,100 @@ import java.util.List; * @version rv2 * @since rv2 */ -public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider -{ - /** - * Power key used for the transferred {@link net.minecraft.nbt.CompoundNBT} - */ - private static final String ID_CURRENT_POWER = "currentPower"; +public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider { + /** + * Power key used for the transferred {@link net.minecraft.nbt.CompoundNBT} + */ + private static final String ID_CURRENT_POWER = "currentPower"; - /** - * Used cache for power if the power was not transmitted through the server. - *

- * This is useful, when a player just started to look at a tile and thus just requested the new information from the - * server. - *

- * The cache will be updated from the server. - */ - private final Object2LongMap cache = new Object2LongOpenHashMap<>(); + /** + * Used cache for power if the power was not transmitted through the server. + *

+ * This is useful, when a player just started to look at a tile and thus just + * requested the new information from the server. + *

+ * The cache will be updated from the server. + */ + private final Object2LongMap cache = new Object2LongOpenHashMap<>(); - @Override - public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { - // Removes RF tooltip on WAILA 1.5.9+ - // FIXME ( (ITaggedList) tooltip ).removeEntries( "RFEnergyStorage" ); + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + // Removes RF tooltip on WAILA 1.5.9+ + // FIXME ( (ITaggedList) tooltip ).removeEntries( + // "RFEnergyStorage" ); - final TileEntity te = accessor.getTileEntity(); - if( te instanceof IAEPowerStorage ) - { - final IAEPowerStorage storage = (IAEPowerStorage) te; + final TileEntity te = accessor.getTileEntity(); + if (te instanceof IAEPowerStorage) { + final IAEPowerStorage storage = (IAEPowerStorage) te; - final double maxPower = storage.getAEMaxPower(); - if( maxPower > 0 ) - { - final CompoundNBT tag = accessor.getServerData(); + final double maxPower = storage.getAEMaxPower(); + if (maxPower > 0) { + final CompoundNBT tag = accessor.getServerData(); - final long internalCurrentPower = this.getInternalCurrentPower( tag, te ); + final long internalCurrentPower = this.getInternalCurrentPower(tag, te); - if( internalCurrentPower >= 0 ) - { - final long internalMaxPower = (long) ( 100 * maxPower ); + if (internalCurrentPower >= 0) { + final long internalMaxPower = (long) (100 * maxPower); - final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false ); - final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false ); + final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false); + final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false); - tooltip.add( WailaText.Contains.textComponent().appendText(": " + formatCurrentPower + " / " + formatMaxPower)); - } - } - } - } + tooltip.add(WailaText.Contains.textComponent() + .appendText(": " + formatCurrentPower + " / " + formatMaxPower)); + } + } + } + } - /** - * Called on server to transfer information from server to client. - *

- * If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage}, it - * writes the power information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key. - * - * @param serverPlayerEntity player looking at the power storage - * @param te power storage - * @param tag transferred tag which is send to the client - * @param world world of the power storage - */ - @Override - public void appendServerData(CompoundNBT tag, ServerPlayerEntity serverPlayerEntity, World world, TileEntity te) - { - if( te instanceof IAEPowerStorage ) - { - final IAEPowerStorage storage = (IAEPowerStorage) te; + /** + * Called on server to transfer information from server to client. + *

+ * If the {@link net.minecraft.tileentity.TileEntity} is a + * {@link appeng.api.networking.energy.IAEPowerStorage}, it writes the power + * information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key. + * + * @param serverPlayerEntity player looking at the power storage + * @param te power storage + * @param tag transferred tag which is send to the client + * @param world world of the power storage + */ + @Override + public void appendServerData(CompoundNBT tag, ServerPlayerEntity serverPlayerEntity, World world, TileEntity te) { + if (te instanceof IAEPowerStorage) { + final IAEPowerStorage storage = (IAEPowerStorage) te; - if( storage.getAEMaxPower() > 0 ) - { - final long internalCurrentPower = (long) ( 100 * storage.getAECurrentPower() ); + if (storage.getAEMaxPower() > 0) { + final long internalCurrentPower = (long) (100 * storage.getAECurrentPower()); - tag.putLong( ID_CURRENT_POWER, internalCurrentPower ); - } - } - } + tag.putLong(ID_CURRENT_POWER, internalCurrentPower); + } + } + } - /** - * Determines the current power. - *

- * If the client received power information on the server, they are used, else if the cache contains a previous - * stored value, this will be used. Default value is 0. - * - * @param te te to be looked at - * @param tag tag maybe containing the channel information - * - * @return used channels on the cable - */ - private long getInternalCurrentPower( final CompoundNBT tag, final TileEntity te ) - { - final long internalCurrentPower; + /** + * Determines the current power. + *

+ * If the client received power information on the server, they are used, else + * if the cache contains a previous stored value, this will be used. Default + * value is 0. + * + * @param te te to be looked at + * @param tag tag maybe containing the channel information + * + * @return used channels on the cable + */ + private long getInternalCurrentPower(final CompoundNBT tag, final TileEntity te) { + final long internalCurrentPower; - if( tag.contains( ID_CURRENT_POWER ) ) - { - internalCurrentPower = tag.getLong( ID_CURRENT_POWER ); - this.cache.put( te, internalCurrentPower ); - } - else if( this.cache.containsKey( te ) ) - { - internalCurrentPower = this.cache.get( te ); - } - else - { - internalCurrentPower = -1; - } + if (tag.contains(ID_CURRENT_POWER)) { + internalCurrentPower = tag.getLong(ID_CURRENT_POWER); + this.cache.put(te, internalCurrentPower); + } else if (this.cache.containsKey(te)) { + internalCurrentPower = this.cache.get(te); + } else { + internalCurrentPower = -1; + } - return internalCurrentPower; - } + return internalCurrentPower; + } } diff --git a/src/main/java/appeng/items/AEBaseItem.java b/src/main/java/appeng/items/AEBaseItem.java index d3a674728..c3aa82db9 100644 --- a/src/main/java/appeng/items/AEBaseItem.java +++ b/src/main/java/appeng/items/AEBaseItem.java @@ -18,30 +18,24 @@ package appeng.items; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +public abstract class AEBaseItem extends Item { -public abstract class AEBaseItem extends Item -{ + public AEBaseItem(Item.Properties properties) { + super(properties.setNoRepair()); + } - public AEBaseItem( Item.Properties properties ) - { - super( properties.setNoRepair() ); - } + @Override + public String toString() { + String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered"; + return this.getClass().getSimpleName() + "[" + regName + "]"; + } - @Override - public String toString() - { - String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered"; - return this.getClass().getSimpleName() + "[" + regName + "]"; - } - - @Override - public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 ) - { - return false; - } + @Override + public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) { + return false; + } } diff --git a/src/main/java/appeng/items/contents/CellConfig.java b/src/main/java/appeng/items/contents/CellConfig.java index 10d27658c..32d317487 100644 --- a/src/main/java/appeng/items/contents/CellConfig.java +++ b/src/main/java/appeng/items/contents/CellConfig.java @@ -18,27 +18,22 @@ package appeng.items.contents; - import net.minecraft.item.ItemStack; import appeng.tile.inventory.AppEngInternalInventory; +public class CellConfig extends AppEngInternalInventory { -public class CellConfig extends AppEngInternalInventory -{ + private final ItemStack is; - private final ItemStack is; + public CellConfig(final ItemStack is) { + super(null, 63); + this.is = is; + this.readFromNBT(is.getOrCreateTag(), "list"); + } - public CellConfig( final ItemStack is ) - { - super( null, 63 ); - this.is = is; - this.readFromNBT(is.getOrCreateTag(), "list" ); - } - - @Override - protected void onContentsChanged( int slot ) - { - this.writeToNBT(this.is.getOrCreateTag(), "list" ); - } + @Override + protected void onContentsChanged(int slot) { + this.writeToNBT(this.is.getOrCreateTag(), "list"); + } } \ No newline at end of file diff --git a/src/main/java/appeng/items/contents/CellUpgrades.java b/src/main/java/appeng/items/contents/CellUpgrades.java index dbefc08e8..0b135215f 100644 --- a/src/main/java/appeng/items/contents/CellUpgrades.java +++ b/src/main/java/appeng/items/contents/CellUpgrades.java @@ -18,26 +18,21 @@ package appeng.items.contents; - import net.minecraft.item.ItemStack; import appeng.parts.automation.StackUpgradeInventory; +public final class CellUpgrades extends StackUpgradeInventory { + private final ItemStack is; -public final class CellUpgrades extends StackUpgradeInventory -{ - private final ItemStack is; + public CellUpgrades(final ItemStack is, final int upgrades) { + super(is, null, upgrades); + this.is = is; + this.readFromNBT(is.getOrCreateTag(), "upgrades"); + } - public CellUpgrades( final ItemStack is, final int upgrades ) - { - super( is, null, upgrades ); - this.is = is; - this.readFromNBT(is.getOrCreateTag(), "upgrades" ); - } - - @Override - protected void onContentsChanged( int slot ) - { - this.writeToNBT(this.is.getOrCreateTag(), "upgrades" ); - } + @Override + protected void onContentsChanged(int slot) { + this.writeToNBT(this.is.getOrCreateTag(), "upgrades"); + } } \ No newline at end of file diff --git a/src/main/java/appeng/items/contents/NetworkToolViewer.java b/src/main/java/appeng/items/contents/NetworkToolViewer.java index 7920a45ef..f66ef1658 100644 --- a/src/main/java/appeng/items/contents/NetworkToolViewer.java +++ b/src/main/java/appeng/items/contents/NetworkToolViewer.java @@ -18,7 +18,6 @@ package appeng.items.contents; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -30,72 +29,62 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.inv.filter.IAEItemFilter; +public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory { -public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory -{ + private final AppEngInternalInventory inv; + private final ItemStack is; + private final IGridHost gh; - private final AppEngInternalInventory inv; - private final ItemStack is; - private final IGridHost gh; + public NetworkToolViewer(final ItemStack is, final IGridHost gHost) { + this.is = is; + this.gh = gHost; + this.inv = new AppEngInternalInventory(this, 9); + this.inv.setFilter(new NetworkToolInventoryFilter()); + if (is.hasTag()) // prevent crash when opening network status screen. + { + this.inv.readFromNBT(is.getOrCreateTag(), "inv"); + } + } - public NetworkToolViewer( final ItemStack is, final IGridHost gHost ) - { - this.is = is; - this.gh = gHost; - this.inv = new AppEngInternalInventory( this, 9 ); - this.inv.setFilter( new NetworkToolInventoryFilter() ); - if( is.hasTag() ) // prevent crash when opening network status screen. - { - this.inv.readFromNBT(is.getOrCreateTag(), "inv" ); - } - } + @Override + public void saveChanges() { + this.inv.writeToNBT(this.is.getOrCreateTag(), "inv"); + } - @Override - public void saveChanges() - { - this.inv.writeToNBT(this.is.getOrCreateTag(), "inv" ); - } + @Override + public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, + ItemStack newStack) { + } - @Override - public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) - { - } + @Override + public ItemStack getItemStack() { + return this.is; + } - @Override - public ItemStack getItemStack() - { - return this.is; - } + @Override + public IGridHost getGridHost() { + return this.gh; + } - @Override - public IGridHost getGridHost() - { - return this.gh; - } + private static class NetworkToolInventoryFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } - private static class NetworkToolInventoryFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return stack.getItem() instanceof IUpgradeModule + && ((IUpgradeModule) stack.getItem()).getType(stack) != null; + } + } - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return stack.getItem() instanceof IUpgradeModule && ( (IUpgradeModule) stack.getItem() ).getType( stack ) != null; - } - } + public IItemHandler getInternalInventory() { + return this.inv; + } - public IItemHandler getInternalInventory() - { - return this.inv; - } - - @Override - public IItemHandler getInventory() - { - return this.inv; - } + @Override + public IItemHandler getInventory() { + return this.inv; + } } diff --git a/src/main/java/appeng/items/contents/PortableCellViewer.java b/src/main/java/appeng/items/contents/PortableCellViewer.java index 466b5c8e7..2d23feae6 100644 --- a/src/main/java/appeng/items/contents/PortableCellViewer.java +++ b/src/main/java/appeng/items/contents/PortableCellViewer.java @@ -18,7 +18,6 @@ package appeng.items.contents; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -41,71 +40,61 @@ import appeng.container.interfaces.IInventorySlotAware; import appeng.me.helpers.MEMonitorHandler; import appeng.util.ConfigManager; +public class PortableCellViewer extends MEMonitorHandler implements IPortableCell, IInventorySlotAware { -public class PortableCellViewer extends MEMonitorHandler implements IPortableCell, IInventorySlotAware -{ + private final ItemStack target; + private final IAEItemPowerStorage ips; + private final int inventorySlot; - private final ItemStack target; - private final IAEItemPowerStorage ips; - private final int inventorySlot; + public PortableCellViewer(final ItemStack is, final int slot) { + super(AEApi.instance().registries().cell().getCellInventory(is, null, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + this.ips = (IAEItemPowerStorage) is.getItem(); + this.target = is; + this.inventorySlot = slot; + } - public PortableCellViewer( final ItemStack is, final int slot ) - { - super( AEApi.instance().registries().cell().getCellInventory( is, null, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - this.ips = (IAEItemPowerStorage) is.getItem(); - this.target = is; - this.inventorySlot = slot; - } + @Override + public int getInventorySlot() { + return this.inventorySlot; + } - @Override - public int getInventorySlot() - { - return this.inventorySlot; - } + @Override + public ItemStack getItemStack() { + return this.target; + } - @Override - public ItemStack getItemStack() - { - return this.target; - } + @Override + public double extractAEPower(double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) { + amt = usePowerMultiplier.multiply(amt); - @Override - public double extractAEPower( double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier ) - { - amt = usePowerMultiplier.multiply( amt ); + if (mode == Actionable.SIMULATE) { + return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target))); + } - if( mode == Actionable.SIMULATE ) - { - return usePowerMultiplier.divide( Math.min( amt, this.ips.getAECurrentPower( this.target ) ) ); - } + return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt, Actionable.MODULATE)); + } - return usePowerMultiplier.divide( this.ips.extractAEPower( this.target, amt, Actionable.MODULATE ) ); - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + return (IMEMonitor) this; + } + return null; + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - return (IMEMonitor) this; - } - return null; - } - - @Override - public IConfigManager getConfigManager() - { - final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> - { + @Override + public IConfigManager getConfigManager() { + final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> { final CompoundNBT data = this.target.getOrCreateTag(); - manager.writeToNBT( data ); - } ); + manager.writeToNBT(data); + }); - out.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); + out.registerSetting(Settings.SORT_BY, SortOrder.NAME); + out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); - out.readFromNBT( this.target.getOrCreateTag().copy() ); - return out; - } + out.readFromNBT(this.target.getOrCreateTag().copy()); + return out; + } } diff --git a/src/main/java/appeng/items/contents/QuartzKnifeObj.java b/src/main/java/appeng/items/contents/QuartzKnifeObj.java index a06e032d2..71600af2e 100644 --- a/src/main/java/appeng/items/contents/QuartzKnifeObj.java +++ b/src/main/java/appeng/items/contents/QuartzKnifeObj.java @@ -18,25 +18,20 @@ package appeng.items.contents; - import net.minecraft.item.ItemStack; import appeng.api.implementations.guiobjects.IGuiItemObject; +public class QuartzKnifeObj implements IGuiItemObject { -public class QuartzKnifeObj implements IGuiItemObject -{ + private final ItemStack is; - private final ItemStack is; + public QuartzKnifeObj(final ItemStack o) { + this.is = o; + } - public QuartzKnifeObj( final ItemStack o ) - { - this.is = o; - } - - @Override - public ItemStack getItemStack() - { - return this.is; - } + @Override + public ItemStack getItemStack() { + return this.is; + } } diff --git a/src/main/java/appeng/items/materials/ItemMaterial.java b/src/main/java/appeng/items/materials/ItemMaterial.java index f73299bb8..e4624f67a 100644 --- a/src/main/java/appeng/items/materials/ItemMaterial.java +++ b/src/main/java/appeng/items/materials/ItemMaterial.java @@ -18,7 +18,6 @@ package appeng.items.materials; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -30,7 +29,6 @@ import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; -import appeng.entity.EntitySingularity; import com.google.common.base.Preconditions; import net.minecraft.client.util.ITooltipFlag; @@ -54,6 +52,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.IItemHandler; import appeng.api.config.Upgrades; +import appeng.api.features.AEFeature; import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IStorageComponent; @@ -62,239 +61,204 @@ import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.parts.IPartHost; import appeng.api.parts.SelectedPart; import appeng.core.AEConfig; -import appeng.api.features.AEFeature; import appeng.core.features.IStackSrc; import appeng.core.features.MaterialStackSrc; +import appeng.entity.EntitySingularity; import appeng.items.AEBaseItem; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.AdaptorItemHandler; +public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule { -public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule -{ + private static final int KILO_SCALAR = 1024; - private static final int KILO_SCALAR = 1024; + private final MaterialType materialType; - private final MaterialType materialType; + public ItemMaterial(Properties properties, MaterialType materialType) { + super(properties); + this.materialType = materialType; + } - public ItemMaterial(Properties properties, MaterialType materialType) { - super(properties); - this.materialType = materialType; - } + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + super.addInformation(stack, world, lines, advancedTooltips); - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - super.addInformation( stack, world, lines, advancedTooltips ); + if (materialType == MaterialType.NAME_PRESS) { + final CompoundNBT c = stack.getOrCreateTag(); + if (c.contains("InscriberName")) { + lines.add(new StringTextComponent(c.getString("InscribeName"))); + } + } - if( materialType == MaterialType.NAME_PRESS ) - { - final CompoundNBT c = stack.getOrCreateTag(); - if (c.contains("InscriberName")) { - lines.add(new StringTextComponent(c.getString("InscribeName"))); - } - } + final Upgrades u = this.getType(stack); + if (u != null) { + final List textList = new ArrayList<>(); + for (final Entry j : u.getSupported().entrySet()) { + ITextComponent name = null; - final Upgrades u = this.getType( stack ); - if( u != null ) - { - final List textList = new ArrayList<>(); - for( final Entry j : u.getSupported().entrySet() ) - { - ITextComponent name = null; + final int limit = j.getValue(); - final int limit = j.getValue(); + if (j.getKey().getItem() instanceof IItemGroup) { + final IItemGroup ig = (IItemGroup) j.getKey().getItem(); + final String str = ig.getUnlocalizedGroupName(u.getSupported().keySet(), j.getKey()); + if (str != null) { + name = new TranslationTextComponent(str).appendText(limit > 1 ? " (" + limit + ')' : ""); + } + } - if( j.getKey().getItem() instanceof IItemGroup ) - { - final IItemGroup ig = (IItemGroup) j.getKey().getItem(); - final String str = ig.getUnlocalizedGroupName( u.getSupported().keySet(), j.getKey() ); - if( str != null ) - { - name = new TranslationTextComponent( str ).appendText( limit > 1 ? " (" + limit + ')' : "" ); - } - } + if (name == null) { + name = j.getKey().getDisplayName().appendText((limit > 1 ? " (" + limit + ')' : "")); + } - if( name == null ) - { - name = j.getKey().getDisplayName().appendText( ( limit > 1 ? " (" + limit + ')' : "" ) ); - } + if (!textList.contains(name)) { + textList.add(name); + } + } - if( !textList.contains( name ) ) - { - textList.add( name ); - } - } + final Pattern p = Pattern.compile("(\\d+)[^\\d]"); + // FIXME This comparison is not great... + final SlightlyBetterSort s = new SlightlyBetterSort(p); + textList.sort(s); + lines.addAll(textList); + } + } - final Pattern p = Pattern.compile( "(\\d+)[^\\d]" ); - // FIXME This comparison is not great... - final SlightlyBetterSort s = new SlightlyBetterSort( p ); - textList.sort(s); - lines.addAll( textList ); - } - } + @Override + public Upgrades getType(final ItemStack itemstack) { + switch (materialType) { + case CARD_CAPACITY: + return Upgrades.CAPACITY; + case CARD_FUZZY: + return Upgrades.FUZZY; + case CARD_REDSTONE: + return Upgrades.REDSTONE; + case CARD_SPEED: + return Upgrades.SPEED; + case CARD_INVERTER: + return Upgrades.INVERTER; + case CARD_CRAFTING: + return Upgrades.CRAFTING; + default: + return null; + } + } - @Override - public Upgrades getType( final ItemStack itemstack ) - { - switch( materialType ) - { - case CARD_CAPACITY: - return Upgrades.CAPACITY; - case CARD_FUZZY: - return Upgrades.FUZZY; - case CARD_REDSTONE: - return Upgrades.REDSTONE; - case CARD_SPEED: - return Upgrades.SPEED; - case CARD_INVERTER: - return Upgrades.INVERTER; - case CARD_CRAFTING: - return Upgrades.CRAFTING; - default: - return null; - } - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + PlayerEntity player = context.getPlayer(); + Hand hand = context.getHand(); + if (player.isCrouching()) { + final TileEntity te = context.getWorld().getTileEntity(context.getPos()); + IItemHandler upgrades = null; - @Override - public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context ) - { - PlayerEntity player = context.getPlayer(); - Hand hand = context.getHand(); - if( player.isCrouching() ) - { - final TileEntity te = context.getWorld().getTileEntity( context.getPos() ); - IItemHandler upgrades = null; + if (te instanceof IPartHost) { + final SelectedPart sp = ((IPartHost) te).selectPart(context.getHitVec()); + if (sp.part instanceof IUpgradeableHost) { + upgrades = ((ISegmentedInventory) sp.part).getInventoryByName("upgrades"); + } + } else if (te instanceof IUpgradeableHost) { + upgrades = ((ISegmentedInventory) te).getInventoryByName("upgrades"); + } - if( te instanceof IPartHost ) - { - final SelectedPart sp = ( (IPartHost) te ).selectPart( context.getHitVec() ); - if( sp.part instanceof IUpgradeableHost ) - { - upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" ); - } - } - else if( te instanceof IUpgradeableHost ) - { - upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" ); - } + if (upgrades != null && !player.getHeldItem(hand).isEmpty() + && player.getHeldItem(hand).getItem() instanceof IUpgradeModule) { + final IUpgradeModule um = (IUpgradeModule) player.getHeldItem(hand).getItem(); + final Upgrades u = um.getType(player.getHeldItem(hand)); - if( upgrades != null && !player.getHeldItem( hand ).isEmpty() && player.getHeldItem( hand ).getItem() instanceof IUpgradeModule ) - { - final IUpgradeModule um = (IUpgradeModule) player.getHeldItem( hand ).getItem(); - final Upgrades u = um.getType( player.getHeldItem( hand ) ); + if (u != null) { + if (player.world.isRemote) { + return ActionResultType.PASS; + } - if( u != null ) - { - if( player.world.isRemote ) - { - return ActionResultType.PASS; - } + final InventoryAdaptor ad = new AdaptorItemHandler(upgrades); + player.setHeldItem(hand, ad.addItems(player.getHeldItem(hand))); + return ActionResultType.SUCCESS; + } + } + } - final InventoryAdaptor ad = new AdaptorItemHandler( upgrades ); - player.setHeldItem( hand, ad.addItems( player.getHeldItem( hand ) ) ); - return ActionResultType.SUCCESS; - } - } - } + return super.onItemUseFirst(stack, context); + } - return super.onItemUseFirst( stack, context ); - } + @Override + public boolean hasCustomEntity(final ItemStack is) { + return materialType.hasCustomEntity(); + } - @Override - public boolean hasCustomEntity( final ItemStack is ) - { - return materialType.hasCustomEntity(); - } + @Override + public Entity createEntity(final World w, final Entity location, final ItemStack itemstack) { + final Class droppedEntity = materialType.getCustomEntityClass(); + final Entity eqi; - @Override - public Entity createEntity( final World w, final Entity location, final ItemStack itemstack ) - { - final Class droppedEntity = materialType.getCustomEntityClass(); - final Entity eqi; + try { + eqi = droppedEntity.getConstructor(World.class, double.class, double.class, double.class, ItemStack.class) + .newInstance(w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack); + } catch (final Throwable t) { + throw new IllegalStateException(t); + } - try - { - eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack ); - } - catch( final Throwable t ) - { - throw new IllegalStateException( t ); - } + eqi.setMotion(location.getMotion()); - eqi.setMotion( location.getMotion() ); + if (location instanceof ItemEntity && eqi instanceof ItemEntity) { + ((ItemEntity) eqi).setDefaultPickupDelay(); + } - if( location instanceof ItemEntity && eqi instanceof ItemEntity ) - { - ( (ItemEntity) eqi ).setDefaultPickupDelay(); - } + return eqi; + } - return eqi; - } + @Override + public int getBytes(final ItemStack is) { + switch (materialType) { + case ITEM_1K_CELL_COMPONENT: + return KILO_SCALAR; + case ITEM_4K_CELL_COMPONENT: + return KILO_SCALAR * 4; + case ITEM_16K_CELL_COMPONENT: + return KILO_SCALAR * 16; + case ITEM_64K_CELL_COMPONENT: + return KILO_SCALAR * 64; + default: + } + return 0; + } - @Override - public int getBytes( final ItemStack is ) - { - switch( materialType ) - { - case ITEM_1K_CELL_COMPONENT: - return KILO_SCALAR; - case ITEM_4K_CELL_COMPONENT: - return KILO_SCALAR * 4; - case ITEM_16K_CELL_COMPONENT: - return KILO_SCALAR * 16; - case ITEM_64K_CELL_COMPONENT: - return KILO_SCALAR * 64; - default: - } - return 0; - } + @Override + public boolean isStorageComponent(final ItemStack is) { + switch (materialType) { + case ITEM_1K_CELL_COMPONENT: + case ITEM_4K_CELL_COMPONENT: + case ITEM_16K_CELL_COMPONENT: + case ITEM_64K_CELL_COMPONENT: + return true; + default: + } + return false; + } - @Override - public boolean isStorageComponent( final ItemStack is ) - { - switch( materialType ) - { - case ITEM_1K_CELL_COMPONENT: - case ITEM_4K_CELL_COMPONENT: - case ITEM_16K_CELL_COMPONENT: - case ITEM_64K_CELL_COMPONENT: - return true; - default: - } - return false; - } + private static class SlightlyBetterSort implements Comparator { + private final Pattern pattern; - private static class SlightlyBetterSort implements Comparator - { - private final Pattern pattern; + public SlightlyBetterSort(final Pattern pattern) { + this.pattern = pattern; + } - public SlightlyBetterSort( final Pattern pattern ) - { - this.pattern = pattern; - } - - @Override - public int compare( final ITextComponent o1, final ITextComponent o2 ) - { - try - { - final Matcher a = this.pattern.matcher( o1.getString() ); - final Matcher b = this.pattern.matcher( o2.getString() ); - if( a.find() && b.find() ) - { - final int ia = Integer.parseInt( a.group( 1 ) ); - final int ib = Integer.parseInt( b.group( 1 ) ); - return Integer.compare( ia, ib ); - } - } - catch( final Throwable t ) - { - // ek! - } - return o1.getString().compareTo( o2.getString() ); - } - } + @Override + public int compare(final ITextComponent o1, final ITextComponent o2) { + try { + final Matcher a = this.pattern.matcher(o1.getString()); + final Matcher b = this.pattern.matcher(o2.getString()); + if (a.find() && b.find()) { + final int ia = Integer.parseInt(a.group(1)); + final int ib = Integer.parseInt(b.group(1)); + return Integer.compare(ia, ib); + } + } catch (final Throwable t) { + // ek! + } + return o1.getString().compareTo(o2.getString()); + } + } } diff --git a/src/main/java/appeng/items/materials/MaterialType.java b/src/main/java/appeng/items/materials/MaterialType.java index 7657d89d4..c499ebde7 100644 --- a/src/main/java/appeng/items/materials/MaterialType.java +++ b/src/main/java/appeng/items/materials/MaterialType.java @@ -18,7 +18,6 @@ package appeng.items.materials; - import java.util.EnumSet; import java.util.Set; @@ -27,190 +26,180 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import appeng.core.AppEng; import appeng.api.features.AEFeature; +import appeng.core.AppEng; import appeng.core.features.MaterialStackSrc; import appeng.entity.EntityChargedQuartz; import appeng.entity.EntitySingularity; +public enum MaterialType { + CERTUS_QUARTZ_CRYSTAL("certus_quartz_crystal", EnumSet.of(AEFeature.CERTUS), "crystalCertusQuartz"), + CERTUS_QUARTZ_CRYSTAL_CHARGED("charged_certus_quartz_crystal", EnumSet.of(AEFeature.CERTUS), + EntityChargedQuartz.class), -public enum MaterialType -{ - CERTUS_QUARTZ_CRYSTAL("certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS ), "crystalCertusQuartz" ), - CERTUS_QUARTZ_CRYSTAL_CHARGED("charged_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS ), EntityChargedQuartz.class ), + CERTUS_QUARTZ_DUST("certus_quartz_dust", EnumSet.of(AEFeature.DUSTS, AEFeature.CERTUS), "dustCertusQuartz"), + NETHER_QUARTZ_DUST("nether_quartz_dust", EnumSet.of(AEFeature.DUSTS), "dustNetherQuartz,dustQuartz"), + FLOUR("flour", EnumSet.of(AEFeature.FLOUR), "dustWheat"), + GOLD_DUST("gold_dust", EnumSet.of(AEFeature.DUSTS), "dustGold"), + IRON_DUST("iron_dust", EnumSet.of(AEFeature.DUSTS), "dustIron"), - CERTUS_QUARTZ_DUST("certus_quartz_dust", EnumSet.of( AEFeature.DUSTS, AEFeature.CERTUS ), "dustCertusQuartz" ), - NETHER_QUARTZ_DUST("nether_quartz_dust", EnumSet.of( AEFeature.DUSTS ), "dustNetherQuartz,dustQuartz" ), - FLOUR("flour", EnumSet.of( AEFeature.FLOUR ), "dustWheat" ), - GOLD_DUST("gold_dust", EnumSet.of( AEFeature.DUSTS ), "dustGold" ), - IRON_DUST("iron_dust", EnumSet.of( AEFeature.DUSTS ), "dustIron" ), + SILICON("silicon", EnumSet.of(AEFeature.SILICON), "itemSilicon"), + MATTER_BALL("matter_ball", EnumSet.of(AEFeature.MATTER_BALL)), - SILICON("silicon", EnumSet.of( AEFeature.SILICON ), "itemSilicon" ), - MATTER_BALL("matter_ball", EnumSet.of( AEFeature.MATTER_BALL ) ), + FLUIX_CRYSTAL("fluix_crystal", EnumSet.of(AEFeature.FLUIX), "crystalFluix"), + FLUIX_DUST("fluix_dust", EnumSet.of(AEFeature.FLUIX, AEFeature.DUSTS), "dustFluix"), + FLUIX_PEARL("fluix_pearl", EnumSet.of(AEFeature.FLUIX), "pearlFluix"), - FLUIX_CRYSTAL("fluix_crystal", EnumSet.of( AEFeature.FLUIX ), "crystalFluix" ), - FLUIX_DUST("fluix_dust", EnumSet.of( AEFeature.FLUIX, AEFeature.DUSTS ), "dustFluix" ), - FLUIX_PEARL("fluix_pearl", EnumSet.of( AEFeature.FLUIX ), "pearlFluix" ), + PURIFIED_CERTUS_QUARTZ_CRYSTAL("purified_certus_quartz_crystal", + EnumSet.of(AEFeature.CERTUS, AEFeature.PURE_CRYSTALS), "crystalPureCertusQuartz"), + PURIFIED_NETHER_QUARTZ_CRYSTAL("purified_nether_quartz_crystal", EnumSet.of(AEFeature.PURE_CRYSTALS), + "crystalPureNetherQuartz"), + PURIFIED_FLUIX_CRYSTAL("purified_fluix_crystal", EnumSet.of(AEFeature.FLUIX, AEFeature.PURE_CRYSTALS), + "crystalPureFluix"), - PURIFIED_CERTUS_QUARTZ_CRYSTAL("purified_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS, - AEFeature.PURE_CRYSTALS ), "crystalPureCertusQuartz" ), - PURIFIED_NETHER_QUARTZ_CRYSTAL("purified_nether_quartz_crystal", EnumSet.of( AEFeature.PURE_CRYSTALS ), "crystalPureNetherQuartz" ), - PURIFIED_FLUIX_CRYSTAL("purified_fluix_crystal", EnumSet.of( AEFeature.FLUIX, AEFeature.PURE_CRYSTALS ), "crystalPureFluix" ), + CALCULATION_PROCESSOR_PRESS("calculation_processor_press", EnumSet.of(AEFeature.PRESSES)), + ENGINEERING_PROCESSOR_PRESS("engineering_processor_press", EnumSet.of(AEFeature.PRESSES)), + LOGIC_PROCESSOR_PRESS("logic_processor_press", EnumSet.of(AEFeature.PRESSES)), - CALCULATION_PROCESSOR_PRESS("calculation_processor_press", EnumSet.of( AEFeature.PRESSES ) ), - ENGINEERING_PROCESSOR_PRESS("engineering_processor_press", EnumSet.of( AEFeature.PRESSES ) ), - LOGIC_PROCESSOR_PRESS("logic_processor_press", EnumSet.of( AEFeature.PRESSES ) ), + CALCULATION_PROCESSOR_PRINT("printed_calculation_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)), + ENGINEERING_PROCESSOR_PRINT("printed_engineering_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)), + LOGIC_PROCESSOR_PRINT("printed_logic_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)), - CALCULATION_PROCESSOR_PRINT("printed_calculation_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ), - ENGINEERING_PROCESSOR_PRINT("printed_engineering_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ), - LOGIC_PROCESSOR_PRINT("printed_logic_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ), + SILICON_PRESS("silicon_press", EnumSet.of(AEFeature.PRESSES)), + SILICON_PRINT("printed_silicon", EnumSet.of(AEFeature.PRINTED_CIRCUITS)), - SILICON_PRESS("silicon_press", EnumSet.of( AEFeature.PRESSES ) ), - SILICON_PRINT("printed_silicon", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ), + NAME_PRESS("name_press", EnumSet.of(AEFeature.PRESSES)), - NAME_PRESS("name_press", EnumSet.of( AEFeature.PRESSES ) ), + LOGIC_PROCESSOR("logic_processor", EnumSet.of(AEFeature.PROCESSORS)), + CALCULATION_PROCESSOR("calculation_processor", EnumSet.of(AEFeature.PROCESSORS)), + ENGINEERING_PROCESSOR("engineering_processor", EnumSet.of(AEFeature.PROCESSORS)), - LOGIC_PROCESSOR("logic_processor", EnumSet.of( AEFeature.PROCESSORS ) ), - CALCULATION_PROCESSOR("calculation_processor", EnumSet.of( AEFeature.PROCESSORS ) ), - ENGINEERING_PROCESSOR("engineering_processor", EnumSet.of( AEFeature.PROCESSORS ) ), + // Basic Cards + BASIC_CARD("basic_card", EnumSet.of(AEFeature.BASIC_CARDS)), + CARD_REDSTONE("redstone_card", EnumSet.of(AEFeature.BASIC_CARDS)), + CARD_CAPACITY("capacity_card", EnumSet.of(AEFeature.BASIC_CARDS)), - // Basic Cards - BASIC_CARD("basic_card", EnumSet.of( AEFeature.BASIC_CARDS ) ), - CARD_REDSTONE("redstone_card", EnumSet.of( AEFeature.BASIC_CARDS ) ), - CARD_CAPACITY("capacity_card", EnumSet.of( AEFeature.BASIC_CARDS ) ), + // Adv Cards + ADVANCED_CARD("advanced_card", EnumSet.of(AEFeature.ADVANCED_CARDS)), + CARD_FUZZY("fuzzy_card", EnumSet.of(AEFeature.ADVANCED_CARDS)), + CARD_SPEED("speed_card", EnumSet.of(AEFeature.ADVANCED_CARDS)), + CARD_INVERTER("inverter_card", EnumSet.of(AEFeature.ADVANCED_CARDS)), - // Adv Cards - ADVANCED_CARD("advanced_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ), - CARD_FUZZY("fuzzy_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ), - CARD_SPEED("speed_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ), - CARD_INVERTER("inverter_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ), + SPATIAL_2_CELL_COMPONENT("2_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)), + SPATIAL_16_CELL_COMPONENT("16_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)), + SPATIAL_128_CELL_COMPONENT("128_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)), - SPATIAL_2_CELL_COMPONENT("2_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ), - SPATIAL_16_CELL_COMPONENT("16_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ), - SPATIAL_128_CELL_COMPONENT("128_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ), + ITEM_1K_CELL_COMPONENT("1k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + ITEM_4K_CELL_COMPONENT("4k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + ITEM_16K_CELL_COMPONENT("16k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + ITEM_64K_CELL_COMPONENT("64k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + EMPTY_STORAGE_CELL("empty_storage_cell", EnumSet.of(AEFeature.STORAGE_CELLS)), - ITEM_1K_CELL_COMPONENT("1k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - ITEM_4K_CELL_COMPONENT("4k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - ITEM_16K_CELL_COMPONENT("16k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - ITEM_64K_CELL_COMPONENT("64k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - EMPTY_STORAGE_CELL("empty_storage_cell", EnumSet.of( AEFeature.STORAGE_CELLS ) ), + WOODEN_GEAR("wooden_gear", EnumSet.of(AEFeature.GRIND_STONE), "gearWood"), - WOODEN_GEAR("wooden_gear", EnumSet.of( AEFeature.GRIND_STONE ), "gearWood" ), + WIRELESS_RECEIVER("wireless_receiver", EnumSet.of(AEFeature.WIRELESS_ACCESS_TERMINAL)), + WIRELESS_BOOSTER("wireless_booster", EnumSet.of(AEFeature.WIRELESS_ACCESS_TERMINAL)), - WIRELESS_RECEIVER("wireless_receiver", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ), - WIRELESS_BOOSTER("wireless_booster", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ), + FORMATION_CORE("formation_core", EnumSet.of(AEFeature.CORES)), + ANNIHILATION_CORE("annihilation_core", EnumSet.of(AEFeature.CORES)), - FORMATION_CORE("formation_core", EnumSet.of( AEFeature.CORES ) ), - ANNIHILATION_CORE("annihilation_core", EnumSet.of( AEFeature.CORES ) ), + SKY_DUST("sky_dust", EnumSet.of(AEFeature.DUSTS)), - SKY_DUST("sky_dust", EnumSet.of( AEFeature.DUSTS ) ), + ENDER_DUST("ender_dust", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE), "dustEnder,dustEnderPearl", + EntitySingularity.class), + SINGULARITY("singularity", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE), EntitySingularity.class), + QUANTUM_ENTANGLED_SINGULARITY("quantum_entangled_singularity", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE), + EntitySingularity.class), - ENDER_DUST("ender_dust", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), "dustEnder,dustEnderPearl", EntitySingularity.class ), - SINGULARITY("singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ), - QUANTUM_ENTANGLED_SINGULARITY("quantum_entangled_singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ), + BLANK_PATTERN("blank_pattern", EnumSet.of(AEFeature.PATTERNS)), + CARD_CRAFTING("crafting_card", EnumSet.of(AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU)), - BLANK_PATTERN("blank_pattern", EnumSet.of( AEFeature.PATTERNS ) ), - CARD_CRAFTING("crafting_card", EnumSet.of( AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU ) ), + FLUID_1K_CELL_COMPONENT("1k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + FLUID_4K_CELL_COMPONENT("4k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + FLUID_16K_CELL_COMPONENT("16k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)), + FLUID_64K_CELL_COMPONENT("64k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)); - FLUID_1K_CELL_COMPONENT("1k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - FLUID_4K_CELL_COMPONENT("4k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - FLUID_16K_CELL_COMPONENT("16k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ), - FLUID_64K_CELL_COMPONENT("64k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ); + private final Set features; + private final ResourceLocation registryName; + private Item itemInstance; + // stack! + private MaterialStackSrc stackSrc; + private String oreName; + private Class droppedEntity; + private boolean isRegistered = false; - private final Set features; - private final ResourceLocation registryName; - private Item itemInstance; - // stack! - private MaterialStackSrc stackSrc; - private String oreName; - private Class droppedEntity; - private boolean isRegistered = false; + MaterialType(String id, final Set features) { + this.features = features; + this.registryName = new ResourceLocation(AppEng.MOD_ID, id); + } - MaterialType(String id, final Set features) - { - this.features = features; - this.registryName = new ResourceLocation( AppEng.MOD_ID, id); - } + MaterialType(String id, final Set features, final Class c) { + this(id, features); + this.droppedEntity = c; + } - MaterialType(String id, final Set features, final Class c) - { - this(id, features ); - this.droppedEntity = c; - } + MaterialType(String id, final Set features, final String oreDictionary, + final Class c) { + this(id, features); + this.oreName = oreDictionary; + this.droppedEntity = c; + } - MaterialType(String id, final Set features, final String oreDictionary, final Class c) - { - this(id, features ); - this.oreName = oreDictionary; - this.droppedEntity = c; - } + MaterialType(String id, final Set features, final String oreDictionary) { + this(id, features); + this.oreName = oreDictionary; + } - MaterialType(String id, final Set features, final String oreDictionary) - { - this(id, features ); - this.oreName = oreDictionary; - } + public ItemStack stack(final int size) { + return new ItemStack(this.getItemInstance(), size); + } - public ItemStack stack( final int size ) - { - return new ItemStack( this.getItemInstance(), size ); - } + public Set getFeature() { + return this.features; + } - public Set getFeature() - { - return this.features; - } + public String getOreName() { + return this.oreName; + } - public String getOreName() - { - return this.oreName; - } + boolean hasCustomEntity() { + return this.droppedEntity != null; + } - boolean hasCustomEntity() - { - return this.droppedEntity != null; - } + Class getCustomEntityClass() { + return this.droppedEntity; + } - Class getCustomEntityClass() - { - return this.droppedEntity; - } + public boolean isRegistered() { + return this.isRegistered; + } - public boolean isRegistered() - { - return this.isRegistered; - } + public void markReady() { + this.isRegistered = true; + } - public void markReady() - { - this.isRegistered = true; - } + public Item getItemInstance() { + return this.itemInstance; + } - public Item getItemInstance() - { - return this.itemInstance; - } + public void setItemInstance(final Item itemInstance) { + this.itemInstance = itemInstance; + } - public void setItemInstance( final Item itemInstance ) - { - this.itemInstance = itemInstance; - } + public MaterialStackSrc getStackSrc() { + return this.stackSrc; + } - public MaterialStackSrc getStackSrc() - { - return this.stackSrc; - } + public void setStackSrc(final MaterialStackSrc stackSrc) { + this.stackSrc = stackSrc; + } - public void setStackSrc( final MaterialStackSrc stackSrc ) - { - this.stackSrc = stackSrc; - } + public String getId() { + return registryName.getPath(); + } - public String getId() { return registryName.getPath(); } - - public ResourceLocation getRegistryName() - { - return this.registryName; - } + public ResourceLocation getRegistryName() { + return this.registryName; + } } diff --git a/src/main/java/appeng/items/misc/ItemCrystalSeed.java b/src/main/java/appeng/items/misc/ItemCrystalSeed.java index 378747051..86e4916a4 100644 --- a/src/main/java/appeng/items/misc/ItemCrystalSeed.java +++ b/src/main/java/appeng/items/misc/ItemCrystalSeed.java @@ -18,12 +18,12 @@ package appeng.items.misc; +import java.util.List; + +import javax.annotation.Nullable; -import appeng.api.implementations.items.IGrowableCrystal; -import appeng.core.localization.ButtonToolTips; -import appeng.entity.EntityGrowingCrystal; -import appeng.items.AEBaseItem; import com.google.common.base.Preconditions; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.util.ITooltipFlag; @@ -41,121 +41,116 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; -import java.util.List; +import appeng.api.implementations.items.IGrowableCrystal; +import appeng.core.localization.ButtonToolTips; +import appeng.entity.EntityGrowingCrystal; +import appeng.items.AEBaseItem; /** * This item reprents one of the seeds used to grow various forms of quartz by * throwing them into water (for that behavior, see the linked entity) */ -public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal -{ +public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal { - /** - * Name of NBT tag used to store the growth progress value. - */ - private static final String TAG_GROWTH_TICKS = "p"; + /** + * Name of NBT tag used to store the growth progress value. + */ + private static final String TAG_GROWTH_TICKS = "p"; - /** - * The number of growth ticks required to finish growing. - */ - private static final int GROWTH_TICKS_REQUIRED = 600; + /** + * The number of growth ticks required to finish growing. + */ + private static final int GROWTH_TICKS_REQUIRED = 600; - /** - * The item to convert to, when growth finishes. - */ - private final IItemProvider grownItem; + /** + * The item to convert to, when growth finishes. + */ + private final IItemProvider grownItem; - public ItemCrystalSeed(Properties properties, IItemProvider grownItem) { - super(properties); - this.grownItem = Preconditions.checkNotNull(grownItem); - // Expose the growth of the seed to the model system - addPropertyOverride(new ResourceLocation("appliedenergistics2:growth"), - (is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED); - } + public ItemCrystalSeed(Properties properties, IItemProvider grownItem) { + super(properties); + this.grownItem = Preconditions.checkNotNull(grownItem); + // Expose the growth of the seed to the model system + addPropertyOverride(new ResourceLocation("appliedenergistics2:growth"), + (is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED); + } - @Nullable - @Override - public ItemStack triggerGrowth( final ItemStack is ) - { - final int growthTicks = getGrowthTicks( is ) + 1; - if (growthTicks >= GROWTH_TICKS_REQUIRED) { - return new ItemStack(grownItem, is.getCount()); - } else { - this.setGrowthTicks(is, growthTicks); - return is; - } - } + @Nullable + @Override + public ItemStack triggerGrowth(final ItemStack is) { + final int growthTicks = getGrowthTicks(is) + 1; + if (growthTicks >= GROWTH_TICKS_REQUIRED) { + return new ItemStack(grownItem, is.getCount()); + } else { + this.setGrowthTicks(is, growthTicks); + return is; + } + } - private static int getGrowthTicks(final ItemStack is ) - { - CompoundNBT tag = is.getTag(); - return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0; - } + private static int getGrowthTicks(final ItemStack is) { + CompoundNBT tag = is.getTag(); + return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0; + } - private void setGrowthTicks(final ItemStack is, int ticks) - { - ticks = MathHelper.clamp(ticks, 0, GROWTH_TICKS_REQUIRED); - is.getOrCreateTag().putInt(TAG_GROWTH_TICKS, ticks); - } + private void setGrowthTicks(final ItemStack is, int ticks) { + ticks = MathHelper.clamp(ticks, 0, GROWTH_TICKS_REQUIRED); + is.getOrCreateTag().putInt(TAG_GROWTH_TICKS, ticks); + } - @Override - public float getMultiplier( final Block blk, final Material mat ) - { - return 0.5f; - } + @Override + public float getMultiplier(final Block blk, final Material mat) { + return 0.5f; + } - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - lines.add( ButtonToolTips.DoesntDespawn.getTranslationKey() ); - lines.add(getGrowthTooltipItem(stack)); + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + lines.add(ButtonToolTips.DoesntDespawn.getTranslationKey()); + lines.add(getGrowthTooltipItem(stack)); - super.addInformation( stack, world, lines, advancedTooltips ); - } + super.addInformation(stack, world, lines, advancedTooltips); + } - public ITextComponent getGrowthTooltipItem(ItemStack stack) { - final int progress = getGrowthTicks( stack ); - return new StringTextComponent( Math.round( 100 * progress / (float) GROWTH_TICKS_REQUIRED ) + "%" ); - } + public ITextComponent getGrowthTooltipItem(ItemStack stack) { + final int progress = getGrowthTicks(stack); + return new StringTextComponent(Math.round(100 * progress / (float) GROWTH_TICKS_REQUIRED) + "%"); + } - @Override - public int getEntityLifespan( final ItemStack itemStack, final World world ) - { - return Integer.MAX_VALUE; - } + @Override + public int getEntityLifespan(final ItemStack itemStack, final World world) { + return Integer.MAX_VALUE; + } - @Override - public boolean hasCustomEntity( final ItemStack stack ) - { - return true; - } + @Override + public boolean hasCustomEntity(final ItemStack stack) { + return true; + } - @Override - public Entity createEntity( final World world, final Entity location, final ItemStack itemstack ) - { - final EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack ); + @Override + public Entity createEntity(final World world, final Entity location, final ItemStack itemstack) { + final EntityGrowingCrystal egc = new EntityGrowingCrystal(world, location.getPosX(), location.getPosY(), + location.getPosZ(), itemstack); - egc.setMotion( location.getMotion() ); + egc.setMotion(location.getMotion()); - // Cannot read the pickup delay of the original item, so we - // use the pickup delay used for items dropped by a player instead - egc.setPickupDelay( 40 ); + // Cannot read the pickup delay of the original item, so we + // use the pickup delay used for items dropped by a player instead + egc.setPickupDelay(40); - return egc; - } + return egc; + } - @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (this.isInGroup(group)) { - // lvl 0 - items.add(new ItemStack(this, 1)); - // one tick before maturity - ItemStack almostFullGrown = new ItemStack(this, 1); - setGrowthTicks(almostFullGrown, GROWTH_TICKS_REQUIRED - 1); - items.add(almostFullGrown); - } - } + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + if (this.isInGroup(group)) { + // lvl 0 + items.add(new ItemStack(this, 1)); + // one tick before maturity + ItemStack almostFullGrown = new ItemStack(this, 1); + setGrowthTicks(almostFullGrown, GROWTH_TICKS_REQUIRED - 1); + items.add(almostFullGrown); + } + } } diff --git a/src/main/java/appeng/items/misc/ItemEncodedPattern.java b/src/main/java/appeng/items/misc/ItemEncodedPattern.java index 94113d236..c6b48f3de 100644 --- a/src/main/java/appeng/items/misc/ItemEncodedPattern.java +++ b/src/main/java/appeng/items/misc/ItemEncodedPattern.java @@ -18,17 +18,10 @@ package appeng.items.misc; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; -import appeng.api.AEApi; -import appeng.api.implementations.ICraftingPatternItem; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.storage.data.IAEItemStack; -import appeng.core.AppEng; -import appeng.core.localization.GuiText; -import appeng.helpers.InvalidPatternHelper; -import appeng.helpers.PatternHelper; -import appeng.items.AEBaseItem; -import appeng.util.Platform; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -44,189 +37,176 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; +import appeng.api.AEApi; +import appeng.api.implementations.ICraftingPatternItem; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.api.storage.data.IAEItemStack; +import appeng.core.AppEng; +import appeng.core.localization.GuiText; +import appeng.helpers.InvalidPatternHelper; +import appeng.helpers.PatternHelper; +import appeng.items.AEBaseItem; +import appeng.util.Platform; +public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem { + // rather simple client side caching. + private static final Map SIMPLE_CACHE = new WeakHashMap<>(); -public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem -{ - // rather simple client side caching. - private static final Map SIMPLE_CACHE = new WeakHashMap<>(); + public ItemEncodedPattern(Properties properties) { + super(properties); + } - public ItemEncodedPattern(Properties properties) { - super(properties); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + this.clearPattern(player.getHeldItem(hand), player); - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity player, final Hand hand ) - { - this.clearPattern( player.getHeldItem( hand ), player ); + return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand)); + } - return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) ); - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + return this.clearPattern(stack, context.getPlayer()) ? ActionResultType.SUCCESS : ActionResultType.PASS; + } - @Override - public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context ) - { - return this.clearPattern( stack, context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS; - } + private boolean clearPattern(final ItemStack stack, final PlayerEntity player) { + if (player.isCrouching()) { + if (Platform.isClient()) { + return false; + } - private boolean clearPattern( final ItemStack stack, final PlayerEntity player ) - { - if( player.isCrouching() ) - { - if( Platform.isClient() ) - { - return false; - } + final PlayerInventory inv = player.inventory; - final PlayerInventory inv = player.inventory; + ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack(stack.getCount()) + .orElse(ItemStack.EMPTY); + if (!is.isEmpty()) { + for (int s = 0; s < player.inventory.getSizeInventory(); s++) { + if (inv.getStackInSlot(s) == stack) { + inv.setInventorySlotContents(s, is); + return true; + } + } + } + } - ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY ); - if( !is.isEmpty() ) - { - for( int s = 0; s < player.inventory.getSizeInventory(); s++ ) - { - if( inv.getStackInSlot( s ) == stack ) - { - inv.setInventorySlotContents( s, is ); - return true; - } - } - } - } + return false; + } - return false; - } + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + final ICraftingPatternDetails details = this.getPatternForItem(stack, world); - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - final ICraftingPatternDetails details = this.getPatternForItem( stack, world ); + if (details == null) { + if (!stack.hasTag()) { + return; + } - if( details == null ) - { - if( !stack.hasTag() ) - { - return; - } + stack.setDisplayName(GuiText.InvalidPattern.textComponent().applyTextStyle(TextFormatting.RED)); - stack.setDisplayName(GuiText.InvalidPattern.textComponent().applyTextStyle(TextFormatting.RED)); + InvalidPatternHelper invalid = new InvalidPatternHelper(stack); - InvalidPatternHelper invalid = new InvalidPatternHelper( stack ); + final ITextComponent label = (invalid.isCraftable() ? GuiText.Crafts.textComponent() + : GuiText.Creates.textComponent()).appendText(": "); + final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()) + .appendText(" "); + final ITextComponent with = GuiText.With.textComponent().appendText(": "); - final ITextComponent label = (invalid.isCraftable() ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent()).appendText(": "); - final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()).appendText(" "); - final ITextComponent with = GuiText.With.textComponent().appendText(": "); + boolean first = true; + for (final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs()) { + lines.add((first ? label : and).deepCopy().appendSibling(output.getFormattedToolTip())); + first = false; + } - boolean first = true; - for( final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs() ) - { - lines.add( ( first ? label : and ).deepCopy().appendSibling(output.getFormattedToolTip()) ); - first = false; - } + first = true; + for (final InvalidPatternHelper.PatternIngredient input : invalid.getInputs()) { + lines.add((first ? with : and).deepCopy().appendSibling(input.getFormattedToolTip())); + first = false; + } - first = true; - for( final InvalidPatternHelper.PatternIngredient input : invalid.getInputs() ) - { - lines.add( ( first ? with : and ).deepCopy().appendSibling(input.getFormattedToolTip()) ); - first = false; - } + if (invalid.isCraftable()) { + final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" "); + final ITextComponent canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent() + : GuiText.No.textComponent(); - if( invalid.isCraftable() ) - { - final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" "); - final ITextComponent canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent() : GuiText.No.textComponent(); + lines.add(substitutionLabel.appendSibling(canSubstitute)); + } - lines.add( substitutionLabel.appendSibling(canSubstitute) ); - } + return; + } - return; - } + if (stack.hasDisplayName()) { + stack.removeChildTag("display"); + } - if( stack.hasDisplayName() ) - { - stack.removeChildTag( "display" ); - } + final boolean isCrafting = details.isCraftable(); + final boolean substitute = details.canSubstitute(); - final boolean isCrafting = details.isCraftable(); - final boolean substitute = details.canSubstitute(); + final IAEItemStack[] in = details.getCondensedInputs(); + final IAEItemStack[] out = details.getCondensedOutputs(); - final IAEItemStack[] in = details.getCondensedInputs(); - final IAEItemStack[] out = details.getCondensedOutputs(); + final ITextComponent label = (isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent()) + .appendText(": "); + final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()) + .appendText(" "); + final ITextComponent with = GuiText.With.textComponent().appendText(": "); - final ITextComponent label = ( isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent() ).appendText(": "); - final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()).appendText(" "); - final ITextComponent with = GuiText.With.textComponent().appendText(": "); + boolean first = true; + for (final IAEItemStack anOut : out) { + if (anOut == null) { + continue; + } - boolean first = true; - for( final IAEItemStack anOut : out ) - { - if( anOut == null ) - { - continue; - } + lines.add((first ? label : and).deepCopy().appendText(anOut.getStackSize() + "x ") + .appendSibling(Platform.getItemDisplayName(anOut))); + first = false; + } - lines.add( ( first ? label : and ).deepCopy().appendText(anOut.getStackSize() + "x ").appendSibling(Platform.getItemDisplayName( anOut ))); - first = false; - } + first = true; + for (final IAEItemStack anIn : in) { + if (anIn == null) { + continue; + } - first = true; - for( final IAEItemStack anIn : in ) - { - if( anIn == null ) - { - continue; - } + lines.add((first ? with : and).deepCopy().appendText(anIn.getStackSize() + "x ") + .appendSibling(Platform.getItemDisplayName(anIn))); + first = false; + } - lines.add((first ? with : and).deepCopy().appendText(anIn.getStackSize() + "x ").appendSibling(Platform.getItemDisplayName(anIn))); - first = false; - } + if (isCrafting) { + final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" "); + final ITextComponent canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent(); - if( isCrafting ) - { - final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" "); - final ITextComponent canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent(); + lines.add(substitutionLabel.appendSibling(canSubstitute)); + } + } - lines.add( substitutionLabel.appendSibling(canSubstitute) ); - } - } + @Override + public ICraftingPatternDetails getPatternForItem(final ItemStack is, final World w) { + try { + return new PatternHelper(is, w); + } catch (final Throwable t) { + return null; + } + } - @Override - public ICraftingPatternDetails getPatternForItem( final ItemStack is, final World w ) - { - try - { - return new PatternHelper( is, w ); - } - catch( final Throwable t ) - { - return null; - } - } + public ItemStack getOutput(final ItemStack item) { + ItemStack out = SIMPLE_CACHE.get(item); - public ItemStack getOutput( final ItemStack item ) - { - ItemStack out = SIMPLE_CACHE.get( item ); + if (out != null) { + return out; + } - if( out != null ) - { - return out; - } + final World w = AppEng.proxy.getWorld(); + if (w == null) { + return ItemStack.EMPTY; + } - final World w = AppEng.proxy.getWorld(); - if( w == null ) - { - return ItemStack.EMPTY; - } + final ICraftingPatternDetails details = this.getPatternForItem(item, w); - final ICraftingPatternDetails details = this.getPatternForItem( item, w ); + out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY; - out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY; - - SIMPLE_CACHE.put( item, out ); - return out; - } + SIMPLE_CACHE.put(item, out); + return out; + } } diff --git a/src/main/java/appeng/items/misc/ItemPaintBall.java b/src/main/java/appeng/items/misc/ItemPaintBall.java index eb0d9301e..30f9f62d7 100644 --- a/src/main/java/appeng/items/misc/ItemPaintBall.java +++ b/src/main/java/appeng/items/misc/ItemPaintBall.java @@ -18,9 +18,6 @@ package appeng.items.misc; - -import appeng.api.util.AEColor; -import appeng.items.AEBaseItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -29,28 +26,27 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +import appeng.api.util.AEColor; +import appeng.items.AEBaseItem; -public class ItemPaintBall extends AEBaseItem -{ +public class ItemPaintBall extends AEBaseItem { - private final AEColor color; + private final AEColor color; - private final boolean lumen; + private final boolean lumen; - public ItemPaintBall(Properties properties, AEColor color, boolean lumen) { - super(properties); - this.color = color; - this.lumen = lumen; - } + public ItemPaintBall(Properties properties, AEColor color, boolean lumen) { + super(properties); + this.color = color; + this.lumen = lumen; + } - public AEColor getColor() - { - return color; - } + public AEColor getColor() { + return color; + } - public boolean isLumen() - { - return lumen; - } + public boolean isLumen() { + return lumen; + } } diff --git a/src/main/java/appeng/items/misc/ItemPaintBallRendering.java b/src/main/java/appeng/items/misc/ItemPaintBallRendering.java index 21234f535..ced0c0c6e 100644 --- a/src/main/java/appeng/items/misc/ItemPaintBallRendering.java +++ b/src/main/java/appeng/items/misc/ItemPaintBallRendering.java @@ -18,46 +18,39 @@ package appeng.items.misc; - - import appeng.api.util.AEColor; import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; +public class ItemPaintBallRendering extends ItemRenderingCustomizer { -public class ItemPaintBallRendering extends ItemRenderingCustomizer -{ + private final boolean lumen; - private final boolean lumen; + private final AEColor color; - private final AEColor color; + public ItemPaintBallRendering(AEColor color, boolean lumen) { + this.lumen = lumen; + this.color = color; + } - public ItemPaintBallRendering(AEColor color, boolean lumen) { - this.lumen = lumen; - this.color = color; - } + @Override + public void customize(IItemRendering rendering) { + final int colorValue = lumen ? color.mediumVariant : color.mediumVariant; + final int r = (colorValue >> 16) & 0xff; + final int g = (colorValue >> 8) & 0xff; + final int b = (colorValue) & 0xff; - @Override - public void customize( IItemRendering rendering ) - { - final int colorValue = lumen ? color.mediumVariant : color.mediumVariant; - final int r = ( colorValue >> 16 ) & 0xff; - final int g = ( colorValue >> 8 ) & 0xff; - final int b = ( colorValue ) & 0xff; + int renderColor; + if (lumen) { + final float fail = 0.7f; + final int full = (int) (255 * 0.3); + renderColor = (int) (full + r * fail) << 16 | (int) (full + g * fail) << 8 | (int) (full + b * fail) + | 0xff << 24; + } else { + renderColor = r << 16 | g << 8 | b | 0xff << 24; + } - int renderColor; - if( lumen ) - { - final float fail = 0.7f; - final int full = (int) ( 255 * 0.3 ); - renderColor = (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24; - } - else - { - renderColor = r << 16 | g << 8 | b | 0xff << 24; - } - - rendering.color( (is, tintIndex) -> renderColor ); - } + rendering.color((is, tintIndex) -> renderColor); + } } diff --git a/src/main/java/appeng/items/parts/ColoredPartItem.java b/src/main/java/appeng/items/parts/ColoredPartItem.java index 530e4de61..0c1c17b75 100644 --- a/src/main/java/appeng/items/parts/ColoredPartItem.java +++ b/src/main/java/appeng/items/parts/ColoredPartItem.java @@ -1,10 +1,11 @@ package appeng.items.parts; +import java.util.function.Function; + +import net.minecraft.item.ItemStack; + import appeng.api.parts.IPart; import appeng.api.util.AEColor; -import net.minecraft.item.ItemStack; - -import java.util.function.Function; public class ColoredPartItem extends ItemPart { diff --git a/src/main/java/appeng/items/parts/FacadeRendering.java b/src/main/java/appeng/items/parts/FacadeRendering.java index e52288e7f..ac060e30f 100644 --- a/src/main/java/appeng/items/parts/FacadeRendering.java +++ b/src/main/java/appeng/items/parts/FacadeRendering.java @@ -18,21 +18,18 @@ package appeng.items.parts; - import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; - /** - * Handles rendering customization for facade items. Please note that this works very differently - * from actually rendering a Facade in a cable bus. + * Handles rendering customization for facade items. Please note that this works + * very differently from actually rendering a Facade in a cable bus. */ -public class FacadeRendering extends ItemRenderingCustomizer -{ - @Override - public void customize( IItemRendering rendering ) - { - // This actually just uses the path it will look for by default, no custom model redirection needed - // FIXME rendering.builtInModel( "models/item/facade", new FacadeItemModel() ); - } +public class FacadeRendering extends ItemRenderingCustomizer { + @Override + public void customize(IItemRendering rendering) { + // This actually just uses the path it will look for by default, no custom model + // redirection needed + // FIXME rendering.builtInModel( "models/item/facade", new FacadeItemModel() ); + } } diff --git a/src/main/java/appeng/items/parts/ItemFacade.java b/src/main/java/appeng/items/parts/ItemFacade.java index ebbe84fdb..3d65d3d63 100644 --- a/src/main/java/appeng/items/parts/ItemFacade.java +++ b/src/main/java/appeng/items/parts/ItemFacade.java @@ -18,16 +18,15 @@ package appeng.items.parts; - import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.block.Blocks; import net.minecraft.item.*; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResultType; @@ -47,277 +46,232 @@ import appeng.facade.FacadePart; import appeng.facade.IFacadeItem; import appeng.items.AEBaseItem; +public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem { -public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem -{ + private static final String TAG_ITEM_ID = "item"; - private static final String TAG_ITEM_ID = "item"; + private List subTypes = null; - private List subTypes = null; + public ItemFacade(Properties properties) { + super(properties); + // FIXME this.setHasSubtypes( true ); + } - public ItemFacade(Properties properties) { - super(properties); - // FIXME this.setHasSubtypes( true ); - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + return AEApi.instance().partHelper().placeBus(stack, context.getPos(), context.getFace(), context.getPlayer(), + context.getHand(), context.getWorld()); + } - @Override - public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context ) - { - return AEApi.instance().partHelper().placeBus( stack, context.getPos(), context.getFace(), context.getPlayer(), context.getHand(), context.getWorld() ); - } + @Override + public ITextComponent getDisplayName(ItemStack is) { + try { + final ItemStack in = this.getTextureItem(is); + if (!in.isEmpty()) { + return super.getDisplayName(is).deepCopy().appendText(" - ").appendSibling(in.getDisplayName()); + } + } catch (final Throwable ignored) { - @Override - public ITextComponent getDisplayName(ItemStack is) { - try - { - final ItemStack in = this.getTextureItem( is ); - if( !in.isEmpty() ) - { - return super.getDisplayName( is ).deepCopy().appendText(" - ").appendSibling(in.getDisplayName()); - } - } - catch( final Throwable ignored ) - { + } - } + return super.getDisplayName(is); + } - return super.getDisplayName( is ); - } + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + this.calculateSubTypes(); + items.addAll(this.subTypes); + } - @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - this.calculateSubTypes(); - items.addAll( this.subTypes ); - } + private void calculateSubTypes() { + if (this.subTypes == null) { + this.subTypes = new ArrayList<>(1000); + for (final Block b : ForgeRegistries.BLOCKS) { + try { + final Item item = Item.getItemFromBlock(b); + if (item == Items.AIR) { + continue; + } - private void calculateSubTypes() - { - if( this.subTypes == null ) - { - this.subTypes = new ArrayList<>( 1000 ); - for( final Block b : ForgeRegistries.BLOCKS ) - { - try - { - final Item item = Item.getItemFromBlock( b ); - if( item == Items.AIR ) - { - continue; - } + Item blockItem = b.asItem(); + if (blockItem != null && blockItem.getGroup() != null) { + final NonNullList tmpList = NonNullList.create(); + b.fillItemGroup(blockItem.getGroup(), tmpList); + for (final ItemStack l : tmpList) { + final ItemStack facade = this.createFacadeForItem(l, false); + if (!facade.isEmpty()) { + this.subTypes.add(facade); + } + } + } + } catch (final Throwable t) { + // just absorb.. + } + } + } + } - Item blockItem = b.asItem(); - if (blockItem != null && blockItem.getGroup() != null) { - final NonNullList tmpList = NonNullList.create(); - b.fillItemGroup(blockItem.getGroup(), tmpList); - for (final ItemStack l : tmpList) { - final ItemStack facade = this.createFacadeForItem(l, false); - if (!facade.isEmpty()) { - this.subTypes.add(facade); - } - } - } - } - catch( final Throwable t ) - { - // just absorb.. - } - } - } - } + public ItemStack createFacadeForItem(final ItemStack itemStack, final boolean returnItem) { + if (itemStack.isEmpty()) { + return ItemStack.EMPTY; + } - public ItemStack createFacadeForItem( final ItemStack itemStack, final boolean returnItem ) - { - if( itemStack.isEmpty() ) - { - return ItemStack.EMPTY; - } + final Block block = Block.getBlockFromItem(itemStack.getItem()); + if (block == Blocks.AIR || itemStack.hasTag()) { + return ItemStack.EMPTY; + } - final Block block = Block.getBlockFromItem( itemStack.getItem() ); - if( block == Blocks.AIR || itemStack.hasTag() ) - { - return ItemStack.EMPTY; - } + final int metadata = 0; // FIXME itemStack.getItem().getMetadata( itemStack.getDamage() ); - final int metadata = 0; // FIXME itemStack.getItem().getMetadata( itemStack.getDamage() ); + // Try to get the block state based on the item stack's meta. If this fails, + // don't consider it for a facade + // This for example fails for Pistons because they hardcoded an invalid meta + // value in vanilla + BlockState blockState; + try { + blockState = null; // FIXME block.getStateFromMeta( metadata ); + } catch (Exception e) { + AELog.debug(e, "Cannot create a facade for " + block.getRegistryName()); + return ItemStack.EMPTY; + } - // Try to get the block state based on the item stack's meta. If this fails, don't consider it for a facade - // This for example fails for Pistons because they hardcoded an invalid meta value in vanilla - BlockState blockState; - try - { - blockState = null; // FIXME block.getStateFromMeta( metadata ); - } - catch( Exception e ) - { - AELog.debug( e, "Cannot create a facade for " + block.getRegistryName() ); - return ItemStack.EMPTY; - } + final boolean areTileEntitiesEnabled = FacadeConfig.instance().allowTileEntityFacades(); + final boolean isWhiteListed = FacadeConfig.instance().isWhiteListed(block, metadata); + final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL; - final boolean areTileEntitiesEnabled = FacadeConfig.instance().allowTileEntityFacades(); - final boolean isWhiteListed = FacadeConfig.instance().isWhiteListed( block, metadata ); - final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL; + final BlockState defaultState = block.getDefaultState(); + final boolean isTileEntity = block.hasTileEntity(defaultState); + final boolean isFullCube = true; // FIXME defaultState.isFullCube( defaultState ); - final BlockState defaultState = block.getDefaultState(); - final boolean isTileEntity = block.hasTileEntity( defaultState ); - final boolean isFullCube = true; // FIXME defaultState.isFullCube( defaultState ); + final boolean isTileEntityAllowed = !isTileEntity || (areTileEntitiesEnabled && isWhiteListed); + final boolean isBlockAllowed = isFullCube || isWhiteListed; - final boolean isTileEntityAllowed = !isTileEntity || ( areTileEntitiesEnabled && isWhiteListed ); - final boolean isBlockAllowed = isFullCube || isWhiteListed; + if (isModel && isTileEntityAllowed && isBlockAllowed) { + if (returnItem) { + return itemStack; + } - if( isModel && isTileEntityAllowed && isBlockAllowed ) - { - if( returnItem ) - { - return itemStack; - } + final ItemStack is = new ItemStack(this); + final CompoundNBT data = new CompoundNBT(); + data.putString(TAG_ITEM_ID, itemStack.getItem().getRegistryName().toString()); + is.setTag(data); + return is; + } + return ItemStack.EMPTY; + } - final ItemStack is = new ItemStack( this ); - final CompoundNBT data = new CompoundNBT(); - data.putString(TAG_ITEM_ID, itemStack.getItem().getRegistryName().toString()); - is.setTag( data ); - return is; - } - return ItemStack.EMPTY; - } + @Override + public FacadePart createPartFromItemStack(final ItemStack is, final AEPartLocation side) { + final ItemStack in = this.getTextureItem(is); + if (!in.isEmpty()) { + return new FacadePart(is, side); + } + return null; + } - @Override - public FacadePart createPartFromItemStack( final ItemStack is, final AEPartLocation side ) - { - final ItemStack in = this.getTextureItem( is ); - if( !in.isEmpty() ) - { - return new FacadePart( is, side ); - } - return null; - } + @Override + public ItemStack getTextureItem(ItemStack is) { - @Override - public ItemStack getTextureItem( ItemStack is ) - { + CompoundNBT nbt = is.getTag(); - CompoundNBT nbt = is.getTag(); + if (nbt == null) { + return ItemStack.EMPTY; + } - if( nbt == null ) - { - return ItemStack.EMPTY; - } + ResourceLocation itemId; - ResourceLocation itemId; + // Handle legacy facades + if (nbt.contains("x")) { + int[] data = nbt.getIntArray("x"); + if (data.length != 2) { + return ItemStack.EMPTY; + } - // Handle legacy facades - if( nbt.contains("x") ) - { - int[] data = nbt.getIntArray( "x" ); - if( data.length != 2 ) - { - return ItemStack.EMPTY; - } + Item item = Registry.ITEM.getByValue(data[0]); + if (item == null) { + return ItemStack.EMPTY; + } - Item item = Registry.ITEM.getByValue( data[0] ); - if( item == null ) - { - return ItemStack.EMPTY; - } + itemId = item.getRegistryName(); + } else { + // First item is numeric item id + itemId = new ResourceLocation(nbt.getString(TAG_ITEM_ID)); + } - itemId = item.getRegistryName(); - } - else - { - // First item is numeric item id - itemId = new ResourceLocation( nbt.getString( TAG_ITEM_ID ) ); - } + Item baseItem = ForgeRegistries.ITEMS.getValue(itemId); - Item baseItem = ForgeRegistries.ITEMS.getValue( itemId ); + if (baseItem == null) { + return ItemStack.EMPTY; + } - if( baseItem == null ) - { - return ItemStack.EMPTY; - } + return new ItemStack(baseItem, 1); + } - return new ItemStack( baseItem, 1 ); - } + @Override + public BlockState getTextureBlockState(ItemStack is) { - @Override - public BlockState getTextureBlockState( ItemStack is ) - { + ItemStack baseItemStack = this.getTextureItem(is); - ItemStack baseItemStack = this.getTextureItem( is ); + if (baseItemStack.isEmpty()) { + return Blocks.GLASS.getDefaultState(); + } - if( baseItemStack.isEmpty() ) - { - return Blocks.GLASS.getDefaultState(); - } + Block block = Block.getBlockFromItem(baseItemStack.getItem()); - Block block = Block.getBlockFromItem( baseItemStack.getItem() ); + if (block == Blocks.AIR) { + return Blocks.GLASS.getDefaultState(); + } - if( block == Blocks.AIR ) - { - return Blocks.GLASS.getDefaultState(); - } + int metadata = 0; // FIXME baseItemStack.getItem().getMetadata( baseItemStack ); - int metadata = 0; // FIXME baseItemStack.getItem().getMetadata( baseItemStack ); + try { + return null; // FIXME block.getStateFromMeta( metadata ); + } catch (Exception e) { + AELog.warn("Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), + baseItemStack.getDamage()); + return Blocks.GLASS.getDefaultState(); + } + } - try - { - return null; // FIXME block.getStateFromMeta( metadata ); - } - catch( Exception e ) - { - AELog.warn( "Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), baseItemStack.getDamage() ); - return Blocks.GLASS.getDefaultState(); - } - } + public List getFacades() { + this.calculateSubTypes(); + return this.subTypes; + } - 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); + } - public ItemStack getCreativeTabIcon() - { - this.calculateSubTypes(); - if( this.subTypes.isEmpty() ) - { - return new ItemStack( Items.CAKE ); - } - return this.subTypes.get( 0 ); - } + public ItemStack createFromID(final int id) { + ItemStack facadeStack = AEApi.instance().definitions().items().facade().maybeStack(1).orElseThrow( + () -> new MissingDefinitionException("Tried to create a facade, while facades are being deactivated.")); - public ItemStack createFromID( final int id ) - { - ItemStack facadeStack = AEApi.instance() - .definitions() - .items() - .facade() - .maybeStack( 1 ) - .orElseThrow( () -> new MissingDefinitionException( "Tried to create a facade, while facades are being deactivated." ) ); + // Convert back to a registry name... + Item item = Registry.ITEM.getByValue(id); + if (item == null) { + return ItemStack.EMPTY; + } - // Convert back to a registry name... - Item item = Registry.ITEM.getByValue( id ); - if( item == null ) - { - return ItemStack.EMPTY; - } + final CompoundNBT facadeTag = new CompoundNBT(); + facadeTag.putString(TAG_ITEM_ID, item.getRegistryName().toString()); + facadeStack.setTag(facadeTag); - final CompoundNBT facadeTag = new CompoundNBT(); - facadeTag.putString(TAG_ITEM_ID, item.getRegistryName().toString()); - facadeStack.setTag( facadeTag ); + return facadeStack; + } - return facadeStack; - } + @Override + public boolean useAlphaPass(final ItemStack is) { + BlockState blockState = this.getTextureBlockState(is); - @Override - public boolean useAlphaPass( final ItemStack is ) - { - BlockState blockState = this.getTextureBlockState( is ); + if (blockState == null) { + return false; + } - if( blockState == null ) - { - return false; - } - - return RenderTypeLookup.canRenderInLayer( blockState, RenderType.getTranslucent() ) - || RenderTypeLookup.canRenderInLayer( blockState, RenderType.getTranslucentNoCrumbling() ); - } + return RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucent()) + || RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucentNoCrumbling()); + } } diff --git a/src/main/java/appeng/items/parts/ItemPart.java b/src/main/java/appeng/items/parts/ItemPart.java index 9d2517d3c..4fb09756f 100644 --- a/src/main/java/appeng/items/parts/ItemPart.java +++ b/src/main/java/appeng/items/parts/ItemPart.java @@ -18,6 +18,24 @@ package appeng.items.parts; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.Map.Entry; +import java.util.function.Function; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.google.common.base.Preconditions; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.NonNullList; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; import appeng.api.AEApi; import appeng.api.implementations.items.IItemGroup; @@ -28,127 +46,99 @@ import appeng.core.features.ActivityState; import appeng.core.features.ItemStackSrc; import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; -import com.google.common.base.Preconditions; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.Map.Entry; -import java.util.function.Function; +public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup { + private final PartType type; + private final Function factory; -public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup -{ - private final PartType type; + public ItemPart(Properties properties, PartType type, Function factory) { + super(properties); + this.type = type; + this.factory = factory; + } - private final Function factory; + @Override + public ActionResultType onItemUse(ItemUseContext context) { + PlayerEntity player = context.getPlayer(); + ItemStack held = player.getHeldItem(context.getHand()); + if (held.getItem() != this) { + return ActionResultType.PASS; + } - public ItemPart(Properties properties, PartType type, Function factory) { - super(properties); - this.type = type; - this.factory = factory; - } + return AEApi.instance().partHelper().placeBus(held, context.getPos(), context.getFace(), player, + context.getHand(), context.getWorld()); + } - @Override - public ActionResultType onItemUse( ItemUseContext context ) - { - PlayerEntity player = context.getPlayer(); - ItemStack held = player.getHeldItem( context.getHand() ); - if( held.getItem() != this ) - { - return ActionResultType.PASS; - } + public PartType getType() { + return type; + } - return AEApi.instance().partHelper().placeBus( held, context.getPos(), context.getFace(), player, context.getHand(), context.getWorld() ); - } + @Override + public T createPart(ItemStack is) { + return factory.apply(is); + } - public PartType getType() { - return type; - } + private static PartType getTypeByStack(ItemStack is) { + if (is.getItem() instanceof ItemPart) { + return ((ItemPart) is.getItem()).getType(); + } + return PartType.INVALID_TYPE; + } - @Override - public T createPart(ItemStack is) { - return factory.apply(is); - } + @Nullable + @Override + public String getUnlocalizedGroupName(final Set others, final ItemStack is) { + boolean importBus = false; + boolean importBusFluids = false; + boolean exportBus = false; + boolean exportBusFluids = false; + boolean group = false; - private static PartType getTypeByStack(ItemStack is) { - if (is.getItem() instanceof ItemPart) { - return ((ItemPart) is.getItem()).getType(); - } - return PartType.INVALID_TYPE; - } + final PartType u = getTypeByStack(is); - @Nullable - @Override - public String getUnlocalizedGroupName( final Set others, final ItemStack is ) - { - boolean importBus = false; - boolean importBusFluids = false; - boolean exportBus = false; - boolean exportBusFluids = false; - boolean group = false; + for (final ItemStack stack : others) { + if (stack.getItem() == this) { + final PartType pt = getTypeByStack(stack); + switch (pt) { + case IMPORT_BUS: + importBus = true; + if (u == pt) { + group = true; + } + break; + case FLUID_IMPORT_BUS: + importBusFluids = true; + if (u == pt) { + group = true; + } + break; + case EXPORT_BUS: + exportBus = true; + if (u == pt) { + group = true; + } + break; + case FLUID_EXPORT_BUS: + exportBusFluids = true; + if (u == pt) { + group = true; + } + break; + default: + } + } + } - final PartType u = getTypeByStack( is ); + if (group && importBus && exportBus && (u == PartType.IMPORT_BUS || u == PartType.EXPORT_BUS)) { + return GuiText.IOBuses.getTranslationKey(); + } + if (group && importBusFluids && exportBusFluids + && (u == PartType.FLUID_IMPORT_BUS || u == PartType.FLUID_EXPORT_BUS)) { + return GuiText.IOBusesFluids.getTranslationKey(); + } - for( final ItemStack stack : others ) - { - if( stack.getItem() == this ) - { - final PartType pt = getTypeByStack( stack ); - switch( pt ) - { - case IMPORT_BUS: - importBus = true; - if( u == pt ) - { - group = true; - } - break; - case FLUID_IMPORT_BUS: - importBusFluids = true; - if( u == pt ) - { - group = true; - } - break; - case EXPORT_BUS: - exportBus = true; - if( u == pt ) - { - group = true; - } - break; - case FLUID_EXPORT_BUS: - exportBusFluids = true; - if( u == pt ) - { - group = true; - } - break; - default: - } - } - } - - if( group && importBus && exportBus && ( u == PartType.IMPORT_BUS || u == PartType.EXPORT_BUS ) ) - { - return GuiText.IOBuses.getTranslationKey(); - } - if( group && importBusFluids && exportBusFluids && ( u == PartType.FLUID_IMPORT_BUS || u == PartType.FLUID_EXPORT_BUS ) ) - { - return GuiText.IOBusesFluids.getTranslationKey(); - } - - return null; - } + return null; + } } diff --git a/src/main/java/appeng/items/parts/ItemPartRendering.java b/src/main/java/appeng/items/parts/ItemPartRendering.java index 4742a2f1b..d51f16b1c 100644 --- a/src/main/java/appeng/items/parts/ItemPartRendering.java +++ b/src/main/java/appeng/items/parts/ItemPartRendering.java @@ -18,32 +18,29 @@ package appeng.items.parts; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import appeng.api.util.AEColor; import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; import appeng.client.render.StaticItemColor; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +public class ItemPartRendering extends ItemRenderingCustomizer { -public class ItemPartRendering extends ItemRenderingCustomizer -{ + private final AEColor color; - private final AEColor color; + public ItemPartRendering() { + this.color = AEColor.TRANSPARENT; + } - public ItemPartRendering() { - this.color = AEColor.TRANSPARENT; - } + public ItemPartRendering(AEColor color) { + this.color = color; + } - public ItemPartRendering(AEColor color) { - this.color = color; - } - - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IItemRendering rendering ) - { - rendering.color( new StaticItemColor(color) ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IItemRendering rendering) { + rendering.color(new StaticItemColor(color)); + } } diff --git a/src/main/java/appeng/items/parts/PartModels.java b/src/main/java/appeng/items/parts/PartModels.java index 2a7fbd1cc..01f9f6cc4 100644 --- a/src/main/java/appeng/items/parts/PartModels.java +++ b/src/main/java/appeng/items/parts/PartModels.java @@ -18,21 +18,17 @@ package appeng.items.parts; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** - * This annotation is used to mark static fields or static methods that return/contain models used - * for a part. They are automatically registered as part of the part item registration. + * This annotation is used to mark static fields or static methods that + * return/contain models used for a part. They are automatically registered as + * part of the part item registration. */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { - ElementType.FIELD, - ElementType.METHOD -} ) -public @interface PartModels -{} +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.FIELD, ElementType.METHOD }) +public @interface PartModels { +} diff --git a/src/main/java/appeng/items/parts/PartModelsHelper.java b/src/main/java/appeng/items/parts/PartModelsHelper.java index 83dd00ef9..81532144d 100644 --- a/src/main/java/appeng/items/parts/PartModelsHelper.java +++ b/src/main/java/appeng/items/parts/PartModelsHelper.java @@ -1,7 +1,6 @@ package appeng.items.parts; - import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -15,130 +14,111 @@ import net.minecraft.util.ResourceLocation; import appeng.api.parts.IPartModel; import appeng.core.AELog; - /** - * Helps with the reflection magic needed to gather all models for AE2 cable bus parts. + * Helps with the reflection magic needed to gather all models for AE2 cable bus + * parts. */ -class PartModelsHelper -{ +class PartModelsHelper { - static List createModels( Class clazz ) - { - List locations = new ArrayList<>(); + static List createModels(Class clazz) { + List locations = new ArrayList<>(); - // Check all static fields for used models - Field[] fields = clazz.getDeclaredFields(); - for( Field field : fields ) - { - if( field.getAnnotation( PartModels.class ) == null ) - { - continue; - } + // Check all static fields for used models + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + if (field.getAnnotation(PartModels.class) == null) { + continue; + } - if( !Modifier.isStatic( field.getModifiers() ) ) - { - AELog.error( "The @PartModels annotation can only be used on static fields or methods. Was seen on: " + field ); - continue; - } + if (!Modifier.isStatic(field.getModifiers())) { + AELog.error("The @PartModels annotation can only be used on static fields or methods. Was seen on: " + + field); + continue; + } - Object value; - try - { - field.setAccessible( true ); - value = field.get( null ); - } - catch( IllegalAccessException e ) - { - AELog.error( e, "Cannot access field annotated with @PartModels: " + field ); - continue; - } + Object value; + try { + field.setAccessible(true); + value = field.get(null); + } catch (IllegalAccessException e) { + AELog.error(e, "Cannot access field annotated with @PartModels: " + field); + continue; + } - convertAndAddLocation( field, value, locations ); - } + convertAndAddLocation(field, value, locations); + } - // Check all static methods for the annotation - for( Method method : clazz.getDeclaredMethods() ) - { - if( method.getAnnotation( PartModels.class ) == null ) - { - continue; - } + // Check all static methods for the annotation + for (Method method : clazz.getDeclaredMethods()) { + if (method.getAnnotation(PartModels.class) == null) { + continue; + } - if( !Modifier.isStatic( method.getModifiers() ) ) - { - AELog.error( "The @PartModels annotation can only be used on static fields or methods. Was seen on: " + method ); - continue; - } + if (!Modifier.isStatic(method.getModifiers())) { + AELog.error("The @PartModels annotation can only be used on static fields or methods. Was seen on: " + + method); + continue; + } - // Check for parameter count - if( method.getParameters().length != 0 ) - { - AELog.error( "The @PartModels annotation can only be used on static methods without parameters. Was seen on: " + method ); - continue; - } + // Check for parameter count + if (method.getParameters().length != 0) { + AELog.error( + "The @PartModels annotation can only be used on static methods without parameters. Was seen on: " + + method); + continue; + } - // Make sure we can handle the return type - Class returnType = method.getReturnType(); - if( !ResourceLocation.class.isAssignableFrom( returnType ) && !Collection.class.isAssignableFrom( returnType ) ) - { - AELog.error( - "The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of " + "ResourceLocations. Was seen on: " + method ); - continue; - } + // Make sure we can handle the return type + Class returnType = method.getReturnType(); + if (!ResourceLocation.class.isAssignableFrom(returnType) + && !Collection.class.isAssignableFrom(returnType)) { + AELog.error( + "The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of " + + "ResourceLocations. Was seen on: " + method); + continue; + } - Object value = null; - try - { - method.setAccessible( true ); - value = method.invoke( null ); - } - catch( IllegalAccessException | InvocationTargetException e ) - { - AELog.error( e, "Failed to invoke the @PartModels annotated method " + method ); - continue; - } + Object value = null; + try { + method.setAccessible(true); + value = method.invoke(null); + } catch (IllegalAccessException | InvocationTargetException e) { + AELog.error(e, "Failed to invoke the @PartModels annotated method " + method); + continue; + } - convertAndAddLocation( method, value, locations ); - } + convertAndAddLocation(method, value, locations); + } - if( clazz.getSuperclass() != null ) - { - locations.addAll( createModels( clazz.getSuperclass() ) ); - } + if (clazz.getSuperclass() != null) { + locations.addAll(createModels(clazz.getSuperclass())); + } - return locations; - } + return locations; + } - private static void convertAndAddLocation( Object source, Object value, List locations ) - { - if( value == null ) - { - return; - } + private static void convertAndAddLocation(Object source, Object value, List locations) { + if (value == null) { + return; + } - if( value instanceof ResourceLocation ) - { - locations.add( (ResourceLocation) value ); - } - else if( value instanceof IPartModel ) - { - locations.addAll( ( (IPartModel) value ).getModels() ); - } - else if( value instanceof Collection ) - { - // Check that each object is an IPartModel - Collection values = (Collection) value; - for( Object candidate : values ) - { - if( !( candidate instanceof IPartModel ) ) - { - AELog.error( "List of locations obtained from {} contains a non resource location: {}", source, candidate ); - continue; - } + if (value instanceof ResourceLocation) { + locations.add((ResourceLocation) value); + } else if (value instanceof IPartModel) { + locations.addAll(((IPartModel) value).getModels()); + } else if (value instanceof Collection) { + // Check that each object is an IPartModel + Collection values = (Collection) value; + for (Object candidate : values) { + if (!(candidate instanceof IPartModel)) { + AELog.error("List of locations obtained from {} contains a non resource location: {}", source, + candidate); + continue; + } - locations.addAll( ( (IPartModel) candidate ).getModels() ); - } - } - } + locations.addAll(((IPartModel) candidate).getModels()); + } + } + } } diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index e7a5ca82a..a46dac06e 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -18,21 +18,18 @@ package appeng.items.parts; - import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; -import appeng.fluids.parts.*; -import appeng.parts.p2p.*; - import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import appeng.api.parts.IPart; import appeng.api.features.AEFeature; +import appeng.api.parts.IPart; +import appeng.fluids.parts.*; import appeng.parts.automation.PartAnnihilationPlane; import appeng.parts.automation.PartExportBus; import appeng.parts.automation.PartFormationPlane; @@ -50,6 +47,7 @@ import appeng.parts.networking.PartCableSmart; import appeng.parts.networking.PartDenseCableCovered; import appeng.parts.networking.PartDenseCableSmart; import appeng.parts.networking.PartQuartzFiber; +import appeng.parts.p2p.*; import appeng.parts.reporting.PartConversionMonitor; import appeng.parts.reporting.PartCraftingTerminal; import appeng.parts.reporting.PartDarkPanel; @@ -60,187 +58,177 @@ import appeng.parts.reporting.PartSemiDarkPanel; import appeng.parts.reporting.PartStorageMonitor; import appeng.parts.reporting.PartTerminal; +public enum PartType { + INVALID_TYPE(EnumSet.of(AEFeature.CORE), EnumSet.noneOf(IntegrationType.class), null), -public enum PartType -{ - INVALID_TYPE(EnumSet.of( AEFeature.CORE ), EnumSet.noneOf( IntegrationType.class ), null ), + CABLE_GLASS(EnumSet.of(AEFeature.GLASS_CABLES), EnumSet.noneOf(IntegrationType.class), PartCableGlass.class) { + @Override + public boolean isCable() { + return true; + } + }, - CABLE_GLASS(EnumSet.of( AEFeature.GLASS_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableGlass.class ) - { - @Override - public boolean isCable() - { - return true; - } - }, + CABLE_COVERED(EnumSet.of(AEFeature.COVERED_CABLES), EnumSet.noneOf(IntegrationType.class), PartCableCovered.class) { + @Override + public boolean isCable() { + return true; + } + }, - CABLE_COVERED(EnumSet.of( AEFeature.COVERED_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableCovered.class ) - { - @Override - public boolean isCable() - { - return true; - } - }, + CABLE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.SMART_CABLES), EnumSet.noneOf(IntegrationType.class), + PartCableSmart.class) { + @Override + public boolean isCable() { + return true; + } + }, - CABLE_SMART(EnumSet.of( AEFeature.CHANNELS, AEFeature.SMART_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableSmart.class ) - { - @Override - public boolean isCable() - { - return true; - } - }, + CABLE_DENSE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), EnumSet.noneOf(IntegrationType.class), + PartDenseCableSmart.class) { + @Override + public boolean isCable() { + return true; + } + }, - CABLE_DENSE_SMART(EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet - .noneOf( IntegrationType.class ), PartDenseCableSmart.class ) - { - @Override - public boolean isCable() - { - return true; - } - }, + CABLE_DENSE_COVERED(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), EnumSet.noneOf(IntegrationType.class), + PartDenseCableCovered.class) { + @Override + public boolean isCable() { + return true; + } + }, - CABLE_DENSE_COVERED(EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet - .noneOf( IntegrationType.class ), PartDenseCableCovered.class ) - { - @Override - public boolean isCable() - { - return true; - } - }, + TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), EnumSet.noneOf(IntegrationType.class), PartToggleBus.class), - TOGGLE_BUS(EnumSet.of( AEFeature.TOGGLE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartToggleBus.class ), + INVERTED_TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), EnumSet.noneOf(IntegrationType.class), + PartInvertedToggleBus.class), - INVERTED_TOGGLE_BUS(EnumSet.of( AEFeature.TOGGLE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartInvertedToggleBus.class ), + CABLE_ANCHOR(EnumSet.of(AEFeature.CABLE_ANCHOR), EnumSet.noneOf(IntegrationType.class), PartCableAnchor.class), - CABLE_ANCHOR(EnumSet.of( AEFeature.CABLE_ANCHOR ), EnumSet.noneOf( IntegrationType.class ), PartCableAnchor.class ), + QUARTZ_FIBER(EnumSet.of(AEFeature.QUARTZ_FIBER), EnumSet.noneOf(IntegrationType.class), PartQuartzFiber.class), - QUARTZ_FIBER(EnumSet.of( AEFeature.QUARTZ_FIBER ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ), + MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartPanel.class), - MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class), + SEMI_DARK_MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartSemiDarkPanel.class), - SEMI_DARK_MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet - .noneOf( IntegrationType.class ), PartSemiDarkPanel.class), + DARK_MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartDarkPanel.class), - DARK_MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class), + STORAGE_BUS(EnumSet.of(AEFeature.STORAGE_BUS), EnumSet.noneOf(IntegrationType.class), PartStorageBus.class), + FLUID_STORAGE_BUS(EnumSet.of(AEFeature.FLUID_STORAGE_BUS), EnumSet.noneOf(IntegrationType.class), + PartFluidStorageBus.class), - STORAGE_BUS(EnumSet.of( AEFeature.STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ), - FLUID_STORAGE_BUS(EnumSet.of( AEFeature.FLUID_STORAGE_BUS ), EnumSet - .noneOf( IntegrationType.class ), PartFluidStorageBus.class ), + IMPORT_BUS(EnumSet.of(AEFeature.IMPORT_BUS), EnumSet.noneOf(IntegrationType.class), PartImportBus.class), - IMPORT_BUS(EnumSet.of( AEFeature.IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartImportBus.class ), + FLUID_IMPORT_BUS(EnumSet.of(AEFeature.FLUID_IMPORT_BUS), EnumSet.noneOf(IntegrationType.class), + PartFluidImportBus.class), - FLUID_IMPORT_BUS(EnumSet.of( AEFeature.FLUID_IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidImportBus.class ), + EXPORT_BUS(EnumSet.of(AEFeature.EXPORT_BUS), EnumSet.noneOf(IntegrationType.class), PartExportBus.class), - EXPORT_BUS(EnumSet.of( AEFeature.EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartExportBus.class ), + FLUID_EXPORT_BUS(EnumSet.of(AEFeature.FLUID_EXPORT_BUS), EnumSet.noneOf(IntegrationType.class), + PartFluidExportBus.class), - FLUID_EXPORT_BUS(EnumSet.of( AEFeature.FLUID_EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidExportBus.class ), + LEVEL_EMITTER(EnumSet.of(AEFeature.LEVEL_EMITTER), EnumSet.noneOf(IntegrationType.class), PartLevelEmitter.class), + FLUID_LEVEL_EMITTER(EnumSet.of(AEFeature.FLUID_LEVEL_EMITTER), EnumSet.noneOf(IntegrationType.class), + PartFluidLevelEmitter.class), - LEVEL_EMITTER(EnumSet.of( AEFeature.LEVEL_EMITTER ), EnumSet.noneOf( IntegrationType.class ), PartLevelEmitter.class ), - FLUID_LEVEL_EMITTER(EnumSet.of( AEFeature.FLUID_LEVEL_EMITTER ), EnumSet - .noneOf( IntegrationType.class ), PartFluidLevelEmitter.class ), + ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE), EnumSet.noneOf(IntegrationType.class), + PartAnnihilationPlane.class), - ANNIHILATION_PLANE(EnumSet.of( AEFeature.ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartAnnihilationPlane.class ), + IDENTITY_ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE), + EnumSet.noneOf(IntegrationType.class), PartIdentityAnnihilationPlane.class), - IDENTITY_ANNIHILATION_PLANE(EnumSet.of( AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartIdentityAnnihilationPlane.class ), + FLUID_ANNIHILATION_PLANE(EnumSet.of(AEFeature.FLUID_ANNIHILATION_PLANE), EnumSet.noneOf(IntegrationType.class), + PartFluidAnnihilationPlane.class), - FLUID_ANNIHILATION_PLANE(EnumSet.of( AEFeature.FLUID_ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartFluidAnnihilationPlane.class ), + FORMATION_PLANE(EnumSet.of(AEFeature.FORMATION_PLANE), EnumSet.noneOf(IntegrationType.class), + PartFormationPlane.class), - FORMATION_PLANE(EnumSet.of( AEFeature.FORMATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartFormationPlane.class ), + FLUID_FORMATION_PLANE(EnumSet.of(AEFeature.FLUID_FORMATION_PLANE), EnumSet.noneOf(IntegrationType.class), + PartFluidFormationPlane.class), - FLUID_FORMATION_PLANE(EnumSet.of( AEFeature.FLUID_FORMATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartFluidFormationPlane.class ), + PATTERN_TERMINAL(EnumSet.of(AEFeature.PATTERNS), EnumSet.noneOf(IntegrationType.class), PartPatternTerminal.class), - PATTERN_TERMINAL(EnumSet.of( AEFeature.PATTERNS ), EnumSet.noneOf( IntegrationType.class ), PartPatternTerminal.class ), + CRAFTING_TERMINAL(EnumSet.of(AEFeature.CRAFTING_TERMINAL), EnumSet.noneOf(IntegrationType.class), + PartCraftingTerminal.class), - CRAFTING_TERMINAL(EnumSet.of( AEFeature.CRAFTING_TERMINAL ), EnumSet - .noneOf( IntegrationType.class ), PartCraftingTerminal.class ), + TERMINAL(EnumSet.of(AEFeature.TERMINAL), EnumSet.noneOf(IntegrationType.class), PartTerminal.class), - TERMINAL(EnumSet.of( AEFeature.TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartTerminal.class ), + STORAGE_MONITOR(EnumSet.of(AEFeature.STORAGE_MONITOR), EnumSet.noneOf(IntegrationType.class), + PartStorageMonitor.class), - STORAGE_MONITOR(EnumSet.of( AEFeature.STORAGE_MONITOR ), EnumSet.noneOf( IntegrationType.class ), PartStorageMonitor.class ), + CONVERSION_MONITOR(EnumSet.of(AEFeature.PART_CONVERSION_MONITOR), EnumSet.noneOf(IntegrationType.class), + PartConversionMonitor.class), - CONVERSION_MONITOR(EnumSet.of( AEFeature.PART_CONVERSION_MONITOR ), EnumSet - .noneOf( IntegrationType.class ), PartConversionMonitor.class ), + INTERFACE(EnumSet.of(AEFeature.INTERFACE), EnumSet.noneOf(IntegrationType.class), PartInterface.class), + FLUID_INTERFACE(EnumSet.of(AEFeature.FLUID_INTERFACE), EnumSet.noneOf(IntegrationType.class), + PartFluidInterface.class), - INTERFACE(EnumSet.of( AEFeature.INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartInterface.class ), - FLUID_INTERFACE(EnumSet.of( AEFeature.FLUID_INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartFluidInterface.class ), + P2P_TUNNEL_ME(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME), EnumSet.noneOf(IntegrationType.class), + PartP2PTunnelME.class), - P2P_TUNNEL_ME(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME ), EnumSet - .noneOf( IntegrationType.class ), PartP2PTunnelME.class), + P2P_TUNNEL_REDSTONE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE), + EnumSet.noneOf(IntegrationType.class), PartP2PRedstone.class), - P2P_TUNNEL_REDSTONE(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE ), EnumSet - .noneOf( IntegrationType.class ), PartP2PRedstone.class), + P2P_TUNNEL_ITEM(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS), EnumSet.noneOf(IntegrationType.class), + PartP2PItems.class), - P2P_TUNNEL_ITEM(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS ), EnumSet - .noneOf( IntegrationType.class ), PartP2PItems.class), - - P2P_TUNNEL_FLUID(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS ), EnumSet - .noneOf( IntegrationType.class ), PartP2PFluids.class), + P2P_TUNNEL_FLUID(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS), + EnumSet.noneOf(IntegrationType.class), PartP2PFluids.class), //FIXME P2P_TUNNEL_IC2( 465, "p2p_tunnel_ic2", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_EU ), EnumSet //FIXME .of( IntegrationType.IC2 ), PartP2PIC2Power.class ), - P2P_TUNNEL_LIGHT(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet - .noneOf( IntegrationType.class ), PartP2PLight.class), + P2P_TUNNEL_LIGHT(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT), + EnumSet.noneOf(IntegrationType.class), PartP2PLight.class), - P2P_TUNNEL_FE(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE ), EnumSet - .noneOf( IntegrationType.class ), PartP2PFEPower.class), + P2P_TUNNEL_FE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE), EnumSet.noneOf(IntegrationType.class), + PartP2PFEPower.class), - // P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of( - // IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ), + // P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, + // AEFeature.P2PTunnelOpenComputers ), EnumSet.of( + // IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel + // ), - INTERFACE_TERMINAL(EnumSet.of( AEFeature.INTERFACE_TERMINAL ), EnumSet - .noneOf( IntegrationType.class ), PartInterfaceTerminal.class ), + INTERFACE_TERMINAL(EnumSet.of(AEFeature.INTERFACE_TERMINAL), EnumSet.noneOf(IntegrationType.class), + PartInterfaceTerminal.class), - FLUID_TERMINAL(EnumSet.of( AEFeature.FLUID_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartFluidTerminal.class ); + FLUID_TERMINAL(EnumSet.of(AEFeature.FLUID_TERMINAL), EnumSet.noneOf(IntegrationType.class), + PartFluidTerminal.class); - private final Set features; - private final Set integrations; - @OnlyIn( Dist.CLIENT ) - private final Set models; + private final Set features; + private final Set integrations; + @OnlyIn(Dist.CLIENT) + private final Set models; - PartType(final Set features, final Set integrations, final Class c) - { - this.features = Collections.unmodifiableSet( features ); - this.integrations = Collections.unmodifiableSet( integrations ); + PartType(final Set features, final Set integrations, final Class c) { + this.features = Collections.unmodifiableSet(features); + this.integrations = Collections.unmodifiableSet(integrations); - if( c != null ) - { - this.models = new HashSet<>( PartModelsHelper.createModels( c ) ); - } - else - { - this.models = Collections.emptySet(); - } - } + if (c != null) { + this.models = new HashSet<>(PartModelsHelper.createModels(c)); + } else { + this.models = Collections.emptySet(); + } + } - public boolean isCable() - { - return false; - } + public boolean isCable() { + return false; + } - public Set getFeature() - { - return this.features; - } + public Set getFeature() { + return this.features; + } - Set getIntegrations() - { - return this.integrations; - } + Set getIntegrations() { + return this.integrations; + } - public Set getModels() - { - return this.models; - } + public Set getModels() { + return this.models; + } } -enum IntegrationType {} \ No newline at end of file +enum IntegrationType { +} \ No newline at end of file diff --git a/src/main/java/appeng/items/storage/AbstractStorageCell.java b/src/main/java/appeng/items/storage/AbstractStorageCell.java index cb73e8c5f..9e9cb7467 100644 --- a/src/main/java/appeng/items/storage/AbstractStorageCell.java +++ b/src/main/java/appeng/items/storage/AbstractStorageCell.java @@ -18,7 +18,6 @@ package appeng.items.storage; - import java.util.List; import java.util.Set; @@ -29,7 +28,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; @@ -42,6 +40,7 @@ import net.minecraftforge.items.IItemHandler; import appeng.api.AEApi; import appeng.api.config.FuzzyMode; import appeng.api.exceptions.MissingDefinitionException; +import appeng.api.features.AEFeature; import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IUpgradeModule; @@ -50,7 +49,6 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; import appeng.core.AEConfig; -import appeng.api.features.AEFeature; import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; import appeng.items.contents.CellConfig; @@ -59,191 +57,159 @@ import appeng.items.materials.MaterialType; import appeng.util.InventoryAdaptor; import appeng.util.Platform; - /** * @author DrummerMC * @version rv6 - 2018-01-17 * @since rv6 2018-01-17 */ -public abstract class AbstractStorageCell> extends AEBaseItem implements IStorageCell, IItemGroup -{ - protected final MaterialType component; - protected final int totalBytes; +public abstract class AbstractStorageCell> extends AEBaseItem + implements IStorageCell, IItemGroup { + protected final MaterialType component; + protected final int totalBytes; - public AbstractStorageCell(Properties properties, final MaterialType whichCell, final int kilobytes ) { - super(properties); - this.totalBytes = kilobytes * 1024; - this.component = whichCell; - } + public AbstractStorageCell(Properties properties, final MaterialType whichCell, final int kilobytes) { + super(properties); + this.totalBytes = kilobytes * 1024; + this.component = whichCell; + } - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - AEApi.instance() - .client() - .addCellInformation( AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() ), lines ); - } + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + AEApi.instance().client().addCellInformation( + AEApi.instance().registries().cell().getCellInventory(stack, null, this.getChannel()), lines); + } - @Override - public int getBytes( final ItemStack cellItem ) - { - return this.totalBytes; - } + @Override + public int getBytes(final ItemStack cellItem) { + return this.totalBytes; + } - @Override - public int getTotalTypes( final ItemStack cellItem ) - { - return 63; - } + @Override + public int getTotalTypes(final ItemStack cellItem) { + return 63; + } - @Override - public boolean isBlackListed( final ItemStack cellItem, final T requestedAddition ) - { - return false; - } + @Override + public boolean isBlackListed(final ItemStack cellItem, final T requestedAddition) { + return false; + } - @Override - public boolean storableInStorageCell() - { - return false; - } + @Override + public boolean storableInStorageCell() { + return false; + } - @Override - public boolean isStorageCell( final ItemStack i ) - { - return true; - } + @Override + public boolean isStorageCell(final ItemStack i) { + return true; + } - @Override - public String getUnlocalizedGroupName( final Set others, final ItemStack is ) - { - return GuiText.StorageCells.getTranslationKey(); - } + @Override + public String getUnlocalizedGroupName(final Set others, final ItemStack is) { + return GuiText.StorageCells.getTranslationKey(); + } - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } + @Override + public boolean isEditable(final ItemStack is) { + return true; + } - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return new CellUpgrades( is, 2 ); - } + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 2); + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - final String fz = is.getOrCreateTag().getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { - return FuzzyMode.IGNORE_ALL; - } - } + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = is.getOrCreateTag().getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { + return FuzzyMode.IGNORE_ALL; + } + } - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { is.getOrCreateTag().putString("FuzzyMode", fzMode.name()); - } + } - @Override - public ActionResult onItemRightClick( final World world, final PlayerEntity player, final Hand hand ) - { - this.disassembleDrive( player.getHeldItem( hand ), world, player ); - return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) ); - } + @Override + public ActionResult onItemRightClick(final World world, final PlayerEntity player, final Hand hand) { + this.disassembleDrive(player.getHeldItem(hand), world, player); + return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand)); + } - private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player ) - { - if( player.isCrouching() ) - { - if( Platform.isClient() ) - { - return false; - } + private boolean disassembleDrive(final ItemStack stack, final World world, final PlayerEntity player) { + if (player.isCrouching()) { + if (Platform.isClient()) { + return false; + } - final PlayerInventory playerInventory = player.inventory; - final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() ); - if( inv != null && playerInventory.getCurrentItem() == stack ) - { - final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player ); - final IItemList list = inv.getAvailableItems( this.getChannel().createList() ); - if( list.isEmpty() && ia != null ) - { - playerInventory.setInventorySlotContents( playerInventory.currentItem, ItemStack.EMPTY ); + final PlayerInventory playerInventory = player.inventory; + final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory(stack, null, + this.getChannel()); + if (inv != null && playerInventory.getCurrentItem() == stack) { + final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player); + final IItemList list = inv.getAvailableItems(this.getChannel().createList()); + if (list.isEmpty() && ia != null) { + playerInventory.setInventorySlotContents(playerInventory.currentItem, ItemStack.EMPTY); - // drop core - final ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); - if( !extraB.isEmpty() ) - { - player.dropItem( extraB, false ); - } + // drop core + final ItemStack extraB = ia.addItems(this.component.stack(1)); + if (!extraB.isEmpty()) { + player.dropItem(extraB, false); + } - // drop upgrades - final IItemHandler upgradesInventory = this.getUpgradesInventory( stack ); - for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++ ) - { - final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex ); - final ItemStack leftStack = ia.addItems( upgradeStack ); - if( !leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule ) - { - player.dropItem( upgradeStack, false ); - } - } + // drop upgrades + final IItemHandler upgradesInventory = this.getUpgradesInventory(stack); + for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++) { + final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex); + final ItemStack leftStack = ia.addItems(upgradeStack); + if (!leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule) { + player.dropItem(upgradeStack, false); + } + } - // drop empty storage cell case - this.dropEmptyStorageCellCase( ia, player ); + // drop empty storage cell case + this.dropEmptyStorageCellCase(ia, player); - if( player.container != null ) - { - player.container.detectAndSendChanges(); - } + if (player.container != null) { + player.container.detectAndSendChanges(); + } - return true; - } - } - } - return false; - } + return true; + } + } + } + return false; + } - protected abstract void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player ); + protected abstract void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player); - @Override - public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context ) - { - return this.disassembleDrive( stack, context.getWorld(), context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS; - } - - @Override - public ItemStack getContainerItem( final ItemStack itemStack ) - { - return AEApi.instance() - .definitions() - .materials() - .emptyStorageCell() - .maybeStack( 1 ) - .orElseThrow( () -> new MissingDefinitionException( "Tried to use empty storage cells while basic storage cells are defined." ) ); - } - - @Override - public boolean hasContainerItem( final ItemStack stack ) - { - return AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ); - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + return this.disassembleDrive(stack, context.getWorld(), context.getPlayer()) ? ActionResultType.SUCCESS + : ActionResultType.PASS; + } + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + return AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1) + .orElseThrow(() -> new MissingDefinitionException( + "Tried to use empty storage cells while basic storage cells are defined.")); + } + @Override + public boolean hasContainerItem(final ItemStack stack) { + return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING); + } } diff --git a/src/main/java/appeng/items/storage/BasicItemStorageCell.java b/src/main/java/appeng/items/storage/BasicItemStorageCell.java index 3003e4586..93a21e9f0 100644 --- a/src/main/java/appeng/items/storage/BasicItemStorageCell.java +++ b/src/main/java/appeng/items/storage/BasicItemStorageCell.java @@ -18,7 +18,6 @@ package appeng.items.storage; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -29,69 +28,59 @@ import appeng.api.storage.data.IAEItemStack; import appeng.items.materials.MaterialType; import appeng.util.InventoryAdaptor; +public final class BasicItemStorageCell extends AbstractStorageCell { -public final class BasicItemStorageCell extends AbstractStorageCell -{ + protected final int perType; + protected final double idleDrain; - protected final int perType; - protected final double idleDrain; + public BasicItemStorageCell(Properties props, final MaterialType whichCell, final int kilobytes) { + super(props, whichCell, kilobytes); + switch (whichCell) { + case ITEM_1K_CELL_COMPONENT: + this.idleDrain = 0.5; + this.perType = 8; + break; + case ITEM_4K_CELL_COMPONENT: + this.idleDrain = 1.0; + this.perType = 32; + break; + case ITEM_16K_CELL_COMPONENT: + this.idleDrain = 1.5; + this.perType = 128; + break; + case ITEM_64K_CELL_COMPONENT: + this.idleDrain = 2.0; + this.perType = 512; + break; + default: + this.idleDrain = 0.0; + this.perType = 8; + } - public BasicItemStorageCell( Properties props, final MaterialType whichCell, final int kilobytes ) - { - super( props, whichCell, kilobytes ); - switch( whichCell ) - { - case ITEM_1K_CELL_COMPONENT: - this.idleDrain = 0.5; - this.perType = 8; - break; - case ITEM_4K_CELL_COMPONENT: - this.idleDrain = 1.0; - this.perType = 32; - break; - case ITEM_16K_CELL_COMPONENT: - this.idleDrain = 1.5; - this.perType = 128; - break; - case ITEM_64K_CELL_COMPONENT: - this.idleDrain = 2.0; - this.perType = 512; - break; - default: - this.idleDrain = 0.0; - this.perType = 8; - } + } - } + @Override + public int getBytesPerType(ItemStack cellItem) { + return this.perType; + } - @Override - public int getBytesPerType( ItemStack cellItem ) - { - return this.perType; - } + @Override + public double getIdleDrain() { + return this.idleDrain; + } - @Override - public double getIdleDrain() - { - return this.idleDrain; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } - - @Override - protected void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player ) - { - AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is -> - { - final ItemStack extraA = ia.addItems( is ); - if( !extraA.isEmpty() ) - { - player.dropItem( extraA, false ); - } - } ); - } + @Override + protected void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player) { + AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1).ifPresent(is -> { + final ItemStack extraA = ia.addItems(is); + if (!extraA.isEmpty()) { + player.dropItem(extraA, false); + } + }); + } } diff --git a/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java b/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java index 6e7544d79..989f5318c 100644 --- a/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java @@ -18,7 +18,6 @@ package appeng.items.storage; - import java.util.List; import net.minecraft.client.util.ITooltipFlag; @@ -38,66 +37,52 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.items.AEBaseItem; import appeng.items.contents.CellConfig; +public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem { -public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem -{ + public ItemCreativeStorageCell(Properties props) { + super(props); + } - public ItemCreativeStorageCell(Properties props) - { - super(props); - } + @Override + public boolean isEditable(final ItemStack is) { + return true; + } - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return null; + } - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return null; - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + return FuzzyMode.IGNORE_ALL; + } - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - return FuzzyMode.IGNORE_ALL; - } + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { + } - } + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + final IMEInventoryHandler inventory = AEApi.instance().registries().cell().getCellInventory(stack, null, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - final IMEInventoryHandler inventory = AEApi.instance() - .registries() - .cell() - .getCellInventory( stack, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + if (inventory instanceof ICellInventoryHandler) { + final CellConfig cc = new CellConfig(stack); - if( inventory instanceof ICellInventoryHandler ) - { - final CellConfig cc = new CellConfig( stack ); - - for( final ItemStack is : cc ) - { - if( !is.isEmpty() ) - { - lines.add( is.getDisplayName() ); - } - } - } - } + for (final ItemStack is : cc) { + if (!is.isEmpty()) { + lines.add(is.getDisplayName()); + } + } + } + } } diff --git a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java index b309412bd..109ed2d92 100644 --- a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java @@ -18,16 +18,8 @@ package appeng.items.storage; +import java.util.List; -import appeng.api.implementations.TransitionResult; -import appeng.api.implementations.items.ISpatialStorageCell; -import appeng.api.storage.ISpatialDimension; -import appeng.api.util.WorldCoord; -import appeng.core.AELog; -import appeng.core.localization.GuiText; -import appeng.spatial.SpatialDimensionManager; -import appeng.items.AEBaseItem; -import appeng.spatial.StorageHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -41,130 +33,120 @@ import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.List; +import appeng.api.implementations.TransitionResult; +import appeng.api.implementations.items.ISpatialStorageCell; +import appeng.api.storage.ISpatialDimension; +import appeng.api.util.WorldCoord; +import appeng.core.AELog; +import appeng.core.localization.GuiText; +import appeng.items.AEBaseItem; +import appeng.spatial.SpatialDimensionManager; +import appeng.spatial.StorageHelper; +public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell { + private static final String TAG_DIMENSION_ID = "dimension_id"; -public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell -{ - private static final String TAG_DIMENSION_ID = "dimension_id"; + private final int maxRegion; - private final int maxRegion; + public ItemSpatialStorageCell(Properties props, final int spatialScale) { + super(props); + this.maxRegion = spatialScale; + } - public ItemSpatialStorageCell( Properties props, final int spatialScale ) - { - super(props); - this.maxRegion = spatialScale; - } + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + final DimensionType dimType = this.getStoredDimension(stack); + if (dimType == null) { + lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC)); + lines.add(GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion)); + } else { + SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines); + } - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - final DimensionType dimType = this.getStoredDimension(stack); - if (dimType == null) { - lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC)); - lines.add( GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion)); - } else { - SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines); - } + if (advancedTooltips.isAdvanced()) { + if (dimType != null && dimType.getRegistryName() != null) { + lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName())); + } + } + } - if (advancedTooltips.isAdvanced()) { - if (dimType != null && dimType.getRegistryName() != null) { - lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName())); - } - } - } + @Override + public boolean isSpatialStorage(final ItemStack is) { + return true; + } - @Override - public boolean isSpatialStorage( final ItemStack is ) - { - return true; - } + @Override + public int getMaxStoredDim(final ItemStack is) { + return this.maxRegion; + } - @Override - public int getMaxStoredDim( final ItemStack is ) - { - return this.maxRegion; - } + @Override + public DimensionType getStoredDimension(final ItemStack is) { + final CompoundNBT c = is.getTag(); + if (c != null && c.contains(TAG_DIMENSION_ID)) { + try { + ResourceLocation dimTypeId = new ResourceLocation(c.getString(TAG_DIMENSION_ID)); + return DimensionType.byName(dimTypeId); + } catch (Exception e) { + AELog.warn("Failed to retrieve storage cell dimension.", e); + } + } + return null; + } - @Override - public DimensionType getStoredDimension(final ItemStack is ) - { - final CompoundNBT c = is.getTag(); - if( c != null && c.contains(TAG_DIMENSION_ID) ) - { - try { - ResourceLocation dimTypeId = new ResourceLocation(c.getString(TAG_DIMENSION_ID) ); - return DimensionType.byName(dimTypeId); - } catch (Exception e) { - AELog.warn("Failed to retrieve storage cell dimension.", e); - } - } - return null; - } + @Override + public TransitionResult doSpatialTransition(final ItemStack is, final World w, final WorldCoord min, + final WorldCoord max, int playerId) { + final int targetX = max.x - min.x - 1; + final int targetY = max.y - min.y - 1; + final int targetZ = max.z - min.z - 1; + final int maxSize = this.getMaxStoredDim(is); - @Override - public TransitionResult doSpatialTransition( final ItemStack is, final World w, final WorldCoord min, final WorldCoord max, int playerId ) - { - final int targetX = max.x - min.x - 1; - final int targetY = max.y - min.y - 1; - final int targetZ = max.z - min.z - 1; - final int maxSize = this.getMaxStoredDim( is ); + final BlockPos targetSize = new BlockPos(targetX, targetY, targetZ); - final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ ); + ISpatialDimension manager = SpatialDimensionManager.INSTANCE; - ISpatialDimension manager = SpatialDimensionManager.INSTANCE; + DimensionType storedDim = this.getStoredDimension(is); + if (storedDim == null) { + storedDim = manager.createNewCellDimension(targetSize); + } - DimensionType storedDim = this.getStoredDimension( is ); - if( storedDim == null ) - { - storedDim = manager.createNewCellDimension( targetSize); - } + if (storedDim == null) { + // Failed to create the dimension + return new TransitionResult(false, 0); + } - if (storedDim == null) { - // Failed to create the dimension - return new TransitionResult(false, 0); - } + try { + if (manager.isCellDimension(storedDim)) { + World cellWorld = manager.getWorld(storedDim); - try - { - if( manager.isCellDimension( storedDim ) ) - { - World cellWorld = manager.getWorld(storedDim); + BlockPos scale = manager.getCellDimensionSize(storedDim); - BlockPos scale = manager.getCellDimensionSize( storedDim ); + if (scale.equals(targetSize)) { + if (targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize) { + BlockPos offset = manager.getCellDimensionOrigin(storedDim); - if( scale.equals( targetSize ) ) - { - if( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize ) - { - BlockPos offset = manager.getCellDimensionOrigin( storedDim ); + this.setStoredDimension(is, storedDim); + StorageHelper.getInstance().swapRegions(w, min.x + 1, min.y + 1, min.z + 1, cellWorld, + offset.getX(), offset.getY(), offset.getZ(), targetX - 1, targetY - 1, targetZ - 1); - this.setStoredDimension( is, storedDim); - StorageHelper.getInstance() - .swapRegions( w, min.x + 1, min.y + 1, min.z + 1, cellWorld, offset.getX(), offset.getY(), - offset.getZ(), targetX - 1, targetY - 1, - targetZ - 1 ); + return new TransitionResult(true, 0); + } + } + } + return new TransitionResult(false, 0); + } finally { + // clean up newly created dimensions that failed transfer + if (manager.isCellDimension(storedDim) && this.getStoredDimension(is) == null) { + manager.deleteCellDimension(storedDim); + } + } + } - return new TransitionResult( true, 0 ); - } - } - } - return new TransitionResult( false, 0 ); - } - finally - { - // clean up newly created dimensions that failed transfer - if( manager.isCellDimension( storedDim ) && this.getStoredDimension( is ) == null ) - { - manager.deleteCellDimension( storedDim ); - } - } - } - - private void setStoredDimension(final ItemStack is, DimensionType dim) - { + private void setStoredDimension(final ItemStack is, DimensionType dim) { final CompoundNBT c = is.getOrCreateTag(); - c.putString(TAG_DIMENSION_ID, dim.getRegistryName().toString() ); - } + c.putString(TAG_DIMENSION_ID, dim.getRegistryName().toString()); + } } diff --git a/src/main/java/appeng/items/storage/ItemViewCell.java b/src/main/java/appeng/items/storage/ItemViewCell.java index 5db194c0d..0606f377b 100644 --- a/src/main/java/appeng/items/storage/ItemViewCell.java +++ b/src/main/java/appeng/items/storage/ItemViewCell.java @@ -18,7 +18,6 @@ package appeng.items.storage; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; @@ -40,124 +39,101 @@ import appeng.util.prioritylist.IPartitionList; import appeng.util.prioritylist.MergedPriorityList; import appeng.util.prioritylist.PrecisePriorityList; +public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem { -public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem -{ + public ItemViewCell(Properties properties) { + super(properties); + } - public ItemViewCell(Properties properties) { - super(properties); - } + public static IPartitionList createFilter(final ItemStack[] list) { + IPartitionList myPartitionList = null; - public static IPartitionList createFilter(final ItemStack[] list ) - { - IPartitionList myPartitionList = null; + final MergedPriorityList myMergedList = new MergedPriorityList<>(); - final MergedPriorityList myMergedList = new MergedPriorityList<>(); + for (final ItemStack currentViewCell : list) { + if (currentViewCell == null) { + continue; + } - for( final ItemStack currentViewCell : list ) - { - if( currentViewCell == null ) - { - continue; - } + if ((currentViewCell.getItem() instanceof ItemViewCell)) { + final IItemList priorityList = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); - if( ( currentViewCell.getItem() instanceof ItemViewCell ) ) - { - final IItemList priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); + final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem(); + final IItemHandler upgrades = vc.getUpgradesInventory(currentViewCell); + final IItemHandler config = vc.getConfigInventory(currentViewCell); + final FuzzyMode fzMode = vc.getFuzzyMode(currentViewCell); - final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem(); - final IItemHandler upgrades = vc.getUpgradesInventory( currentViewCell ); - final IItemHandler config = vc.getConfigInventory( currentViewCell ); - final FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell ); + boolean hasInverter = false; + boolean hasFuzzy = false; - boolean hasInverter = false; - boolean hasFuzzy = false; + for (int x = 0; x < upgrades.getSlots(); x++) { + final ItemStack is = upgrades.getStackInSlot(x); + if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) { + final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is); + if (u != null) { + switch (u) { + case FUZZY: + hasFuzzy = true; + break; + case INVERTER: + hasInverter = true; + break; + default: + } + } + } + } - for( int x = 0; x < upgrades.getSlots(); x++ ) - { - final ItemStack is = upgrades.getStackInSlot( x ); - if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) - { - final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is ); - if( u != null ) - { - switch( u ) - { - case FUZZY: - hasFuzzy = true; - break; - case INVERTER: - hasInverter = true; - break; - default: - } - } - } - } + for (int x = 0; x < config.getSlots(); x++) { + final ItemStack is = config.getStackInSlot(x); + if (!is.isEmpty()) { + priorityList.add(AEItemStack.fromItemStack(is)); + } + } - for( int x = 0; x < config.getSlots(); x++ ) - { - final ItemStack is = config.getStackInSlot( x ); - if( !is.isEmpty() ) - { - priorityList.add( AEItemStack.fromItemStack( is ) ); - } - } + if (!priorityList.isEmpty()) { + if (hasFuzzy) { + myMergedList.addNewList(new FuzzyPriorityList<>(priorityList, fzMode), !hasInverter); + } else { + myMergedList.addNewList(new PrecisePriorityList<>(priorityList), !hasInverter); + } - if( !priorityList.isEmpty() ) - { - if( hasFuzzy ) - { - myMergedList.addNewList( new FuzzyPriorityList<>( priorityList, fzMode ), !hasInverter ); - } - else - { - myMergedList.addNewList( new PrecisePriorityList<>( priorityList ), !hasInverter ); - } + myPartitionList = myMergedList; + } + } + } - myPartitionList = myMergedList; - } - } - } + return myPartitionList; + } - return myPartitionList; - } + @Override + public boolean isEditable(final ItemStack is) { + return true; + } - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 2); + } - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return new CellUpgrades( is, 2 ); - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = is.getOrCreateTag().getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { + return FuzzyMode.IGNORE_ALL; + } + } - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - final String fz = is.getOrCreateTag().getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { - return FuzzyMode.IGNORE_ALL; - } - } - - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { is.getOrCreateTag().putString("FuzzyMode", fzMode.name()); - } + } } diff --git a/src/main/java/appeng/items/tools/ToolBiometricCard.java b/src/main/java/appeng/items/tools/ToolBiometricCard.java index b63557f43..326d3a122 100644 --- a/src/main/java/appeng/items/tools/ToolBiometricCard.java +++ b/src/main/java/appeng/items/tools/ToolBiometricCard.java @@ -18,7 +18,6 @@ package appeng.items.tools; - import java.util.EnumSet; import java.util.List; @@ -46,163 +45,132 @@ import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; import appeng.util.Platform; +public class ToolBiometricCard extends AEBaseItem implements IBiometricCard { + public ToolBiometricCard(Properties properties) { + super(properties); + } -public class ToolBiometricCard extends AEBaseItem implements IBiometricCard -{ - public ToolBiometricCard(Properties properties) { - super(properties); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + if (p.isCrouching()) { + this.encode(p.getHeldItem(hand), p); + p.swingArm(hand); + return ActionResult.resultSuccess(p.getHeldItem(hand)); + } - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity p, final Hand hand ) - { - if( p.isCrouching() ) - { - this.encode( p.getHeldItem( hand ), p ); - p.swingArm( hand ); - return ActionResult.resultSuccess( p.getHeldItem( hand ) ); - } + return ActionResult.resultPass(p.getHeldItem(hand)); + } - return ActionResult.resultPass( p.getHeldItem( hand ) ); - } + @Override + public boolean itemInteractionForEntity(ItemStack is, final PlayerEntity player, final LivingEntity target, + final Hand hand) { + if (target instanceof PlayerEntity && !player.isCrouching()) { + if (player.isCreative()) { + is = player.getHeldItem(hand); + } + this.encode(is, (PlayerEntity) target); + player.swingArm(hand); + return true; + } + return false; + } - @Override - public boolean itemInteractionForEntity( ItemStack is, final PlayerEntity player, final LivingEntity target, final Hand hand ) - { - if( target instanceof PlayerEntity && !player.isCrouching() ) - { - if( player.isCreative() ) - { - is = player.getHeldItem( hand ); - } - this.encode( is, (PlayerEntity) target ); - player.swingArm( hand ); - return true; - } - return false; - } + @Override + public ITextComponent getDisplayName(final ItemStack is) { + final GameProfile username = this.getProfile(is); + return username != null ? super.getDisplayName(is).appendText(" - " + username.getName()) + : super.getDisplayName(is); + } - @Override - public ITextComponent getDisplayName( final ItemStack is ) - { - final GameProfile username = this.getProfile( is ); - return username != null ? super.getDisplayName( is ).appendText( " - " + username.getName() ) : super.getDisplayName( is ); - } + private void encode(final ItemStack is, final PlayerEntity p) { + final GameProfile username = this.getProfile(is); - private void encode( final ItemStack is, final PlayerEntity p ) - { - final GameProfile username = this.getProfile( is ); + if (username != null && username.equals(p.getGameProfile())) { + this.setProfile(is, null); + } else { + this.setProfile(is, p.getGameProfile()); + } + } - if( username != null && username.equals( p.getGameProfile() ) ) - { - this.setProfile( is, null ); - } - else - { - this.setProfile( is, p.getGameProfile() ); - } - } + @Override + public void setProfile(final ItemStack itemStack, final GameProfile profile) { + final CompoundNBT tag = itemStack.getOrCreateTag(); - @Override - public void setProfile( final ItemStack itemStack, final GameProfile profile ) - { - final CompoundNBT tag = itemStack.getOrCreateTag(); + if (profile != null) { + final CompoundNBT pNBT = new CompoundNBT(); + NBTUtil.writeGameProfile(pNBT, profile); + tag.put("profile", pNBT); + } else { + tag.remove("profile"); + } + } - if( profile != null ) - { - final CompoundNBT pNBT = new CompoundNBT(); - NBTUtil.writeGameProfile( pNBT, profile ); - tag.put( "profile", pNBT ); - } - else - { - tag.remove( "profile" ); - } - } + @Override + public GameProfile getProfile(final ItemStack is) { + final CompoundNBT tag = is.getOrCreateTag(); + if (tag.contains("profile")) { + return NBTUtil.readGameProfile(tag.getCompound("profile")); + } + return null; + } - @Override - public GameProfile getProfile( final ItemStack is ) - { - final CompoundNBT tag = is.getOrCreateTag(); - if( tag.contains( "profile" ) ) - { - return NBTUtil.readGameProfile( tag.getCompound( "profile" ) ); - } - return null; - } + @Override + public EnumSet getPermissions(final ItemStack is) { + final CompoundNBT tag = is.getOrCreateTag(); + final EnumSet result = EnumSet.noneOf(SecurityPermissions.class); - @Override - public EnumSet getPermissions( final ItemStack is ) - { - final CompoundNBT tag = is.getOrCreateTag(); - final EnumSet result = EnumSet.noneOf( SecurityPermissions.class ); + for (final SecurityPermissions sp : SecurityPermissions.values()) { + if (tag.getBoolean(sp.name())) { + result.add(sp); + } + } - for( final SecurityPermissions sp : SecurityPermissions.values() ) - { - if( tag.getBoolean( sp.name() ) ) - { - result.add( sp ); - } - } + return result; + } - return result; - } + @Override + public boolean hasPermission(final ItemStack is, final SecurityPermissions permission) { + final CompoundNBT tag = is.getOrCreateTag(); + return tag.getBoolean(permission.name()); + } - @Override - public boolean hasPermission( final ItemStack is, final SecurityPermissions permission ) - { - final CompoundNBT tag = is.getOrCreateTag(); - return tag.getBoolean( permission.name() ); - } + @Override + public void removePermission(final ItemStack itemStack, final SecurityPermissions permission) { + final CompoundNBT tag = itemStack.getOrCreateTag(); + if (tag.contains(permission.name())) { + tag.remove(permission.name()); + } + } - @Override - public void removePermission( final ItemStack itemStack, final SecurityPermissions permission ) - { - final CompoundNBT tag = itemStack.getOrCreateTag(); - if( tag.contains( permission.name() ) ) - { - tag.remove( permission.name() ); - } - } + @Override + public void addPermission(final ItemStack itemStack, final SecurityPermissions permission) { + final CompoundNBT tag = itemStack.getOrCreateTag(); + tag.putBoolean(permission.name(), true); + } - @Override - public void addPermission( final ItemStack itemStack, final SecurityPermissions permission ) - { - final CompoundNBT tag = itemStack.getOrCreateTag(); - tag.putBoolean( permission.name(), true ); - } + @Override + public void registerPermissions(final ISecurityRegistry register, final IPlayerRegistry pr, final ItemStack is) { + register.addPlayer(pr.getID(this.getProfile(is)), this.getPermissions(is)); + } - @Override - public void registerPermissions( final ISecurityRegistry register, final IPlayerRegistry pr, final ItemStack is ) - { - register.addPlayer( pr.getID( this.getProfile( is ) ), this.getPermissions( is ) ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + final EnumSet perms = this.getPermissions(stack); + if (perms.isEmpty()) { + lines.add(new TranslationTextComponent(GuiText.NoPermissions.getLocal())); + } else { + ITextComponent msg = null; - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - final EnumSet perms = this.getPermissions( stack ); - if( perms.isEmpty() ) - { - lines.add( new TranslationTextComponent( GuiText.NoPermissions.getLocal() ) ); - } - else - { - ITextComponent msg = null; - - for( final SecurityPermissions sp : perms ) - { - if( msg == null ) - { - msg = new TranslationTextComponent( sp.getTranslatedName() ); - } - else - { - msg = msg.appendText( ", " ).appendSibling( new TranslationTextComponent( sp.getTranslatedName() ) ); - } - } - lines.add( msg ); - } - } + for (final SecurityPermissions sp : perms) { + if (msg == null) { + msg = new TranslationTextComponent(sp.getTranslatedName()); + } else { + msg = msg.appendText(", ").appendSibling(new TranslationTextComponent(sp.getTranslatedName())); + } + } + lines.add(msg); + } + } } diff --git a/src/main/java/appeng/items/tools/ToolMemoryCard.java b/src/main/java/appeng/items/tools/ToolMemoryCard.java index c03734e41..40c0d5cf1 100644 --- a/src/main/java/appeng/items/tools/ToolMemoryCard.java +++ b/src/main/java/appeng/items/tools/ToolMemoryCard.java @@ -18,7 +18,6 @@ package appeng.items.tools; - import java.util.List; import net.minecraft.client.resources.I18n; @@ -47,192 +46,154 @@ import appeng.core.localization.PlayerMessages; import appeng.items.AEBaseItem; import appeng.util.Platform; +public class ToolMemoryCard extends AEBaseItem implements IMemoryCard { -public class ToolMemoryCard extends AEBaseItem implements IMemoryCard -{ + private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { AEColor.TRANSPARENT, AEColor.TRANSPARENT, + AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, + AEColor.TRANSPARENT, }; - private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - AEColor.TRANSPARENT, - }; + public ToolMemoryCard(Properties properties) { + super(properties); + } - public ToolMemoryCard(Properties properties) { - super(properties); - } + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + String firstLineKey = this.getFirstValidTranslationKey(this.getSettingsName(stack) + ".name", + this.getSettingsName(stack)); + lines.add(new TranslationTextComponent(firstLineKey)); - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - String firstLineKey = this.getFirstValidTranslationKey( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ); - lines.add( new TranslationTextComponent(firstLineKey)); + final CompoundNBT data = this.getData(stack); + if (data.contains("tooltip")) { + String tooltipKey = getFirstValidTranslationKey(data.getString("tooltip") + ".name", + data.getString("tooltip")); + lines.add(new TranslationTextComponent(tooltipKey)); + } - final CompoundNBT data = this.getData( stack ); - if( data.contains( "tooltip" ) ) - { - String tooltipKey = getFirstValidTranslationKey( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ); - lines.add( new TranslationTextComponent(tooltipKey) ); - } + if (data.contains("freq")) { + final short freq = data.getShort("freq"); + final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString(freq); - if( data.contains( "freq" ) ) - { - final short freq = data.getShort( "freq" ); - final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString( freq ); + lines.add(new TranslationTextComponent("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip)); + } + } - lines.add( new TranslationTextComponent( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) ); - } - } + /** + * Find the localized string... + * + * @param name possible names for the localized string + * + * @return localized name + */ + private String getFirstValidTranslationKey(final String... name) { + for (final String n : name) { + if (I18n.hasKey(n)) { + return n; + } + } - /** - * Find the localized string... - * - * @param name possible names for the localized string - * - * @return localized name - */ - private String getFirstValidTranslationKey( final String... name ) - { - for( final String n : name ) - { - if( I18n.hasKey(n) ) - { - return n; - } - } + for (final String n : name) { + return n; + } - for( final String n : name ) - { - return n; - } + return ""; + } - return ""; - } + @Override + public void setMemoryCardContents(final ItemStack is, final String settingsName, final CompoundNBT data) { + final CompoundNBT c = is.getOrCreateTag(); + c.putString("Config", settingsName); + c.put("Data", data); + } - @Override - public void setMemoryCardContents( final ItemStack is, final String settingsName, final CompoundNBT data ) - { - final CompoundNBT c = is.getOrCreateTag(); - c.putString( "Config", settingsName ); - c.put( "Data", data ); - } + @Override + public String getSettingsName(final ItemStack is) { + final CompoundNBT c = is.getOrCreateTag(); + final String name = c.getString("Config"); + return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name; + } - @Override - public String getSettingsName( final ItemStack is ) - { - final CompoundNBT c = is.getOrCreateTag(); - final String name = c.getString( "Config" ); - return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name; - } + @Override + public CompoundNBT getData(final ItemStack is) { + final CompoundNBT c = is.getOrCreateTag(); + CompoundNBT o = c.getCompound("Data"); + return o.copy(); + } - @Override - public CompoundNBT getData( final ItemStack is ) - { - final CompoundNBT c = is.getOrCreateTag(); - CompoundNBT o = c.getCompound( "Data" ); - return o.copy(); - } + @Override + public AEColor[] getColorCode(ItemStack is) { + final CompoundNBT tag = this.getData(is); - @Override - public AEColor[] getColorCode( ItemStack is ) - { - final CompoundNBT tag = this.getData( is ); + if (tag.contains("colorCode")) { + final int[] frequency = tag.getIntArray("colorCode"); + final AEColor[] colorArray = AEColor.values(); - if( tag.contains( "colorCode" ) ) - { - final int[] frequency = tag.getIntArray( "colorCode" ); - final AEColor[] colorArray = AEColor.values(); + return new AEColor[] { colorArray[frequency[0]], colorArray[frequency[1]], colorArray[frequency[2]], + colorArray[frequency[3]], colorArray[frequency[4]], colorArray[frequency[5]], + colorArray[frequency[6]], colorArray[frequency[7]], }; + } - return new AEColor[] { - colorArray[frequency[0]], - colorArray[frequency[1]], - colorArray[frequency[2]], - colorArray[frequency[3]], - colorArray[frequency[4]], - colorArray[frequency[5]], - colorArray[frequency[6]], - colorArray[frequency[7]], - }; - } + return DEFAULT_COLOR_CODE; + } - return DEFAULT_COLOR_CODE; - } + @Override + public void notifyUser(final PlayerEntity player, final MemoryCardMessages msg) { + if (Platform.isClient()) { + return; + } - @Override - public void notifyUser( final PlayerEntity player, final MemoryCardMessages msg ) - { - if( Platform.isClient() ) - { - return; - } + switch (msg) { + case SETTINGS_CLEARED: + player.sendMessage(PlayerMessages.SettingCleared.get()); + break; + case INVALID_MACHINE: + player.sendMessage(PlayerMessages.InvalidMachine.get()); + break; + case SETTINGS_LOADED: + player.sendMessage(PlayerMessages.LoadedSettings.get()); + break; + case SETTINGS_SAVED: + player.sendMessage(PlayerMessages.SavedSettings.get()); + break; + case SETTINGS_RESET: + player.sendMessage(PlayerMessages.ResetSettings.get()); + break; + default: + } + } - switch( msg ) - { - case SETTINGS_CLEARED: - player.sendMessage( PlayerMessages.SettingCleared.get() ); - break; - case INVALID_MACHINE: - player.sendMessage( PlayerMessages.InvalidMachine.get() ); - break; - case SETTINGS_LOADED: - player.sendMessage( PlayerMessages.LoadedSettings.get() ); - break; - case SETTINGS_SAVED: - player.sendMessage( PlayerMessages.SavedSettings.get() ); - break; - case SETTINGS_RESET: - player.sendMessage( PlayerMessages.ResetSettings.get() ); - break; - default: - } - } + @Override + public ActionResultType onItemUse(ItemUseContext context) { + if (context.getPlayer().isCrouching()) { + if (!context.getPlayer().world.isRemote) { + this.clearCard(context.getPlayer(), context.getWorld(), context.getHand()); + } + return ActionResultType.SUCCESS; + } else { + return super.onItemUse(context); + } + } - @Override - public ActionResultType onItemUse( ItemUseContext context ) - { - if( context.getPlayer().isCrouching() ) - { - if( !context.getPlayer().world.isRemote ) - { - this.clearCard( context.getPlayer(), context.getWorld(), context.getHand() ); - } - return ActionResultType.SUCCESS; - } - else - { - return super.onItemUse( context ); - } - } + @Override + public ActionResult onItemRightClick(World w, PlayerEntity player, Hand hand) { + if (player.isCrouching()) { + if (!w.isRemote) { + this.clearCard(player, w, hand); + } + } - @Override - public ActionResult onItemRightClick( World w, PlayerEntity player, Hand hand ) - { - if( player.isCrouching() ) - { - if( !w.isRemote ) - { - this.clearCard( player, w, hand ); - } - } + return super.onItemRightClick(w, player, hand); + } - return super.onItemRightClick( w, player, hand ); - } + @Override + public boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player) { + return true; + } - @Override - public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player ) - { - return true; - } - - private void clearCard( final PlayerEntity player, final World w, final Hand hand ) - { - final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem(); - mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); - player.getHeldItem( hand ).setTag( null ); - } + private void clearCard(final PlayerEntity player, final World w, final Hand hand) { + final IMemoryCard mem = (IMemoryCard) player.getHeldItem(hand).getItem(); + mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED); + player.getHeldItem(hand).setTag(null); + } } diff --git a/src/main/java/appeng/items/tools/ToolNetworkTool.java b/src/main/java/appeng/items/tools/ToolNetworkTool.java index bfd6e017d..3139352d7 100644 --- a/src/main/java/appeng/items/tools/ToolNetworkTool.java +++ b/src/main/java/appeng/items/tools/ToolNetworkTool.java @@ -18,11 +18,6 @@ package appeng.items.tools; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerNetworkStatus; -import appeng.container.implementations.ContainerNetworkTool; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -50,149 +45,126 @@ import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.api.util.INetworkToolAgent; import appeng.container.AEBaseContainer; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerNetworkStatus; +import appeng.container.implementations.ContainerNetworkTool; import appeng.core.AppEng; - import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketClick; import appeng.items.AEBaseItem; import appeng.items.contents.NetworkToolViewer; import appeng.util.Platform; +public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench { -public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench -{ + public ToolNetworkTool(Properties properties) { + super(properties); + } - public ToolNetworkTool(Properties properties) { - super(properties); - } + @Override + public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world, + final BlockPos pos) { + if (pos == null) { + return new NetworkToolViewer(is, null); + } + final TileEntity te = world.getTileEntity(pos); + return new NetworkToolViewer(is, (IGridHost) (te instanceof IGridHost ? te : null)); + } - @Override - public IGuiItemObject getGuiObject( final ItemStack is, int playerInventorySlot, final World world, final BlockPos pos ) - { - if (pos == null) { - return new NetworkToolViewer( is, null ); - } - final TileEntity te = world.getTileEntity( pos ); - return new NetworkToolViewer( is, (IGridHost) ( te instanceof IGridHost ? te : null ) ); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + if (Platform.isClient()) { + final RayTraceResult mop = AppEng.proxy.getRTR(); - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity p, final Hand hand ) - { - if( Platform.isClient() ) - { - final RayTraceResult mop = AppEng.proxy.getRTR(); + if (mop == null || mop.getType() == RayTraceResult.Type.MISS) { + NetworkHandler.instance().sendToServer(new PacketClick(hand)); + } + } - if( mop == null || mop.getType() == RayTraceResult.Type.MISS ) - { - NetworkHandler.instance().sendToServer( new PacketClick( hand ) ); - } - } + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + final BlockRayTraceResult mop = new BlockRayTraceResult(context.getHitVec(), context.getFace(), + context.getPos(), context.isInside()); + final TileEntity te = context.getWorld().getTileEntity(context.getPos()); - @Override - public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context ) - { - final BlockRayTraceResult mop = new BlockRayTraceResult( context.getHitVec(), context.getFace(), context.getPos(), context.isInside() ); - final TileEntity te = context.getWorld().getTileEntity( context.getPos() ); + if (te instanceof IPartHost) { + final SelectedPart part = ((IPartHost) te).selectPart(mop.getHitVec()); - if( te instanceof IPartHost ) - { - final SelectedPart part = ( (IPartHost) te ).selectPart( mop.getHitVec() ); + if (part.part != null || part.facade != null) { + if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) { + return ActionResultType.FAIL; + } else if (context.getPlayer().isCrouching()) { + return ActionResultType.PASS; + } + } + } else if (te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo(mop)) { + return ActionResultType.FAIL; + } - if( part.part != null || part.facade != null ) - { - if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) ) - { - return ActionResultType.FAIL; - } - else if( context.getPlayer().isCrouching() ) - { - return ActionResultType.PASS; - } - } - } - else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) ) - { - return ActionResultType.FAIL; - } + if (Platform.isClient()) { + NetworkHandler.instance().sendToServer(new PacketClick(context)); + } - if( Platform.isClient() ) - { - NetworkHandler.instance().sendToServer( new PacketClick( context ) ); - } + return ActionResultType.SUCCESS; + } - return ActionResultType.SUCCESS; - } + @Override + public boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player) { + return true; + } - @Override - public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player ) - { - return true; - } + public boolean serverSideToolLogic(ItemUseContext useContext) { + BlockPos pos = useContext.getPos(); + PlayerEntity p = useContext.getPlayer(); + World w = p.world; + Hand hand = useContext.getHand(); + Direction side = useContext.getFace(); - public boolean serverSideToolLogic( ItemUseContext useContext ) - { - BlockPos pos = useContext.getPos(); - PlayerEntity p = useContext.getPlayer(); - World w = p.world; - Hand hand = useContext.getHand(); - Direction side = useContext.getFace(); + if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) { + return false; + } - if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) ) - { - return false; - } + final BlockState bs = w.getBlockState(pos); + if (!p.isCrouching()) { + final TileEntity te = w.getTileEntity(pos); + if (!(te instanceof IGridHost)) { + if (bs.rotate(w, pos, Rotation.CLOCKWISE_90) != bs) { + bs.neighborChanged(w, pos, Platform.AIR_BLOCK, pos, false); + p.swingArm(hand); + return !w.isRemote; + } + } + } - final BlockState bs = w.getBlockState( pos ); - if( !p.isCrouching() ) - { - final TileEntity te = w.getTileEntity( pos ); - if( !( te instanceof IGridHost ) ) - { - if( bs.rotate( w, pos, Rotation.CLOCKWISE_90 ) != bs ) - { - bs.neighborChanged( w, pos, Platform.AIR_BLOCK, pos, false ); - p.swingArm( hand ); - return !w.isRemote; - } - } - } + if (!p.isCrouching()) { + if (p.openContainer instanceof AEBaseContainer) { + return true; + } - if( !p.isCrouching() ) - { - if( p.openContainer instanceof AEBaseContainer ) - { - return true; - } + final TileEntity te = w.getTileEntity(pos); - final TileEntity te = w.getTileEntity( pos ); + if (te instanceof IGridHost) { + ContainerOpener.openContainer(ContainerNetworkStatus.TYPE, p, + ContainerLocator.forItemUseContext(useContext)); + } else { + ContainerOpener.openContainer(ContainerNetworkTool.TYPE, p, ContainerLocator.forHand(p, hand)); + } - if( te instanceof IGridHost ) - { - ContainerOpener.openContainer(ContainerNetworkStatus.TYPE, p, ContainerLocator.forItemUseContext(useContext)); - } - else - { - ContainerOpener.openContainer(ContainerNetworkTool.TYPE, p, ContainerLocator.forHand(p, hand)); - } + return true; + } else { + BlockRayTraceResult rtr = new BlockRayTraceResult(useContext.getHitVec(), side, pos, false); + bs.onBlockActivated(w, p, hand, rtr); + } - return true; - } - else - { - BlockRayTraceResult rtr = new BlockRayTraceResult(useContext.getHitVec(), side, pos, false); - bs.onBlockActivated( w, p, hand, rtr ); - } + return false; + } - return false; - } - - @Override - public boolean canWrench( final ItemStack wrench, final PlayerEntity player, final BlockPos pos ) - { - return true; - } + @Override + public boolean canWrench(final ItemStack wrench, final PlayerEntity player, final BlockPos pos) { + return true; + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java b/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java index 77f107d57..70eabee55 100644 --- a/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java +++ b/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java @@ -18,7 +18,6 @@ package appeng.items.tools.powered; - import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -32,36 +31,30 @@ import appeng.core.sync.packets.PacketLightning; import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.util.Platform; +public class ToolChargedStaff extends AEBasePoweredItem { -public class ToolChargedStaff extends AEBasePoweredItem -{ + public ToolChargedStaff(Item.Properties props) { + super(AEConfig.instance().getChargedStaffBattery(), props); + } - public ToolChargedStaff(Item.Properties props) - { - super( AEConfig.instance().getChargedStaffBattery(), props ); - } + @Override + public boolean hitEntity(final ItemStack item, final LivingEntity target, final LivingEntity hitter) { + if (this.getAECurrentPower(item) > 300) { + this.extractAEPower(item, 300, Actionable.MODULATE); + if (Platform.isServer()) { + for (int x = 0; x < 2; x++) { + final AxisAlignedBB entityBoundingBox = target.getBoundingBox(); + final float dx = (float) (Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minX); + final float dy = (float) (Platform.getRandomFloat() * target.getHeight() + entityBoundingBox.minY); + final float dz = (float) (Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minZ); + AppEng.proxy.sendToAllNearExcept(null, dx, dy, dz, 32.0, target.world, + new PacketLightning(dx, dy, dz)); + } + } + target.attackEntityFrom(DamageSource.MAGIC, 6); + return true; + } - @Override - public boolean hitEntity( final ItemStack item, final LivingEntity target, final LivingEntity hitter ) - { - if( this.getAECurrentPower( item ) > 300 ) - { - this.extractAEPower( item, 300, Actionable.MODULATE ); - if( Platform.isServer() ) - { - for( int x = 0; x < 2; x++ ) - { - final AxisAlignedBB entityBoundingBox = target.getBoundingBox(); - final float dx = (float) ( Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minX ); - final float dy = (float) ( Platform.getRandomFloat() * target.getHeight() + entityBoundingBox.minY ); - final float dz = (float) ( Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minZ ); - AppEng.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.world, new PacketLightning( dx, dy, dz ) ); - } - } - target.attackEntityFrom( DamageSource.MAGIC, 6 ); - return true; - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java index f764b5cfc..0e443f780 100644 --- a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java +++ b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java @@ -18,6 +18,30 @@ package appeng.items.tools.powered; +import java.util.*; + +import org.apache.commons.lang3.text.WordUtils; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.SnowballItem; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.items.IItemHandler; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -48,311 +72,239 @@ import appeng.me.helpers.BaseActionSource; import appeng.tile.misc.TilePaint; import appeng.util.Platform; import appeng.util.item.AEItemStack; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SnowballItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.items.IItemHandler; -import org.apache.commons.lang3.text.WordUtils; -import java.util.*; +public class ToolColorApplicator extends AEBasePoweredItem + implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem { + private static final Map ORE_TO_COLOR = new HashMap<>(); -public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem -{ + private static final String TAG_COLOR = "color"; - private static final Map ORE_TO_COLOR = new HashMap<>(); + static { + for (final AEColor color : AEColor.VALID_COLORS) { + final String dyeName = color.dye.getTranslationKey(); + final String oreDictName = "dye" + WordUtils.capitalize(dyeName); + // FIXME final int oreDictId = OreDictionary.getOreID( oreDictName ); - private static final String TAG_COLOR = "color"; + // FIXME ORE_TO_COLOR.put( oreDictId, color ); + } + } - static - { - for( final AEColor color : AEColor.VALID_COLORS ) - { - final String dyeName = color.dye.getTranslationKey(); - final String oreDictName = "dye" + WordUtils.capitalize( dyeName ); - // FIXME final int oreDictId = OreDictionary.getOreID( oreDictName ); + public ToolColorApplicator(Item.Properties props) { + super(AEConfig.instance().getColorApplicatorBattery(), props); + addPropertyOverride(new ResourceLocation(AppEng.MOD_ID, "colored"), (itemStack, world, entity) -> { + // If the stack has no color, don't use the colored model since the impact of + // calling getColor + // for every quad is extremely high, if the stack tries to re-search its + // inventory for a new + // paintball everytime + AEColor col = getActiveColor(itemStack); + return (col != null) ? 1 : 0; + }); + } - // FIXME ORE_TO_COLOR.put( oreDictId, color ); - } - } + @Override + public ActionResultType onItemUse(PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, + float hitY, float hitZ) { + return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ); + } - public ToolColorApplicator(Item.Properties props) - { - super( AEConfig.instance().getColorApplicatorBattery(), props ); - addPropertyOverride( - new ResourceLocation(AppEng.MOD_ID, "colored"), - (itemStack, world, entity) -> { - // If the stack has no color, don't use the colored model since the impact of calling getColor - // for every quad is extremely high, if the stack tries to re-search its inventory for a new - // paintball everytime - AEColor col = getActiveColor( itemStack ); - return ( col != null ) ? 1 : 0; - } - ); - } + @Override + public ActionResultType onItemUse(ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, + float hitX, float hitY, float hitZ) { + final Block blk = w.getBlockState(pos).getBlock(); - @Override - public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) - { - return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ ); - } + ItemStack paintBall = this.getColor(is); - @Override - public ActionResultType onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) - { - final Block blk = w.getBlockState( pos ).getBlock(); + final IMEInventory inv = AEApi.instance().registries().cell().getCellInventory(is, null, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + if (inv != null) { + final IAEItemStack option = inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.SIMULATE, + new BaseActionSource()); - ItemStack paintBall = this.getColor( is ); + if (option != null) { + paintBall = option.createItemStack(); + paintBall.setCount(1); + } else { + paintBall = ItemStack.EMPTY; + } - final IMEInventory inv = AEApi.instance() - .registries() - .cell() - .getCellInventory( is, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - if( inv != null ) - { - final IAEItemStack option = inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.SIMULATE, new BaseActionSource() ); + if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) { + return ActionResultType.FAIL; + } - if( option != null ) - { - paintBall = option.createItemStack(); - paintBall.setCount( 1 ); - } - else - { - paintBall = ItemStack.EMPTY; - } + final double powerPerUse = 100; + if (!paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem) { + final TileEntity te = w.getTileEntity(pos); + // clean cables. + if (te instanceof IColorableTile) { + if (this.getAECurrentPower(is) > powerPerUse + && ((IColorableTile) te).getColor() != AEColor.TRANSPARENT) { + if (((IColorableTile) te).recolourBlock(side, AEColor.TRANSPARENT, p)) { + inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, + new BaseActionSource()); + this.extractAEPower(is, powerPerUse, Actionable.MODULATE); + return ActionResultType.SUCCESS; + } + } + } - if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) ) - { - return ActionResultType.FAIL; - } + // clean paint balls.. + final Block testBlk = w.getBlockState(pos.offset(side)).getBlock(); + final TileEntity painted = w.getTileEntity(pos.offset(side)); + if (this.getAECurrentPower(is) > powerPerUse && testBlk instanceof BlockPaint + && painted instanceof TilePaint) { + inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource()); + this.extractAEPower(is, powerPerUse, Actionable.MODULATE); + ((TilePaint) painted).cleanSide(side.getOpposite()); + return ActionResultType.SUCCESS; + } + } else if (!paintBall.isEmpty()) { + final AEColor color = this.getColorFromItem(paintBall); - final double powerPerUse = 100; - if( !paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem ) - { - final TileEntity te = w.getTileEntity( pos ); - // clean cables. - if( te instanceof IColorableTile ) - { - if( this.getAECurrentPower( is ) > powerPerUse && ( (IColorableTile) te ).getColor() != AEColor.TRANSPARENT ) - { - if( ( (IColorableTile) te ).recolourBlock( side, AEColor.TRANSPARENT, p ) ) - { - inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); - this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); - return ActionResultType.SUCCESS; - } - } - } + if (color != null && this.getAECurrentPower(is) > powerPerUse) { + if (color != AEColor.TRANSPARENT && this.recolourBlock(blk, side, w, pos, side, color, p)) { + inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, + new BaseActionSource()); + this.extractAEPower(is, powerPerUse, Actionable.MODULATE); + return ActionResultType.SUCCESS; + } + } + } + } - // clean paint balls.. - final Block testBlk = w.getBlockState( pos.offset( side ) ).getBlock(); - final TileEntity painted = w.getTileEntity( pos.offset( side ) ); - if( this.getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint ) - { - inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); - this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); - ( (TilePaint) painted ).cleanSide( side.getOpposite() ); - return ActionResultType.SUCCESS; - } - } - else if( !paintBall.isEmpty() ) - { - final AEColor color = this.getColorFromItem( paintBall ); + if (p.isCrouching()) { + this.cycleColors(is, paintBall, 1); + } - if( color != null && this.getAECurrentPower( is ) > powerPerUse ) - { - if( color != AEColor.TRANSPARENT && this.recolourBlock( blk, side, w, pos, side, color, p ) ) - { - inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); - this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); - return ActionResultType.SUCCESS; - } - } - } - } + return ActionResultType.FAIL; + } - if( p.isCrouching() ) - { - this.cycleColors( is, paintBall, 1 ); - } + @Override + public ITextComponent getDisplayName(final ItemStack is) { + ITextComponent extra = GuiText.Empty.textComponent(); - return ActionResultType.FAIL; - } + final AEColor selected = this.getActiveColor(is); - @Override - public ITextComponent getDisplayName( final ItemStack is ) - { - ITextComponent extra = GuiText.Empty.textComponent(); + if (selected != null && Platform.isClient()) { + extra = new TranslationTextComponent(selected.translationKey); + } - final AEColor selected = this.getActiveColor( is ); + return super.getDisplayName(is).appendText(" - ").appendSibling(extra); + } - if( selected != null && Platform.isClient() ) - { - extra = new TranslationTextComponent(selected.translationKey); - } + public AEColor getActiveColor(final ItemStack tol) { + return this.getColorFromItem(this.getColor(tol)); + } - return super.getDisplayName( is ).appendText(" - ").appendSibling( extra ); - } + private AEColor getColorFromItem(final ItemStack paintBall) { + if (paintBall.isEmpty()) { + return null; + } - public AEColor getActiveColor( final ItemStack tol ) - { - return this.getColorFromItem( this.getColor( tol ) ); - } + if (paintBall.getItem() instanceof SnowballItem) { + return AEColor.TRANSPARENT; + } - private AEColor getColorFromItem( final ItemStack paintBall ) - { - if( paintBall.isEmpty() ) - { - return null; - } - - if( paintBall.getItem() instanceof SnowballItem ) - { - return AEColor.TRANSPARENT; - } - - if( paintBall.getItem() instanceof ItemPaintBall ) - { - final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem(); - return ipb.getColor(); - } - else - { - // FIXME final int[] id = OreDictionary.getOreIDs( paintBall ); + if (paintBall.getItem() instanceof ItemPaintBall) { + final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem(); + return ipb.getColor(); + } else { + // FIXME final int[] id = OreDictionary.getOreIDs( paintBall ); // FIXME - // FIXME for( final int oreID : id ) - // FIXME { - // FIXME if( ORE_TO_COLOR.containsKey( oreID ) ) - // FIXME { - // FIXME return ORE_TO_COLOR.get( oreID ); - // FIXME } - // FIXME } - } + // FIXME for( final int oreID : id ) + // FIXME { + // FIXME if( ORE_TO_COLOR.containsKey( oreID ) ) + // FIXME { + // FIXME return ORE_TO_COLOR.get( oreID ); + // FIXME } + // FIXME } + } - return null; - } + return null; + } - public ItemStack getColor( final ItemStack is ) - { - final CompoundNBT c = is.getTag(); - if( c != null && c.contains(TAG_COLOR) ) - { - final CompoundNBT color = c.getCompound( TAG_COLOR ); - final ItemStack oldColor = ItemStack.read(color); - if( !oldColor.isEmpty() ) - { - return oldColor; - } - } + public ItemStack getColor(final ItemStack is) { + final CompoundNBT c = is.getTag(); + if (c != null && c.contains(TAG_COLOR)) { + final CompoundNBT color = c.getCompound(TAG_COLOR); + final ItemStack oldColor = ItemStack.read(color); + if (!oldColor.isEmpty()) { + return oldColor; + } + } - return this.findNextColor( is, ItemStack.EMPTY, 0 ); - } + return this.findNextColor(is, ItemStack.EMPTY, 0); + } - private ItemStack findNextColor( final ItemStack is, final ItemStack anchor, final int scrollOffset ) - { - ItemStack newColor = ItemStack.EMPTY; + private ItemStack findNextColor(final ItemStack is, final ItemStack anchor, final int scrollOffset) { + ItemStack newColor = ItemStack.EMPTY; - final IMEInventory inv = AEApi.instance() - .registries() - .cell() - .getCellInventory( is, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - if( inv != null ) - { - final IItemList itemList = inv - .getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - if( anchor.isEmpty() ) - { - final IAEItemStack firstItem = itemList.getFirstItem(); - if( firstItem != null ) - { - newColor = firstItem.asItemStackRepresentation(); - } - } - else - { - final LinkedList list = new LinkedList<>(); + final IMEInventory inv = AEApi.instance().registries().cell().getCellInventory(is, null, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + if (inv != null) { + final IItemList itemList = inv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + if (anchor.isEmpty()) { + final IAEItemStack firstItem = itemList.getFirstItem(); + if (firstItem != null) { + newColor = firstItem.asItemStackRepresentation(); + } + } else { + final LinkedList list = new LinkedList<>(); - for( final IAEItemStack i : itemList ) - { - list.add( i ); - } + for (final IAEItemStack i : itemList) { + list.add(i); + } - Collections.sort( list, ( a, b ) -> Integer.compare( a.getItemDamage(), b.getItemDamage() ) ); + Collections.sort(list, (a, b) -> Integer.compare(a.getItemDamage(), b.getItemDamage())); - if( list.size() <= 0 ) - { - return ItemStack.EMPTY; - } + if (list.size() <= 0) { + return ItemStack.EMPTY; + } - IAEItemStack where = list.getFirst(); - int cycles = 1 + list.size(); + IAEItemStack where = list.getFirst(); + int cycles = 1 + list.size(); - while( cycles > 0 && !where.equals( anchor ) ) - { - list.addLast( list.removeFirst() ); - cycles--; - where = list.getFirst(); - } + while (cycles > 0 && !where.equals(anchor)) { + list.addLast(list.removeFirst()); + cycles--; + where = list.getFirst(); + } - if( scrollOffset > 0 ) - { - list.addLast( list.removeFirst() ); - } + if (scrollOffset > 0) { + list.addLast(list.removeFirst()); + } - if( scrollOffset < 0 ) - { - list.addFirst( list.removeLast() ); - } + if (scrollOffset < 0) { + list.addFirst(list.removeLast()); + } - return list.get( 0 ).asItemStackRepresentation(); - } - } + return list.get(0).asItemStackRepresentation(); + } + } - if( !newColor.isEmpty() ) - { - this.setColor( is, newColor ); - } + if (!newColor.isEmpty()) { + this.setColor(is, newColor); + } - return newColor; - } + return newColor; + } - private void setColor( final ItemStack is, final ItemStack newColor ) - { + private void setColor(final ItemStack is, final ItemStack newColor) { final CompoundNBT data = is.getOrCreateTag(); - if( newColor.isEmpty() ) - { - data.remove( TAG_COLOR ); - } - else - { - final CompoundNBT color = new CompoundNBT(); - newColor.write(color); - data.put( TAG_COLOR, color ); - } - } + if (newColor.isEmpty()) { + data.remove(TAG_COLOR); + } else { + final CompoundNBT color = new CompoundNBT(); + newColor.write(color); + data.put(TAG_COLOR, color); + } + } - private boolean recolourBlock( final Block blk, final Direction side, final World w, final BlockPos pos, final Direction orientation, final AEColor newColor, final PlayerEntity p ) - { - final BlockState state = w.getBlockState( pos ); + private boolean recolourBlock(final Block blk, final Direction side, final World w, final BlockPos pos, + final Direction orientation, final AEColor newColor, final PlayerEntity p) { + final BlockState state = w.getBlockState(pos); // FIXME if( blk instanceof BlockColored ) // FIXME { @@ -405,156 +357,129 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe // return w.setBlockState( pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().with( BlockColored.COLOR, newColor.dye ) ); // } - if( blk instanceof BlockCableBus ) - { - return ( (BlockCableBus) blk ).recolorBlock( w, pos, side, newColor.dye, p ); - } + if (blk instanceof BlockCableBus) { + return ((BlockCableBus) blk).recolorBlock(w, pos, side, newColor.dye, p); + } - return blk.recolorBlock( state, w, pos, side, newColor.dye ); - } + return blk.recolorBlock(state, w, pos, side, newColor.dye); + } - public void cycleColors( final ItemStack is, final ItemStack paintBall, final int i ) - { - if( paintBall.isEmpty() ) - { - this.setColor( is, this.getColor( is ) ); - } - else - { - this.setColor( is, this.findNextColor( is, paintBall, i ) ); - } - } + public void cycleColors(final ItemStack is, final ItemStack paintBall, final int i) { + if (paintBall.isEmpty()) { + this.setColor(is, this.getColor(is)); + } else { + this.setColor(is, this.findNextColor(is, paintBall, i)); + } + } - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - super.addInformation( stack, world, lines, advancedTooltips ); + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + super.addInformation(stack, world, lines, advancedTooltips); - final ICellInventoryHandler cdi = AEApi.instance() - .registries() - .cell() - .getCellInventory( stack, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + final ICellInventoryHandler cdi = AEApi.instance().registries().cell().getCellInventory(stack, + null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - AEApi.instance().client().addCellInformation( cdi, lines ); - } + AEApi.instance().client().addCellInformation(cdi, lines); + } - @Override - public int getBytes( final ItemStack cellItem ) - { - return 512; - } + @Override + public int getBytes(final ItemStack cellItem) { + return 512; + } - @Override - public int getBytesPerType( final ItemStack cellItem ) - { - return 8; - } + @Override + public int getBytesPerType(final ItemStack cellItem) { + return 8; + } - @Override - public int getTotalTypes( final ItemStack cellItem ) - { - return 27; - } + @Override + public int getTotalTypes(final ItemStack cellItem) { + return 27; + } - @Override - public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition ) - { - if( requestedAddition != null ) - { - // FIXME final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() ); + @Override + public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) { + if (requestedAddition != null) { + // FIXME final int[] id = OreDictionary.getOreIDs( + // requestedAddition.getDefinition() ); - // FIXME for( final int x : id ) - // FIXME { - // FIXME if( ORE_TO_COLOR.containsKey( x ) ) - // FIXME { - // FIXME return false; - // FIXME } - // FIXME } + // FIXME for( final int x : id ) + // FIXME { + // FIXME if( ORE_TO_COLOR.containsKey( x ) ) + // FIXME { + // FIXME return false; + // FIXME } + // FIXME } - if( requestedAddition.getItem() instanceof SnowballItem ) - { - return false; - } + if (requestedAddition.getItem() instanceof SnowballItem) { + return false; + } - return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 ); - } - return true; - } + return !(requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20); + } + return true; + } - @Override - public boolean storableInStorageCell() - { - return true; - } + @Override + public boolean storableInStorageCell() { + return true; + } - @Override - public boolean isStorageCell( final ItemStack i ) - { - return true; - } + @Override + public boolean isStorageCell(final ItemStack i) { + return true; + } - @Override - public double getIdleDrain() - { - return 0.5; - } + @Override + public double getIdleDrain() { + return 0.5; + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public String getUnlocalizedGroupName( final Set others, final ItemStack is ) - { - return GuiText.StorageCells.getTranslationKey(); - } + @Override + public String getUnlocalizedGroupName(final Set others, final ItemStack is) { + return GuiText.StorageCells.getTranslationKey(); + } - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } + @Override + public boolean isEditable(final ItemStack is) { + return true; + } - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return new CellUpgrades( is, 2 ); - } + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 2); + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - final String fz = is.getOrCreateTag().getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { - return FuzzyMode.IGNORE_ALL; - } - } + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = is.getOrCreateTag().getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { + return FuzzyMode.IGNORE_ALL; + } + } - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { is.getOrCreateTag().putString("FuzzyMode", fzMode.name()); - } + } - @Override - public void onWheel( final ItemStack is, final boolean up ) - { - this.cycleColors( is, this.getColor( is ), up ? 1 : -1 ); - } + @Override + public void onWheel(final ItemStack is, final boolean up) { + this.cycleColors(is, this.getColor(is), up ? 1 : -1); + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolColorApplicatorRendering.java b/src/main/java/appeng/items/tools/powered/ToolColorApplicatorRendering.java index 4af276578..41778fd78 100644 --- a/src/main/java/appeng/items/tools/powered/ToolColorApplicatorRendering.java +++ b/src/main/java/appeng/items/tools/powered/ToolColorApplicatorRendering.java @@ -1,6 +1,5 @@ package appeng.items.tools.powered; - import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -12,56 +11,52 @@ import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; import appeng.core.AppEng; +public class ToolColorApplicatorRendering extends ItemRenderingCustomizer { -public class ToolColorApplicatorRendering extends ItemRenderingCustomizer -{ + private static final ModelResourceLocation MODEL_COLORED = new ModelResourceLocation( + new ResourceLocation(AppEng.MOD_ID, "builtin/color_applicator_colored"), "inventory"); + private static final ModelResourceLocation MODEL_UNCOLORED = new ModelResourceLocation( + new ResourceLocation(AppEng.MOD_ID, "color_applicator_uncolored"), "inventory"); - private static final ModelResourceLocation MODEL_COLORED = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, "builtin/color_applicator_colored" ), "inventory" ); - private static final ModelResourceLocation MODEL_UNCOLORED = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, "color_applicator_uncolored" ), "inventory" ); + @Override + @OnlyIn(Dist.CLIENT) + public void customize(IItemRendering rendering) { + // FIXME rendering.builtInModel( "models/item/builtin/color_applicator_colored", + // new ColorApplicatorModel() ); + rendering.variants(MODEL_COLORED, MODEL_UNCOLORED); + rendering.color(this::getColor); + // FIXME rendering.meshDefinition( this::getMesh ); + } - @Override - @OnlyIn( Dist.CLIENT ) - public void customize( IItemRendering rendering ) - { - // FIXME rendering.builtInModel( "models/item/builtin/color_applicator_colored", new ColorApplicatorModel() ); - rendering.variants( MODEL_COLORED, MODEL_UNCOLORED ); - rendering.color( this::getColor ); - // FIXME rendering.meshDefinition( this::getMesh ); - } + private ModelResourceLocation getMesh(ItemStack itemStack) { + // If the stack has no color, don't use the colored model since the impact of + // calling getColor for every quad is + // extremely high, + // if the stack tries to re-search its inventory for a new paintball everytime + AEColor col = ((ToolColorApplicator) itemStack.getItem()).getActiveColor(itemStack); + return (col != null) ? MODEL_COLORED : MODEL_UNCOLORED; + } - private ModelResourceLocation getMesh( ItemStack itemStack ) - { - // If the stack has no color, don't use the colored model since the impact of calling getColor for every quad is - // extremely high, - // if the stack tries to re-search its inventory for a new paintball everytime - AEColor col = ( (ToolColorApplicator) itemStack.getItem() ).getActiveColor( itemStack ); - return ( col != null ) ? MODEL_COLORED : MODEL_UNCOLORED; - } + private int getColor(ItemStack itemStack, int idx) { + if (idx == 0) { + return -1; + } - private int getColor( ItemStack itemStack, int idx ) - { - if( idx == 0 ) - { - return -1; - } + final AEColor col = ((ToolColorApplicator) itemStack.getItem()).getActiveColor(itemStack); - final AEColor col = ( (ToolColorApplicator) itemStack.getItem() ).getActiveColor( itemStack ); + if (col == null) { + return -1; + } - if( col == null ) - { - return -1; - } - - switch( idx ) - { - case 1: - return col.blackVariant; - case 2: - return col.mediumVariant; - case 3: - return col.whiteVariant; - default: - return -1; - } - } + switch (idx) { + case 1: + return col.blackVariant; + case 2: + return col.mediumVariant; + case 3: + return col.whiteVariant; + default: + return -1; + } + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java index da853893a..b87248a35 100644 --- a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java +++ b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java @@ -18,7 +18,6 @@ package appeng.items.tools.powered; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -55,246 +54,206 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.util.InWorldToolOperationResult; import appeng.util.Platform; +public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool { + private final Map heatUp; + private final Map coolDown; -public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool -{ - private final Map heatUp; - private final Map coolDown; + public ToolEntropyManipulator(Item.Properties props) { + super(AEConfig.instance().getEntropyManipulatorBattery(), props); - public ToolEntropyManipulator(Item.Properties props) - { - super( AEConfig.instance().getEntropyManipulatorBattery(), props ); + this.heatUp = new HashMap<>(); + this.coolDown = new HashMap<>(); - this.heatUp = new HashMap<>(); - this.coolDown = new HashMap<>(); - - this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ), - new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) ); + this.coolDown.put(new InWorldToolOperationIngredient(Blocks.STONE.getDefaultState()), + new InWorldToolOperationResult(Blocks.COBBLESTONE.getDefaultState())); // FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE_BRICKS.getDefaultState() ), // FIXME new InWorldToolOperationResult( Blocks.STONE_BRICKS.getStateFromMeta( 2 ) ) ); - this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); + this.coolDown.put(new InWorldToolOperationIngredient(Blocks.LAVA, true), + new InWorldToolOperationResult(Blocks.OBSIDIAN.getDefaultState())); // FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ), // FIXME new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); - this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) ); + this.coolDown.put(new InWorldToolOperationIngredient(Blocks.GRASS, true), + new InWorldToolOperationResult(Blocks.DIRT.getDefaultState())); - final List snowBalls = new ArrayList<>(); - snowBalls.add( new ItemStack( Items.SNOWBALL ) ); + final List snowBalls = new ArrayList<>(); + snowBalls.add(new ItemStack(Items.SNOWBALL)); // FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) ); - this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) ); + this.coolDown.put(new InWorldToolOperationIngredient(Blocks.WATER, true), + new InWorldToolOperationResult(Blocks.ICE.getDefaultState())); - this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) ); + this.heatUp.put(new InWorldToolOperationIngredient(Blocks.ICE.getDefaultState()), + new InWorldToolOperationResult(Blocks.WATER.getDefaultState())); // FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() ); - this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() ); + this.heatUp.put(new InWorldToolOperationIngredient(Blocks.WATER, true), new InWorldToolOperationResult()); // FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ), // FIXME new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) ); - } + } - private static class InWorldToolOperationIngredient - { - private final BlockState state; - private final boolean blockOnly; + private static class InWorldToolOperationIngredient { + private final BlockState state; + private final boolean blockOnly; - public InWorldToolOperationIngredient( final BlockState state ) - { - this.state = state; - this.blockOnly = false; - } + public InWorldToolOperationIngredient(final BlockState state) { + this.state = state; + this.blockOnly = false; + } - public InWorldToolOperationIngredient( final Block blk, final boolean b ) - { - this.state = blk.getDefaultState(); - this.blockOnly = b; - } + public InWorldToolOperationIngredient(final Block blk, final boolean b) { + this.state = blk.getDefaultState(); + this.blockOnly = b; + } - @Override - public int hashCode() - { - return this.state.getBlock().hashCode(); - } + @Override + public int hashCode() { + return this.state.getBlock().hashCode(); + } - @Override - public boolean equals( final Object obj ) - { - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } - final InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj; - return this.state == other.state && ( this.blockOnly && this.state.getBlock() == other.state.getBlock() ); - } - } + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } + final InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj; + return this.state == other.state && (this.blockOnly && this.state.getBlock() == other.state.getBlock()); + } + } - private void heat( final BlockState state, final World w, final BlockPos pos ) - { - InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) ); + private void heat(final BlockState state, final World w, final BlockPos pos) { + InWorldToolOperationResult r = this.heatUp.get(new InWorldToolOperationIngredient(state)); - if( r == null ) - { - r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); - } + if (r == null) { + r = this.heatUp.get(new InWorldToolOperationIngredient(state.getBlock(), true)); + } - if( r.getBlockState() != null ) - { - w.setBlockState( pos, r.getBlockState(), 3 ); - } - else - { - w.removeBlock(pos, false); - } + if (r.getBlockState() != null) { + w.setBlockState(pos, r.getBlockState(), 3); + } else { + w.removeBlock(pos, false); + } - if( r.getDrops() != null ) - { - Platform.spawnDrops( w, pos, r.getDrops() ); - } - } + if (r.getDrops() != null) { + Platform.spawnDrops(w, pos, r.getDrops()); + } + } - private boolean canHeat( final BlockState state ) - { - InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) ); + private boolean canHeat(final BlockState state) { + InWorldToolOperationResult r = this.heatUp.get(new InWorldToolOperationIngredient(state)); - if( r == null ) - { - r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); - } + if (r == null) { + r = this.heatUp.get(new InWorldToolOperationIngredient(state.getBlock(), true)); + } - return r != null; - } + return r != null; + } - private void cool( final BlockState state, final World w, final BlockPos pos ) - { - InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) ); + private void cool(final BlockState state, final World w, final BlockPos pos) { + InWorldToolOperationResult r = this.coolDown.get(new InWorldToolOperationIngredient(state)); - if( r == null ) - { - r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); - } + if (r == null) { + r = this.coolDown.get(new InWorldToolOperationIngredient(state.getBlock(), true)); + } - if( r.getBlockState() != null ) - { - w.setBlockState( pos, r.getBlockState(), 3 ); - } - else - { - w.removeBlock(pos, false); - } + if (r.getBlockState() != null) { + w.setBlockState(pos, r.getBlockState(), 3); + } else { + w.removeBlock(pos, false); + } - if( r.getDrops() != null ) - { - Platform.spawnDrops( w, pos, r.getDrops() ); - } - } + if (r.getDrops() != null) { + Platform.spawnDrops(w, pos, r.getDrops()); + } + } - private boolean canCool( final BlockState state ) - { - InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) ); + private boolean canCool(final BlockState state) { + InWorldToolOperationResult r = this.coolDown.get(new InWorldToolOperationIngredient(state)); - if( r == null ) - { - r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); - } + if (r == null) { + r = this.coolDown.get(new InWorldToolOperationIngredient(state.getBlock(), true)); + } - return r != null; - } + return r != null; + } - @Override - public boolean hitEntity( final ItemStack item, final LivingEntity target, final LivingEntity hitter ) - { - if( this.getAECurrentPower( item ) > 1600 ) - { - this.extractAEPower( item, 1600, Actionable.MODULATE ); - target.setFire( 8 ); - } + @Override + public boolean hitEntity(final ItemStack item, final LivingEntity target, final LivingEntity hitter) { + if (this.getAECurrentPower(item) > 1600) { + this.extractAEPower(item, 1600, Actionable.MODULATE); + target.setFire(8); + } - return false; - } + return false; + } - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity p, final Hand hand ) - { - final RayTraceResult target = this.rayTrace( w, p, RayTraceContext.FluidMode.ANY ); + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + final RayTraceResult target = this.rayTrace(w, p, RayTraceContext.FluidMode.ANY); - if( target.getType() != RayTraceResult.Type.BLOCK ) - { - return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) ); - } - else - { - BlockPos pos = ((BlockRayTraceResult) target).getPos(); - final BlockState state = w.getBlockState( pos ); - if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER ) - { - if( Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) ) - { - this.onItemUse( p, w, pos, hand, Direction.UP, 0.0F, 0.0F, 0.0F ); - } - } - } + if (target.getType() != RayTraceResult.Type.BLOCK) { + return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand)); + } else { + BlockPos pos = ((BlockRayTraceResult) target).getPos(); + final BlockState state = w.getBlockState(pos); + if (state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER) { + if (Platform.hasPermissions(new DimensionalCoord(w, pos), p)) { + this.onItemUse(p, w, pos, hand, Direction.UP, 0.0F, 0.0F, 0.0F); + } + } + } - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } - @Override - public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) - { - return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ ); - } + @Override + public ActionResultType onItemUse(PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, + float hitY, float hitZ) { + return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ); + } - @Override - public ActionResultType onItemUse( ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) - { - if( this.getAECurrentPower( item ) > 1600 ) - { - if( !p.canPlayerEdit( pos, side, item ) ) - { - return ActionResultType.FAIL; - } + @Override + public ActionResultType onItemUse(ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, + float hitX, float hitY, float hitZ) { + if (this.getAECurrentPower(item) > 1600) { + if (!p.canPlayerEdit(pos, side, item)) { + return ActionResultType.FAIL; + } - final BlockState state = w.getBlockState( pos ); - final Block blockID = state.getBlock(); + final BlockState state = w.getBlockState(pos); + final Block blockID = state.getBlock(); - if( p.isCrouching() ) - { - if( this.canCool( state ) ) - { - this.extractAEPower( item, 1600, Actionable.MODULATE ); - this.cool( state, w, pos ); - return ActionResultType.SUCCESS; - } - } - else - { - if( blockID instanceof TNTBlock) - { - w.removeBlock(pos, false); - ( (TNTBlock) blockID ).explode( w, pos ); - return ActionResultType.SUCCESS; - } + if (p.isCrouching()) { + if (this.canCool(state)) { + this.extractAEPower(item, 1600, Actionable.MODULATE); + this.cool(state, w, pos); + return ActionResultType.SUCCESS; + } + } else { + if (blockID instanceof TNTBlock) { + w.removeBlock(pos, false); + ((TNTBlock) blockID).explode(w, pos); + return ActionResultType.SUCCESS; + } - if( blockID instanceof BlockTinyTNT ) - { - w.removeBlock(pos, false); - ( (BlockTinyTNT) blockID ).startFuse( w, pos, p ); - return ActionResultType.SUCCESS; - } + if (blockID instanceof BlockTinyTNT) { + w.removeBlock(pos, false); + ((BlockTinyTNT) blockID).startFuse(w, pos, p); + return ActionResultType.SUCCESS; + } - if( this.canHeat( state ) ) - { - this.extractAEPower( item, 1600, Actionable.MODULATE ); - this.heat( state, w, pos ); - return ActionResultType.SUCCESS; - } + if (this.canHeat(state)) { + this.extractAEPower(item, 1600, Actionable.MODULATE); + this.heat(state, w, pos); + return ActionResultType.SUCCESS; + } - final ItemStack[] stack = Platform.getBlockDrops( w, pos ); - final List out = new ArrayList<>(); - boolean hasFurnaceable = false; - boolean canFurnaceable = true; + final ItemStack[] stack = Platform.getBlockDrops(w, pos); + final List out = new ArrayList<>(); + boolean hasFurnaceable = false; + boolean canFurnaceable = true; - for( final ItemStack i : stack ) - { + for (final ItemStack i : stack) { // FIXME final ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i ); // FIXME // FIXME if( !result.isEmpty() ) @@ -315,53 +274,47 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT // FIXME canFurnaceable = false; // FIXME out.add( i ); // FIXME } - } + } - if( hasFurnaceable && canFurnaceable ) - { - this.extractAEPower( item, 1600, Actionable.MODULATE ); - final InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) ); - w.playSound( p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F, - random.nextFloat() * 0.4F + 0.8F ); + if (hasFurnaceable && canFurnaceable) { + this.extractAEPower(item, 1600, Actionable.MODULATE); + final InWorldToolOperationResult or = InWorldToolOperationResult + .getBlockOperationResult(out.toArray(new ItemStack[out.size()])); + w.playSound(p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, + SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F, + random.nextFloat() * 0.4F + 0.8F); - if( or.getBlockState() == null ) - { - w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 ); - } - else - { - w.setBlockState( pos, or.getBlockState(), 3 ); - } + if (or.getBlockState() == null) { + w.setBlockState(pos, Platform.AIR_BLOCK.getDefaultState(), 3); + } else { + w.setBlockState(pos, or.getBlockState(), 3); + } - if( or.getDrops() != null ) - { - Platform.spawnDrops( w, pos, or.getDrops() ); - } + if (or.getDrops() != null) { + Platform.spawnDrops(w, pos, or.getDrops()); + } - return ActionResultType.SUCCESS; - } - else - { - final BlockPos offsetPos = pos.offset( side ); + return ActionResultType.SUCCESS; + } else { + final BlockPos offsetPos = pos.offset(side); - if( !p.canPlayerEdit( offsetPos, side, item ) ) - { - return ActionResultType.FAIL; - } + if (!p.canPlayerEdit(offsetPos, side, item)) { + return ActionResultType.FAIL; + } - if( w.isAirBlock( offsetPos ) ) - { - this.extractAEPower( item, 1600, Actionable.MODULATE ); - w.playSound( p, offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, - SoundCategory.PLAYERS, 1.0F, random.nextFloat() * 0.4F + 0.8F ); - w.setBlockState( offsetPos, Blocks.FIRE.getDefaultState() ); - } + if (w.isAirBlock(offsetPos)) { + this.extractAEPower(item, 1600, Actionable.MODULATE); + w.playSound(p, offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, + SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F, + random.nextFloat() * 0.4F + 0.8F); + w.setBlockState(offsetPos, Blocks.FIRE.getDefaultState()); + } - return ActionResultType.SUCCESS; - } - } - } + return ActionResultType.SUCCESS; + } + } + } - return ActionResultType.PASS; - } + return ActionResultType.PASS; + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolMatterCannon.java b/src/main/java/appeng/items/tools/powered/ToolMatterCannon.java index f7579acd6..299caf936 100644 --- a/src/main/java/appeng/items/tools/powered/ToolMatterCannon.java +++ b/src/main/java/appeng/items/tools/powered/ToolMatterCannon.java @@ -18,8 +18,8 @@ package appeng.items.tools.powered; - import java.util.List; + import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -44,6 +44,7 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; import appeng.api.config.Upgrades; +import appeng.api.features.AEFeature; import appeng.api.implementations.items.IStorageCell; import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.IStorageChannel; @@ -55,7 +56,6 @@ import appeng.api.util.DimensionalCoord; import appeng.core.AEConfig; import appeng.core.AELog; import appeng.core.AppEng; -import appeng.api.features.AEFeature; import appeng.core.localization.PlayerMessages; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMatterCannon; @@ -70,455 +70,389 @@ import appeng.tile.misc.TilePaint; import appeng.util.LookDirection; import appeng.util.Platform; - -public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell -{ - - public ToolMatterCannon(Item.Properties props) - { - super( AEConfig.instance().getMatterCannonBattery(), props ); - } - - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - super.addInformation( stack, world, lines, advancedTooltips ); - - final ICellInventoryHandler cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - - AEApi.instance().client().addCellInformation( cdi, lines ); - } - - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity p, final @Nullable Hand hand ) - { - if( this.getAECurrentPower( p.getHeldItem( hand ) ) > 1600 ) - { - int shots = 1; - - final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory( p.getHeldItem( hand ) ); - if( cu != null ) - { - shots += cu.getInstalledUpgrades( Upgrades.SPEED ); - } - - final ICellInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( p.getHeldItem( hand ), null, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - if( inv != null ) - { - final IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - IAEItemStack req = itemList.getFirstItem(); - if( req instanceof IAEItemStack ) - { - shots = Math.min( shots, (int) req.getStackSize() ); - for( int sh = 0; sh < shots; sh++ ) - { - IAEItemStack aeAmmo = req.copy(); - this.extractAEPower( p.getHeldItem( hand ), 1600, Actionable.MODULATE ); - - if( Platform.isClient() ) - { - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } - - aeAmmo.setStackSize( 1 ); - final ItemStack ammo = aeAmmo.createItemStack(); - if( ammo == null ) - { - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } - - aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) ); - if( aeAmmo == null ) - { - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } - - final LookDirection dir = Platform.getPlayerRay( p ); - - final Vec3d Vec3d = dir.getA(); - final Vec3d Vec3d1 = dir.getB(); - final Vec3d direction = Vec3d1.subtract( Vec3d ); - direction.normalize(); - - final double d0 = Vec3d.x; - final double d1 = Vec3d.y; - final double d2 = Vec3d.z; - - final float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f; - if( penetration <= 0 ) - { - final ItemStack type = aeAmmo.asItemStackRepresentation(); - if( type.getItem() instanceof ItemPaintBall ) - { - this.shootPaintBalls( type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 ); - } - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } - else - { - this.standardAmmo( penetration, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 ); - } - } - } - else - { - if( Platform.isServer() ) - { - p.sendMessage( PlayerMessages.AmmoDepleted.get() ); - } - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } - } - } - return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) ); - } - - private void shootPaintBalls( final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 ) - { - final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 ); - - Entity entity = null; - Vec3d entityIntersection = null; - final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb ); - double closest = 9999999.0D; - - for( int l = 0; l < list.size(); ++l ) - { - final Entity entity1 = (Entity) list.get( l ); - - if( !entity1.isAlive() && entity1 != p && !( entity1 instanceof ItemEntity ) ) - { - if( entity1.isAlive() ) - { - // prevent killing / flying of mounts. - if( entity1.isRidingOrBeingRiddenBy( p ) ) - { - continue; - } - - final float f1 = 0.3F; - - final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 ); - final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null); - - if( intersection != null ) - { - final double nd = Vec3d.squareDistanceTo( intersection ); - - if( nd < closest ) - { - entity = entity1; - entityIntersection = intersection; - closest = nd; - } - } - } - } - } - - RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p); - RayTraceResult pos = w.rayTraceBlocks( rayTraceContext ); - - final Vec3d vec = new Vec3d( d0, d1, d2 ); - if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest ) - { - pos = new EntityRayTraceResult( entity, entityIntersection ); - } - else if( entity != null && pos.getType() == RayTraceResult.Type.MISS ) - { - pos = new EntityRayTraceResult( entity, entityIntersection ); - } - - try - { - AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) ); - } - catch( final Exception err ) - { - AELog.debug( err ); - } - - if( pos.getType() != RayTraceResult.Type.MISS && type != null && type.getItem() instanceof ItemPaintBall ) - { - final ItemPaintBall ipb = (ItemPaintBall) type.getItem(); - - final AEColor col = ipb.getColor(); - // boolean lit = ipb.isLumen( type ); - - if( pos instanceof EntityRayTraceResult ) - { - EntityRayTraceResult entityResult = (EntityRayTraceResult) pos; - Entity entityHit = entityResult.getEntity(); - - final int id = entityHit.getEntityId(); - final PlayerColor marker = new PlayerColor( id, col, 20 * 30 ); - TickHandler.INSTANCE.getPlayerColors().put( id, marker ); - - if( entityHit instanceof SheepEntity) - { - final SheepEntity sh = (SheepEntity) entityHit; - sh.setFleeceColor( col.dye ); - } - - entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 ); - NetworkHandler.instance().sendToAll( marker.getPacket() ); - } - else if( pos instanceof BlockRayTraceResult ) - { - BlockRayTraceResult blockResult = (BlockRayTraceResult) pos; - final Direction side = blockResult.getFace(); - final BlockPos hitPos = blockResult.getPos().offset( side ); - - if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) ) - { - return; - } - - final BlockState whatsThere = w.getBlockState( hitPos ); - if( whatsThere.getMaterial().isReplaceable() && w.isAirBlock( hitPos ) ) - { - AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent( paintBlock -> { - w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 ); - } ); - } - - final TileEntity te = w.getTileEntity( hitPos ); - if( te instanceof TilePaint ) - { - final Vec3d hp = pos.getHitVec().subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() ); - ( (TilePaint) te ).addBlot( type, side.getOpposite(), hp ); - } - } - } - } - - private void standardAmmo( float penetration, final World w, final PlayerEntity p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 ) - { - boolean hasDestroyed = true; - while( penetration > 0 && hasDestroyed ) - { - hasDestroyed = false; - - final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 ); - - Entity entity = null; - Vec3d entityIntersection = null; - final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb ); - double closest = 9999999.0D; - - for( int l = 0; l < list.size(); ++l ) - { - final Entity entity1 = (Entity) list.get( l ); - - if( entity1.isAlive() && entity1 != p && !( entity1 instanceof ItemEntity ) ) - { - if( entity1.isAlive() ) - { - // prevent killing / flying of mounts. - if( entity1.isRidingOrBeingRiddenBy( p ) ) - { - continue; - } - - final float f1 = 0.3F; - - final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 ); - final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null); - - if( intersection != null ) - { - final double nd = Vec3d.squareDistanceTo( intersection ); - - if( nd < closest ) - { - entity = entity1; - entityIntersection = intersection; - closest = nd; - } - } - } - } - } - - RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p); - final Vec3d vec = new Vec3d( d0, d1, d2 ); - RayTraceResult pos = w.rayTraceBlocks( rayTraceContext ); - if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest ) - { - pos = new EntityRayTraceResult( entity, entityIntersection ); - } - else if( entity != null && pos.getType() == RayTraceResult.Type.MISS ) - { - pos = new EntityRayTraceResult( entity, entityIntersection ); - } - - try - { - AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) ); - } - catch( final Exception err ) - { - AELog.debug( err ); - } - - if( pos.getType() != RayTraceResult.Type.MISS ) - { - final DamageSource dmgSrc = new EntityDamageSource( "matter_cannon", p ); - - if( pos instanceof EntityRayTraceResult ) - { - EntityRayTraceResult entityResult = (EntityRayTraceResult) pos; - Entity entityHit = entityResult.getEntity(); - - final int dmg = (int) Math.ceil( penetration / 20.0f ); - if( entityHit instanceof LivingEntity ) - { - final LivingEntity el = (LivingEntity) entityHit; - penetration -= dmg; - el.knockBack( p, 0, -direction.x, -direction.z ); - // el.knockBack( p, 0, Vec3d.x, - // Vec3d.z ); - el.attackEntityFrom( dmgSrc, dmg ); - if( !el.isAlive() ) - { - hasDestroyed = true; - } - } - else if( entityHit instanceof ItemEntity ) - { - hasDestroyed = true; - entityHit.remove(); - } - else if( entityHit.attackEntityFrom( dmgSrc, dmg ) ) - { - hasDestroyed = true; - } - } - else if( pos instanceof BlockRayTraceResult ) - { - BlockRayTraceResult blockResult = (BlockRayTraceResult) pos; - - if( !AEConfig.instance().isFeatureEnabled( AEFeature.MASS_CANNON_BLOCK_DAMAGE ) ) - { - penetration = 0; - } - else - { - BlockPos blockPos = blockResult.getPos(); - final BlockState bs = w.getBlockState(blockPos); - - final float hardness = bs.getBlockHardness( w, blockPos) * 9.0f; - if( hardness >= 0.0 ) - { - if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, blockPos), p ) ) - { - hasDestroyed = true; - penetration -= hardness; - penetration *= 0.60; - w.destroyBlock(blockPos, true ); - } - } - } - } - } - } - } - - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } - - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return new CellUpgrades( is, 4 ); - } - - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } - - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - final String fz = is.getOrCreateTag().getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { - return FuzzyMode.IGNORE_ALL; - } - } - - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { - is.getOrCreateTag().putString( "FuzzyMode", fzMode.name() ); - } - - @Override - public int getBytes( final ItemStack cellItem ) - { - return 512; - } - - @Override - public int getBytesPerType( final ItemStack cellItem ) - { - return 8; - } - - @Override - public int getTotalTypes( final ItemStack cellItem ) - { - return 1; - } - - @Override - public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition ) - { - final float pen = AEApi.instance().registries().matterCannon().getPenetration( requestedAddition.createItemStack() ); - if( pen > 0 ) - { - return false; - } - - if( requestedAddition.getItem() instanceof ItemPaintBall ) - { - return false; - } - - return true; - } - - @Override - public boolean storableInStorageCell() - { - return true; - } - - @Override - public boolean isStorageCell( final ItemStack i ) - { - return true; - } - - @Override - public double getIdleDrain() - { - return 0.5; - } - - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } +public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell { + + public ToolMatterCannon(Item.Properties props) { + super(AEConfig.instance().getMatterCannonBattery(), props); + } + + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + super.addInformation(stack, world, lines, advancedTooltips); + + final ICellInventoryHandler cdi = AEApi.instance().registries().cell().getCellInventory(stack, + null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + + AEApi.instance().client().addCellInformation(cdi, lines); + } + + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) { + if (this.getAECurrentPower(p.getHeldItem(hand)) > 1600) { + int shots = 1; + + final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory(p.getHeldItem(hand)); + if (cu != null) { + shots += cu.getInstalledUpgrades(Upgrades.SPEED); + } + + final ICellInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( + p.getHeldItem(hand), null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + if (inv != null) { + final IItemList itemList = inv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + IAEItemStack req = itemList.getFirstItem(); + if (req instanceof IAEItemStack) { + shots = Math.min(shots, (int) req.getStackSize()); + for (int sh = 0; sh < shots; sh++) { + IAEItemStack aeAmmo = req.copy(); + this.extractAEPower(p.getHeldItem(hand), 1600, Actionable.MODULATE); + + if (Platform.isClient()) { + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } + + aeAmmo.setStackSize(1); + final ItemStack ammo = aeAmmo.createItemStack(); + if (ammo == null) { + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } + + aeAmmo = inv.extractItems(aeAmmo, Actionable.MODULATE, new PlayerSource(p, null)); + if (aeAmmo == null) { + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } + + final LookDirection dir = Platform.getPlayerRay(p); + + final Vec3d Vec3d = dir.getA(); + final Vec3d Vec3d1 = dir.getB(); + final Vec3d direction = Vec3d1.subtract(Vec3d); + direction.normalize(); + + final double d0 = Vec3d.x; + final double d1 = Vec3d.y; + final double d2 = Vec3d.z; + + final float penetration = AEApi.instance().registries().matterCannon().getPenetration(ammo); // 196.96655f; + if (penetration <= 0) { + final ItemStack type = aeAmmo.asItemStackRepresentation(); + if (type.getItem() instanceof ItemPaintBall) { + this.shootPaintBalls(type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2); + } + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } else { + this.standardAmmo(penetration, w, p, Vec3d, Vec3d1, direction, d0, d1, d2); + } + } + } else { + if (Platform.isServer()) { + p.sendMessage(PlayerMessages.AmmoDepleted.get()); + } + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } + } + } + return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand)); + } + + private void shootPaintBalls(final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d, + final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2) { + final AxisAlignedBB bb = new AxisAlignedBB(Math.min(Vec3d.x, Vec3d1.x), Math.min(Vec3d.y, Vec3d1.y), + Math.min(Vec3d.z, Vec3d1.z), Math.max(Vec3d.x, Vec3d1.x), Math.max(Vec3d.y, Vec3d1.y), + Math.max(Vec3d.z, Vec3d1.z)).grow(16, 16, 16); + + Entity entity = null; + Vec3d entityIntersection = null; + final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb); + double closest = 9999999.0D; + + for (int l = 0; l < list.size(); ++l) { + final Entity entity1 = (Entity) list.get(l); + + if (!entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) { + if (entity1.isAlive()) { + // prevent killing / flying of mounts. + if (entity1.isRidingOrBeingRiddenBy(p)) { + continue; + } + + final float f1 = 0.3F; + + final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1); + final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null); + + if (intersection != null) { + final double nd = Vec3d.squareDistanceTo(intersection); + + if (nd < closest) { + entity = entity1; + entityIntersection = intersection; + closest = nd; + } + } + } + } + } + + RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, + RayTraceContext.FluidMode.NONE, p); + RayTraceResult pos = w.rayTraceBlocks(rayTraceContext); + + final Vec3d vec = new Vec3d(d0, d1, d2); + if (entity != null && pos.getType() != RayTraceResult.Type.MISS + && pos.getHitVec().squareDistanceTo(vec) > closest) { + pos = new EntityRayTraceResult(entity, entityIntersection); + } else if (entity != null && pos.getType() == RayTraceResult.Type.MISS) { + pos = new EntityRayTraceResult(entity, entityIntersection); + } + + try { + AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w, + new PacketMatterCannon(d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, + (byte) (pos.getType() == RayTraceResult.Type.MISS ? 32 + : pos.getHitVec().squareDistanceTo(vec) + 1))); + } catch (final Exception err) { + AELog.debug(err); + } + + if (pos.getType() != RayTraceResult.Type.MISS && type != null && type.getItem() instanceof ItemPaintBall) { + final ItemPaintBall ipb = (ItemPaintBall) type.getItem(); + + final AEColor col = ipb.getColor(); + // boolean lit = ipb.isLumen( type ); + + if (pos instanceof EntityRayTraceResult) { + EntityRayTraceResult entityResult = (EntityRayTraceResult) pos; + Entity entityHit = entityResult.getEntity(); + + final int id = entityHit.getEntityId(); + final PlayerColor marker = new PlayerColor(id, col, 20 * 30); + TickHandler.INSTANCE.getPlayerColors().put(id, marker); + + if (entityHit instanceof SheepEntity) { + final SheepEntity sh = (SheepEntity) entityHit; + sh.setFleeceColor(col.dye); + } + + entityHit.attackEntityFrom(DamageSource.causePlayerDamage(p), 0); + NetworkHandler.instance().sendToAll(marker.getPacket()); + } else if (pos instanceof BlockRayTraceResult) { + BlockRayTraceResult blockResult = (BlockRayTraceResult) pos; + final Direction side = blockResult.getFace(); + final BlockPos hitPos = blockResult.getPos().offset(side); + + if (!Platform.hasPermissions(new DimensionalCoord(w, hitPos), p)) { + return; + } + + final BlockState whatsThere = w.getBlockState(hitPos); + if (whatsThere.getMaterial().isReplaceable() && w.isAirBlock(hitPos)) { + AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent(paintBlock -> { + w.setBlockState(hitPos, paintBlock.getDefaultState(), 3); + }); + } + + final TileEntity te = w.getTileEntity(hitPos); + if (te instanceof TilePaint) { + final Vec3d hp = pos.getHitVec().subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ()); + ((TilePaint) te).addBlot(type, side.getOpposite(), hp); + } + } + } + } + + private void standardAmmo(float penetration, final World w, final PlayerEntity p, final Vec3d Vec3d, + final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2) { + boolean hasDestroyed = true; + while (penetration > 0 && hasDestroyed) { + hasDestroyed = false; + + final AxisAlignedBB bb = new AxisAlignedBB(Math.min(Vec3d.x, Vec3d1.x), Math.min(Vec3d.y, Vec3d1.y), + Math.min(Vec3d.z, Vec3d1.z), Math.max(Vec3d.x, Vec3d1.x), Math.max(Vec3d.y, Vec3d1.y), + Math.max(Vec3d.z, Vec3d1.z)).grow(16, 16, 16); + + Entity entity = null; + Vec3d entityIntersection = null; + final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb); + double closest = 9999999.0D; + + for (int l = 0; l < list.size(); ++l) { + final Entity entity1 = (Entity) list.get(l); + + if (entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) { + if (entity1.isAlive()) { + // prevent killing / flying of mounts. + if (entity1.isRidingOrBeingRiddenBy(p)) { + continue; + } + + final float f1 = 0.3F; + + final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1); + final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null); + + if (intersection != null) { + final double nd = Vec3d.squareDistanceTo(intersection); + + if (nd < closest) { + entity = entity1; + entityIntersection = intersection; + closest = nd; + } + } + } + } + } + + RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, + RayTraceContext.FluidMode.NONE, p); + final Vec3d vec = new Vec3d(d0, d1, d2); + RayTraceResult pos = w.rayTraceBlocks(rayTraceContext); + if (entity != null && pos.getType() != RayTraceResult.Type.MISS + && pos.getHitVec().squareDistanceTo(vec) > closest) { + pos = new EntityRayTraceResult(entity, entityIntersection); + } else if (entity != null && pos.getType() == RayTraceResult.Type.MISS) { + pos = new EntityRayTraceResult(entity, entityIntersection); + } + + try { + AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w, + new PacketMatterCannon(d0, d1, d2, (float) direction.x, (float) direction.y, + (float) direction.z, (byte) (pos.getType() == RayTraceResult.Type.MISS ? 32 + : pos.getHitVec().squareDistanceTo(vec) + 1))); + } catch (final Exception err) { + AELog.debug(err); + } + + if (pos.getType() != RayTraceResult.Type.MISS) { + final DamageSource dmgSrc = new EntityDamageSource("matter_cannon", p); + + if (pos instanceof EntityRayTraceResult) { + EntityRayTraceResult entityResult = (EntityRayTraceResult) pos; + Entity entityHit = entityResult.getEntity(); + + final int dmg = (int) Math.ceil(penetration / 20.0f); + if (entityHit instanceof LivingEntity) { + final LivingEntity el = (LivingEntity) entityHit; + penetration -= dmg; + el.knockBack(p, 0, -direction.x, -direction.z); + // el.knockBack( p, 0, Vec3d.x, + // Vec3d.z ); + el.attackEntityFrom(dmgSrc, dmg); + if (!el.isAlive()) { + hasDestroyed = true; + } + } else if (entityHit instanceof ItemEntity) { + hasDestroyed = true; + entityHit.remove(); + } else if (entityHit.attackEntityFrom(dmgSrc, dmg)) { + hasDestroyed = true; + } + } else if (pos instanceof BlockRayTraceResult) { + BlockRayTraceResult blockResult = (BlockRayTraceResult) pos; + + if (!AEConfig.instance().isFeatureEnabled(AEFeature.MASS_CANNON_BLOCK_DAMAGE)) { + penetration = 0; + } else { + BlockPos blockPos = blockResult.getPos(); + final BlockState bs = w.getBlockState(blockPos); + + final float hardness = bs.getBlockHardness(w, blockPos) * 9.0f; + if (hardness >= 0.0) { + if (penetration > hardness + && Platform.hasPermissions(new DimensionalCoord(w, blockPos), p)) { + hasDestroyed = true; + penetration -= hardness; + penetration *= 0.60; + w.destroyBlock(blockPos, true); + } + } + } + } + } + } + } + + @Override + public boolean isEditable(final ItemStack is) { + return true; + } + + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 4); + } + + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } + + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = is.getOrCreateTag().getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { + return FuzzyMode.IGNORE_ALL; + } + } + + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { + is.getOrCreateTag().putString("FuzzyMode", fzMode.name()); + } + + @Override + public int getBytes(final ItemStack cellItem) { + return 512; + } + + @Override + public int getBytesPerType(final ItemStack cellItem) { + return 8; + } + + @Override + public int getTotalTypes(final ItemStack cellItem) { + return 1; + } + + @Override + public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) { + final float pen = AEApi.instance().registries().matterCannon() + .getPenetration(requestedAddition.createItemStack()); + if (pen > 0) { + return false; + } + + if (requestedAddition.getItem() instanceof ItemPaintBall) { + return false; + } + + return true; + } + + @Override + public boolean storableInStorageCell() { + return true; + } + + @Override + public boolean isStorageCell(final ItemStack i) { + return true; + } + + @Override + public double getIdleDrain() { + return 0.5; + } + + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java index 1b5c9af3e..90d766a45 100644 --- a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java +++ b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java @@ -18,20 +18,15 @@ package appeng.items.tools.powered; - import java.util.List; import java.util.Set; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerMEPortableCell; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; @@ -51,146 +46,122 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.util.AEPartLocation; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerMEPortableCell; import appeng.core.AEConfig; import appeng.core.localization.GuiText; - import appeng.items.contents.CellConfig; import appeng.items.contents.CellUpgrades; import appeng.items.contents.PortableCellViewer; import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.util.Platform; +public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup { + public ToolPortableCell(Item.Properties props) { + super(AEConfig.instance().getPortableCellBattery(), props); + } -public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup -{ - public ToolPortableCell(Item.Properties props) - { - super( AEConfig.instance().getPortableCellBattery(), props ); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + ContainerOpener.openContainer(ContainerMEPortableCell.TYPE, player, ContainerLocator.forHand(player, hand)); + return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand)); + } - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity player, final Hand hand ) - { - ContainerOpener.openContainer(ContainerMEPortableCell.TYPE, player, ContainerLocator.forHand(player, hand)); - return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + super.addInformation(stack, world, lines, advancedTooltips); - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - super.addInformation( stack, world, lines, advancedTooltips ); + final ICellInventoryHandler cdi = AEApi.instance().registries().cell().getCellInventory(stack, + null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - final ICellInventoryHandler cdi = AEApi.instance() - .registries() - .cell() - .getCellInventory( stack, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + AEApi.instance().client().addCellInformation(cdi, lines); + } - AEApi.instance().client().addCellInformation( cdi, lines ); - } + @Override + public int getBytes(final ItemStack cellItem) { + return 512; + } - @Override - public int getBytes( final ItemStack cellItem ) - { - return 512; - } + @Override + public int getBytesPerType(final ItemStack cellItem) { + return 8; + } - @Override - public int getBytesPerType( final ItemStack cellItem ) - { - return 8; - } + @Override + public int getTotalTypes(final ItemStack cellItem) { + return 27; + } - @Override - public int getTotalTypes( final ItemStack cellItem ) - { - return 27; - } + @Override + public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) { + return false; + } - @Override - public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition ) - { - return false; - } + @Override + public boolean storableInStorageCell() { + return false; + } - @Override - public boolean storableInStorageCell() - { - return false; - } + @Override + public boolean isStorageCell(final ItemStack i) { + return true; + } - @Override - public boolean isStorageCell( final ItemStack i ) - { - return true; - } + @Override + public double getIdleDrain() { + return 0.5; + } - @Override - public double getIdleDrain() - { - return 0.5; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public String getUnlocalizedGroupName(final Set others, final ItemStack is) { + return GuiText.StorageCells.getTranslationKey(); + } - @Override - public String getUnlocalizedGroupName( final Set others, final ItemStack is ) - { - return GuiText.StorageCells.getTranslationKey(); - } + @Override + public boolean isEditable(final ItemStack is) { + return true; + } - @Override - public boolean isEditable( final ItemStack is ) - { - return true; - } + @Override + public IItemHandler getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 2); + } - @Override - public IItemHandler getUpgradesInventory( final ItemStack is ) - { - return new CellUpgrades( is, 2 ); - } + @Override + public IItemHandler getConfigInventory(final ItemStack is) { + return new CellConfig(is); + } - @Override - public IItemHandler getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); - } + @Override + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = is.getOrCreateTag().getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { + return FuzzyMode.IGNORE_ALL; + } + } - @Override - public FuzzyMode getFuzzyMode( final ItemStack is ) - { - final String fz = is.getOrCreateTag().getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { - return FuzzyMode.IGNORE_ALL; - } - } - - @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { + @Override + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { is.getOrCreateTag().putString("FuzzyMode", fzMode.name()); - } + } - @Override - public IGuiItemObject getGuiObject( final ItemStack is, int playerInventorySlot, final World w, final BlockPos pos ) - { - return new PortableCellViewer( is, playerInventorySlot ); - } + @Override + public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World w, final BlockPos pos) { + return new PortableCellViewer(is, playerInventorySlot); + } - @Override - public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged ) - { - return slotChanged; - } + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return slotChanged; + } } diff --git a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java index 6f3225d04..6cf40f4a9 100644 --- a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java +++ b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java @@ -18,7 +18,6 @@ package appeng.items.tools.powered; - import java.util.List; import net.minecraft.client.util.ITooltipFlag; @@ -48,103 +47,85 @@ import appeng.core.localization.GuiText; import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.util.ConfigManager; +public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler { -public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler -{ + public ToolWirelessTerminal(Item.Properties props) { + super(AEConfig.instance().getWirelessTerminalBattery(), props); + } - public ToolWirelessTerminal(Item.Properties props) - { - super( AEConfig.instance().getWirelessTerminalBattery(), props ); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player, hand); + return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand)); + } - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity player, final Hand hand ) - { - AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player, hand ); - return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) ); - } + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + super.addInformation(stack, world, lines, advancedTooltips); - @Override - @OnlyIn( Dist.CLIENT ) - public void addInformation( final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - super.addInformation( stack, world, lines, advancedTooltips ); + if (stack.hasTag()) { + final CompoundNBT tag = stack.getOrCreateTag(); + if (tag != null) { + final String encKey = tag.getString("encryptionKey"); - if( stack.hasTag() ) - { - final CompoundNBT tag = stack.getOrCreateTag(); - if( tag != null ) - { - final String encKey = tag.getString( "encryptionKey" ); + if (encKey == null || encKey.isEmpty()) { + lines.add(GuiText.Unlinked.textComponent()); + } else { + lines.add(GuiText.Linked.textComponent()); + } + } + } else { + lines.add(new TranslationTextComponent("AppEng.GuiITooltip.Unlinked")); + } + } - if( encKey == null || encKey.isEmpty() ) - { - lines.add( GuiText.Unlinked.textComponent() ); - } - else - { - lines.add( GuiText.Linked.textComponent() ); - } - } - } - else - { - lines.add( new TranslationTextComponent( "AppEng.GuiITooltip.Unlinked" ) ); - } - } + @Override + public boolean canHandle(final ItemStack is) { + return AEApi.instance().definitions().items().wirelessTerminal().isSameAs(is); + } - @Override - public boolean canHandle( final ItemStack is ) - { - return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is ); - } + @Override + public boolean usePower(final PlayerEntity player, final double amount, final ItemStack is) { + return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5; + } - @Override - public boolean usePower( final PlayerEntity player, final double amount, final ItemStack is ) - { - return this.extractAEPower( is, amount, Actionable.MODULATE ) >= amount - 0.5; - } + @Override + public boolean hasPower(final PlayerEntity player, final double amt, final ItemStack is) { + return this.getAECurrentPower(is) >= amt; + } - @Override - public boolean hasPower( final PlayerEntity player, final double amt, final ItemStack is ) - { - return this.getAECurrentPower( is ) >= amt; - } + @Override + public IConfigManager getConfigManager(final ItemStack target) { + final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> { + final CompoundNBT data = target.getOrCreateTag(); + manager.writeToNBT(data); + }); - @Override - public IConfigManager getConfigManager( final ItemStack target ) - { - final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> { - final CompoundNBT data = target.getOrCreateTag(); - manager.writeToNBT( data ); - } ); + out.registerSetting(Settings.SORT_BY, SortOrder.NAME); + out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); - out.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); + out.readFromNBT(target.getOrCreateTag().copy()); + return out; + } - out.readFromNBT( target.getOrCreateTag().copy() ); - return out; - } + @Override + public String getEncryptionKey(final ItemStack item) { + final CompoundNBT tag = item.getOrCreateTag(); + return tag.getString("encryptionKey"); + } - @Override - public String getEncryptionKey( final ItemStack item ) - { - final CompoundNBT tag = item.getOrCreateTag(); - return tag.getString( "encryptionKey" ); - } + @Override + public void setEncryptionKey(final ItemStack item, final String encKey, final String name) { + final CompoundNBT tag = item.getOrCreateTag(); + tag.putString("encryptionKey", encKey); + tag.putString("name", name); + } - @Override - public void setEncryptionKey( final ItemStack item, final String encKey, final String name ) - { - final CompoundNBT tag = item.getOrCreateTag(); - tag.putString( "encryptionKey", encKey ); - tag.putString( "name", name ); - } - - @Override - public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged ) - { - return slotChanged; - } + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return slotChanged; + } } 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 907589979..ae875e066 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java +++ b/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java @@ -18,7 +18,6 @@ package appeng.items.tools.powered.powersink; - import java.text.MessageFormat; import java.util.List; import java.util.function.DoubleSupplier; @@ -31,9 +30,9 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.capabilities.ICapabilityProvider; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; @@ -43,137 +42,122 @@ import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; import appeng.util.Platform; +public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPowerStorage { + private static final String CURRENT_POWER_NBT_KEY = "internalCurrentPower"; + private static final String MAX_POWER_NBT_KEY = "internalMaxPower"; + private final DoubleSupplier powerCapacity; -public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPowerStorage -{ - private static final String CURRENT_POWER_NBT_KEY = "internalCurrentPower"; - private static final String MAX_POWER_NBT_KEY = "internalMaxPower"; - private final DoubleSupplier powerCapacity; - - public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props ) - { - super(props); + public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props) { + super(props); // FIXME this.setFull3D(); - this.powerCapacity = powerCapacity; - } + this.powerCapacity = powerCapacity; + } - @OnlyIn( Dist.CLIENT ) - @Override - public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) - { - final CompoundNBT tag = stack.getTag(); - double internalCurrentPower = 0; - final double internalMaxPower = this.getAEMaxPower( stack ); + @OnlyIn(Dist.CLIENT) + @Override + public void addInformation(final ItemStack stack, final World world, final List lines, + final ITooltipFlag advancedTooltips) { + final CompoundNBT tag = stack.getTag(); + double internalCurrentPower = 0; + final double internalMaxPower = this.getAEMaxPower(stack); - if( tag != null ) - { - internalCurrentPower = tag.getDouble( CURRENT_POWER_NBT_KEY ); - } + if (tag != null) { + internalCurrentPower = tag.getDouble(CURRENT_POWER_NBT_KEY); + } - final double percent = internalCurrentPower / internalMaxPower; + final double percent = internalCurrentPower / internalMaxPower; - lines.add( GuiText.StoredEnergy.textComponent().appendText( ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) ) - .appendSibling( new TranslationTextComponent( PowerUnits.AE.unlocalizedName ) ) - .appendText( " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) ) ); - } + lines.add(GuiText.StoredEnergy.textComponent() + .appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower)) + .appendSibling(new TranslationTextComponent(PowerUnits.AE.unlocalizedName)) + .appendText(" - " + MessageFormat.format(" {0,number,#.##%} ", percent))); + } - @Override - public boolean isDamageable() - { - return true; - } + @Override + public boolean isDamageable() { + return true; + } - @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - super.fillItemGroup(group, items); + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + super.fillItemGroup(group, items); - if (this.isInGroup(group)) { - final ItemStack charged = new ItemStack(this, 1); - final CompoundNBT tag = charged.getOrCreateTag(); - tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged)); - tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged)); + if (this.isInGroup(group)) { + final ItemStack charged = new ItemStack(this, 1); + final CompoundNBT tag = charged.getOrCreateTag(); + tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged)); + tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged)); - items.add(charged); - } - } + items.add(charged); + } + } - @Override - public double getDurabilityForDisplay( final ItemStack is ) - { - return 1 - this.getAECurrentPower( is ) / this.getAEMaxPower( is ); - } + @Override + public double getDurabilityForDisplay(final ItemStack is) { + return 1 - this.getAECurrentPower(is) / this.getAEMaxPower(is); + } - @Override - public boolean isDamaged( final ItemStack stack ) - { - return true; - } + @Override + public boolean isDamaged(final ItemStack stack) { + return true; + } - @Override - public void setDamage( final ItemStack stack, final int damage ) - { + @Override + public void setDamage(final ItemStack stack, final int damage) { - } + } - @Override - public double injectAEPower( final ItemStack is, final double amount, Actionable mode ) - { - final double maxStorage = this.getAEMaxPower( is ); - final double currentStorage = this.getAECurrentPower( is ); - final double required = maxStorage - currentStorage; - final double overflow = amount - required; + @Override + public double injectAEPower(final ItemStack is, final double amount, Actionable mode) { + final double maxStorage = this.getAEMaxPower(is); + final double currentStorage = this.getAECurrentPower(is); + final double required = maxStorage - currentStorage; + final double overflow = amount - required; - if( mode == Actionable.MODULATE ) - { + if (mode == Actionable.MODULATE) { final CompoundNBT data = is.getOrCreateTag(); - final double toAdd = Math.min( amount, required ); + final double toAdd = Math.min(amount, required); - data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage + toAdd); - } + data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage + toAdd); + } - return Math.max( 0, overflow ); - } + return Math.max(0, overflow); + } - @Override - public double extractAEPower( final ItemStack is, final double amount, Actionable mode ) - { - final double currentStorage = this.getAECurrentPower( is ); - final double fulfillable = Math.min( amount, currentStorage ); + @Override + public double extractAEPower(final ItemStack is, final double amount, Actionable mode) { + final double currentStorage = this.getAECurrentPower(is); + final double fulfillable = Math.min(amount, currentStorage); - if( mode == Actionable.MODULATE ) - { + if (mode == Actionable.MODULATE) { final CompoundNBT data = is.getOrCreateTag(); - data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable); - } + data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable); + } - return fulfillable; - } + return fulfillable; + } - @Override - public double getAEMaxPower( final ItemStack is ) - { - return this.powerCapacity.getAsDouble(); - } + @Override + public double getAEMaxPower(final ItemStack is) { + return this.powerCapacity.getAsDouble(); + } - @Override - public double getAECurrentPower( final ItemStack is ) - { + @Override + public double getAECurrentPower(final ItemStack is) { final CompoundNBT data = is.getOrCreateTag(); - return data.getDouble( CURRENT_POWER_NBT_KEY ); - } + return data.getDouble(CURRENT_POWER_NBT_KEY); + } - @Override - public AccessRestriction getPowerFlow( final ItemStack is ) - { - return AccessRestriction.WRITE; - } + @Override + public AccessRestriction getPowerFlow(final ItemStack is) { + return AccessRestriction.WRITE; + } - @Override - public ICapabilityProvider initCapabilities( ItemStack stack, CompoundNBT nbt ) - { - return new PoweredItemCapabilities( stack, this ); - } + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) { + return new PoweredItemCapabilities(stack, this); + } } diff --git a/src/main/java/appeng/items/tools/powered/powersink/PoweredItemCapabilities.java b/src/main/java/appeng/items/tools/powered/powersink/PoweredItemCapabilities.java index 4edf4855c..fa60aad55 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/PoweredItemCapabilities.java +++ b/src/main/java/appeng/items/tools/powered/powersink/PoweredItemCapabilities.java @@ -18,7 +18,6 @@ package appeng.items.tools.powered.powersink; - import javax.annotation.Nullable; import net.minecraft.item.ItemStack; @@ -33,71 +32,61 @@ import appeng.api.config.PowerUnits; import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.capabilities.Capabilities; - /** * The capability provider to expose chargable items to other mods. */ -class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage -{ +class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage { - private final ItemStack is; + private final ItemStack is; - private final IAEItemPowerStorage item; + private final IAEItemPowerStorage item; - PoweredItemCapabilities( ItemStack is, IAEItemPowerStorage item ) - { - this.is = is; - this.item = item; - } + PoweredItemCapabilities(ItemStack is, IAEItemPowerStorage item) { + this.is = is; + this.item = item; + } - @SuppressWarnings( "unchecked" ) - @Override - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - if( capability == Capabilities.FORGE_ENERGY ) - { - return (LazyOptional) LazyOptional.of(() -> this); - } - return LazyOptional.empty(); - } + @SuppressWarnings("unchecked") + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + if (capability == Capabilities.FORGE_ENERGY) { + return (LazyOptional) LazyOptional.of(() -> this); + } + return LazyOptional.empty(); + } - @Override - public int receiveEnergy( int maxReceive, boolean simulate ) - { - final double convertedOffer = PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive ); - final double overflow = this.item.injectAEPower( this.is, convertedOffer, simulate ? Actionable.SIMULATE : Actionable.MODULATE ); + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + final double convertedOffer = PowerUnits.RF.convertTo(PowerUnits.AE, maxReceive); + final double overflow = this.item.injectAEPower(this.is, convertedOffer, + simulate ? Actionable.SIMULATE : Actionable.MODULATE); - return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, overflow ); - } + return maxReceive - (int) PowerUnits.AE.convertTo(PowerUnits.RF, overflow); + } - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - return 0; - } + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } - @Override - public int getEnergyStored() - { - return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAECurrentPower( this.is ) ); - } + @Override + public int getEnergyStored() { + return (int) PowerUnits.AE.convertTo(PowerUnits.RF, this.item.getAECurrentPower(this.is)); + } - @Override - public int getMaxEnergyStored() - { - return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAEMaxPower( this.is ) ); - } + @Override + public int getMaxEnergyStored() { + return (int) PowerUnits.AE.convertTo(PowerUnits.RF, this.item.getAEMaxPower(this.is)); + } - @Override - public boolean canExtract() - { - return false; - } + @Override + public boolean canExtract() { + return false; + } - @Override - public boolean canReceive() - { - return true; - } + @Override + public boolean canReceive() { + return true; + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzAxe.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzAxe.java index 262a0e9e0..4639b8470 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzAxe.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzAxe.java @@ -18,7 +18,6 @@ package appeng.items.tools.quartz; - import net.minecraft.item.AxeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -28,20 +27,16 @@ import net.minecraft.item.ItemTier; import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ToolQuartzAxe extends AxeItem { + private final AEFeature type; -public class ToolQuartzAxe extends AxeItem -{ - private final AEFeature type; + public ToolQuartzAxe(Item.Properties props, final AEFeature type) { + super(ItemTier.IRON, 6.0F, -3.1F, props); + this.type = type; + } - public ToolQuartzAxe( Item.Properties props, final AEFeature type ) - { - super( ItemTier.IRON, 6.0F, -3.1F, props ); - this.type = type; - } - - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java index 3d5e2b99a..0a1f43660 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java @@ -18,16 +18,6 @@ package appeng.items.tools.quartz; - -import appeng.api.features.AEFeature; -import appeng.api.implementations.guiobjects.IGuiItem; -import appeng.api.implementations.guiobjects.IGuiItemObject; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerQuartzKnife; -import appeng.items.AEBaseItem; -import appeng.items.contents.QuartzKnifeObj; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -38,63 +28,64 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import appeng.api.features.AEFeature; +import appeng.api.implementations.guiobjects.IGuiItem; +import appeng.api.implementations.guiobjects.IGuiItemObject; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerQuartzKnife; +import appeng.items.AEBaseItem; +import appeng.items.contents.QuartzKnifeObj; +import appeng.util.Platform; -public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem -{ - private final AEFeature type; +public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem { + private final AEFeature type; - public ToolQuartzCuttingKnife( Item.Properties props, final AEFeature type ) - { - super(props); - this.type = type; - } + public ToolQuartzCuttingKnife(Item.Properties props, final AEFeature type) { + super(props); + this.type = type; + } - @Override - public ActionResultType onItemUse(ItemUseContext context ) - { - PlayerEntity player = context.getPlayer(); - if( Platform.isServer() && player != null ) - { - ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, context.getPlayer(), ContainerLocator.forItemUseContext(context)); - } - return ActionResultType.SUCCESS; - } + @Override + public ActionResultType onItemUse(ItemUseContext context) { + PlayerEntity player = context.getPlayer(); + if (Platform.isServer() && player != null) { + ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, context.getPlayer(), + ContainerLocator.forItemUseContext(context)); + } + return ActionResultType.SUCCESS; + } - @Override - public ActionResult onItemRightClick( final World w, final PlayerEntity p, final Hand hand ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, p, ContainerLocator.forHand(p, hand)); - } - p.swingArm( hand ); - return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) ); - } + @Override + public ActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, p, ContainerLocator.forHand(p, hand)); + } + p.swingArm(hand); + return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand)); + } - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } - @Override - public ItemStack getContainerItem( final ItemStack itemStack ) - { - ItemStack copy = itemStack.copy(); - copy.setDamage( itemStack.getDamage() + 1 ); + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + ItemStack copy = itemStack.copy(); + copy.setDamage(itemStack.getDamage() + 1); - return copy; - } + return copy; + } - @Override - public boolean hasContainerItem( final ItemStack stack ) - { - return true; - } + @Override + public boolean hasContainerItem(final ItemStack stack) { + return true; + } - @Override - public IGuiItemObject getGuiObject( final ItemStack is, int playerInventorySlot, final World world, final BlockPos pos ) - { - return new QuartzKnifeObj( is ); - } + @Override + public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world, + final BlockPos pos) { + return new QuartzKnifeObj(is); + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzHoe.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzHoe.java index 6abc82dd1..11856cce1 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzHoe.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzHoe.java @@ -18,7 +18,6 @@ package appeng.items.tools.quartz; - import net.minecraft.item.HoeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -28,21 +27,17 @@ import net.minecraft.item.ItemTier; import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ToolQuartzHoe extends HoeItem { + private final AEFeature type; -public class ToolQuartzHoe extends HoeItem -{ - private final AEFeature type; + public ToolQuartzHoe(Item.Properties props, final AEFeature type) { + super(ItemTier.IRON, -1.0F, props); + this.type = type; + } - public ToolQuartzHoe( Item.Properties props, final AEFeature type ) - { - super( ItemTier.IRON, -1.0F, props); - this.type = type; - } - - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } } \ No newline at end of file diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzPickaxe.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzPickaxe.java index 7396f48c3..ea94b2719 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzPickaxe.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzPickaxe.java @@ -18,7 +18,6 @@ package appeng.items.tools.quartz; - import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -28,20 +27,16 @@ import net.minecraft.item.PickaxeItem; import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ToolQuartzPickaxe extends PickaxeItem { + private final AEFeature type; -public class ToolQuartzPickaxe extends PickaxeItem -{ - private final AEFeature type; + public ToolQuartzPickaxe(Item.Properties props, final AEFeature type) { + super(ItemTier.IRON, 1, -2.8F, props); + this.type = type; + } - public ToolQuartzPickaxe( Item.Properties props, final AEFeature type ) - { - super( ItemTier.IRON, 1, -2.8F, props ); - this.type = type; - } - - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzSpade.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzSpade.java index 79eca8093..d4073c32b 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzSpade.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzSpade.java @@ -18,7 +18,6 @@ package appeng.items.tools.quartz; - import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -28,20 +27,16 @@ import net.minecraft.item.ShovelItem; import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ToolQuartzSpade extends ShovelItem { + private final AEFeature type; -public class ToolQuartzSpade extends ShovelItem -{ - private final AEFeature type; + public ToolQuartzSpade(Item.Properties props, final AEFeature type) { + super(ItemTier.IRON, 1.5F, -3.0F, props); + this.type = type; + } - public ToolQuartzSpade( Item.Properties props, final AEFeature type ) - { - super( ItemTier.IRON, 1.5F, -3.0F, props ); - this.type = type; - } - - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzSword.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzSword.java index 079db162a..ed5fd5105 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzSword.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzSword.java @@ -18,7 +18,6 @@ package appeng.items.tools.quartz; - import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -28,20 +27,16 @@ import net.minecraft.item.SwordItem; import appeng.api.features.AEFeature; import appeng.util.Platform; +public class ToolQuartzSword extends SwordItem { + private final AEFeature type; -public class ToolQuartzSword extends SwordItem -{ - private final AEFeature type; + public ToolQuartzSword(Item.Properties props, AEFeature type) { + super(ItemTier.IRON, 3, -2.4F, props); + this.type = type; + } - public ToolQuartzSword( Item.Properties props, AEFeature type ) - { - super( ItemTier.IRON, 3, -2.4F, props ); - this.type = type; - } - - @Override - public boolean getIsRepairable( final ItemStack a, final ItemStack b ) - { - return Platform.canRepair( this.type, a, b ); - } + @Override + public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + return Platform.canRepair(this.type, a, b); + } } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java index c4aea7bbe..3619750dc 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java @@ -18,12 +18,6 @@ package appeng.items.tools.quartz; - -import appeng.api.implementations.items.IAEWrench; -import appeng.api.util.DimensionalCoord; -import appeng.block.AEBaseBlock; -import appeng.items.AEBaseItem; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -32,42 +26,43 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; +import appeng.api.implementations.items.IAEWrench; +import appeng.api.util.DimensionalCoord; +import appeng.block.AEBaseBlock; +import appeng.items.AEBaseItem; +import appeng.util.Platform; -public class ToolQuartzWrench extends AEBaseItem implements IAEWrench -{ +public class ToolQuartzWrench extends AEBaseItem implements IAEWrench { - public ToolQuartzWrench(Item.Properties props) - { - super( props ); - } + public ToolQuartzWrench(Item.Properties props) { + super(props); + } - @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - if( !context.getPlayer().isCrouching() && Platform.hasPermissions( new DimensionalCoord( context.getWorld(), context.getPos() ), - context.getPlayer() ) ) - { + @Override + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { + if (!context.getPlayer().isCrouching() && Platform + .hasPermissions(new DimensionalCoord(context.getWorld(), context.getPos()), context.getPlayer())) { - Block block = context.getWorld().getBlockState(context.getPos()).getBlock(); - if (block instanceof AEBaseBlock) { - if( Platform.isClient() ) - { - // TODO 1.10-R - if we return FAIL on client, action will not be sent to server. Fix that in all Block#onItemUseFirst overrides. - return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.PASS; - } + Block block = context.getWorld().getBlockState(context.getPos()).getBlock(); + if (block instanceof AEBaseBlock) { + if (Platform.isClient()) { + // TODO 1.10-R - if we return FAIL on client, action will not be sent to server. + // Fix that in all Block#onItemUseFirst overrides. + return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.PASS; + } - AEBaseBlock aeBlock = (AEBaseBlock) block; - if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) { - context.getPlayer().swingArm(context.getHand()); - return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.FAIL; - } - } - } - return ActionResultType.PASS; - } + AEBaseBlock aeBlock = (AEBaseBlock) block; + if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) { + context.getPlayer().swingArm(context.getHand()); + return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.FAIL; + } + } + } + return ActionResultType.PASS; + } - @Override - public boolean canWrench( final ItemStack wrench, final PlayerEntity player, final BlockPos pos ) - { - return true; - } + @Override + public boolean canWrench(final ItemStack wrench, final PlayerEntity player, final BlockPos pos) { + return true; + } } diff --git a/src/main/java/appeng/me/Grid.java b/src/main/java/appeng/me/Grid.java index daab0dbd5..1c86bba91 100644 --- a/src/main/java/appeng/me/Grid.java +++ b/src/main/java/appeng/me/Grid.java @@ -18,7 +18,6 @@ package appeng.me; - import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -40,259 +39,213 @@ import appeng.core.worlddata.WorldData; import appeng.hooks.TickHandler; import appeng.util.ReadOnlyCollection; +public class Grid implements IGrid { + private final NetworkEventBus eventBus = new NetworkEventBus(); + private final Map, MachineSet> machines = new HashMap<>(); + private final Map, GridCacheWrapper> caches = new HashMap<>(); + private GridNode pivot; + private int priority; // how import is this network? + private GridStorage myStorage; -public class Grid implements IGrid -{ - private final NetworkEventBus eventBus = new NetworkEventBus(); - private final Map, MachineSet> machines = new HashMap<>(); - private final Map, GridCacheWrapper> caches = new HashMap<>(); - private GridNode pivot; - private int priority; // how import is this network? - private GridStorage myStorage; + public Grid(final GridNode center) { + this.pivot = center; - public Grid( final GridNode center ) - { - this.pivot = center; + final Map, IGridCache> myCaches = AEApi.instance().registries().gridCache() + .createCacheInstance(this); + for (final Entry, IGridCache> c : myCaches.entrySet()) { + final Class key = c.getKey(); + final IGridCache value = c.getValue(); + final Class valueClass = value.getClass(); - final Map, IGridCache> myCaches = AEApi.instance().registries().gridCache().createCacheInstance( this ); - for( final Entry, IGridCache> c : myCaches.entrySet() ) - { - final Class key = c.getKey(); - final IGridCache value = c.getValue(); - final Class valueClass = value.getClass(); + this.eventBus.readClass(key, valueClass); + this.caches.put(key, new GridCacheWrapper(value)); + } - this.eventBus.readClass( key, valueClass ); - this.caches.put( key, new GridCacheWrapper( value ) ); - } + this.postEvent(new MENetworkPostCacheConstruction()); - this.postEvent( new MENetworkPostCacheConstruction() ); + TickHandler.INSTANCE.addNetwork(this); + center.setGrid(this); + } - TickHandler.INSTANCE.addNetwork( this ); - center.setGrid( this ); - } + int getPriority() { + return this.priority; + } - int getPriority() - { - return this.priority; - } + IGridStorage getMyStorage() { + return this.myStorage; + } - IGridStorage getMyStorage() - { - return this.myStorage; - } + Map, GridCacheWrapper> getCaches() { + return this.caches; + } - Map, GridCacheWrapper> getCaches() - { - return this.caches; - } + public Iterable> getMachineClasses() { + return this.machines.keySet(); + } - public Iterable> getMachineClasses() - { - return this.machines.keySet(); - } + int size() { + int out = 0; + for (final Collection x : this.machines.values()) { + out += x.size(); + } + return out; + } - int size() - { - int out = 0; - for( final Collection x : this.machines.values() ) - { - out += x.size(); - } - return out; - } + void remove(final GridNode gridNode) { + for (final IGridCache c : this.caches.values()) { + final IGridHost machine = gridNode.getMachine(); + c.removeNode(gridNode, machine); + } - void remove( final GridNode gridNode ) - { - for( final IGridCache c : this.caches.values() ) - { - final IGridHost machine = gridNode.getMachine(); - c.removeNode( gridNode, machine ); - } + final Class machineClass = gridNode.getMachineClass(); + final Set nodes = this.machines.get(machineClass); + if (nodes != null) { + nodes.remove(gridNode); + } - final Class machineClass = gridNode.getMachineClass(); - final Set nodes = this.machines.get( machineClass ); - if( nodes != null ) - { - nodes.remove( gridNode ); - } + gridNode.setGridStorage(null); - gridNode.setGridStorage( null ); + if (this.pivot == gridNode) { + final Iterator n = this.getNodes().iterator(); + if (n.hasNext()) { + this.pivot = (GridNode) n.next(); + } else { + this.pivot = null; + TickHandler.INSTANCE.removeNetwork(this); + this.myStorage.remove(); + } + } + } - if( this.pivot == gridNode ) - { - final Iterator n = this.getNodes().iterator(); - if( n.hasNext() ) - { - this.pivot = (GridNode) n.next(); - } - else - { - this.pivot = null; - TickHandler.INSTANCE.removeNetwork( this ); - this.myStorage.remove(); - } - } - } + void add(final GridNode gridNode) { + final Class mClass = gridNode.getMachineClass(); - void add( final GridNode gridNode ) - { - final Class mClass = gridNode.getMachineClass(); + MachineSet nodes = this.machines.get(mClass); + if (nodes == null) { + nodes = new MachineSet(mClass); + this.machines.put(mClass, nodes); + this.eventBus.readClass(mClass, mClass); + } - MachineSet nodes = this.machines.get( mClass ); - if( nodes == null ) - { - nodes = new MachineSet( mClass ); - this.machines.put( mClass, nodes ); - this.eventBus.readClass( mClass, mClass ); - } + // handle loading grid storages. + if (gridNode.getGridStorage() != null) { + final GridStorage gs = gridNode.getGridStorage(); + final IGrid grid = gs.getGrid(); - // handle loading grid storages. - if( gridNode.getGridStorage() != null ) - { - final GridStorage gs = gridNode.getGridStorage(); - final IGrid grid = gs.getGrid(); + if (grid == null) { + this.myStorage = gs; + this.myStorage.setGrid(this); - if( grid == null ) - { - this.myStorage = gs; - this.myStorage.setGrid( this ); + for (final IGridCache gc : this.caches.values()) { + gc.onJoin(this.myStorage); + } + } else if (grid != this) { + if (this.myStorage == null) { + this.myStorage = WorldData.instance().storageData().getNewGridStorage(); + this.myStorage.setGrid(this); + } - for( final IGridCache gc : this.caches.values() ) - { - gc.onJoin( this.myStorage ); - } - } - else if( grid != this ) - { - if( this.myStorage == null ) - { - this.myStorage = WorldData.instance().storageData().getNewGridStorage(); - this.myStorage.setGrid( this ); - } + final IGridStorage tmp = new GridStorage(); + if (!gs.hasDivided(this.myStorage)) { + gs.addDivided(this.myStorage); - final IGridStorage tmp = new GridStorage(); - if( !gs.hasDivided( this.myStorage ) ) - { - gs.addDivided( this.myStorage ); + for (final IGridCache gc : ((Grid) grid).caches.values()) { + gc.onSplit(tmp); + } - for( final IGridCache gc : ( (Grid) grid ).caches.values() ) - { - gc.onSplit( tmp ); - } + for (final IGridCache gc : this.caches.values()) { + gc.onJoin(tmp); + } + } + } + } else if (this.myStorage == null) { + this.myStorage = WorldData.instance().storageData().getNewGridStorage(); + this.myStorage.setGrid(this); + } - for( final IGridCache gc : this.caches.values() ) - { - gc.onJoin( tmp ); - } - } - } - } - else if( this.myStorage == null ) - { - this.myStorage = WorldData.instance().storageData().getNewGridStorage(); - this.myStorage.setGrid( this ); - } + // update grid node... + gridNode.setGridStorage(this.myStorage); - // update grid node... - gridNode.setGridStorage( this.myStorage ); + // track node. + nodes.add(gridNode); - // track node. - nodes.add( gridNode ); + for (final IGridCache cache : this.caches.values()) { + final IGridHost machine = gridNode.getMachine(); + cache.addNode(gridNode, machine); + } - for( final IGridCache cache : this.caches.values() ) - { - final IGridHost machine = gridNode.getMachine(); - cache.addNode( gridNode, machine ); - } + gridNode.getGridProxy().gridChanged(); + // postEventTo( gridNode, networkChanged ); + } - gridNode.getGridProxy().gridChanged(); - // postEventTo( gridNode, networkChanged ); - } + @Override + @SuppressWarnings("unchecked") + public C getCache(final Class iface) { + return (C) this.caches.get(iface).getCache(); + } - @Override - @SuppressWarnings( "unchecked" ) - public C getCache( final Class iface ) - { - return (C) this.caches.get( iface ).getCache(); - } + @Override + public MENetworkEvent postEvent(final MENetworkEvent ev) { + return this.eventBus.postEvent(this, ev); + } - @Override - public MENetworkEvent postEvent( final MENetworkEvent ev ) - { - return this.eventBus.postEvent( this, ev ); - } + @Override + public MENetworkEvent postEventTo(final IGridNode node, final MENetworkEvent ev) { + return this.eventBus.postEventTo(this, (GridNode) node, ev); + } - @Override - public MENetworkEvent postEventTo( final IGridNode node, final MENetworkEvent ev ) - { - return this.eventBus.postEventTo( this, (GridNode) node, ev ); - } + @Override + public IReadOnlyCollection> getMachinesClasses() { + final Set> machineKeys = this.machines.keySet(); - @Override - public IReadOnlyCollection> getMachinesClasses() - { - final Set> machineKeys = this.machines.keySet(); + return new ReadOnlyCollection<>(machineKeys); + } - return new ReadOnlyCollection<>( machineKeys ); - } + @Override + public IMachineSet getMachines(final Class c) { + final MachineSet s = this.machines.get(c); + if (s == null) { + return new MachineSet(c); + } + return s; + } - @Override - public IMachineSet getMachines( final Class c ) - { - final MachineSet s = this.machines.get( c ); - if( s == null ) - { - return new MachineSet( c ); - } - return s; - } + @Override + public IReadOnlyCollection getNodes() { + return new GridNodeCollection(this.machines); + } - @Override - public IReadOnlyCollection getNodes() - { - return new GridNodeCollection( this.machines ); - } + @Override + public boolean isEmpty() { + return this.pivot == null; + } - @Override - public boolean isEmpty() - { - return this.pivot == null; - } + @Override + public IGridNode getPivot() { + return this.pivot; + } - @Override - public IGridNode getPivot() - { - return this.pivot; - } + void setPivot(final GridNode pivot) { + this.pivot = pivot; + } - void setPivot( final GridNode pivot ) - { - this.pivot = pivot; - } + public void update() { + for (final IGridCache gc : this.caches.values()) { + // are there any nodes left? + if (this.pivot != null) { + gc.onUpdateTick(); + } + } + } - public void update() - { - for( final IGridCache gc : this.caches.values() ) - { - // are there any nodes left? - if( this.pivot != null ) - { - gc.onUpdateTick(); - } - } - } + void saveState() { + for (final IGridCache c : this.caches.values()) { + c.populateGridStorage(this.myStorage); + } + } - void saveState() - { - for( final IGridCache c : this.caches.values() ) - { - c.populateGridStorage( this.myStorage ); - } - } - - public void setImportantFlag( final int i, final boolean publicHasPower ) - { - final int flag = 1 << i; - this.priority = ( this.priority & ~flag ) | ( publicHasPower ? flag : 0 ); - } + public void setImportantFlag(final int i, final boolean publicHasPower) { + final int flag = 1 << i; + this.priority = (this.priority & ~flag) | (publicHasPower ? flag : 0); + } } diff --git a/src/main/java/appeng/me/GridAccessException.java b/src/main/java/appeng/me/GridAccessException.java index 6877e2176..1442d9202 100644 --- a/src/main/java/appeng/me/GridAccessException.java +++ b/src/main/java/appeng/me/GridAccessException.java @@ -18,9 +18,7 @@ package appeng.me; +public class GridAccessException extends Exception { -public class GridAccessException extends Exception -{ - - private static final long serialVersionUID = 3914554394866375300L; + private static final long serialVersionUID = 3914554394866375300L; } diff --git a/src/main/java/appeng/me/GridCacheWrapper.java b/src/main/java/appeng/me/GridCacheWrapper.java index 2825faa45..d3bf5cd07 100644 --- a/src/main/java/appeng/me/GridCacheWrapper.java +++ b/src/main/java/appeng/me/GridCacheWrapper.java @@ -18,68 +18,56 @@ package appeng.me; - import appeng.api.networking.IGridCache; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.IGridStorage; +public class GridCacheWrapper implements IGridCache { -public class GridCacheWrapper implements IGridCache -{ + private final IGridCache myCache; + private final String name; - private final IGridCache myCache; - private final String name; + public GridCacheWrapper(final IGridCache gc) { + this.myCache = gc; + this.name = this.getCache().getClass().getName(); + } - public GridCacheWrapper( final IGridCache gc ) - { - this.myCache = gc; - this.name = this.getCache().getClass().getName(); - } + @Override + public void onUpdateTick() { + this.getCache().onUpdateTick(); + } - @Override - public void onUpdateTick() - { - this.getCache().onUpdateTick(); - } + @Override + public void removeNode(final IGridNode gridNode, final IGridHost machine) { + this.getCache().removeNode(gridNode, machine); + } - @Override - public void removeNode( final IGridNode gridNode, final IGridHost machine ) - { - this.getCache().removeNode( gridNode, machine ); - } + @Override + public void addNode(final IGridNode gridNode, final IGridHost machine) { + this.getCache().addNode(gridNode, machine); + } - @Override - public void addNode( final IGridNode gridNode, final IGridHost machine ) - { - this.getCache().addNode( gridNode, machine ); - } + @Override + public void onSplit(final IGridStorage storageB) { + this.getCache().onSplit(storageB); + } - @Override - public void onSplit( final IGridStorage storageB ) - { - this.getCache().onSplit( storageB ); - } + @Override + public void onJoin(final IGridStorage storageB) { + this.getCache().onJoin(storageB); + } - @Override - public void onJoin( final IGridStorage storageB ) - { - this.getCache().onJoin( storageB ); - } + @Override + public void populateGridStorage(final IGridStorage storage) { + this.getCache().populateGridStorage(storage); + } - @Override - public void populateGridStorage( final IGridStorage storage ) - { - this.getCache().populateGridStorage( storage ); - } + public String getName() { + return this.name; + } - public String getName() - { - return this.name; - } - - IGridCache getCache() - { - return this.myCache; - } + IGridCache getCache() { + return this.myCache; + } } diff --git a/src/main/java/appeng/me/GridConnection.java b/src/main/java/appeng/me/GridConnection.java index 8c6e602be..4ffe5e47c 100644 --- a/src/main/java/appeng/me/GridConnection.java +++ b/src/main/java/appeng/me/GridConnection.java @@ -18,7 +18,6 @@ package appeng.me; - import java.util.Arrays; import java.util.EnumSet; @@ -26,6 +25,7 @@ import appeng.api.exceptions.ExistingConnectionException; import appeng.api.exceptions.FailedConnectionException; import appeng.api.exceptions.NullNodeConnectionException; import appeng.api.exceptions.SecurityConnectionException; +import appeng.api.features.AEFeature; import appeng.api.networking.GridFlags; import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridNode; @@ -36,267 +36,221 @@ import appeng.api.util.DimensionalCoord; import appeng.api.util.IReadOnlyCollection; import appeng.core.AEConfig; import appeng.core.AELog; -import appeng.api.features.AEFeature; import appeng.me.pathfinding.IPathItem; import appeng.util.Platform; import appeng.util.ReadOnlyCollection; +public class GridConnection implements IGridConnection, IPathItem { -public class GridConnection implements IGridConnection, IPathItem -{ + private static final String EXISTING_CONNECTION_MESSAGE = "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists."; - private static final String EXISTING_CONNECTION_MESSAGE = "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists."; + private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged(); + private int channelData = 0; + private Object visitorIterationNumber = null; + private GridNode sideA; + private AEPartLocation fromAtoB; + private GridNode sideB; - private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged(); - private int channelData = 0; - private Object visitorIterationNumber = null; - private GridNode sideA; - private AEPartLocation fromAtoB; - private GridNode sideB; + private GridConnection(final GridNode aNode, final GridNode bNode, final AEPartLocation fromAtoB) { + this.sideA = aNode; + this.fromAtoB = fromAtoB; + this.sideB = bNode; + } - private GridConnection( final GridNode aNode, final GridNode bNode, final AEPartLocation fromAtoB ) - { - this.sideA = aNode; - this.fromAtoB = fromAtoB; - this.sideB = bNode; - } + private boolean isNetworkABetter(final GridNode a, final GridNode b) { + return a.getMyGrid().getPriority() > b.getMyGrid().getPriority() || a.getMyGrid().size() > b.getMyGrid().size(); + } - private boolean isNetworkABetter( final GridNode a, final GridNode b ) - { - return a.getMyGrid().getPriority() > b.getMyGrid().getPriority() || a.getMyGrid().size() > b.getMyGrid().size(); - } + @Override + public IGridNode getOtherSide(final IGridNode gridNode) { + if (gridNode == this.sideA) { + return this.sideB; + } + if (gridNode == this.sideB) { + return this.sideA; + } - @Override - public IGridNode getOtherSide( final IGridNode gridNode ) - { - if( gridNode == this.sideA ) - { - return this.sideB; - } - if( gridNode == this.sideB ) - { - return this.sideA; - } + throw new GridException("Invalid Side of Connection"); + } - throw new GridException( "Invalid Side of Connection" ); - } + @Override + public AEPartLocation getDirection(final IGridNode side) { + if (this.fromAtoB == AEPartLocation.INTERNAL) { + return this.fromAtoB; + } - @Override - public AEPartLocation getDirection( final IGridNode side ) - { - if( this.fromAtoB == AEPartLocation.INTERNAL ) - { - return this.fromAtoB; - } + if (this.sideA == side) { + return this.fromAtoB; + } else { + return this.fromAtoB.getOpposite(); + } + } - if( this.sideA == side ) - { - return this.fromAtoB; - } - else - { - return this.fromAtoB.getOpposite(); - } - } + @Override + public void destroy() { + // a connection was destroyed RE-PATH!! + final IPathingGrid p = this.sideA.getInternalGrid().getCache(IPathingGrid.class); + p.repath(); - @Override - public void destroy() - { - // a connection was destroyed RE-PATH!! - final IPathingGrid p = this.sideA.getInternalGrid().getCache( IPathingGrid.class ); - p.repath(); + this.sideA.removeConnection(this); + this.sideB.removeConnection(this); - this.sideA.removeConnection( this ); - this.sideB.removeConnection( this ); + this.sideA.validateGrid(); + this.sideB.validateGrid(); + } - this.sideA.validateGrid(); - this.sideB.validateGrid(); - } + @Override + public IGridNode a() { + return this.sideA; + } - @Override - public IGridNode a() - { - return this.sideA; - } + @Override + public IGridNode b() { + return this.sideB; + } - @Override - public IGridNode b() - { - return this.sideB; - } + @Override + public boolean hasDirection() { + return this.fromAtoB != AEPartLocation.INTERNAL; + } - @Override - public boolean hasDirection() - { - return this.fromAtoB != AEPartLocation.INTERNAL; - } + @Override + public int getUsedChannels() { + return (this.channelData >> 8) & 0xff; + } - @Override - public int getUsedChannels() - { - return ( this.channelData >> 8 ) & 0xff; - } + @Override + public IPathItem getControllerRoute() { + if (this.sideA.getFlags().contains(GridFlags.CANNOT_CARRY)) { + return null; + } + return this.sideA; + } - @Override - public IPathItem getControllerRoute() - { - if( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) ) - { - return null; - } - return this.sideA; - } + @Override + public void setControllerRoute(final IPathItem fast, final boolean zeroOut) { + if (zeroOut) { + this.channelData &= ~0xff; + } - @Override - public void setControllerRoute( final IPathItem fast, final boolean zeroOut ) - { - if( zeroOut ) - { - this.channelData &= ~0xff; - } + if (this.sideB == fast) { + final GridNode tmp = this.sideA; + this.sideA = this.sideB; + this.sideB = tmp; + this.fromAtoB = this.fromAtoB.getOpposite(); + } + } - if( this.sideB == fast ) - { - final GridNode tmp = this.sideA; - this.sideA = this.sideB; - this.sideB = tmp; - this.fromAtoB = this.fromAtoB.getOpposite(); - } - } + @Override + public boolean canSupportMoreChannels() { + return this.getLastUsedChannels() < 32; // max, PERIOD. + } - @Override - public boolean canSupportMoreChannels() - { - return this.getLastUsedChannels() < 32; // max, PERIOD. - } + @Override + public IReadOnlyCollection getPossibleOptions() { + return new ReadOnlyCollection<>(Arrays.asList((IPathItem) this.a(), (IPathItem) this.b())); + } - @Override - public IReadOnlyCollection getPossibleOptions() - { - return new ReadOnlyCollection<>( Arrays.asList( (IPathItem) this.a(), (IPathItem) this.b() ) ); - } + @Override + public void incrementChannelCount(final int usedChannels) { + this.channelData += usedChannels; + } - @Override - public void incrementChannelCount( final int usedChannels ) - { - this.channelData += usedChannels; - } + @Override + public EnumSet getFlags() { + return EnumSet.noneOf(GridFlags.class); + } - @Override - public EnumSet getFlags() - { - return EnumSet.noneOf( GridFlags.class ); - } + @Override + public void finalizeChannels() { + if (this.getUsedChannels() != this.getLastUsedChannels()) { + this.channelData &= 0xff; + this.channelData |= this.channelData << 8; - @Override - public void finalizeChannels() - { - if( this.getUsedChannels() != this.getLastUsedChannels() ) - { - this.channelData &= 0xff; - this.channelData |= this.channelData << 8; + if (this.sideA.getInternalGrid() != null) { + this.sideA.getInternalGrid().postEventTo(this.sideA, EVENT); + } - if( this.sideA.getInternalGrid() != null ) - { - this.sideA.getInternalGrid().postEventTo( this.sideA, EVENT ); - } + if (this.sideB.getInternalGrid() != null) { + this.sideB.getInternalGrid().postEventTo(this.sideB, EVENT); + } + } + } - if( this.sideB.getInternalGrid() != null ) - { - this.sideB.getInternalGrid().postEventTo( this.sideB, EVENT ); - } - } - } + private int getLastUsedChannels() { + return this.channelData & 0xff; + } - private int getLastUsedChannels() - { - return this.channelData & 0xff; - } + Object getVisitorIterationNumber() { + return this.visitorIterationNumber; + } - Object getVisitorIterationNumber() - { - return this.visitorIterationNumber; - } + void setVisitorIterationNumber(final Object visitorIterationNumber) { + this.visitorIterationNumber = visitorIterationNumber; + } - void setVisitorIterationNumber( final Object visitorIterationNumber ) - { - this.visitorIterationNumber = visitorIterationNumber; - } + public static GridConnection create(final IGridNode aNode, final IGridNode bNode, final AEPartLocation fromAtoB) + throws FailedConnectionException { + if (aNode == null || bNode == null) { + throw new NullNodeConnectionException(); + } - public static GridConnection create( final IGridNode aNode, final IGridNode bNode, final AEPartLocation fromAtoB ) throws FailedConnectionException - { - if( aNode == null || bNode == null ) - { - throw new NullNodeConnectionException(); - } + final GridNode a = (GridNode) aNode; + final GridNode b = (GridNode) bNode; - final GridNode a = (GridNode) aNode; - final GridNode b = (GridNode) bNode; + if (a.hasConnection(b) || b.hasConnection(a)) { + final String aMachineClass = a.getGridBlock().getMachine().getClass().getSimpleName(); + final String bMachineClass = b.getGridBlock().getMachine().getClass().getSimpleName(); + final String aCoordinates = a.getGridBlock().getLocation().toString(); + final String bCoordinates = b.getGridBlock().getLocation().toString(); - if( a.hasConnection( b ) || b.hasConnection( a ) ) - { - final String aMachineClass = a.getGridBlock().getMachine().getClass().getSimpleName(); - final String bMachineClass = b.getGridBlock().getMachine().getClass().getSimpleName(); - final String aCoordinates = a.getGridBlock().getLocation().toString(); - final String bCoordinates = b.getGridBlock().getLocation().toString(); + throw new ExistingConnectionException(String.format(EXISTING_CONNECTION_MESSAGE, aMachineClass, + aCoordinates, bMachineClass, bCoordinates, fromAtoB)); + } - throw new ExistingConnectionException( String.format( EXISTING_CONNECTION_MESSAGE, aMachineClass, aCoordinates, bMachineClass, bCoordinates, - fromAtoB ) ); - } + if (!Platform.securityCheck(a, b)) { + if (AEConfig.instance().isFeatureEnabled(AEFeature.LOG_SECURITY_AUDITS)) { + final DimensionalCoord aCoordinates = a.getGridBlock().getLocation(); + final DimensionalCoord bCoordinates = b.getGridBlock().getLocation(); - if( !Platform.securityCheck( a, b ) ) - { - if( AEConfig.instance().isFeatureEnabled( AEFeature.LOG_SECURITY_AUDITS ) ) - { - final DimensionalCoord aCoordinates = a.getGridBlock().getLocation(); - final DimensionalCoord bCoordinates = b.getGridBlock().getLocation(); + AELog.info("Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), + a.getPlayerID()); + AELog.info("Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), + b.getPlayerID()); + } - AELog.info( "Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), a.getPlayerID() ); - AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.getPlayerID() ); - } + throw new SecurityConnectionException(); + } - throw new SecurityConnectionException(); - } + // Create the actual connection + final GridConnection connection = new GridConnection(a, b, fromAtoB); - // Create the actual connection - final GridConnection connection = new GridConnection( a, b, fromAtoB ); + // Update both nodes with the new connection. + if (a.getMyGrid() == null) { + b.setGrid(a.getInternalGrid()); + } else { + if (a.getMyGrid() == null) { + final GridPropagator gp = new GridPropagator(b.getInternalGrid()); + aNode.beginVisit(gp); + } else if (b.getMyGrid() == null) { + final GridPropagator gp = new GridPropagator(a.getInternalGrid()); + bNode.beginVisit(gp); + } else if (connection.isNetworkABetter(a, b)) { + final GridPropagator gp = new GridPropagator(a.getInternalGrid()); + b.beginVisit(gp); + } else { + final GridPropagator gp = new GridPropagator(b.getInternalGrid()); + a.beginVisit(gp); + } + } - // Update both nodes with the new connection. - if( a.getMyGrid() == null ) - { - b.setGrid( a.getInternalGrid() ); - } - else - { - if( a.getMyGrid() == null ) - { - final GridPropagator gp = new GridPropagator( b.getInternalGrid() ); - aNode.beginVisit( gp ); - } - else if( b.getMyGrid() == null ) - { - final GridPropagator gp = new GridPropagator( a.getInternalGrid() ); - bNode.beginVisit( gp ); - } - else if( connection.isNetworkABetter( a, b ) ) - { - final GridPropagator gp = new GridPropagator( a.getInternalGrid() ); - b.beginVisit( gp ); - } - else - { - final GridPropagator gp = new GridPropagator( b.getInternalGrid() ); - a.beginVisit( gp ); - } - } + // a connection was destroyed RE-PATH!! + final IPathingGrid p = connection.sideA.getInternalGrid().getCache(IPathingGrid.class); + p.repath(); - // a connection was destroyed RE-PATH!! - final IPathingGrid p = connection.sideA.getInternalGrid().getCache( IPathingGrid.class ); - p.repath(); + connection.sideA.addConnection(connection); + connection.sideB.addConnection(connection); - connection.sideA.addConnection( connection ); - connection.sideB.addConnection( connection ); - - return connection; - } + return connection; + } } diff --git a/src/main/java/appeng/me/GridException.java b/src/main/java/appeng/me/GridException.java index 5a3f418b7..590868b0e 100644 --- a/src/main/java/appeng/me/GridException.java +++ b/src/main/java/appeng/me/GridException.java @@ -18,15 +18,12 @@ package appeng.me; +public class GridException extends RuntimeException { -public class GridException extends RuntimeException -{ + private static final long serialVersionUID = -8110077032108243076L; - private static final long serialVersionUID = -8110077032108243076L; + public GridException(final String s) { - public GridException( final String s ) - { - - super( s ); - } + super(s); + } } diff --git a/src/main/java/appeng/me/GridNode.java b/src/main/java/appeng/me/GridNode.java index e0eef4b7c..4c8a31c9c 100644 --- a/src/main/java/appeng/me/GridNode.java +++ b/src/main/java/appeng/me/GridNode.java @@ -18,7 +18,6 @@ package appeng.me; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; @@ -60,691 +59,559 @@ import appeng.me.pathfinding.IPathItem; import appeng.util.IWorldCallable; import appeng.util.ReadOnlyCollection; - -public class GridNode implements IGridNode, IPathItem -{ - private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged(); - private static final int[] CHANNEL_COUNT = { 0, 8, 32 }; - - private final List connections = new ArrayList<>(); - private final IGridBlock gridProxy; - // old power draw, used to diff - private double previousDraw = 0.0; - private long lastSecurityKey = -1; - private int playerID = -1; - private GridStorage myStorage = null; - private Grid myGrid; - private Object visitorIterationNumber = null; - // connection criteria - private int compressedData = 0; - private int usedChannels = 0; - private int lastUsedChannels = 0; - - public GridNode( final IGridBlock what ) - { - this.gridProxy = what; - } - - IGridBlock getGridProxy() - { - return this.gridProxy; - } - - Grid getMyGrid() - { - return this.myGrid; - } - - public int usedChannels() - { - return this.lastUsedChannels; - } - - Class getMachineClass() - { - return this.getMachine().getClass(); - } - - void addConnection( final IGridConnection gridConnection ) - { - this.connections.add( gridConnection ); - if( gridConnection.hasDirection() ) - { - this.gridProxy.onGridNotification( GridNotification.CONNECTIONS_CHANGED ); - } - - final IGridNode gn = this; - - Collections.sort( this.connections, new ConnectionComparator( gn ) ); - } - - void removeConnection( final IGridConnection gridConnection ) - { - this.connections.remove( gridConnection ); - if( gridConnection.hasDirection() ) - { - this.gridProxy.onGridNotification( GridNotification.CONNECTIONS_CHANGED ); - } - } - - boolean hasConnection( final IGridNode otherSide ) - { - for( final IGridConnection gc : this.connections ) - { - if( gc.a() == otherSide || gc.b() == otherSide ) - { - return true; - } - } - return false; - } - - void validateGrid() - { - final GridSplitDetector gsd = new GridSplitDetector( this.getInternalGrid().getPivot() ); - this.beginVisit( gsd ); - if( !gsd.isPivotFound() ) - { - final IGridVisitor gp = new GridPropagator( new Grid( this ) ); - this.beginVisit( gp ); - } - } - - public Grid getInternalGrid() - { - if( this.myGrid == null ) - { - this.myGrid = new Grid( this ); - } - - return this.myGrid; - } - - @Override - public void beginVisit( final IGridVisitor g ) - { - final Object tracker = new Object(); - - Deque nextRun = new ArrayDeque<>(); - nextRun.add( this ); - - this.visitorIterationNumber = tracker; - - if( g instanceof IGridConnectionVisitor ) - { - final Deque nextConn = new ArrayDeque<>(); - final IGridConnectionVisitor gcv = (IGridConnectionVisitor) g; - - while( !nextRun.isEmpty() ) - { - while( !nextConn.isEmpty() ) - { - gcv.visitConnection( nextConn.poll() ); - } - - final Iterable thisRun = nextRun; - nextRun = new ArrayDeque<>(); - - for( final GridNode n : thisRun ) - { - n.visitorConnection( tracker, g, nextRun, nextConn ); - } - } - } - else - { - while( !nextRun.isEmpty() ) - { - final Iterable thisRun = nextRun; - nextRun = new ArrayDeque<>(); - - for( final GridNode n : thisRun ) - { - n.visitorNode( tracker, g, nextRun ); - } - } - } - } - - @Override - public void updateState() - { - final EnumSet set = this.gridProxy.getFlags(); - - this.compressedData = set.contains( GridFlags.CANNOT_CARRY ) ? 0 : ( set.contains( GridFlags.DENSE_CAPACITY ) ? 2 : 1 ); - - this.compressedData |= ( this.gridProxy.getGridColor().ordinal() << 3 ); - - for( final Direction dir : this.gridProxy.getConnectableSides() ) - { - this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) ); - } - - this.findConnections(); - this.getInternalGrid(); - } - - @Override - public IGridHost getMachine() - { - return this.gridProxy.getMachine(); - } - - @Override - public IGrid getGrid() - { - return this.myGrid; - } - - void setGrid( final Grid grid ) - { - if( this.myGrid == grid ) - { - return; - } - - if( this.myGrid != null ) - { - this.myGrid.remove( this ); - - if( this.myGrid.isEmpty() ) - { - this.myGrid.saveState(); - - for( final IGridCache c : grid.getCaches().values() ) - { - c.onJoin( this.myGrid.getMyStorage() ); - } - } - } - - this.myGrid = grid; - this.myGrid.add( this ); - } - - @Override - public void destroy() - { - while( !this.connections.isEmpty() ) - { - // not part of this network for real anymore. - if( this.connections.size() == 1 ) - { - this.setGridStorage( null ); - } - - final IGridConnection c = this.connections.listIterator().next(); - final GridNode otherSide = (GridNode) c.getOtherSide( this ); - otherSide.getInternalGrid().setPivot( otherSide ); - c.destroy(); - } - - if( this.myGrid != null ) - { - this.myGrid.remove( this ); - } - } - - @Override - public IWorld getWorld() - { - return this.gridProxy.getLocation().getWorld(); - } - - @Override - public EnumSet getConnectedSides() - { - final EnumSet set = EnumSet.noneOf( AEPartLocation.class ); - for( final IGridConnection gc : this.connections ) - { - set.add( gc.getDirection( this ) ); - } - return set; - } - - @Override - public IReadOnlyCollection getConnections() - { - return new ReadOnlyCollection<>( this.connections ); - } - - @Override - public IGridBlock getGridBlock() - { - return this.gridProxy; - } - - @Override - public boolean isActive() - { - final IGrid g = this.getGrid(); - if( g != null ) - { - final IPathingGrid pg = g.getCache( IPathingGrid.class ); - final IEnergyGrid eg = g.getCache( IEnergyGrid.class ); - return eg.isNetworkPowered() && !pg.isNetworkBooting() && this.meetsChannelRequirements(); - } - return false; - } - - @Override - public void loadFromNBT( final String name, final CompoundNBT nodeData ) - { - if( this.myGrid == null ) - { - final CompoundNBT node = nodeData.getCompound( name ); - this.playerID = node.getInt( "p" ); - this.setLastSecurityKey( node.getLong( "k" ) ); - - final long storageID = node.getLong( "g" ); - final GridStorage gridStorage = WorldData.instance().storageData().getGridStorage( storageID ); - this.setGridStorage( gridStorage ); - } - else - { - throw new IllegalStateException( "Loading data after part of a grid, this is invalid." ); - } - } - - @Override - public void saveToNBT( final String name, final CompoundNBT nodeData ) - { - if( this.myStorage != null ) - { - final CompoundNBT node = new CompoundNBT(); - - node.putInt( "p", this.playerID ); - node.putLong( "k", this.getLastSecurityKey() ); - node.putLong( "g", this.myStorage.getID() ); - - nodeData.put( name, node ); - } - else - { - nodeData.remove( name ); - } - } - - @Override - public boolean meetsChannelRequirements() - { - return( !this.gridProxy.getFlags().contains( GridFlags.REQUIRE_CHANNEL ) || this.getUsedChannels() > 0 ); - } - - @Override - public boolean hasFlag( final GridFlags flag ) - { - return this.gridProxy.getFlags().contains( flag ); - } - - @Override - public int getPlayerID() - { - return this.playerID; - } - - @Override - public void setPlayerID( final int playerID ) - { - if( playerID >= 0 ) - { - this.playerID = playerID; - } - } - - private int getUsedChannels() - { - return this.usedChannels; - } - - private void findConnections() - { - if( !this.gridProxy.isWorldAccessible() ) - { - return; - } - - final EnumSet newSecurityConnections = EnumSet.noneOf( AEPartLocation.class ); - - final DimensionalCoord dc = this.gridProxy.getLocation(); - for( final AEPartLocation f : AEPartLocation.SIDE_LOCATIONS ) - { - final IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.xOffset, dc.y + f.yOffset, dc.z + f.zOffset ); - if( te != null ) - { - final GridNode node = (GridNode) te.getGridNode( f.getOpposite() ); - if( node == null ) - { - continue; - } - - final boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() ); - - IGridConnection con = null; // find the connection for this - // direction.. - for( final IGridConnection c : this.getConnections() ) - { - if( c.getDirection( this ) == f ) - { - con = c; - break; - } - } - - if( con != null ) - { - final IGridNode os = con.getOtherSide( this ); - if( os == node ) - { - // if this connection is no longer valid, destroy it. - if( !isValidConnection ) - { - con.destroy(); - } - } - else - { - con.destroy(); - // throw new GridException( "invalid state found, encountered connection to phantom block." ); - } - } - else if( isValidConnection ) - { - if( node.getLastSecurityKey() != -1 ) - { - newSecurityConnections.add( f ); - } - else - { - // construct a new connection between these two nodes. - try - { - GridConnection.create( node, this, f.getOpposite() ); - } - catch( SecurityConnectionException e ) - { - AELog.debug( e ); - TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) ); - - return; - } - catch( final FailedConnectionException e ) - { - AELog.debug( e ); - - return; - } - } - } - } - } - - for( final AEPartLocation f : newSecurityConnections ) - { - final IGridHost te = this.findGridHost( dc.getWorld(), dc.x + f.xOffset, dc.y + f.yOffset, dc.z + f.zOffset ); - if( te != null ) - { - final GridNode node = (GridNode) te.getGridNode( f.getOpposite() ); - if( node == null ) - { - continue; - } - - // construct a new connection between these two nodes. - try - { - GridConnection.create( node, this, f.getOpposite() ); - } - catch( SecurityConnectionException e ) - { - AELog.debug( e ); - - TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) ); - - return; - } - catch( final FailedConnectionException e ) - { - AELog.debug( e ); - - return; - } - } - } - } - - private IGridHost findGridHost( final IWorld world, final int x, final int y, final int z ) - { - final BlockPos pos = new BlockPos( x, y, z ); - if( world.isBlockLoaded( pos ) ) - { - final TileEntity te = world.getTileEntity( pos ); - if( te instanceof IGridHost ) - { - return (IGridHost) te; - } - } - return null; - } - - private boolean canConnect( final GridNode from, final AEPartLocation dir ) - { - if( !this.isValidDirection( dir ) ) - { - return false; - } - - if( !from.getColor().matches( this.getColor() ) ) - { - return false; - } - - return true; - } - - private boolean isValidDirection( final AEPartLocation dir ) - { - return ( this.compressedData & ( 1 << ( 8 + dir.ordinal() ) ) ) > 0; - } - - private AEColor getColor() - { - return AEColor.values()[( this.compressedData >> 3 ) & 0x1F]; - } - - private void visitorConnection( final Object tracker, final IGridVisitor g, final Deque nextRun, final Deque nextConnections ) - { - if( g.visitNode( this ) ) - { - for( final IGridConnection gc : this.getConnections() ) - { - final GridNode gn = (GridNode) gc.getOtherSide( this ); - final GridConnection gcc = (GridConnection) gc; - - if( gcc.getVisitorIterationNumber() != tracker ) - { - gcc.setVisitorIterationNumber( tracker ); - nextConnections.add( gc ); - } - - if( tracker == gn.visitorIterationNumber ) - { - continue; - } - - gn.visitorIterationNumber = tracker; - - nextRun.add( gn ); - } - } - } - - private void visitorNode( final Object tracker, final IGridVisitor g, final Deque nextRun ) - { - if( g.visitNode( this ) ) - { - for( final IGridConnection gc : this.getConnections() ) - { - final GridNode gn = (GridNode) gc.getOtherSide( this ); - - if( tracker == gn.visitorIterationNumber ) - { - continue; - } - - gn.visitorIterationNumber = tracker; - - nextRun.add( gn ); - } - } - } - - GridStorage getGridStorage() - { - return this.myStorage; - } - - void setGridStorage( final GridStorage s ) - { - this.myStorage = s; - this.usedChannels = 0; - this.lastUsedChannels = 0; - } - - @Override - public IPathItem getControllerRoute() - { - if( this.connections.isEmpty() || this.getFlags().contains( GridFlags.CANNOT_CARRY ) ) - { - return null; - } - - return (IPathItem) this.connections.get( 0 ); - } - - @Override - public void setControllerRoute( final IPathItem fast, final boolean zeroOut ) - { - if( zeroOut ) - { - this.usedChannels = 0; - } - - final int idx = this.connections.indexOf( fast ); - if( idx > 0 ) - { - this.connections.remove( fast ); - this.connections.add( 0, (IGridConnection) fast ); - } - } - - @Override - public boolean canSupportMoreChannels() - { - return this.getUsedChannels() < this.getMaxChannels(); - } - - private int getMaxChannels() - { - return CHANNEL_COUNT[this.compressedData & 0x03]; - } - - @Override - public IReadOnlyCollection getPossibleOptions() - { - return (IReadOnlyCollection) this.getConnections(); - } - - @Override - public void incrementChannelCount( final int usedChannels ) - { - this.usedChannels += usedChannels; - } - - @Override - public EnumSet getFlags() - { - return this.gridProxy.getFlags(); - } - - @Override - public void finalizeChannels() - { - if( this.getFlags().contains( GridFlags.CANNOT_CARRY ) ) - { - return; - } - - if( this.getLastUsedChannels() != this.getUsedChannels() ) - { - this.lastUsedChannels = this.usedChannels; - - if( this.getInternalGrid() != null ) - { - this.getInternalGrid().postEventTo( this, EVENT ); - } - } - } - - private int getLastUsedChannels() - { - return this.lastUsedChannels; - } - - public long getLastSecurityKey() - { - return this.lastSecurityKey; - } - - public void setLastSecurityKey( final long lastSecurityKey ) - { - this.lastSecurityKey = lastSecurityKey; - } - - public double getPreviousDraw() - { - return this.previousDraw; - } - - public void setPreviousDraw( final double previousDraw ) - { - this.previousDraw = previousDraw; - } - - private static class MachineSecurityBreak implements IWorldCallable - { - private final GridNode node; - - public MachineSecurityBreak( final GridNode node ) - { - this.node = node; - } - - @Override - public Void call( final World world ) throws Exception - { - this.node.getMachine().securityBreak(); - - return null; - } - } - - private static class ConnectionComparator implements Comparator - { - private final IGridNode gn; - - public ConnectionComparator( final IGridNode gn ) - { - this.gn = gn; - } - - @Override - public int compare( final IGridConnection o1, final IGridConnection o2 ) - { - final boolean preferredA = o1.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED ); - final boolean preferredB = o2.getOtherSide( this.gn ).hasFlag( GridFlags.PREFERRED ); - - return preferredA == preferredB ? 0 : ( preferredA ? -1 : 1 ); - } - } +public class GridNode implements IGridNode, IPathItem { + private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged(); + private static final int[] CHANNEL_COUNT = { 0, 8, 32 }; + + private final List connections = new ArrayList<>(); + private final IGridBlock gridProxy; + // old power draw, used to diff + private double previousDraw = 0.0; + private long lastSecurityKey = -1; + private int playerID = -1; + private GridStorage myStorage = null; + private Grid myGrid; + private Object visitorIterationNumber = null; + // connection criteria + private int compressedData = 0; + private int usedChannels = 0; + private int lastUsedChannels = 0; + + public GridNode(final IGridBlock what) { + this.gridProxy = what; + } + + IGridBlock getGridProxy() { + return this.gridProxy; + } + + Grid getMyGrid() { + return this.myGrid; + } + + public int usedChannels() { + return this.lastUsedChannels; + } + + Class getMachineClass() { + return this.getMachine().getClass(); + } + + void addConnection(final IGridConnection gridConnection) { + this.connections.add(gridConnection); + if (gridConnection.hasDirection()) { + this.gridProxy.onGridNotification(GridNotification.CONNECTIONS_CHANGED); + } + + final IGridNode gn = this; + + Collections.sort(this.connections, new ConnectionComparator(gn)); + } + + void removeConnection(final IGridConnection gridConnection) { + this.connections.remove(gridConnection); + if (gridConnection.hasDirection()) { + this.gridProxy.onGridNotification(GridNotification.CONNECTIONS_CHANGED); + } + } + + boolean hasConnection(final IGridNode otherSide) { + for (final IGridConnection gc : this.connections) { + if (gc.a() == otherSide || gc.b() == otherSide) { + return true; + } + } + return false; + } + + void validateGrid() { + final GridSplitDetector gsd = new GridSplitDetector(this.getInternalGrid().getPivot()); + this.beginVisit(gsd); + if (!gsd.isPivotFound()) { + final IGridVisitor gp = new GridPropagator(new Grid(this)); + this.beginVisit(gp); + } + } + + public Grid getInternalGrid() { + if (this.myGrid == null) { + this.myGrid = new Grid(this); + } + + return this.myGrid; + } + + @Override + public void beginVisit(final IGridVisitor g) { + final Object tracker = new Object(); + + Deque nextRun = new ArrayDeque<>(); + nextRun.add(this); + + this.visitorIterationNumber = tracker; + + if (g instanceof IGridConnectionVisitor) { + final Deque nextConn = new ArrayDeque<>(); + final IGridConnectionVisitor gcv = (IGridConnectionVisitor) g; + + while (!nextRun.isEmpty()) { + while (!nextConn.isEmpty()) { + gcv.visitConnection(nextConn.poll()); + } + + final Iterable thisRun = nextRun; + nextRun = new ArrayDeque<>(); + + for (final GridNode n : thisRun) { + n.visitorConnection(tracker, g, nextRun, nextConn); + } + } + } else { + while (!nextRun.isEmpty()) { + final Iterable thisRun = nextRun; + nextRun = new ArrayDeque<>(); + + for (final GridNode n : thisRun) { + n.visitorNode(tracker, g, nextRun); + } + } + } + } + + @Override + public void updateState() { + final EnumSet set = this.gridProxy.getFlags(); + + this.compressedData = set.contains(GridFlags.CANNOT_CARRY) ? 0 + : (set.contains(GridFlags.DENSE_CAPACITY) ? 2 : 1); + + this.compressedData |= (this.gridProxy.getGridColor().ordinal() << 3); + + for (final Direction dir : this.gridProxy.getConnectableSides()) { + this.compressedData |= (1 << (dir.ordinal() + 8)); + } + + this.findConnections(); + this.getInternalGrid(); + } + + @Override + public IGridHost getMachine() { + return this.gridProxy.getMachine(); + } + + @Override + public IGrid getGrid() { + return this.myGrid; + } + + void setGrid(final Grid grid) { + if (this.myGrid == grid) { + return; + } + + if (this.myGrid != null) { + this.myGrid.remove(this); + + if (this.myGrid.isEmpty()) { + this.myGrid.saveState(); + + for (final IGridCache c : grid.getCaches().values()) { + c.onJoin(this.myGrid.getMyStorage()); + } + } + } + + this.myGrid = grid; + this.myGrid.add(this); + } + + @Override + public void destroy() { + while (!this.connections.isEmpty()) { + // not part of this network for real anymore. + if (this.connections.size() == 1) { + this.setGridStorage(null); + } + + final IGridConnection c = this.connections.listIterator().next(); + final GridNode otherSide = (GridNode) c.getOtherSide(this); + otherSide.getInternalGrid().setPivot(otherSide); + c.destroy(); + } + + if (this.myGrid != null) { + this.myGrid.remove(this); + } + } + + @Override + public IWorld getWorld() { + return this.gridProxy.getLocation().getWorld(); + } + + @Override + public EnumSet getConnectedSides() { + final EnumSet set = EnumSet.noneOf(AEPartLocation.class); + for (final IGridConnection gc : this.connections) { + set.add(gc.getDirection(this)); + } + return set; + } + + @Override + public IReadOnlyCollection getConnections() { + return new ReadOnlyCollection<>(this.connections); + } + + @Override + public IGridBlock getGridBlock() { + return this.gridProxy; + } + + @Override + public boolean isActive() { + final IGrid g = this.getGrid(); + if (g != null) { + final IPathingGrid pg = g.getCache(IPathingGrid.class); + final IEnergyGrid eg = g.getCache(IEnergyGrid.class); + return eg.isNetworkPowered() && !pg.isNetworkBooting() && this.meetsChannelRequirements(); + } + return false; + } + + @Override + public void loadFromNBT(final String name, final CompoundNBT nodeData) { + if (this.myGrid == null) { + final CompoundNBT node = nodeData.getCompound(name); + this.playerID = node.getInt("p"); + this.setLastSecurityKey(node.getLong("k")); + + final long storageID = node.getLong("g"); + final GridStorage gridStorage = WorldData.instance().storageData().getGridStorage(storageID); + this.setGridStorage(gridStorage); + } else { + throw new IllegalStateException("Loading data after part of a grid, this is invalid."); + } + } + + @Override + public void saveToNBT(final String name, final CompoundNBT nodeData) { + if (this.myStorage != null) { + final CompoundNBT node = new CompoundNBT(); + + node.putInt("p", this.playerID); + node.putLong("k", this.getLastSecurityKey()); + node.putLong("g", this.myStorage.getID()); + + nodeData.put(name, node); + } else { + nodeData.remove(name); + } + } + + @Override + public boolean meetsChannelRequirements() { + return (!this.gridProxy.getFlags().contains(GridFlags.REQUIRE_CHANNEL) || this.getUsedChannels() > 0); + } + + @Override + public boolean hasFlag(final GridFlags flag) { + return this.gridProxy.getFlags().contains(flag); + } + + @Override + public int getPlayerID() { + return this.playerID; + } + + @Override + public void setPlayerID(final int playerID) { + if (playerID >= 0) { + this.playerID = playerID; + } + } + + private int getUsedChannels() { + return this.usedChannels; + } + + private void findConnections() { + if (!this.gridProxy.isWorldAccessible()) { + return; + } + + final EnumSet newSecurityConnections = EnumSet.noneOf(AEPartLocation.class); + + final DimensionalCoord dc = this.gridProxy.getLocation(); + for (final AEPartLocation f : AEPartLocation.SIDE_LOCATIONS) { + final IGridHost te = this.findGridHost(dc.getWorld(), dc.x + f.xOffset, dc.y + f.yOffset, dc.z + f.zOffset); + if (te != null) { + final GridNode node = (GridNode) te.getGridNode(f.getOpposite()); + if (node == null) { + continue; + } + + final boolean isValidConnection = this.canConnect(node, f) && node.canConnect(this, f.getOpposite()); + + IGridConnection con = null; // find the connection for this + // direction.. + for (final IGridConnection c : this.getConnections()) { + if (c.getDirection(this) == f) { + con = c; + break; + } + } + + if (con != null) { + final IGridNode os = con.getOtherSide(this); + if (os == node) { + // if this connection is no longer valid, destroy it. + if (!isValidConnection) { + con.destroy(); + } + } else { + con.destroy(); + // throw new GridException( "invalid state found, encountered connection to + // phantom block." ); + } + } else if (isValidConnection) { + if (node.getLastSecurityKey() != -1) { + newSecurityConnections.add(f); + } else { + // construct a new connection between these two nodes. + try { + GridConnection.create(node, this, f.getOpposite()); + } catch (SecurityConnectionException e) { + AELog.debug(e); + TickHandler.INSTANCE.addCallable(node.getWorld(), new MachineSecurityBreak(this)); + + return; + } catch (final FailedConnectionException e) { + AELog.debug(e); + + return; + } + } + } + } + } + + for (final AEPartLocation f : newSecurityConnections) { + final IGridHost te = this.findGridHost(dc.getWorld(), dc.x + f.xOffset, dc.y + f.yOffset, dc.z + f.zOffset); + if (te != null) { + final GridNode node = (GridNode) te.getGridNode(f.getOpposite()); + if (node == null) { + continue; + } + + // construct a new connection between these two nodes. + try { + GridConnection.create(node, this, f.getOpposite()); + } catch (SecurityConnectionException e) { + AELog.debug(e); + + TickHandler.INSTANCE.addCallable(node.getWorld(), new MachineSecurityBreak(this)); + + return; + } catch (final FailedConnectionException e) { + AELog.debug(e); + + return; + } + } + } + } + + private IGridHost findGridHost(final IWorld world, final int x, final int y, final int z) { + final BlockPos pos = new BlockPos(x, y, z); + if (world.isBlockLoaded(pos)) { + final TileEntity te = world.getTileEntity(pos); + if (te instanceof IGridHost) { + return (IGridHost) te; + } + } + return null; + } + + private boolean canConnect(final GridNode from, final AEPartLocation dir) { + if (!this.isValidDirection(dir)) { + return false; + } + + if (!from.getColor().matches(this.getColor())) { + return false; + } + + return true; + } + + private boolean isValidDirection(final AEPartLocation dir) { + return (this.compressedData & (1 << (8 + dir.ordinal()))) > 0; + } + + private AEColor getColor() { + return AEColor.values()[(this.compressedData >> 3) & 0x1F]; + } + + private void visitorConnection(final Object tracker, final IGridVisitor g, final Deque nextRun, + final Deque nextConnections) { + if (g.visitNode(this)) { + for (final IGridConnection gc : this.getConnections()) { + final GridNode gn = (GridNode) gc.getOtherSide(this); + final GridConnection gcc = (GridConnection) gc; + + if (gcc.getVisitorIterationNumber() != tracker) { + gcc.setVisitorIterationNumber(tracker); + nextConnections.add(gc); + } + + if (tracker == gn.visitorIterationNumber) { + continue; + } + + gn.visitorIterationNumber = tracker; + + nextRun.add(gn); + } + } + } + + private void visitorNode(final Object tracker, final IGridVisitor g, final Deque nextRun) { + if (g.visitNode(this)) { + for (final IGridConnection gc : this.getConnections()) { + final GridNode gn = (GridNode) gc.getOtherSide(this); + + if (tracker == gn.visitorIterationNumber) { + continue; + } + + gn.visitorIterationNumber = tracker; + + nextRun.add(gn); + } + } + } + + GridStorage getGridStorage() { + return this.myStorage; + } + + void setGridStorage(final GridStorage s) { + this.myStorage = s; + this.usedChannels = 0; + this.lastUsedChannels = 0; + } + + @Override + public IPathItem getControllerRoute() { + if (this.connections.isEmpty() || this.getFlags().contains(GridFlags.CANNOT_CARRY)) { + return null; + } + + return (IPathItem) this.connections.get(0); + } + + @Override + public void setControllerRoute(final IPathItem fast, final boolean zeroOut) { + if (zeroOut) { + this.usedChannels = 0; + } + + final int idx = this.connections.indexOf(fast); + if (idx > 0) { + this.connections.remove(fast); + this.connections.add(0, (IGridConnection) fast); + } + } + + @Override + public boolean canSupportMoreChannels() { + return this.getUsedChannels() < this.getMaxChannels(); + } + + private int getMaxChannels() { + return CHANNEL_COUNT[this.compressedData & 0x03]; + } + + @Override + public IReadOnlyCollection getPossibleOptions() { + return (IReadOnlyCollection) this.getConnections(); + } + + @Override + public void incrementChannelCount(final int usedChannels) { + this.usedChannels += usedChannels; + } + + @Override + public EnumSet getFlags() { + return this.gridProxy.getFlags(); + } + + @Override + public void finalizeChannels() { + if (this.getFlags().contains(GridFlags.CANNOT_CARRY)) { + return; + } + + if (this.getLastUsedChannels() != this.getUsedChannels()) { + this.lastUsedChannels = this.usedChannels; + + if (this.getInternalGrid() != null) { + this.getInternalGrid().postEventTo(this, EVENT); + } + } + } + + private int getLastUsedChannels() { + return this.lastUsedChannels; + } + + public long getLastSecurityKey() { + return this.lastSecurityKey; + } + + public void setLastSecurityKey(final long lastSecurityKey) { + this.lastSecurityKey = lastSecurityKey; + } + + public double getPreviousDraw() { + return this.previousDraw; + } + + public void setPreviousDraw(final double previousDraw) { + this.previousDraw = previousDraw; + } + + private static class MachineSecurityBreak implements IWorldCallable { + private final GridNode node; + + public MachineSecurityBreak(final GridNode node) { + this.node = node; + } + + @Override + public Void call(final World world) throws Exception { + this.node.getMachine().securityBreak(); + + return null; + } + } + + private static class ConnectionComparator implements Comparator { + private final IGridNode gn; + + public ConnectionComparator(final IGridNode gn) { + this.gn = gn; + } + + @Override + public int compare(final IGridConnection o1, final IGridConnection o2) { + final boolean preferredA = o1.getOtherSide(this.gn).hasFlag(GridFlags.PREFERRED); + final boolean preferredB = o2.getOtherSide(this.gn).hasFlag(GridFlags.PREFERRED); + + return preferredA == preferredB ? 0 : (preferredA ? -1 : 1); + } + } } diff --git a/src/main/java/appeng/me/GridNodeCollection.java b/src/main/java/appeng/me/GridNodeCollection.java index e0a8515bd..6d8453d82 100644 --- a/src/main/java/appeng/me/GridNodeCollection.java +++ b/src/main/java/appeng/me/GridNodeCollection.java @@ -18,7 +18,6 @@ package appeng.me; - import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -27,69 +26,56 @@ import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.util.IReadOnlyCollection; +public class GridNodeCollection implements IReadOnlyCollection { + private final Map, MachineSet> machines; -public class GridNodeCollection implements IReadOnlyCollection -{ - private final Map, MachineSet> machines; + public GridNodeCollection(final Map, MachineSet> machines) { + this.machines = machines; + } - public GridNodeCollection( final Map, MachineSet> machines ) - { - this.machines = machines; - } + @Override + public Iterator iterator() { + return new GridNodeIterator(this.machines); + } - @Override - public Iterator iterator() - { - return new GridNodeIterator( this.machines ); - } + @Override + public int size() { + int size = 0; - @Override - public int size() - { - int size = 0; + for (final Set o : this.machines.values()) { + size += o.size(); + } - for( final Set o : this.machines.values() ) - { - size += o.size(); - } + return size; + } - return size; - } + @Override + public boolean isEmpty() { + for (final Set o : this.machines.values()) { + if (!o.isEmpty()) { + return false; + } + } - @Override - public boolean isEmpty() - { - for( final Set o : this.machines.values() ) - { - if( !o.isEmpty() ) - { - return false; - } - } + return true; + } - return true; - } + @Override + public boolean contains(final Object maybeGridNode) { + final boolean doesContainNode; - @Override - public boolean contains( final Object maybeGridNode ) - { - final boolean doesContainNode; + if (maybeGridNode instanceof IGridNode) { + final IGridNode node = (IGridNode) maybeGridNode; + final IGridHost machine = node.getMachine(); + final Class machineClass = machine.getClass(); - if( maybeGridNode instanceof IGridNode ) - { - final IGridNode node = (IGridNode) maybeGridNode; - final IGridHost machine = node.getMachine(); - final Class machineClass = machine.getClass(); + final MachineSet machineSet = this.machines.get(machineClass); - final MachineSet machineSet = this.machines.get( machineClass ); + doesContainNode = machineSet != null && machineSet.contains(maybeGridNode); + } else { + doesContainNode = false; + } - doesContainNode = machineSet != null && machineSet.contains( maybeGridNode ); - } - else - { - doesContainNode = false; - } - - return doesContainNode; - } + return doesContainNode; + } } diff --git a/src/main/java/appeng/me/GridNodeIterator.java b/src/main/java/appeng/me/GridNodeIterator.java index e441aeb09..066a85dde 100644 --- a/src/main/java/appeng/me/GridNodeIterator.java +++ b/src/main/java/appeng/me/GridNodeIterator.java @@ -18,69 +18,56 @@ package appeng.me; - import java.util.Iterator; import java.util.Map; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; - /** * Nested iterator for {@link appeng.me.MachineSet} * - * Traverses first over the {@link appeng.me.MachineSet} and then over every containing - * {@link appeng.api.networking.IGridNode} + * Traverses first over the {@link appeng.me.MachineSet} and then over every + * containing {@link appeng.api.networking.IGridNode} */ -public class GridNodeIterator implements Iterator -{ - private final Iterator outerIterator; - private Iterator innerIterator; +public class GridNodeIterator implements Iterator { + private final Iterator outerIterator; + private Iterator innerIterator; - public GridNodeIterator( final Map, MachineSet> machines ) - { - this.outerIterator = machines.values().iterator(); - this.innerHasNext(); - } + public GridNodeIterator(final Map, MachineSet> machines) { + this.outerIterator = machines.values().iterator(); + this.innerHasNext(); + } - private boolean innerHasNext() - { - final boolean hasNext = this.outerIterator.hasNext(); + private boolean innerHasNext() { + final boolean hasNext = this.outerIterator.hasNext(); - if( hasNext ) - { - final MachineSet nextElem = this.outerIterator.next(); - this.innerIterator = nextElem.iterator(); - } + if (hasNext) { + final MachineSet nextElem = this.outerIterator.next(); + this.innerIterator = nextElem.iterator(); + } - return hasNext; - } + return hasNext; + } - @Override - public boolean hasNext() - { - while( true ) - { - if( this.innerIterator.hasNext() ) - { - return true; - } - else if( !this.innerHasNext() ) - { - return false; - } - } - } + @Override + public boolean hasNext() { + while (true) { + if (this.innerIterator.hasNext()) { + return true; + } else if (!this.innerHasNext()) { + return false; + } + } + } - @Override - public IGridNode next() - { - return this.innerIterator.next(); - } + @Override + public IGridNode next() { + return this.innerIterator.next(); + } - @Override - public void remove() - { - this.innerIterator.remove(); - } + @Override + public void remove() { + this.innerIterator.remove(); + } } diff --git a/src/main/java/appeng/me/GridPropagator.java b/src/main/java/appeng/me/GridPropagator.java index 4bc6c99fb..2e12292e8 100644 --- a/src/main/java/appeng/me/GridPropagator.java +++ b/src/main/java/appeng/me/GridPropagator.java @@ -18,30 +18,24 @@ package appeng.me; - import appeng.api.networking.IGridNode; import appeng.api.networking.IGridVisitor; +public class GridPropagator implements IGridVisitor { + private final Grid g; -public class GridPropagator implements IGridVisitor -{ - private final Grid g; + public GridPropagator(final Grid g) { + this.g = g; + } - public GridPropagator( final Grid g ) - { - this.g = g; - } + @Override + public boolean visitNode(final IGridNode n) { + final GridNode gn = (GridNode) n; + if (gn.getMyGrid() != this.g || this.g.getPivot() == n) { + gn.setGrid(this.g); - @Override - public boolean visitNode( final IGridNode n ) - { - final GridNode gn = (GridNode) n; - if( gn.getMyGrid() != this.g || this.g.getPivot() == n ) - { - gn.setGrid( this.g ); - - return true; - } - return false; - } + return true; + } + return false; + } } diff --git a/src/main/java/appeng/me/GridSplitDetector.java b/src/main/java/appeng/me/GridSplitDetector.java index ac0b98c7a..6bc747b8c 100644 --- a/src/main/java/appeng/me/GridSplitDetector.java +++ b/src/main/java/appeng/me/GridSplitDetector.java @@ -18,40 +18,32 @@ package appeng.me; - import appeng.api.networking.IGridNode; import appeng.api.networking.IGridVisitor; +class GridSplitDetector implements IGridVisitor { -class GridSplitDetector implements IGridVisitor -{ + private final IGridNode pivot; + private boolean pivotFound; - private final IGridNode pivot; - private boolean pivotFound; + public GridSplitDetector(final IGridNode pivot) { + this.pivot = pivot; + } - public GridSplitDetector( final IGridNode pivot ) - { - this.pivot = pivot; - } + @Override + public boolean visitNode(final IGridNode n) { + if (n == this.pivot) { + this.setPivotFound(true); + } - @Override - public boolean visitNode( final IGridNode n ) - { - if( n == this.pivot ) - { - this.setPivotFound( true ); - } + return !this.isPivotFound(); + } - return !this.isPivotFound(); - } + public boolean isPivotFound() { + return this.pivotFound; + } - public boolean isPivotFound() - { - return this.pivotFound; - } - - private void setPivotFound( final boolean pivotFound ) - { - this.pivotFound = pivotFound; - } + private void setPivotFound(final boolean pivotFound) { + this.pivotFound = pivotFound; + } } diff --git a/src/main/java/appeng/me/GridStorage.java b/src/main/java/appeng/me/GridStorage.java index 077bdcc28..3e2de69b0 100644 --- a/src/main/java/appeng/me/GridStorage.java +++ b/src/main/java/appeng/me/GridStorage.java @@ -18,99 +18,85 @@ package appeng.me; +import java.lang.ref.WeakReference; +import java.util.WeakHashMap; + +import net.minecraft.nbt.CompoundNBT; import appeng.api.networking.IGrid; import appeng.api.networking.IGridStorage; import appeng.core.worlddata.WorldData; -import net.minecraft.nbt.CompoundNBT; -import java.lang.ref.WeakReference; -import java.util.WeakHashMap; +public class GridStorage implements IGridStorage { + private final long myID; + private final CompoundNBT data; + private final WeakHashMap divided = new WeakHashMap<>(); + private WeakReference internalGrid = null; -public class GridStorage implements IGridStorage -{ + /** + * for use with world settings + * + * @param id ID of grid storage + */ + public GridStorage(final long id) { + this.myID = id; + this.data = new CompoundNBT(); + } - private final long myID; - private final CompoundNBT data; - private final WeakHashMap divided = new WeakHashMap<>(); - private WeakReference internalGrid = null; + /** + * for use with world settings + * + * @param data The Grid data. + * @param id ID of grid storage + */ + public GridStorage(final long id, final CompoundNBT data) { + this.myID = id; + this.data = data; + } - /** - * for use with world settings - * - * @param id ID of grid storage - */ - public GridStorage( final long id ) - { - this.myID = id; - this.data = new CompoundNBT(); - } + /** + * fake storage. + */ + public GridStorage() { + this.myID = 0; + this.data = new CompoundNBT(); + } - /** - * for use with world settings - * - * @param data The Grid data. - * @param id ID of grid storage - */ - public GridStorage( final long id, final CompoundNBT data ) - { - this.myID = id; - this.data = data; - } + public void saveState() { + final Grid currentGrid = (Grid) this.getGrid(); + if (currentGrid != null) { + currentGrid.saveState(); + } + } - /** - * fake storage. - */ - public GridStorage() - { - this.myID = 0; - this.data = new CompoundNBT(); - } + public IGrid getGrid() { + return this.internalGrid == null ? null : this.internalGrid.get(); + } - public void saveState() - { - final Grid currentGrid = (Grid) this.getGrid(); - if( currentGrid != null ) - { - currentGrid.saveState(); - } - } + void setGrid(final IGrid grid) { + this.internalGrid = new WeakReference<>(grid); + } - public IGrid getGrid() - { - return this.internalGrid == null ? null : this.internalGrid.get(); - } + @Override + public CompoundNBT dataObject() { + return this.data; + } - void setGrid( final IGrid grid ) - { - this.internalGrid = new WeakReference<>( grid ); - } + @Override + public long getID() { + return this.myID; + } - @Override - public CompoundNBT dataObject() - { - return this.data; - } + void addDivided(final GridStorage gs) { + this.divided.put(gs, true); + } - @Override - public long getID() - { - return this.myID; - } + boolean hasDivided(final GridStorage myStorage) { + return this.divided.containsKey(myStorage); + } - void addDivided( final GridStorage gs ) - { - this.divided.put( gs, true ); - } - - boolean hasDivided( final GridStorage myStorage ) - { - return this.divided.containsKey( myStorage ); - } - - void remove() - { - WorldData.instance().storageData().destroyGridStorage( this.myID ); - } + void remove() { + WorldData.instance().storageData().destroyGridStorage(this.myID); + } } diff --git a/src/main/java/appeng/me/MachineSet.java b/src/main/java/appeng/me/MachineSet.java index f35209c53..966082441 100644 --- a/src/main/java/appeng/me/MachineSet.java +++ b/src/main/java/appeng/me/MachineSet.java @@ -18,29 +18,24 @@ package appeng.me; - import java.util.HashSet; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.IMachineSet; +public class MachineSet extends HashSet implements IMachineSet { -public class MachineSet extends HashSet implements IMachineSet -{ + private static final long serialVersionUID = 3224660708327386933L; - private static final long serialVersionUID = 3224660708327386933L; + private final Class machine; - private final Class machine; + MachineSet(final Class m) { + this.machine = m; + } - MachineSet( final Class m ) - { - this.machine = m; - } - - @Override - public Class getMachineClass() - { - return this.machine; - } + @Override + public Class getMachineClass() { + return this.machine; + } } diff --git a/src/main/java/appeng/me/NetworkEventBus.java b/src/main/java/appeng/me/NetworkEventBus.java index 55519baa9..3d22cb7ed 100644 --- a/src/main/java/appeng/me/NetworkEventBus.java +++ b/src/main/java/appeng/me/NetworkEventBus.java @@ -18,7 +18,6 @@ package appeng.me; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; @@ -34,196 +33,153 @@ import appeng.api.networking.events.MENetworkEvent; import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.core.AELog; +public class NetworkEventBus { + private static final Collection READ_CLASSES = new HashSet<>(); + private static final Map, Map> EVENTS = new HashMap<>(); -public class NetworkEventBus -{ - private static final Collection READ_CLASSES = new HashSet<>(); - private static final Map, Map> EVENTS = new HashMap<>(); + void readClass(final Class listAs, final Class c) { + if (READ_CLASSES.contains(c)) { + return; + } + READ_CLASSES.add(c); - void readClass( final Class listAs, final Class c ) - { - if( READ_CLASSES.contains( c ) ) - { - return; - } - READ_CLASSES.add( c ); + try { + for (final Method m : c.getMethods()) { + final MENetworkEventSubscribe s = m.getAnnotation(MENetworkEventSubscribe.class); + if (s != null) { + final Class[] types = m.getParameterTypes(); + if (types.length == 1) { + if (MENetworkEvent.class.isAssignableFrom(types[0])) { - try - { - for( final Method m : c.getMethods() ) - { - final MENetworkEventSubscribe s = m.getAnnotation( MENetworkEventSubscribe.class ); - if( s != null ) - { - final Class[] types = m.getParameterTypes(); - if( types.length == 1 ) - { - if( MENetworkEvent.class.isAssignableFrom( types[0] ) ) - { + Map classEvents = EVENTS.get(types[0]); + if (classEvents == null) { + EVENTS.put(types[0], classEvents = new HashMap<>()); + } - Map classEvents = EVENTS.get( types[0] ); - if( classEvents == null ) - { - EVENTS.put( types[0], classEvents = new HashMap<>() ); - } + MENetworkEventInfo thisEvent = classEvents.get(listAs); + if (thisEvent == null) { + thisEvent = new MENetworkEventInfo(); + } - MENetworkEventInfo thisEvent = classEvents.get( listAs ); - if( thisEvent == null ) - { - thisEvent = new MENetworkEventInfo(); - } + thisEvent.Add(types[0], c, m); - thisEvent.Add( types[0], c, m ); + classEvents.put(listAs, thisEvent); + } else { + throw new IllegalStateException("Invalid ME Network Event Subscriber, " + m.getName() + + "s Parameter must extend MENetworkEvent."); + } + } else { + throw new IllegalStateException("Invalid ME Network Event Subscriber, " + m.getName() + + " must have exactly 1 parameter."); + } + } + } + } catch (final Throwable t) { + throw new IllegalStateException("Error while adding " + c.getName() + " to event bus", t); + } + } - classEvents.put( listAs, thisEvent ); - } - else - { - throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m - .getName() + "s Parameter must extend MENetworkEvent." ); - } - } - else - { - throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + " must have exactly 1 parameter." ); - } - } - } - } - catch( final Throwable t ) - { - throw new IllegalStateException( "Error while adding " + c.getName() + " to event bus", t ); - } - } + MENetworkEvent postEvent(final Grid g, final MENetworkEvent e) { + final Map subscribers = EVENTS.get(e.getClass()); + int x = 0; - MENetworkEvent postEvent( final Grid g, final MENetworkEvent e ) - { - final Map subscribers = EVENTS.get( e.getClass() ); - int x = 0; + try { + if (subscribers != null) { + for (final Entry subscriber : subscribers.entrySet()) { + final MENetworkEventInfo target = subscriber.getValue(); + final GridCacheWrapper cache = g.getCaches().get(subscriber.getKey()); + if (cache != null) { + x++; + target.invoke(cache.getCache(), e); + } - try - { - if( subscribers != null ) - { - for( final Entry subscriber : subscribers.entrySet() ) - { - final MENetworkEventInfo target = subscriber.getValue(); - final GridCacheWrapper cache = g.getCaches().get( subscriber.getKey() ); - if( cache != null ) - { - x++; - target.invoke( cache.getCache(), e ); - } + // events may create or remove grid nodes in rare cases + final IMachineSet machines = g.getMachines(subscriber.getKey()); + final List work = new ArrayList<>(machines.size()); + machines.forEach(work::add); - // events may create or remove grid nodes in rare cases - final IMachineSet machines = g.getMachines( subscriber.getKey() ); - final List work = new ArrayList<>( machines.size() ); - machines.forEach( work::add ); + for (final IGridNode obj : work) { + // stil part of grid? + if (machines.contains(obj)) { + x++; + target.invoke(obj.getMachine(), e); + } + } + } + } + } catch (final NetworkEventDone done) { + // Early out. + } - for( final IGridNode obj : work ) - { - // stil part of grid? - if( machines.contains( obj ) ) - { - x++; - target.invoke( obj.getMachine(), e ); - } - } - } - } - } - catch( final NetworkEventDone done ) - { - // Early out. - } + e.setVisitedObjects(x); + return e; + } - e.setVisitedObjects( x ); - return e; - } + MENetworkEvent postEventTo(final Grid grid, final GridNode node, final MENetworkEvent e) { + final Map subscribers = EVENTS.get(e.getClass()); + int x = 0; - MENetworkEvent postEventTo( final Grid grid, final GridNode node, final MENetworkEvent e ) - { - final Map subscribers = EVENTS.get( e.getClass() ); - int x = 0; + try { + if (subscribers != null) { + final MENetworkEventInfo target = subscribers.get(node.getMachineClass()); + if (target != null) { + x++; + target.invoke(node.getMachine(), e); + } + } + } catch (final NetworkEventDone done) { + // Early out. + } - try - { - if( subscribers != null ) - { - final MENetworkEventInfo target = subscribers.get( node.getMachineClass() ); - if( target != null ) - { - x++; - target.invoke( node.getMachine(), e ); - } - } - } - catch( final NetworkEventDone done ) - { - // Early out. - } + e.setVisitedObjects(x); + return e; + } - e.setVisitedObjects( x ); - return e; - } + private static class NetworkEventDone extends Throwable { - private static class NetworkEventDone extends Throwable - { + private static final long serialVersionUID = -3079021487019171205L; + } - private static final long serialVersionUID = -3079021487019171205L; - } + private class EventMethod { - private class EventMethod - { + private final Class objClass; + private final Method objMethod; + private final Class objEvent; - private final Class objClass; - private final Method objMethod; - private final Class objEvent; + public EventMethod(final Class Event, final Class ObjClass, final Method ObjMethod) { + this.objClass = ObjClass; + this.objMethod = ObjMethod; + this.objEvent = Event; + } - public EventMethod( final Class Event, final Class ObjClass, final Method ObjMethod ) - { - this.objClass = ObjClass; - this.objMethod = ObjMethod; - this.objEvent = Event; - } + private void invoke(final Object obj, final MENetworkEvent e) throws NetworkEventDone { + try { + this.objMethod.invoke(obj, e); + } catch (final Throwable e1) { + AELog.error("[AppEng] Network Event caused exception:"); + AELog.error("Class: %1s, Object: %2s", obj.getClass().getName(), obj.toString()); + AELog.info(e1); + throw new IllegalStateException(e1); + } - private void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone - { - try - { - this.objMethod.invoke( obj, e ); - } - catch( final Throwable e1 ) - { - AELog.error( "[AppEng] Network Event caused exception:" ); - AELog.error( "Class: %1s, Object: %2s", obj.getClass().getName(), obj.toString() ); - AELog.info( e1 ); - throw new IllegalStateException( e1 ); - } + if (e.isCanceled()) { + throw new NetworkEventDone(); + } + } + } - if( e.isCanceled() ) - { - throw new NetworkEventDone(); - } - } - } + private class MENetworkEventInfo { - private class MENetworkEventInfo - { + private final List methods = new ArrayList<>(); - private final List methods = new ArrayList<>(); + private void Add(final Class Event, final Class ObjClass, final Method ObjMethod) { + this.methods.add(new EventMethod(Event, ObjClass, ObjMethod)); + } - private void Add( final Class Event, final Class ObjClass, final Method ObjMethod ) - { - this.methods.add( new EventMethod( Event, ObjClass, ObjMethod ) ); - } - - private void invoke( final Object obj, final MENetworkEvent e ) throws NetworkEventDone - { - for( final EventMethod em : this.methods ) - { - em.invoke( obj, e ); - } - } - } + private void invoke(final Object obj, final MENetworkEvent e) throws NetworkEventDone { + for (final EventMethod em : this.methods) { + em.invoke(obj, e); + } + } + } } diff --git a/src/main/java/appeng/me/cache/CraftingGridCache.java b/src/main/java/appeng/me/cache/CraftingGridCache.java index ccd3fc2bd..44aaa6918 100644 --- a/src/main/java/appeng/me/cache/CraftingGridCache.java +++ b/src/main/java/appeng/me/cache/CraftingGridCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -87,579 +86,487 @@ import appeng.me.helpers.GenericInterestManager; import appeng.tile.crafting.TileCraftingStorageTile; import appeng.tile.crafting.TileCraftingTile; - -public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler -{ - - private static final ExecutorService CRAFTING_POOL; - private static final Comparator COMPARATOR = ( firstDetail, nextDetail ) -> nextDetail.getPriority() - firstDetail.getPriority(); - - static - { - final ThreadFactory factory = ar -> new Thread( ar, "AE Crafting Calculator" ); - - CRAFTING_POOL = Executors.newCachedThreadPool( factory ); - } - - private final Set craftingCPUClusters = new HashSet<>(); - private final Set craftingProviders = new HashSet<>(); - private final Map craftingWatchers = new HashMap<>(); - private final IGrid grid; - private final Map> craftingMethods = new HashMap<>(); - private final Map> craftableItems = new HashMap<>(); - private final Set emitableItems = new HashSet<>(); - private final Map craftingLinks = new HashMap<>(); - private final Multimap interests = HashMultimap.create(); - private final GenericInterestManager interestManager = new GenericInterestManager<>( this.interests ); - private IStorageGrid storageGrid; - private IEnergyGrid energyGrid; - private boolean updateList = false; - - public CraftingGridCache( final IGrid grid ) - { - this.grid = grid; - } - - @MENetworkEventSubscribe - public void afterCacheConstruction( final MENetworkPostCacheConstruction cacheConstruction ) - { - this.storageGrid = this.grid.getCache( IStorageGrid.class ); - this.energyGrid = this.grid.getCache( IEnergyGrid.class ); - - this.storageGrid.registerCellProvider( this ); - } - - @Override - public void onUpdateTick() - { - if( this.updateList ) - { - this.updateList = false; - this.updateCPUClusters(); - } - - final Iterator craftingLinkIterator = this.craftingLinks.values().iterator(); - while( craftingLinkIterator.hasNext() ) - { - if( craftingLinkIterator.next().isDead( this.grid, this ) ) - { - craftingLinkIterator.remove(); - } - } - - for( final CraftingCPUCluster cpu : this.craftingCPUClusters ) - { - cpu.updateCraftingLogic( this.grid, this.energyGrid, this ); - } - } - - @Override - public void removeNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof ICraftingWatcherHost ) - { - final ICraftingWatcher craftingWatcher = this.craftingWatchers.get( machine ); - if( craftingWatcher != null ) - { - craftingWatcher.reset(); - this.craftingWatchers.remove( machine ); - } - } - - if( machine instanceof ICraftingRequester ) - { - for( final CraftingLinkNexus link : this.craftingLinks.values() ) - { - if( link.isMachine( machine ) ) - { - link.removeNode(); - } - } - } - - if( machine instanceof TileCraftingTile ) - { - this.updateList = true; - } - - if( machine instanceof ICraftingProvider ) - { - this.craftingProviders.remove( machine ); - this.updatePatterns(); - } - } - - @Override - public void addNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof ICraftingWatcherHost ) - { - final ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine; - final CraftingWatcher watcher = new CraftingWatcher( this, watcherHost ); - this.craftingWatchers.put( gridNode, watcher ); - watcherHost.updateWatcher( watcher ); - } - - if( machine instanceof ICraftingRequester ) - { - for( final ICraftingLink link : ( (ICraftingRequester) machine ).getRequestedJobs() ) - { - if( link instanceof CraftingLink ) - { - this.addLink( (CraftingLink) link ); - } - } - } - - if( machine instanceof TileCraftingTile ) - { - this.updateList = true; - } - - if( machine instanceof ICraftingProvider ) - { - this.craftingProviders.add( (ICraftingProvider) machine ); - this.updatePatterns(); - } - } - - @Override - public void onSplit( final IGridStorage destinationStorage ) - { // nothing! - } - - @Override - public void onJoin( final IGridStorage sourceStorage ) - { - // nothing! - } - - @Override - public void populateGridStorage( final IGridStorage destinationStorage ) - { - // nothing! - } - - private void updatePatterns() - { - final Map> oldItems = this.craftableItems; - - // erase list. - this.craftingMethods.clear(); - this.craftableItems.clear(); - this.emitableItems.clear(); - - // update the stuff that was in the list... - this.storageGrid.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), oldItems.keySet(), - new BaseActionSource() ); - - // re-create list.. - for( final ICraftingProvider provider : this.craftingProviders ) - { - provider.provideCrafting( this ); - } - - final Map> tmpCraft = new HashMap<>(); - - // new craftables! - for( final ICraftingPatternDetails details : this.craftingMethods.keySet() ) - { - for( IAEItemStack out : details.getOutputs() ) - { - out = out.copy(); - out.reset(); - out.setCraftable( true ); - - Set methods = tmpCraft.get( out ); - - if( methods == null ) - { - tmpCraft.put( out, methods = new TreeSet<>( COMPARATOR ) ); - } - - methods.add( details ); - } - } - - // make them immutable - for( final Entry> e : tmpCraft.entrySet() ) - { - this.craftableItems.put( e.getKey(), ImmutableList.copyOf( e.getValue() ) ); - } - - this.storageGrid.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), this.craftableItems.keySet(), - new BaseActionSource() ); - } - - private void updateCPUClusters() - { - this.craftingCPUClusters.clear(); - - for( final IGridNode cst : this.grid.getMachines( TileCraftingStorageTile.class ) ) - { - final TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine(); - final CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster(); - if( cluster != null ) - { - this.craftingCPUClusters.add( cluster ); - - if( cluster.getLastCraftingLink() != null ) - { - this.addLink( (CraftingLink) cluster.getLastCraftingLink() ); - } - } - } - - } - - public void addLink( final CraftingLink link ) - { - if( link.isStandalone() ) - { - return; - } - - CraftingLinkNexus nexus = this.craftingLinks.get( link.getCraftingID() ); - if( nexus == null ) - { - this.craftingLinks.put( link.getCraftingID(), nexus = new CraftingLinkNexus( link.getCraftingID() ) ); - } - - link.setNexus( nexus ); - } - - @MENetworkEventSubscribe - public void updateCPUClusters( final MENetworkCraftingCpuChange c ) - { - this.updateList = true; - } - - @MENetworkEventSubscribe - public void updateCPUClusters( final MENetworkCraftingPatternChange c ) - { - this.updatePatterns(); - } - - @Override - public void addCraftingOption( final ICraftingMedium medium, final ICraftingPatternDetails api ) - { - List details = this.craftingMethods.get( api ); - if( details == null ) - { - details = new ArrayList<>(); - details.add( medium ); - this.craftingMethods.put( api, details ); - } - else - { - details.add( medium ); - } - } - - @Override - public void setEmitable( final IAEItemStack someItem ) - { - this.emitableItems.add( someItem.copy() ); - } - - @Override - public List getCellArray( final IStorageChannel channel ) - { - final List list = new ArrayList<>( 1 ); - - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - list.add( this ); - } - - return list; - } - - @Override - public int getPriority() - { - return Integer.MAX_VALUE; - } - - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.WRITE; - } - - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - return true; - } - - @Override - public boolean canAccept( final IAEItemStack input ) - { - for( final CraftingCPUCluster cpu : this.craftingCPUClusters ) - { - if( cpu.canAccept( input ) ) - { - return true; - } - } - - return false; - } - - @Override - public int getSlot() - { - return 0; - } - - @Override - public boolean validForPass( final int i ) - { - return i == 1; - } - - @Override - public IAEItemStack injectItems( IAEItemStack input, final Actionable type, final IActionSource src ) - { - for( final CraftingCPUCluster cpu : this.craftingCPUClusters ) - { - input = cpu.injectItems( input, type, src ); - } - - return input; - } - - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - return null; - } - - @Override - public IItemList getAvailableItems( final IItemList out ) - { - // add craftable items! - for( final IAEItemStack stack : this.craftableItems.keySet() ) - { - out.addCrafting( stack ); - } - - for( final IAEItemStack st : this.emitableItems ) - { - out.addCrafting( st ); - } - - return out; - } - - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } - - @Override - public ImmutableCollection getCraftingFor( final IAEItemStack whatToCraft, final ICraftingPatternDetails details, final int slotIndex, final World world ) - { - final ImmutableList res = this.craftableItems.get( whatToCraft ); - - if( res == null ) - { - if( details != null && details.isCraftable() ) - { - for( final IAEItemStack ais : this.craftableItems.keySet() ) - { - if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().isDamageable() || ais.getItemDamage() == whatToCraft.getItemDamage() ) ) - { - // TODO: check if OK - // TODO: this is slightly hacky, but fine as long as we only deal with itemstacks - if( details.isValidItemForSlot( slotIndex, ais.asItemStackRepresentation(), world ) ) - { - return this.craftableItems.get( ais ); - } - } - } - } - - return ImmutableSet.of(); - } - - return res; - } - - @Override - public Future beginCraftingJob( final World world, final IGrid grid, final IActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb ) - { - if( world == null || grid == null || actionSrc == null || slotItem == null ) - { - throw new IllegalArgumentException( "Invalid Crafting Job Request" ); - } - - final CraftingJob job = new CraftingJob( world, grid, actionSrc, slotItem, cb ); - - return CRAFTING_POOL.submit( job, (ICraftingJob) job ); - } - - @Override - public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final IActionSource src ) - { - if( job.isSimulation() ) - { - return null; - } - - CraftingCPUCluster cpuCluster = null; - - if( target instanceof CraftingCPUCluster ) - { - cpuCluster = (CraftingCPUCluster) target; - } - - if( target == null ) - { - final List validCpusClusters = new ArrayList<>(); - for( final CraftingCPUCluster cpu : this.craftingCPUClusters ) - { - if( cpu.isActive() && !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal() ) - { - validCpusClusters.add( cpu ); - } - } - - Collections.sort( validCpusClusters, ( firstCluster, nextCluster ) -> - { - if( prioritizePower ) - { - final int comparison1 = Long.compare( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() ); - if( comparison1 != 0 ) - { - return comparison1; - } - return Long.compare( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() ); - } - - final int comparison2 = Long.compare( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() ); - if( comparison2 != 0 ) - { - return comparison2; - } - return Long.compare( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() ); - } ); - - if( !validCpusClusters.isEmpty() ) - { - cpuCluster = validCpusClusters.get( 0 ); - } - } - - if( cpuCluster != null ) - { - return cpuCluster.submitJob( this.grid, job, src, requestingMachine ); - } - - return null; - } - - @Override - public ImmutableSet getCpus() - { - return ImmutableSet.copyOf( new ActiveCpuIterator( this.craftingCPUClusters ) ); - } - - @Override - public boolean canEmitFor( final IAEItemStack someItem ) - { - return this.emitableItems.contains( someItem ); - } - - @Override - public boolean isRequesting( final IAEItemStack what ) - { - return this.requesting( what ) > 0; - } - - @Override - public long requesting( IAEItemStack what ) - { - long requested = 0; - - for( final CraftingCPUCluster cluster : this.craftingCPUClusters ) - { - final IAEItemStack stack = cluster.making( what ); - requested += stack != null ? stack.getStackSize() : 0; - } - - return requested; - } - - public List getMediums( final ICraftingPatternDetails key ) - { - List mediums = this.craftingMethods.get( key ); - - if( mediums == null ) - { - mediums = ImmutableList.of(); - } - - return mediums; - } - - public boolean hasCpu( final ICraftingCPU cpu ) - { - return this.craftingCPUClusters.contains( cpu ); - } - - public GenericInterestManager getInterestManager() - { - return this.interestManager; - } - - private static class ActiveCpuIterator implements Iterator - { - - private final Iterator iterator; - private CraftingCPUCluster cpuCluster; - - public ActiveCpuIterator( final Collection o ) - { - this.iterator = o.iterator(); - this.cpuCluster = null; - } - - @Override - public boolean hasNext() - { - this.findNext(); - - return this.cpuCluster != null; - } - - private void findNext() - { - while( this.iterator.hasNext() && this.cpuCluster == null ) - { - this.cpuCluster = this.iterator.next(); - if( !this.cpuCluster.isActive() || this.cpuCluster.isDestroyed() ) - { - this.cpuCluster = null; - } - } - } - - @Override - public ICraftingCPU next() - { - final ICraftingCPU o = this.cpuCluster; - this.cpuCluster = null; - - return o; - } - - @Override - public void remove() - { - // no.. - } - } +public class CraftingGridCache + implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler { + + private static final ExecutorService CRAFTING_POOL; + private static final Comparator COMPARATOR = (firstDetail, + nextDetail) -> nextDetail.getPriority() - firstDetail.getPriority(); + + static { + final ThreadFactory factory = ar -> new Thread(ar, "AE Crafting Calculator"); + + CRAFTING_POOL = Executors.newCachedThreadPool(factory); + } + + private final Set craftingCPUClusters = new HashSet<>(); + private final Set craftingProviders = new HashSet<>(); + private final Map craftingWatchers = new HashMap<>(); + private final IGrid grid; + private final Map> craftingMethods = new HashMap<>(); + private final Map> craftableItems = new HashMap<>(); + private final Set emitableItems = new HashSet<>(); + private final Map craftingLinks = new HashMap<>(); + private final Multimap interests = HashMultimap.create(); + private final GenericInterestManager interestManager = new GenericInterestManager<>( + this.interests); + private IStorageGrid storageGrid; + private IEnergyGrid energyGrid; + private boolean updateList = false; + + public CraftingGridCache(final IGrid grid) { + this.grid = grid; + } + + @MENetworkEventSubscribe + public void afterCacheConstruction(final MENetworkPostCacheConstruction cacheConstruction) { + this.storageGrid = this.grid.getCache(IStorageGrid.class); + this.energyGrid = this.grid.getCache(IEnergyGrid.class); + + this.storageGrid.registerCellProvider(this); + } + + @Override + public void onUpdateTick() { + if (this.updateList) { + this.updateList = false; + this.updateCPUClusters(); + } + + final Iterator craftingLinkIterator = this.craftingLinks.values().iterator(); + while (craftingLinkIterator.hasNext()) { + if (craftingLinkIterator.next().isDead(this.grid, this)) { + craftingLinkIterator.remove(); + } + } + + for (final CraftingCPUCluster cpu : this.craftingCPUClusters) { + cpu.updateCraftingLogic(this.grid, this.energyGrid, this); + } + } + + @Override + public void removeNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof ICraftingWatcherHost) { + final ICraftingWatcher craftingWatcher = this.craftingWatchers.get(machine); + if (craftingWatcher != null) { + craftingWatcher.reset(); + this.craftingWatchers.remove(machine); + } + } + + if (machine instanceof ICraftingRequester) { + for (final CraftingLinkNexus link : this.craftingLinks.values()) { + if (link.isMachine(machine)) { + link.removeNode(); + } + } + } + + if (machine instanceof TileCraftingTile) { + this.updateList = true; + } + + if (machine instanceof ICraftingProvider) { + this.craftingProviders.remove(machine); + this.updatePatterns(); + } + } + + @Override + public void addNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof ICraftingWatcherHost) { + final ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine; + final CraftingWatcher watcher = new CraftingWatcher(this, watcherHost); + this.craftingWatchers.put(gridNode, watcher); + watcherHost.updateWatcher(watcher); + } + + if (machine instanceof ICraftingRequester) { + for (final ICraftingLink link : ((ICraftingRequester) machine).getRequestedJobs()) { + if (link instanceof CraftingLink) { + this.addLink((CraftingLink) link); + } + } + } + + if (machine instanceof TileCraftingTile) { + this.updateList = true; + } + + if (machine instanceof ICraftingProvider) { + this.craftingProviders.add((ICraftingProvider) machine); + this.updatePatterns(); + } + } + + @Override + public void onSplit(final IGridStorage destinationStorage) { // nothing! + } + + @Override + public void onJoin(final IGridStorage sourceStorage) { + // nothing! + } + + @Override + public void populateGridStorage(final IGridStorage destinationStorage) { + // nothing! + } + + private void updatePatterns() { + final Map> oldItems = this.craftableItems; + + // erase list. + this.craftingMethods.clear(); + this.craftableItems.clear(); + this.emitableItems.clear(); + + // update the stuff that was in the list... + this.storageGrid.postAlterationOfStoredItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), oldItems.keySet(), + new BaseActionSource()); + + // re-create list.. + for (final ICraftingProvider provider : this.craftingProviders) { + provider.provideCrafting(this); + } + + final Map> tmpCraft = new HashMap<>(); + + // new craftables! + for (final ICraftingPatternDetails details : this.craftingMethods.keySet()) { + for (IAEItemStack out : details.getOutputs()) { + out = out.copy(); + out.reset(); + out.setCraftable(true); + + Set methods = tmpCraft.get(out); + + if (methods == null) { + tmpCraft.put(out, methods = new TreeSet<>(COMPARATOR)); + } + + methods.add(details); + } + } + + // make them immutable + for (final Entry> e : tmpCraft.entrySet()) { + this.craftableItems.put(e.getKey(), ImmutableList.copyOf(e.getValue())); + } + + this.storageGrid.postAlterationOfStoredItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), this.craftableItems.keySet(), + new BaseActionSource()); + } + + private void updateCPUClusters() { + this.craftingCPUClusters.clear(); + + for (final IGridNode cst : this.grid.getMachines(TileCraftingStorageTile.class)) { + final TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine(); + final CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster(); + if (cluster != null) { + this.craftingCPUClusters.add(cluster); + + if (cluster.getLastCraftingLink() != null) { + this.addLink((CraftingLink) cluster.getLastCraftingLink()); + } + } + } + + } + + public void addLink(final CraftingLink link) { + if (link.isStandalone()) { + return; + } + + CraftingLinkNexus nexus = this.craftingLinks.get(link.getCraftingID()); + if (nexus == null) { + this.craftingLinks.put(link.getCraftingID(), nexus = new CraftingLinkNexus(link.getCraftingID())); + } + + link.setNexus(nexus); + } + + @MENetworkEventSubscribe + public void updateCPUClusters(final MENetworkCraftingCpuChange c) { + this.updateList = true; + } + + @MENetworkEventSubscribe + public void updateCPUClusters(final MENetworkCraftingPatternChange c) { + this.updatePatterns(); + } + + @Override + public void addCraftingOption(final ICraftingMedium medium, final ICraftingPatternDetails api) { + List details = this.craftingMethods.get(api); + if (details == null) { + details = new ArrayList<>(); + details.add(medium); + this.craftingMethods.put(api, details); + } else { + details.add(medium); + } + } + + @Override + public void setEmitable(final IAEItemStack someItem) { + this.emitableItems.add(someItem.copy()); + } + + @Override + public List getCellArray(final IStorageChannel channel) { + final List list = new ArrayList<>(1); + + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + list.add(this); + } + + return list; + } + + @Override + public int getPriority() { + return Integer.MAX_VALUE; + } + + @Override + public AccessRestriction getAccess() { + return AccessRestriction.WRITE; + } + + @Override + public boolean isPrioritized(final IAEItemStack input) { + return true; + } + + @Override + public boolean canAccept(final IAEItemStack input) { + for (final CraftingCPUCluster cpu : this.craftingCPUClusters) { + if (cpu.canAccept(input)) { + return true; + } + } + + return false; + } + + @Override + public int getSlot() { + return 0; + } + + @Override + public boolean validForPass(final int i) { + return i == 1; + } + + @Override + public IAEItemStack injectItems(IAEItemStack input, final Actionable type, final IActionSource src) { + for (final CraftingCPUCluster cpu : this.craftingCPUClusters) { + input = cpu.injectItems(input, type, src); + } + + return input; + } + + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + return null; + } + + @Override + public IItemList getAvailableItems(final IItemList out) { + // add craftable items! + for (final IAEItemStack stack : this.craftableItems.keySet()) { + out.addCrafting(stack); + } + + for (final IAEItemStack st : this.emitableItems) { + out.addCrafting(st); + } + + return out; + } + + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } + + @Override + public ImmutableCollection getCraftingFor(final IAEItemStack whatToCraft, + final ICraftingPatternDetails details, final int slotIndex, final World world) { + final ImmutableList res = this.craftableItems.get(whatToCraft); + + if (res == null) { + if (details != null && details.isCraftable()) { + for (final IAEItemStack ais : this.craftableItems.keySet()) { + if (ais.getItem() == whatToCraft.getItem() + && (!ais.getItem().isDamageable() || ais.getItemDamage() == whatToCraft.getItemDamage())) { + // TODO: check if OK + // TODO: this is slightly hacky, but fine as long as we only deal with + // itemstacks + if (details.isValidItemForSlot(slotIndex, ais.asItemStackRepresentation(), world)) { + return this.craftableItems.get(ais); + } + } + } + } + + return ImmutableSet.of(); + } + + return res; + } + + @Override + public Future beginCraftingJob(final World world, final IGrid grid, final IActionSource actionSrc, + final IAEItemStack slotItem, final ICraftingCallback cb) { + if (world == null || grid == null || actionSrc == null || slotItem == null) { + throw new IllegalArgumentException("Invalid Crafting Job Request"); + } + + final CraftingJob job = new CraftingJob(world, grid, actionSrc, slotItem, cb); + + return CRAFTING_POOL.submit(job, (ICraftingJob) job); + } + + @Override + public ICraftingLink submitJob(final ICraftingJob job, final ICraftingRequester requestingMachine, + final ICraftingCPU target, final boolean prioritizePower, final IActionSource src) { + if (job.isSimulation()) { + return null; + } + + CraftingCPUCluster cpuCluster = null; + + if (target instanceof CraftingCPUCluster) { + cpuCluster = (CraftingCPUCluster) target; + } + + if (target == null) { + final List validCpusClusters = new ArrayList<>(); + for (final CraftingCPUCluster cpu : this.craftingCPUClusters) { + if (cpu.isActive() && !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal()) { + validCpusClusters.add(cpu); + } + } + + Collections.sort(validCpusClusters, (firstCluster, nextCluster) -> { + if (prioritizePower) { + final int comparison1 = Long.compare(nextCluster.getCoProcessors(), firstCluster.getCoProcessors()); + if (comparison1 != 0) { + return comparison1; + } + return Long.compare(nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage()); + } + + final int comparison2 = Long.compare(firstCluster.getCoProcessors(), nextCluster.getCoProcessors()); + if (comparison2 != 0) { + return comparison2; + } + return Long.compare(firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage()); + }); + + if (!validCpusClusters.isEmpty()) { + cpuCluster = validCpusClusters.get(0); + } + } + + if (cpuCluster != null) { + return cpuCluster.submitJob(this.grid, job, src, requestingMachine); + } + + return null; + } + + @Override + public ImmutableSet getCpus() { + return ImmutableSet.copyOf(new ActiveCpuIterator(this.craftingCPUClusters)); + } + + @Override + public boolean canEmitFor(final IAEItemStack someItem) { + return this.emitableItems.contains(someItem); + } + + @Override + public boolean isRequesting(final IAEItemStack what) { + return this.requesting(what) > 0; + } + + @Override + public long requesting(IAEItemStack what) { + long requested = 0; + + for (final CraftingCPUCluster cluster : this.craftingCPUClusters) { + final IAEItemStack stack = cluster.making(what); + requested += stack != null ? stack.getStackSize() : 0; + } + + return requested; + } + + public List getMediums(final ICraftingPatternDetails key) { + List mediums = this.craftingMethods.get(key); + + if (mediums == null) { + mediums = ImmutableList.of(); + } + + return mediums; + } + + public boolean hasCpu(final ICraftingCPU cpu) { + return this.craftingCPUClusters.contains(cpu); + } + + public GenericInterestManager getInterestManager() { + return this.interestManager; + } + + private static class ActiveCpuIterator implements Iterator { + + private final Iterator iterator; + private CraftingCPUCluster cpuCluster; + + public ActiveCpuIterator(final Collection o) { + this.iterator = o.iterator(); + this.cpuCluster = null; + } + + @Override + public boolean hasNext() { + this.findNext(); + + return this.cpuCluster != null; + } + + private void findNext() { + while (this.iterator.hasNext() && this.cpuCluster == null) { + this.cpuCluster = this.iterator.next(); + if (!this.cpuCluster.isActive() || this.cpuCluster.isDestroyed()) { + this.cpuCluster = null; + } + } + } + + @Override + public ICraftingCPU next() { + final ICraftingCPU o = this.cpuCluster; + this.cpuCluster = null; + + return o; + } + + @Override + public void remove() { + // no.. + } + } } diff --git a/src/main/java/appeng/me/cache/EnergyGridCache.java b/src/main/java/appeng/me/cache/EnergyGridCache.java index d636c1c81..b8bb25800 100644 --- a/src/main/java/appeng/me/cache/EnergyGridCache.java +++ b/src/main/java/appeng/me/cache/EnergyGridCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.Collection; import java.util.Comparator; import java.util.HashMap; @@ -59,632 +58,539 @@ import appeng.me.GridNode; import appeng.me.energy.EnergyThreshold; import appeng.me.energy.EnergyWatcher; - -public class EnergyGridCache implements IEnergyGrid -{ - - private static final double MAX_BUFFER_STORAGE = 800; - - private static final Comparator COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST = ( o1, o2 ) -> Double.compare( o2.getProviderStoredEnergy(), - o1.getProviderStoredEnergy() ); - - private static final Comparator COMPARATOR_LOWEST_PERCENTAGE_FIRST = ( o1, o2 ) -> - { - final double percent1 = ( o1.getProviderStoredEnergy() + 1 ) / ( o1.getProviderMaxEnergy() + 1 ); - final double percent2 = ( o2.getProviderStoredEnergy() + 1 ) / ( o2.getProviderMaxEnergy() + 1 ); - - return Double.compare( percent1, percent2 ); - }; - - private final NavigableSet interests = Sets.newTreeSet(); - private final double averageLength = 40.0; - private final Set providers = new LinkedHashSet<>(); - private final Set requesters = new LinkedHashSet<>(); - private final Multiset energyGridProviders = HashMultiset.create(); - private final IGrid myGrid; - private final HashMap watchers = new HashMap<>(); - - /** - * estimated power available. - */ - private int availableTicksSinceUpdate = 0; - private double globalAvailablePower = 0; - private double globalMaxPower = MAX_BUFFER_STORAGE; - - /** - * idle draw. - */ - private double drainPerTick = 0; - private double avgDrainPerTick = 0; - private double avgInjectionPerTick = 0; - private double tickDrainPerTick = 0; - private double tickInjectionPerTick = 0; - - /** - * power status - */ - private boolean publicHasPower = false; - private boolean hasPower = true; - private long ticksSinceHasPowerChange = 900; - - private PathGridCache pgc; - private double lastStoredPower = -1; - - private final GridPowerStorage localStorage = new GridPowerStorage(); - - public EnergyGridCache( final IGrid g ) - { - this.myGrid = g; - this.requesters.add( this.localStorage ); - this.providers.add( this.localStorage ); - } - - @MENetworkEventSubscribe - public void postInit( final MENetworkPostCacheConstruction pcc ) - { - this.pgc = this.myGrid.getCache( IPathingGrid.class ); - } - - @MENetworkEventSubscribe - public void nodeIdlePowerChangeHandler( final MENetworkPowerIdleChange ev ) - { - // update power usage based on event. - final GridNode node = (GridNode) ev.node; - final IGridBlock gb = node.getGridBlock(); - - final double newDraw = gb.getIdlePowerUsage(); - final double diffDraw = newDraw - node.getPreviousDraw(); - node.setPreviousDraw( newDraw ); - - this.drainPerTick += diffDraw; - } - - @MENetworkEventSubscribe - public void storagePowerChangeHandler( final MENetworkPowerStorage ev ) - { - if( ev.storage.isAEPublicPowerStorage() ) - { - switch( ev.type ) - { - case PROVIDE_POWER: - if( ev.storage.getPowerFlow() != AccessRestriction.WRITE ) - { - this.providers.add( ev.storage ); - } - break; - case REQUEST_POWER: - if( ev.storage.getPowerFlow() != AccessRestriction.READ ) - { - this.requesters.add( ev.storage ); - } - break; - } - } - else - { - ( new RuntimeException( "Attempt to ask the IEnergyGrid to charge a non public energy store." ) ).printStackTrace(); - } - } - - @Override - public void onUpdateTick() - { - if( !this.interests.isEmpty() ) - { - final double oldPower = this.lastStoredPower; - this.lastStoredPower = this.getStoredPower(); - - final EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), Integer.MIN_VALUE ); - final EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), Integer.MAX_VALUE ); - - for( final EnergyThreshold th : this.interests.subSet( low, true, high, true ) ) - { - ( (EnergyWatcher) th.getEnergyWatcher() ).post( this ); - } - } - - this.avgDrainPerTick *= ( this.averageLength - 1 ) / this.averageLength; - this.avgInjectionPerTick *= ( this.averageLength - 1 ) / this.averageLength; - - this.avgDrainPerTick += this.tickDrainPerTick / this.averageLength; - this.avgInjectionPerTick += this.tickInjectionPerTick / this.averageLength; - - this.tickDrainPerTick = 0; - this.tickInjectionPerTick = 0; - - // power information. - boolean currentlyHasPower = false; - - if( this.drainPerTick > 0.0001 ) - { - final double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); - currentlyHasPower = drained >= this.drainPerTick - 0.001; - } - else - { - currentlyHasPower = this.extractAEPower( 0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0; - } - - // ticks since change.. - if( currentlyHasPower == this.hasPower ) - { - this.ticksSinceHasPowerChange++; - } - else - { - this.ticksSinceHasPowerChange = 0; - } - - // update status.. - this.hasPower = currentlyHasPower; - - // update public status, this buffers power ups for 30 ticks. - if( this.hasPower && this.ticksSinceHasPowerChange > 30 ) - { - this.publicPowerState( true, this.myGrid ); - } - else if( !this.hasPower ) - { - this.publicPowerState( false, this.myGrid ); - } - - this.availableTicksSinceUpdate++; - } - - @Override - public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm ) - { - final double toExtract = pm.multiply( amt ); - final Queue toVisit = new PriorityQueue<>( COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST ); - final Set visited = new HashSet<>(); - - double extracted = 0; - toVisit.add( this ); - - while( !toVisit.isEmpty() && extracted < toExtract ) - { - final IEnergyGridProvider next = toVisit.poll(); - visited.add( next ); - - extracted += next.extractProviderPower( toExtract - extracted, mode ); - - for( IEnergyGridProvider iEnergyGridProvider : next.providers() ) - { - if( !visited.contains( iEnergyGridProvider ) ) - { - toVisit.add( iEnergyGridProvider ); - } - } - } - - return pm.divide( extracted ); - } - - @Override - public double getIdlePowerUsage() - { - return this.drainPerTick + this.pgc.getChannelPowerUsage(); - } - - private void publicPowerState( final boolean newState, final IGrid grid ) - { - if( this.publicHasPower == newState ) - { - return; - } - - this.publicHasPower = newState; - ( (Grid) this.myGrid ).setImportantFlag( 0, this.publicHasPower ); - grid.postEvent( new MENetworkPowerStatusChange() ); - } - - /** - * refresh current stored power. - */ - private void refreshPower() - { - this.availableTicksSinceUpdate = 0; - this.globalAvailablePower = 0; - for( final IAEPowerStorage p : this.providers ) - { - this.globalAvailablePower += p.getAECurrentPower(); - } - } - - @Override - public Collection providers() - { - return this.energyGridProviders; - } - - @Override - public double extractProviderPower( final double amt, final Actionable mode ) - { - double extractedPower = 0; - - final Iterator it = this.providers.iterator(); - - while( extractedPower < amt && it.hasNext() ) - { - final IAEPowerStorage node = it.next(); - - final double req = amt - extractedPower; - final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE ); - extractedPower += newPower; - - if( newPower < req && mode == Actionable.MODULATE ) - { - it.remove(); - } - } - - final double result = Math.min( extractedPower, amt ); - - if( mode == Actionable.MODULATE ) - { - if( extractedPower > amt ) - { - this.localStorage.addCurrentAEPower( extractedPower - amt ); - } - - this.globalAvailablePower -= result; - this.tickDrainPerTick += result; - } - - return result; - } - - @Override - public double injectProviderPower( double amt, final Actionable mode ) - { - final double originalAmount = amt; - - final Iterator it = this.requesters.iterator(); - - while( amt > 0 && it.hasNext() ) - { - final IAEPowerStorage node = it.next(); - amt = node.injectAEPower( amt, mode ); - - if( amt > 0 && mode == Actionable.MODULATE ) - { - it.remove(); - } - } - - final double overflow = Math.max( 0.0, amt ); - - if( mode == Actionable.MODULATE ) - { - this.tickInjectionPerTick += originalAmount - overflow; - } - - return overflow; - } - - @Override - public double getProviderEnergyDemand( final double maxRequired ) - { - double required = 0; - - final Iterator it = this.requesters.iterator(); - while( required < maxRequired && it.hasNext() ) - { - final IAEPowerStorage node = it.next(); - if( node.getPowerFlow() != AccessRestriction.READ ) - { - required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() ); - } - } - - return required; - } - - @Override - public double getAvgPowerUsage() - { - return this.avgDrainPerTick; - } - - @Override - public double getAvgPowerInjection() - { - return this.avgInjectionPerTick; - } - - @Override - public boolean isNetworkPowered() - { - return this.publicHasPower; - } - - @Override - public double injectPower( final double amt, final Actionable mode ) - { - final Queue toVisit = new PriorityQueue<>( COMPARATOR_LOWEST_PERCENTAGE_FIRST ); - final Set visited = new HashSet<>(); - toVisit.add( this ); - - double leftover = amt; - - while( !toVisit.isEmpty() && leftover > 0 ) - { - final IEnergyGridProvider next = toVisit.poll(); - visited.add( next ); - - leftover = next.injectProviderPower( leftover, mode ); - - for( IEnergyGridProvider iEnergyGridProvider : next.providers() ) - { - if( !visited.contains( iEnergyGridProvider ) ) - { - toVisit.add( iEnergyGridProvider ); - } - } - } - - return leftover; - } - - @Override - public double getStoredPower() - { - if( this.availableTicksSinceUpdate > 90 ) - { - this.refreshPower(); - } - - return Math.max( 0.0, this.globalAvailablePower ); - } - - @Override - public double getMaxStoredPower() - { - return this.globalMaxPower; - } - - @Override - public double getEnergyDemand( final double maxRequired ) - { - final Queue toVisit = new PriorityQueue<>( COMPARATOR_LOWEST_PERCENTAGE_FIRST ); - final Set visited = new HashSet<>(); - toVisit.add( this ); - - double required = 0; - - while( !toVisit.isEmpty() && required < maxRequired ) - { - final IEnergyGridProvider next = toVisit.poll(); - visited.add( next ); - - required += next.getProviderEnergyDemand( maxRequired - required ); - - for( IEnergyGridProvider iEnergyGridProvider : next.providers() ) - { - if( !visited.contains( iEnergyGridProvider ) ) - { - toVisit.add( iEnergyGridProvider ); - } - } - } - - return required; - } - - @Override - public double getProviderStoredEnergy() - { - return this.getStoredPower(); - } - - @Override - public double getProviderMaxEnergy() - { - return this.getMaxStoredPower(); - } - - @Override - public void removeNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof IEnergyGridProvider ) - { - this.energyGridProviders.remove( machine ); - } - - // idle draw. - final GridNode gridNode = (GridNode) node; - this.drainPerTick -= gridNode.getPreviousDraw(); - - // power storage. - if( machine instanceof IAEPowerStorage ) - { - final IAEPowerStorage ps = (IAEPowerStorage) machine; - if( ps.isAEPublicPowerStorage() ) - { - if( ps.getPowerFlow() != AccessRestriction.WRITE ) - { - this.globalMaxPower -= ps.getAEMaxPower(); - this.globalAvailablePower -= ps.getAECurrentPower(); - } - - this.providers.remove( ps ); - this.requesters.remove( ps ); - } - } - - if( machine instanceof IEnergyWatcherHost ) - { - final IEnergyWatcher watcher = this.watchers.get( node ); - - if( watcher != null ) - { - watcher.reset(); - this.watchers.remove( node ); - } - } - } - - @Override - public void addNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof IEnergyGridProvider ) - { - this.energyGridProviders.add( (IEnergyGridProvider) machine ); - } - - // idle draw... - final GridNode gridNode = (GridNode) node; - final IGridBlock gb = gridNode.getGridBlock(); - gridNode.setPreviousDraw( gb.getIdlePowerUsage() ); - this.drainPerTick += gridNode.getPreviousDraw(); - - // power storage - if( machine instanceof IAEPowerStorage ) - { - final IAEPowerStorage ps = (IAEPowerStorage) machine; - if( ps.isAEPublicPowerStorage() ) - { - final double max = ps.getAEMaxPower(); - final double current = ps.getAECurrentPower(); - - if( ps.getPowerFlow() != AccessRestriction.WRITE ) - { - this.globalMaxPower += ps.getAEMaxPower(); - } - - if( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE ) - { - this.globalAvailablePower += current; - this.providers.add( ps ); - } - - if( current < max && ps.getPowerFlow() != AccessRestriction.READ ) - { - this.requesters.add( ps ); - } - } - } - - if( machine instanceof IEnergyWatcherHost ) - { - final IEnergyWatcherHost swh = (IEnergyWatcherHost) machine; - final EnergyWatcher iw = new EnergyWatcher( this, swh ); - - this.watchers.put( node, iw ); - swh.updateWatcher( iw ); - } - - this.myGrid.postEventTo( node, new MENetworkPowerStatusChange() ); - } - - @Override - public void onSplit( final IGridStorage storageB ) - { - final double newBuffer = this.localStorage.getAECurrentPower() / 2; - this.localStorage.removeCurrentAEPower( newBuffer ); - storageB.dataObject().putDouble("buffer", newBuffer); - } - - @Override - public void onJoin( final IGridStorage storageB ) - { - this.localStorage.addCurrentAEPower( storageB.dataObject().getDouble( "buffer" ) ); - } - - @Override - public void populateGridStorage( final IGridStorage storage ) - { - storage.dataObject().putDouble("buffer", this.localStorage.getAECurrentPower()); - } - - public boolean registerEnergyInterest( final EnergyThreshold threshold ) - { - return this.interests.add( threshold ); - } - - public boolean unregisterEnergyInterest( final EnergyThreshold threshold ) - { - return this.interests.remove( threshold ); - } - - private class GridPowerStorage implements IAEPowerStorage - { - private double stored = 0; - - @Override - public double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier ) - { - double extracted = Math.min( amt, this.stored ); - - if( mode == Actionable.MODULATE ) - { - this.removeCurrentAEPower( extracted ); - } - - return extracted; - } - - @Override - public boolean isAEPublicPowerStorage() - { - return true; - } - - @Override - public double injectAEPower( double amt, Actionable mode ) - { - double toStore = Math.min( amt, MAX_BUFFER_STORAGE - this.stored ); - - if( mode == Actionable.MODULATE ) - { - this.addCurrentAEPower( toStore ); - } - - return amt - toStore; - } - - @Override - public AccessRestriction getPowerFlow() - { - return AccessRestriction.READ_WRITE; - } - - @Override - public double getAEMaxPower() - { - return MAX_BUFFER_STORAGE; - } - - @Override - public double getAECurrentPower() - { - return this.stored; - } - - private void addCurrentAEPower( double amount ) - { - this.stored += amount; - - if( this.stored > 0.01 ) - { - EnergyGridCache.this.myGrid.postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) ); - } - } - - private void removeCurrentAEPower( double amount ) - { - this.stored -= amount; - - if( this.stored < MAX_BUFFER_STORAGE - 0.001 ) - { - EnergyGridCache.this.myGrid.postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) ); - } - - if( this.stored < 0.01 ) - { - EnergyGridCache.this.ticksSinceHasPowerChange = 0; - EnergyGridCache.this.publicPowerState( false, EnergyGridCache.this.myGrid ); - } - } - } +public class EnergyGridCache implements IEnergyGrid { + + private static final double MAX_BUFFER_STORAGE = 800; + + private static final Comparator COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST = (o1, o2) -> Double + .compare(o2.getProviderStoredEnergy(), o1.getProviderStoredEnergy()); + + private static final Comparator COMPARATOR_LOWEST_PERCENTAGE_FIRST = (o1, o2) -> { + final double percent1 = (o1.getProviderStoredEnergy() + 1) / (o1.getProviderMaxEnergy() + 1); + final double percent2 = (o2.getProviderStoredEnergy() + 1) / (o2.getProviderMaxEnergy() + 1); + + return Double.compare(percent1, percent2); + }; + + private final NavigableSet interests = Sets.newTreeSet(); + private final double averageLength = 40.0; + private final Set providers = new LinkedHashSet<>(); + private final Set requesters = new LinkedHashSet<>(); + private final Multiset energyGridProviders = HashMultiset.create(); + private final IGrid myGrid; + private final HashMap watchers = new HashMap<>(); + + /** + * estimated power available. + */ + private int availableTicksSinceUpdate = 0; + private double globalAvailablePower = 0; + private double globalMaxPower = MAX_BUFFER_STORAGE; + + /** + * idle draw. + */ + private double drainPerTick = 0; + private double avgDrainPerTick = 0; + private double avgInjectionPerTick = 0; + private double tickDrainPerTick = 0; + private double tickInjectionPerTick = 0; + + /** + * power status + */ + private boolean publicHasPower = false; + private boolean hasPower = true; + private long ticksSinceHasPowerChange = 900; + + private PathGridCache pgc; + private double lastStoredPower = -1; + + private final GridPowerStorage localStorage = new GridPowerStorage(); + + public EnergyGridCache(final IGrid g) { + this.myGrid = g; + this.requesters.add(this.localStorage); + this.providers.add(this.localStorage); + } + + @MENetworkEventSubscribe + public void postInit(final MENetworkPostCacheConstruction pcc) { + this.pgc = this.myGrid.getCache(IPathingGrid.class); + } + + @MENetworkEventSubscribe + public void nodeIdlePowerChangeHandler(final MENetworkPowerIdleChange ev) { + // update power usage based on event. + final GridNode node = (GridNode) ev.node; + final IGridBlock gb = node.getGridBlock(); + + final double newDraw = gb.getIdlePowerUsage(); + final double diffDraw = newDraw - node.getPreviousDraw(); + node.setPreviousDraw(newDraw); + + this.drainPerTick += diffDraw; + } + + @MENetworkEventSubscribe + public void storagePowerChangeHandler(final MENetworkPowerStorage ev) { + if (ev.storage.isAEPublicPowerStorage()) { + switch (ev.type) { + case PROVIDE_POWER: + if (ev.storage.getPowerFlow() != AccessRestriction.WRITE) { + this.providers.add(ev.storage); + } + break; + case REQUEST_POWER: + if (ev.storage.getPowerFlow() != AccessRestriction.READ) { + this.requesters.add(ev.storage); + } + break; + } + } else { + (new RuntimeException("Attempt to ask the IEnergyGrid to charge a non public energy store.")) + .printStackTrace(); + } + } + + @Override + public void onUpdateTick() { + if (!this.interests.isEmpty()) { + final double oldPower = this.lastStoredPower; + this.lastStoredPower = this.getStoredPower(); + + final EnergyThreshold low = new EnergyThreshold(Math.min(oldPower, this.lastStoredPower), + Integer.MIN_VALUE); + final EnergyThreshold high = new EnergyThreshold(Math.max(oldPower, this.lastStoredPower), + Integer.MAX_VALUE); + + for (final EnergyThreshold th : this.interests.subSet(low, true, high, true)) { + ((EnergyWatcher) th.getEnergyWatcher()).post(this); + } + } + + this.avgDrainPerTick *= (this.averageLength - 1) / this.averageLength; + this.avgInjectionPerTick *= (this.averageLength - 1) / this.averageLength; + + this.avgDrainPerTick += this.tickDrainPerTick / this.averageLength; + this.avgInjectionPerTick += this.tickInjectionPerTick / this.averageLength; + + this.tickDrainPerTick = 0; + this.tickInjectionPerTick = 0; + + // power information. + boolean currentlyHasPower = false; + + if (this.drainPerTick > 0.0001) { + final double drained = this.extractAEPower(this.getIdlePowerUsage(), Actionable.MODULATE, + PowerMultiplier.CONFIG); + currentlyHasPower = drained >= this.drainPerTick - 0.001; + } else { + currentlyHasPower = this.extractAEPower(0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0; + } + + // ticks since change.. + if (currentlyHasPower == this.hasPower) { + this.ticksSinceHasPowerChange++; + } else { + this.ticksSinceHasPowerChange = 0; + } + + // update status.. + this.hasPower = currentlyHasPower; + + // update public status, this buffers power ups for 30 ticks. + if (this.hasPower && this.ticksSinceHasPowerChange > 30) { + this.publicPowerState(true, this.myGrid); + } else if (!this.hasPower) { + this.publicPowerState(false, this.myGrid); + } + + this.availableTicksSinceUpdate++; + } + + @Override + public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) { + final double toExtract = pm.multiply(amt); + final Queue toVisit = new PriorityQueue<>(COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST); + final Set visited = new HashSet<>(); + + double extracted = 0; + toVisit.add(this); + + while (!toVisit.isEmpty() && extracted < toExtract) { + final IEnergyGridProvider next = toVisit.poll(); + visited.add(next); + + extracted += next.extractProviderPower(toExtract - extracted, mode); + + for (IEnergyGridProvider iEnergyGridProvider : next.providers()) { + if (!visited.contains(iEnergyGridProvider)) { + toVisit.add(iEnergyGridProvider); + } + } + } + + return pm.divide(extracted); + } + + @Override + public double getIdlePowerUsage() { + return this.drainPerTick + this.pgc.getChannelPowerUsage(); + } + + private void publicPowerState(final boolean newState, final IGrid grid) { + if (this.publicHasPower == newState) { + return; + } + + this.publicHasPower = newState; + ((Grid) this.myGrid).setImportantFlag(0, this.publicHasPower); + grid.postEvent(new MENetworkPowerStatusChange()); + } + + /** + * refresh current stored power. + */ + private void refreshPower() { + this.availableTicksSinceUpdate = 0; + this.globalAvailablePower = 0; + for (final IAEPowerStorage p : this.providers) { + this.globalAvailablePower += p.getAECurrentPower(); + } + } + + @Override + public Collection providers() { + return this.energyGridProviders; + } + + @Override + public double extractProviderPower(final double amt, final Actionable mode) { + double extractedPower = 0; + + final Iterator it = this.providers.iterator(); + + while (extractedPower < amt && it.hasNext()) { + final IAEPowerStorage node = it.next(); + + final double req = amt - extractedPower; + final double newPower = node.extractAEPower(req, mode, PowerMultiplier.ONE); + extractedPower += newPower; + + if (newPower < req && mode == Actionable.MODULATE) { + it.remove(); + } + } + + final double result = Math.min(extractedPower, amt); + + if (mode == Actionable.MODULATE) { + if (extractedPower > amt) { + this.localStorage.addCurrentAEPower(extractedPower - amt); + } + + this.globalAvailablePower -= result; + this.tickDrainPerTick += result; + } + + return result; + } + + @Override + public double injectProviderPower(double amt, final Actionable mode) { + final double originalAmount = amt; + + final Iterator it = this.requesters.iterator(); + + while (amt > 0 && it.hasNext()) { + final IAEPowerStorage node = it.next(); + amt = node.injectAEPower(amt, mode); + + if (amt > 0 && mode == Actionable.MODULATE) { + it.remove(); + } + } + + final double overflow = Math.max(0.0, amt); + + if (mode == Actionable.MODULATE) { + this.tickInjectionPerTick += originalAmount - overflow; + } + + return overflow; + } + + @Override + public double getProviderEnergyDemand(final double maxRequired) { + double required = 0; + + final Iterator it = this.requesters.iterator(); + while (required < maxRequired && it.hasNext()) { + final IAEPowerStorage node = it.next(); + if (node.getPowerFlow() != AccessRestriction.READ) { + required += Math.max(0.0, node.getAEMaxPower() - node.getAECurrentPower()); + } + } + + return required; + } + + @Override + public double getAvgPowerUsage() { + return this.avgDrainPerTick; + } + + @Override + public double getAvgPowerInjection() { + return this.avgInjectionPerTick; + } + + @Override + public boolean isNetworkPowered() { + return this.publicHasPower; + } + + @Override + public double injectPower(final double amt, final Actionable mode) { + final Queue toVisit = new PriorityQueue<>(COMPARATOR_LOWEST_PERCENTAGE_FIRST); + final Set visited = new HashSet<>(); + toVisit.add(this); + + double leftover = amt; + + while (!toVisit.isEmpty() && leftover > 0) { + final IEnergyGridProvider next = toVisit.poll(); + visited.add(next); + + leftover = next.injectProviderPower(leftover, mode); + + for (IEnergyGridProvider iEnergyGridProvider : next.providers()) { + if (!visited.contains(iEnergyGridProvider)) { + toVisit.add(iEnergyGridProvider); + } + } + } + + return leftover; + } + + @Override + public double getStoredPower() { + if (this.availableTicksSinceUpdate > 90) { + this.refreshPower(); + } + + return Math.max(0.0, this.globalAvailablePower); + } + + @Override + public double getMaxStoredPower() { + return this.globalMaxPower; + } + + @Override + public double getEnergyDemand(final double maxRequired) { + final Queue toVisit = new PriorityQueue<>(COMPARATOR_LOWEST_PERCENTAGE_FIRST); + final Set visited = new HashSet<>(); + toVisit.add(this); + + double required = 0; + + while (!toVisit.isEmpty() && required < maxRequired) { + final IEnergyGridProvider next = toVisit.poll(); + visited.add(next); + + required += next.getProviderEnergyDemand(maxRequired - required); + + for (IEnergyGridProvider iEnergyGridProvider : next.providers()) { + if (!visited.contains(iEnergyGridProvider)) { + toVisit.add(iEnergyGridProvider); + } + } + } + + return required; + } + + @Override + public double getProviderStoredEnergy() { + return this.getStoredPower(); + } + + @Override + public double getProviderMaxEnergy() { + return this.getMaxStoredPower(); + } + + @Override + public void removeNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof IEnergyGridProvider) { + this.energyGridProviders.remove(machine); + } + + // idle draw. + final GridNode gridNode = (GridNode) node; + this.drainPerTick -= gridNode.getPreviousDraw(); + + // power storage. + if (machine instanceof IAEPowerStorage) { + final IAEPowerStorage ps = (IAEPowerStorage) machine; + if (ps.isAEPublicPowerStorage()) { + if (ps.getPowerFlow() != AccessRestriction.WRITE) { + this.globalMaxPower -= ps.getAEMaxPower(); + this.globalAvailablePower -= ps.getAECurrentPower(); + } + + this.providers.remove(ps); + this.requesters.remove(ps); + } + } + + if (machine instanceof IEnergyWatcherHost) { + final IEnergyWatcher watcher = this.watchers.get(node); + + if (watcher != null) { + watcher.reset(); + this.watchers.remove(node); + } + } + } + + @Override + public void addNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof IEnergyGridProvider) { + this.energyGridProviders.add((IEnergyGridProvider) machine); + } + + // idle draw... + final GridNode gridNode = (GridNode) node; + final IGridBlock gb = gridNode.getGridBlock(); + gridNode.setPreviousDraw(gb.getIdlePowerUsage()); + this.drainPerTick += gridNode.getPreviousDraw(); + + // power storage + if (machine instanceof IAEPowerStorage) { + final IAEPowerStorage ps = (IAEPowerStorage) machine; + if (ps.isAEPublicPowerStorage()) { + final double max = ps.getAEMaxPower(); + final double current = ps.getAECurrentPower(); + + if (ps.getPowerFlow() != AccessRestriction.WRITE) { + this.globalMaxPower += ps.getAEMaxPower(); + } + + if (current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE) { + this.globalAvailablePower += current; + this.providers.add(ps); + } + + if (current < max && ps.getPowerFlow() != AccessRestriction.READ) { + this.requesters.add(ps); + } + } + } + + if (machine instanceof IEnergyWatcherHost) { + final IEnergyWatcherHost swh = (IEnergyWatcherHost) machine; + final EnergyWatcher iw = new EnergyWatcher(this, swh); + + this.watchers.put(node, iw); + swh.updateWatcher(iw); + } + + this.myGrid.postEventTo(node, new MENetworkPowerStatusChange()); + } + + @Override + public void onSplit(final IGridStorage storageB) { + final double newBuffer = this.localStorage.getAECurrentPower() / 2; + this.localStorage.removeCurrentAEPower(newBuffer); + storageB.dataObject().putDouble("buffer", newBuffer); + } + + @Override + public void onJoin(final IGridStorage storageB) { + this.localStorage.addCurrentAEPower(storageB.dataObject().getDouble("buffer")); + } + + @Override + public void populateGridStorage(final IGridStorage storage) { + storage.dataObject().putDouble("buffer", this.localStorage.getAECurrentPower()); + } + + public boolean registerEnergyInterest(final EnergyThreshold threshold) { + return this.interests.add(threshold); + } + + public boolean unregisterEnergyInterest(final EnergyThreshold threshold) { + return this.interests.remove(threshold); + } + + private class GridPowerStorage implements IAEPowerStorage { + private double stored = 0; + + @Override + public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) { + double extracted = Math.min(amt, this.stored); + + if (mode == Actionable.MODULATE) { + this.removeCurrentAEPower(extracted); + } + + return extracted; + } + + @Override + public boolean isAEPublicPowerStorage() { + return true; + } + + @Override + public double injectAEPower(double amt, Actionable mode) { + double toStore = Math.min(amt, MAX_BUFFER_STORAGE - this.stored); + + if (mode == Actionable.MODULATE) { + this.addCurrentAEPower(toStore); + } + + return amt - toStore; + } + + @Override + public AccessRestriction getPowerFlow() { + return AccessRestriction.READ_WRITE; + } + + @Override + public double getAEMaxPower() { + return MAX_BUFFER_STORAGE; + } + + @Override + public double getAECurrentPower() { + return this.stored; + } + + private void addCurrentAEPower(double amount) { + this.stored += amount; + + if (this.stored > 0.01) { + EnergyGridCache.this.myGrid.postEvent(new MENetworkPowerStorage(this, PowerEventType.PROVIDE_POWER)); + } + } + + private void removeCurrentAEPower(double amount) { + this.stored -= amount; + + if (this.stored < MAX_BUFFER_STORAGE - 0.001) { + EnergyGridCache.this.myGrid.postEvent(new MENetworkPowerStorage(this, PowerEventType.REQUEST_POWER)); + } + + if (this.stored < 0.01) { + EnergyGridCache.this.ticksSinceHasPowerChange = 0; + EnergyGridCache.this.publicPowerState(false, EnergyGridCache.this.myGrid); + } + } + } } diff --git a/src/main/java/appeng/me/cache/GridStorageCache.java b/src/main/java/appeng/me/cache/GridStorageCache.java index 6693b80b8..1bbf898b1 100644 --- a/src/main/java/appeng/me/cache/GridStorageCache.java +++ b/src/main/java/appeng/me/cache/GridStorageCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -56,294 +55,252 @@ import appeng.me.helpers.MachineSource; import appeng.me.storage.ItemWatcher; import appeng.me.storage.NetworkInventoryHandler; +public class GridStorageCache implements IStorageGrid { -public class GridStorageCache implements IStorageGrid -{ + private final IGrid myGrid; + private final HashSet activeCellProviders = new HashSet<>(); + private final HashSet inactiveCellProviders = new HashSet<>(); + private final SetMultimap interests = HashMultimap.create(); + private final GenericInterestManager interestManager = new GenericInterestManager<>(this.interests); + private final HashMap watchers = new HashMap<>(); + private Map, NetworkInventoryHandler> storageNetworks; + private Map, NetworkMonitor> storageMonitors; - private final IGrid myGrid; - private final HashSet activeCellProviders = new HashSet<>(); - private final HashSet inactiveCellProviders = new HashSet<>(); - private final SetMultimap interests = HashMultimap.create(); - private final GenericInterestManager interestManager = new GenericInterestManager<>( this.interests ); - private final HashMap watchers = new HashMap<>(); - private Map, NetworkInventoryHandler> storageNetworks; - private Map, NetworkMonitor> storageMonitors; + public GridStorageCache(final IGrid g) { + this.myGrid = g; + this.storageNetworks = new IdentityHashMap<>(); + this.storageMonitors = new IdentityHashMap<>(); - public GridStorageCache( final IGrid g ) - { - this.myGrid = g; - this.storageNetworks = new IdentityHashMap<>(); - this.storageMonitors = new IdentityHashMap<>(); + AEApi.instance().storage().storageChannels() + .forEach(channel -> this.storageMonitors.put(channel, new NetworkMonitor<>(this, channel))); + } - AEApi.instance().storage().storageChannels().forEach( channel -> this.storageMonitors.put( channel, new NetworkMonitor<>( this, channel ) ) ); - } + @Override + public void onUpdateTick() { + this.storageMonitors.forEach((channel, monitor) -> monitor.onTick()); + } - @Override - public void onUpdateTick() - { - this.storageMonitors.forEach( ( channel, monitor ) -> monitor.onTick() ); - } + @Override + public void removeNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof ICellContainer) { + final ICellContainer cc = (ICellContainer) machine; + final CellChangeTracker tracker = new CellChangeTracker(); - @Override - public void removeNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof ICellContainer ) - { - final ICellContainer cc = (ICellContainer) machine; - final CellChangeTracker tracker = new CellChangeTracker(); + this.removeCellProvider(cc, tracker); + this.inactiveCellProviders.remove(cc); + this.getGrid().postEvent(new MENetworkCellArrayUpdate()); - this.removeCellProvider( cc, tracker ); - this.inactiveCellProviders.remove( cc ); - this.getGrid().postEvent( new MENetworkCellArrayUpdate() ); + tracker.applyChanges(); + } - tracker.applyChanges(); - } + if (machine instanceof IStackWatcherHost) { + final IStackWatcher myWatcher = this.watchers.get(machine); - if( machine instanceof IStackWatcherHost ) - { - final IStackWatcher myWatcher = this.watchers.get( machine ); + if (myWatcher != null) { + myWatcher.reset(); + this.watchers.remove(machine); + } + } + } - if( myWatcher != null ) - { - myWatcher.reset(); - this.watchers.remove( machine ); - } - } - } + @Override + public void addNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof ICellContainer) { + final ICellContainer cc = (ICellContainer) machine; + this.inactiveCellProviders.add(cc); - @Override - public void addNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof ICellContainer ) - { - final ICellContainer cc = (ICellContainer) machine; - this.inactiveCellProviders.add( cc ); + this.getGrid().postEvent(new MENetworkCellArrayUpdate()); - this.getGrid().postEvent( new MENetworkCellArrayUpdate() ); + if (node.isActive()) { + final CellChangeTracker tracker = new CellChangeTracker(); - if( node.isActive() ) - { - final CellChangeTracker tracker = new CellChangeTracker(); + this.addCellProvider(cc, tracker); + tracker.applyChanges(); + } + } - this.addCellProvider( cc, tracker ); - tracker.applyChanges(); - } - } + if (machine instanceof IStackWatcherHost) { + final IStackWatcherHost swh = (IStackWatcherHost) machine; + final ItemWatcher iw = new ItemWatcher(this, swh); + this.watchers.put(node, iw); + swh.updateWatcher(iw); + } + } - if( machine instanceof IStackWatcherHost ) - { - final IStackWatcherHost swh = (IStackWatcherHost) machine; - final ItemWatcher iw = new ItemWatcher( this, swh ); - this.watchers.put( node, iw ); - swh.updateWatcher( iw ); - } - } + @Override + public void onSplit(final IGridStorage storageB) { - @Override - public void onSplit( final IGridStorage storageB ) - { + } - } + @Override + public void onJoin(final IGridStorage storageB) { - @Override - public void onJoin( final IGridStorage storageB ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage storage) { - @Override - public void populateGridStorage( final IGridStorage storage ) - { + } - } + public > IMEInventoryHandler getInventoryHandler(IStorageChannel channel) { + return (IMEInventoryHandler) this.storageNetworks.computeIfAbsent(channel, this::buildNetworkStorage); + } - public > IMEInventoryHandler getInventoryHandler( IStorageChannel channel ) - { - return (IMEInventoryHandler) this.storageNetworks.computeIfAbsent( channel, this::buildNetworkStorage ); - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + return (IMEMonitor) this.storageMonitors.get(channel); + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - return (IMEMonitor) this.storageMonitors.get( channel ); - } + private CellChangeTracker addCellProvider(final ICellProvider cc, final CellChangeTracker tracker) { + if (this.inactiveCellProviders.contains(cc)) { + this.inactiveCellProviders.remove(cc); + this.activeCellProviders.add(cc); - private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker ) - { - if( this.inactiveCellProviders.contains( cc ) ) - { - this.inactiveCellProviders.remove( cc ); - this.activeCellProviders.add( cc ); + final IActionSource actionSrc = cc instanceof IActionHost ? new MachineSource((IActionHost) cc) + : new BaseActionSource(); - final IActionSource actionSrc = cc instanceof IActionHost ? new MachineSource( (IActionHost) cc ) : new BaseActionSource(); + this.storageMonitors.forEach((channel, monitor) -> { + for (final IMEInventoryHandler h : cc.getCellArray(channel)) { + tracker.postChanges(channel, 1, h, actionSrc); + } + }); + } - this.storageMonitors.forEach( ( channel, monitor ) -> - { - for( final IMEInventoryHandler h : cc.getCellArray( channel ) ) - { - tracker.postChanges( channel, 1, h, actionSrc ); - } - } ); - } + return tracker; + } - return tracker; - } + private CellChangeTracker removeCellProvider(final ICellProvider cc, final CellChangeTracker tracker) { + if (this.activeCellProviders.contains(cc)) { + this.activeCellProviders.remove(cc); + this.inactiveCellProviders.add(cc); - private CellChangeTracker removeCellProvider( final ICellProvider cc, final CellChangeTracker tracker ) - { - if( this.activeCellProviders.contains( cc ) ) - { - this.activeCellProviders.remove( cc ); - this.inactiveCellProviders.add( cc ); + final IActionSource actionSrc = cc instanceof IActionHost ? new MachineSource((IActionHost) cc) + : new BaseActionSource(); - final IActionSource actionSrc = cc instanceof IActionHost ? new MachineSource( (IActionHost) cc ) : new BaseActionSource(); + this.storageMonitors.forEach((channel, monitor) -> { + for (final IMEInventoryHandler h : cc.getCellArray(channel)) { + tracker.postChanges(channel, -1, h, actionSrc); + } + }); + } - this.storageMonitors.forEach( ( channel, monitor ) -> - { - for( final IMEInventoryHandler h : cc.getCellArray( channel ) ) - { - tracker.postChanges( channel, -1, h, actionSrc ); - } - } ); - } + return tracker; + } - return tracker; - } + @MENetworkEventSubscribe + public void cellUpdate(final MENetworkCellArrayUpdate ev) { + this.storageNetworks.clear(); - @MENetworkEventSubscribe - public void cellUpdate( final MENetworkCellArrayUpdate ev ) - { - this.storageNetworks.clear(); + final List ll = new ArrayList(); + ll.addAll(this.inactiveCellProviders); + ll.addAll(this.activeCellProviders); - final List ll = new ArrayList(); - ll.addAll( this.inactiveCellProviders ); - ll.addAll( this.activeCellProviders ); + final CellChangeTracker tracker = new CellChangeTracker(); - final CellChangeTracker tracker = new CellChangeTracker(); + for (final ICellProvider cc : ll) { + boolean active = true; - for( final ICellProvider cc : ll ) - { - boolean active = true; + if (cc instanceof IActionHost) { + final IGridNode node = ((IActionHost) cc).getActionableNode(); + if (node != null && node.isActive()) { + active = true; + } else { + active = false; + } + } - if( cc instanceof IActionHost ) - { - final IGridNode node = ( (IActionHost) cc ).getActionableNode(); - if( node != null && node.isActive() ) - { - active = true; - } - else - { - active = false; - } - } + if (active) { + this.addCellProvider(cc, tracker); + } else { + this.removeCellProvider(cc, tracker); + } + } - if( active ) - { - this.addCellProvider( cc, tracker ); - } - else - { - this.removeCellProvider( cc, tracker ); - } - } + this.storageMonitors.forEach((channel, monitor) -> monitor.forceUpdate()); - this.storageMonitors.forEach( ( channel, monitor ) -> monitor.forceUpdate() ); + tracker.applyChanges(); + } - tracker.applyChanges(); - } + private , C extends IStorageChannel> void postChangesToNetwork(final C chan, + final int upOrDown, final IItemList availableItems, final IActionSource src) { + this.storageMonitors.get(chan).postChange(upOrDown > 0, (Iterable) availableItems, src); + } - private , C extends IStorageChannel> void postChangesToNetwork( final C chan, final int upOrDown, final IItemList availableItems, final IActionSource src ) - { - this.storageMonitors.get( chan ).postChange( upOrDown > 0, (Iterable) availableItems, src ); - } + private , C extends IStorageChannel> NetworkInventoryHandler buildNetworkStorage( + final C chan) { + final SecurityCache security = this.getGrid().getCache(ISecurityGrid.class); - private , C extends IStorageChannel> NetworkInventoryHandler buildNetworkStorage( final C chan ) - { - final SecurityCache security = this.getGrid().getCache( ISecurityGrid.class ); + final NetworkInventoryHandler storageNetwork = new NetworkInventoryHandler<>(chan, security); - final NetworkInventoryHandler storageNetwork = new NetworkInventoryHandler<>( chan, security ); + for (final ICellProvider cc : this.activeCellProviders) { + for (final IMEInventoryHandler h : cc.getCellArray(chan)) { + storageNetwork.addNewStorage(h); + } + } - for( final ICellProvider cc : this.activeCellProviders ) - { - for( final IMEInventoryHandler h : cc.getCellArray( chan ) ) - { - storageNetwork.addNewStorage( h ); - } - } + return storageNetwork; + } - return storageNetwork; - } + @Override + public void postAlterationOfStoredItems(final IStorageChannel chan, final Iterable> input, + final IActionSource src) { + this.storageMonitors.get(chan).postChange(true, (Iterable) input, src); + } - @Override - public void postAlterationOfStoredItems( final IStorageChannel chan, final Iterable> input, final IActionSource src ) - { - this.storageMonitors.get( chan ).postChange( true, (Iterable) input, src ); - } + @Override + public void registerCellProvider(final ICellProvider provider) { + this.inactiveCellProviders.add(provider); + this.addCellProvider(provider, new CellChangeTracker()).applyChanges(); + } - @Override - public void registerCellProvider( final ICellProvider provider ) - { - this.inactiveCellProviders.add( provider ); - this.addCellProvider( provider, new CellChangeTracker() ).applyChanges(); - } + @Override + public void unregisterCellProvider(final ICellProvider provider) { + this.removeCellProvider(provider, new CellChangeTracker()).applyChanges(); + this.inactiveCellProviders.remove(provider); + } - @Override - public void unregisterCellProvider( final ICellProvider provider ) - { - this.removeCellProvider( provider, new CellChangeTracker() ).applyChanges(); - this.inactiveCellProviders.remove( provider ); - } + public GenericInterestManager getInterestManager() { + return this.interestManager; + } - public GenericInterestManager getInterestManager() - { - return this.interestManager; - } + IGrid getGrid() { + return this.myGrid; + } - IGrid getGrid() - { - return this.myGrid; - } + private class CellChangeTrackerRecord> { - private class CellChangeTrackerRecord> - { + final IStorageChannel channel; + final int up_or_down; + final IItemList list; + final IActionSource src; - final IStorageChannel channel; - final int up_or_down; - final IItemList list; - final IActionSource src; + public CellChangeTrackerRecord(final IStorageChannel channel, final int i, final IMEInventoryHandler h, + final IActionSource actionSrc) { + this.channel = channel; + this.up_or_down = i; + this.src = actionSrc; - public CellChangeTrackerRecord( final IStorageChannel channel, final int i, final IMEInventoryHandler h, final IActionSource actionSrc ) - { - this.channel = channel; - this.up_or_down = i; - this.src = actionSrc; + this.list = h.getAvailableItems(channel.createList()); + } - this.list = h.getAvailableItems( channel.createList() ); - } + public void applyChanges() { + GridStorageCache.this.postChangesToNetwork(this.channel, this.up_or_down, this.list, this.src); + } + } - public void applyChanges() - { - GridStorageCache.this.postChangesToNetwork( this.channel, this.up_or_down, this.list, this.src ); - } - } + private class CellChangeTracker> { - private class CellChangeTracker> - { + final List> data = new ArrayList<>(); - final List> data = new ArrayList<>(); + public void postChanges(final IStorageChannel channel, final int i, final IMEInventoryHandler h, + final IActionSource actionSrc) { + this.data.add(new CellChangeTrackerRecord(channel, i, h, actionSrc)); + } - public void postChanges( final IStorageChannel channel, final int i, final IMEInventoryHandler h, final IActionSource actionSrc ) - { - this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) ); - } - - public void applyChanges() - { - for( final CellChangeTrackerRecord rec : this.data ) - { - rec.applyChanges(); - } - } - } + public void applyChanges() { + for (final CellChangeTrackerRecord rec : this.data) { + rec.applyChanges(); + } + } + } } diff --git a/src/main/java/appeng/me/cache/NetworkMonitor.java b/src/main/java/appeng/me/cache/NetworkMonitor.java index efd417b07..596a8357f 100644 --- a/src/main/java/appeng/me/cache/NetworkMonitor.java +++ b/src/main/java/appeng/me/cache/NetworkMonitor.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.Collection; import java.util.Deque; import java.util.HashMap; @@ -45,291 +44,243 @@ import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; import appeng.me.storage.ItemWatcher; +public class NetworkMonitor> implements IMEMonitor { + @Nonnull + private static final Deque> GLOBAL_DEPTH = Queues.newArrayDeque(); -public class NetworkMonitor> implements IMEMonitor -{ - @Nonnull - private static final Deque> GLOBAL_DEPTH = Queues.newArrayDeque(); + @Nonnull + private final GridStorageCache myGridCache; + @Nonnull + private final IStorageChannel myChannel; + @Nonnull + private final IItemList cachedList; + @Nonnull + private final Map, Object> listeners; - @Nonnull - private final GridStorageCache myGridCache; - @Nonnull - private final IStorageChannel myChannel; - @Nonnull - private final IItemList cachedList; - @Nonnull - private final Map, Object> listeners; + private boolean sendEvent = false; + private boolean hasChanged = false; + @Nonnegative + private int localDepthSemaphore = 0; - private boolean sendEvent = false; - private boolean hasChanged = false; - @Nonnegative - private int localDepthSemaphore = 0; + public NetworkMonitor(final GridStorageCache cache, final IStorageChannel chan) { + this.myGridCache = cache; + this.myChannel = chan; + this.cachedList = chan.createList(); + this.listeners = new HashMap<>(); + } - public NetworkMonitor( final GridStorageCache cache, final IStorageChannel chan ) - { - this.myGridCache = cache; - this.myChannel = chan; - this.cachedList = chan.createList(); - this.listeners = new HashMap<>(); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public boolean canAccept(final T input) { + return this.getHandler().canAccept(input); + } - @Override - public boolean canAccept( final T input ) - { - return this.getHandler().canAccept( input ); - } + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + if (mode == Actionable.SIMULATE) { + return this.getHandler().extractItems(request, mode, src); + } - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.SIMULATE ) - { - return this.getHandler().extractItems( request, mode, src ); - } + this.localDepthSemaphore++; + final T leftover = this.getHandler().extractItems(request, mode, src); + this.localDepthSemaphore--; - this.localDepthSemaphore++; - final T leftover = this.getHandler().extractItems( request, mode, src ); - this.localDepthSemaphore--; + if (this.localDepthSemaphore == 0) { + this.monitorDifference(request.copy(), leftover, true, src); + } - if( this.localDepthSemaphore == 0 ) - { - this.monitorDifference( request.copy(), leftover, true, src ); - } + return leftover; + } - return leftover; - } + @Override + public AccessRestriction getAccess() { + return this.getHandler().getAccess(); + } - @Override - public AccessRestriction getAccess() - { - return this.getHandler().getAccess(); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return this.getHandler().getAvailableItems(out); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return this.getHandler().getAvailableItems( out ); - } + @Override + public IStorageChannel getChannel() { + return this.getHandler().getChannel(); + } - @Override - public IStorageChannel getChannel() - { - return this.getHandler().getChannel(); - } + @Override + public int getPriority() { + return this.getHandler().getPriority(); + } - @Override - public int getPriority() - { - return this.getHandler().getPriority(); - } + @Override + public int getSlot() { + return this.getHandler().getSlot(); + } - @Override - public int getSlot() - { - return this.getHandler().getSlot(); - } + @Nonnull + @Override + public IItemList getStorageList() { + if (this.hasChanged) { + this.hasChanged = false; + this.cachedList.resetStatus(); + return this.getAvailableItems(this.cachedList); + } - @Nonnull - @Override - public IItemList getStorageList() - { - if( this.hasChanged ) - { - this.hasChanged = false; - this.cachedList.resetStatus(); - return this.getAvailableItems( this.cachedList ); - } + return this.cachedList; + } - return this.cachedList; - } + @Override + public T injectItems(final T input, final Actionable mode, final IActionSource src) { + if (mode == Actionable.SIMULATE) { + return this.getHandler().injectItems(input, mode, src); + } - @Override - public T injectItems( final T input, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.SIMULATE ) - { - return this.getHandler().injectItems( input, mode, src ); - } + this.localDepthSemaphore++; + final T leftover = this.getHandler().injectItems(input, mode, src); + this.localDepthSemaphore--; - this.localDepthSemaphore++; - final T leftover = this.getHandler().injectItems( input, mode, src ); - this.localDepthSemaphore--; + if (this.localDepthSemaphore == 0) { + this.monitorDifference(input.copy(), leftover, false, src); + } - if( this.localDepthSemaphore == 0 ) - { - this.monitorDifference( input.copy(), leftover, false, src ); - } + return leftover; + } - return leftover; - } + @Override + public boolean isPrioritized(final T input) { + return this.getHandler().isPrioritized(input); + } - @Override - public boolean isPrioritized( final T input ) - { - return this.getHandler().isPrioritized( input ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public boolean validForPass(final int i) { + return this.getHandler().validForPass(i); + } - @Override - public boolean validForPass( final int i ) - { - return this.getHandler().validForPass( i ); - } + @Nullable + private IMEInventoryHandler getHandler() { + return this.myGridCache.getInventoryHandler(this.myChannel); + } - @Nullable - private IMEInventoryHandler getHandler() - { - return this.myGridCache.getInventoryHandler( this.myChannel ); - } + private Iterator, Object>> getListeners() { + return this.listeners.entrySet().iterator(); + } - private Iterator, Object>> getListeners() - { - return this.listeners.entrySet().iterator(); - } + private T monitorDifference(final IAEStack original, final T leftOvers, final boolean extraction, + final IActionSource src) { + final T diff = original.copy(); - private T monitorDifference( final IAEStack original, final T leftOvers, final boolean extraction, final IActionSource src ) - { - final T diff = original.copy(); + if (extraction) { + diff.setStackSize(leftOvers == null ? 0 : -leftOvers.getStackSize()); + } else if (leftOvers != null) { + diff.decStackSize(leftOvers.getStackSize()); + } - if( extraction ) - { - diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() ); - } - else if( leftOvers != null ) - { - diff.decStackSize( leftOvers.getStackSize() ); - } + if (diff.getStackSize() != 0) { + this.postChangesToListeners(ImmutableList.of(diff), src); + } - if( diff.getStackSize() != 0 ) - { - this.postChangesToListeners( ImmutableList.of( diff ), src ); - } + return leftOvers; + } - return leftOvers; - } + private void notifyListenersOfChange(final Iterable diff, final IActionSource src) { + this.hasChanged = true; + final Iterator, Object>> i = this.getListeners(); - private void notifyListenersOfChange( final Iterable diff, final IActionSource src ) - { - this.hasChanged = true; - final Iterator, Object>> i = this.getListeners(); + while (i.hasNext()) { + final Entry, Object> o = i.next(); + final IMEMonitorHandlerReceiver receiver = o.getKey(); + if (receiver.isValid(o.getValue())) { + receiver.postChange(this, diff, src); + } else { + i.remove(); + } + } + } - while( i.hasNext() ) - { - final Entry, Object> o = i.next(); - final IMEMonitorHandlerReceiver receiver = o.getKey(); - if( receiver.isValid( o.getValue() ) ) - { - receiver.postChange( this, diff, src ); - } - else - { - i.remove(); - } - } - } + private void postChangesToListeners(final Iterable changes, final IActionSource src) { + this.postChange(true, changes, src); + } - private void postChangesToListeners( final Iterable changes, final IActionSource src ) - { - this.postChange( true, changes, src ); - } + protected void postChange(final boolean add, final Iterable changes, final IActionSource src) { + if (this.localDepthSemaphore > 0 || GLOBAL_DEPTH.contains(this)) { + return; + } - protected void postChange( final boolean add, final Iterable changes, final IActionSource src ) - { - if( this.localDepthSemaphore > 0 || GLOBAL_DEPTH.contains( this ) ) - { - return; - } + GLOBAL_DEPTH.push(this); + this.localDepthSemaphore++; - GLOBAL_DEPTH.push( this ); - this.localDepthSemaphore++; + this.sendEvent = true; - this.sendEvent = true; + this.notifyListenersOfChange(changes, src); - this.notifyListenersOfChange( changes, src ); + for (final T changedItem : changes) { + T difference = changedItem; - for( final T changedItem : changes ) - { - T difference = changedItem; + if (!add && changedItem != null) { + difference = changedItem.copy(); + difference.setStackSize(-changedItem.getStackSize()); + } - if( !add && changedItem != null ) - { - difference = changedItem.copy(); - difference.setStackSize( -changedItem.getStackSize() ); - } + if (this.myGridCache.getInterestManager().containsKey(changedItem)) { + final Collection list = this.myGridCache.getInterestManager().get(changedItem); - if( this.myGridCache.getInterestManager().containsKey( changedItem ) ) - { - final Collection list = this.myGridCache.getInterestManager().get( changedItem ); + if (!list.isEmpty()) { + IAEStack fullStack = this.getStorageList().findPrecise(changedItem); - if( !list.isEmpty() ) - { - IAEStack fullStack = this.getStorageList().findPrecise( changedItem ); + if (fullStack == null) { + fullStack = changedItem.copy(); + fullStack.setStackSize(0); + } - if( fullStack == null ) - { - fullStack = changedItem.copy(); - fullStack.setStackSize( 0 ); - } + this.myGridCache.getInterestManager().enableTransactions(); - this.myGridCache.getInterestManager().enableTransactions(); + for (final ItemWatcher iw : list) { + iw.getHost().onStackChange(this.getStorageList(), fullStack, difference, src, + this.getChannel()); + } - for( final ItemWatcher iw : list ) - { - iw.getHost().onStackChange( this.getStorageList(), fullStack, difference, src, this.getChannel() ); - } + this.myGridCache.getInterestManager().disableTransactions(); + } + } + } - this.myGridCache.getInterestManager().disableTransactions(); - } - } - } + final NetworkMonitor last = GLOBAL_DEPTH.pop(); + this.localDepthSemaphore--; - final NetworkMonitor last = GLOBAL_DEPTH.pop(); - this.localDepthSemaphore--; + if (last != this) { + throw new IllegalStateException("Invalid Access to Networked Storage API detected."); + } + } - if( last != this ) - { - throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); - } - } + void forceUpdate() { + this.hasChanged = true; - void forceUpdate() - { - this.hasChanged = true; + final Iterator, Object>> i = this.getListeners(); + while (i.hasNext()) { + final Entry, Object> o = i.next(); + final IMEMonitorHandlerReceiver receiver = o.getKey(); - final Iterator, Object>> i = this.getListeners(); - while( i.hasNext() ) - { - final Entry, Object> o = i.next(); - final IMEMonitorHandlerReceiver receiver = o.getKey(); + if (receiver.isValid(o.getValue())) { + receiver.onListUpdate(); + } else { + i.remove(); + } + } + } - if( receiver.isValid( o.getValue() ) ) - { - receiver.onListUpdate(); - } - else - { - i.remove(); - } - } - } - - void onTick() - { - if( this.sendEvent ) - { - this.sendEvent = false; - this.myGridCache.getGrid().postEvent( new MENetworkStorageEvent( this, this.myChannel ) ); - } - } + void onTick() { + if (this.sendEvent) { + this.sendEvent = false; + this.myGridCache.getGrid().postEvent(new MENetworkStorageEvent(this, this.myChannel)); + } + } } diff --git a/src/main/java/appeng/me/cache/P2PCache.java b/src/main/java/appeng/me/cache/P2PCache.java index f25bbb080..b36db03d6 100644 --- a/src/main/java/appeng/me/cache/P2PCache.java +++ b/src/main/java/appeng/me/cache/P2PCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.HashMap; import java.util.Random; @@ -40,221 +39,176 @@ import appeng.me.cache.helpers.TunnelCollection; import appeng.parts.p2p.PartP2PTunnel; import appeng.parts.p2p.PartP2PTunnelME; +public class P2PCache implements IGridCache { + private static final TunnelCollection NULL_COLLECTION = new TunnelCollection(null, + null); -public class P2PCache implements IGridCache -{ - private static final TunnelCollection NULL_COLLECTION = new TunnelCollection( null, null ); + private final IGrid myGrid; + private final HashMap inputs = new HashMap<>(); + private final Multimap outputs = LinkedHashMultimap.create(); + private final Random frequencyGenerator; - private final IGrid myGrid; - private final HashMap inputs = new HashMap<>(); - private final Multimap outputs = LinkedHashMultimap.create(); - private final Random frequencyGenerator; + public P2PCache(final IGrid g) { + this.myGrid = g; + this.frequencyGenerator = new Random(g.hashCode()); + } - public P2PCache( final IGrid g ) - { - this.myGrid = g; - this.frequencyGenerator = new Random( g.hashCode() ); - } + @MENetworkEventSubscribe + public void bootComplete(final MENetworkBootingStatusChange bootStatus) { + final ITickManager tm = this.myGrid.getCache(ITickManager.class); + for (final PartP2PTunnel me : this.inputs.values()) { + if (me instanceof PartP2PTunnelME) { + tm.wakeDevice(me.getGridNode()); + } + } + } - @MENetworkEventSubscribe - public void bootComplete( final MENetworkBootingStatusChange bootStatus ) - { - final ITickManager tm = this.myGrid.getCache( ITickManager.class ); - for( final PartP2PTunnel me : this.inputs.values() ) - { - if( me instanceof PartP2PTunnelME ) - { - tm.wakeDevice( me.getGridNode() ); - } - } - } + @MENetworkEventSubscribe + public void bootComplete(final MENetworkPowerStatusChange power) { + final ITickManager tm = this.myGrid.getCache(ITickManager.class); + for (final PartP2PTunnel me : this.inputs.values()) { + if (me instanceof PartP2PTunnelME) { + tm.wakeDevice(me.getGridNode()); + } + } + } - @MENetworkEventSubscribe - public void bootComplete( final MENetworkPowerStatusChange power ) - { - final ITickManager tm = this.myGrid.getCache( ITickManager.class ); - for( final PartP2PTunnel me : this.inputs.values() ) - { - if( me instanceof PartP2PTunnelME ) - { - tm.wakeDevice( me.getGridNode() ); - } - } - } + @Override + public void onUpdateTick() { - @Override - public void onUpdateTick() - { + } - } + @Override + public void removeNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof PartP2PTunnel) { + if (machine instanceof PartP2PTunnelME) { + if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL)) { + return; + } + } - @Override - public void removeNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof PartP2PTunnel ) - { - if( machine instanceof PartP2PTunnelME ) - { - if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) ) - { - return; - } - } + final PartP2PTunnel t = (PartP2PTunnel) machine; + // AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq ); - final PartP2PTunnel t = (PartP2PTunnel) machine; - // AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq ); + if (t.isOutput()) { + this.outputs.remove(t.getFrequency(), t); + } else { + this.inputs.remove(t.getFrequency()); + } - if( t.isOutput() ) - { - this.outputs.remove( t.getFrequency(), t ); - } - else - { - this.inputs.remove( t.getFrequency() ); - } + this.updateTunnel(t.getFrequency(), !t.isOutput(), false); + } + } - this.updateTunnel( t.getFrequency(), !t.isOutput(), false ); - } - } + @Override + public void addNode(final IGridNode node, final IGridHost machine) { + if (machine instanceof PartP2PTunnel) { + if (machine instanceof PartP2PTunnelME) { + if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL)) { + return; + } + } - @Override - public void addNode( final IGridNode node, final IGridHost machine ) - { - if( machine instanceof PartP2PTunnel ) - { - if( machine instanceof PartP2PTunnelME ) - { - if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) ) - { - return; - } - } + final PartP2PTunnel t = (PartP2PTunnel) machine; + // AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq ); - final PartP2PTunnel t = (PartP2PTunnel) machine; - // AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq ); + if (t.isOutput()) { + this.outputs.put(t.getFrequency(), t); + } else { + this.inputs.put(t.getFrequency(), t); + } - if( t.isOutput() ) - { - this.outputs.put( t.getFrequency(), t ); - } - else - { - this.inputs.put( t.getFrequency(), t ); - } + this.updateTunnel(t.getFrequency(), !t.isOutput(), false); + } + } - this.updateTunnel( t.getFrequency(), !t.isOutput(), false ); - } - } + @Override + public void onSplit(final IGridStorage storageB) { - @Override - public void onSplit( final IGridStorage storageB ) - { + } - } + @Override + public void onJoin(final IGridStorage storageB) { - @Override - public void onJoin( final IGridStorage storageB ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage storage) { - @Override - public void populateGridStorage( final IGridStorage storage ) - { + } - } + private void updateTunnel(final short freq, final boolean updateOutputs, final boolean configChange) { + for (final PartP2PTunnel p : this.outputs.get(freq)) { + if (configChange) { + p.onTunnelConfigChange(); + } + p.onTunnelNetworkChange(); + } - private void updateTunnel( final short freq, final boolean updateOutputs, final boolean configChange ) - { - for( final PartP2PTunnel p : this.outputs.get( freq ) ) - { - if( configChange ) - { - p.onTunnelConfigChange(); - } - p.onTunnelNetworkChange(); - } + final PartP2PTunnel in = this.inputs.get(freq); + if (in != null) { + if (configChange) { + in.onTunnelConfigChange(); + } + in.onTunnelNetworkChange(); + } + } - final PartP2PTunnel in = this.inputs.get( freq ); - if( in != null ) - { - if( configChange ) - { - in.onTunnelConfigChange(); - } - in.onTunnelNetworkChange(); - } - } + public void updateFreq(final PartP2PTunnel t, final short newFrequency) { + if (this.outputs.containsValue(t)) { + this.outputs.remove(t.getFrequency(), t); + } - public void updateFreq( final PartP2PTunnel t, final short newFrequency ) - { - if( this.outputs.containsValue( t ) ) - { - this.outputs.remove( t.getFrequency(), t ); - } + if (this.inputs.containsValue(t)) { + this.inputs.remove(t.getFrequency()); + } - if( this.inputs.containsValue( t ) ) - { - this.inputs.remove( t.getFrequency() ); - } + t.setFrequency(newFrequency); - t.setFrequency( newFrequency ); + if (t.isOutput()) { + this.outputs.put(t.getFrequency(), t); + } else { + this.inputs.put(t.getFrequency(), t); + } - if( t.isOutput() ) - { - this.outputs.put( t.getFrequency(), t ); - } - else - { - this.inputs.put( t.getFrequency(), t ); - } + // AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq ); + this.updateTunnel(t.getFrequency(), t.isOutput(), true); + this.updateTunnel(t.getFrequency(), !t.isOutput(), true); + } - // AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq ); - this.updateTunnel( t.getFrequency(), t.isOutput(), true ); - this.updateTunnel( t.getFrequency(), !t.isOutput(), true ); - } + public short newFrequency() { + short newFrequency; + int cycles = 0; - public short newFrequency() - { - short newFrequency; - int cycles = 0; + do { + newFrequency = (short) this.frequencyGenerator.nextInt(1 << 16); + cycles++; + } while (newFrequency == 0 || this.inputs.containsKey(newFrequency)); - do - { - newFrequency = (short) this.frequencyGenerator.nextInt( 1 << 16 ); - cycles++; - } - while( newFrequency == 0 || this.inputs.containsKey( newFrequency ) ); + if (cycles > 25) { + AELog.debug("Generating a new P2P frequency '%1$d' took %2$d cycles", newFrequency, cycles); + } - if( cycles > 25 ) - { - AELog.debug( "Generating a new P2P frequency '%1$d' took %2$d cycles", newFrequency, cycles ); - } + return newFrequency; + } - return newFrequency; - } + public TunnelCollection getOutputs(final short freq, final Class c) { + final PartP2PTunnel in = this.inputs.get(freq); - public TunnelCollection getOutputs( final short freq, final Class c ) - { - final PartP2PTunnel in = this.inputs.get( freq ); + if (in == null) { + return NULL_COLLECTION; + } - if( in == null ) - { - return NULL_COLLECTION; - } + final TunnelCollection out = this.inputs.get(freq).getCollection(this.outputs.get(freq), c); - final TunnelCollection out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c ); + if (out == null) { + return NULL_COLLECTION; + } - if( out == null ) - { - return NULL_COLLECTION; - } + return out; + } - return out; - } - - public PartP2PTunnel getInput( final short freq ) - { - return this.inputs.get( freq ); - } + public PartP2PTunnel getInput(final short freq) { + return this.inputs.get(freq); + } } diff --git a/src/main/java/appeng/me/cache/PathGridCache.java b/src/main/java/appeng/me/cache/PathGridCache.java index 3961ddfd5..b9096d2c8 100644 --- a/src/main/java/appeng/me/cache/PathGridCache.java +++ b/src/main/java/appeng/me/cache/PathGridCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.ArrayList; import java.util.EnumSet; import java.util.HashSet; @@ -29,6 +28,8 @@ import java.util.Set; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; +import appeng.api.AEApi; +import appeng.api.features.AEFeature; import appeng.api.networking.GridFlags; import appeng.api.networking.IGrid; import appeng.api.networking.IGridBlock; @@ -47,8 +48,6 @@ import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.core.AEConfig; import appeng.core.AppEng; -import appeng.api.AEApi; -import appeng.api.features.AEFeature; import appeng.core.stats.IAdvancementTrigger; import appeng.me.GridConnection; import appeng.me.GridNode; @@ -59,395 +58,323 @@ import appeng.me.pathfinding.IPathItem; import appeng.me.pathfinding.PathSegment; import appeng.tile.networking.TileController; +public class PathGridCache implements IPathingGrid { -public class PathGridCache implements IPathingGrid -{ + private final List active = new ArrayList<>(); + private final Set controllers = new HashSet<>(); + private final Set requireChannels = new HashSet<>(); + private final Set blockDense = new HashSet<>(); + private final IGrid myGrid; + private int channelsInUse = 0; + private int channelsByBlocks = 0; + private double channelPowerUsage = 0.0; + private boolean recalculateControllerNextTick = true; + private boolean updateNetwork = true; + private boolean booting = false; + private ControllerState controllerState = ControllerState.NO_CONTROLLER; + private int ticksUntilReady = 20; + private int lastChannels = 0; + private HashSet semiOpen = new HashSet<>(); - private final List active = new ArrayList<>(); - private final Set controllers = new HashSet<>(); - private final Set requireChannels = new HashSet<>(); - private final Set blockDense = new HashSet<>(); - private final IGrid myGrid; - private int channelsInUse = 0; - private int channelsByBlocks = 0; - private double channelPowerUsage = 0.0; - private boolean recalculateControllerNextTick = true; - private boolean updateNetwork = true; - private boolean booting = false; - private ControllerState controllerState = ControllerState.NO_CONTROLLER; - private int ticksUntilReady = 20; - private int lastChannels = 0; - private HashSet semiOpen = new HashSet<>(); + public PathGridCache(final IGrid g) { + this.myGrid = g; + } - public PathGridCache( final IGrid g ) - { - this.myGrid = g; - } + @Override + public void onUpdateTick() { + if (this.recalculateControllerNextTick) { + this.recalcController(); + } - @Override - public void onUpdateTick() - { - if( this.recalculateControllerNextTick ) - { - this.recalcController(); - } + if (this.updateNetwork) { + if (!this.booting) { + this.myGrid.postEvent(new MENetworkBootingStatusChange()); + } - if( this.updateNetwork ) - { - if( !this.booting ) - { - this.myGrid.postEvent( new MENetworkBootingStatusChange() ); - } + this.booting = true; + this.updateNetwork = false; + this.setChannelsInUse(0); - this.booting = true; - this.updateNetwork = false; - this.setChannelsInUse( 0 ); + if (!AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS)) { + final int used = this.calculateRequiredChannels(); - if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) ) - { - final int used = this.calculateRequiredChannels(); + final int nodes = this.myGrid.getNodes().size(); + this.ticksUntilReady = 20 + Math.max(0, nodes / 100 - 20); + this.setChannelsByBlocks(nodes * used); + this.setChannelPowerUsage(this.getChannelsByBlocks() / 128.0); - final int nodes = this.myGrid.getNodes().size(); - this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 ); - this.setChannelsByBlocks( nodes * used ); - this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 ); + this.myGrid.getPivot().beginVisit(new AdHocChannelUpdater(used)); + } else if (this.controllerState == ControllerState.NO_CONTROLLER) { + final int requiredChannels = this.calculateRequiredChannels(); + int used = requiredChannels; + if (requiredChannels > 8) { + used = 0; + } - this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) ); - } - else if( this.controllerState == ControllerState.NO_CONTROLLER ) - { - final int requiredChannels = this.calculateRequiredChannels(); - int used = requiredChannels; - if( requiredChannels > 8 ) - { - used = 0; - } + final int nodes = this.myGrid.getNodes().size(); + this.setChannelsInUse(used); - final int nodes = this.myGrid.getNodes().size(); - this.setChannelsInUse( used ); + this.ticksUntilReady = 20 + Math.max(0, nodes / 100 - 20); + this.setChannelsByBlocks(nodes * used); + this.setChannelPowerUsage(this.getChannelsByBlocks() / 128.0); - this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 ); - this.setChannelsByBlocks( nodes * used ); - this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 ); + this.myGrid.getPivot().beginVisit(new AdHocChannelUpdater(used)); + } else if (this.controllerState == ControllerState.CONTROLLER_CONFLICT) { + this.ticksUntilReady = 20; + this.myGrid.getPivot().beginVisit(new AdHocChannelUpdater(0)); + } else { + final int nodes = this.myGrid.getNodes().size(); + this.ticksUntilReady = 20 + Math.max(0, nodes / 100 - 20); + final HashSet closedList = new HashSet<>(); + this.semiOpen = new HashSet<>(); - this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) ); - } - else if( this.controllerState == ControllerState.CONTROLLER_CONFLICT ) - { - this.ticksUntilReady = 20; - this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) ); - } - else - { - final int nodes = this.myGrid.getNodes().size(); - this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 ); - final HashSet closedList = new HashSet<>(); - this.semiOpen = new HashSet<>(); + // myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) + // ); + for (final IGridNode node : this.myGrid.getMachines(TileController.class)) { + closedList.add((IPathItem) node); + for (final IGridConnection gcc : node.getConnections()) { + final GridConnection gc = (GridConnection) gcc; + if (!(gc.getOtherSide(node).getMachine() instanceof TileController)) { + final List open = new ArrayList<>(); + closedList.add(gc); + open.add(gc); + gc.setControllerRoute((GridNode) node, true); + this.active.add(new PathSegment(this, open, this.semiOpen, closedList)); + } + } + } + } + } - // myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) - // ); - for( final IGridNode node : this.myGrid.getMachines( TileController.class ) ) - { - closedList.add( (IPathItem) node ); - for( final IGridConnection gcc : node.getConnections() ) - { - final GridConnection gc = (GridConnection) gcc; - if( !( gc.getOtherSide( node ).getMachine() instanceof TileController ) ) - { - final List open = new ArrayList<>(); - closedList.add( gc ); - open.add( gc ); - gc.setControllerRoute( (GridNode) node, true ); - this.active.add( new PathSegment( this, open, this.semiOpen, closedList ) ); - } - } - } - } - } + if (!this.active.isEmpty() || this.ticksUntilReady > 0) { + final Iterator i = this.active.iterator(); + while (i.hasNext()) { + final PathSegment pat = i.next(); + if (pat.step()) { + pat.setDead(true); + i.remove(); + } + } - if( !this.active.isEmpty() || this.ticksUntilReady > 0 ) - { - final Iterator i = this.active.iterator(); - while( i.hasNext() ) - { - final PathSegment pat = i.next(); - if( pat.step() ) - { - pat.setDead( true ); - i.remove(); - } - } + this.ticksUntilReady--; - this.ticksUntilReady--; + if (this.active.isEmpty() && this.ticksUntilReady <= 0) { + if (this.controllerState == ControllerState.CONTROLLER_ONLINE) { + final Iterator controllerIterator = this.controllers.iterator(); + if (controllerIterator.hasNext()) { + final TileController controller = controllerIterator.next(); + controller.getGridNode(AEPartLocation.INTERNAL).beginVisit(new ControllerChannelUpdater()); + } + } - if( this.active.isEmpty() && this.ticksUntilReady <= 0 ) - { - if( this.controllerState == ControllerState.CONTROLLER_ONLINE ) - { - final Iterator controllerIterator = this.controllers.iterator(); - if( controllerIterator.hasNext() ) - { - final TileController controller = controllerIterator.next(); - controller.getGridNode( AEPartLocation.INTERNAL ).beginVisit( new ControllerChannelUpdater() ); - } - } + // check for achievements + this.achievementPost(); - // check for achievements - this.achievementPost(); + this.booting = false; + this.setChannelPowerUsage(this.getChannelsByBlocks() / 128.0); + this.myGrid.postEvent(new MENetworkBootingStatusChange()); + } + } + } - this.booting = false; - this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 ); - this.myGrid.postEvent( new MENetworkBootingStatusChange() ); - } - } - } + @Override + public void removeNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof TileController) { + this.controllers.remove(machine); + this.recalculateControllerNextTick = true; + } - @Override - public void removeNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof TileController ) - { - this.controllers.remove( machine ); - this.recalculateControllerNextTick = true; - } + final EnumSet flags = gridNode.getGridBlock().getFlags(); - final EnumSet flags = gridNode.getGridBlock().getFlags(); + if (flags.contains(GridFlags.REQUIRE_CHANNEL)) { + this.requireChannels.remove(gridNode); + } - if( flags.contains( GridFlags.REQUIRE_CHANNEL ) ) - { - this.requireChannels.remove( gridNode ); - } + if (flags.contains(GridFlags.CANNOT_CARRY_COMPRESSED)) { + this.blockDense.remove(gridNode); + } - if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) - { - this.blockDense.remove( gridNode ); - } + this.repath(); + } - this.repath(); - } + @Override + public void addNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof TileController) { + this.controllers.add((TileController) machine); + this.recalculateControllerNextTick = true; + } - @Override - public void addNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof TileController ) - { - this.controllers.add( (TileController) machine ); - this.recalculateControllerNextTick = true; - } + final EnumSet flags = gridNode.getGridBlock().getFlags(); - final EnumSet flags = gridNode.getGridBlock().getFlags(); + if (flags.contains(GridFlags.REQUIRE_CHANNEL)) { + this.requireChannels.add(gridNode); + } - if( flags.contains( GridFlags.REQUIRE_CHANNEL ) ) - { - this.requireChannels.add( gridNode ); - } + if (flags.contains(GridFlags.CANNOT_CARRY_COMPRESSED)) { + this.blockDense.add(gridNode); + } - if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) - { - this.blockDense.add( gridNode ); - } + this.repath(); + } - this.repath(); - } + @Override + public void onSplit(final IGridStorage storageB) { - @Override - public void onSplit( final IGridStorage storageB ) - { + } - } + @Override + public void onJoin(final IGridStorage storageB) { - @Override - public void onJoin( final IGridStorage storageB ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage storage) { - @Override - public void populateGridStorage( final IGridStorage storage ) - { + } - } + private void recalcController() { + this.recalculateControllerNextTick = false; + final ControllerState old = this.controllerState; - private void recalcController() - { - this.recalculateControllerNextTick = false; - final ControllerState old = this.controllerState; + if (this.controllers.isEmpty()) { + this.controllerState = ControllerState.NO_CONTROLLER; + } else { + final IGridNode startingNode = this.controllers.iterator().next().getGridNode(AEPartLocation.INTERNAL); + if (startingNode == null) { + this.controllerState = ControllerState.CONTROLLER_CONFLICT; + return; + } - if( this.controllers.isEmpty() ) - { - this.controllerState = ControllerState.NO_CONTROLLER; - } - else - { - final IGridNode startingNode = this.controllers.iterator().next().getGridNode( AEPartLocation.INTERNAL ); - if( startingNode == null ) - { - this.controllerState = ControllerState.CONTROLLER_CONFLICT; - return; - } + final DimensionalCoord dc = startingNode.getGridBlock().getLocation(); + final ControllerValidator cv = new ControllerValidator(dc.x, dc.y, dc.z); - final DimensionalCoord dc = startingNode.getGridBlock().getLocation(); - final ControllerValidator cv = new ControllerValidator( dc.x, dc.y, dc.z ); + startingNode.beginVisit(cv); - startingNode.beginVisit( cv ); + if (cv.isValid() && cv.getFound() == this.controllers.size()) { + this.controllerState = ControllerState.CONTROLLER_ONLINE; + } else { + this.controllerState = ControllerState.CONTROLLER_CONFLICT; + } + } - if( cv.isValid() && cv.getFound() == this.controllers.size() ) - { - this.controllerState = ControllerState.CONTROLLER_ONLINE; - } - else - { - this.controllerState = ControllerState.CONTROLLER_CONFLICT; - } - } + if (old != this.controllerState) { + this.myGrid.postEvent(new MENetworkControllerChange()); + } + } - if( old != this.controllerState ) - { - this.myGrid.postEvent( new MENetworkControllerChange() ); - } - } + private int calculateRequiredChannels() { + this.semiOpen.clear(); - private int calculateRequiredChannels() - { - this.semiOpen.clear(); + int depth = 0; + for (final IGridNode nodes : this.requireChannels) { + if (!this.semiOpen.contains(nodes)) { + final IGridBlock gb = nodes.getGridBlock(); + final EnumSet flags = gb.getFlags(); - int depth = 0; - for( final IGridNode nodes : this.requireChannels ) - { - if( !this.semiOpen.contains( nodes ) ) - { - final IGridBlock gb = nodes.getGridBlock(); - final EnumSet flags = gb.getFlags(); + if (flags.contains(GridFlags.COMPRESSED_CHANNEL) && !this.blockDense.isEmpty()) { + return 9; + } - if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() ) - { - return 9; - } + depth++; - depth++; + if (flags.contains(GridFlags.MULTIBLOCK)) { + final IGridMultiblock gmb = (IGridMultiblock) gb; + final Iterator i = gmb.getMultiblockNodes(); + while (i.hasNext()) { + this.semiOpen.add((IPathItem) i.next()); + } + } + } + } - if( flags.contains( GridFlags.MULTIBLOCK ) ) - { - final IGridMultiblock gmb = (IGridMultiblock) gb; - final Iterator i = gmb.getMultiblockNodes(); - while( i.hasNext() ) - { - this.semiOpen.add( (IPathItem) i.next() ); - } - } - } - } + return depth; + } - return depth; - } + private void achievementPost() { + if (this.lastChannels != this.getChannelsInUse() && AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS)) { + final IAdvancementTrigger currentBracket = this.getAchievementBracket(this.getChannelsInUse()); + final IAdvancementTrigger lastBracket = this.getAchievementBracket(this.lastChannels); + if (currentBracket != lastBracket && currentBracket != null) { + for (final IGridNode n : this.requireChannels) { + PlayerEntity player = AEApi.instance().registries().players().findPlayer(n.getPlayerID()); + if (player instanceof ServerPlayerEntity) { + currentBracket.trigger((ServerPlayerEntity) player); + } + } + } + } + this.lastChannels = this.getChannelsInUse(); + } - private void achievementPost() - { - if( this.lastChannels != this.getChannelsInUse() && AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) ) - { - final IAdvancementTrigger currentBracket = this.getAchievementBracket( this.getChannelsInUse() ); - final IAdvancementTrigger lastBracket = this.getAchievementBracket( this.lastChannels ); - if( currentBracket != lastBracket && currentBracket != null ) - { - for( final IGridNode n : this.requireChannels ) - { - PlayerEntity player = AEApi.instance().registries().players().findPlayer( n.getPlayerID() ); - if( player instanceof ServerPlayerEntity ) - { - currentBracket.trigger( (ServerPlayerEntity) player ); - } - } - } - } - this.lastChannels = this.getChannelsInUse(); - } + private IAdvancementTrigger getAchievementBracket(final int ch) { + if (ch < 8) { + return null; + } - private IAdvancementTrigger getAchievementBracket( final int ch ) - { - if( ch < 8 ) - { - return null; - } + if (ch < 128) { + return AppEng.instance().getAdvancementTriggers().getNetworkApprentice(); + } - if( ch < 128 ) - { - return AppEng.instance().getAdvancementTriggers().getNetworkApprentice(); - } + if (ch < 2048) { + return AppEng.instance().getAdvancementTriggers().getNetworkEngineer(); + } - if( ch < 2048 ) - { - return AppEng.instance().getAdvancementTriggers().getNetworkEngineer(); - } + return AppEng.instance().getAdvancementTriggers().getNetworkAdmin(); + } - return AppEng.instance().getAdvancementTriggers().getNetworkAdmin(); - } + @MENetworkEventSubscribe + void updateNodReq(final MENetworkChannelChanged ev) { + final IGridNode gridNode = ev.node; - @MENetworkEventSubscribe - void updateNodReq( final MENetworkChannelChanged ev ) - { - final IGridNode gridNode = ev.node; + if (gridNode.getGridBlock().getFlags().contains(GridFlags.REQUIRE_CHANNEL)) { + this.requireChannels.add(gridNode); + } else { + this.requireChannels.remove(gridNode); + } - if( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) ) - { - this.requireChannels.add( gridNode ); - } - else - { - this.requireChannels.remove( gridNode ); - } + this.repath(); + } - this.repath(); - } + @Override + public boolean isNetworkBooting() { + return !this.booting && !this.active.isEmpty(); + } - @Override - public boolean isNetworkBooting() - { - return !this.booting && !this.active.isEmpty(); - } + @Override + public ControllerState getControllerState() { + return this.controllerState; + } - @Override - public ControllerState getControllerState() - { - return this.controllerState; - } + @Override + public void repath() { + // clean up... + this.active.clear(); - @Override - public void repath() - { - // clean up... - this.active.clear(); + this.setChannelsByBlocks(0); + this.updateNetwork = true; + } - this.setChannelsByBlocks( 0 ); - this.updateNetwork = true; - } + double getChannelPowerUsage() { + return this.channelPowerUsage; + } - double getChannelPowerUsage() - { - return this.channelPowerUsage; - } + private void setChannelPowerUsage(final double channelPowerUsage) { + this.channelPowerUsage = channelPowerUsage; + } - private void setChannelPowerUsage( final double channelPowerUsage ) - { - this.channelPowerUsage = channelPowerUsage; - } + public int getChannelsByBlocks() { + return this.channelsByBlocks; + } - public int getChannelsByBlocks() - { - return this.channelsByBlocks; - } + public void setChannelsByBlocks(final int channelsByBlocks) { + this.channelsByBlocks = channelsByBlocks; + } - public void setChannelsByBlocks( final int channelsByBlocks ) - { - this.channelsByBlocks = channelsByBlocks; - } + public int getChannelsInUse() { + return this.channelsInUse; + } - public int getChannelsInUse() - { - return this.channelsInUse; - } - - public void setChannelsInUse( final int channelsInUse ) - { - this.channelsInUse = channelsInUse; - } + public void setChannelsInUse(final int channelsInUse) { + this.channelsInUse = channelsInUse; + } } diff --git a/src/main/java/appeng/me/cache/SecurityCache.java b/src/main/java/appeng/me/cache/SecurityCache.java index 1bbf5a627..423372570 100644 --- a/src/main/java/appeng/me/cache/SecurityCache.java +++ b/src/main/java/appeng/me/cache/SecurityCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -41,162 +40,130 @@ import appeng.api.networking.security.ISecurityProvider; import appeng.core.worlddata.WorldData; import appeng.me.GridNode; +public class SecurityCache implements ISecurityGrid { -public class SecurityCache implements ISecurityGrid -{ + private final IGrid myGrid; + private final List securityProvider = new ArrayList<>(); + private final HashMap> playerPerms = new HashMap<>(); + private long securityKey = -1; - private final IGrid myGrid; - private final List securityProvider = new ArrayList<>(); - private final HashMap> playerPerms = new HashMap<>(); - private long securityKey = -1; + public SecurityCache(final IGrid g) { + this.myGrid = g; + } - public SecurityCache( final IGrid g ) - { - this.myGrid = g; - } + @MENetworkEventSubscribe + public void updatePermissions(final MENetworkSecurityChange ev) { + this.playerPerms.clear(); + if (this.securityProvider.isEmpty()) { + return; + } - @MENetworkEventSubscribe - public void updatePermissions( final MENetworkSecurityChange ev ) - { - this.playerPerms.clear(); - if( this.securityProvider.isEmpty() ) - { - return; - } + this.securityProvider.get(0).readPermissions(this.playerPerms); + } - this.securityProvider.get( 0 ).readPermissions( this.playerPerms ); - } + public long getSecurityKey() { + return this.securityKey; + } - public long getSecurityKey() - { - return this.securityKey; - } + @Override + public void onUpdateTick() { - @Override - public void onUpdateTick() - { + } - } + @Override + public void removeNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof ISecurityProvider) { + this.securityProvider.remove(machine); + this.updateSecurityKey(); + } + } - @Override - public void removeNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof ISecurityProvider ) - { - this.securityProvider.remove( machine ); - this.updateSecurityKey(); - } - } + private void updateSecurityKey() { + final long lastCode = this.securityKey; - private void updateSecurityKey() - { - final long lastCode = this.securityKey; + if (this.securityProvider.size() == 1) { + this.securityKey = this.securityProvider.get(0).getSecurityKey(); + } else { + this.securityKey = -1; + } - if( this.securityProvider.size() == 1 ) - { - this.securityKey = this.securityProvider.get( 0 ).getSecurityKey(); - } - else - { - this.securityKey = -1; - } + if (lastCode != this.securityKey) { + this.getGrid().postEvent(new MENetworkSecurityChange()); + for (final IGridNode n : this.getGrid().getNodes()) { + ((GridNode) n).setLastSecurityKey(this.securityKey); + } + } + } - if( lastCode != this.securityKey ) - { - this.getGrid().postEvent( new MENetworkSecurityChange() ); - for( final IGridNode n : this.getGrid().getNodes() ) - { - ( (GridNode) n ).setLastSecurityKey( this.securityKey ); - } - } - } + @Override + public void addNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof ISecurityProvider) { + this.securityProvider.add((ISecurityProvider) machine); + this.updateSecurityKey(); + } else { + ((GridNode) gridNode).setLastSecurityKey(this.securityKey); + } + } - @Override - public void addNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof ISecurityProvider ) - { - this.securityProvider.add( (ISecurityProvider) machine ); - this.updateSecurityKey(); - } - else - { - ( (GridNode) gridNode ).setLastSecurityKey( this.securityKey ); - } - } + @Override + public void onSplit(final IGridStorage destinationStorage) { - @Override - public void onSplit( final IGridStorage destinationStorage ) - { + } - } + @Override + public void onJoin(final IGridStorage sourceStorage) { - @Override - public void onJoin( final IGridStorage sourceStorage ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage destinationStorage) { - @Override - public void populateGridStorage( final IGridStorage destinationStorage ) - { + } - } + @Override + public boolean isAvailable() { + return this.securityProvider.size() == 1 && this.securityProvider.get(0).isSecurityEnabled(); + } - @Override - public boolean isAvailable() - { - return this.securityProvider.size() == 1 && this.securityProvider.get( 0 ).isSecurityEnabled(); - } + @Override + public boolean hasPermission(final PlayerEntity player, final SecurityPermissions perm) { + Preconditions.checkNotNull(player); + Preconditions.checkNotNull(perm); - @Override - public boolean hasPermission( final PlayerEntity player, final SecurityPermissions perm ) - { - Preconditions.checkNotNull( player ); - Preconditions.checkNotNull( perm ); + final GameProfile profile = player.getGameProfile(); + final int playerID = WorldData.instance().playerData().getMePlayerId(profile); - final GameProfile profile = player.getGameProfile(); - final int playerID = WorldData.instance().playerData().getMePlayerId( profile ); + return this.hasPermission(playerID, perm); + } - return this.hasPermission( playerID, perm ); - } + @Override + public boolean hasPermission(final int playerID, final SecurityPermissions perm) { + if (this.isAvailable()) { + final EnumSet perms = this.playerPerms.get(playerID); - @Override - public boolean hasPermission( final int playerID, final SecurityPermissions perm ) - { - if( this.isAvailable() ) - { - final EnumSet perms = this.playerPerms.get( playerID ); + if (perms == null) { + if (playerID == -1) // no default? + { + return false; + } else { + return this.hasPermission(-1, perm); + } + } - if( perms == null ) - { - if( playerID == -1 ) // no default? - { - return false; - } - else - { - return this.hasPermission( -1, perm ); - } - } + return perms.contains(perm); + } + return true; + } - return perms.contains( perm ); - } - return true; - } + @Override + public int getOwner() { + if (this.isAvailable()) { + return this.securityProvider.get(0).getOwner(); + } + return -1; + } - @Override - public int getOwner() - { - if( this.isAvailable() ) - { - return this.securityProvider.get( 0 ).getOwner(); - } - return -1; - } - - public IGrid getGrid() - { - return this.myGrid; - } + public IGrid getGrid() { + return this.myGrid; + } } diff --git a/src/main/java/appeng/me/cache/SpatialPylonCache.java b/src/main/java/appeng/me/cache/SpatialPylonCache.java index 7bc2f9d29..4315b7d5b 100644 --- a/src/main/java/appeng/me/cache/SpatialPylonCache.java +++ b/src/main/java/appeng/me/cache/SpatialPylonCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -37,223 +36,196 @@ import appeng.me.cluster.implementations.SpatialPylonCluster; import appeng.tile.spatial.TileSpatialIOPort; import appeng.tile.spatial.TileSpatialPylon; +public class SpatialPylonCache implements ISpatialCache { -public class SpatialPylonCache implements ISpatialCache -{ + private final IGrid myGrid; + private long powerRequired = 0; + private double efficiency = 0.0; + private DimensionalCoord captureMin; + private DimensionalCoord captureMax; + private boolean isValid = false; + private List ioPorts = new ArrayList<>(); + private HashMap clusters = new HashMap<>(); - private final IGrid myGrid; - private long powerRequired = 0; - private double efficiency = 0.0; - private DimensionalCoord captureMin; - private DimensionalCoord captureMax; - private boolean isValid = false; - private List ioPorts = new ArrayList<>(); - private HashMap clusters = new HashMap<>(); + public SpatialPylonCache(final IGrid g) { + this.myGrid = g; + } - public SpatialPylonCache( final IGrid g ) - { - this.myGrid = g; - } + @MENetworkEventSubscribe + public void bootingRender(final MENetworkBootingStatusChange c) { + this.reset(this.myGrid); + } - @MENetworkEventSubscribe - public void bootingRender( final MENetworkBootingStatusChange c ) - { - this.reset( this.myGrid ); - } + private void reset(final IGrid grid) { - private void reset( final IGrid grid ) - { + this.clusters = new HashMap<>(); + this.ioPorts = new ArrayList<>(); - this.clusters = new HashMap<>(); - this.ioPorts = new ArrayList<>(); + for (final IGridNode gm : grid.getMachines(TileSpatialIOPort.class)) { + this.ioPorts.add((TileSpatialIOPort) gm.getMachine()); + } - for( final IGridNode gm : grid.getMachines( TileSpatialIOPort.class ) ) - { - this.ioPorts.add( (TileSpatialIOPort) gm.getMachine() ); - } + final IReadOnlyCollection set = grid.getMachines(TileSpatialPylon.class); + for (final IGridNode gm : set) { + if (gm.meetsChannelRequirements()) { + final SpatialPylonCluster c = ((TileSpatialPylon) gm.getMachine()).getCluster(); + if (c != null) { + this.clusters.put(c, c); + } + } + } - final IReadOnlyCollection set = grid.getMachines( TileSpatialPylon.class ); - for( final IGridNode gm : set ) - { - if( gm.meetsChannelRequirements() ) - { - final SpatialPylonCluster c = ( (TileSpatialPylon) gm.getMachine() ).getCluster(); - if( c != null ) - { - this.clusters.put( c, c ); - } - } - } + this.captureMax = null; + this.captureMin = null; + this.isValid = true; - this.captureMax = null; - this.captureMin = null; - this.isValid = true; + int pylonBlocks = 0; + for (final SpatialPylonCluster cl : this.clusters.values()) { + if (this.captureMax == null) { + this.captureMax = cl.getMax().copy(); + } + if (this.captureMin == null) { + this.captureMin = cl.getMin().copy(); + } - int pylonBlocks = 0; - for( final SpatialPylonCluster cl : this.clusters.values() ) - { - if( this.captureMax == null ) - { - this.captureMax = cl.getMax().copy(); - } - if( this.captureMin == null ) - { - this.captureMin = cl.getMin().copy(); - } + pylonBlocks += cl.tileCount(); - pylonBlocks += cl.tileCount(); + this.captureMin.x = Math.min(this.captureMin.x, cl.getMin().x); + this.captureMin.y = Math.min(this.captureMin.y, cl.getMin().y); + this.captureMin.z = Math.min(this.captureMin.z, cl.getMin().z); - this.captureMin.x = Math.min( this.captureMin.x, cl.getMin().x ); - this.captureMin.y = Math.min( this.captureMin.y, cl.getMin().y ); - this.captureMin.z = Math.min( this.captureMin.z, cl.getMin().z ); + this.captureMax.x = Math.max(this.captureMax.x, cl.getMax().x); + this.captureMax.y = Math.max(this.captureMax.y, cl.getMax().y); + this.captureMax.z = Math.max(this.captureMax.z, cl.getMax().z); + } - this.captureMax.x = Math.max( this.captureMax.x, cl.getMax().x ); - this.captureMax.y = Math.max( this.captureMax.y, cl.getMax().y ); - this.captureMax.z = Math.max( this.captureMax.z, cl.getMax().z ); - } + double maxPower = 0; + double minPower = 0; + if (this.hasRegion()) { + this.isValid = this.captureMax.x - this.captureMin.x > 1 && this.captureMax.y - this.captureMin.y > 1 + && this.captureMax.z - this.captureMin.z > 1; - double maxPower = 0; - double minPower = 0; - if( this.hasRegion() ) - { - this.isValid = this.captureMax.x - this.captureMin.x > 1 && this.captureMax.y - this.captureMin.y > 1 && this.captureMax.z - this.captureMin.z > 1; + for (final SpatialPylonCluster cl : this.clusters.values()) { + switch (cl.getCurrentAxis()) { + case X: - for( final SpatialPylonCluster cl : this.clusters.values() ) - { - switch( cl.getCurrentAxis() ) - { - case X: + this.isValid = this.isValid + && ((this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y) + || (this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z)) + && ((this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y) + || (this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z)); - this.isValid = this.isValid && ( ( this.captureMax.y == cl.getMin().y || this.captureMin.y == cl - .getMax().y ) || ( this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z ) ) && ( ( this.captureMax.y == cl - .getMax().y || this.captureMin.y == cl - .getMin().y ) || ( this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z ) ); + break; + case Y: - break; - case Y: + this.isValid = this.isValid + && ((this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x) + || (this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z)) + && ((this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x) + || (this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z)); - this.isValid = this.isValid && ( ( this.captureMax.x == cl.getMin().x || this.captureMin.x == cl - .getMax().x ) || ( this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z ) ) && ( ( this.captureMax.x == cl - .getMax().x || this.captureMin.x == cl - .getMin().x ) || ( this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z ) ); + break; + case Z: - break; - case Z: + this.isValid = this.isValid + && ((this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y) + || (this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x)) + && ((this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y) + || (this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x)); - this.isValid = this.isValid && ( ( this.captureMax.y == cl.getMin().y || this.captureMin.y == cl - .getMax().y ) || ( this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x ) ) && ( ( this.captureMax.y == cl - .getMax().y || this.captureMin.y == cl - .getMin().y ) || ( this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x ) ); + break; + case UNFORMED: + this.isValid = false; + break; + } + } - break; - case UNFORMED: - this.isValid = false; - break; - } - } + final int reqX = this.captureMax.x - this.captureMin.x; + final int reqY = this.captureMax.y - this.captureMin.y; + final int reqZ = this.captureMax.z - this.captureMin.z; + final int requirePylonBlocks = Math.max(6, ((reqX * reqZ + reqX * reqY + reqY * reqZ) * 3) / 8); - final int reqX = this.captureMax.x - this.captureMin.x; - final int reqY = this.captureMax.y - this.captureMin.y; - final int reqZ = this.captureMax.z - this.captureMin.z; - final int requirePylonBlocks = Math.max( 6, ( ( reqX * reqZ + reqX * reqY + reqY * reqZ ) * 3 ) / 8 ); + this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks; - this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks; + if (this.efficiency > 1.0) { + this.efficiency = 1.0; + } + if (this.efficiency < 0.0) { + this.efficiency = 0.0; + } - if( this.efficiency > 1.0 ) - { - this.efficiency = 1.0; - } - if( this.efficiency < 0.0 ) - { - this.efficiency = 0.0; - } + minPower = (double) reqX * (double) reqY * reqZ * AEConfig.instance().getSpatialPowerMultiplier(); + maxPower = Math.pow(minPower, AEConfig.instance().getSpatialPowerExponent()); + } - minPower = (double) reqX * (double) reqY * reqZ * AEConfig.instance().getSpatialPowerMultiplier(); - maxPower = Math.pow( minPower, AEConfig.instance().getSpatialPowerExponent() ); - } + final double affective_efficiency = Math.pow(this.efficiency, 0.25); + this.powerRequired = (long) (affective_efficiency * minPower + (1.0 - affective_efficiency) * maxPower); - final double affective_efficiency = Math.pow( this.efficiency, 0.25 ); - this.powerRequired = (long) ( affective_efficiency * minPower + ( 1.0 - affective_efficiency ) * maxPower ); + for (final SpatialPylonCluster cl : this.clusters.values()) { + final boolean myWasValid = cl.isValid(); + cl.setValid(this.isValid); + if (myWasValid != this.isValid) { + cl.updateStatus(false); + } + } + } - for( final SpatialPylonCluster cl : this.clusters.values() ) - { - final boolean myWasValid = cl.isValid(); - cl.setValid( this.isValid ); - if( myWasValid != this.isValid ) - { - cl.updateStatus( false ); - } - } - } + @Override + public boolean hasRegion() { + return this.captureMin != null; + } - @Override - public boolean hasRegion() - { - return this.captureMin != null; - } + @Override + public boolean isValidRegion() { + return this.hasRegion() && this.isValid; + } - @Override - public boolean isValidRegion() - { - return this.hasRegion() && this.isValid; - } + @Override + public DimensionalCoord getMin() { + return this.captureMin; + } - @Override - public DimensionalCoord getMin() - { - return this.captureMin; - } + @Override + public DimensionalCoord getMax() { + return this.captureMax; + } - @Override - public DimensionalCoord getMax() - { - return this.captureMax; - } + @Override + public long requiredPower() { + return this.powerRequired; + } - @Override - public long requiredPower() - { - return this.powerRequired; - } + @Override + public float currentEfficiency() { + return (float) this.efficiency * 100; + } - @Override - public float currentEfficiency() - { - return (float) this.efficiency * 100; - } + @Override + public void onUpdateTick() { + } - @Override - public void onUpdateTick() - { - } + @Override + public void removeNode(final IGridNode node, final IGridHost machine) { - @Override - public void removeNode( final IGridNode node, final IGridHost machine ) - { + } - } + @Override + public void addNode(final IGridNode node, final IGridHost machine) { - @Override - public void addNode( final IGridNode node, final IGridHost machine ) - { + } - } + @Override + public void onSplit(final IGridStorage storageB) { - @Override - public void onSplit( final IGridStorage storageB ) - { + } - } + @Override + public void onJoin(final IGridStorage storageB) { - @Override - public void onJoin( final IGridStorage storageB ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage storage) { - @Override - public void populateGridStorage( final IGridStorage storage ) - { - - } + } } diff --git a/src/main/java/appeng/me/cache/TickManagerCache.java b/src/main/java/appeng/me/cache/TickManagerCache.java index 4afb85665..12a3d9cd9 100644 --- a/src/main/java/appeng/me/cache/TickManagerCache.java +++ b/src/main/java/appeng/me/cache/TickManagerCache.java @@ -18,7 +18,6 @@ package appeng.me.cache; - import java.util.HashMap; import java.util.PriorityQueue; @@ -38,232 +37,201 @@ import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; import appeng.me.cache.helpers.TickTracker; +public class TickManagerCache implements ITickManager { -public class TickManagerCache implements ITickManager -{ + private final IGrid myGrid; + private final HashMap alertable = new HashMap<>(); + private final HashMap sleeping = new HashMap<>(); + private final HashMap awake = new HashMap<>(); + private final PriorityQueue upcomingTicks = new PriorityQueue<>(); - private final IGrid myGrid; - private final HashMap alertable = new HashMap<>(); - private final HashMap sleeping = new HashMap<>(); - private final HashMap awake = new HashMap<>(); - private final PriorityQueue upcomingTicks = new PriorityQueue<>(); + private long currentTick = 0; - private long currentTick = 0; + public TickManagerCache(final IGrid g) { + this.myGrid = g; + } - public TickManagerCache( final IGrid g ) - { - this.myGrid = g; - } + public long getCurrentTick() { + return this.currentTick; + } - public long getCurrentTick() - { - return this.currentTick; - } + public long getAvgNanoTime(final IGridNode node) { + TickTracker tt = this.awake.get(node); - public long getAvgNanoTime( final IGridNode node ) - { - TickTracker tt = this.awake.get( node ); + if (tt == null) { + tt = this.sleeping.get(node); + } - if( tt == null ) - { - tt = this.sleeping.get( node ); - } + if (tt == null) { + return -1; + } - if( tt == null ) - { - return -1; - } + return tt.getAvgNanos(); + } - return tt.getAvgNanos(); - } + @Override + public void onUpdateTick() { + TickTracker tt = null; - @Override - public void onUpdateTick() - { - TickTracker tt = null; + try { + this.currentTick++; - try - { - this.currentTick++; + while (!this.upcomingTicks.isEmpty()) { + tt = this.upcomingTicks.peek(); - while( !this.upcomingTicks.isEmpty() ) - { - tt = this.upcomingTicks.peek(); + // Stop once it reaches a TickTracker running at a later tick + if (tt.getNextTick() > this.currentTick) { + break; + } - // Stop once it reaches a TickTracker running at a later tick - if( tt.getNextTick() > this.currentTick ) - { - break; - } + this.upcomingTicks.poll(); - this.upcomingTicks.poll(); + final int diff = (int) (this.currentTick - tt.getLastTick()); + final TickRateModulation mod = tt.getGridTickable().tickingRequest(tt.getNode(), diff); - final int diff = (int) ( this.currentTick - tt.getLastTick() ); - final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff ); + switch (mod) { + case FASTER: + tt.setCurrentRate(tt.getCurrentRate() - 2); + break; + case IDLE: + tt.setCurrentRate(tt.getRequest().maxTickRate); + break; + case SAME: + break; + case SLEEP: + this.sleepDevice(tt.getNode()); + break; + case SLOWER: + tt.setCurrentRate(tt.getCurrentRate() + 1); + break; + case URGENT: + tt.setCurrentRate(0); + break; + default: + break; + } - switch( mod ) - { - case FASTER: - tt.setCurrentRate( tt.getCurrentRate() - 2 ); - break; - case IDLE: - tt.setCurrentRate( tt.getRequest().maxTickRate ); - break; - case SAME: - break; - case SLEEP: - this.sleepDevice( tt.getNode() ); - break; - case SLOWER: - tt.setCurrentRate( tt.getCurrentRate() + 1 ); - break; - case URGENT: - tt.setCurrentRate( 0 ); - break; - default: - break; - } + if (this.awake.containsKey(tt.getNode())) { + this.addToQueue(tt); + } + } + } catch (final Throwable t) { + final CrashReport crashreport = CrashReport.makeCrashReport(t, "Ticking GridNode"); + final CrashReportCategory crashreportcategory = crashreport + .makeCategory(tt.getGridTickable().getClass().getSimpleName() + " being ticked."); + tt.addEntityCrashInfo(crashreportcategory); + throw new ReportedException(crashreport); + } + } - if( this.awake.containsKey( tt.getNode() ) ) - { - this.addToQueue( tt ); - } - } - } - catch( final Throwable t ) - { - final CrashReport crashreport = CrashReport.makeCrashReport( t, "Ticking GridNode" ); - final CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.getGridTickable().getClass().getSimpleName() + " being ticked." ); - tt.addEntityCrashInfo( crashreportcategory ); - throw new ReportedException( crashreport ); - } - } + private void addToQueue(final TickTracker tt) { + tt.setLastTick(this.currentTick); + this.upcomingTicks.add(tt); + } - private void addToQueue( final TickTracker tt ) - { - tt.setLastTick( this.currentTick ); - this.upcomingTicks.add( tt ); - } + @Override + public void removeNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof IGridTickable) { + this.alertable.remove(gridNode); + this.sleeping.remove(gridNode); + this.awake.remove(gridNode); + } + } - @Override - public void removeNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof IGridTickable ) - { - this.alertable.remove( gridNode ); - this.sleeping.remove( gridNode ); - this.awake.remove( gridNode ); - } - } + @Override + public void addNode(final IGridNode gridNode, final IGridHost machine) { + if (machine instanceof IGridTickable) { + final IGridTickable tickable = ((IGridTickable) machine); + final TickingRequest tr = tickable.getTickingRequest(gridNode); - @Override - public void addNode( final IGridNode gridNode, final IGridHost machine ) - { - if( machine instanceof IGridTickable ) - { - final IGridTickable tickable = ( (IGridTickable) machine ); - final TickingRequest tr = tickable.getTickingRequest( gridNode ); + Preconditions.checkNotNull(tr); - Preconditions.checkNotNull( tr ); + final TickTracker tt = new TickTracker(tr, gridNode, (IGridTickable) machine, this.currentTick, this); - final TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this ); + if (tr.canBeAlerted) { + this.alertable.put(gridNode, tt); + } - if( tr.canBeAlerted ) - { - this.alertable.put( gridNode, tt ); - } + if (tr.isSleeping) { + this.sleeping.put(gridNode, tt); + } else { + this.awake.put(gridNode, tt); + this.addToQueue(tt); + } + } + } - if( tr.isSleeping ) - { - this.sleeping.put( gridNode, tt ); - } - else - { - this.awake.put( gridNode, tt ); - this.addToQueue( tt ); - } - } - } + @Override + public void onSplit(final IGridStorage storageB) { - @Override - public void onSplit( final IGridStorage storageB ) - { + } - } + @Override + public void onJoin(final IGridStorage storageB) { - @Override - public void onJoin( final IGridStorage storageB ) - { + } - } + @Override + public void populateGridStorage(final IGridStorage storage) { - @Override - public void populateGridStorage( final IGridStorage storage ) - { + } - } + @Override + public boolean alertDevice(final IGridNode node) { + Preconditions.checkNotNull(node); - @Override - public boolean alertDevice( final IGridNode node ) - { - Preconditions.checkNotNull( node ); + final TickTracker tt = this.alertable.get(node); + if (tt == null) { + return false; + } + // throw new RuntimeException( + // "Invalid alerted device, this node is not marked as alertable, or part of + // this grid." ); - final TickTracker tt = this.alertable.get( node ); - if( tt == null ) - { - return false; - } - // throw new RuntimeException( - // "Invalid alerted device, this node is not marked as alertable, or part of this grid." ); + // set to awake, this is for sanity. + this.sleeping.remove(node); + this.awake.put(node, tt); - // set to awake, this is for sanity. - this.sleeping.remove( node ); - this.awake.put( node, tt ); + // configure sort. + tt.setLastTick(tt.getLastTick() - tt.getRequest().maxTickRate); + tt.setCurrentRate(tt.getRequest().minTickRate); - // configure sort. - tt.setLastTick( tt.getLastTick() - tt.getRequest().maxTickRate ); - tt.setCurrentRate( tt.getRequest().minTickRate ); + // prevent dupes and tick build up. + this.upcomingTicks.remove(tt); + this.upcomingTicks.add(tt); - // prevent dupes and tick build up. - this.upcomingTicks.remove( tt ); - this.upcomingTicks.add( tt ); + return true; + } - return true; - } + @Override + public boolean sleepDevice(final IGridNode node) { + Preconditions.checkNotNull(node); - @Override - public boolean sleepDevice( final IGridNode node ) - { - Preconditions.checkNotNull( node ); + if (this.awake.containsKey(node)) { + final TickTracker gt = this.awake.get(node); + this.awake.remove(node); + this.sleeping.put(node, gt); - if( this.awake.containsKey( node ) ) - { - final TickTracker gt = this.awake.get( node ); - this.awake.remove( node ); - this.sleeping.put( node, gt ); + return true; + } - return true; - } + return false; + } - return false; - } + @Override + public boolean wakeDevice(final IGridNode node) { + Preconditions.checkNotNull(node); - @Override - public boolean wakeDevice( final IGridNode node ) - { - Preconditions.checkNotNull( node ); + if (this.sleeping.containsKey(node)) { + final TickTracker gt = this.sleeping.get(node); + this.sleeping.remove(node); + this.awake.put(node, gt); + this.upcomingTicks.remove(gt); + this.addToQueue(gt); - if( this.sleeping.containsKey( node ) ) - { - final TickTracker gt = this.sleeping.get( node ); - this.sleeping.remove( node ); - this.awake.put( node, gt ); - this.upcomingTicks.remove( gt ); - this.addToQueue( gt ); + return true; + } - return true; - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/me/cache/helpers/ConnectionWrapper.java b/src/main/java/appeng/me/cache/helpers/ConnectionWrapper.java index 759a94080..0aa9d3d0f 100644 --- a/src/main/java/appeng/me/cache/helpers/ConnectionWrapper.java +++ b/src/main/java/appeng/me/cache/helpers/ConnectionWrapper.java @@ -18,27 +18,21 @@ package appeng.me.cache.helpers; - import appeng.api.networking.IGridConnection; +public class ConnectionWrapper { -public class ConnectionWrapper -{ + private IGridConnection connection; - private IGridConnection connection; + public ConnectionWrapper(final IGridConnection gc) { + this.setConnection(gc); + } - public ConnectionWrapper( final IGridConnection gc ) - { - this.setConnection( gc ); - } + public IGridConnection getConnection() { + return this.connection; + } - public IGridConnection getConnection() - { - return this.connection; - } - - public void setConnection( final IGridConnection connection ) - { - this.connection = connection; - } + public void setConnection(final IGridConnection connection) { + this.connection = connection; + } } \ No newline at end of file diff --git a/src/main/java/appeng/me/cache/helpers/Connections.java b/src/main/java/appeng/me/cache/helpers/Connections.java index 295cb7ae5..8ab4dcfc6 100644 --- a/src/main/java/appeng/me/cache/helpers/Connections.java +++ b/src/main/java/appeng/me/cache/helpers/Connections.java @@ -18,7 +18,6 @@ package appeng.me.cache.helpers; - import java.util.HashMap; import net.minecraft.world.World; @@ -27,62 +26,51 @@ import appeng.api.networking.IGridNode; import appeng.parts.p2p.PartP2PTunnelME; import appeng.util.IWorldCallable; +public class Connections implements IWorldCallable { -public class Connections implements IWorldCallable -{ + private final HashMap connections = new HashMap<>(); + private final PartP2PTunnelME me; + private boolean create = false; + private boolean destroy = false; - private final HashMap connections = new HashMap<>(); - private final PartP2PTunnelME me; - private boolean create = false; - private boolean destroy = false; + public Connections(final PartP2PTunnelME o) { + this.me = o; + } - public Connections( final PartP2PTunnelME o ) - { - this.me = o; - } + @Override + public Void call(final World world) throws Exception { + this.me.updateConnections(this); - @Override - public Void call( final World world ) throws Exception - { - this.me.updateConnections( this ); + return null; + } - return null; - } + public void markDestroy() { + this.setCreate(false); + this.setDestroy(true); + } - public void markDestroy() - { - this.setCreate( false ); - this.setDestroy( true ); - } + public void markCreate() { + this.setCreate(true); + this.setDestroy(false); + } - public void markCreate() - { - this.setCreate( true ); - this.setDestroy( false ); - } + public HashMap getConnections() { + return this.connections; + } - public HashMap getConnections() - { - return this.connections; - } + public boolean isCreate() { + return this.create; + } - public boolean isCreate() - { - return this.create; - } + private void setCreate(final boolean create) { + this.create = create; + } - private void setCreate( final boolean create ) - { - this.create = create; - } + public boolean isDestroy() { + return this.destroy; + } - public boolean isDestroy() - { - return this.destroy; - } - - private void setDestroy( final boolean destroy ) - { - this.destroy = destroy; - } + private void setDestroy(final boolean destroy) { + this.destroy = destroy; + } } diff --git a/src/main/java/appeng/me/cache/helpers/TickTracker.java b/src/main/java/appeng/me/cache/helpers/TickTracker.java index 7a636636d..8c83f4a26 100644 --- a/src/main/java/appeng/me/cache/helpers/TickTracker.java +++ b/src/main/java/appeng/me/cache/helpers/TickTracker.java @@ -18,7 +18,6 @@ package appeng.me.cache.helpers; - import javax.annotation.Nonnull; import net.minecraft.crash.CrashReportCategory; @@ -30,113 +29,97 @@ import appeng.api.util.DimensionalCoord; import appeng.me.cache.TickManagerCache; import appeng.parts.AEBasePart; +public class TickTracker implements Comparable { -public class TickTracker implements Comparable -{ + private final TickingRequest request; + private final IGridTickable gt; + private final IGridNode node; - private final TickingRequest request; - private final IGridTickable gt; - private final IGridNode node; + private final long LastFiveTicksTime = 0; - private final long LastFiveTicksTime = 0; + private long lastTick; + private int currentRate; - private long lastTick; - private int currentRate; + public TickTracker(final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, + final TickManagerCache tickManagerCache) { + this.request = req; + this.gt = gt; + this.node = node; + this.setCurrentRate((req.minTickRate + req.maxTickRate) / 2); + this.setLastTick(currentTick); + } - public TickTracker( final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache ) - { - this.request = req; - this.gt = gt; - this.node = node; - this.setCurrentRate( ( req.minTickRate + req.maxTickRate ) / 2 ); - this.setLastTick( currentTick ); - } + public long getAvgNanos() { + return (this.LastFiveTicksTime / 5); + } - public long getAvgNanos() - { - return( this.LastFiveTicksTime / 5 ); - } + @Override + public int compareTo(@Nonnull final TickTracker t) { + int next = Long.compare(this.getNextTick(), t.getNextTick()); - @Override - public int compareTo( @Nonnull final TickTracker t ) - { - int next = Long.compare( this.getNextTick(), t.getNextTick() ); + if (next != 0) { + return next; + } - if( next != 0 ) - { - return next; - } + int last = Long.compare(this.getLastTick(), t.getLastTick()); - int last = Long.compare( this.getLastTick(), t.getLastTick() ); + if (last != 0) { + return last; + } - if( last != 0 ) - { - return last; - } + return Integer.compare(this.getCurrentRate(), t.getCurrentRate()); - return Integer.compare( this.getCurrentRate(), t.getCurrentRate() ); + } - } + public void addEntityCrashInfo(final CrashReportCategory crashreportcategory) { + if (this.getGridTickable() instanceof AEBasePart) { + final AEBasePart part = (AEBasePart) this.getGridTickable(); + part.addEntityCrashInfo(crashreportcategory); + } - public void addEntityCrashInfo( final CrashReportCategory crashreportcategory ) - { - if( this.getGridTickable() instanceof AEBasePart ) - { - final AEBasePart part = (AEBasePart) this.getGridTickable(); - part.addEntityCrashInfo( crashreportcategory ); - } + crashreportcategory.addDetail("CurrentTickRate", this.getCurrentRate()); + crashreportcategory.addDetail("MinTickRate", this.getRequest().minTickRate); + crashreportcategory.addDetail("MaxTickRate", this.getRequest().maxTickRate); + crashreportcategory.addDetail("MachineType", this.getGridTickable().getClass().getName()); + crashreportcategory.addDetail("GridBlockType", this.getNode().getGridBlock().getClass().getName()); + crashreportcategory.addDetail("ConnectedSides", this.getNode().getConnectedSides()); - crashreportcategory.addDetail( "CurrentTickRate", this.getCurrentRate() ); - crashreportcategory.addDetail( "MinTickRate", this.getRequest().minTickRate ); - crashreportcategory.addDetail( "MaxTickRate", this.getRequest().maxTickRate ); - crashreportcategory.addDetail( "MachineType", this.getGridTickable().getClass().getName() ); - crashreportcategory.addDetail( "GridBlockType", this.getNode().getGridBlock().getClass().getName() ); - crashreportcategory.addDetail( "ConnectedSides", this.getNode().getConnectedSides() ); + final DimensionalCoord dc = this.getNode().getGridBlock().getLocation(); + if (dc != null) { + crashreportcategory.addDetail("Location", dc); + } + } - final DimensionalCoord dc = this.getNode().getGridBlock().getLocation(); - if( dc != null ) - { - crashreportcategory.addDetail( "Location", dc ); - } - } + public int getCurrentRate() { + return this.currentRate; + } - public int getCurrentRate() - { - return this.currentRate; - } + public void setCurrentRate(final int currentRate) { + this.currentRate = Math.min(this.getRequest().maxTickRate, + Math.max(this.getRequest().minTickRate, currentRate)); + } - public void setCurrentRate( final int currentRate ) - { - this.currentRate = Math.min( this.getRequest().maxTickRate, Math.max( this.getRequest().minTickRate, currentRate ) ); - } + public long getNextTick() { + return this.lastTick + this.currentRate; + } - public long getNextTick() - { - return this.lastTick + this.currentRate; - } + public long getLastTick() { + return this.lastTick; + } - public long getLastTick() - { - return this.lastTick; - } + public void setLastTick(final long lastTick) { + this.lastTick = lastTick; + } - public void setLastTick( final long lastTick ) - { - this.lastTick = lastTick; - } + public IGridNode getNode() { + return this.node; + } - public IGridNode getNode() - { - return this.node; - } + public IGridTickable getGridTickable() { + return this.gt; + } - public IGridTickable getGridTickable() - { - return this.gt; - } - - public TickingRequest getRequest() - { - return this.request; - } + public TickingRequest getRequest() { + return this.request; + } } diff --git a/src/main/java/appeng/me/cache/helpers/TunnelCollection.java b/src/main/java/appeng/me/cache/helpers/TunnelCollection.java index 9d6220ca4..3db13cb16 100644 --- a/src/main/java/appeng/me/cache/helpers/TunnelCollection.java +++ b/src/main/java/appeng/me/cache/helpers/TunnelCollection.java @@ -18,59 +18,48 @@ package appeng.me.cache.helpers; - import java.util.Collection; import java.util.Iterator; import appeng.parts.p2p.PartP2PTunnel; import appeng.util.iterators.NullIterator; +public class TunnelCollection implements Iterable { -public class TunnelCollection implements Iterable -{ + private final Class clz; + private Collection tunnelSources; - private final Class clz; - private Collection tunnelSources; + public TunnelCollection(final Collection src, final Class c) { + this.tunnelSources = src; + this.clz = c; + } - public TunnelCollection( final Collection src, final Class c ) - { - this.tunnelSources = src; - this.clz = c; - } + public void setSource(final Collection c) { + this.tunnelSources = c; + } - public void setSource( final Collection c ) - { - this.tunnelSources = c; - } + public boolean isEmpty() { + return !this.iterator().hasNext(); + } - public boolean isEmpty() - { - return !this.iterator().hasNext(); - } + @Override + public Iterator iterator() { + if (this.tunnelSources == null) { + return new NullIterator<>(); + } + return new TunnelIterator<>(this.tunnelSources, this.clz); + } - @Override - public Iterator iterator() - { - if( this.tunnelSources == null ) - { - return new NullIterator<>(); - } - return new TunnelIterator<>( this.tunnelSources, this.clz ); - } + public boolean matches(final Class c) { + return this.clz == c; + } - public boolean matches( final Class c ) - { - return this.clz == c; - } + public Class getClz() { + return this.clz; + } - public Class getClz() - { - return this.clz; - } - - public int size() - { - return this.tunnelSources == null ? 0 : this.tunnelSources.size(); - } + public int size() { + return this.tunnelSources == null ? 0 : this.tunnelSources.size(); + } } diff --git a/src/main/java/appeng/me/cache/helpers/TunnelConnection.java b/src/main/java/appeng/me/cache/helpers/TunnelConnection.java index b4abb1b34..0adae1665 100644 --- a/src/main/java/appeng/me/cache/helpers/TunnelConnection.java +++ b/src/main/java/appeng/me/cache/helpers/TunnelConnection.java @@ -18,30 +18,24 @@ package appeng.me.cache.helpers; - import appeng.api.networking.IGridConnection; import appeng.parts.p2p.PartP2PTunnelME; +public class TunnelConnection { -public class TunnelConnection -{ + private final PartP2PTunnelME tunnel; + private final IGridConnection c; - private final PartP2PTunnelME tunnel; - private final IGridConnection c; + public TunnelConnection(final PartP2PTunnelME t, final IGridConnection con) { + this.tunnel = t; + this.c = con; + } - public TunnelConnection( final PartP2PTunnelME t, final IGridConnection con ) - { - this.tunnel = t; - this.c = con; - } + public IGridConnection getConnection() { + return this.c; + } - public IGridConnection getConnection() - { - return this.c; - } - - public PartP2PTunnelME getTunnel() - { - return this.tunnel; - } + public PartP2PTunnelME getTunnel() { + return this.tunnel; + } } \ No newline at end of file diff --git a/src/main/java/appeng/me/cache/helpers/TunnelIterator.java b/src/main/java/appeng/me/cache/helpers/TunnelIterator.java index 3e86f1207..60c698186 100644 --- a/src/main/java/appeng/me/cache/helpers/TunnelIterator.java +++ b/src/main/java/appeng/me/cache/helpers/TunnelIterator.java @@ -18,57 +18,47 @@ package appeng.me.cache.helpers; - import java.util.Collection; import java.util.Iterator; import appeng.parts.p2p.PartP2PTunnel; +public class TunnelIterator implements Iterator { -public class TunnelIterator implements Iterator -{ + private final Iterator wrapped; + private final Class targetType; + private T Next; - private final Iterator wrapped; - private final Class targetType; - private T Next; + public TunnelIterator(final Collection tunnelSources, final Class clz) { + this.wrapped = tunnelSources.iterator(); + this.targetType = clz; + this.findNext(); + } - public TunnelIterator( final Collection tunnelSources, final Class clz ) - { - this.wrapped = tunnelSources.iterator(); - this.targetType = clz; - this.findNext(); - } + private void findNext() { + while (this.Next == null && this.wrapped.hasNext()) { + this.Next = this.wrapped.next(); + if (!this.targetType.isInstance(this.Next)) { + this.Next = null; + } + } + } - private void findNext() - { - while( this.Next == null && this.wrapped.hasNext() ) - { - this.Next = this.wrapped.next(); - if( !this.targetType.isInstance( this.Next ) ) - { - this.Next = null; - } - } - } + @Override + public boolean hasNext() { + this.findNext(); + return this.Next != null; + } - @Override - public boolean hasNext() - { - this.findNext(); - return this.Next != null; - } + @Override + public T next() { + final T tmp = this.Next; + this.Next = null; + return tmp; + } - @Override - public T next() - { - final T tmp = this.Next; - this.Next = null; - return tmp; - } - - @Override - public void remove() - { - // no. - } + @Override + public void remove() { + // no. + } } diff --git a/src/main/java/appeng/me/cluster/IAECluster.java b/src/main/java/appeng/me/cluster/IAECluster.java index 23944f755..98ae4bbf4 100644 --- a/src/main/java/appeng/me/cluster/IAECluster.java +++ b/src/main/java/appeng/me/cluster/IAECluster.java @@ -18,18 +18,15 @@ package appeng.me.cluster; - import java.util.Iterator; import appeng.api.networking.IGridHost; +public interface IAECluster { -public interface IAECluster -{ + void updateStatus(boolean updateGrid); - void updateStatus( boolean updateGrid ); + void destroy(); - void destroy(); - - Iterator getTiles(); + Iterator getTiles(); } diff --git a/src/main/java/appeng/me/cluster/IAEMultiBlock.java b/src/main/java/appeng/me/cluster/IAEMultiBlock.java index 8dc36f998..a78898855 100644 --- a/src/main/java/appeng/me/cluster/IAEMultiBlock.java +++ b/src/main/java/appeng/me/cluster/IAEMultiBlock.java @@ -18,13 +18,11 @@ package appeng.me.cluster; +public interface IAEMultiBlock { -public interface IAEMultiBlock -{ + void disconnect(boolean b); - void disconnect( boolean b ); + IAECluster getCluster(); - IAECluster getCluster(); - - boolean isValid(); + boolean isValid(); } diff --git a/src/main/java/appeng/me/cluster/MBCalculator.java b/src/main/java/appeng/me/cluster/MBCalculator.java index 2a352b72d..b9f01f095 100644 --- a/src/main/java/appeng/me/cluster/MBCalculator.java +++ b/src/main/java/appeng/me/cluster/MBCalculator.java @@ -18,7 +18,6 @@ package appeng.me.cluster; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -28,213 +27,181 @@ import appeng.api.util.WorldCoord; import appeng.core.AELog; import appeng.util.Platform; +public abstract class MBCalculator { -public abstract class MBCalculator -{ + private final IAEMultiBlock target; - private final IAEMultiBlock target; + public MBCalculator(final IAEMultiBlock t) { + this.target = t; + } - public MBCalculator( final IAEMultiBlock t ) - { - this.target = t; - } + public void calculateMultiblock(final World world, final WorldCoord loc) { + if (Platform.isClient()) { + return; + } - public void calculateMultiblock( final World world, final WorldCoord loc ) - { - if( Platform.isClient() ) - { - return; - } + try { + final WorldCoord min = loc.copy(); + final WorldCoord max = loc.copy(); - try - { - final WorldCoord min = loc.copy(); - final WorldCoord max = loc.copy(); + // find size of MB structure... + while (this.isValidTileAt(world, min.x - 1, min.y, min.z)) { + min.x--; + } + while (this.isValidTileAt(world, min.x, min.y - 1, min.z)) { + min.y--; + } + while (this.isValidTileAt(world, min.x, min.y, min.z - 1)) { + min.z--; + } + while (this.isValidTileAt(world, max.x + 1, max.y, max.z)) { + max.x++; + } + while (this.isValidTileAt(world, max.x, max.y + 1, max.z)) { + max.y++; + } + while (this.isValidTileAt(world, max.x, max.y, max.z + 1)) { + max.z++; + } - // find size of MB structure... - while( this.isValidTileAt( world, min.x - 1, min.y, min.z ) ) - { - min.x--; - } - while( this.isValidTileAt( world, min.x, min.y - 1, min.z ) ) - { - min.y--; - } - while( this.isValidTileAt( world, min.x, min.y, min.z - 1 ) ) - { - min.z--; - } - while( this.isValidTileAt( world, max.x + 1, max.y, max.z ) ) - { - max.x++; - } - while( this.isValidTileAt( world, max.x, max.y + 1, max.z ) ) - { - max.y++; - } - while( this.isValidTileAt( world, max.x, max.y, max.z + 1 ) ) - { - max.z++; - } + if (this.checkMultiblockScale(min, max)) { + if (this.verifyUnownedRegion(world, min, max)) { + IAECluster c = this.createCluster(world, min, max); - if( this.checkMultiblockScale( min, max ) ) - { - if( this.verifyUnownedRegion( world, min, max ) ) - { - IAECluster c = this.createCluster( world, min, max ); + try { + if (!this.verifyInternalStructure(world, min, max)) { + this.disconnect(); + return; + } + } catch (final Exception err) { + this.disconnect(); + return; + } - try - { - if( !this.verifyInternalStructure( world, min, max ) ) - { - this.disconnect(); - return; - } - } - catch( final Exception err ) - { - this.disconnect(); - return; - } + boolean updateGrid = false; + final IAECluster cluster = this.target.getCluster(); + if (cluster == null) { + this.updateTiles(c, world, min, max); - boolean updateGrid = false; - final IAECluster cluster = this.target.getCluster(); - if( cluster == null ) - { - this.updateTiles( c, world, min, max ); + updateGrid = true; + } else { + c = cluster; + } - updateGrid = true; - } - else - { - c = cluster; - } + c.updateStatus(updateGrid); + return; + } + } + } catch (final Throwable err) { + AELog.debug(err); + } - c.updateStatus( updateGrid ); - return; - } - } - } - catch( final Throwable err ) - { - AELog.debug( err ); - } + this.disconnect(); + } - this.disconnect(); - } + private boolean isValidTileAt(final World w, final int x, final int y, final int z) { + return this.isValidTile(w.getTileEntity(new BlockPos(x, y, z))); + } - private boolean isValidTileAt( final World w, final int x, final int y, final int z ) - { - return this.isValidTile( w.getTileEntity( new BlockPos( x, y, z ) ) ); - } + /** + * verify if the structure is the correct dimensions, or size + * + * @param min min world coord + * @param max max world coord + * + * @return true if structure has correct dimensions or size + */ + public abstract boolean checkMultiblockScale(WorldCoord min, WorldCoord max); - /** - * verify if the structure is the correct dimensions, or size - * - * @param min min world coord - * @param max max world coord - * - * @return true if structure has correct dimensions or size - */ - public abstract boolean checkMultiblockScale( WorldCoord min, WorldCoord max ); + private boolean verifyUnownedRegion(final World w, final WorldCoord min, final WorldCoord max) { + for (final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS) { + if (this.verifyUnownedRegionInner(w, min.x, min.y, min.z, max.x, max.y, max.z, side)) { + return false; + } + } - private boolean verifyUnownedRegion( final World w, final WorldCoord min, final WorldCoord max ) - { - for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS ) - { - if( this.verifyUnownedRegionInner( w, min.x, min.y, min.z, max.x, max.y, max.z, side ) ) - { - return false; - } - } + return true; + } - return true; - } + /** + * construct the correct cluster, usually very simple. + * + * @param w world + * @param min min world coord + * @param max max world coord + * + * @return created cluster + */ + public abstract IAECluster createCluster(World w, WorldCoord min, WorldCoord max); - /** - * construct the correct cluster, usually very simple. - * - * @param w world - * @param min min world coord - * @param max max world coord - * - * @return created cluster - */ - public abstract IAECluster createCluster( World w, WorldCoord min, WorldCoord max ); + public abstract boolean verifyInternalStructure(World world, WorldCoord min, WorldCoord max); - public abstract boolean verifyInternalStructure( World world, WorldCoord min, WorldCoord max ); + /** + * disassembles the multi-block. + */ + public abstract void disconnect(); - /** - * disassembles the multi-block. - */ - public abstract void disconnect(); + /** + * configure the multi-block tiles, most of the important stuff is in here. + * + * @param c updated cluster + * @param w in world + * @param min min world coord + * @param max max world coord + */ + public abstract void updateTiles(IAECluster c, World w, WorldCoord min, WorldCoord max); - /** - * configure the multi-block tiles, most of the important stuff is in here. - * - * @param c updated cluster - * @param w in world - * @param min min world coord - * @param max max world coord - */ - public abstract void updateTiles( IAECluster c, World w, WorldCoord min, WorldCoord max ); + /** + * check if the tile entities are correct for the structure. + * + * @param te to be checked tile entity + * + * @return true if tile entity is valid for structure + */ + public abstract boolean isValidTile(TileEntity te); - /** - * check if the tile entities are correct for the structure. - * - * @param te to be checked tile entity - * - * @return true if tile entity is valid for structure - */ - public abstract boolean isValidTile( TileEntity te ); + private boolean verifyUnownedRegionInner(final World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, + final AEPartLocation side) { + switch (side) { + case WEST: + minX -= 1; + maxX = minX; + break; + case EAST: + maxX += 1; + minX = maxX; + break; + case DOWN: + minY -= 1; + maxY = minY; + break; + case NORTH: + maxZ += 1; + minZ = maxZ; + break; + case SOUTH: + minZ -= 1; + maxZ = minZ; + break; + case UP: + maxY += 1; + minY = maxY; + break; + case INTERNAL: + return false; + } - private boolean verifyUnownedRegionInner( final World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, final AEPartLocation side ) - { - switch( side ) - { - case WEST: - minX -= 1; - maxX = minX; - break; - case EAST: - maxX += 1; - minX = maxX; - break; - case DOWN: - minY -= 1; - maxY = minY; - break; - case NORTH: - maxZ += 1; - minZ = maxZ; - break; - case SOUTH: - minZ -= 1; - maxZ = minZ; - break; - case UP: - maxY += 1; - minY = maxY; - break; - case INTERNAL: - return false; - } + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + final TileEntity te = w.getTileEntity(new BlockPos(x, y, z)); + if (this.isValidTile(te)) { + return true; + } + } + } + } - for( int x = minX; x <= maxX; x++ ) - { - for( int y = minY; y <= maxY; y++ ) - { - for( int z = minZ; z <= maxZ; z++ ) - { - final TileEntity te = w.getTileEntity( new BlockPos( x, y, z ) ); - if( this.isValidTile( te ) ) - { - return true; - } - } - } - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java index a95aa7c5d..8ac98bd93 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import java.util.Iterator; import net.minecraft.tileentity.TileEntity; @@ -36,120 +35,97 @@ import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.MBCalculator; import appeng.tile.crafting.TileCraftingTile; +public class CraftingCPUCalculator extends MBCalculator { -public class CraftingCPUCalculator extends MBCalculator -{ + private final TileCraftingTile tqb; - private final TileCraftingTile tqb; + public CraftingCPUCalculator(final IAEMultiBlock t) { + super(t); + this.tqb = (TileCraftingTile) t; + } - public CraftingCPUCalculator( final IAEMultiBlock t ) - { - super( t ); - this.tqb = (TileCraftingTile) t; - } + @Override + public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) { + if (max.x - min.x > 16) { + return false; + } - @Override - public boolean checkMultiblockScale( final WorldCoord min, final WorldCoord max ) - { - if( max.x - min.x > 16 ) - { - return false; - } + if (max.y - min.y > 16) { + return false; + } - if( max.y - min.y > 16 ) - { - return false; - } + if (max.z - min.z > 16) { + return false; + } - if( max.z - min.z > 16 ) - { - return false; - } + return true; + } - return true; - } + @Override + public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) { + return new CraftingCPUCluster(min, max); + } - @Override - public IAECluster createCluster( final World w, final WorldCoord min, final WorldCoord max ) - { - return new CraftingCPUCluster( min, max ); - } + @Override + public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) { + boolean storage = false; - @Override - public boolean verifyInternalStructure( final World w, final WorldCoord min, final WorldCoord max ) - { - boolean storage = false; + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(new BlockPos(x, y, z)); - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( new BlockPos( x, y, z ) ); + if (!te.isValid()) { + return false; + } - if( !te.isValid() ) - { - return false; - } + if (!storage && te instanceof TileCraftingTile) { + storage = ((TileCraftingTile) te).getStorageBytes() > 0; + } + } + } + } - if( !storage && te instanceof TileCraftingTile ) - { - storage = ( (TileCraftingTile) te ).getStorageBytes() > 0; - } - } - } - } + return storage; + } - return storage; - } + @Override + public void disconnect() { + this.tqb.disconnect(true); + } - @Override - public void disconnect() - { - this.tqb.disconnect( true ); - } + @Override + public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) { + final CraftingCPUCluster c = (CraftingCPUCluster) cl; - @Override - public void updateTiles( final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max ) - { - final CraftingCPUCluster c = (CraftingCPUCluster) cl; + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final TileCraftingTile te = (TileCraftingTile) w.getTileEntity(new BlockPos(x, y, z)); + te.updateStatus(c); + c.addTile(te); + } + } + } - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final TileCraftingTile te = (TileCraftingTile) w.getTileEntity( new BlockPos( x, y, z ) ); - te.updateStatus( c ); - c.addTile( te ); - } - } - } + c.done(); - c.done(); + final Iterator i = c.getTiles(); + while (i.hasNext()) { + final IGridHost gh = i.next(); + final IGridNode n = gh.getGridNode(AEPartLocation.INTERNAL); + if (n != null) { + final IGrid g = n.getGrid(); + if (g != null) { + g.postEvent(new MENetworkCraftingCpuChange(n)); + return; + } + } + } + } - final Iterator i = c.getTiles(); - while( i.hasNext() ) - { - final IGridHost gh = i.next(); - final IGridNode n = gh.getGridNode( AEPartLocation.INTERNAL ); - if( n != null ) - { - final IGrid g = n.getGrid(); - if( g != null ) - { - g.postEvent( new MENetworkCraftingCpuChange( n ) ); - return; - } - } - } - } - - @Override - public boolean isValidTile( final TileEntity te ) - { - return te instanceof TileCraftingTile; - } + @Override + public boolean isValidTile(final TileEntity te) { + return te instanceof TileCraftingTile; + } } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java index 3c9495624..af75643ad 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -79,1290 +78,1094 @@ import appeng.tile.crafting.TileCraftingTile; import appeng.util.Platform; import appeng.util.item.AEItemStack; +public final class CraftingCPUCluster implements IAECluster, ICraftingCPU { + + private static final String LOG_MARK_AS_COMPLETE = "Completed job for %s."; + + private final WorldCoord min; + private final WorldCoord max; + private final int[] usedOps = new int[3]; + private final Map tasks = new HashMap<>(); + // INSTANCE sate + private final List tiles = new ArrayList<>(); + private final List storage = new ArrayList<>(); + private final List status = new ArrayList<>(); + private final HashMap, Object> listeners = new HashMap<>(); + private ICraftingLink myLastLink; + private ITextComponent myName = null; + private boolean isDestroyed = false; + /** + * crafting job info + */ + private MECraftingInventory inventory = new MECraftingInventory(); + private IAEItemStack finalOutput; + private boolean waiting = false; + private IItemList waitingFor = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private long availableStorage = 0; + private MachineSource machineSrc = null; + private int accelerator = 0; + private boolean isComplete = true; + private int remainingOperations; + private boolean somethingChanged; + + private long lastTime; + private long elapsedTime; + private long startItemCount; + private long remainingItemCount; + + public CraftingCPUCluster(final WorldCoord min, final WorldCoord max) { + this.min = min; + this.max = max; + } + + public boolean isDestroyed() { + return this.isDestroyed; + } + + public ICraftingLink getLastCraftingLink() { + return this.myLastLink; + } + + /** + * add a new Listener to the monitor, be sure to properly remove yourself when + * your done. + */ + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } + + /** + * remove a Listener to the monitor. + */ + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } + + public IMEInventory getInventory() { + return this.inventory; + } + + @Override + public void updateStatus(final boolean updateGrid) { + for (final TileCraftingTile r : this.tiles) { + r.updateMeta(true); + } + } + + @Override + public void destroy() { + if (this.isDestroyed) { + return; + } + this.isDestroyed = true; + + boolean posted = false; + + for (final TileCraftingTile r : this.tiles) { + final IGridNode n = r.getActionableNode(); + if (n != null && !posted) { + final IGrid g = n.getGrid(); + if (g != null) { + g.postEvent(new MENetworkCraftingCpuChange(n)); + posted = true; + } + } + + r.updateStatus(null); + } + } + + @Override + public Iterator getTiles() { + return (Iterator) this.tiles.iterator(); + } + + void addTile(final TileCraftingTile te) { + if (this.machineSrc == null || te.isCoreBlock()) { + this.machineSrc = new MachineSource(te); + } + + te.setCoreBlock(false); + te.saveChanges(); + this.tiles.add(0, te); + + if (te.isStorage()) { + this.availableStorage += te.getStorageBytes(); + this.storage.add(te); + } else if (te.isStatus()) { + this.status.add((TileCraftingMonitorTile) te); + } else if (te.isAccelerator()) { + this.accelerator++; + } + } + + public boolean canAccept(final IAEItemStack input) { + if (input instanceof IAEItemStack) { + final IAEItemStack is = this.waitingFor.findPrecise(input); + if (is != null && is.getStackSize() > 0) { + return true; + } + } + return false; + } + + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + if (!(input instanceof IAEItemStack)) { + return input; + } + + final IAEItemStack what = input.copy(); + final IAEItemStack is = this.waitingFor.findPrecise(what); + + if (type == Actionable.SIMULATE)// causes crafting to lock up? + { + if (is != null && is.getStackSize() > 0) { + if (is.getStackSize() >= what.getStackSize()) { + if (this.finalOutput.equals(what)) { + if (this.myLastLink != null) { + return ((CraftingLink) this.myLastLink).injectItems(what.copy(), type); + } + + return what; // ignore it. + } + + return null; + } + + final IAEItemStack leftOver = what.copy(); + leftOver.decStackSize(is.getStackSize()); + + final IAEItemStack used = what.copy(); + used.setStackSize(is.getStackSize()); + + if (this.finalOutput.equals(what)) { + if (this.myLastLink != null) { + leftOver.add(((CraftingLink) this.myLastLink).injectItems(used.copy(), type)); + return leftOver; + } + + return what; // ignore it. + } + + return leftOver; + } + } else if (type == Actionable.MODULATE) { + if (is != null && is.getStackSize() > 0) { + this.waiting = false; + + this.postChange(what, src); + + if (is.getStackSize() >= what.getStackSize()) { + is.decStackSize(what.getStackSize()); + + this.updateElapsedTime(what); + this.markDirty(); + this.postCraftingStatusChange(what.copy().setStackSize(-what.getStackSize())); + + if (this.finalOutput.equals(what)) { + IAEItemStack leftover = what; + + this.finalOutput.decStackSize(what.getStackSize()); + + if (this.myLastLink != null) { + leftover = ((CraftingLink) this.myLastLink).injectItems(what, type); + } + + if (this.finalOutput.getStackSize() <= 0) { + this.completeJob(); + } + + this.updateCPU(); + + return leftover; // ignore it. + } + + // 2000 + return this.inventory.injectItems(what, type, src); + } + + final IAEItemStack insert = what.copy(); + insert.setStackSize(is.getStackSize()); + what.decStackSize(is.getStackSize()); + + is.setStackSize(0); + this.postCraftingStatusChange(insert.copy().setStackSize(-insert.getStackSize())); + + if (this.finalOutput.equals(insert)) { + IAEItemStack leftover = input; + + this.finalOutput.decStackSize(insert.getStackSize()); + + if (this.myLastLink != null) { + what.add(((CraftingLink) this.myLastLink).injectItems(insert.copy(), type)); + leftover = what; + } + + if (this.finalOutput.getStackSize() <= 0) { + this.completeJob(); + } + + this.updateCPU(); + this.markDirty(); -public final class CraftingCPUCluster implements IAECluster, ICraftingCPU -{ - - private static final String LOG_MARK_AS_COMPLETE = "Completed job for %s."; - - private final WorldCoord min; - private final WorldCoord max; - private final int[] usedOps = new int[3]; - private final Map tasks = new HashMap<>(); - // INSTANCE sate - private final List tiles = new ArrayList<>(); - private final List storage = new ArrayList<>(); - private final List status = new ArrayList<>(); - private final HashMap, Object> listeners = new HashMap<>(); - private ICraftingLink myLastLink; - private ITextComponent myName = null; - private boolean isDestroyed = false; - /** - * crafting job info - */ - private MECraftingInventory inventory = new MECraftingInventory(); - private IAEItemStack finalOutput; - private boolean waiting = false; - private IItemList waitingFor = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private long availableStorage = 0; - private MachineSource machineSrc = null; - private int accelerator = 0; - private boolean isComplete = true; - private int remainingOperations; - private boolean somethingChanged; - - private long lastTime; - private long elapsedTime; - private long startItemCount; - private long remainingItemCount; - - public CraftingCPUCluster( final WorldCoord min, final WorldCoord max ) - { - this.min = min; - this.max = max; - } - - public boolean isDestroyed() - { - return this.isDestroyed; - } - - public ICraftingLink getLastCraftingLink() - { - return this.myLastLink; - } - - /** - * add a new Listener to the monitor, be sure to properly remove yourself when your done. - */ - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } - - /** - * remove a Listener to the monitor. - */ - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } - - public IMEInventory getInventory() - { - return this.inventory; - } - - @Override - public void updateStatus( final boolean updateGrid ) - { - for( final TileCraftingTile r : this.tiles ) - { - r.updateMeta( true ); - } - } - - @Override - public void destroy() - { - if( this.isDestroyed ) - { - return; - } - this.isDestroyed = true; - - boolean posted = false; - - for( final TileCraftingTile r : this.tiles ) - { - final IGridNode n = r.getActionableNode(); - if( n != null && !posted ) - { - final IGrid g = n.getGrid(); - if( g != null ) - { - g.postEvent( new MENetworkCraftingCpuChange( n ) ); - posted = true; - } - } - - r.updateStatus( null ); - } - } - - @Override - public Iterator getTiles() - { - return (Iterator) this.tiles.iterator(); - } - - void addTile( final TileCraftingTile te ) - { - if( this.machineSrc == null || te.isCoreBlock() ) - { - this.machineSrc = new MachineSource( te ); - } - - te.setCoreBlock( false ); - te.saveChanges(); - this.tiles.add( 0, te ); - - if( te.isStorage() ) - { - this.availableStorage += te.getStorageBytes(); - this.storage.add( te ); - } - else if( te.isStatus() ) - { - this.status.add( (TileCraftingMonitorTile) te ); - } - else if( te.isAccelerator() ) - { - this.accelerator++; - } - } - - public boolean canAccept( final IAEItemStack input ) - { - if( input instanceof IAEItemStack ) - { - final IAEItemStack is = this.waitingFor.findPrecise( input ); - if( is != null && is.getStackSize() > 0 ) - { - return true; - } - } - return false; - } - - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - if( !( input instanceof IAEItemStack ) ) - { - return input; - } - - final IAEItemStack what = input.copy(); - final IAEItemStack is = this.waitingFor.findPrecise( what ); - - if( type == Actionable.SIMULATE )// causes crafting to lock up? - { - if( is != null && is.getStackSize() > 0 ) - { - if( is.getStackSize() >= what.getStackSize() ) - { - if( this.finalOutput.equals( what ) ) - { - if( this.myLastLink != null ) - { - return ( (CraftingLink) this.myLastLink ).injectItems( what.copy(), type ); - } - - return what; // ignore it. - } - - return null; - } - - final IAEItemStack leftOver = what.copy(); - leftOver.decStackSize( is.getStackSize() ); - - final IAEItemStack used = what.copy(); - used.setStackSize( is.getStackSize() ); - - if( this.finalOutput.equals( what ) ) - { - if( this.myLastLink != null ) - { - leftOver.add( ( (CraftingLink) this.myLastLink ).injectItems( used.copy(), type ) ); - return leftOver; - } - - return what; // ignore it. - } - - return leftOver; - } - } - else if( type == Actionable.MODULATE ) - { - if( is != null && is.getStackSize() > 0 ) - { - this.waiting = false; - - this.postChange( what, src ); - - if( is.getStackSize() >= what.getStackSize() ) - { - is.decStackSize( what.getStackSize() ); - - this.updateElapsedTime( what ); - this.markDirty(); - this.postCraftingStatusChange( what.copy().setStackSize( -what.getStackSize() ) ); - - if( this.finalOutput.equals( what ) ) - { - IAEItemStack leftover = what; - - this.finalOutput.decStackSize( what.getStackSize() ); - - if( this.myLastLink != null ) - { - leftover = ( (CraftingLink) this.myLastLink ).injectItems( what, type ); - } - - if( this.finalOutput.getStackSize() <= 0 ) - { - this.completeJob(); - } - - this.updateCPU(); - - return leftover; // ignore it. - } - - // 2000 - return this.inventory.injectItems( what, type, src ); - } - - final IAEItemStack insert = what.copy(); - insert.setStackSize( is.getStackSize() ); - what.decStackSize( is.getStackSize() ); - - is.setStackSize( 0 ); - this.postCraftingStatusChange( insert.copy().setStackSize( -insert.getStackSize() ) ); - - if( this.finalOutput.equals( insert ) ) - { - IAEItemStack leftover = input; - - this.finalOutput.decStackSize( insert.getStackSize() ); - - if( this.myLastLink != null ) - { - what.add( ( (CraftingLink) this.myLastLink ).injectItems( insert.copy(), type ) ); - leftover = what; - } - - if( this.finalOutput.getStackSize() <= 0 ) - { - this.completeJob(); - } - - this.updateCPU(); - this.markDirty(); - - return leftover; // ignore it. - } - - this.inventory.injectItems( insert, type, src ); - this.markDirty(); - - return what; - } - } - - return input; - } - - private void postChange( final IAEItemStack diff, final IActionSource src ) - { - final Iterator, Object>> i = this.getListeners(); - - // protect integrity - if( i.hasNext() ) - { - final ImmutableList single = ImmutableList.of( diff.copy() ); - - while( i.hasNext() ) - { - final Entry, Object> o = i.next(); - final IMEMonitorHandlerReceiver receiver = o.getKey(); - - if( receiver.isValid( o.getValue() ) ) - { - receiver.postChange( null, single, src ); - } - else - { - i.remove(); - } - } - } - } - - private void markDirty() - { - this.getCore().saveChanges(); - } - - private void postCraftingStatusChange( final IAEItemStack diff ) - { - if( this.getGrid() == null ) - { - return; - } - - final CraftingGridCache sg = this.getGrid().getCache( ICraftingGrid.class ); - - if( sg.getInterestManager().containsKey( diff ) ) - { - final Collection list = sg.getInterestManager().get( diff ); - - if( !list.isEmpty() ) - { - for( final CraftingWatcher iw : list ) - - { - iw.getHost().onRequestChange( sg, diff ); - } - } - } - } - - private void completeJob() - { - if( this.myLastLink != null ) - { - ( (CraftingLink) this.myLastLink ).markDone(); - } - - if( AELog.isCraftingLogEnabled() ) - { - final IAEItemStack logStack = this.finalOutput.copy(); - logStack.setStackSize( this.startItemCount ); - AELog.crafting( LOG_MARK_AS_COMPLETE, logStack ); - } - - this.remainingItemCount = 0; - this.startItemCount = 0; - this.lastTime = 0; - this.elapsedTime = 0; - this.isComplete = true; - } - - private void updateCPU() - { - IAEItemStack send = this.finalOutput; - - if( this.finalOutput != null && this.finalOutput.getStackSize() <= 0 ) - { - send = null; - } - - for( final TileCraftingMonitorTile t : this.status ) - { - t.setJob( send ); - } - } - - private Iterator, Object>> getListeners() - { - return this.listeners.entrySet().iterator(); - } - - private TileCraftingTile getCore() - { - if( this.machineSrc == null ) - { - return null; - } - return (TileCraftingTile) this.machineSrc.machine().get(); - } - - private IGrid getGrid() - { - for( final TileCraftingTile r : this.tiles ) - { - final IGridNode gn = r.getActionableNode(); - if( gn != null ) - { - final IGrid g = gn.getGrid(); - if( g != null ) - { - return r.getActionableNode().getGrid(); - } - } - } - - return null; - } - - private boolean canCraft( final ICraftingPatternDetails details, final IAEItemStack[] condensedInputs ) - { - for( IAEItemStack g : condensedInputs ) - { - - if( details.isCraftable() ) - { - boolean found = false; - - for( IAEItemStack fuzz : this.inventory.getItemList().findFuzzy( g, FuzzyMode.IGNORE_ALL ) ) - { - fuzz = fuzz.copy(); - fuzz.setStackSize( g.getStackSize() ); - final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.SIMULATE, this.machineSrc ); - final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - - if( !is.isEmpty() && is.getCount() == g.getStackSize() ) - { - found = true; - break; - } - else if( !is.isEmpty() ) - { - g = g.copy(); - g.decStackSize( is.getCount() ); - } - } - - if( !found ) - { - return false; - } - } - else - { - final IAEItemStack ais = this.inventory.extractItems( g.copy(), Actionable.SIMULATE, this.machineSrc ); - final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - - if( is.isEmpty() || is.getCount() < g.getStackSize() ) - { - return false; - } - } - } - - return true; - } - - public void cancel() - { - if( this.myLastLink != null ) - { - this.myLastLink.cancel(); - } - - final IItemList list; - this.getListOfItem( list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(), CraftingItemList.ALL ); - for( final IAEItemStack is : list ) - { - this.postChange( is, this.machineSrc ); - } - - this.isComplete = true; - this.myLastLink = null; - this.tasks.clear(); - - // final ImmutableSet items = ImmutableSet.copyOf( this.waitingFor ); - final List items = new ArrayList<>( this.waitingFor.size() ); - this.waitingFor.forEach( stack -> items.add( stack.copy().setStackSize( -stack.getStackSize() ) ) ); - - this.waitingFor.resetStatus(); - - for( final IAEItemStack is : items ) - { - this.postCraftingStatusChange( is ); - } - - this.finalOutput = null; - this.updateCPU(); - - this.storeItems(); // marks dirty - } - - public void updateCraftingLogic( final IGrid grid, final IEnergyGrid eg, final CraftingGridCache cc ) - { - if( !this.getCore().isActive() ) - { - return; - } - - if( this.myLastLink != null ) - { - if( this.myLastLink.isCanceled() ) - { - this.myLastLink = null; - this.cancel(); - } - } - - if( this.isComplete ) - { - if( this.inventory.getItemList().isEmpty() ) - { - return; - } - - this.storeItems(); - return; - } - - this.waiting = false; - if( this.waiting || this.tasks.isEmpty() ) // nothing to do here... - { - return; - } - - this.remainingOperations = this.accelerator + 1 - ( this.usedOps[0] + this.usedOps[1] + this.usedOps[2] ); - final int started = this.remainingOperations; - - if( this.remainingOperations > 0 ) - { - do - { - this.somethingChanged = false; - this.executeCrafting( eg, cc ); - } - while( this.somethingChanged && this.remainingOperations > 0 ); - } - this.usedOps[2] = this.usedOps[1]; - this.usedOps[1] = this.usedOps[0]; - this.usedOps[0] = started - this.remainingOperations; - - if( this.remainingOperations > 0 && !this.somethingChanged ) - { - this.waiting = true; - } - } - - private void executeCrafting( final IEnergyGrid eg, final CraftingGridCache cc ) - { - final Iterator> i = this.tasks.entrySet().iterator(); - - while( i.hasNext() ) - { - final Entry e = i.next(); - - if( e.getValue().value <= 0 ) - { - i.remove(); - continue; - } - - final ICraftingPatternDetails details = e.getKey(); - - if( this.canCraft( details, details.getCondensedInputs() ) ) - { - CraftingInventory ic = null; - - for( final ICraftingMedium m : cc.getMediums( e.getKey() ) ) - { - if( e.getValue().value <= 0 ) - { - continue; - } - - if( !m.isBusy() ) - { - if( ic == null ) - { - final IAEItemStack[] input = details.getInputs(); - double sum = 0; - - for( final IAEItemStack anInput : input ) - { - if( anInput != null ) - { - sum += anInput.getStackSize(); - } - } - - // power... - if( eg.extractAEPower( sum, Actionable.MODULATE, PowerMultiplier.CONFIG ) < sum - 0.01 ) - { - continue; - } - - ic = new CraftingInventory( new ContainerNull(), 3, 3 ); - boolean found = false; - - for( int x = 0; x < input.length; x++ ) - { - if( input[x] != null ) - { - found = false; - - if( details.isCraftable() ) - { - final Collection itemList; - - if( details.canSubstitute() ) - { - itemList = this.inventory.getItemList().findFuzzy( input[x], FuzzyMode.IGNORE_ALL ); - } - else - { - itemList = new ArrayList<>( 1 ); - - final IAEItemStack item = this.inventory.getItemList().findPrecise( input[x] ); - - if( item != null ) - { - itemList.add( item ); - } - } - - for( IAEItemStack fuzz : itemList ) - { - fuzz = fuzz.copy(); - fuzz.setStackSize( input[x].getStackSize() ); - - if( details.isValidItemForSlot( x, fuzz.createItemStack(), this.getWorld() ) ) - { - final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.MODULATE, this.machineSrc ); - final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - - if( !is.isEmpty() ) - { - this.postChange( AEItemStack.fromItemStack( is ), this.machineSrc ); - ic.setInventorySlotContents( x, is ); - found = true; - break; - } - } - } - } - else - { - final IAEItemStack ais = this.inventory.extractItems( input[x].copy(), Actionable.MODULATE, this.machineSrc ); - final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); - - if( !is.isEmpty() ) - { - this.postChange( input[x], this.machineSrc ); - ic.setInventorySlotContents( x, is ); - if( is.getCount() == input[x].getStackSize() ) - { - found = true; - continue; - } - } - } - - if( !found ) - { - break; - } - } - } - - if( !found ) - { - // put stuff back.. - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - final ItemStack is = ic.getStackInSlot( x ); - if( !is.isEmpty() ) - { - this.inventory.injectItems( AEItemStack.fromItemStack( is ), Actionable.MODULATE, this.machineSrc ); - } - } - ic = null; - break; - } - } - - if( m.pushPattern( details, ic ) ) - { - this.somethingChanged = true; - this.remainingOperations--; - - for( final IAEItemStack out : details.getCondensedOutputs() ) - { - this.postChange( out, this.machineSrc ); - this.waitingFor.add( out.copy() ); - this.postCraftingStatusChange( out.copy() ); - } - - if( details.isCraftable() ) - { - BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) getWorld() ), details.getOutput( ic, this.getWorld() ), ic ); - - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - final ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) ); - if( !output.isEmpty() ) - { - final IAEItemStack cItem = AEItemStack.fromItemStack( output ); - this.postChange( cItem, this.machineSrc ); - this.waitingFor.add( cItem ); - this.postCraftingStatusChange( cItem ); - } - } - } - - ic = null; // hand off complete! - this.markDirty(); - - e.getValue().value--; - if( e.getValue().value <= 0 ) - { - continue; - } - - if( this.remainingOperations == 0 ) - { - return; - } - } - } - } - - if( ic != null ) - { - // put stuff back.. - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - final ItemStack is = ic.getStackInSlot( x ); - if( !is.isEmpty() ) - { - this.inventory.injectItems( AEItemStack.fromItemStack( is ), Actionable.MODULATE, this.machineSrc ); - } - } - } - } - } - } - - private void storeItems() - { - final IGrid g = this.getGrid(); - - if( g == null ) - { - return; - } - - final IStorageGrid sg = g.getCache( IStorageGrid.class ); - final IMEInventory ii = sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - - for( IAEItemStack is : this.inventory.getItemList() ) - { - is = this.inventory.extractItems( is.copy(), Actionable.MODULATE, this.machineSrc ); - - if( is != null ) - { - this.postChange( is, this.machineSrc ); - is = ii.injectItems( is, Actionable.MODULATE, this.machineSrc ); - } - - if( is != null ) - { - this.inventory.injectItems( is, Actionable.MODULATE, this.machineSrc ); - } - } - - if( this.inventory.getItemList().isEmpty() ) - { - this.inventory = new MECraftingInventory(); - } - - this.markDirty(); - } - - public ICraftingLink submitJob( final IGrid g, final ICraftingJob job, final IActionSource src, final ICraftingRequester requestingMachine ) - { - if( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() ) - { - return null; - } - - if( !( job instanceof CraftingJob ) ) - { - return null; - } - - if( this.isBusy() || !this.isActive() || this.availableStorage < job.getByteTotal() ) - { - return null; - } - - final IStorageGrid sg = g.getCache( IStorageGrid.class ); - final IMEInventory storage = sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final MECraftingInventory ci = new MECraftingInventory( storage, true, false, false ); - - try - { - this.waitingFor.resetStatus(); - ( (CraftingJob) job ).getTree().setJob( ci, this, src ); - if( ci.commit( src ) ) - { - this.finalOutput = job.getOutput(); - this.waiting = false; - this.isComplete = false; - this.markDirty(); - - this.updateCPU(); - final String craftID = this.generateCraftingID(); - - this.myLastLink = new CraftingLink( this.generateLinkData( craftID, requestingMachine == null, false ), this ); - - this.prepareElapsedTime(); - - if( requestingMachine == null ) - { - return this.myLastLink; - } - - final ICraftingLink whatLink = new CraftingLink( this.generateLinkData( craftID, false, true ), requestingMachine ); - - this.submitLink( this.myLastLink ); - this.submitLink( whatLink ); - - final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - this.getListOfItem( list, CraftingItemList.ALL ); - for( final IAEItemStack ge : list ) - { - this.postChange( ge, this.machineSrc ); - } - - return whatLink; - } - else - { - this.tasks.clear(); - this.inventory.getItemList().resetStatus(); - } - } - catch( final CraftBranchFailure e ) - { - this.tasks.clear(); - this.inventory.getItemList().resetStatus(); - // AELog.error( e ); - } - - return null; - } - - @Override - public boolean isBusy() - { - final Iterator> i = this.tasks.entrySet().iterator(); - - while( i.hasNext() ) - { - if( i.next().getValue().value <= 0 ) - { - i.remove(); - } - } - - return !this.tasks.isEmpty() || !this.waitingFor.isEmpty(); - } - - @Override - public IActionSource getActionSource() - { - return this.machineSrc; - } - - @Override - public long getAvailableStorage() - { - return this.availableStorage; - } - - @Override - public int getCoProcessors() - { - return this.accelerator; - } - - @Override - public ITextComponent getName() - { - return this.myName; - } - - public boolean isActive() - { - final TileCraftingTile core = this.getCore(); - - if( core == null ) - { - return false; - } - - final IGridNode node = core.getActionableNode(); - if( node == null ) - { - return false; - } - - return node.isActive(); - } - - private String generateCraftingID() - { - final long now = System.currentTimeMillis(); - final int hash = System.identityHashCode( this ); - final int hmm = this.finalOutput == null ? 0 : this.finalOutput.hashCode(); - - return Long.toString( now, Character.MAX_RADIX ) + '-' + Integer.toString( hash, Character.MAX_RADIX ) + '-' + Integer.toString( hmm, Character.MAX_RADIX ); - } - - private CompoundNBT generateLinkData( final String craftingID, final boolean standalone, final boolean req ) - { - final CompoundNBT tag = new CompoundNBT(); - - tag.putString( "CraftID", craftingID ); - tag.putBoolean( "canceled", false ); - tag.putBoolean( "done", false ); - tag.putBoolean( "standalone", standalone ); - tag.putBoolean( "req", req ); - - return tag; - } - - private void submitLink( final ICraftingLink myLastLink2 ) - { - if( this.getGrid() != null ) - { - final CraftingGridCache cc = this.getGrid().getCache( ICraftingGrid.class ); - cc.addLink( (CraftingLink) myLastLink2 ); - } - } - - public void getListOfItem( final IItemList list, final CraftingItemList whichList ) - { - switch( whichList ) - { - case ACTIVE: - for( final IAEItemStack ais : this.waitingFor ) - { - list.add( ais ); - } - break; - case PENDING: - for( final Entry t : this.tasks.entrySet() ) - { - for( IAEItemStack ais : t.getKey().getCondensedOutputs() ) - { - ais = ais.copy(); - ais.setStackSize( ais.getStackSize() * t.getValue().value ); - list.add( ais ); - } - } - break; - case STORAGE: - this.inventory.getAvailableItems( list ); - break; - default: - case ALL: - this.inventory.getAvailableItems( list ); - - for( final IAEItemStack ais : this.waitingFor ) - { - list.add( ais ); - } - - for( final Entry t : this.tasks.entrySet() ) - { - for( IAEItemStack ais : t.getKey().getCondensedOutputs() ) - { - ais = ais.copy(); - ais.setStackSize( ais.getStackSize() * t.getValue().value ); - list.add( ais ); - } - } - break; - } - } - - public void addStorage( final IAEItemStack extractItems ) - { - this.inventory.injectItems( extractItems, Actionable.MODULATE, null ); - } - - public void addEmitable( final IAEItemStack i ) - { - this.waitingFor.add( i ); - this.postCraftingStatusChange( i ); - } - - public void addCrafting( final ICraftingPatternDetails details, final long crafts ) - { - TaskProgress i = this.tasks.get( details ); - - if( i == null ) - { - this.tasks.put( details, i = new TaskProgress() ); - } - - i.value += crafts; - } - - public IAEItemStack getItemStack( final IAEItemStack what, final CraftingItemList storage2 ) - { - IAEItemStack is; - - switch( storage2 ) - { - case STORAGE: - is = this.inventory.getItemList().findPrecise( what ); - break; - case ACTIVE: - is = this.waitingFor.findPrecise( what ); - break; - case PENDING: - - is = what.copy(); - is.setStackSize( 0 ); - - for( final Entry t : this.tasks.entrySet() ) - { - for( final IAEItemStack ais : t.getKey().getCondensedOutputs() ) - { - if( ais.equals( is ) ) - { - is.setStackSize( is.getStackSize() + ais.getStackSize() * t.getValue().value ); - } - } - } - - break; - default: - case ALL: - throw new IllegalStateException( "Invalid Operation" ); - } - - if( is != null ) - { - return is.copy(); - } - - is = what.copy(); - is.setStackSize( 0 ); - return is; - } - - public void writeToNBT( final CompoundNBT data ) - { - data.put( "finalOutput", this.writeItem( this.finalOutput ) ); - data.put( "inventory", this.writeList( this.inventory.getItemList() ) ); - data.putBoolean( "waiting", this.waiting ); - data.putBoolean( "isComplete", this.isComplete ); - - if( this.myLastLink != null ) - { - final CompoundNBT link = new CompoundNBT(); - this.myLastLink.writeToNBT( link ); - data.put( "link", link ); - } - - final ListNBT list = new ListNBT(); - for( final Entry e : this.tasks.entrySet() ) - { - final CompoundNBT item = this.writeItem( AEItemStack.fromItemStack( e.getKey().getPattern() ) ); - item.putLong( "craftingProgress", e.getValue().value ); - list.add( item ); - } - data.put( "tasks", list ); - - data.put( "waitingFor", this.writeList( this.waitingFor ) ); - - data.putLong( "elapsedTime", this.getElapsedTime() ); - data.putLong( "startItemCount", this.getStartItemCount() ); - data.putLong( "remainingItemCount", this.getRemainingItemCount() ); - } - - private CompoundNBT writeItem( final IAEItemStack finalOutput2 ) - { - final CompoundNBT out = new CompoundNBT(); - - if( finalOutput2 != null ) - { - finalOutput2.writeToNBT( out ); - } - - return out; - } - - private ListNBT writeList( final IItemList myList ) - { - final ListNBT out = new ListNBT(); - - for( final IAEItemStack ais : myList ) - { - out.add( this.writeItem( ais ) ); - } - - return out; - } - - void done() - { - final TileCraftingTile core = this.getCore(); - - core.setCoreBlock( true ); - - if( core.getPreviousState() != null ) - { - this.readFromNBT( core.getPreviousState() ); - core.setPreviousState( null ); - } - - this.updateCPU(); - this.updateName(); - } - - public void readFromNBT( final CompoundNBT data ) - { - this.finalOutput = AEItemStack.fromNBT( data.getCompound( "finalOutput" ) ); - for( final IAEItemStack ais : this.readList( data.getList( "inventory", 10 ) ) ) - { - this.inventory.injectItems( ais, Actionable.MODULATE, this.machineSrc ); - } - - this.waiting = data.getBoolean( "waiting" ); - this.isComplete = data.getBoolean( "isComplete" ); - - if( data.contains( "link" ) ) - { - final CompoundNBT link = data.getCompound( "link" ); - this.myLastLink = new CraftingLink( link, this ); - this.submitLink( this.myLastLink ); - } - - final ListNBT list = data.getList( "tasks", 10 ); - for( int x = 0; x < list.size(); x++ ) - { - final CompoundNBT item = list.getCompound( x ); - final IAEItemStack pattern = AEItemStack.fromNBT( item ); - if( pattern != null && pattern.getItem() instanceof ICraftingPatternItem ) - { - final ICraftingPatternItem cpi = (ICraftingPatternItem) pattern.getItem(); - final ICraftingPatternDetails details = cpi.getPatternForItem( pattern.createItemStack(), this.getWorld() ); - if( details != null ) - { - final TaskProgress tp = new TaskProgress(); - tp.value = item.getLong( "craftingProgress" ); - this.tasks.put( details, tp ); - } - } - } - - this.waitingFor = this.readList( data.getList( "waitingFor", 10 ) ); - for( final IAEItemStack is : this.waitingFor ) - { - this.postCraftingStatusChange( is.copy() ); - } - - this.lastTime = System.nanoTime(); - this.elapsedTime = data.getLong( "elapsedTime" ); - this.startItemCount = data.getLong( "startItemCount" ); - this.remainingItemCount = data.getLong( "remainingItemCount" ); - } - - public void updateName() - { - this.myName = null; - for( final TileCraftingTile te : this.tiles ) - { - - if( te.hasCustomInventoryName() ) - { - if( this.myName != null ) - { - this.myName.appendText(" ").appendSibling(te.getCustomInventoryName()); - } - else - { - this.myName = te.getCustomInventoryName().deepCopy(); - } - } - } - } - - private IItemList readList( final ListNBT tag ) - { - final IItemList out = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - - if( tag == null ) - { - return out; - } - - for( int x = 0; x < tag.size(); x++ ) - { - final IAEItemStack ais = AEItemStack.fromNBT( tag.getCompound( x ) ); - if( ais != null ) - { - out.add( ais ); - } - } - - return out; - } - - private World getWorld() - { - return this.getCore().getWorld(); - } - - public IAEItemStack making( final IAEItemStack what ) - { - return this.waitingFor.findPrecise( what ); - } - - public void breakCluster() - { - final TileCraftingTile t = this.getCore(); - - if( t != null ) - { - t.breakCluster(); - } - } - - private void prepareElapsedTime() - { - this.lastTime = System.nanoTime(); - this.elapsedTime = 0; - - final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - - this.getListOfItem( list, CraftingItemList.ACTIVE ); - this.getListOfItem( list, CraftingItemList.PENDING ); - - int itemCount = 0; - for( final IAEItemStack ge : list ) - { - itemCount += ge.getStackSize(); - } - - this.startItemCount = itemCount; - this.remainingItemCount = itemCount; - } - - private void updateElapsedTime( final IAEItemStack is ) - { - final long nextStartTime = System.nanoTime(); - this.elapsedTime = this.getElapsedTime() + nextStartTime - this.lastTime; - this.lastTime = nextStartTime; - this.remainingItemCount = this.getRemainingItemCount() - is.getStackSize(); - } - - public long getElapsedTime() - { - return this.elapsedTime; - } - - public long getRemainingItemCount() - { - return this.remainingItemCount; - } - - public long getStartItemCount() - { - return this.startItemCount; - } - - private static class TaskProgress - { - private long value; - } + return leftover; // ignore it. + } + + this.inventory.injectItems(insert, type, src); + this.markDirty(); + + return what; + } + } + + return input; + } + + private void postChange(final IAEItemStack diff, final IActionSource src) { + final Iterator, Object>> i = this.getListeners(); + + // protect integrity + if (i.hasNext()) { + final ImmutableList single = ImmutableList.of(diff.copy()); + + while (i.hasNext()) { + final Entry, Object> o = i.next(); + final IMEMonitorHandlerReceiver receiver = o.getKey(); + + if (receiver.isValid(o.getValue())) { + receiver.postChange(null, single, src); + } else { + i.remove(); + } + } + } + } + + private void markDirty() { + this.getCore().saveChanges(); + } + + private void postCraftingStatusChange(final IAEItemStack diff) { + if (this.getGrid() == null) { + return; + } + + final CraftingGridCache sg = this.getGrid().getCache(ICraftingGrid.class); + + if (sg.getInterestManager().containsKey(diff)) { + final Collection list = sg.getInterestManager().get(diff); + + if (!list.isEmpty()) { + for (final CraftingWatcher iw : list) + + { + iw.getHost().onRequestChange(sg, diff); + } + } + } + } + + private void completeJob() { + if (this.myLastLink != null) { + ((CraftingLink) this.myLastLink).markDone(); + } + + if (AELog.isCraftingLogEnabled()) { + final IAEItemStack logStack = this.finalOutput.copy(); + logStack.setStackSize(this.startItemCount); + AELog.crafting(LOG_MARK_AS_COMPLETE, logStack); + } + + this.remainingItemCount = 0; + this.startItemCount = 0; + this.lastTime = 0; + this.elapsedTime = 0; + this.isComplete = true; + } + + private void updateCPU() { + IAEItemStack send = this.finalOutput; + + if (this.finalOutput != null && this.finalOutput.getStackSize() <= 0) { + send = null; + } + + for (final TileCraftingMonitorTile t : this.status) { + t.setJob(send); + } + } + + private Iterator, Object>> getListeners() { + return this.listeners.entrySet().iterator(); + } + + private TileCraftingTile getCore() { + if (this.machineSrc == null) { + return null; + } + return (TileCraftingTile) this.machineSrc.machine().get(); + } + + private IGrid getGrid() { + for (final TileCraftingTile r : this.tiles) { + final IGridNode gn = r.getActionableNode(); + if (gn != null) { + final IGrid g = gn.getGrid(); + if (g != null) { + return r.getActionableNode().getGrid(); + } + } + } + + return null; + } + + private boolean canCraft(final ICraftingPatternDetails details, final IAEItemStack[] condensedInputs) { + for (IAEItemStack g : condensedInputs) { + + if (details.isCraftable()) { + boolean found = false; + + for (IAEItemStack fuzz : this.inventory.getItemList().findFuzzy(g, FuzzyMode.IGNORE_ALL)) { + fuzz = fuzz.copy(); + fuzz.setStackSize(g.getStackSize()); + final IAEItemStack ais = this.inventory.extractItems(fuzz, Actionable.SIMULATE, this.machineSrc); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); + + if (!is.isEmpty() && is.getCount() == g.getStackSize()) { + found = true; + break; + } else if (!is.isEmpty()) { + g = g.copy(); + g.decStackSize(is.getCount()); + } + } + + if (!found) { + return false; + } + } else { + final IAEItemStack ais = this.inventory.extractItems(g.copy(), Actionable.SIMULATE, this.machineSrc); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); + + if (is.isEmpty() || is.getCount() < g.getStackSize()) { + return false; + } + } + } + + return true; + } + + public void cancel() { + if (this.myLastLink != null) { + this.myLastLink.cancel(); + } + + final IItemList list; + this.getListOfItem(list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(), + CraftingItemList.ALL); + for (final IAEItemStack is : list) { + this.postChange(is, this.machineSrc); + } + + this.isComplete = true; + this.myLastLink = null; + this.tasks.clear(); + + // final ImmutableSet items = ImmutableSet.copyOf( this.waitingFor + // ); + final List items = new ArrayList<>(this.waitingFor.size()); + this.waitingFor.forEach(stack -> items.add(stack.copy().setStackSize(-stack.getStackSize()))); + + this.waitingFor.resetStatus(); + + for (final IAEItemStack is : items) { + this.postCraftingStatusChange(is); + } + + this.finalOutput = null; + this.updateCPU(); + + this.storeItems(); // marks dirty + } + + public void updateCraftingLogic(final IGrid grid, final IEnergyGrid eg, final CraftingGridCache cc) { + if (!this.getCore().isActive()) { + return; + } + + if (this.myLastLink != null) { + if (this.myLastLink.isCanceled()) { + this.myLastLink = null; + this.cancel(); + } + } + + if (this.isComplete) { + if (this.inventory.getItemList().isEmpty()) { + return; + } + + this.storeItems(); + return; + } + + this.waiting = false; + if (this.waiting || this.tasks.isEmpty()) // nothing to do here... + { + return; + } + + this.remainingOperations = this.accelerator + 1 - (this.usedOps[0] + this.usedOps[1] + this.usedOps[2]); + final int started = this.remainingOperations; + + if (this.remainingOperations > 0) { + do { + this.somethingChanged = false; + this.executeCrafting(eg, cc); + } while (this.somethingChanged && this.remainingOperations > 0); + } + this.usedOps[2] = this.usedOps[1]; + this.usedOps[1] = this.usedOps[0]; + this.usedOps[0] = started - this.remainingOperations; + + if (this.remainingOperations > 0 && !this.somethingChanged) { + this.waiting = true; + } + } + + private void executeCrafting(final IEnergyGrid eg, final CraftingGridCache cc) { + final Iterator> i = this.tasks.entrySet().iterator(); + + while (i.hasNext()) { + final Entry e = i.next(); + + if (e.getValue().value <= 0) { + i.remove(); + continue; + } + + final ICraftingPatternDetails details = e.getKey(); + + if (this.canCraft(details, details.getCondensedInputs())) { + CraftingInventory ic = null; + + for (final ICraftingMedium m : cc.getMediums(e.getKey())) { + if (e.getValue().value <= 0) { + continue; + } + + if (!m.isBusy()) { + if (ic == null) { + final IAEItemStack[] input = details.getInputs(); + double sum = 0; + + for (final IAEItemStack anInput : input) { + if (anInput != null) { + sum += anInput.getStackSize(); + } + } + + // power... + if (eg.extractAEPower(sum, Actionable.MODULATE, PowerMultiplier.CONFIG) < sum - 0.01) { + continue; + } + + ic = new CraftingInventory(new ContainerNull(), 3, 3); + boolean found = false; + + for (int x = 0; x < input.length; x++) { + if (input[x] != null) { + found = false; + + if (details.isCraftable()) { + final Collection itemList; + + if (details.canSubstitute()) { + itemList = this.inventory.getItemList().findFuzzy(input[x], + FuzzyMode.IGNORE_ALL); + } else { + itemList = new ArrayList<>(1); + + final IAEItemStack item = this.inventory.getItemList() + .findPrecise(input[x]); + + if (item != null) { + itemList.add(item); + } + } + + for (IAEItemStack fuzz : itemList) { + fuzz = fuzz.copy(); + fuzz.setStackSize(input[x].getStackSize()); + + if (details.isValidItemForSlot(x, fuzz.createItemStack(), + this.getWorld())) { + final IAEItemStack ais = this.inventory.extractItems(fuzz, + Actionable.MODULATE, this.machineSrc); + final ItemStack is = ais == null ? ItemStack.EMPTY + : ais.createItemStack(); + + if (!is.isEmpty()) { + this.postChange(AEItemStack.fromItemStack(is), this.machineSrc); + ic.setInventorySlotContents(x, is); + found = true; + break; + } + } + } + } else { + final IAEItemStack ais = this.inventory.extractItems(input[x].copy(), + Actionable.MODULATE, this.machineSrc); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack(); + + if (!is.isEmpty()) { + this.postChange(input[x], this.machineSrc); + ic.setInventorySlotContents(x, is); + if (is.getCount() == input[x].getStackSize()) { + found = true; + continue; + } + } + } + + if (!found) { + break; + } + } + } + + if (!found) { + // put stuff back.. + for (int x = 0; x < ic.getSizeInventory(); x++) { + final ItemStack is = ic.getStackInSlot(x); + if (!is.isEmpty()) { + this.inventory.injectItems(AEItemStack.fromItemStack(is), Actionable.MODULATE, + this.machineSrc); + } + } + ic = null; + break; + } + } + + if (m.pushPattern(details, ic)) { + this.somethingChanged = true; + this.remainingOperations--; + + for (final IAEItemStack out : details.getCondensedOutputs()) { + this.postChange(out, this.machineSrc); + this.waitingFor.add(out.copy()); + this.postCraftingStatusChange(out.copy()); + } + + if (details.isCraftable()) { + BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) getWorld()), + details.getOutput(ic, this.getWorld()), ic); + + for (int x = 0; x < ic.getSizeInventory(); x++) { + final ItemStack output = Platform.getContainerItem(ic.getStackInSlot(x)); + if (!output.isEmpty()) { + final IAEItemStack cItem = AEItemStack.fromItemStack(output); + this.postChange(cItem, this.machineSrc); + this.waitingFor.add(cItem); + this.postCraftingStatusChange(cItem); + } + } + } + + ic = null; // hand off complete! + this.markDirty(); + + e.getValue().value--; + if (e.getValue().value <= 0) { + continue; + } + + if (this.remainingOperations == 0) { + return; + } + } + } + } + + if (ic != null) { + // put stuff back.. + for (int x = 0; x < ic.getSizeInventory(); x++) { + final ItemStack is = ic.getStackInSlot(x); + if (!is.isEmpty()) { + this.inventory.injectItems(AEItemStack.fromItemStack(is), Actionable.MODULATE, + this.machineSrc); + } + } + } + } + } + } + + private void storeItems() { + final IGrid g = this.getGrid(); + + if (g == null) { + return; + } + + final IStorageGrid sg = g.getCache(IStorageGrid.class); + final IMEInventory ii = sg + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + + for (IAEItemStack is : this.inventory.getItemList()) { + is = this.inventory.extractItems(is.copy(), Actionable.MODULATE, this.machineSrc); + + if (is != null) { + this.postChange(is, this.machineSrc); + is = ii.injectItems(is, Actionable.MODULATE, this.machineSrc); + } + + if (is != null) { + this.inventory.injectItems(is, Actionable.MODULATE, this.machineSrc); + } + } + + if (this.inventory.getItemList().isEmpty()) { + this.inventory = new MECraftingInventory(); + } + + this.markDirty(); + } + + public ICraftingLink submitJob(final IGrid g, final ICraftingJob job, final IActionSource src, + final ICraftingRequester requestingMachine) { + if (!this.tasks.isEmpty() || !this.waitingFor.isEmpty()) { + return null; + } + + if (!(job instanceof CraftingJob)) { + return null; + } + + if (this.isBusy() || !this.isActive() || this.availableStorage < job.getByteTotal()) { + return null; + } + + final IStorageGrid sg = g.getCache(IStorageGrid.class); + final IMEInventory storage = sg + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final MECraftingInventory ci = new MECraftingInventory(storage, true, false, false); + + try { + this.waitingFor.resetStatus(); + ((CraftingJob) job).getTree().setJob(ci, this, src); + if (ci.commit(src)) { + this.finalOutput = job.getOutput(); + this.waiting = false; + this.isComplete = false; + this.markDirty(); + + this.updateCPU(); + final String craftID = this.generateCraftingID(); + + this.myLastLink = new CraftingLink(this.generateLinkData(craftID, requestingMachine == null, false), + this); + + this.prepareElapsedTime(); + + if (requestingMachine == null) { + return this.myLastLink; + } + + final ICraftingLink whatLink = new CraftingLink(this.generateLinkData(craftID, false, true), + requestingMachine); + + this.submitLink(this.myLastLink); + this.submitLink(whatLink); + + final IItemList list = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + this.getListOfItem(list, CraftingItemList.ALL); + for (final IAEItemStack ge : list) { + this.postChange(ge, this.machineSrc); + } + + return whatLink; + } else { + this.tasks.clear(); + this.inventory.getItemList().resetStatus(); + } + } catch (final CraftBranchFailure e) { + this.tasks.clear(); + this.inventory.getItemList().resetStatus(); + // AELog.error( e ); + } + + return null; + } + + @Override + public boolean isBusy() { + final Iterator> i = this.tasks.entrySet().iterator(); + + while (i.hasNext()) { + if (i.next().getValue().value <= 0) { + i.remove(); + } + } + + return !this.tasks.isEmpty() || !this.waitingFor.isEmpty(); + } + + @Override + public IActionSource getActionSource() { + return this.machineSrc; + } + + @Override + public long getAvailableStorage() { + return this.availableStorage; + } + + @Override + public int getCoProcessors() { + return this.accelerator; + } + + @Override + public ITextComponent getName() { + return this.myName; + } + + public boolean isActive() { + final TileCraftingTile core = this.getCore(); + + if (core == null) { + return false; + } + + final IGridNode node = core.getActionableNode(); + if (node == null) { + return false; + } + + return node.isActive(); + } + + private String generateCraftingID() { + final long now = System.currentTimeMillis(); + final int hash = System.identityHashCode(this); + final int hmm = this.finalOutput == null ? 0 : this.finalOutput.hashCode(); + + return Long.toString(now, Character.MAX_RADIX) + '-' + Integer.toString(hash, Character.MAX_RADIX) + '-' + + Integer.toString(hmm, Character.MAX_RADIX); + } + + private CompoundNBT generateLinkData(final String craftingID, final boolean standalone, final boolean req) { + final CompoundNBT tag = new CompoundNBT(); + + tag.putString("CraftID", craftingID); + tag.putBoolean("canceled", false); + tag.putBoolean("done", false); + tag.putBoolean("standalone", standalone); + tag.putBoolean("req", req); + + return tag; + } + + private void submitLink(final ICraftingLink myLastLink2) { + if (this.getGrid() != null) { + final CraftingGridCache cc = this.getGrid().getCache(ICraftingGrid.class); + cc.addLink((CraftingLink) myLastLink2); + } + } + + public void getListOfItem(final IItemList list, final CraftingItemList whichList) { + switch (whichList) { + case ACTIVE: + for (final IAEItemStack ais : this.waitingFor) { + list.add(ais); + } + break; + case PENDING: + for (final Entry t : this.tasks.entrySet()) { + for (IAEItemStack ais : t.getKey().getCondensedOutputs()) { + ais = ais.copy(); + ais.setStackSize(ais.getStackSize() * t.getValue().value); + list.add(ais); + } + } + break; + case STORAGE: + this.inventory.getAvailableItems(list); + break; + default: + case ALL: + this.inventory.getAvailableItems(list); + + for (final IAEItemStack ais : this.waitingFor) { + list.add(ais); + } + + for (final Entry t : this.tasks.entrySet()) { + for (IAEItemStack ais : t.getKey().getCondensedOutputs()) { + ais = ais.copy(); + ais.setStackSize(ais.getStackSize() * t.getValue().value); + list.add(ais); + } + } + break; + } + } + + public void addStorage(final IAEItemStack extractItems) { + this.inventory.injectItems(extractItems, Actionable.MODULATE, null); + } + + public void addEmitable(final IAEItemStack i) { + this.waitingFor.add(i); + this.postCraftingStatusChange(i); + } + + public void addCrafting(final ICraftingPatternDetails details, final long crafts) { + TaskProgress i = this.tasks.get(details); + + if (i == null) { + this.tasks.put(details, i = new TaskProgress()); + } + + i.value += crafts; + } + + public IAEItemStack getItemStack(final IAEItemStack what, final CraftingItemList storage2) { + IAEItemStack is; + + switch (storage2) { + case STORAGE: + is = this.inventory.getItemList().findPrecise(what); + break; + case ACTIVE: + is = this.waitingFor.findPrecise(what); + break; + case PENDING: + + is = what.copy(); + is.setStackSize(0); + + for (final Entry t : this.tasks.entrySet()) { + for (final IAEItemStack ais : t.getKey().getCondensedOutputs()) { + if (ais.equals(is)) { + is.setStackSize(is.getStackSize() + ais.getStackSize() * t.getValue().value); + } + } + } + + break; + default: + case ALL: + throw new IllegalStateException("Invalid Operation"); + } + + if (is != null) { + return is.copy(); + } + + is = what.copy(); + is.setStackSize(0); + return is; + } + + public void writeToNBT(final CompoundNBT data) { + data.put("finalOutput", this.writeItem(this.finalOutput)); + data.put("inventory", this.writeList(this.inventory.getItemList())); + data.putBoolean("waiting", this.waiting); + data.putBoolean("isComplete", this.isComplete); + + if (this.myLastLink != null) { + final CompoundNBT link = new CompoundNBT(); + this.myLastLink.writeToNBT(link); + data.put("link", link); + } + + final ListNBT list = new ListNBT(); + for (final Entry e : this.tasks.entrySet()) { + final CompoundNBT item = this.writeItem(AEItemStack.fromItemStack(e.getKey().getPattern())); + item.putLong("craftingProgress", e.getValue().value); + list.add(item); + } + data.put("tasks", list); + + data.put("waitingFor", this.writeList(this.waitingFor)); + + data.putLong("elapsedTime", this.getElapsedTime()); + data.putLong("startItemCount", this.getStartItemCount()); + data.putLong("remainingItemCount", this.getRemainingItemCount()); + } + + private CompoundNBT writeItem(final IAEItemStack finalOutput2) { + final CompoundNBT out = new CompoundNBT(); + + if (finalOutput2 != null) { + finalOutput2.writeToNBT(out); + } + + return out; + } + + private ListNBT writeList(final IItemList myList) { + final ListNBT out = new ListNBT(); + + for (final IAEItemStack ais : myList) { + out.add(this.writeItem(ais)); + } + + return out; + } + + void done() { + final TileCraftingTile core = this.getCore(); + + core.setCoreBlock(true); + + if (core.getPreviousState() != null) { + this.readFromNBT(core.getPreviousState()); + core.setPreviousState(null); + } + + this.updateCPU(); + this.updateName(); + } + + public void readFromNBT(final CompoundNBT data) { + this.finalOutput = AEItemStack.fromNBT(data.getCompound("finalOutput")); + for (final IAEItemStack ais : this.readList(data.getList("inventory", 10))) { + this.inventory.injectItems(ais, Actionable.MODULATE, this.machineSrc); + } + + this.waiting = data.getBoolean("waiting"); + this.isComplete = data.getBoolean("isComplete"); + + if (data.contains("link")) { + final CompoundNBT link = data.getCompound("link"); + this.myLastLink = new CraftingLink(link, this); + this.submitLink(this.myLastLink); + } + + final ListNBT list = data.getList("tasks", 10); + for (int x = 0; x < list.size(); x++) { + final CompoundNBT item = list.getCompound(x); + final IAEItemStack pattern = AEItemStack.fromNBT(item); + if (pattern != null && pattern.getItem() instanceof ICraftingPatternItem) { + final ICraftingPatternItem cpi = (ICraftingPatternItem) pattern.getItem(); + final ICraftingPatternDetails details = cpi.getPatternForItem(pattern.createItemStack(), + this.getWorld()); + if (details != null) { + final TaskProgress tp = new TaskProgress(); + tp.value = item.getLong("craftingProgress"); + this.tasks.put(details, tp); + } + } + } + + this.waitingFor = this.readList(data.getList("waitingFor", 10)); + for (final IAEItemStack is : this.waitingFor) { + this.postCraftingStatusChange(is.copy()); + } + + this.lastTime = System.nanoTime(); + this.elapsedTime = data.getLong("elapsedTime"); + this.startItemCount = data.getLong("startItemCount"); + this.remainingItemCount = data.getLong("remainingItemCount"); + } + + public void updateName() { + this.myName = null; + for (final TileCraftingTile te : this.tiles) { + + if (te.hasCustomInventoryName()) { + if (this.myName != null) { + this.myName.appendText(" ").appendSibling(te.getCustomInventoryName()); + } else { + this.myName = te.getCustomInventoryName().deepCopy(); + } + } + } + } + + private IItemList readList(final ListNBT tag) { + final IItemList out = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + + if (tag == null) { + return out; + } + + for (int x = 0; x < tag.size(); x++) { + final IAEItemStack ais = AEItemStack.fromNBT(tag.getCompound(x)); + if (ais != null) { + out.add(ais); + } + } + + return out; + } + + private World getWorld() { + return this.getCore().getWorld(); + } + + public IAEItemStack making(final IAEItemStack what) { + return this.waitingFor.findPrecise(what); + } + + public void breakCluster() { + final TileCraftingTile t = this.getCore(); + + if (t != null) { + t.breakCluster(); + } + } + + private void prepareElapsedTime() { + this.lastTime = System.nanoTime(); + this.elapsedTime = 0; + + final IItemList list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + + this.getListOfItem(list, CraftingItemList.ACTIVE); + this.getListOfItem(list, CraftingItemList.PENDING); + + int itemCount = 0; + for (final IAEItemStack ge : list) { + itemCount += ge.getStackSize(); + } + + this.startItemCount = itemCount; + this.remainingItemCount = itemCount; + } + + private void updateElapsedTime(final IAEItemStack is) { + final long nextStartTime = System.nanoTime(); + this.elapsedTime = this.getElapsedTime() + nextStartTime - this.lastTime; + this.lastTime = nextStartTime; + this.remainingItemCount = this.getRemainingItemCount() - is.getStackSize(); + } + + public long getElapsedTime() { + return this.elapsedTime; + } + + public long getRemainingItemCount() { + return this.remainingItemCount; + } + + public long getStartItemCount() { + return this.startItemCount; + } + + private static class TaskProgress { + private long value; + } } diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java index e40e13b1e..441596f83 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; @@ -33,137 +32,110 @@ import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.MBCalculator; import appeng.tile.qnb.TileQuantumBridge; +public class QuantumCalculator extends MBCalculator { -public class QuantumCalculator extends MBCalculator -{ + private final TileQuantumBridge tqb; - private final TileQuantumBridge tqb; + public QuantumCalculator(final IAEMultiBlock t) { + super(t); + this.tqb = (TileQuantumBridge) t; + } - public QuantumCalculator( final IAEMultiBlock t ) - { - super( t ); - this.tqb = (TileQuantumBridge) t; - } + @Override + public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) { - @Override - public boolean checkMultiblockScale( final WorldCoord min, final WorldCoord max ) - { + if ((max.x - min.x + 1) * (max.y - min.y + 1) * (max.z - min.z + 1) == 9) { + final int ones = ((max.x - min.x) == 0 ? 1 : 0) + ((max.y - min.y) == 0 ? 1 : 0) + + ((max.z - min.z) == 0 ? 1 : 0); - if( ( max.x - min.x + 1 ) * ( max.y - min.y + 1 ) * ( max.z - min.z + 1 ) == 9 ) - { - final int ones = ( ( max.x - min.x ) == 0 ? 1 : 0 ) + ( ( max.y - min.y ) == 0 ? 1 : 0 ) + ( ( max.z - min.z ) == 0 ? 1 : 0 ); + final int threes = ((max.x - min.x) == 2 ? 1 : 0) + ((max.y - min.y) == 2 ? 1 : 0) + + ((max.z - min.z) == 2 ? 1 : 0); - final int threes = ( ( max.x - min.x ) == 2 ? 1 : 0 ) + ( ( max.y - min.y ) == 2 ? 1 : 0 ) + ( ( max.z - min.z ) == 2 ? 1 : 0 ); + return ones == 1 && threes == 2; + } + return false; + } - return ones == 1 && threes == 2; - } - return false; - } + @Override + public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) { + return new QuantumCluster(min, max); + } - @Override - public IAECluster createCluster( final World w, final WorldCoord min, final WorldCoord max ) - { - return new QuantumCluster( min, max ); - } + @Override + public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) { - @Override - public boolean verifyInternalStructure( final World w, final WorldCoord min, final WorldCoord max ) - { + byte num = 0; - byte num = 0; + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final BlockPos p = new BlockPos(x, y, z); + final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(p); - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final BlockPos p = new BlockPos( x, y, z ); - final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( p ); + if (!te.isValid()) { + return false; + } - if( !te.isValid() ) - { - return false; - } + num++; + final IBlocks blocks = AEApi.instance().definitions().blocks(); + if (num == 5) { + if (!this.isBlockAtLocation(w, p, blocks.quantumLink())) { + return false; + } + } else { + if (!this.isBlockAtLocation(w, p, blocks.quantumRing())) { + return false; + } + } + } + } + } + return true; + } - num++; - final IBlocks blocks = AEApi.instance().definitions().blocks(); - if( num == 5 ) - { - if( !this.isBlockAtLocation( w, p, blocks.quantumLink() ) ) - { - return false; - } - } - else - { - if( !this.isBlockAtLocation( w, p, blocks.quantumRing() ) ) - { - return false; - } - } - } - } - } - return true; - } + @Override + public void disconnect() { + this.tqb.disconnect(true); + } - @Override - public void disconnect() - { - this.tqb.disconnect( true ); - } + @Override + public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) { + byte num = 0; + byte ringNum = 0; + final QuantumCluster c = (QuantumCluster) cl; - @Override - public void updateTiles( final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max ) - { - byte num = 0; - byte ringNum = 0; - final QuantumCluster c = (QuantumCluster) cl; + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final TileQuantumBridge te = (TileQuantumBridge) w.getTileEntity(new BlockPos(x, y, z)); - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final TileQuantumBridge te = (TileQuantumBridge) w.getTileEntity( new BlockPos( x, y, z ) ); + num++; + final byte flags; + if (num == 5) { + flags = num; + c.setCenter(te); + } else { + if (num == 1 || num == 3 || num == 7 || num == 9) { + flags = (byte) (this.tqb.getCorner() | num); + } else { + flags = num; + } + c.getRing()[ringNum] = te; + ringNum++; + } - num++; - final byte flags; - if( num == 5 ) - { - flags = num; - c.setCenter( te ); - } - else - { - if( num == 1 || num == 3 || num == 7 || num == 9 ) - { - flags = (byte) ( this.tqb.getCorner() | num ); - } - else - { - flags = num; - } - c.getRing()[ringNum] = te; - ringNum++; - } + te.updateStatus(c, flags, true); + } + } + } + } - te.updateStatus( c, flags, true ); - } - } - } - } + @Override + public boolean isValidTile(final TileEntity te) { + return te instanceof TileQuantumBridge; + } - @Override - public boolean isValidTile( final TileEntity te ) - { - return te instanceof TileQuantumBridge; - } - - private boolean isBlockAtLocation( final IBlockReader w, final BlockPos pos, final IBlockDefinition def ) - { - return def.maybeBlock().map( block -> block == w.getBlockState( pos ).getBlock() ).orElse( false ); - } + private boolean isBlockAtLocation(final IBlockReader w, final BlockPos pos, final IBlockDefinition def) { + return def.maybeBlock().map(block -> block == w.getBlockState(pos).getBlock()).orElse(false); + } } diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java index 0ba6b1c8d..bf7f8f80f 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import java.util.Iterator; import net.minecraft.tileentity.TileEntity; @@ -44,267 +43,218 @@ import appeng.me.cluster.IAECluster; import appeng.tile.qnb.TileQuantumBridge; import appeng.util.iterators.ChainedIterator; +public class QuantumCluster implements ILocatable, IAECluster { -public class QuantumCluster implements ILocatable, IAECluster -{ + private final WorldCoord min; + private final WorldCoord max; + private boolean isDestroyed = false; + private boolean updateStatus = true; + private TileQuantumBridge[] Ring; + private boolean registered = false; + private ConnectionWrapper connection; + private long thisSide; + private long otherSide; + private TileQuantumBridge center; - private final WorldCoord min; - private final WorldCoord max; - private boolean isDestroyed = false; - private boolean updateStatus = true; - private TileQuantumBridge[] Ring; - private boolean registered = false; - private ConnectionWrapper connection; - private long thisSide; - private long otherSide; - private TileQuantumBridge center; + public QuantumCluster(final WorldCoord min, final WorldCoord max) { + this.min = min; + this.max = max; + this.setRing(new TileQuantumBridge[8]); + } - public QuantumCluster( final WorldCoord min, final WorldCoord max ) - { - this.min = min; - this.max = max; - this.setRing( new TileQuantumBridge[8] ); - } + @SubscribeEvent + public void onUnload(final WorldEvent.Unload e) { + if (this.center.getWorld() == e.getWorld()) { + this.setUpdateStatus(false); + this.destroy(); + } + } - @SubscribeEvent - public void onUnload( final WorldEvent.Unload e ) - { - if( this.center.getWorld() == e.getWorld() ) - { - this.setUpdateStatus( false ); - this.destroy(); - } - } + @Override + public void updateStatus(final boolean updateGrid) { - @Override - public void updateStatus( final boolean updateGrid ) - { + final long qe = this.center.getQEFrequency(); - final long qe = this.center.getQEFrequency(); + if (this.thisSide != qe && this.thisSide != -qe) { + if (qe != 0) { + if (this.thisSide != 0) { + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER)); + } - if( this.thisSide != qe && this.thisSide != -qe ) - { - if( qe != 0 ) - { - if( this.thisSide != 0 ) - { - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) ); - } + if (this.canUseNode(-qe)) { + this.otherSide = qe; + this.thisSide = -qe; + } else if (this.canUseNode(qe)) { + this.thisSide = qe; + this.otherSide = -qe; + } - if( this.canUseNode( -qe ) ) - { - this.otherSide = qe; - this.thisSide = -qe; - } - else if( this.canUseNode( qe ) ) - { - this.thisSide = qe; - this.otherSide = -qe; - } + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.REGISTER)); + } else { + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER)); - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.REGISTER ) ); - } - else - { - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) ); + this.otherSide = 0; + this.thisSide = 0; + } + } - this.otherSide = 0; - this.thisSide = 0; - } - } + final ILocatable myOtherSide = this.otherSide == 0 ? null + : AEApi.instance().registries().locatable().getLocatableBy(this.otherSide); - final ILocatable myOtherSide = this.otherSide == 0 ? null : AEApi.instance().registries().locatable().getLocatableBy( this.otherSide ); + boolean shutdown = false; - boolean shutdown = false; + if (myOtherSide instanceof QuantumCluster) { + final QuantumCluster sideA = this; + final QuantumCluster sideB = (QuantumCluster) myOtherSide; - if( myOtherSide instanceof QuantumCluster ) - { - final QuantumCluster sideA = this; - final QuantumCluster sideB = (QuantumCluster) myOtherSide; + if (sideA.isActive() && sideB.isActive()) { + if (this.connection != null && this.connection.getConnection() != null) { + final IGridNode a = this.connection.getConnection().a(); + final IGridNode b = this.connection.getConnection().b(); + final IGridNode sa = sideA.getNode(); + final IGridNode sb = sideB.getNode(); + if ((a == sa || b == sa) && (a == sb || b == sb)) { + return; + } + } - if( sideA.isActive() && sideB.isActive() ) - { - if( this.connection != null && this.connection.getConnection() != null ) - { - final IGridNode a = this.connection.getConnection().a(); - final IGridNode b = this.connection.getConnection().b(); - final IGridNode sa = sideA.getNode(); - final IGridNode sb = sideB.getNode(); - if( ( a == sa || b == sa ) && ( a == sb || b == sb ) ) - { - return; - } - } + try { + if (sideA.connection != null) { + if (sideA.connection.getConnection() != null) { + sideA.connection.getConnection().destroy(); + sideA.connection = new ConnectionWrapper(null); + } + } - try - { - if( sideA.connection != null ) - { - if( sideA.connection.getConnection() != null ) - { - sideA.connection.getConnection().destroy(); - sideA.connection = new ConnectionWrapper( null ); - } - } + if (sideB.connection != null) { + if (sideB.connection.getConnection() != null) { + sideB.connection.getConnection().destroy(); + sideB.connection = new ConnectionWrapper(null); + } + } - if( sideB.connection != null ) - { - if( sideB.connection.getConnection() != null ) - { - sideB.connection.getConnection().destroy(); - sideB.connection = new ConnectionWrapper( null ); - } - } + sideA.connection = sideB.connection = new ConnectionWrapper( + AEApi.instance().grid().createGridConnection(sideA.getNode(), sideB.getNode())); + } catch (final FailedConnectionException e) { + // :( + AELog.debug(e); + } + } else { + shutdown = true; + } + } else { + shutdown = true; + } - sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().grid().createGridConnection( sideA.getNode(), sideB.getNode() ) ); - } - catch( final FailedConnectionException e ) - { - // :( - AELog.debug( e ); - } - } - else - { - shutdown = true; - } - } - else - { - shutdown = true; - } + if (shutdown && this.connection != null) { + if (this.connection.getConnection() != null) { + this.connection.getConnection().destroy(); + this.connection.setConnection(null); + this.connection = new ConnectionWrapper(null); + } + } + } - if( shutdown && this.connection != null ) - { - if( this.connection.getConnection() != null ) - { - this.connection.getConnection().destroy(); - this.connection.setConnection( null ); - this.connection = new ConnectionWrapper( null ); - } - } - } + private boolean canUseNode(final long qe) { + final QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().getLocatableBy(qe); + if (qc != null) { + final World theWorld = qc.center.getWorld(); + if (!qc.isDestroyed) { + ChunkPos cPos = new ChunkPos(qc.center.getPos()); + if (theWorld.getChunkProvider().isChunkLoaded(cPos)) { + final DimensionType id = theWorld.dimension.getType(); + final World cur = theWorld.getServer().getWorld(id); - private boolean canUseNode( final long qe ) - { - final QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locatable().getLocatableBy( qe ); - if( qc != null ) - { - final World theWorld = qc.center.getWorld(); - if( !qc.isDestroyed ) - { - ChunkPos cPos = new ChunkPos( qc.center.getPos() ); - if( theWorld.getChunkProvider().isChunkLoaded( cPos ) ) - { - final DimensionType id = theWorld.dimension.getType(); - final World cur = theWorld.getServer().getWorld( id ); + final TileEntity te = theWorld.getTileEntity(qc.center.getPos()); + return te != qc.center || theWorld != cur; + } + } + } + return true; + } - final TileEntity te = theWorld.getTileEntity( qc.center.getPos() ); - return te != qc.center || theWorld != cur; - } - } - } - return true; - } + private boolean isActive() { + if (this.isDestroyed || !this.registered) { + return false; + } - private boolean isActive() - { - if( this.isDestroyed || !this.registered ) - { - return false; - } + return this.center.isPowered() && this.hasQES(); + } - return this.center.isPowered() && this.hasQES(); - } + private IGridNode getNode() { + return this.center.getGridNode(AEPartLocation.INTERNAL); + } - private IGridNode getNode() - { - return this.center.getGridNode( AEPartLocation.INTERNAL ); - } + private boolean hasQES() { + return this.thisSide != 0; + } - private boolean hasQES() - { - return this.thisSide != 0; - } + @Override + public void destroy() { + if (this.isDestroyed) { + return; + } + this.isDestroyed = true; - @Override - public void destroy() - { - if( this.isDestroyed ) - { - return; - } - this.isDestroyed = true; + if (this.registered) { + MinecraftForge.EVENT_BUS.unregister(this); + this.registered = false; + } - if( this.registered ) - { - MinecraftForge.EVENT_BUS.unregister( this ); - this.registered = false; - } + if (this.thisSide != 0) { + this.updateStatus(true); + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER)); + } - if( this.thisSide != 0 ) - { - this.updateStatus( true ); - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) ); - } + this.center.updateStatus(null, (byte) -1, this.isUpdateStatus()); - this.center.updateStatus( null, (byte) -1, this.isUpdateStatus() ); + for (final TileQuantumBridge r : this.getRing()) { + r.updateStatus(null, (byte) -1, this.isUpdateStatus()); + } - for( final TileQuantumBridge r : this.getRing() ) - { - r.updateStatus( null, (byte) -1, this.isUpdateStatus() ); - } + this.center = null; + this.setRing(new TileQuantumBridge[8]); + } - this.center = null; - this.setRing( new TileQuantumBridge[8] ); - } + @Override + public Iterator getTiles() { + return new ChainedIterator<>(this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3], + this.getRing()[4], this.getRing()[5], this.getRing()[6], this.getRing()[7], this.center); + } - @Override - public Iterator getTiles() - { - return new ChainedIterator<>( this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3], this.getRing()[4], this.getRing()[5], this.getRing()[6], this.getRing()[7], this.center ); - } + public boolean isCorner(final TileQuantumBridge tileQuantumBridge) { + return this.getRing()[0] == tileQuantumBridge || this.getRing()[2] == tileQuantumBridge + || this.getRing()[4] == tileQuantumBridge || this.getRing()[6] == tileQuantumBridge; + } - public boolean isCorner( final TileQuantumBridge tileQuantumBridge ) - { - return this.getRing()[0] == tileQuantumBridge || this.getRing()[2] == tileQuantumBridge || this.getRing()[4] == tileQuantumBridge || this.getRing()[6] == tileQuantumBridge; - } + @Override + public long getLocatableSerial() { + return this.thisSide; + } - @Override - public long getLocatableSerial() - { - return this.thisSide; - } + public TileQuantumBridge getCenter() { + return this.center; + } - public TileQuantumBridge getCenter() - { - return this.center; - } + void setCenter(final TileQuantumBridge c) { + this.registered = true; + MinecraftForge.EVENT_BUS.register(this); + this.center = c; + } - void setCenter( final TileQuantumBridge c ) - { - this.registered = true; - MinecraftForge.EVENT_BUS.register( this ); - this.center = c; - } + private boolean isUpdateStatus() { + return this.updateStatus; + } - private boolean isUpdateStatus() - { - return this.updateStatus; - } + public void setUpdateStatus(final boolean updateStatus) { + this.updateStatus = updateStatus; + } - public void setUpdateStatus( final boolean updateStatus ) - { - this.updateStatus = updateStatus; - } + TileQuantumBridge[] getRing() { + return this.Ring; + } - TileQuantumBridge[] getRing() - { - return this.Ring; - } - - private void setRing( final TileQuantumBridge[] ring ) - { - this.Ring = ring; - } + private void setRing(final TileQuantumBridge[] ring) { + this.Ring = ring; + } } diff --git a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java index 57960c28e..f6b818f51 100644 --- a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -30,81 +29,68 @@ import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.MBCalculator; import appeng.tile.spatial.TileSpatialPylon; +public class SpatialPylonCalculator extends MBCalculator { -public class SpatialPylonCalculator extends MBCalculator -{ + private final TileSpatialPylon tqb; - private final TileSpatialPylon tqb; + public SpatialPylonCalculator(final IAEMultiBlock t) { + super(t); + this.tqb = (TileSpatialPylon) t; + } - public SpatialPylonCalculator( final IAEMultiBlock t ) - { - super( t ); - this.tqb = (TileSpatialPylon) t; - } + @Override + public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) { + return (min.x == max.x && min.y == max.y && min.z != max.z) + || (min.x == max.x && min.y != max.y && min.z == max.z) + || (min.x != max.x && min.y == max.y && min.z == max.z); + } - @Override - public boolean checkMultiblockScale( final WorldCoord min, final WorldCoord max ) - { - return ( min.x == max.x && min.y == max.y && min.z != max.z ) || ( min.x == max.x && min.y != max.y && min.z == max.z ) || ( min.x != max.x && min.y == max.y && min.z == max.z ); - } + @Override + public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) { + return new SpatialPylonCluster(new DimensionalCoord(w, min.x, min.y, min.z), + new DimensionalCoord(w, max.x, max.y, max.z)); + } - @Override - public IAECluster createCluster( final World w, final WorldCoord min, final WorldCoord max ) - { - return new SpatialPylonCluster( new DimensionalCoord( w, min.x, min.y, min.z ), new DimensionalCoord( w, max.x, max.y, max.z ) ); - } + @Override + public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) { - @Override - public boolean verifyInternalStructure( final World w, final WorldCoord min, final WorldCoord max ) - { + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(new BlockPos(x, y, z)); - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( new BlockPos( x, y, z ) ); + if (!te.isValid()) { + return false; + } + } + } + } - if( !te.isValid() ) - { - return false; - } - } - } - } + return true; + } - return true; - } + @Override + public void disconnect() { + this.tqb.disconnect(true); + } - @Override - public void disconnect() - { - this.tqb.disconnect( true ); - } + @Override + public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) { + final SpatialPylonCluster c = (SpatialPylonCluster) cl; - @Override - public void updateTiles( final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max ) - { - final SpatialPylonCluster c = (SpatialPylonCluster) cl; + for (int x = min.x; x <= max.x; x++) { + for (int y = min.y; y <= max.y; y++) { + for (int z = min.z; z <= max.z; z++) { + final TileSpatialPylon te = (TileSpatialPylon) w.getTileEntity(new BlockPos(x, y, z)); + te.updateStatus(c); + c.getLine().add((te)); + } + } + } + } - for( int x = min.x; x <= max.x; x++ ) - { - for( int y = min.y; y <= max.y; y++ ) - { - for( int z = min.z; z <= max.z; z++ ) - { - final TileSpatialPylon te = (TileSpatialPylon) w.getTileEntity( new BlockPos( x, y, z ) ); - te.updateStatus( c ); - c.getLine().add( ( te ) ); - } - } - } - } - - @Override - public boolean isValidTile( final TileEntity te ) - { - return te instanceof TileSpatialPylon; - } + @Override + public boolean isValidTile(final TileEntity te) { + return te instanceof TileSpatialPylon; + } } diff --git a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java index c01ba90d3..ae110f800 100644 --- a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java @@ -18,7 +18,6 @@ package appeng.me.cluster.implementations; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -28,114 +27,89 @@ import appeng.api.util.DimensionalCoord; import appeng.me.cluster.IAECluster; import appeng.tile.spatial.TileSpatialPylon; +public class SpatialPylonCluster implements IAECluster { -public class SpatialPylonCluster implements IAECluster -{ + private final DimensionalCoord min; + private final DimensionalCoord max; + private final List line = new ArrayList<>(); + private boolean isDestroyed = false; - private final DimensionalCoord min; - private final DimensionalCoord max; - private final List line = new ArrayList<>(); - private boolean isDestroyed = false; + private Axis currentAxis = Axis.UNFORMED; + private boolean isValid; - private Axis currentAxis = Axis.UNFORMED; - private boolean isValid; + public SpatialPylonCluster(final DimensionalCoord min, final DimensionalCoord max) { + this.min = min.copy(); + this.max = max.copy(); - public SpatialPylonCluster( final DimensionalCoord min, final DimensionalCoord max ) - { - this.min = min.copy(); - this.max = max.copy(); + if (this.getMin().x != this.getMax().x) { + this.setCurrentAxis(Axis.X); + } else if (this.getMin().y != this.getMax().y) { + this.setCurrentAxis(Axis.Y); + } else if (this.getMin().z != this.getMax().z) { + this.setCurrentAxis(Axis.Z); + } else { + this.setCurrentAxis(Axis.UNFORMED); + } + } - if( this.getMin().x != this.getMax().x ) - { - this.setCurrentAxis( Axis.X ); - } - else if( this.getMin().y != this.getMax().y ) - { - this.setCurrentAxis( Axis.Y ); - } - else if( this.getMin().z != this.getMax().z ) - { - this.setCurrentAxis( Axis.Z ); - } - else - { - this.setCurrentAxis( Axis.UNFORMED ); - } - } + @Override + public void updateStatus(final boolean updateGrid) { + for (final TileSpatialPylon r : this.getLine()) { + r.recalculateDisplay(); + } + } - @Override - public void updateStatus( final boolean updateGrid ) - { - for( final TileSpatialPylon r : this.getLine() ) - { - r.recalculateDisplay(); - } - } + @Override + public void destroy() { - @Override - public void destroy() - { + if (this.isDestroyed) { + return; + } + this.isDestroyed = true; - if( this.isDestroyed ) - { - return; - } - this.isDestroyed = true; + for (final TileSpatialPylon r : this.getLine()) { + r.updateStatus(null); + } + } - for( final TileSpatialPylon r : this.getLine() ) - { - r.updateStatus( null ); - } - } + @Override + public Iterator getTiles() { + return (Iterator) this.getLine().iterator(); + } - @Override - public Iterator getTiles() - { - return (Iterator) this.getLine().iterator(); - } + public int tileCount() { + return this.getLine().size(); + } - public int tileCount() - { - return this.getLine().size(); - } + public Axis getCurrentAxis() { + return this.currentAxis; + } - public Axis getCurrentAxis() - { - return this.currentAxis; - } + private void setCurrentAxis(final Axis currentAxis) { + this.currentAxis = currentAxis; + } - private void setCurrentAxis( final Axis currentAxis ) - { - this.currentAxis = currentAxis; - } + public boolean isValid() { + return this.isValid; + } - public boolean isValid() - { - return this.isValid; - } + public void setValid(final boolean isValid) { + this.isValid = isValid; + } - public void setValid( final boolean isValid ) - { - this.isValid = isValid; - } + public DimensionalCoord getMax() { + return this.max; + } - public DimensionalCoord getMax() - { - return this.max; - } + public DimensionalCoord getMin() { + return this.min; + } - public DimensionalCoord getMin() - { - return this.min; - } + List getLine() { + return this.line; + } - List getLine() - { - return this.line; - } - - public enum Axis - { - X, Y, Z, UNFORMED - } + public enum Axis { + X, Y, Z, UNFORMED + } } diff --git a/src/main/java/appeng/me/energy/EnergyThreshold.java b/src/main/java/appeng/me/energy/EnergyThreshold.java index cc97bacb7..071250528 100644 --- a/src/main/java/appeng/me/energy/EnergyThreshold.java +++ b/src/main/java/appeng/me/energy/EnergyThreshold.java @@ -18,100 +18,82 @@ package appeng.me.energy; - import appeng.api.networking.energy.IEnergyWatcher; +public class EnergyThreshold implements Comparable { -public class EnergyThreshold implements Comparable -{ + private final double threshold; + private final IEnergyWatcher watcher; + private final int watcherHash; - private final double threshold; - private final IEnergyWatcher watcher; - private final int watcherHash; + public EnergyThreshold(final double lim, final IEnergyWatcher watcher) { + this.threshold = lim; + this.watcher = watcher; + this.watcherHash = watcher.hashCode(); + } - public EnergyThreshold( final double lim, final IEnergyWatcher watcher ) - { - this.threshold = lim; - this.watcher = watcher; - this.watcherHash = watcher.hashCode(); - } + /** + * Special constructor to allow querying a for a subset of thresholds. + * + * @param lim + * @param bound + */ + public EnergyThreshold(final double lim, final int bound) { + this.threshold = lim; + this.watcher = null; + this.watcherHash = bound; + } - /** - * Special constructor to allow querying a for a subset of thresholds. - * - * @param lim - * @param bound - */ - public EnergyThreshold( final double lim, final int bound ) - { - this.threshold = lim; - this.watcher = null; - this.watcherHash = bound; - } + public IEnergyWatcher getEnergyWatcher() { + return this.watcher; + } - public IEnergyWatcher getEnergyWatcher() - { - return this.watcher; - } + @Override + public int compareTo(EnergyThreshold o) { + int a = Double.compare(this.threshold, o.threshold); - @Override - public int compareTo( EnergyThreshold o ) - { - int a = Double.compare( this.threshold, o.threshold ); + if (a == 0) { + return Integer.compare(this.watcherHash, o.watcherHash); + } - if( a == 0 ) - { - return Integer.compare( this.watcherHash, o.watcherHash ); - } + return a; + } - return a; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(this.threshold); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + ((this.watcher == null) ? 0 : this.watcher.hashCode()); + return result; + } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits( this.threshold ); - result = prime * result + (int) ( temp ^ ( temp >>> 32 ) ); - result = prime * result + ( ( this.watcher == null ) ? 0 : this.watcher.hashCode() ); - return result; - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (this.getClass() != obj.getClass()) { + return false; + } - @Override - public boolean equals( Object obj ) - { - if( this == obj ) - { - return true; - } - if( obj == null ) - { - return false; - } - if( this.getClass() != obj.getClass() ) - { - return false; - } + EnergyThreshold other = (EnergyThreshold) obj; + if (Double.doubleToLongBits(this.threshold) != Double.doubleToLongBits(other.threshold)) { + return false; + } - EnergyThreshold other = (EnergyThreshold) obj; - if( Double.doubleToLongBits( this.threshold ) != Double.doubleToLongBits( other.threshold ) ) - { - return false; - } - - if( this.watcher == null ) - { - if( other.watcher != null ) - { - return false; - } - } - else if( !this.watcher.equals( other.watcher ) ) - { - return false; - } - return true; - } + if (this.watcher == null) { + if (other.watcher != null) { + return false; + } + } else if (!this.watcher.equals(other.watcher)) { + return false; + } + return true; + } } diff --git a/src/main/java/appeng/me/energy/EnergyWatcher.java b/src/main/java/appeng/me/energy/EnergyWatcher.java index 45be0a95b..bc14b6076 100644 --- a/src/main/java/appeng/me/energy/EnergyWatcher.java +++ b/src/main/java/appeng/me/energy/EnergyWatcher.java @@ -18,7 +18,6 @@ package appeng.me.energy; - import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -27,65 +26,57 @@ import appeng.api.networking.energy.IEnergyWatcher; import appeng.api.networking.energy.IEnergyWatcherHost; import appeng.me.cache.EnergyGridCache; - /** - * Maintain my interests, and a global watch list, they should always be fully synchronized. + * Maintain my interests, and a global watch list, they should always be fully + * synchronized. */ -public class EnergyWatcher implements IEnergyWatcher -{ +public class EnergyWatcher implements IEnergyWatcher { - private final EnergyGridCache gsc; - private final IEnergyWatcherHost watcherHost; - private final Set myInterests = new HashSet<>(); + private final EnergyGridCache gsc; + private final IEnergyWatcherHost watcherHost; + private final Set myInterests = new HashSet<>(); - public EnergyWatcher( final EnergyGridCache cache, final IEnergyWatcherHost host ) - { - this.gsc = cache; - this.watcherHost = host; - } + public EnergyWatcher(final EnergyGridCache cache, final IEnergyWatcherHost host) { + this.gsc = cache; + this.watcherHost = host; + } - public void post( final EnergyGridCache energyGridCache ) - { - this.watcherHost.onThresholdPass( energyGridCache ); - } + public void post(final EnergyGridCache energyGridCache) { + this.watcherHost.onThresholdPass(energyGridCache); + } - public IEnergyWatcherHost getHost() - { - return this.watcherHost; - } + public IEnergyWatcherHost getHost() { + return this.watcherHost; + } - @Override - public boolean add( final double amount ) - { - final EnergyThreshold eh = new EnergyThreshold( amount, this ); + @Override + public boolean add(final double amount) { + final EnergyThreshold eh = new EnergyThreshold(amount, this); - if( this.myInterests.contains( eh ) ) + if (this.myInterests.contains(eh)) - { - return false; - } + { + return false; + } - return this.gsc.registerEnergyInterest( eh ) && this.myInterests.add( eh ); - } + return this.gsc.registerEnergyInterest(eh) && this.myInterests.add(eh); + } - @Override - public boolean remove( final double amount ) - { - final EnergyThreshold eh = new EnergyThreshold( amount, this ); + @Override + public boolean remove(final double amount) { + final EnergyThreshold eh = new EnergyThreshold(amount, this); - return this.myInterests.remove( eh ) && this.gsc.unregisterEnergyInterest( eh ); - } + return this.myInterests.remove(eh) && this.gsc.unregisterEnergyInterest(eh); + } - @Override - public void reset() - { - for( Iterator iterator = this.myInterests.iterator(); iterator.hasNext(); ) - { - final EnergyThreshold threshold = iterator.next(); + @Override + public void reset() { + for (Iterator iterator = this.myInterests.iterator(); iterator.hasNext();) { + final EnergyThreshold threshold = iterator.next(); - this.gsc.unregisterEnergyInterest( threshold ); - iterator.remove(); - } - } + this.gsc.unregisterEnergyInterest(threshold); + iterator.remove(); + } + } } diff --git a/src/main/java/appeng/me/helpers/AENetworkProxy.java b/src/main/java/appeng/me/helpers/AENetworkProxy.java index 929e59702..8cbdde645 100644 --- a/src/main/java/appeng/me/helpers/AENetworkProxy.java +++ b/src/main/java/appeng/me/helpers/AENetworkProxy.java @@ -18,14 +18,9 @@ package appeng.me.helpers; - import java.util.Collections; import java.util.EnumSet; -import appeng.core.worlddata.WorldData; -import appeng.hooks.TickHandler; -import appeng.me.cache.P2PCache; -import appeng.parts.networking.PartCable; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; @@ -50,402 +45,333 @@ import appeng.api.networking.ticking.ITickManager; import appeng.api.util.AEColor; import appeng.api.util.DimensionalCoord; import appeng.api.util.IOrientable; +import appeng.core.worlddata.WorldData; +import appeng.hooks.TickHandler; import appeng.me.GridAccessException; +import appeng.me.cache.P2PCache; +import appeng.parts.networking.PartCable; import appeng.tile.AEBaseTile; import appeng.util.Platform; +public class AENetworkProxy implements IGridBlock { -public class AENetworkProxy implements IGridBlock -{ + private final IGridProxyable gp; + private final boolean worldNode; + private final String nbtName; // name + private AEColor myColor = AEColor.TRANSPARENT; + private CompoundNBT data = null; // input + private ItemStack myRepInstance = ItemStack.EMPTY; + private boolean isReady = false; + private IGridNode node = null; + private EnumSet validSides; + private EnumSet flags = EnumSet.noneOf(GridFlags.class); + private double idleDraw = 1.0; + private PlayerEntity owner; - private final IGridProxyable gp; - private final boolean worldNode; - private final String nbtName; // name - private AEColor myColor = AEColor.TRANSPARENT; - private CompoundNBT data = null; // input - private ItemStack myRepInstance = ItemStack.EMPTY; - private boolean isReady = false; - private IGridNode node = null; - private EnumSet validSides; - private EnumSet flags = EnumSet.noneOf( GridFlags.class ); - private double idleDraw = 1.0; - private PlayerEntity owner; + public AENetworkProxy(final IGridProxyable te, final String nbtName, final ItemStack visual, + final boolean inWorld) { + this.gp = te; + this.nbtName = nbtName; + this.worldNode = inWorld; + this.myRepInstance = visual; + this.validSides = EnumSet.allOf(Direction.class); + } - public AENetworkProxy( final IGridProxyable te, final String nbtName, final ItemStack visual, final boolean inWorld ) - { - this.gp = te; - this.nbtName = nbtName; - this.worldNode = inWorld; - this.myRepInstance = visual; - this.validSides = EnumSet.allOf( Direction.class ); - } + public void setVisualRepresentation(final ItemStack is) { + this.myRepInstance = is; + } - public void setVisualRepresentation( final ItemStack is ) - { - this.myRepInstance = is; - } + public void writeToNBT(final CompoundNBT tag) { + if (this.node != null) { + this.node.saveToNBT(this.nbtName, tag); + } + } - public void writeToNBT( final CompoundNBT tag ) - { - if( this.node != null ) - { - this.node.saveToNBT( this.nbtName, tag ); - } - } + public void setValidSides(final EnumSet validSides) { + this.validSides = validSides; + if (this.node != null) { + this.node.updateState(); + } + } - public void setValidSides( final EnumSet validSides ) - { - this.validSides = validSides; - if( this.node != null ) - { - this.node.updateState(); - } - } + public void validate() { + if (this.gp instanceof AEBaseTile) { + TickHandler.INSTANCE.addInit((AEBaseTile) this.gp); + } + } - public void validate() - { - if( this.gp instanceof AEBaseTile ) - { - TickHandler.INSTANCE.addInit( (AEBaseTile) this.gp ); - } - } + public void onChunkUnloaded() { + this.isReady = false; + this.remove(); + } - public void onChunkUnloaded() - { - this.isReady = false; - this.remove(); - } + public void remove() { + this.isReady = false; + if (this.node != null) { + this.node.destroy(); + this.node = null; + } + } - public void remove() - { - this.isReady = false; - if( this.node != null ) - { - this.node.destroy(); - this.node = null; - } - } + public void onReady() { + this.isReady = true; - public void onReady() - { - this.isReady = true; + // send orientation based directionality to the node. + if (this.gp instanceof IOrientable) { + final IOrientable ori = (IOrientable) this.gp; + if (ori.canBeRotated()) { + ori.setOrientation(ori.getForward(), ori.getUp()); + } + } - // send orientation based directionality to the node. - if( this.gp instanceof IOrientable ) - { - final IOrientable ori = (IOrientable) this.gp; - if( ori.canBeRotated() ) - { - ori.setOrientation( ori.getForward(), ori.getUp() ); - } - } + this.getNode(); + } - this.getNode(); - } + public IGridNode getNode() { + if (this.node == null && Platform.isServer() && this.isReady) { + this.node = AEApi.instance().grid().createGridNode(this); + this.readFromNBT(this.data); + this.node.updateState(); + } - public IGridNode getNode() - { - if( this.node == null && Platform.isServer() && this.isReady ) - { - this.node = AEApi.instance().grid().createGridNode( this ); - this.readFromNBT( this.data ); - this.node.updateState(); - } + return this.node; + } - return this.node; - } + public void readFromNBT(final CompoundNBT tag) { + this.data = tag; + if (this.node != null && this.data != null) { + this.node.loadFromNBT(this.nbtName, this.data); + this.data = null; + } else if (this.node != null && this.owner != null) { + final GameProfile profile = this.owner.getGameProfile(); + final int playerID = WorldData.instance().playerData().getMePlayerId(profile); - public void readFromNBT( final CompoundNBT tag ) - { - this.data = tag; - if( this.node != null && this.data != null ) - { - this.node.loadFromNBT( this.nbtName, this.data ); - this.data = null; - } - else if( this.node != null && this.owner != null ) - { - final GameProfile profile = this.owner.getGameProfile(); - final int playerID = WorldData.instance().playerData().getMePlayerId( profile ); + this.node.setPlayerID(playerID); + this.owner = null; + } + } - this.node.setPlayerID( playerID ); - this.owner = null; - } - } + public IPathingGrid getPath() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } + final IPathingGrid pg = grid.getCache(IPathingGrid.class); + if (pg == null) { + throw new GridAccessException(); + } + return pg; + } - public IPathingGrid getPath() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } - final IPathingGrid pg = grid.getCache( IPathingGrid.class ); - if( pg == null ) - { - throw new GridAccessException(); - } - return pg; - } + /** + * short cut! + * + * @return grid of node + * + * @throws GridAccessException of node or grid is null + */ + public IGrid getGrid() throws GridAccessException { + if (this.node == null) { + throw new GridAccessException(); + } + final IGrid grid = this.node.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } + return grid; + } - /** - * short cut! - * - * @return grid of node - * - * @throws GridAccessException of node or grid is null - */ - public IGrid getGrid() throws GridAccessException - { - if( this.node == null ) - { - throw new GridAccessException(); - } - final IGrid grid = this.node.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } - return grid; - } + public ITickManager getTick() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } + final ITickManager pg = grid.getCache(ITickManager.class); + if (pg == null) { + throw new GridAccessException(); + } + return pg; + } - public ITickManager getTick() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } - final ITickManager pg = grid.getCache( ITickManager.class ); - if( pg == null ) - { - throw new GridAccessException(); - } - return pg; - } + public IStorageGrid getStorage() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } - public IStorageGrid getStorage() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } + final IStorageGrid pg = grid.getCache(IStorageGrid.class); - final IStorageGrid pg = grid.getCache( IStorageGrid.class ); + if (pg == null) { + throw new GridAccessException(); + } - if( pg == null ) - { - throw new GridAccessException(); - } + return pg; + } - return pg; - } + public P2PCache getP2P() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } - public P2PCache getP2P() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } + final P2PCache pg = grid.getCache(P2PCache.class); - final P2PCache pg = grid.getCache( P2PCache.class ); + if (pg == null) { + throw new GridAccessException(); + } - if( pg == null ) - { - throw new GridAccessException(); - } + return pg; + } - return pg; - } + public ISecurityGrid getSecurity() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } - public ISecurityGrid getSecurity() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } + final ISecurityGrid sg = grid.getCache(ISecurityGrid.class); - final ISecurityGrid sg = grid.getCache( ISecurityGrid.class ); + if (sg == null) { + throw new GridAccessException(); + } - if( sg == null ) - { - throw new GridAccessException(); - } + return sg; + } - return sg; - } + public ICraftingGrid getCrafting() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } - public ICraftingGrid getCrafting() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } + final ICraftingGrid sg = grid.getCache(ICraftingGrid.class); - final ICraftingGrid sg = grid.getCache( ICraftingGrid.class ); + if (sg == null) { + throw new GridAccessException(); + } - if( sg == null ) - { - throw new GridAccessException(); - } + return sg; + } - return sg; - } + @Override + public double getIdlePowerUsage() { + return this.idleDraw; + } - @Override - public double getIdlePowerUsage() - { - return this.idleDraw; - } + @Override + public EnumSet getFlags() { + return this.flags; + } - @Override - public EnumSet getFlags() - { - return this.flags; - } + @Override + public boolean isWorldAccessible() { + return this.worldNode; + } - @Override - public boolean isWorldAccessible() - { - return this.worldNode; - } + @Override + public DimensionalCoord getLocation() { + return this.gp.getLocation(); + } - @Override - public DimensionalCoord getLocation() - { - return this.gp.getLocation(); - } + @Override + public AEColor getGridColor() { + return this.getColor(); + } - @Override - public AEColor getGridColor() - { - return this.getColor(); - } + @Override + public void onGridNotification(final GridNotification notification) { + if (this.gp instanceof PartCable) { + ((PartCable) this.gp).markForUpdate(); + } + } - @Override - public void onGridNotification( final GridNotification notification ) - { - if( this.gp instanceof PartCable) - { - ( (PartCable) this.gp ).markForUpdate(); - } - } + @Override + public void setNetworkStatus(final IGrid grid, final int channelsInUse) { - @Override - public void setNetworkStatus( final IGrid grid, final int channelsInUse ) - { + } - } + @Override + public EnumSet getConnectableSides() { + return this.validSides; + } - @Override - public EnumSet getConnectableSides() - { - return this.validSides; - } + @Override + public IGridHost getMachine() { + return this.gp; + } - @Override - public IGridHost getMachine() - { - return this.gp; - } + @Override + public void gridChanged() { + this.gp.gridChanged(); + } - @Override - public void gridChanged() - { - this.gp.gridChanged(); - } + @Override + public ItemStack getMachineRepresentation() { + return this.myRepInstance; + } - @Override - public ItemStack getMachineRepresentation() - { - return this.myRepInstance; - } + public void setFlags(final GridFlags... requireChannel) { + final EnumSet flags = EnumSet.noneOf(GridFlags.class); - public void setFlags( final GridFlags... requireChannel ) - { - final EnumSet flags = EnumSet.noneOf( GridFlags.class ); + Collections.addAll(flags, requireChannel); - Collections.addAll( flags, requireChannel ); + this.flags = flags; + } - this.flags = flags; - } + public void setIdlePowerUsage(final double idle) { + this.idleDraw = idle; - public void setIdlePowerUsage( final double idle ) - { - this.idleDraw = idle; + if (this.node != null) { + try { + final IGrid g = this.getGrid(); + g.postEvent(new MENetworkPowerIdleChange(this.node)); + } catch (final GridAccessException e) { + // not ready for this yet.. + } + } + } - if( this.node != null ) - { - try - { - final IGrid g = this.getGrid(); - g.postEvent( new MENetworkPowerIdleChange( this.node ) ); - } - catch( final GridAccessException e ) - { - // not ready for this yet.. - } - } - } + public boolean isReady() { + return this.isReady; + } - public boolean isReady() - { - return this.isReady; - } + public boolean isActive() { + if (this.node == null) { + return false; + } - public boolean isActive() - { - if( this.node == null ) - { - return false; - } + return this.node.isActive(); + } - return this.node.isActive(); - } + public boolean isPowered() { + try { + return this.getEnergy().isNetworkPowered(); + } catch (final GridAccessException e) { + return false; + } + } - public boolean isPowered() - { - try - { - return this.getEnergy().isNetworkPowered(); - } - catch( final GridAccessException e ) - { - return false; - } - } + public IEnergyGrid getEnergy() throws GridAccessException { + final IGrid grid = this.getGrid(); + if (grid == null) { + throw new GridAccessException(); + } + final IEnergyGrid eg = grid.getCache(IEnergyGrid.class); + if (eg == null) { + throw new GridAccessException(); + } + return eg; + } - public IEnergyGrid getEnergy() throws GridAccessException - { - final IGrid grid = this.getGrid(); - if( grid == null ) - { - throw new GridAccessException(); - } - final IEnergyGrid eg = grid.getCache( IEnergyGrid.class ); - if( eg == null ) - { - throw new GridAccessException(); - } - return eg; - } + public void setOwner(final PlayerEntity player) { + this.owner = player; + } - public void setOwner( final PlayerEntity player ) - { - this.owner = player; - } + public AEColor getColor() { + return this.myColor; + } - public AEColor getColor() - { - return this.myColor; - } - - public void setColor( final AEColor myColor ) - { - this.myColor = myColor; - } + public void setColor(final AEColor myColor) { + this.myColor = myColor; + } } diff --git a/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java b/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java index a0a14e77d..9742d1f2c 100644 --- a/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java +++ b/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java @@ -18,7 +18,6 @@ package appeng.me.helpers; - import java.util.Iterator; import net.minecraft.item.ItemStack; @@ -30,28 +29,23 @@ import appeng.me.cluster.IAEMultiBlock; import appeng.util.iterators.ChainedIterator; import appeng.util.iterators.ProxyNodeIterator; +public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMultiblock { -public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMultiblock -{ + public AENetworkProxyMultiblock(final IGridProxyable te, final String nbtName, final ItemStack itemStack, + final boolean inWorld) { + super(te, nbtName, itemStack, inWorld); + } - public AENetworkProxyMultiblock( final IGridProxyable te, final String nbtName, final ItemStack itemStack, final boolean inWorld ) - { - super( te, nbtName, itemStack, inWorld ); - } + @Override + public Iterator getMultiblockNodes() { + if (this.getCluster() == null) { + return new ChainedIterator<>(); + } - @Override - public Iterator getMultiblockNodes() - { - if( this.getCluster() == null ) - { - return new ChainedIterator<>(); - } + return new ProxyNodeIterator(this.getCluster().getTiles()); + } - return new ProxyNodeIterator( this.getCluster().getTiles() ); - } - - private IAECluster getCluster() - { - return ( (IAEMultiBlock) this.getMachine() ).getCluster(); - } + private IAECluster getCluster() { + return ((IAEMultiBlock) this.getMachine()).getCluster(); + } } diff --git a/src/main/java/appeng/me/helpers/BaseActionSource.java b/src/main/java/appeng/me/helpers/BaseActionSource.java index 07b11ede3..18b8917bc 100644 --- a/src/main/java/appeng/me/helpers/BaseActionSource.java +++ b/src/main/java/appeng/me/helpers/BaseActionSource.java @@ -18,7 +18,6 @@ package appeng.me.helpers; - import java.util.Optional; import net.minecraft.entity.player.PlayerEntity; @@ -26,25 +25,20 @@ import net.minecraft.entity.player.PlayerEntity; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionSource; +public class BaseActionSource implements IActionSource { -public class BaseActionSource implements IActionSource -{ + @Override + public Optional player() { + return Optional.empty(); + } - @Override - public Optional player() - { - return Optional.empty(); - } + @Override + public Optional machine() { + return Optional.empty(); + } - @Override - public Optional machine() - { - return Optional.empty(); - } - - @Override - public Optional context( Class key ) - { - return Optional.empty(); - } + @Override + public Optional context(Class key) { + return Optional.empty(); + } } diff --git a/src/main/java/appeng/me/helpers/ChannelPowerSrc.java b/src/main/java/appeng/me/helpers/ChannelPowerSrc.java index 8ca76443c..2b088aaa2 100644 --- a/src/main/java/appeng/me/helpers/ChannelPowerSrc.java +++ b/src/main/java/appeng/me/helpers/ChannelPowerSrc.java @@ -18,32 +18,26 @@ package appeng.me.helpers; - import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.networking.IGridNode; import appeng.api.networking.energy.IEnergySource; +public class ChannelPowerSrc implements IEnergySource { -public class ChannelPowerSrc implements IEnergySource -{ + private final IGridNode node; + private final IEnergySource realSrc; - private final IGridNode node; - private final IEnergySource realSrc; + public ChannelPowerSrc(final IGridNode networkNode, final IEnergySource src) { + this.node = networkNode; + this.realSrc = src; + } - public ChannelPowerSrc( final IGridNode networkNode, final IEnergySource src ) - { - this.node = networkNode; - this.realSrc = src; - } - - @Override - public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier ) - { - if( this.node.isActive() ) - { - return this.realSrc.extractAEPower( amt, mode, usePowerMultiplier ); - } - return 0.0; - } + @Override + public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) { + if (this.node.isActive()) { + return this.realSrc.extractAEPower(amt, mode, usePowerMultiplier); + } + return 0.0; + } } diff --git a/src/main/java/appeng/me/helpers/GenericInterestManager.java b/src/main/java/appeng/me/helpers/GenericInterestManager.java index 1439c3424..b34526bdc 100644 --- a/src/main/java/appeng/me/helpers/GenericInterestManager.java +++ b/src/main/java/appeng/me/helpers/GenericInterestManager.java @@ -18,7 +18,6 @@ package appeng.me.helpers; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -27,100 +26,77 @@ import com.google.common.collect.Multimap; import appeng.api.storage.data.IAEStack; +public class GenericInterestManager { -public class GenericInterestManager -{ + private final Multimap container; + private List transactions = null; + private int transDepth = 0; - private final Multimap container; - private List transactions = null; - private int transDepth = 0; + public GenericInterestManager(final Multimap interests) { + this.container = interests; + } - public GenericInterestManager( final Multimap interests ) - { - this.container = interests; - } + public void enableTransactions() { + if (this.transDepth == 0) { + this.transactions = new ArrayList<>(); + } - public void enableTransactions() - { - if( this.transDepth == 0 ) - { - this.transactions = new ArrayList<>(); - } + this.transDepth++; + } - this.transDepth++; - } + public void disableTransactions() { + this.transDepth--; - public void disableTransactions() - { - this.transDepth--; + if (this.transDepth == 0) { + final List myActions = this.transactions; + this.transactions = null; - if( this.transDepth == 0 ) - { - final List myActions = this.transactions; - this.transactions = null; + for (final SavedTransactions t : myActions) { + if (t.put) { + this.put(t.stack, t.iw); + } else { + this.remove(t.stack, t.iw); + } + } + } + } - for( final SavedTransactions t : myActions ) - { - if( t.put ) - { - this.put( t.stack, t.iw ); - } - else - { - this.remove( t.stack, t.iw ); - } - } - } - } + public boolean put(final IAEStack stack, final T iw) { + if (this.transactions != null) { + this.transactions.add(new SavedTransactions(true, stack, iw)); + return true; + } else { + return this.container.put(stack, iw); + } + } - public boolean put( final IAEStack stack, final T iw ) - { - if( this.transactions != null ) - { - this.transactions.add( new SavedTransactions( true, stack, iw ) ); - return true; - } - else - { - return this.container.put( stack, iw ); - } - } + public boolean remove(final IAEStack stack, final T iw) { + if (this.transactions != null) { + this.transactions.add(new SavedTransactions(false, stack, iw)); + return true; + } else { + return this.container.remove(stack, iw); + } + } - public boolean remove( final IAEStack stack, final T iw ) - { - if( this.transactions != null ) - { - this.transactions.add( new SavedTransactions( false, stack, iw ) ); - return true; - } - else - { - return this.container.remove( stack, iw ); - } - } + public boolean containsKey(final IAEStack stack) { + return this.container.containsKey(stack); + } - public boolean containsKey( final IAEStack stack ) - { - return this.container.containsKey( stack ); - } + public Collection get(final IAEStack stack) { + return this.container.get(stack); + } - public Collection get( final IAEStack stack ) - { - return this.container.get( stack ); - } + private class SavedTransactions { - private class SavedTransactions - { + private final boolean put; + private final IAEStack stack; + private final T iw; - private final boolean put; - private final IAEStack stack; - private final T iw; - - public SavedTransactions( final boolean putOperation, final IAEStack myStack, final T watcher ) - { - this.put = putOperation; - this.stack = myStack; - this.iw = watcher; - } - } + public SavedTransactions(final boolean putOperation, final IAEStack myStack, final T watcher) { + this.put = putOperation; + this.stack = myStack; + this.iw = watcher; + } + } } diff --git a/src/main/java/appeng/me/helpers/IGridProxyable.java b/src/main/java/appeng/me/helpers/IGridProxyable.java index 916a5659a..4f47bdb91 100644 --- a/src/main/java/appeng/me/helpers/IGridProxyable.java +++ b/src/main/java/appeng/me/helpers/IGridProxyable.java @@ -18,17 +18,14 @@ package appeng.me.helpers; - import appeng.api.networking.IGridHost; import appeng.api.util.DimensionalCoord; +public interface IGridProxyable extends IGridHost { -public interface IGridProxyable extends IGridHost -{ + AENetworkProxy getProxy(); - AENetworkProxy getProxy(); + DimensionalCoord getLocation(); - DimensionalCoord getLocation(); - - void gridChanged(); + void gridChanged(); } diff --git a/src/main/java/appeng/me/helpers/MEMonitorHandler.java b/src/main/java/appeng/me/helpers/MEMonitorHandler.java index e77c284a3..832f5734e 100644 --- a/src/main/java/appeng/me/helpers/MEMonitorHandler.java +++ b/src/main/java/appeng/me/helpers/MEMonitorHandler.java @@ -23,7 +23,6 @@ package appeng.me.helpers; - import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; @@ -40,182 +39,150 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; - /** - * Common implementation of a simple class that monitors injection/extraction of a inventory to send events to a list of - * listeners. + * Common implementation of a simple class that monitors injection/extraction of + * a inventory to send events to a list of listeners. * * @param * - * TODO: Needs to be redesigned to solve performance issues. + * TODO: Needs to be redesigned to solve performance issues. */ -public class MEMonitorHandler> implements IMEMonitor -{ +public class MEMonitorHandler> implements IMEMonitor { - private final IMEInventoryHandler internalHandler; - private final IItemList cachedList; - private final HashMap, Object> listeners = new HashMap<>(); + private final IMEInventoryHandler internalHandler; + private final IItemList cachedList; + private final HashMap, Object> listeners = new HashMap<>(); - protected boolean hasChanged = true; + protected boolean hasChanged = true; - public MEMonitorHandler( final IMEInventoryHandler t ) - { - this.internalHandler = t; - this.cachedList = t.getChannel().createList(); - } + public MEMonitorHandler(final IMEInventoryHandler t) { + this.internalHandler = t; + this.cachedList = t.getChannel().createList(); + } - public MEMonitorHandler( final IMEInventoryHandler t, final IStorageChannel chan ) - { - this.internalHandler = t; - this.cachedList = chan.createList(); - } + public MEMonitorHandler(final IMEInventoryHandler t, final IStorageChannel chan) { + this.internalHandler = t; + this.cachedList = chan.createList(); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public T injectItems( final T input, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.SIMULATE ) - { - return this.getHandler().injectItems( input, mode, src ); - } - return this.monitorDifference( input.copy(), this.getHandler().injectItems( input, mode, src ), false, src ); - } + @Override + public T injectItems(final T input, final Actionable mode, final IActionSource src) { + if (mode == Actionable.SIMULATE) { + return this.getHandler().injectItems(input, mode, src); + } + return this.monitorDifference(input.copy(), this.getHandler().injectItems(input, mode, src), false, src); + } - protected IMEInventoryHandler getHandler() - { - return this.internalHandler; - } + protected IMEInventoryHandler getHandler() { + return this.internalHandler; + } - private T monitorDifference( final T original, final T leftOvers, final boolean extraction, final IActionSource src ) - { - final T diff = original.copy(); + private T monitorDifference(final T original, final T leftOvers, final boolean extraction, + final IActionSource src) { + final T diff = original.copy(); - if( extraction ) - { - diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() ); - } - else if( leftOvers != null ) - { - diff.decStackSize( leftOvers.getStackSize() ); - } + if (extraction) { + diff.setStackSize(leftOvers == null ? 0 : -leftOvers.getStackSize()); + } else if (leftOvers != null) { + diff.decStackSize(leftOvers.getStackSize()); + } - if( diff.getStackSize() != 0 ) - { - this.postChangesToListeners( ImmutableList.of( diff ), src ); - } + if (diff.getStackSize() != 0) { + this.postChangesToListeners(ImmutableList.of(diff), src); + } - return leftOvers; - } + return leftOvers; + } - protected void postChangesToListeners( final Iterable changes, final IActionSource src ) - { - this.notifyListenersOfChange( changes, src ); - } + protected void postChangesToListeners(final Iterable changes, final IActionSource src) { + this.notifyListenersOfChange(changes, src); + } - protected void notifyListenersOfChange( final Iterable diff, final IActionSource src ) - { - this.hasChanged = true;// need to update the cache. - final Iterator, Object>> i = this.getListeners(); - while( i.hasNext() ) - { - final Entry, Object> o = i.next(); - final IMEMonitorHandlerReceiver receiver = o.getKey(); - if( receiver.isValid( o.getValue() ) ) - { - receiver.postChange( this, diff, src ); - } - else - { - i.remove(); - } - } - } + protected void notifyListenersOfChange(final Iterable diff, final IActionSource src) { + this.hasChanged = true;// need to update the cache. + final Iterator, Object>> i = this.getListeners(); + while (i.hasNext()) { + final Entry, Object> o = i.next(); + final IMEMonitorHandlerReceiver receiver = o.getKey(); + if (receiver.isValid(o.getValue())) { + receiver.postChange(this, diff, src); + } else { + i.remove(); + } + } + } - protected Iterator, Object>> getListeners() - { - return this.listeners.entrySet().iterator(); - } + protected Iterator, Object>> getListeners() { + return this.listeners.entrySet().iterator(); + } - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.SIMULATE ) - { - return this.getHandler().extractItems( request, mode, src ); - } - return this.monitorDifference( request.copy(), this.getHandler().extractItems( request, mode, src ), true, src ); - } + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + if (mode == Actionable.SIMULATE) { + return this.getHandler().extractItems(request, mode, src); + } + return this.monitorDifference(request.copy(), this.getHandler().extractItems(request, mode, src), true, src); + } - @Override - public IStorageChannel getChannel() - { - return this.getHandler().getChannel(); - } + @Override + public IStorageChannel getChannel() { + return this.getHandler().getChannel(); + } - @Override - public AccessRestriction getAccess() - { - return this.getHandler().getAccess(); - } + @Override + public AccessRestriction getAccess() { + return this.getHandler().getAccess(); + } - @Override - public IItemList getStorageList() - { - if( this.hasChanged ) - { - this.hasChanged = false; - this.cachedList.resetStatus(); - return this.getAvailableItems( this.cachedList ); - } + @Override + public IItemList getStorageList() { + if (this.hasChanged) { + this.hasChanged = false; + this.cachedList.resetStatus(); + return this.getAvailableItems(this.cachedList); + } - return this.cachedList; - } + return this.cachedList; + } - @Override - public boolean isPrioritized( final T input ) - { - return this.getHandler().isPrioritized( input ); - } + @Override + public boolean isPrioritized(final T input) { + return this.getHandler().isPrioritized(input); + } - @Override - public boolean canAccept( final T input ) - { - return this.getHandler().canAccept( input ); - } + @Override + public boolean canAccept(final T input) { + return this.getHandler().canAccept(input); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return this.getHandler().getAvailableItems( out ); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return this.getHandler().getAvailableItems(out); + } - @Override - public int getPriority() - { - return this.getHandler().getPriority(); - } + @Override + public int getPriority() { + return this.getHandler().getPriority(); + } - @Override - public int getSlot() - { - return this.getHandler().getSlot(); - } + @Override + public int getSlot() { + return this.getHandler().getSlot(); + } - @Override - public boolean validForPass( final int i ) - { - return this.getHandler().validForPass( i ); - } + @Override + public boolean validForPass(final int i) { + return this.getHandler().validForPass(i); + } } diff --git a/src/main/java/appeng/me/helpers/MachineSource.java b/src/main/java/appeng/me/helpers/MachineSource.java index 2b4270d9b..fd9907496 100644 --- a/src/main/java/appeng/me/helpers/MachineSource.java +++ b/src/main/java/appeng/me/helpers/MachineSource.java @@ -18,7 +18,6 @@ package appeng.me.helpers; - import java.util.Optional; import net.minecraft.entity.player.PlayerEntity; @@ -26,33 +25,27 @@ import net.minecraft.entity.player.PlayerEntity; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionSource; +public class MachineSource implements IActionSource { -public class MachineSource implements IActionSource -{ + private final IActionHost via; - private final IActionHost via; + public MachineSource(final IActionHost v) { + this.via = v; + } - public MachineSource( final IActionHost v ) - { - this.via = v; - } + @Override + public Optional player() { + return Optional.empty(); + } - @Override - public Optional player() - { - return Optional.empty(); - } + @Override + public Optional machine() { + return Optional.of(this.via); + } - @Override - public Optional machine() - { - return Optional.of( this.via ); - } - - @Override - public Optional context( Class key ) - { - return Optional.empty(); - } + @Override + public Optional context(Class key) { + return Optional.empty(); + } } diff --git a/src/main/java/appeng/me/helpers/PlayerSource.java b/src/main/java/appeng/me/helpers/PlayerSource.java index c8bb9b048..2bcda6b13 100644 --- a/src/main/java/appeng/me/helpers/PlayerSource.java +++ b/src/main/java/appeng/me/helpers/PlayerSource.java @@ -18,7 +18,6 @@ package appeng.me.helpers; - import java.util.Optional; import com.google.common.base.Preconditions; @@ -28,35 +27,29 @@ import net.minecraft.entity.player.PlayerEntity; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionSource; +public class PlayerSource implements IActionSource { -public class PlayerSource implements IActionSource -{ + private final PlayerEntity player; + private final IActionHost via; - private final PlayerEntity player; - private final IActionHost via; + public PlayerSource(final PlayerEntity p, final IActionHost v) { + Preconditions.checkNotNull(p); + this.player = p; + this.via = v; + } - public PlayerSource( final PlayerEntity p, final IActionHost v ) - { - Preconditions.checkNotNull( p ); - this.player = p; - this.via = v; - } + @Override + public Optional player() { + return Optional.of(this.player); + } - @Override - public Optional player() - { - return Optional.of( this.player ); - } + @Override + public Optional machine() { + return Optional.ofNullable(this.via); + } - @Override - public Optional machine() - { - return Optional.ofNullable( this.via ); - } - - @Override - public Optional context( Class key ) - { - return Optional.empty(); - } + @Override + public Optional context(Class key) { + return Optional.empty(); + } } diff --git a/src/main/java/appeng/me/pathfinding/AdHocChannelUpdater.java b/src/main/java/appeng/me/pathfinding/AdHocChannelUpdater.java index 8a0afab1f..18534b576 100644 --- a/src/main/java/appeng/me/pathfinding/AdHocChannelUpdater.java +++ b/src/main/java/appeng/me/pathfinding/AdHocChannelUpdater.java @@ -18,40 +18,34 @@ package appeng.me.pathfinding; - import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridConnectionVisitor; import appeng.api.networking.IGridNode; import appeng.me.GridConnection; import appeng.me.GridNode; +public class AdHocChannelUpdater implements IGridConnectionVisitor { -public class AdHocChannelUpdater implements IGridConnectionVisitor -{ + private final int usedChannels; - private final int usedChannels; + public AdHocChannelUpdater(final int used) { + this.usedChannels = used; + } - public AdHocChannelUpdater( final int used ) - { - this.usedChannels = used; - } + @Override + public boolean visitNode(final IGridNode n) { + final GridNode gn = (GridNode) n; + gn.setControllerRoute(null, true); + gn.incrementChannelCount(this.usedChannels); + gn.finalizeChannels(); + return true; + } - @Override - public boolean visitNode( final IGridNode n ) - { - final GridNode gn = (GridNode) n; - gn.setControllerRoute( null, true ); - gn.incrementChannelCount( this.usedChannels ); - gn.finalizeChannels(); - return true; - } - - @Override - public void visitConnection( final IGridConnection gcc ) - { - final GridConnection gc = (GridConnection) gcc; - gc.setControllerRoute( null, true ); - gc.incrementChannelCount( this.usedChannels ); - gc.finalizeChannels(); - } + @Override + public void visitConnection(final IGridConnection gcc) { + final GridConnection gc = (GridConnection) gcc; + gc.setControllerRoute(null, true); + gc.incrementChannelCount(this.usedChannels); + gc.finalizeChannels(); + } } diff --git a/src/main/java/appeng/me/pathfinding/ControllerChannelUpdater.java b/src/main/java/appeng/me/pathfinding/ControllerChannelUpdater.java index f6bb4ff7c..b2b581bd7 100644 --- a/src/main/java/appeng/me/pathfinding/ControllerChannelUpdater.java +++ b/src/main/java/appeng/me/pathfinding/ControllerChannelUpdater.java @@ -18,29 +18,24 @@ package appeng.me.pathfinding; - import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridConnectionVisitor; import appeng.api.networking.IGridNode; import appeng.me.GridConnection; import appeng.me.GridNode; +public class ControllerChannelUpdater implements IGridConnectionVisitor { -public class ControllerChannelUpdater implements IGridConnectionVisitor -{ + @Override + public boolean visitNode(final IGridNode n) { + final GridNode gn = (GridNode) n; + gn.finalizeChannels(); + return true; + } - @Override - public boolean visitNode( final IGridNode n ) - { - final GridNode gn = (GridNode) n; - gn.finalizeChannels(); - return true; - } - - @Override - public void visitConnection( final IGridConnection gcc ) - { - final GridConnection gc = (GridConnection) gcc; - gc.finalizeChannels(); - } + @Override + public void visitConnection(final IGridConnection gcc) { + final GridConnection gc = (GridConnection) gcc; + gc.finalizeChannels(); + } } diff --git a/src/main/java/appeng/me/pathfinding/ControllerValidator.java b/src/main/java/appeng/me/pathfinding/ControllerValidator.java index fb9e7af2d..f1fed445b 100644 --- a/src/main/java/appeng/me/pathfinding/ControllerValidator.java +++ b/src/main/java/appeng/me/pathfinding/ControllerValidator.java @@ -18,7 +18,6 @@ package appeng.me.pathfinding; - import net.minecraft.util.math.BlockPos; import appeng.api.networking.IGridHost; @@ -26,79 +25,67 @@ import appeng.api.networking.IGridNode; import appeng.api.networking.IGridVisitor; import appeng.tile.networking.TileController; +public class ControllerValidator implements IGridVisitor { -public class ControllerValidator implements IGridVisitor -{ + private boolean isValid = true; + private int found = 0; + private int minX; + private int minY; + private int minZ; + private int maxX; + private int maxY; + private int maxZ; - private boolean isValid = true; - private int found = 0; - private int minX; - private int minY; - private int minZ; - private int maxX; - private int maxY; - private int maxZ; + public ControllerValidator(final int x, final int y, final int z) { + this.minX = x; + this.maxX = x; + this.minY = y; + this.maxY = y; + this.minZ = z; + this.maxZ = z; + } - public ControllerValidator( final int x, final int y, final int z ) - { - this.minX = x; - this.maxX = x; - this.minY = y; - this.maxY = y; - this.minZ = z; - this.maxZ = z; - } + @Override + public boolean visitNode(final IGridNode n) { + final IGridHost host = n.getMachine(); + if (this.isValid() && host instanceof TileController) { + final TileController c = (TileController) host; - @Override - public boolean visitNode( final IGridNode n ) - { - final IGridHost host = n.getMachine(); - if( this.isValid() && host instanceof TileController ) - { - final TileController c = (TileController) host; + final BlockPos pos = c.getPos(); - final BlockPos pos = c.getPos(); + this.minX = Math.min(pos.getX(), this.minX); + this.maxX = Math.max(pos.getX(), this.maxX); + this.minY = Math.min(pos.getY(), this.minY); + this.maxY = Math.max(pos.getY(), this.maxY); + this.minZ = Math.min(pos.getZ(), this.minZ); + this.maxZ = Math.max(pos.getZ(), this.maxZ); - this.minX = Math.min( pos.getX(), this.minX ); - this.maxX = Math.max( pos.getX(), this.maxX ); - this.minY = Math.min( pos.getY(), this.minY ); - this.maxY = Math.max( pos.getY(), this.maxY ); - this.minZ = Math.min( pos.getZ(), this.minZ ); - this.maxZ = Math.max( pos.getZ(), this.maxZ ); + if (this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7) { + this.setFound(this.getFound() + 1); + return true; + } - if( this.maxX - this.minX < 7 && this.maxY - this.minY < 7 && this.maxZ - this.minZ < 7 ) - { - this.setFound( this.getFound() + 1 ); - return true; - } + this.setValid(false); + } else { + return false; + } - this.setValid( false ); - } - else - { - return false; - } + return this.isValid(); + } - return this.isValid(); - } + public boolean isValid() { + return this.isValid; + } - public boolean isValid() - { - return this.isValid; - } + private void setValid(final boolean isValid) { + this.isValid = isValid; + } - private void setValid( final boolean isValid ) - { - this.isValid = isValid; - } + public int getFound() { + return this.found; + } - public int getFound() - { - return this.found; - } - - private void setFound( final int found ) - { - this.found = found; - } + private void setFound(final int found) { + this.found = found; + } } diff --git a/src/main/java/appeng/me/pathfinding/IPathItem.java b/src/main/java/appeng/me/pathfinding/IPathItem.java index bc9835a2c..313e99bf8 100644 --- a/src/main/java/appeng/me/pathfinding/IPathItem.java +++ b/src/main/java/appeng/me/pathfinding/IPathItem.java @@ -18,44 +18,41 @@ package appeng.me.pathfinding; - import java.util.EnumSet; import appeng.api.networking.GridFlags; import appeng.api.util.IReadOnlyCollection; +public interface IPathItem { -public interface IPathItem -{ + IPathItem getControllerRoute(); - IPathItem getControllerRoute(); + void setControllerRoute(IPathItem fast, boolean zeroOut); - void setControllerRoute( IPathItem fast, boolean zeroOut ); + /** + * used to determine if the finder can continue. + */ + boolean canSupportMoreChannels(); - /** - * used to determine if the finder can continue. - */ - boolean canSupportMoreChannels(); + /** + * find possible choices for other pathing. + */ + IReadOnlyCollection getPossibleOptions(); - /** - * find possible choices for other pathing. - */ - IReadOnlyCollection getPossibleOptions(); + /** + * add one to the channel count, this is mostly for cables. + */ + void incrementChannelCount(int usedChannels); - /** - * add one to the channel count, this is mostly for cables. - */ - void incrementChannelCount( int usedChannels ); + /** + * get the grid flags for this IPathItem. + * + * @return the flag set. + */ + EnumSet getFlags(); - /** - * get the grid flags for this IPathItem. - * - * @return the flag set. - */ - EnumSet getFlags(); - - /** - * channels are done, wrap it up. - */ - void finalizeChannels(); + /** + * channels are done, wrap it up. + */ + void finalizeChannels(); } diff --git a/src/main/java/appeng/me/pathfinding/PathSegment.java b/src/main/java/appeng/me/pathfinding/PathSegment.java index 6209fc60c..55bc55c21 100644 --- a/src/main/java/appeng/me/pathfinding/PathSegment.java +++ b/src/main/java/appeng/me/pathfinding/PathSegment.java @@ -18,7 +18,6 @@ package appeng.me.pathfinding; - import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; @@ -30,142 +29,117 @@ import appeng.api.networking.IGridMultiblock; import appeng.api.networking.IGridNode; import appeng.me.cache.PathGridCache; +public class PathSegment { -public class PathSegment -{ + private final PathGridCache pgc; + private final Set semiOpen; + private final Set closed; + private boolean isDead; + private List open; - private final PathGridCache pgc; - private final Set semiOpen; - private final Set closed; - private boolean isDead; - private List open; + public PathSegment(final PathGridCache myPGC, final List open, final Set semiOpen, + final Set closed) { + this.open = open; + this.semiOpen = semiOpen; + this.closed = closed; + this.pgc = myPGC; + this.setDead(false); + } - public PathSegment( final PathGridCache myPGC, final List open, final Set semiOpen, final Set closed ) - { - this.open = open; - this.semiOpen = semiOpen; - this.closed = closed; - this.pgc = myPGC; - this.setDead( false ); - } + public boolean step() { + final List oldOpen = this.open; + this.open = new ArrayList<>(); - public boolean step() - { - final List oldOpen = this.open; - this.open = new ArrayList<>(); + for (final IPathItem i : oldOpen) { + for (final IPathItem pi : i.getPossibleOptions()) { + final EnumSet flags = pi.getFlags(); - for( final IPathItem i : oldOpen ) - { - for( final IPathItem pi : i.getPossibleOptions() ) - { - final EnumSet flags = pi.getFlags(); + if (!this.closed.contains(pi)) { + pi.setControllerRoute(i, true); - if( !this.closed.contains( pi ) ) - { - pi.setControllerRoute( i, true ); + if (flags.contains(GridFlags.REQUIRE_CHANNEL)) { + // close the semi open. + if (!this.semiOpen.contains(pi)) { + final boolean worked; - if( flags.contains( GridFlags.REQUIRE_CHANNEL ) ) - { - // close the semi open. - if( !this.semiOpen.contains( pi ) ) - { - final boolean worked; + if (flags.contains(GridFlags.COMPRESSED_CHANNEL)) { + worked = this.useDenseChannel(pi); + } else { + worked = this.useChannel(pi); + } - if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) ) - { - worked = this.useDenseChannel( pi ); - } - else - { - worked = this.useChannel( pi ); - } + if (worked && flags.contains(GridFlags.MULTIBLOCK)) { + final Iterator oni = ((IGridMultiblock) ((IGridNode) pi).getGridBlock()) + .getMultiblockNodes(); + while (oni.hasNext()) { + final IGridNode otherNodes = oni.next(); + if (otherNodes != pi) { + this.semiOpen.add((IPathItem) otherNodes); + } + } + } + } else { + pi.incrementChannelCount(1); // give a channel. + this.semiOpen.remove(pi); + } + } - if( worked && flags.contains( GridFlags.MULTIBLOCK ) ) - { - final Iterator oni = ( (IGridMultiblock) ( (IGridNode) pi ).getGridBlock() ).getMultiblockNodes(); - while( oni.hasNext() ) - { - final IGridNode otherNodes = oni.next(); - if( otherNodes != pi ) - { - this.semiOpen.add( (IPathItem) otherNodes ); - } - } - } - } - else - { - pi.incrementChannelCount( 1 ); // give a channel. - this.semiOpen.remove( pi ); - } - } + this.closed.add(pi); + this.open.add(pi); + } + } + } - this.closed.add( pi ); - this.open.add( pi ); - } - } - } + return this.open.isEmpty(); + } - return this.open.isEmpty(); - } + private boolean useDenseChannel(final IPathItem start) { + IPathItem pi = start; + while (pi != null) { + if (!pi.canSupportMoreChannels() || pi.getFlags().contains(GridFlags.CANNOT_CARRY_COMPRESSED)) { + return false; + } - private boolean useDenseChannel( final IPathItem start ) - { - IPathItem pi = start; - while( pi != null ) - { - if( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) - { - return false; - } + pi = pi.getControllerRoute(); + } - pi = pi.getControllerRoute(); - } + pi = start; + while (pi != null) { + this.pgc.setChannelsByBlocks(this.pgc.getChannelsByBlocks() + 1); + pi.incrementChannelCount(1); + pi = pi.getControllerRoute(); + } - pi = start; - while( pi != null ) - { - this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 ); - pi.incrementChannelCount( 1 ); - pi = pi.getControllerRoute(); - } + this.pgc.setChannelsInUse(this.pgc.getChannelsInUse() + 1); + return true; + } - this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 ); - return true; - } + private boolean useChannel(final IPathItem start) { + IPathItem pi = start; + while (pi != null) { + if (!pi.canSupportMoreChannels()) { + return false; + } - private boolean useChannel( final IPathItem start ) - { - IPathItem pi = start; - while( pi != null ) - { - if( !pi.canSupportMoreChannels() ) - { - return false; - } + pi = pi.getControllerRoute(); + } - pi = pi.getControllerRoute(); - } + pi = start; + while (pi != null) { + this.pgc.setChannelsByBlocks(this.pgc.getChannelsByBlocks() + 1); + pi.incrementChannelCount(1); + pi = pi.getControllerRoute(); + } - pi = start; - while( pi != null ) - { - this.pgc.setChannelsByBlocks( this.pgc.getChannelsByBlocks() + 1 ); - pi.incrementChannelCount( 1 ); - pi = pi.getControllerRoute(); - } + this.pgc.setChannelsInUse(this.pgc.getChannelsInUse() + 1); + return true; + } - this.pgc.setChannelsInUse( this.pgc.getChannelsInUse() + 1 ); - return true; - } + public boolean isDead() { + return this.isDead; + } - public boolean isDead() - { - return this.isDead; - } - - public void setDead( final boolean isDead ) - { - this.isDead = isDead; - } + public void setDead(final boolean isDead) { + this.isDead = isDead; + } } diff --git a/src/main/java/appeng/me/storage/AbstractCellInventory.java b/src/main/java/appeng/me/storage/AbstractCellInventory.java index 01a8f085a..0c6277212 100644 --- a/src/main/java/appeng/me/storage/AbstractCellInventory.java +++ b/src/main/java/appeng/me/storage/AbstractCellInventory.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.items.IItemHandler; @@ -30,322 +29,273 @@ import appeng.api.storage.ISaveProvider; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; - /** * @author DrummerMC * @version rv6 - 2018-01-17 * @since rv6 2018-01-17 */ -public abstract class AbstractCellInventory> implements ICellInventory -{ - private static final int MAX_ITEM_TYPES = 63; - private static final String ITEM_TYPE_TAG = "it"; - private static final String ITEM_COUNT_TAG = "ic"; - private static final String ITEM_SLOT = "#"; - private static final String ITEM_SLOT_COUNT = "@"; - protected static final String ITEM_PRE_FORMATTED_COUNT = "PF"; - protected static final String ITEM_PRE_FORMATTED_SLOT = "PF#"; - protected static final String ITEM_PRE_FORMATTED_NAME = "PN"; - protected static final String ITEM_PRE_FORMATTED_FUZZY = "FP"; - private static final String[] ITEM_SLOT_KEYS = new String[MAX_ITEM_TYPES]; - private static final String[] ITEM_SLOT_COUNT_KEYS = new String[MAX_ITEM_TYPES]; - private final CompoundNBT tagCompound; - protected final ISaveProvider container; - private int maxItemTypes = MAX_ITEM_TYPES; - private short storedItems = 0; - private int storedItemCount = 0; - protected IItemList cellItems; - private final ItemStack i; - protected final IStorageCell cellType; - protected final int itemsPerByte; - private boolean isPersisted = true; +public abstract class AbstractCellInventory> implements ICellInventory { + private static final int MAX_ITEM_TYPES = 63; + private static final String ITEM_TYPE_TAG = "it"; + private static final String ITEM_COUNT_TAG = "ic"; + private static final String ITEM_SLOT = "#"; + private static final String ITEM_SLOT_COUNT = "@"; + protected static final String ITEM_PRE_FORMATTED_COUNT = "PF"; + protected static final String ITEM_PRE_FORMATTED_SLOT = "PF#"; + protected static final String ITEM_PRE_FORMATTED_NAME = "PN"; + protected static final String ITEM_PRE_FORMATTED_FUZZY = "FP"; + private static final String[] ITEM_SLOT_KEYS = new String[MAX_ITEM_TYPES]; + private static final String[] ITEM_SLOT_COUNT_KEYS = new String[MAX_ITEM_TYPES]; + private final CompoundNBT tagCompound; + protected final ISaveProvider container; + private int maxItemTypes = MAX_ITEM_TYPES; + private short storedItems = 0; + private int storedItemCount = 0; + protected IItemList cellItems; + private final ItemStack i; + protected final IStorageCell cellType; + protected final int itemsPerByte; + private boolean isPersisted = true; - static - { - for( int x = 0; x < MAX_ITEM_TYPES; x++ ) - { - ITEM_SLOT_KEYS[x] = ITEM_SLOT + x; - ITEM_SLOT_COUNT_KEYS[x] = ITEM_SLOT_COUNT + x; - } - } + static { + for (int x = 0; x < MAX_ITEM_TYPES; x++) { + ITEM_SLOT_KEYS[x] = ITEM_SLOT + x; + ITEM_SLOT_COUNT_KEYS[x] = ITEM_SLOT_COUNT + x; + } + } - protected AbstractCellInventory( final IStorageCell cellType, final ItemStack o, final ISaveProvider container ) - { - this.i = o; - this.cellType = cellType; - this.itemsPerByte = this.cellType.getChannel().getUnitsPerByte(); - this.maxItemTypes = this.cellType.getTotalTypes( this.i ); + protected AbstractCellInventory(final IStorageCell cellType, final ItemStack o, final ISaveProvider container) { + this.i = o; + this.cellType = cellType; + this.itemsPerByte = this.cellType.getChannel().getUnitsPerByte(); + this.maxItemTypes = this.cellType.getTotalTypes(this.i); - if( this.maxItemTypes > MAX_ITEM_TYPES ) - { - this.maxItemTypes = MAX_ITEM_TYPES; - } - if( this.maxItemTypes < 1 ) - { - this.maxItemTypes = 1; - } + if (this.maxItemTypes > MAX_ITEM_TYPES) { + this.maxItemTypes = MAX_ITEM_TYPES; + } + if (this.maxItemTypes < 1) { + this.maxItemTypes = 1; + } - this.container = container; - this.tagCompound = o.getOrCreateTag(); - this.storedItems = this.tagCompound.getShort( ITEM_TYPE_TAG ); - this.storedItemCount = this.tagCompound.getInt( ITEM_COUNT_TAG ); - this.cellItems = null; - } + this.container = container; + this.tagCompound = o.getOrCreateTag(); + this.storedItems = this.tagCompound.getShort(ITEM_TYPE_TAG); + this.storedItemCount = this.tagCompound.getInt(ITEM_COUNT_TAG); + this.cellItems = null; + } - protected IItemList getCellItems() - { - if( this.cellItems == null ) - { - this.cellItems = this.getChannel().createList(); - this.loadCellItems(); - } + protected IItemList getCellItems() { + if (this.cellItems == null) { + this.cellItems = this.getChannel().createList(); + this.loadCellItems(); + } - return this.cellItems; - } + return this.cellItems; + } - @Override - public void persist() - { - if( this.isPersisted ) - { - return; - } + @Override + public void persist() { + if (this.isPersisted) { + return; + } - int itemCount = 0; + int itemCount = 0; - // add new pretty stuff... - int x = 0; - for( final T v : this.cellItems ) - { - itemCount += v.getStackSize(); + // add new pretty stuff... + int x = 0; + for (final T v : this.cellItems) { + itemCount += v.getStackSize(); - final CompoundNBT g = new CompoundNBT(); - v.writeToNBT( g ); - this.tagCompound.put( ITEM_SLOT_KEYS[x], g ); - this.tagCompound.putInt( ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize() ); + final CompoundNBT g = new CompoundNBT(); + v.writeToNBT(g); + this.tagCompound.put(ITEM_SLOT_KEYS[x], g); + this.tagCompound.putInt(ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize()); - x++; - } + x++; + } - final short oldStoredItems = this.storedItems; + final short oldStoredItems = this.storedItems; - this.storedItems = (short) this.cellItems.size(); - if( this.cellItems.isEmpty() ) - { - this.tagCompound.remove( ITEM_TYPE_TAG ); - } - else - { - this.tagCompound.putShort( ITEM_TYPE_TAG, this.storedItems ); - } + this.storedItems = (short) this.cellItems.size(); + if (this.cellItems.isEmpty()) { + this.tagCompound.remove(ITEM_TYPE_TAG); + } else { + this.tagCompound.putShort(ITEM_TYPE_TAG, this.storedItems); + } - this.storedItemCount = itemCount; - if( itemCount == 0 ) - { - this.tagCompound.remove( ITEM_COUNT_TAG ); - } - else - { - this.tagCompound.putInt( ITEM_COUNT_TAG, itemCount ); - } + this.storedItemCount = itemCount; + if (itemCount == 0) { + this.tagCompound.remove(ITEM_COUNT_TAG); + } else { + this.tagCompound.putInt(ITEM_COUNT_TAG, itemCount); + } - // clean any old crusty stuff... - for( ; x < oldStoredItems && x < this.maxItemTypes; x++ ) - { - this.tagCompound.remove( ITEM_SLOT_KEYS[x] ); - this.tagCompound.remove( ITEM_SLOT_COUNT_KEYS[x] ); - } + // clean any old crusty stuff... + for (; x < oldStoredItems && x < this.maxItemTypes; x++) { + this.tagCompound.remove(ITEM_SLOT_KEYS[x]); + this.tagCompound.remove(ITEM_SLOT_COUNT_KEYS[x]); + } - this.isPersisted = true; - } + this.isPersisted = true; + } - protected void saveChanges() - { - // recalculate values - this.storedItems = (short) this.cellItems.size(); - this.storedItemCount = 0; - for( final T v : this.cellItems ) - { - this.storedItemCount += v.getStackSize(); - } + protected void saveChanges() { + // recalculate values + this.storedItems = (short) this.cellItems.size(); + this.storedItemCount = 0; + for (final T v : this.cellItems) { + this.storedItemCount += v.getStackSize(); + } - this.isPersisted = false; - if( this.container != null ) - { - this.container.saveChanges( this ); - } - else - { - // if there is no ISaveProvider, store to NBT immediately - this.persist(); - } - } + this.isPersisted = false; + if (this.container != null) { + this.container.saveChanges(this); + } else { + // if there is no ISaveProvider, store to NBT immediately + this.persist(); + } + } - private void loadCellItems() - { - if( this.cellItems == null ) - { - this.cellItems = this.getChannel().createList(); - } + private void loadCellItems() { + if (this.cellItems == null) { + this.cellItems = this.getChannel().createList(); + } - this.cellItems.resetStatus(); // clears totals and stuff. + this.cellItems.resetStatus(); // clears totals and stuff. - final int types = (int) this.getStoredItemTypes(); - boolean needsUpdate = false; + final int types = (int) this.getStoredItemTypes(); + boolean needsUpdate = false; - for( int slot = 0; slot < types; slot++ ) - { - CompoundNBT compoundTag = this.tagCompound.getCompound( ITEM_SLOT_KEYS[slot] ); - int stackSize = this.tagCompound.getInt( ITEM_SLOT_COUNT_KEYS[slot] ); - needsUpdate |= !this.loadCellItem( compoundTag, stackSize ); - } + for (int slot = 0; slot < types; slot++) { + CompoundNBT compoundTag = this.tagCompound.getCompound(ITEM_SLOT_KEYS[slot]); + int stackSize = this.tagCompound.getInt(ITEM_SLOT_COUNT_KEYS[slot]); + needsUpdate |= !this.loadCellItem(compoundTag, stackSize); + } - if( needsUpdate ) - { - this.saveChanges(); - } - } + if (needsUpdate) { + this.saveChanges(); + } + } - /** - * Load a single item. - * - * @param compoundTag - * @param stackSize - * @return true when successfully loaded - */ - protected abstract boolean loadCellItem( CompoundNBT compoundTag, int stackSize ); + /** + * Load a single item. + * + * @param compoundTag + * @param stackSize + * @return true when successfully loaded + */ + protected abstract boolean loadCellItem(CompoundNBT compoundTag, int stackSize); - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final T item : this.getCellItems() ) - { - out.add( item ); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final T item : this.getCellItems()) { + out.add(item); + } - return out; - } + return out; + } - @Override - public ItemStack getItemStack() - { - return this.i; - } + @Override + public ItemStack getItemStack() { + return this.i; + } - @Override - public double getIdleDrain() - { - return this.cellType.getIdleDrain(); - } + @Override + public double getIdleDrain() { + return this.cellType.getIdleDrain(); + } - @Override - public FuzzyMode getFuzzyMode() - { - return this.cellType.getFuzzyMode( this.i ); - } + @Override + public FuzzyMode getFuzzyMode() { + return this.cellType.getFuzzyMode(this.i); + } - @Override - public IItemHandler getConfigInventory() - { - return this.cellType.getConfigInventory( this.i ); - } + @Override + public IItemHandler getConfigInventory() { + return this.cellType.getConfigInventory(this.i); + } - @Override - public IItemHandler getUpgradesInventory() - { - return this.cellType.getUpgradesInventory( this.i ); - } + @Override + public IItemHandler getUpgradesInventory() { + return this.cellType.getUpgradesInventory(this.i); + } - @Override - public int getBytesPerType() - { - return this.cellType.getBytesPerType( this.i ); - } + @Override + public int getBytesPerType() { + return this.cellType.getBytesPerType(this.i); + } - @Override - public boolean canHoldNewItem() - { - final long bytesFree = this.getFreeBytes(); - return ( bytesFree > this.getBytesPerType() || ( bytesFree == this.getBytesPerType() && this.getUnusedItemCount() > 0 ) ) && this - .getRemainingItemTypes() > 0; - } + @Override + public boolean canHoldNewItem() { + final long bytesFree = this.getFreeBytes(); + return (bytesFree > this.getBytesPerType() + || (bytesFree == this.getBytesPerType() && this.getUnusedItemCount() > 0)) + && this.getRemainingItemTypes() > 0; + } - @Override - public long getTotalBytes() - { - return this.cellType.getBytes( this.i ); - } + @Override + public long getTotalBytes() { + return this.cellType.getBytes(this.i); + } - @Override - public long getFreeBytes() - { - return this.getTotalBytes() - this.getUsedBytes(); - } + @Override + public long getFreeBytes() { + return this.getTotalBytes() - this.getUsedBytes(); + } - @Override - public long getTotalItemTypes() - { - return this.maxItemTypes; - } + @Override + public long getTotalItemTypes() { + return this.maxItemTypes; + } - @Override - public long getStoredItemCount() - { - return this.storedItemCount; - } + @Override + public long getStoredItemCount() { + return this.storedItemCount; + } - @Override - public long getStoredItemTypes() - { - return this.storedItems; - } + @Override + public long getStoredItemTypes() { + return this.storedItems; + } - @Override - public long getRemainingItemTypes() - { - final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType(); - final long baseOnTotal = this.getTotalItemTypes() - this.getStoredItemTypes(); - return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage; - } + @Override + public long getRemainingItemTypes() { + final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType(); + final long baseOnTotal = this.getTotalItemTypes() - this.getStoredItemTypes(); + return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage; + } - @Override - public long getUsedBytes() - { - final long bytesForItemCount = ( this.getStoredItemCount() + this.getUnusedItemCount() ) / this.itemsPerByte; - return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount; - } + @Override + public long getUsedBytes() { + final long bytesForItemCount = (this.getStoredItemCount() + this.getUnusedItemCount()) / this.itemsPerByte; + return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount; + } - @Override - public long getRemainingItemCount() - { - final long remaining = this.getFreeBytes() * this.itemsPerByte + this.getUnusedItemCount(); - return remaining > 0 ? remaining : 0; - } + @Override + public long getRemainingItemCount() { + final long remaining = this.getFreeBytes() * this.itemsPerByte + this.getUnusedItemCount(); + return remaining > 0 ? remaining : 0; + } - @Override - public int getUnusedItemCount() - { - final int div = (int) ( this.getStoredItemCount() % 8 ); + @Override + public int getUnusedItemCount() { + final int div = (int) (this.getStoredItemCount() % 8); - if( div == 0 ) - { - return 0; - } + if (div == 0) { + return 0; + } - return this.itemsPerByte - div; - } + return this.itemsPerByte - div; + } - @Override - public int getStatusForCell() - { - if( this.canHoldNewItem() ) - { - return 1; - } - if( this.getRemainingItemCount() > 0 ) - { - return 2; - } - return 3; - } + @Override + public int getStatusForCell() { + if (this.canHoldNewItem()) { + return 1; + } + if (this.getRemainingItemCount() > 0) { + return 2; + } + return 3; + } } diff --git a/src/main/java/appeng/me/storage/BasicCellInventory.java b/src/main/java/appeng/me/storage/BasicCellInventory.java index e5c6f7bc0..71a8da628 100644 --- a/src/main/java/appeng/me/storage/BasicCellInventory.java +++ b/src/main/java/appeng/me/storage/BasicCellInventory.java @@ -1,7 +1,6 @@ package appeng.me.storage; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -19,270 +18,221 @@ import appeng.core.AEConfig; import appeng.core.AELog; import appeng.util.item.AEStack; +public class BasicCellInventory> extends AbstractCellInventory { + private final IStorageChannel channel; -public class BasicCellInventory> extends AbstractCellInventory -{ - private final IStorageChannel channel; + private BasicCellInventory(final IStorageCell cellType, final ItemStack o, final ISaveProvider container) { + super(cellType, o, container); + this.channel = cellType.getChannel(); + } - private BasicCellInventory( final IStorageCell cellType, final ItemStack o, final ISaveProvider container ) - { - super( cellType, o, container ); - this.channel = cellType.getChannel(); - } + public static > ICellInventory createInventory(final ItemStack o, + final ISaveProvider container) { + try { + if (o == null) { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); + } - public static > ICellInventory createInventory( final ItemStack o, final ISaveProvider container ) - { - try - { - if( o == null ) - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); - } + final Item type = o.getItem(); + final IStorageCell cellType; + if (type instanceof IStorageCell) { + cellType = (IStorageCell) type; + } else { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); + } - final Item type = o.getItem(); - final IStorageCell cellType; - if( type instanceof IStorageCell ) - { - cellType = (IStorageCell) type; - } - else - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); - } + if (!cellType.isStorageCell(o)) { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); + } - if( !cellType.isStorageCell( o ) ) - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); - } + return new BasicCellInventory(cellType, o, container); + } catch (final AppEngException e) { + AELog.error(e); + return null; + } + } - return new BasicCellInventory( cellType, o, container ); - } - catch( final AppEngException e ) - { - AELog.error( e ); - return null; - } - } + public static > boolean isCellOfType(final ItemStack input, IStorageChannel channel) { + final IStorageCell type = getStorageCell(input); - public static > boolean isCellOfType( final ItemStack input, IStorageChannel channel ) - { - final IStorageCell type = getStorageCell( input ); + return type != null && type.getChannel() == channel; + } - return type != null && type.getChannel() == channel; - } + public static boolean isCell(final ItemStack input) { + return getStorageCell(input) != null; + } - public static boolean isCell( final ItemStack input ) - { - return getStorageCell( input ) != null; - } + private boolean isStorageCell(final T input) { + if (input instanceof IAEItemStack) { + final IAEItemStack stack = (IAEItemStack) input; + final IStorageCell type = getStorageCell(stack.getDefinition()); - private boolean isStorageCell( final T input ) - { - if( input instanceof IAEItemStack ) - { - final IAEItemStack stack = (IAEItemStack) input; - final IStorageCell type = getStorageCell( stack.getDefinition() ); + return type != null && !type.storableInStorageCell(); + } - return type != null && !type.storableInStorageCell(); - } + return false; + } - return false; - } + private static IStorageCell getStorageCell(final ItemStack input) { + if (input != null) { + final Item type = input.getItem(); - private static IStorageCell getStorageCell( final ItemStack input ) - { - if( input != null ) - { - final Item type = input.getItem(); + if (type instanceof IStorageCell) { + return (IStorageCell) type; + } + } - if( type instanceof IStorageCell ) - { - return (IStorageCell) type; - } - } + return null; + } - return null; - } + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static boolean isCellEmpty(ICellInventory inv) { + if (inv != null) { + return inv.getAvailableItems(inv.getChannel().createList()).isEmpty(); + } + return true; + } - @SuppressWarnings( { "rawtypes", "unchecked" } ) - private static boolean isCellEmpty( ICellInventory inv ) - { - if( inv != null ) - { - return inv.getAvailableItems( inv.getChannel().createList() ).isEmpty(); - } - return true; - } + @Override + public T injectItems(T input, Actionable mode, IActionSource src) { + if (input == null) { + return null; + } + if (input.getStackSize() == 0) { + return null; + } - @Override - public T injectItems( T input, Actionable mode, IActionSource src ) - { - if( input == null ) - { - return null; - } - if( input.getStackSize() == 0 ) - { - return null; - } + if (this.cellType.isBlackListed(this.getItemStack(), input)) { + return input; + } + // This is slightly hacky as it expects a read-only access, but fine for now. + // TODO: Guarantee a read-only access. E.g. provide an isEmpty() method and + // ensure CellInventory does not write + // any NBT data for empty cells instead of relying on an empty IItemContainer + if (this.isStorageCell(input)) { + final ICellInventory meInventory = createInventory(((IAEItemStack) input).createItemStack(), null); + if (!isCellEmpty(meInventory)) { + return input; + } + } - if( this.cellType.isBlackListed( this.getItemStack(), input ) ) - { - return input; - } - // This is slightly hacky as it expects a read-only access, but fine for now. - // TODO: Guarantee a read-only access. E.g. provide an isEmpty() method and ensure CellInventory does not write - // any NBT data for empty cells instead of relying on an empty IItemContainer - if( this.isStorageCell( input ) ) - { - final ICellInventory meInventory = createInventory( ( (IAEItemStack) input ).createItemStack(), null ); - if( !isCellEmpty( meInventory ) ) - { - return input; - } - } + final T l = this.getCellItems().findPrecise(input); + if (l != null) { + final long remainingItemCount = this.getRemainingItemCount(); + if (remainingItemCount <= 0) { + return input; + } - final T l = this.getCellItems().findPrecise( input ); - if( l != null ) - { - final long remainingItemCount = this.getRemainingItemCount(); - if( remainingItemCount <= 0 ) - { - return input; - } + if (input.getStackSize() > remainingItemCount) { + final T r = input.copy(); + r.setStackSize(r.getStackSize() - remainingItemCount); + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() + remainingItemCount); + this.saveChanges(); + } + return r; + } else { + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() + input.getStackSize()); + this.saveChanges(); + } + return null; + } + } - if( input.getStackSize() > remainingItemCount ) - { - final T r = input.copy(); - r.setStackSize( r.getStackSize() - remainingItemCount ); - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() + remainingItemCount ); - this.saveChanges(); - } - return r; - } - else - { - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() + input.getStackSize() ); - this.saveChanges(); - } - return null; - } - } + if (this.canHoldNewItem()) // room for new type, and for at least one item! + { + final int remainingItemCount = (int) this.getRemainingItemCount() + - this.getBytesPerType() * this.itemsPerByte; + if (remainingItemCount > 0) { + if (input.getStackSize() > remainingItemCount) { + final T toReturn = input.copy(); + toReturn.setStackSize(input.getStackSize() - remainingItemCount); + if (mode == Actionable.MODULATE) { + final T toWrite = input.copy(); + toWrite.setStackSize(remainingItemCount); - if( this.canHoldNewItem() ) // room for new type, and for at least one item! - { - final int remainingItemCount = (int) this.getRemainingItemCount() - this.getBytesPerType() * this.itemsPerByte; - if( remainingItemCount > 0 ) - { - if( input.getStackSize() > remainingItemCount ) - { - final T toReturn = input.copy(); - toReturn.setStackSize( input.getStackSize() - remainingItemCount ); - if( mode == Actionable.MODULATE ) - { - final T toWrite = input.copy(); - toWrite.setStackSize( remainingItemCount ); + this.cellItems.add(toWrite); + this.saveChanges(); + } + return toReturn; + } - this.cellItems.add( toWrite ); - this.saveChanges(); - } - return toReturn; - } + if (mode == Actionable.MODULATE) { + this.cellItems.add(input); + this.saveChanges(); + } - if( mode == Actionable.MODULATE ) - { - this.cellItems.add( input ); - this.saveChanges(); - } + return null; + } + } - return null; - } - } + return input; + } - return input; - } + @Override + public T extractItems(T request, Actionable mode, IActionSource src) { + if (request == null) { + return null; + } - @Override - public T extractItems( T request, Actionable mode, IActionSource src ) - { - if( request == null ) - { - return null; - } + final long size = Math.min(Integer.MAX_VALUE, request.getStackSize()); - final long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); + T Results = null; - T Results = null; + final T l = this.getCellItems().findPrecise(request); + if (l != null) { + Results = l.copy(); - final T l = this.getCellItems().findPrecise( request ); - if( l != null ) - { - Results = l.copy(); + if (l.getStackSize() <= size) { + Results.setStackSize(l.getStackSize()); + if (mode == Actionable.MODULATE) { + l.setStackSize(0); + this.saveChanges(); + } + } else { + Results.setStackSize(size); + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() - size); + this.saveChanges(); + } + } + } - if( l.getStackSize() <= size ) - { - Results.setStackSize( l.getStackSize() ); - if( mode == Actionable.MODULATE ) - { - l.setStackSize( 0 ); - this.saveChanges(); - } - } - else - { - Results.setStackSize( size ); - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() - size ); - this.saveChanges(); - } - } - } + return Results; + } - return Results; - } + @Override + public IStorageChannel getChannel() { + return this.channel; + } - @Override - public IStorageChannel getChannel() - { - return this.channel; - } + @Override + protected boolean loadCellItem(CompoundNBT compoundTag, int stackSize) { + // Now load the item stack + final T t; + try { + t = this.getChannel().createFromNBT(compoundTag); + if (t == null) { + AELog.warn("Removing item " + compoundTag + + " from storage cell because the associated item type couldn't be found."); + return false; + } + } catch (Throwable ex) { + if (AEConfig.instance().isRemoveCrashingItemsOnLoad()) { + AELog.warn(ex, + "Removing item " + compoundTag + " from storage cell because loading the ItemStack crashed."); + return false; + } + throw ex; + } - @Override - protected boolean loadCellItem( CompoundNBT compoundTag, int stackSize ) - { - // Now load the item stack - final T t; - try - { - t = this.getChannel().createFromNBT( compoundTag ); - if( t == null ) - { - AELog.warn( "Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found." ); - return false; - } - } - catch( Throwable ex ) - { - if( AEConfig.instance().isRemoveCrashingItemsOnLoad() ) - { - AELog.warn( ex, "Removing item " + compoundTag + " from storage cell because loading the ItemStack crashed." ); - return false; - } - throw ex; - } + t.setStackSize(stackSize); - t.setStackSize( stackSize ); + if (stackSize > 0) { + this.cellItems.add(t); + } - if( stackSize > 0 ) - { - this.cellItems.add( t ); - } - - return true; - } + return true; + } } diff --git a/src/main/java/appeng/me/storage/BasicCellInventoryHandler.java b/src/main/java/appeng/me/storage/BasicCellInventoryHandler.java index 87eee7a5d..9b4cc8c04 100644 --- a/src/main/java/appeng/me/storage/BasicCellInventoryHandler.java +++ b/src/main/java/appeng/me/storage/BasicCellInventoryHandler.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.items.IItemHandler; @@ -36,114 +35,94 @@ import appeng.api.storage.data.IItemList; import appeng.util.prioritylist.FuzzyPriorityList; import appeng.util.prioritylist.PrecisePriorityList; - /** * @author DrummerMC * @version rv6 - 2018-01-23 * @since rv6 2018-01-23 */ -public class BasicCellInventoryHandler> extends MEInventoryHandler implements ICellInventoryHandler -{ - public BasicCellInventoryHandler( final IMEInventory c, final IStorageChannel channel ) - { - super( c, channel ); +public class BasicCellInventoryHandler> extends MEInventoryHandler + implements ICellInventoryHandler { + public BasicCellInventoryHandler(final IMEInventory c, final IStorageChannel channel) { + super(c, channel); - final ICellInventory ci = this.getCellInv(); - if( ci != null ) - { - final IItemList priorityList = channel.createList(); + final ICellInventory ci = this.getCellInv(); + if (ci != null) { + final IItemList priorityList = channel.createList(); - final IItemHandler upgrades = ci.getUpgradesInventory(); - final IItemHandler config = ci.getConfigInventory(); - final FuzzyMode fzMode = ci.getFuzzyMode(); + final IItemHandler upgrades = ci.getUpgradesInventory(); + final IItemHandler config = ci.getConfigInventory(); + final FuzzyMode fzMode = ci.getFuzzyMode(); - boolean hasInverter = false; - boolean hasFuzzy = false; + boolean hasInverter = false; + boolean hasFuzzy = false; - for( int x = 0; x < upgrades.getSlots(); x++ ) - { - final ItemStack is = upgrades.getStackInSlot( x ); - if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) - { - final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is ); - if( u != null ) - { - switch( u ) - { - case FUZZY: - hasFuzzy = true; - break; - case INVERTER: - hasInverter = true; - break; - default: - } - } - } - } + for (int x = 0; x < upgrades.getSlots(); x++) { + final ItemStack is = upgrades.getStackInSlot(x); + if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) { + final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is); + if (u != null) { + switch (u) { + case FUZZY: + hasFuzzy = true; + break; + case INVERTER: + hasInverter = true; + break; + default: + } + } + } + } - for( int x = 0; x < config.getSlots(); x++ ) - { - final ItemStack is = config.getStackInSlot( x ); - if( !is.isEmpty() ) - { - final T configItem = channel.createStack( is ); - if( configItem != null ) - { - priorityList.add( configItem ); - } - } - } + for (int x = 0; x < config.getSlots(); x++) { + final ItemStack is = config.getStackInSlot(x); + if (!is.isEmpty()) { + final T configItem = channel.createStack(is); + if (configItem != null) { + priorityList.add(configItem); + } + } + } - this.setWhitelist( hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); + this.setWhitelist(hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST); - if( !priorityList.isEmpty() ) - { - if( hasFuzzy ) - { - this.setPartitionList( new FuzzyPriorityList<>( priorityList, fzMode ) ); - } - else - { - this.setPartitionList( new PrecisePriorityList<>( priorityList ) ); - } - } - } - } + if (!priorityList.isEmpty()) { + if (hasFuzzy) { + this.setPartitionList(new FuzzyPriorityList<>(priorityList, fzMode)); + } else { + this.setPartitionList(new PrecisePriorityList<>(priorityList)); + } + } + } + } - @Override - public ICellInventory getCellInv() - { - Object o = this.getInternal(); + @Override + public ICellInventory getCellInv() { + Object o = this.getInternal(); - if( o instanceof MEPassThrough ) - { - o = ( (MEPassThrough) o ).getInternal(); - } + if (o instanceof MEPassThrough) { + o = ((MEPassThrough) o).getInternal(); + } - return (ICellInventory) ( o instanceof ICellInventory ? o : null ); - } + return (ICellInventory) (o instanceof ICellInventory ? o : null); + } - @Override - public boolean isPreformatted() - { - return !this.getPartitionList().isEmpty(); - } + @Override + public boolean isPreformatted() { + return !this.getPartitionList().isEmpty(); + } - @Override - public boolean isFuzzy() - { - return this.getPartitionList() instanceof FuzzyPriorityList; - } + @Override + public boolean isFuzzy() { + return this.getPartitionList() instanceof FuzzyPriorityList; + } - @Override - public IncludeExclude getIncludeExcludeMode() - { - return this.getWhitelist(); - } + @Override + public IncludeExclude getIncludeExcludeMode() { + return this.getWhitelist(); + } - CompoundNBT openNbtData() - { + CompoundNBT openNbtData() { return this.getCellInv().getItemStack().getOrCreateTag(); } } diff --git a/src/main/java/appeng/me/storage/CreativeCellInventory.java b/src/main/java/appeng/me/storage/CreativeCellInventory.java index 53031553c..69b0ade62 100644 --- a/src/main/java/appeng/me/storage/CreativeCellInventory.java +++ b/src/main/java/appeng/me/storage/CreativeCellInventory.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import net.minecraft.item.ItemStack; import appeng.api.AEApi; @@ -34,104 +33,87 @@ import appeng.api.storage.data.IItemList; import appeng.items.contents.CellConfig; import appeng.util.item.AEItemStack; +public class CreativeCellInventory implements IMEInventoryHandler { -public class CreativeCellInventory implements IMEInventoryHandler -{ + private final IItemList itemListCache = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); - private final IItemList itemListCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); + protected CreativeCellInventory(final ItemStack o) { + final CellConfig cc = new CellConfig(o); + for (final ItemStack is : cc) { + if (!is.isEmpty()) { + final IAEItemStack i = AEItemStack.fromItemStack(is); + i.setStackSize(Integer.MAX_VALUE); + this.itemListCache.add(i); + } + } + } - protected CreativeCellInventory( final ItemStack o ) - { - final CellConfig cc = new CellConfig( o ); - for( final ItemStack is : cc ) - { - if( !is.isEmpty() ) - { - final IAEItemStack i = AEItemStack.fromItemStack( is ); - i.setStackSize( Integer.MAX_VALUE ); - this.itemListCache.add( i ); - } - } - } + public static ICellInventoryHandler getCell(final ItemStack o) { + return new BasicCellInventoryHandler(new CreativeCellInventory(o), + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + } - public static ICellInventoryHandler getCell( final ItemStack o ) - { - return new BasicCellInventoryHandler( new CreativeCellInventory( o ), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final IActionSource src) { + final IAEItemStack local = this.itemListCache.findPrecise(input); + if (local == null) { + return input; + } - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src ) - { - final IAEItemStack local = this.itemListCache.findPrecise( input ); - if( local == null ) - { - return input; - } + return null; + } - return null; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + final IAEItemStack local = this.itemListCache.findPrecise(request); + if (local == null) { + return null; + } - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - final IAEItemStack local = this.itemListCache.findPrecise( request ); - if( local == null ) - { - return null; - } + return request.copy(); + } - return request.copy(); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final IAEItemStack ais : this.itemListCache) { + out.add(ais); + } + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final IAEItemStack ais : this.itemListCache ) - { - out.add( ais ); - } - return out; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final IAEItemStack input) { + return this.itemListCache.findPrecise(input) != null; + } - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - return this.itemListCache.findPrecise( input ) != null; - } + @Override + public boolean canAccept(final IAEItemStack input) { + return this.itemListCache.findPrecise(input) != null; + } - @Override - public boolean canAccept( final IAEItemStack input ) - { - return this.itemListCache.findPrecise( input ) != null; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } - - @Override - public boolean validForPass( final int i ) - { - return true; - } + @Override + public boolean validForPass(final int i) { + return true; + } } diff --git a/src/main/java/appeng/me/storage/DriveWatcher.java b/src/main/java/appeng/me/storage/DriveWatcher.java index 073b9fb19..e6e2274c3 100644 --- a/src/main/java/appeng/me/storage/DriveWatcher.java +++ b/src/main/java/appeng/me/storage/DriveWatcher.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import net.minecraft.item.ItemStack; import appeng.api.config.Actionable; @@ -28,65 +27,56 @@ import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.data.IAEStack; +public class DriveWatcher> extends MEInventoryHandler { -public class DriveWatcher> extends MEInventoryHandler -{ + private int oldStatus = 0; + private final ItemStack is; + private final ICellHandler handler; + private final IChestOrDrive cord; - private int oldStatus = 0; - private final ItemStack is; - private final ICellHandler handler; - private final IChestOrDrive cord; + public DriveWatcher(final ICellInventoryHandler i, final ItemStack is, final ICellHandler han, + final IChestOrDrive cod) { + super(i, i.getChannel()); + this.is = is; + this.handler = han; + this.cord = cod; + } - public DriveWatcher( final ICellInventoryHandler i, final ItemStack is, final ICellHandler han, final IChestOrDrive cod ) - { - super( i, i.getChannel() ); - this.is = is; - this.handler = han; - this.cord = cod; - } + public int getStatus() { + return this.handler.getStatusForCell(this.is, (ICellInventoryHandler) this.getInternal()); + } - public int getStatus() - { - return this.handler.getStatusForCell( this.is, (ICellInventoryHandler) this.getInternal() ); - } + @Override + public T injectItems(final T input, final Actionable type, final IActionSource src) { + final long size = input.getStackSize(); - @Override - public T injectItems( final T input, final Actionable type, final IActionSource src ) - { - final long size = input.getStackSize(); + final T a = super.injectItems(input, type, src); - final T a = super.injectItems( input, type, src ); + if (type == Actionable.MODULATE && (a == null || a.getStackSize() != size)) { + final int newStatus = this.getStatus(); - if( type == Actionable.MODULATE && ( a == null || a.getStackSize() != size ) ) - { - final int newStatus = this.getStatus(); + if (newStatus != this.oldStatus) { + this.cord.blinkCell(this.getSlot()); + this.oldStatus = newStatus; + } + } - if( newStatus != this.oldStatus ) - { - this.cord.blinkCell( this.getSlot() ); - this.oldStatus = newStatus; - } - } + return a; + } - return a; - } + @Override + public T extractItems(final T request, final Actionable type, final IActionSource src) { + final T a = super.extractItems(request, type, src); - @Override - public T extractItems( final T request, final Actionable type, final IActionSource src ) - { - final T a = super.extractItems( request, type, src ); + if (type == Actionable.MODULATE && a != null) { + final int newStatus = this.getStatus(); - if( type == Actionable.MODULATE && a != null ) - { - final int newStatus = this.getStatus(); + if (newStatus != this.oldStatus) { + this.cord.blinkCell(this.getSlot()); + this.oldStatus = newStatus; + } + } - if( newStatus != this.oldStatus ) - { - this.cord.blinkCell( this.getSlot() ); - this.oldStatus = newStatus; - } - } - - return a; - } + return a; + } } diff --git a/src/main/java/appeng/me/storage/ITickingMonitor.java b/src/main/java/appeng/me/storage/ITickingMonitor.java index 8ddf4b87e..f55ede5db 100644 --- a/src/main/java/appeng/me/storage/ITickingMonitor.java +++ b/src/main/java/appeng/me/storage/ITickingMonitor.java @@ -18,16 +18,13 @@ package appeng.me.storage; - import appeng.api.networking.security.IActionSource; import appeng.api.networking.ticking.TickRateModulation; +public interface ITickingMonitor { -public interface ITickingMonitor -{ + TickRateModulation onTick(); - TickRateModulation onTick(); - - void setActionSource( IActionSource actionSource ); + void setActionSource(IActionSource actionSource); } diff --git a/src/main/java/appeng/me/storage/ItemWatcher.java b/src/main/java/appeng/me/storage/ItemWatcher.java index 0732d7bc4..bb8eec17f 100644 --- a/src/main/java/appeng/me/storage/ItemWatcher.java +++ b/src/main/java/appeng/me/storage/ItemWatcher.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -28,54 +27,46 @@ import appeng.api.networking.storage.IStackWatcherHost; import appeng.api.storage.data.IAEStack; import appeng.me.cache.GridStorageCache; - /** - * Maintain my interests, and a global watch list, they should always be fully synchronized. + * Maintain my interests, and a global watch list, they should always be fully + * synchronized. */ -public class ItemWatcher implements IStackWatcher -{ +public class ItemWatcher implements IStackWatcher { - private final GridStorageCache gsc; - private final IStackWatcherHost myObject; - private final Set myInterests = new HashSet<>(); + private final GridStorageCache gsc; + private final IStackWatcherHost myObject; + private final Set myInterests = new HashSet<>(); - public ItemWatcher( final GridStorageCache cache, final IStackWatcherHost host ) - { - this.gsc = cache; - this.myObject = host; - } + public ItemWatcher(final GridStorageCache cache, final IStackWatcherHost host) { + this.gsc = cache; + this.myObject = host; + } - public IStackWatcherHost getHost() - { - return this.myObject; - } + public IStackWatcherHost getHost() { + return this.myObject; + } - @Override - public boolean add( final IAEStack e ) - { - if( this.myInterests.contains( e ) ) - { - return false; - } + @Override + public boolean add(final IAEStack e) { + if (this.myInterests.contains(e)) { + return false; + } - return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this ); - } + return this.myInterests.add(e.copy()) && this.gsc.getInterestManager().put(e, this); + } - @Override - public boolean remove( final IAEStack o ) - { - return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( o, this ); - } + @Override + public boolean remove(final IAEStack o) { + return this.myInterests.remove(o) && this.gsc.getInterestManager().remove(o, this); + } - @Override - public void reset() - { - final Iterator i = this.myInterests.iterator(); + @Override + public void reset() { + final Iterator i = this.myInterests.iterator(); - while( i.hasNext() ) - { - this.gsc.getInterestManager().remove( i.next(), this ); - i.remove(); - } - } + while (i.hasNext()) { + this.gsc.getInterestManager().remove(i.next(), this); + i.remove(); + } + } } diff --git a/src/main/java/appeng/me/storage/MEInventoryHandler.java b/src/main/java/appeng/me/storage/MEInventoryHandler.java index 9f3a2c84b..98dbcaf60 100644 --- a/src/main/java/appeng/me/storage/MEInventoryHandler.java +++ b/src/main/java/appeng/me/storage/MEInventoryHandler.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; import appeng.api.config.IncludeExclude; @@ -31,169 +30,138 @@ import appeng.api.storage.data.IItemList; import appeng.util.prioritylist.DefaultPriorityList; import appeng.util.prioritylist.IPartitionList; +public class MEInventoryHandler> implements IMEInventoryHandler { -public class MEInventoryHandler> implements IMEInventoryHandler -{ + private final IMEInventoryHandler internal; + private int myPriority; + private IncludeExclude myWhitelist; + private AccessRestriction myAccess; + private IPartitionList myPartitionList; - private final IMEInventoryHandler internal; - private int myPriority; - private IncludeExclude myWhitelist; - private AccessRestriction myAccess; - private IPartitionList myPartitionList; + private AccessRestriction cachedAccessRestriction; + private boolean hasReadAccess; + private boolean hasWriteAccess; - private AccessRestriction cachedAccessRestriction; - private boolean hasReadAccess; - private boolean hasWriteAccess; + public MEInventoryHandler(final IMEInventory i, final IStorageChannel channel) { + if (i instanceof IMEInventoryHandler) { + this.internal = (IMEInventoryHandler) i; + } else { + this.internal = new MEPassThrough<>(i, channel); + } - public MEInventoryHandler( final IMEInventory i, final IStorageChannel channel ) - { - if( i instanceof IMEInventoryHandler ) - { - this.internal = (IMEInventoryHandler) i; - } - else - { - this.internal = new MEPassThrough<>( i, channel ); - } + this.myPriority = 0; + this.myWhitelist = IncludeExclude.WHITELIST; + this.setBaseAccess(AccessRestriction.READ_WRITE); + this.myPartitionList = new DefaultPriorityList<>(); + } - this.myPriority = 0; - this.myWhitelist = IncludeExclude.WHITELIST; - this.setBaseAccess( AccessRestriction.READ_WRITE ); - this.myPartitionList = new DefaultPriorityList<>(); - } + IncludeExclude getWhitelist() { + return this.myWhitelist; + } - IncludeExclude getWhitelist() - { - return this.myWhitelist; - } + public void setWhitelist(final IncludeExclude myWhitelist) { + this.myWhitelist = myWhitelist; + } - public void setWhitelist( final IncludeExclude myWhitelist ) - { - this.myWhitelist = myWhitelist; - } + public AccessRestriction getBaseAccess() { + return this.myAccess; + } - public AccessRestriction getBaseAccess() - { - return this.myAccess; - } + public void setBaseAccess(final AccessRestriction myAccess) { + this.myAccess = myAccess; + this.cachedAccessRestriction = this.myAccess.restrictPermissions(this.internal.getAccess()); + this.hasReadAccess = this.cachedAccessRestriction.hasPermission(AccessRestriction.READ); + this.hasWriteAccess = this.cachedAccessRestriction.hasPermission(AccessRestriction.WRITE); + } - public void setBaseAccess( final AccessRestriction myAccess ) - { - this.myAccess = myAccess; - this.cachedAccessRestriction = this.myAccess.restrictPermissions( this.internal.getAccess() ); - this.hasReadAccess = this.cachedAccessRestriction.hasPermission( AccessRestriction.READ ); - this.hasWriteAccess = this.cachedAccessRestriction.hasPermission( AccessRestriction.WRITE ); - } + IPartitionList getPartitionList() { + return this.myPartitionList; + } - IPartitionList getPartitionList() - { - return this.myPartitionList; - } + public void setPartitionList(final IPartitionList myPartitionList) { + this.myPartitionList = myPartitionList; + } - public void setPartitionList( final IPartitionList myPartitionList ) - { - this.myPartitionList = myPartitionList; - } + @Override + public T injectItems(final T input, final Actionable type, final IActionSource src) { + if (!this.canAccept(input)) { + return input; + } - @Override - public T injectItems( final T input, final Actionable type, final IActionSource src ) - { - if( !this.canAccept( input ) ) - { - return input; - } + return this.internal.injectItems(input, type, src); + } - return this.internal.injectItems( input, type, src ); - } + @Override + public T extractItems(final T request, final Actionable type, final IActionSource src) { + if (!this.hasReadAccess) { + return null; + } - @Override - public T extractItems( final T request, final Actionable type, final IActionSource src ) - { - if( !this.hasReadAccess ) - { - return null; - } + return this.internal.extractItems(request, type, src); + } - return this.internal.extractItems( request, type, src ); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + if (!this.hasReadAccess) { + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - if( !this.hasReadAccess ) - { - return out; - } + return this.internal.getAvailableItems(out); + } - return this.internal.getAvailableItems( out ); - } + @Override + public IStorageChannel getChannel() { + return this.internal.getChannel(); + } - @Override - public IStorageChannel getChannel() - { - return this.internal.getChannel(); - } + @Override + public AccessRestriction getAccess() { + return this.cachedAccessRestriction; + } - @Override - public AccessRestriction getAccess() - { - return this.cachedAccessRestriction; - } + @Override + public boolean isPrioritized(final T input) { + if (this.myWhitelist == IncludeExclude.WHITELIST) { + return this.myPartitionList.isListed(input) || this.internal.isPrioritized(input); + } + return false; + } - @Override - public boolean isPrioritized( final T input ) - { - if( this.myWhitelist == IncludeExclude.WHITELIST ) - { - return this.myPartitionList.isListed( input ) || this.internal.isPrioritized( input ); - } - return false; - } + @Override + public boolean canAccept(final T input) { + if (!this.hasWriteAccess) { + return false; + } - @Override - public boolean canAccept( final T input ) - { - if( !this.hasWriteAccess ) - { - return false; - } + if (this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed(input)) { + return false; + } + if (this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST) { + return this.internal.canAccept(input); + } + return this.myPartitionList.isListed(input) && this.internal.canAccept(input); + } - if( this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed( input ) ) - { - return false; - } - if( this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST ) - { - return this.internal.canAccept( input ); - } - return this.myPartitionList.isListed( input ) && this.internal.canAccept( input ); - } + @Override + public int getPriority() { + return this.myPriority; + } - @Override - public int getPriority() - { - return this.myPriority; - } + public void setPriority(final int myPriority) { + this.myPriority = myPriority; + } - public void setPriority( final int myPriority ) - { - this.myPriority = myPriority; - } + @Override + public int getSlot() { + return this.internal.getSlot(); + } - @Override - public int getSlot() - { - return this.internal.getSlot(); - } + @Override + public boolean validForPass(final int i) { + return true; + } - @Override - public boolean validForPass( final int i ) - { - return true; - } - - public IMEInventory getInternal() - { - return this.internal; - } + public IMEInventory getInternal() { + return this.internal; + } } diff --git a/src/main/java/appeng/me/storage/MEMonitorIFluidHandler.java b/src/main/java/appeng/me/storage/MEMonitorIFluidHandler.java index cbc3f7cb9..0a41b9d1d 100644 --- a/src/main/java/appeng/me/storage/MEMonitorIFluidHandler.java +++ b/src/main/java/appeng/me/storage/MEMonitorIFluidHandler.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -44,315 +43,262 @@ import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IItemList; +public class MEMonitorIFluidHandler implements IMEMonitor, ITickingMonitor { + private final IFluidHandler handler; + private final IItemList list = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createList(); + private final HashMap, Object> listeners = new HashMap<>(); + private final NavigableMap memory; + private IActionSource mySource; + private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY; -public class MEMonitorIFluidHandler implements IMEMonitor, ITickingMonitor -{ - private final IFluidHandler handler; - private final IItemList list = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList(); - private final HashMap, Object> listeners = new HashMap<>(); - private final NavigableMap memory; - private IActionSource mySource; - private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY; + public MEMonitorIFluidHandler(final IFluidHandler handler) { + this.handler = handler; + this.memory = new ConcurrentSkipListMap<>(); + } - public MEMonitorIFluidHandler( final IFluidHandler handler ) - { - this.handler = handler; - this.memory = new ConcurrentSkipListMap<>(); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public IAEFluidStack injectItems(final IAEFluidStack input, final Actionable type, final IActionSource src) { + final int filled = this.handler.fill(input.getFluidStack(), type.getFluidAction()); - @Override - public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable type, final IActionSource src ) - { - final int filled = this.handler.fill( input.getFluidStack(), type.getFluidAction() ); + if (filled == 0) { + return input.copy(); + } - if( filled == 0 ) - { - return input.copy(); - } + if (type == Actionable.MODULATE) { + this.onTick(); + } - if( type == Actionable.MODULATE ) - { - this.onTick(); - } + if (filled == input.getStackSize()) { + return null; + } - if( filled == input.getStackSize() ) - { - return null; - } + final IAEFluidStack o = input.copy(); + o.setStackSize(input.getStackSize() - filled); + return o; + } - final IAEFluidStack o = input.copy(); - o.setStackSize( input.getStackSize() - filled ); - return o; - } + @Override + public IAEFluidStack extractItems(final IAEFluidStack request, final Actionable type, final IActionSource src) { + final FluidStack removed = this.handler.drain(request.getFluidStack(), type.getFluidAction()); - @Override - public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable type, final IActionSource src ) - { - final FluidStack removed = this.handler.drain( request.getFluidStack(), type.getFluidAction() ); + if (removed == null || removed.getAmount() == 0) { + return null; + } - if( removed == null || removed.getAmount() == 0 ) - { - return null; - } + if (type == Actionable.MODULATE) { + this.onTick(); + } - if( type == Actionable.MODULATE ) - { - this.onTick(); - } + final IAEFluidStack o = request.copy(); + o.setStackSize(removed.getAmount()); + return o; + } - final IAEFluidStack o = request.copy(); - o.setStackSize( removed.getAmount() ); - return o; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - } + @Override + public TickRateModulation onTick() { + final List changes = new ArrayList<>(); - @Override - public TickRateModulation onTick() - { - final List changes = new ArrayList<>(); + this.list.resetStatus(); + int high = 0; + boolean changed = false; - this.list.resetStatus(); - int high = 0; - boolean changed = false; + int tankCount = this.handler.getTanks(); + for (int tank = 0; tank < tankCount; ++tank) { + final CachedFluidStack old = this.memory.get(tank); + high = Math.max(high, tank); - int tankCount = this.handler.getTanks(); - for( int tank = 0; tank < tankCount; ++tank ) - { - final CachedFluidStack old = this.memory.get( tank ); - high = Math.max( high, tank ); + FluidStack newIS = this.handler.getFluidInTank(tank); + if (!newIS.isEmpty() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY) { + // We have to actually check if we could extract _anything_ + if (this.handler.drain(1, IFluidHandler.FluidAction.SIMULATE).isEmpty()) { + // Just to safeguard against tanks that prevent non-bucket-size extractions + if (this.handler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE) + .isEmpty()) { + newIS = FluidStack.EMPTY; + } + } + } + final FluidStack oldIS = old == null ? FluidStack.EMPTY : old.fluidStack; - FluidStack newIS = this.handler.getFluidInTank(tank); - if (!newIS.isEmpty() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY) { - // We have to actually check if we could extract _anything_ - if (this.handler.drain(1, IFluidHandler.FluidAction.SIMULATE).isEmpty()) { - // Just to safeguard against tanks that prevent non-bucket-size extractions - if (this.handler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE).isEmpty()) { - newIS = FluidStack.EMPTY; - } - } - } - final FluidStack oldIS = old == null ? FluidStack.EMPTY : old.fluidStack; + if (isDifferent(newIS, oldIS)) { + final CachedFluidStack cis = new CachedFluidStack(newIS); + this.memory.put(tank, cis); - if( isDifferent( newIS, oldIS ) ) - { - final CachedFluidStack cis = new CachedFluidStack( newIS ); - this.memory.put( tank, cis ); + if (old != null && old.aeStack != null) { + old.aeStack.setStackSize(-old.aeStack.getStackSize()); + changes.add(old.aeStack); + } - if( old != null && old.aeStack != null ) - { - old.aeStack.setStackSize( -old.aeStack.getStackSize() ); - changes.add( old.aeStack ); - } + if (cis.aeStack != null) { + changes.add(cis.aeStack); + this.list.add(cis.aeStack); + } - if( cis.aeStack != null ) - { - changes.add( cis.aeStack ); - this.list.add( cis.aeStack ); - } + changed = true; + } else { + final int newSize = newIS.isEmpty() ? 0 : newIS.getAmount(); + final int diff = newSize - (oldIS.isEmpty() ? 0 : oldIS.getAmount()); - changed = true; - } - else - { - final int newSize = newIS.isEmpty() ? 0 : newIS.getAmount(); - final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getAmount() ); + IAEFluidStack stack = null; - IAEFluidStack stack = null; + if (!newIS.isEmpty()) { + stack = (old == null || old.aeStack == null ? AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class).createStack(newIS) : old.aeStack.copy()); + } + if (stack != null) { + stack.setStackSize(newSize); + this.list.add(stack); + } - if( !newIS.isEmpty() ) - { - stack = ( old == null || old.aeStack == null ? AEApi.instance() - .storage() - .getStorageChannel( IFluidStorageChannel.class ) - .createStack( newIS ) : old.aeStack.copy() ); - } - if( stack != null ) - { - stack.setStackSize( newSize ); - this.list.add( stack ); - } + if (diff != 0 && stack != null) { + final CachedFluidStack cis = new CachedFluidStack(newIS); + this.memory.put(tank, cis); - if( diff != 0 && stack != null ) - { - final CachedFluidStack cis = new CachedFluidStack( newIS ); - this.memory.put( tank, cis ); + final IAEFluidStack a = stack.copy(); + a.setStackSize(diff); + changes.add(a); + changed = true; + } + } + } - final IAEFluidStack a = stack.copy(); - a.setStackSize( diff ); - changes.add( a ); - changed = true; - } - } - } + // detect dropped items; should fix non IISided Inventory Changes. + final NavigableMap end = this.memory.tailMap(high, false); + if (!end.isEmpty()) { + for (final CachedFluidStack cis : end.values()) { + if (cis != null && cis.aeStack != null) { + final IAEFluidStack a = cis.aeStack.copy(); + a.setStackSize(-a.getStackSize()); + changes.add(a); + changed = true; + } + } + end.clear(); + } - // detect dropped items; should fix non IISided Inventory Changes. - final NavigableMap end = this.memory.tailMap( high, false ); - if( !end.isEmpty() ) - { - for( final CachedFluidStack cis : end.values() ) - { - if( cis != null && cis.aeStack != null ) - { - final IAEFluidStack a = cis.aeStack.copy(); - a.setStackSize( -a.getStackSize() ); - changes.add( a ); - changed = true; - } - } - end.clear(); - } + if (!changes.isEmpty()) { + this.postDifference(changes); + } - if( !changes.isEmpty() ) - { - this.postDifference( changes ); - } + return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER; + } - return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER; - } + private static boolean isDifferent(FluidStack a, FluidStack b) { + if (a == b) { + return false; + } + if (a == null || b == null) { + return true; + } + return !a.getFluid().equals(b.getFluid()); + } - private static boolean isDifferent( FluidStack a, FluidStack b ) - { - if( a == b ) - { - return false; - } - if( a == null || b == null ) - { - return true; - } - return !a.getFluid().equals( b.getFluid() ); - } + private void postDifference(final Iterable a) { + if (a != null) { + final Iterator, Object>> i = this.listeners.entrySet() + .iterator(); + while (i.hasNext()) { + final Entry, Object> l = i.next(); + final IMEMonitorHandlerReceiver key = l.getKey(); + if (key.isValid(l.getValue())) { + key.postChange(this, a, this.getActionSource()); + } else { + i.remove(); + } + } + } + } - private void postDifference( final Iterable a ) - { - if( a != null ) - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Entry, Object> l = i.next(); - final IMEMonitorHandlerReceiver key = l.getKey(); - if( key.isValid( l.getValue() ) ) - { - key.postChange( this, a, this.getActionSource() ); - } - else - { - i.remove(); - } - } - } - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final IAEFluidStack input) { + return false; + } - @Override - public boolean isPrioritized( final IAEFluidStack input ) - { - return false; - } + @Override + public boolean canAccept(final IAEFluidStack input) { + return true; + } - @Override - public boolean canAccept( final IAEFluidStack input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return true; + } - @Override - public boolean validForPass( final int i ) - { - return true; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final CachedFluidStack is : this.memory.values()) { + out.addStorage(is.aeStack); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final CachedFluidStack is : this.memory.values() ) - { - out.addStorage( is.aeStack ); - } + return out; + } - return out; - } + @Override + public IItemList getStorageList() { + return this.list; + } - @Override - public IItemList getStorageList() - { - return this.list; - } + private StorageFilter getMode() { + return this.mode; + } - private StorageFilter getMode() - { - return this.mode; - } + public void setMode(final StorageFilter mode) { + this.mode = mode; + } - public void setMode( final StorageFilter mode ) - { - this.mode = mode; - } + private IActionSource getActionSource() { + return this.mySource; + } - private IActionSource getActionSource() - { - return this.mySource; - } + @Override + public void setActionSource(final IActionSource mySource) { + this.mySource = mySource; + } - @Override - public void setActionSource( final IActionSource mySource ) - { - this.mySource = mySource; - } + private static class CachedFluidStack { - private static class CachedFluidStack - { + private final FluidStack fluidStack; + private final IAEFluidStack aeStack; - private final FluidStack fluidStack; - private final IAEFluidStack aeStack; - - CachedFluidStack( final FluidStack is ) - { - if( is == null ) - { - this.fluidStack = null; - this.aeStack = null; - } - else - { - this.fluidStack = is.copy(); - this.aeStack = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( is ); - } - } - } + CachedFluidStack(final FluidStack is) { + if (is == null) { + this.fluidStack = null; + this.aeStack = null; + } else { + this.fluidStack = is.copy(); + this.aeStack = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createStack(is); + } + } + } } diff --git a/src/main/java/appeng/me/storage/MEMonitorIInventory.java b/src/main/java/appeng/me/storage/MEMonitorIInventory.java index 8b58eca4d..e98f28a97 100644 --- a/src/main/java/appeng/me/storage/MEMonitorIInventory.java +++ b/src/main/java/appeng/me/storage/MEMonitorIInventory.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -45,320 +44,266 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.ItemSlot; +public class MEMonitorIInventory implements IMEMonitor, ITickingMonitor { -public class MEMonitorIInventory implements IMEMonitor, ITickingMonitor -{ + private final InventoryAdaptor adaptor; + private final IItemList list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + private final HashMap, Object> listeners = new HashMap<>(); + private final NavigableMap memory; + private IActionSource mySource; + private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY; - private final InventoryAdaptor adaptor; - private final IItemList list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final HashMap, Object> listeners = new HashMap<>(); - private final NavigableMap memory; - private IActionSource mySource; - private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY; + public MEMonitorIInventory(final InventoryAdaptor adaptor) { + this.adaptor = adaptor; + this.memory = new ConcurrentSkipListMap<>(); + } - public MEMonitorIInventory( final InventoryAdaptor adaptor ) - { - this.adaptor = adaptor; - this.memory = new ConcurrentSkipListMap<>(); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + ItemStack out = ItemStack.EMPTY; - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - ItemStack out = ItemStack.EMPTY; + if (type == Actionable.SIMULATE) { + out = this.adaptor.simulateAdd(input.createItemStack()); + } else { + out = this.adaptor.addItems(input.createItemStack()); + } - if( type == Actionable.SIMULATE ) - { - out = this.adaptor.simulateAdd( input.createItemStack() ); - } - else - { - out = this.adaptor.addItems( input.createItemStack() ); - } + if (type == Actionable.MODULATE) { + this.onTick(); + } - if( type == Actionable.MODULATE ) - { - this.onTick(); - } + if (out.isEmpty()) { + return null; + } - if( out.isEmpty() ) - { - return null; - } + // better then doing construction from scratch :3 + final IAEItemStack o = input.copy(); + o.setStackSize(out.getCount()); + return o; + } - // better then doing construction from scratch :3 - final IAEItemStack o = input.copy(); - o.setStackSize( out.getCount() ); - return o; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable type, final IActionSource src) { + ItemStack out = ItemStack.EMPTY; - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src ) - { - ItemStack out = ItemStack.EMPTY; + if (type == Actionable.SIMULATE) { + out = this.adaptor.simulateRemove((int) request.getStackSize(), request.getDefinition(), null); + } else { + out = this.adaptor.removeItems((int) request.getStackSize(), request.getDefinition(), null); + } - if( type == Actionable.SIMULATE ) - { - out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getDefinition(), null ); - } - else - { - out = this.adaptor.removeItems( (int) request.getStackSize(), request.getDefinition(), null ); - } + if (out.isEmpty()) { + return null; + } - if( out.isEmpty() ) - { - return null; - } + // better then doing construction from scratch :3 + final IAEItemStack o = request.copy(); + o.setStackSize(out.getCount()); - // better then doing construction from scratch :3 - final IAEItemStack o = request.copy(); - o.setStackSize( out.getCount() ); + if (type == Actionable.MODULATE) { + this.onTick(); + } - if( type == Actionable.MODULATE ) - { - this.onTick(); - } + return o; + } - return o; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public TickRateModulation onTick() { - @Override - public TickRateModulation onTick() - { + final List changes = new ArrayList<>(); - final List changes = new ArrayList<>(); + this.list.resetStatus(); + int high = 0; + boolean changed = false; + for (final ItemSlot is : this.adaptor) { + final CachedItemStack old = this.memory.get(is.getSlot()); + high = Math.max(high, is.getSlot()); - this.list.resetStatus(); - int high = 0; - boolean changed = false; - for( final ItemSlot is : this.adaptor ) - { - final CachedItemStack old = this.memory.get( is.getSlot() ); - high = Math.max( high, is.getSlot() ); + final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY + ? ItemStack.EMPTY + : is.getItemStack(); + final ItemStack oldIS = old == null ? ItemStack.EMPTY : old.itemStack; - final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? ItemStack.EMPTY : is.getItemStack(); - final ItemStack oldIS = old == null ? ItemStack.EMPTY : old.itemStack; + if (this.isDifferent(newIS, oldIS)) { + final CachedItemStack cis = new CachedItemStack(is.getItemStack()); + this.memory.put(is.getSlot(), cis); - if( this.isDifferent( newIS, oldIS ) ) - { - final CachedItemStack cis = new CachedItemStack( is.getItemStack() ); - this.memory.put( is.getSlot(), cis ); + if (old != null && old.aeStack != null) { + old.aeStack.setStackSize(-old.aeStack.getStackSize()); + changes.add(old.aeStack); + } - if( old != null && old.aeStack != null ) - { - old.aeStack.setStackSize( -old.aeStack.getStackSize() ); - changes.add( old.aeStack ); - } + if (cis.aeStack != null) { + changes.add(cis.aeStack); + this.list.add(cis.aeStack); + } - if( cis.aeStack != null ) - { - changes.add( cis.aeStack ); - this.list.add( cis.aeStack ); - } + changed = true; + } else { + final int newSize = (newIS.isEmpty() ? 0 : newIS.getCount()); + final int diff = newSize - (oldIS.isEmpty() ? 0 : oldIS.getCount()); - changed = true; - } - else - { - final int newSize = ( newIS.isEmpty() ? 0 : newIS.getCount() ); - final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getCount() ); + final IAEItemStack stack = (old == null || old.aeStack == null + ? AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(newIS) + : old.aeStack.copy()); + if (stack != null) { + stack.setStackSize(newSize); + this.list.add(stack); + } - final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ) - .createStack( newIS ) : old.aeStack.copy() ); - if( stack != null ) - { - stack.setStackSize( newSize ); - this.list.add( stack ); - } + if (diff != 0 && stack != null) { + final CachedItemStack cis = new CachedItemStack(is.getItemStack()); + this.memory.put(is.getSlot(), cis); - if( diff != 0 && stack != null ) - { - final CachedItemStack cis = new CachedItemStack( is.getItemStack() ); - this.memory.put( is.getSlot(), cis ); + final IAEItemStack a = stack.copy(); + a.setStackSize(diff); + changes.add(a); + changed = true; + } + } + } - final IAEItemStack a = stack.copy(); - a.setStackSize( diff ); - changes.add( a ); - changed = true; - } - } - } + // detect dropped items; should fix non IISided Inventory Changes. + final NavigableMap end = this.memory.tailMap(high, false); + if (!end.isEmpty()) { + for (final CachedItemStack cis : end.values()) { + if (cis != null && cis.aeStack != null) { + final IAEItemStack a = cis.aeStack.copy(); + a.setStackSize(-a.getStackSize()); + changes.add(a); + changed = true; + } + } + end.clear(); + } - // detect dropped items; should fix non IISided Inventory Changes. - final NavigableMap end = this.memory.tailMap( high, false ); - if( !end.isEmpty() ) - { - for( final CachedItemStack cis : end.values() ) - { - if( cis != null && cis.aeStack != null ) - { - final IAEItemStack a = cis.aeStack.copy(); - a.setStackSize( -a.getStackSize() ); - changes.add( a ); - changed = true; - } - } - end.clear(); - } + if (!changes.isEmpty()) { + this.postDifference(changes); + } - if( !changes.isEmpty() ) - { - this.postDifference( changes ); - } + return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER; + } - return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER; - } + private boolean isDifferent(final ItemStack a, final ItemStack b) { + if (a == b && b.isEmpty()) { + return false; + } - private boolean isDifferent( final ItemStack a, final ItemStack b ) - { - if( a == b && b.isEmpty() ) - { - return false; - } + if ((a.isEmpty() && !b.isEmpty()) || (!a.isEmpty() && b.isEmpty())) { + return true; + } - if( ( a.isEmpty() && !b.isEmpty() ) || ( !a.isEmpty() && b.isEmpty() ) ) - { - return true; - } + return !Platform.itemComparisons().isSameItem(a, b); + } - return !Platform.itemComparisons().isSameItem( a, b ); - } + private void postDifference(final Iterable a) { + // AELog.info( a.getItemStack().getTranslationKey() + " @ " + a.getStackSize() + // ); + if (a != null) { + final Iterator, Object>> i = this.listeners.entrySet() + .iterator(); + while (i.hasNext()) { + final Entry, Object> l = i.next(); + final IMEMonitorHandlerReceiver key = l.getKey(); + if (key.isValid(l.getValue())) { + key.postChange(this, a, this.getActionSource()); + } else { + i.remove(); + } + } + } + } - private void postDifference( final Iterable a ) - { - // AELog.info( a.getItemStack().getTranslationKey() + " @ " + a.getStackSize() ); - if( a != null ) - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Entry, Object> l = i.next(); - final IMEMonitorHandlerReceiver key = l.getKey(); - if( key.isValid( l.getValue() ) ) - { - key.postChange( this, a, this.getActionSource() ); - } - else - { - i.remove(); - } - } - } - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final IAEItemStack input) { + return false; + } - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - return false; - } + @Override + public boolean canAccept(final IAEItemStack input) { + return true; + } - @Override - public boolean canAccept( final IAEItemStack input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return true; + } - @Override - public boolean validForPass( final int i ) - { - return true; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final CachedItemStack is : this.memory.values()) { + out.addStorage(is.aeStack); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final CachedItemStack is : this.memory.values() ) - { - out.addStorage( is.aeStack ); - } + return out; + } - return out; - } + @Override + public IItemList getStorageList() { + return this.list; + } - @Override - public IItemList getStorageList() - { - return this.list; - } + private StorageFilter getMode() { + return this.mode; + } - private StorageFilter getMode() - { - return this.mode; - } + public void setMode(final StorageFilter mode) { + this.mode = mode; + } - public void setMode( final StorageFilter mode ) - { - this.mode = mode; - } + private IActionSource getActionSource() { + return this.mySource; + } - private IActionSource getActionSource() - { - return this.mySource; - } + @Override + public void setActionSource(final IActionSource mySource) { + this.mySource = mySource; + } - @Override - public void setActionSource( final IActionSource mySource ) - { - this.mySource = mySource; - } + private static class CachedItemStack { - private static class CachedItemStack - { + private final ItemStack itemStack; + private final IAEItemStack aeStack; - private final ItemStack itemStack; - private final IAEItemStack aeStack; - - public CachedItemStack( final ItemStack is ) - { - if( is.isEmpty() ) - { - this.itemStack = ItemStack.EMPTY; - this.aeStack = null; - } - else - { - this.itemStack = is.copy(); - this.aeStack = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( is ); - } - } - } + public CachedItemStack(final ItemStack is) { + if (is.isEmpty()) { + this.itemStack = ItemStack.EMPTY; + this.aeStack = null; + } else { + this.itemStack = is.copy(); + this.aeStack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is); + } + } + } } diff --git a/src/main/java/appeng/me/storage/MEMonitorPassThrough.java b/src/main/java/appeng/me/storage/MEMonitorPassThrough.java index 4c189eaf2..a0d6a82f1 100644 --- a/src/main/java/appeng/me/storage/MEMonitorPassThrough.java +++ b/src/main/java/appeng/me/storage/MEMonitorPassThrough.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; @@ -34,134 +33,111 @@ import appeng.api.storage.data.IItemList; import appeng.util.Platform; import appeng.util.inv.ItemListIgnoreCrafting; +public class MEMonitorPassThrough> extends MEPassThrough + implements IMEMonitor, IMEMonitorHandlerReceiver { -public class MEMonitorPassThrough> extends MEPassThrough implements IMEMonitor, IMEMonitorHandlerReceiver -{ + private final HashMap, Object> listeners = new HashMap<>(); + private IActionSource changeSource; + private IMEMonitor monitor; - private final HashMap, Object> listeners = new HashMap<>(); - private IActionSource changeSource; - private IMEMonitor monitor; + public MEMonitorPassThrough(final IMEInventory i, final IStorageChannel channel) { + super(i, channel); + if (i instanceof IMEMonitor) { + this.monitor = (IMEMonitor) i; + } + } - public MEMonitorPassThrough( final IMEInventory i, final IStorageChannel channel ) - { - super( i, channel ); - if( i instanceof IMEMonitor ) - { - this.monitor = (IMEMonitor) i; - } - } + @Override + public void setInternal(final IMEInventory i) { + if (this.monitor != null) { + this.monitor.removeListener(this); + } - @Override - public void setInternal( final IMEInventory i ) - { - if( this.monitor != null ) - { - this.monitor.removeListener( this ); - } + this.monitor = null; + final IItemList before = this.getInternal() == null ? this.getWrappedChannel().createList() + : this.getInternal() + .getAvailableItems(new ItemListIgnoreCrafting(this.getWrappedChannel().createList())); - this.monitor = null; - final IItemList before = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal() - .getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) ); + super.setInternal(i); + if (i instanceof IMEMonitor) { + this.monitor = (IMEMonitor) i; + } - super.setInternal( i ); - if( i instanceof IMEMonitor ) - { - this.monitor = (IMEMonitor) i; - } + final IItemList after = this.getInternal() == null ? this.getWrappedChannel().createList() + : this.getInternal() + .getAvailableItems(new ItemListIgnoreCrafting(this.getWrappedChannel().createList())); - final IItemList after = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal() - .getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) ); + if (this.monitor != null) { + this.monitor.addListener(this, this.monitor); + } - if( this.monitor != null ) - { - this.monitor.addListener( this, this.monitor ); - } + Platform.postListChanges(before, after, this, this.getChangeSource()); + } - Platform.postListChanges( before, after, this, this.getChangeSource() ); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + super.getAvailableItems(new ItemListIgnoreCrafting(out)); + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - super.getAvailableItems( new ItemListIgnoreCrafting( out ) ); - return out; - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public IItemList getStorageList() { + if (this.monitor == null) { + final IItemList out = this.getWrappedChannel().createList(); + this.getInternal().getAvailableItems(new ItemListIgnoreCrafting(out)); + return out; + } + return this.monitor.getStorageList(); + } - @Override - public IItemList getStorageList() - { - if( this.monitor == null ) - { - final IItemList out = this.getWrappedChannel().createList(); - this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) ); - return out; - } - return this.monitor.getStorageList(); - } + @Override + public boolean isValid(final Object verificationToken) { + return verificationToken == this.monitor; + } - @Override - public boolean isValid( final Object verificationToken ) - { - return verificationToken == this.monitor; - } + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, final IActionSource source) { + final Iterator, Object>> i = this.listeners.entrySet().iterator(); + while (i.hasNext()) { + final Entry, Object> e = i.next(); + final IMEMonitorHandlerReceiver receiver = e.getKey(); + if (receiver.isValid(e.getValue())) { + receiver.postChange(this, change, source); + } else { + i.remove(); + } + } + } - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource source ) - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Entry, Object> e = i.next(); - final IMEMonitorHandlerReceiver receiver = e.getKey(); - if( receiver.isValid( e.getValue() ) ) - { - receiver.postChange( this, change, source ); - } - else - { - i.remove(); - } - } - } + @Override + public void onListUpdate() { + final Iterator, Object>> i = this.listeners.entrySet().iterator(); + while (i.hasNext()) { + final Entry, Object> e = i.next(); + final IMEMonitorHandlerReceiver receiver = e.getKey(); + if (receiver.isValid(e.getValue())) { + receiver.onListUpdate(); + } else { + i.remove(); + } + } + } - @Override - public void onListUpdate() - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Entry, Object> e = i.next(); - final IMEMonitorHandlerReceiver receiver = e.getKey(); - if( receiver.isValid( e.getValue() ) ) - { - receiver.onListUpdate(); - } - else - { - i.remove(); - } - } - } + private IActionSource getChangeSource() { + return this.changeSource; + } - private IActionSource getChangeSource() - { - return this.changeSource; - } - - public void setChangeSource( final IActionSource changeSource ) - { - this.changeSource = changeSource; - } + public void setChangeSource(final IActionSource changeSource) { + this.changeSource = changeSource; + } } diff --git a/src/main/java/appeng/me/storage/MEPassThrough.java b/src/main/java/appeng/me/storage/MEPassThrough.java index d9caa15f1..b5b40fff8 100644 --- a/src/main/java/appeng/me/storage/MEPassThrough.java +++ b/src/main/java/appeng/me/storage/MEPassThrough.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; import appeng.api.networking.security.IActionSource; @@ -28,91 +27,75 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public class MEPassThrough> implements IMEInventoryHandler { -public class MEPassThrough> implements IMEInventoryHandler -{ + private final IStorageChannel wrappedChannel; + private IMEInventory internal; - private final IStorageChannel wrappedChannel; - private IMEInventory internal; + public MEPassThrough(final IMEInventory i, final IStorageChannel channel) { + this.wrappedChannel = channel; + this.setInternal(i); + } - public MEPassThrough( final IMEInventory i, final IStorageChannel channel ) - { - this.wrappedChannel = channel; - this.setInternal( i ); - } + protected IMEInventory getInternal() { + return this.internal; + } - protected IMEInventory getInternal() - { - return this.internal; - } + public void setInternal(final IMEInventory i) { + this.internal = i; + } - public void setInternal( final IMEInventory i ) - { - this.internal = i; - } + @Override + public T injectItems(final T input, final Actionable type, final IActionSource src) { + return this.internal.injectItems(input, type, src); + } - @Override - public T injectItems( final T input, final Actionable type, final IActionSource src ) - { - return this.internal.injectItems( input, type, src ); - } + @Override + public T extractItems(final T request, final Actionable type, final IActionSource src) { + return this.internal.extractItems(request, type, src); + } - @Override - public T extractItems( final T request, final Actionable type, final IActionSource src ) - { - return this.internal.extractItems( request, type, src ); - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return this.internal.getAvailableItems(out); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return this.internal.getAvailableItems( out ); - } + @Override + public IStorageChannel getChannel() { + return this.internal.getChannel(); + } - @Override - public IStorageChannel getChannel() - { - return this.internal.getChannel(); - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final T input) { + return false; + } - @Override - public boolean isPrioritized( final T input ) - { - return false; - } + @Override + public boolean canAccept(final T input) { + return true; + } - @Override - public boolean canAccept( final T input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return true; + } - @Override - public boolean validForPass( final int i ) - { - return true; - } - - IStorageChannel getWrappedChannel() - { - return this.wrappedChannel; - } + IStorageChannel getWrappedChannel() { + return this.wrappedChannel; + } } diff --git a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java index 54ddd1047..4a19902b5 100644 --- a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java +++ b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Comparator; @@ -41,289 +40,239 @@ import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; import appeng.me.cache.SecurityCache; +public class NetworkInventoryHandler> implements IMEInventoryHandler { -public class NetworkInventoryHandler> implements IMEInventoryHandler -{ + private static final ThreadLocal DEPTH_MOD = new ThreadLocal<>(); + private static final ThreadLocal DEPTH_SIM = new ThreadLocal<>(); + private static final Comparator PRIORITY_SORTER = (o1, o2) -> Integer.compare(o2, o1); - private static final ThreadLocal DEPTH_MOD = new ThreadLocal<>(); - private static final ThreadLocal DEPTH_SIM = new ThreadLocal<>(); - private static final Comparator PRIORITY_SORTER = ( o1, o2 ) -> Integer.compare( o2, o1 ); + private static int currentPass = 0; + private final IStorageChannel myChannel; + private final SecurityCache security; + private final NavigableMap>> priorityInventory; + private int myPass = 0; - private static int currentPass = 0; - private final IStorageChannel myChannel; - private final SecurityCache security; - private final NavigableMap>> priorityInventory; - private int myPass = 0; + public NetworkInventoryHandler(final IStorageChannel chan, final SecurityCache security) { + this.myChannel = chan; + this.security = security; + this.priorityInventory = new TreeMap<>(PRIORITY_SORTER); + } - public NetworkInventoryHandler( final IStorageChannel chan, final SecurityCache security ) - { - this.myChannel = chan; - this.security = security; - this.priorityInventory = new TreeMap<>( PRIORITY_SORTER ); - } + public void addNewStorage(final IMEInventoryHandler h) { + final int priority = h.getPriority(); + List> list = this.priorityInventory.get(priority); + if (list == null) { + this.priorityInventory.put(priority, list = new ArrayList<>()); + } - public void addNewStorage( final IMEInventoryHandler h ) - { - final int priority = h.getPriority(); - List> list = this.priorityInventory.get( priority ); - if( list == null ) - { - this.priorityInventory.put( priority, list = new ArrayList<>() ); - } + list.add(h); + } - list.add( h ); - } + @Override + public T injectItems(T input, final Actionable type, final IActionSource src) { + if (this.diveList(this, type)) { + return input; + } - @Override - public T injectItems( T input, final Actionable type, final IActionSource src ) - { - if( this.diveList( this, type ) ) - { - return input; - } + if (this.testPermission(src, SecurityPermissions.INJECT)) { + this.surface(this, type); + return input; + } - if( this.testPermission( src, SecurityPermissions.INJECT ) ) - { - this.surface( this, type ); - return input; - } + for (final List> invList : this.priorityInventory.values()) { + Iterator> ii = invList.iterator(); + while (ii.hasNext() && input != null) { + final IMEInventoryHandler inv = ii.next(); - for( final List> invList : this.priorityInventory.values() ) - { - Iterator> ii = invList.iterator(); - while( ii.hasNext() && input != null ) - { - final IMEInventoryHandler inv = ii.next(); + if (inv.validForPass(1) && inv.canAccept(input) + && (inv.isPrioritized(input) || inv.extractItems(input, Actionable.SIMULATE, src) != null)) { + input = inv.injectItems(input, type, src); + } + } - if( inv.validForPass( 1 ) && inv - .canAccept( input ) && ( inv.isPrioritized( input ) || inv.extractItems( input, Actionable.SIMULATE, src ) != null ) ) - { - input = inv.injectItems( input, type, src ); - } - } + // We need to ignore prioritized inventories in the second pass. If they were + // not able to store everything + // during the first pass, they will do so in the second, but as this is + // stateless we will just report twice + // the amount of storable items. + // ignores craftingcache on the second pass. + ii = invList.iterator(); + while (ii.hasNext() && input != null) { + final IMEInventoryHandler inv = ii.next(); - // We need to ignore prioritized inventories in the second pass. If they were not able to store everything - // during the first pass, they will do so in the second, but as this is stateless we will just report twice - // the amount of storable items. - // ignores craftingcache on the second pass. - ii = invList.iterator(); - while( ii.hasNext() && input != null ) - { - final IMEInventoryHandler inv = ii.next(); + if (inv.validForPass(2) && inv.canAccept(input) && !inv.isPrioritized(input)) { + input = inv.injectItems(input, type, src); + } + } + } - if( inv.validForPass( 2 ) && inv.canAccept( input ) && !inv.isPrioritized( input ) ) - { - input = inv.injectItems( input, type, src ); - } - } - } + this.surface(this, type); - this.surface( this, type ); + return input; + } - return input; - } + private boolean diveList(final NetworkInventoryHandler networkInventoryHandler, final Actionable type) { + final Deque cDepth = this.getDepth(type); + if (cDepth.contains(networkInventoryHandler)) { + return true; + } - private boolean diveList( final NetworkInventoryHandler networkInventoryHandler, final Actionable type ) - { - final Deque cDepth = this.getDepth( type ); - if( cDepth.contains( networkInventoryHandler ) ) - { - return true; - } + cDepth.push(this); + return false; + } - cDepth.push( this ); - return false; - } + private boolean testPermission(final IActionSource src, final SecurityPermissions permission) { + if (src.player().isPresent()) { + if (!this.security.hasPermission(src.player().get(), permission)) { + return true; + } + } else if (src.machine().isPresent()) { + if (this.security.isAvailable()) { + final IGridNode n = src.machine().get().getActionableNode(); + if (n == null) { + return true; + } - private boolean testPermission( final IActionSource src, final SecurityPermissions permission ) - { - if( src.player().isPresent() ) - { - if( !this.security.hasPermission( src.player().get(), permission ) ) - { - return true; - } - } - else if( src.machine().isPresent() ) - { - if( this.security.isAvailable() ) - { - final IGridNode n = src.machine().get().getActionableNode(); - if( n == null ) - { - return true; - } + final IGrid gn = n.getGrid(); + if (gn != this.security.getGrid()) { - final IGrid gn = n.getGrid(); - if( gn != this.security.getGrid() ) - { + final ISecurityGrid sg = gn.getCache(ISecurityGrid.class); + final int playerID = sg.getOwner(); - final ISecurityGrid sg = gn.getCache( ISecurityGrid.class ); - final int playerID = sg.getOwner(); + if (!this.security.hasPermission(playerID, permission)) { + return true; + } + } + } + } - if( !this.security.hasPermission( playerID, permission ) ) - { - return true; - } - } - } - } + return false; + } - return false; - } + private void surface(final NetworkInventoryHandler networkInventoryHandler, final Actionable type) { + if (this.getDepth(type).pop() != this) { + throw new IllegalStateException("Invalid Access to Networked Storage API detected."); + } + } - private void surface( final NetworkInventoryHandler networkInventoryHandler, final Actionable type ) - { - if( this.getDepth( type ).pop() != this ) - { - throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); - } - } + private Deque getDepth(final Actionable type) { + final ThreadLocal depth = type == Actionable.MODULATE ? DEPTH_MOD : DEPTH_SIM; - private Deque getDepth( final Actionable type ) - { - final ThreadLocal depth = type == Actionable.MODULATE ? DEPTH_MOD : DEPTH_SIM; + Deque s = depth.get(); - Deque s = depth.get(); + if (s == null) { + depth.set(s = new ArrayDeque<>()); + } - if( s == null ) - { - depth.set( s = new ArrayDeque<>() ); - } + return s; + } - return s; - } + @Override + public T extractItems(T request, final Actionable mode, final IActionSource src) { + if (this.diveList(this, mode)) { + return null; + } - @Override - public T extractItems( T request, final Actionable mode, final IActionSource src ) - { - if( this.diveList( this, mode ) ) - { - return null; - } + if (this.testPermission(src, SecurityPermissions.EXTRACT)) { + this.surface(this, mode); + return null; + } - if( this.testPermission( src, SecurityPermissions.EXTRACT ) ) - { - this.surface( this, mode ); - return null; - } + final Iterator>> i = this.priorityInventory.descendingMap().values().iterator();// priorityInventory.asMap().descendingMap().entrySet().iterator(); - final Iterator>> i = this.priorityInventory.descendingMap().values().iterator();// priorityInventory.asMap().descendingMap().entrySet().iterator(); + final T output = request.copy(); + request = request.copy(); + output.setStackSize(0); + final long req = request.getStackSize(); - final T output = request.copy(); - request = request.copy(); - output.setStackSize( 0 ); - final long req = request.getStackSize(); + while (i.hasNext()) { + final List> invList = i.next(); - while( i.hasNext() ) - { - final List> invList = i.next(); + final Iterator> ii = invList.iterator(); + while (ii.hasNext() && output.getStackSize() < req) { + final IMEInventoryHandler inv = ii.next(); - final Iterator> ii = invList.iterator(); - while( ii.hasNext() && output.getStackSize() < req ) - { - final IMEInventoryHandler inv = ii.next(); + request.setStackSize(req - output.getStackSize()); + output.add(inv.extractItems(request, mode, src)); + } + } - request.setStackSize( req - output.getStackSize() ); - output.add( inv.extractItems( request, mode, src ) ); - } - } + this.surface(this, mode); - this.surface( this, mode ); + if (output.getStackSize() <= 0) { + return null; + } - if( output.getStackSize() <= 0 ) - { - return null; - } + return output; + } - return output; - } + @Override + public IItemList getAvailableItems(IItemList out) { + if (this.diveIteration(this, Actionable.SIMULATE)) { + return out; + } - @Override - public IItemList getAvailableItems( IItemList out ) - { - if( this.diveIteration( this, Actionable.SIMULATE ) ) - { - return out; - } + // for (Entry> h : priorityInventory.entries()) + for (final List> i : this.priorityInventory.values()) { + for (final IMEInventoryHandler j : i) { + out = j.getAvailableItems(out); + } + } - // for (Entry> h : priorityInventory.entries()) - for( final List> i : this.priorityInventory.values() ) - { - for( final IMEInventoryHandler j : i ) - { - out = j.getAvailableItems( out ); - } - } + this.surface(this, Actionable.SIMULATE); - this.surface( this, Actionable.SIMULATE ); + return out; + } - return out; - } + private boolean diveIteration(final NetworkInventoryHandler networkInventoryHandler, final Actionable type) { + final Deque cDepth = this.getDepth(type); + if (cDepth.isEmpty()) { + currentPass++; + this.myPass = currentPass; + } else { + if (currentPass == this.myPass) { + return true; + } else { + this.myPass = currentPass; + } + } - private boolean diveIteration( final NetworkInventoryHandler networkInventoryHandler, final Actionable type ) - { - final Deque cDepth = this.getDepth( type ); - if( cDepth.isEmpty() ) - { - currentPass++; - this.myPass = currentPass; - } - else - { - if( currentPass == this.myPass ) - { - return true; - } - else - { - this.myPass = currentPass; - } - } + cDepth.push(this); + return false; + } - cDepth.push( this ); - return false; - } + @Override + public IStorageChannel getChannel() { + return this.myChannel; + } - @Override - public IStorageChannel getChannel() - { - return this.myChannel; - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final T input) { + return false; + } - @Override - public boolean isPrioritized( final T input ) - { - return false; - } + @Override + public boolean canAccept(final T input) { + return true; + } - @Override - public boolean canAccept( final T input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } - - @Override - public boolean validForPass( final int i ) - { - return true; - } + @Override + public boolean validForPass(final int i) { + return true; + } } diff --git a/src/main/java/appeng/me/storage/NullInventory.java b/src/main/java/appeng/me/storage/NullInventory.java index 615a11f3f..4010f04f1 100644 --- a/src/main/java/appeng/me/storage/NullInventory.java +++ b/src/main/java/appeng/me/storage/NullInventory.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import appeng.api.AEApi; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; @@ -29,67 +28,55 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public class NullInventory> implements IMEInventoryHandler { -public class NullInventory> implements IMEInventoryHandler -{ + @Override + public T injectItems(final T input, final Actionable mode, final IActionSource src) { + return input; + } - @Override - public T injectItems( final T input, final Actionable mode, final IActionSource src ) - { - return input; - } + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + return null; + } - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - return null; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return out; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ; - } + @Override + public boolean isPrioritized(final T input) { + return false; + } - @Override - public boolean isPrioritized( final T input ) - { - return false; - } + @Override + public boolean canAccept(final T input) { + return false; + } - @Override - public boolean canAccept( final T input ) - { - return false; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } - - @Override - public boolean validForPass( final int i ) - { - return i == 2; - } + @Override + public boolean validForPass(final int i) { + return i == 2; + } } diff --git a/src/main/java/appeng/me/storage/SecurityStationInventory.java b/src/main/java/appeng/me/storage/SecurityStationInventory.java index b4b9fb23f..1d076e23c 100644 --- a/src/main/java/appeng/me/storage/SecurityStationInventory.java +++ b/src/main/java/appeng/me/storage/SecurityStationInventory.java @@ -18,7 +18,6 @@ package appeng.me.storage; - import com.mojang.authlib.GameProfile; import appeng.api.AEApi; @@ -35,165 +34,134 @@ import appeng.api.storage.data.IItemList; import appeng.me.GridAccessException; import appeng.tile.misc.TileSecurityStation; +public class SecurityStationInventory implements IMEInventoryHandler { -public class SecurityStationInventory implements IMEInventoryHandler -{ + private final IItemList storedItems = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + private final TileSecurityStation securityTile; - private final IItemList storedItems = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - private final TileSecurityStation securityTile; + public SecurityStationInventory(final TileSecurityStation ts) { + this.securityTile = ts; + } - public SecurityStationInventory( final TileSecurityStation ts ) - { - this.securityTile = ts; - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + if (this.hasPermission(src)) { + if (AEApi.instance().definitions().items().biometricCard().isSameAs(input.createItemStack())) { + if (this.canAccept(input)) { + if (type == Actionable.SIMULATE) { + return null; + } - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - if( this.hasPermission( src ) ) - { - if( AEApi.instance().definitions().items().biometricCard().isSameAs( input.createItemStack() ) ) - { - if( this.canAccept( input ) ) - { - if( type == Actionable.SIMULATE ) - { - return null; - } + this.getStoredItems().add(input); + this.securityTile.inventoryChanged(); + return null; + } + } + } + return input; + } - this.getStoredItems().add( input ); - this.securityTile.inventoryChanged(); - return null; - } - } - } - return input; - } + private boolean hasPermission(final IActionSource src) { + if (src.player().isPresent()) { + try { + return this.securityTile.getProxy().getSecurity().hasPermission(src.player().get(), + SecurityPermissions.SECURITY); + } catch (final GridAccessException e) { + // :P + } + } + return false; + } - private boolean hasPermission( final IActionSource src ) - { - if( src.player().isPresent() ) - { - try - { - return this.securityTile.getProxy().getSecurity().hasPermission( src.player().get(), SecurityPermissions.SECURITY ); - } - catch( final GridAccessException e ) - { - // :P - } - } - return false; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + if (this.hasPermission(src)) { + final IAEItemStack target = this.getStoredItems().findPrecise(request); + if (target != null) { + final IAEItemStack output = target.copy(); - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - if( this.hasPermission( src ) ) - { - final IAEItemStack target = this.getStoredItems().findPrecise( request ); - if( target != null ) - { - final IAEItemStack output = target.copy(); + if (mode == Actionable.SIMULATE) { + return output; + } - if( mode == Actionable.SIMULATE ) - { - return output; - } + target.setStackSize(0); + this.securityTile.inventoryChanged(); + return output; + } + } + return null; + } - target.setStackSize( 0 ); - this.securityTile.inventoryChanged(); - return output; - } - } - return null; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + for (final IAEItemStack ais : this.getStoredItems()) { + out.add(ais); + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - for( final IAEItemStack ais : this.getStoredItems() ) - { - out.add( ais ); - } + return out; + } - return out; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final IAEItemStack input) { + return false; + } - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - return false; - } + @Override + public boolean canAccept(final IAEItemStack input) { + if (input.getItem() instanceof IBiometricCard) { + final IBiometricCard tbc = (IBiometricCard) input.getItem(); + final GameProfile newUser = tbc.getProfile(input.createItemStack()); - @Override - public boolean canAccept( final IAEItemStack input ) - { - if( input.getItem() instanceof IBiometricCard ) - { - final IBiometricCard tbc = (IBiometricCard) input.getItem(); - final GameProfile newUser = tbc.getProfile( input.createItemStack() ); + final int PlayerID = AEApi.instance().registries().players().getID(newUser); + if (this.securityTile.getOwner() == PlayerID) { + return false; + } - final int PlayerID = AEApi.instance().registries().players().getID( newUser ); - if( this.securityTile.getOwner() == PlayerID ) - { - return false; - } + for (final IAEItemStack ais : this.getStoredItems()) { + if (ais.isMeaningful()) { + final GameProfile thisUser = tbc.getProfile(ais.createItemStack()); + if (thisUser == newUser) { + return false; + } - for( final IAEItemStack ais : this.getStoredItems() ) - { - if( ais.isMeaningful() ) - { - final GameProfile thisUser = tbc.getProfile( ais.createItemStack() ); - if( thisUser == newUser ) - { - return false; - } + if (thisUser != null && thisUser.equals(newUser)) { + return false; + } + } + } - if( thisUser != null && thisUser.equals( newUser ) ) - { - return false; - } - } - } + return true; + } + return false; + } - return true; - } - return false; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return true; + } - @Override - public boolean validForPass( final int i ) - { - return true; - } - - public IItemList getStoredItems() - { - return this.storedItems; - } + public IItemList getStoredItems() { + return this.storedItems; + } } diff --git a/src/main/java/appeng/parts/AEBasePart.java b/src/main/java/appeng/parts/AEBasePart.java index ffaa7ebfd..534b26d04 100644 --- a/src/main/java/appeng/parts/AEBasePart.java +++ b/src/main/java/appeng/parts/AEBasePart.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.io.IOException; import java.util.ArrayList; import java.util.EnumSet; @@ -77,471 +76,393 @@ import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.util.Platform; import appeng.util.SettingsFrom; - -public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject -{ - - private final AENetworkProxy proxy; - private final ItemStack is; - private TileEntity tile = null; - private IPartHost host = null; - private AEPartLocation side = null; - - public AEBasePart( final ItemStack is ) - { - Preconditions.checkNotNull( is ); - - this.is = is; - this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable ); - this.proxy.setValidSides( EnumSet.noneOf( Direction.class ) ); - } - - public IPartHost getHost() - { - return this.host; - } - - public PartType getType() - { - Item item = this.is.getItem(); - if (!(item instanceof ItemPart)) { - return PartType.INVALID_TYPE; - } - - return ((ItemPart) item).getType(); - } - - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - return this.proxy.getNode(); - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.GLASS; - } - - @Override - public void securityBreak() - { - if( this.getItemStack().getCount() > 0 && this.getGridNode() != null ) - { - final List items = new ArrayList<>(); - items.add( this.is.copy() ); - this.host.removePart( this.side, false ); - Platform.spawnDrops( this.tile.getWorld(), this.tile.getPos(), items ); - this.is.setCount( 0 ); - } - } - - protected AEColor getColor() - { - if( this.host == null ) - { - return AEColor.TRANSPARENT; - } - return this.host.getColor(); - } - - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - - } - - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return 0; - } - - @Override - public TileEntity getTile() - { - return this.tile; - } - - @Override - public AENetworkProxy getProxy() - { - return this.proxy; - } - - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this.tile ); - } - - @Override - public void gridChanged() - { - - } - - @Override - public IGridNode getActionableNode() - { - return this.proxy.getNode(); - } - - public void saveChanges() - { - this.host.markForSave(); - } - - @Override - public ITextComponent getCustomInventoryName() - { - return this.getItemStack().getDisplayName(); - } - - @Override - public boolean hasCustomInventoryName() - { - return this.getItemStack().hasDisplayName(); - } - - public void addEntityCrashInfo( final CrashReportCategory crashreportcategory ) - { - crashreportcategory.addDetail( "Part Side", this.getSide() ); - } - - @Override - public ItemStack getItemStack( final PartItemStack type ) - { - if( type == PartItemStack.NETWORK ) - { - final ItemStack copy = this.is.copy(); - copy.setTag( null ); - return copy; - } - return this.is; - } - - @Override - public boolean isSolid() - { - return false; - } - - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - - } - - @Override - public boolean canConnectRedstone() - { - return false; - } - - @Override - public void readFromNBT( final CompoundNBT data ) - { - this.proxy.readFromNBT( data ); - } - - @Override - public void writeToNBT( final CompoundNBT data ) - { - this.proxy.writeToNBT( data ); - } - - @Override - public int isProvidingStrongPower() - { - return 0; - } - - @Override - public int isProvidingWeakPower() - { - return 0; - } - - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - - } - - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - return false; - } - - @Override - public IGridNode getGridNode() - { - return this.proxy.getNode(); - } - - @Override - public void onEntityCollision( final Entity entity ) - { - - } - - @Override - public void removeFromWorld() - { - this.proxy.remove(); - } - - @Override - public void addToWorld() - { - this.proxy.onReady(); - } - - @Override - public void setPartHostInfo( final AEPartLocation side, final IPartHost host, final TileEntity tile ) - { - this.setSide( side ); - this.tile = tile; - this.host = host; - } - - @Override - public IGridNode getExternalFacingNode() - { - return null; - } - - @Override - @OnlyIn( Dist.CLIENT ) - public void animateTick( final World world, final BlockPos pos, final Random r ) - { - - } - - @Override - public int getLightLevel() - { - return 0; - } - - @Override - public void getDrops( final List drops, final boolean wrenched ) - { - - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 3; - } - - @Override - public boolean isLadder( final LivingEntity entity ) - { - return false; - } - - @Override - public IConfigManager getConfigManager() - { - return null; - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - return null; - } - - /** - * depending on the from, different settings will be accepted, don't call this with null - * - * @param from source of settings - * @param compound compound of source - */ - private void uploadSettings( final SettingsFrom from, final CompoundNBT compound ) - { - if( compound != null ) - { - final IConfigManager cm = this.getConfigManager(); - if( cm != null ) - { - cm.readFromNBT( compound ); - } - } - - if( this instanceof IPriorityHost ) - { - final IPriorityHost pHost = (IPriorityHost) this; - pHost.setPriority( compound.getInt( "priority" ) ); - } - - final IItemHandler inv = this.getInventoryByName( "config" ); - if( inv instanceof AppEngInternalAEInventory ) - { - final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv; - final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() ); - tmp.readFromNBT( compound, "config" ); - for( int x = 0; x < tmp.getSlots(); x++ ) - { - target.setStackInSlot( x, tmp.getStackInSlot( x ) ); - } - } - } - - /** - * null means nothing to store... - * - * @param from source of settings - * - * @return compound of source - */ - private CompoundNBT downloadSettings( final SettingsFrom from ) - { - final CompoundNBT output = new CompoundNBT(); - - final IConfigManager cm = this.getConfigManager(); - if( cm != null ) - { - cm.writeToNBT( output ); - } - - if( this instanceof IPriorityHost ) - { - final IPriorityHost pHost = (IPriorityHost) this; - output.putInt( "priority", pHost.getPriority() ); - } - - final IItemHandler inv = this.getInventoryByName( "config" ); - if( inv instanceof AppEngInternalAEInventory ) - { - ( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" ); - } - - return output.isEmpty() ? null : output; - } - - public boolean useStandardMemoryCard() - { - return true; - } - - private boolean useMemoryCard( final PlayerEntity player ) - { - final ItemStack memCardIS = player.inventory.getCurrentItem(); - - if( !memCardIS.isEmpty() && this.useStandardMemoryCard() && memCardIS.getItem() instanceof IMemoryCard ) - { - final IMemoryCard memoryCard = (IMemoryCard) memCardIS.getItem(); - - ItemStack is = this.getItemStack( PartItemStack.NETWORK ); - - // Blocks and parts share the same soul! - final IDefinitions definitions = AEApi.instance().definitions(); - if( definitions.parts().iface().isSameAs( is ) ) - { - Optional iface = definitions.blocks().iface().maybeStack( 1 ); - if( iface.isPresent() ) - { - is = iface.get(); - } - } - - final String name = is.getTranslationKey(); - - if( player.isCrouching() ) - { - final CompoundNBT data = this.downloadSettings( SettingsFrom.MEMORY_CARD ); - if( data != null ) - { - memoryCard.setMemoryCardContents( memCardIS, name, data ); - memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); - } - } - else - { - final String storedName = memoryCard.getSettingsName( memCardIS ); - final CompoundNBT data = memoryCard.getData( memCardIS ); - if( name.equals( storedName ) ) - { - this.uploadSettings( SettingsFrom.MEMORY_CARD, data ); - memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); - } - else - { - memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE ); - } - } - return true; - } - return false; - } - - @Override - public final boolean onActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( this.useMemoryCard( player ) ) - { - return true; - } - - return this.onPartActivate( player, hand, pos ); - } - - @Override - public final boolean onShiftActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( this.useMemoryCard( player ) ) - { - return true; - } - - return this.onPartShiftActivate( player, hand, pos ); - } - - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - return false; - } - - public boolean onPartShiftActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - return false; - } - - @Override - public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { - this.proxy.setOwner( player ); - } - - @Override - public boolean canBePlacedOn( final BusSupport what ) - { - return what == BusSupport.CABLE; - } - - @Override - public boolean requireDynamicRender() - { - return false; - } - - public AEPartLocation getSide() - { - return this.side; - } - - private void setSide( final AEPartLocation side ) - { - this.side = side; - } - - public ItemStack getItemStack() - { - return this.is; - } +public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject { + + private final AENetworkProxy proxy; + private final ItemStack is; + private TileEntity tile = null; + private IPartHost host = null; + private AEPartLocation side = null; + + public AEBasePart(final ItemStack is) { + Preconditions.checkNotNull(is); + + this.is = is; + this.proxy = new AENetworkProxy(this, "part", is, this instanceof PartCable); + this.proxy.setValidSides(EnumSet.noneOf(Direction.class)); + } + + public IPartHost getHost() { + return this.host; + } + + public PartType getType() { + Item item = this.is.getItem(); + if (!(item instanceof ItemPart)) { + return PartType.INVALID_TYPE; + } + + return ((ItemPart) item).getType(); + } + + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + return this.proxy.getNode(); + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.GLASS; + } + + @Override + public void securityBreak() { + if (this.getItemStack().getCount() > 0 && this.getGridNode() != null) { + final List items = new ArrayList<>(); + items.add(this.is.copy()); + this.host.removePart(this.side, false); + Platform.spawnDrops(this.tile.getWorld(), this.tile.getPos(), items); + this.is.setCount(0); + } + } + + protected AEColor getColor() { + if (this.host == null) { + return AEColor.TRANSPARENT; + } + return this.host.getColor(); + } + + @Override + public void getBoxes(final IPartCollisionHelper bch) { + + } + + @Override + public int getInstalledUpgrades(final Upgrades u) { + return 0; + } + + @Override + public TileEntity getTile() { + return this.tile; + } + + @Override + public AENetworkProxy getProxy() { + return this.proxy; + } + + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this.tile); + } + + @Override + public void gridChanged() { + + } + + @Override + public IGridNode getActionableNode() { + return this.proxy.getNode(); + } + + public void saveChanges() { + this.host.markForSave(); + } + + @Override + public ITextComponent getCustomInventoryName() { + return this.getItemStack().getDisplayName(); + } + + @Override + public boolean hasCustomInventoryName() { + return this.getItemStack().hasDisplayName(); + } + + public void addEntityCrashInfo(final CrashReportCategory crashreportcategory) { + crashreportcategory.addDetail("Part Side", this.getSide()); + } + + @Override + public ItemStack getItemStack(final PartItemStack type) { + if (type == PartItemStack.NETWORK) { + final ItemStack copy = this.is.copy(); + copy.setTag(null); + return copy; + } + return this.is; + } + + @Override + public boolean isSolid() { + return false; + } + + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + + } + + @Override + public boolean canConnectRedstone() { + return false; + } + + @Override + public void readFromNBT(final CompoundNBT data) { + this.proxy.readFromNBT(data); + } + + @Override + public void writeToNBT(final CompoundNBT data) { + this.proxy.writeToNBT(data); + } + + @Override + public int isProvidingStrongPower() { + return 0; + } + + @Override + public int isProvidingWeakPower() { + return 0; + } + + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + + } + + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + return false; + } + + @Override + public IGridNode getGridNode() { + return this.proxy.getNode(); + } + + @Override + public void onEntityCollision(final Entity entity) { + + } + + @Override + public void removeFromWorld() { + this.proxy.remove(); + } + + @Override + public void addToWorld() { + this.proxy.onReady(); + } + + @Override + public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final TileEntity tile) { + this.setSide(side); + this.tile = tile; + this.host = host; + } + + @Override + public IGridNode getExternalFacingNode() { + return null; + } + + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(final World world, final BlockPos pos, final Random r) { + + } + + @Override + public int getLightLevel() { + return 0; + } + + @Override + public void getDrops(final List drops, final boolean wrenched) { + + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 3; + } + + @Override + public boolean isLadder(final LivingEntity entity) { + return false; + } + + @Override + public IConfigManager getConfigManager() { + return null; + } + + @Override + public IItemHandler getInventoryByName(final String name) { + return null; + } + + /** + * depending on the from, different settings will be accepted, don't call this + * with null + * + * @param from source of settings + * @param compound compound of source + */ + private void uploadSettings(final SettingsFrom from, final CompoundNBT compound) { + if (compound != null) { + final IConfigManager cm = this.getConfigManager(); + if (cm != null) { + cm.readFromNBT(compound); + } + } + + if (this instanceof IPriorityHost) { + final IPriorityHost pHost = (IPriorityHost) this; + pHost.setPriority(compound.getInt("priority")); + } + + final IItemHandler inv = this.getInventoryByName("config"); + if (inv instanceof AppEngInternalAEInventory) { + final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv; + final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory(null, target.getSlots()); + tmp.readFromNBT(compound, "config"); + for (int x = 0; x < tmp.getSlots(); x++) { + target.setStackInSlot(x, tmp.getStackInSlot(x)); + } + } + } + + /** + * null means nothing to store... + * + * @param from source of settings + * + * @return compound of source + */ + private CompoundNBT downloadSettings(final SettingsFrom from) { + final CompoundNBT output = new CompoundNBT(); + + final IConfigManager cm = this.getConfigManager(); + if (cm != null) { + cm.writeToNBT(output); + } + + if (this instanceof IPriorityHost) { + final IPriorityHost pHost = (IPriorityHost) this; + output.putInt("priority", pHost.getPriority()); + } + + final IItemHandler inv = this.getInventoryByName("config"); + if (inv instanceof AppEngInternalAEInventory) { + ((AppEngInternalAEInventory) inv).writeToNBT(output, "config"); + } + + return output.isEmpty() ? null : output; + } + + public boolean useStandardMemoryCard() { + return true; + } + + private boolean useMemoryCard(final PlayerEntity player) { + final ItemStack memCardIS = player.inventory.getCurrentItem(); + + if (!memCardIS.isEmpty() && this.useStandardMemoryCard() && memCardIS.getItem() instanceof IMemoryCard) { + final IMemoryCard memoryCard = (IMemoryCard) memCardIS.getItem(); + + ItemStack is = this.getItemStack(PartItemStack.NETWORK); + + // Blocks and parts share the same soul! + final IDefinitions definitions = AEApi.instance().definitions(); + if (definitions.parts().iface().isSameAs(is)) { + Optional iface = definitions.blocks().iface().maybeStack(1); + if (iface.isPresent()) { + is = iface.get(); + } + } + + final String name = is.getTranslationKey(); + + if (player.isCrouching()) { + final CompoundNBT data = this.downloadSettings(SettingsFrom.MEMORY_CARD); + if (data != null) { + memoryCard.setMemoryCardContents(memCardIS, name, data); + memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED); + } + } else { + final String storedName = memoryCard.getSettingsName(memCardIS); + final CompoundNBT data = memoryCard.getData(memCardIS); + if (name.equals(storedName)) { + this.uploadSettings(SettingsFrom.MEMORY_CARD, data); + memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED); + } else { + memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE); + } + } + return true; + } + return false; + } + + @Override + public final boolean onActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (this.useMemoryCard(player)) { + return true; + } + + return this.onPartActivate(player, hand, pos); + } + + @Override + public final boolean onShiftActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (this.useMemoryCard(player)) { + return true; + } + + return this.onPartShiftActivate(player, hand, pos); + } + + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + return false; + } + + public boolean onPartShiftActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + return false; + } + + @Override + public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { + this.proxy.setOwner(player); + } + + @Override + public boolean canBePlacedOn(final BusSupport what) { + return what == BusSupport.CABLE; + } + + @Override + public boolean requireDynamicRender() { + return false; + } + + public AEPartLocation getSide() { + return this.side; + } + + private void setSide(final AEPartLocation side) { + this.side = side; + } + + public ItemStack getItemStack() { + return this.is; + } } diff --git a/src/main/java/appeng/parts/BusCollisionHelper.java b/src/main/java/appeng/parts/BusCollisionHelper.java index 353449040..2078abda4 100644 --- a/src/main/java/appeng/parts/BusCollisionHelper.java +++ b/src/main/java/appeng/parts/BusCollisionHelper.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.util.List; import net.minecraft.entity.Entity; @@ -28,151 +27,139 @@ import net.minecraft.util.math.AxisAlignedBB; import appeng.api.parts.IPartCollisionHelper; import appeng.api.util.AEPartLocation; +public class BusCollisionHelper implements IPartCollisionHelper { -public class BusCollisionHelper implements IPartCollisionHelper -{ + private final List boxes; - private final List boxes; + private final Direction x; + private final Direction y; + private final Direction z; - private final Direction x; - private final Direction y; - private final Direction z; + private final Entity entity; + private final boolean isVisual; - private final Entity entity; - private final boolean isVisual; + public BusCollisionHelper(final List boxes, final Direction x, final Direction y, final Direction z, + final Entity e, final boolean visual) { + this.boxes = boxes; + this.x = x; + this.y = y; + this.z = z; + this.entity = e; + this.isVisual = visual; + } - public BusCollisionHelper( final List boxes, final Direction x, final Direction y, final Direction z, final Entity e, final boolean visual ) - { - this.boxes = boxes; - this.x = x; - this.y = y; - this.z = z; - this.entity = e; - this.isVisual = visual; - } + public BusCollisionHelper(final List boxes, final AEPartLocation s, final Entity e, + final boolean visual) { + this.boxes = boxes; + this.entity = e; + this.isVisual = visual; - public BusCollisionHelper( final List boxes, final AEPartLocation s, final Entity e, final boolean visual ) - { - this.boxes = boxes; - this.entity = e; - this.isVisual = visual; + switch (s) { + case DOWN: + this.x = Direction.EAST; + this.y = Direction.NORTH; + this.z = Direction.DOWN; + break; + case UP: + this.x = Direction.EAST; + this.y = Direction.SOUTH; + this.z = Direction.UP; + break; + case EAST: + this.x = Direction.SOUTH; + this.y = Direction.UP; + this.z = Direction.EAST; + break; + case WEST: + this.x = Direction.NORTH; + this.y = Direction.UP; + this.z = Direction.WEST; + break; + case NORTH: + this.x = Direction.WEST; + this.y = Direction.UP; + this.z = Direction.NORTH; + break; + case SOUTH: + this.x = Direction.EAST; + this.y = Direction.UP; + this.z = Direction.SOUTH; + break; + case INTERNAL: + default: + this.x = Direction.EAST; + this.y = Direction.UP; + this.z = Direction.SOUTH; + break; + } + } - switch( s ) - { - case DOWN: - this.x = Direction.EAST; - this.y = Direction.NORTH; - this.z = Direction.DOWN; - break; - case UP: - this.x = Direction.EAST; - this.y = Direction.SOUTH; - this.z = Direction.UP; - break; - case EAST: - this.x = Direction.SOUTH; - this.y = Direction.UP; - this.z = Direction.EAST; - break; - case WEST: - this.x = Direction.NORTH; - this.y = Direction.UP; - this.z = Direction.WEST; - break; - case NORTH: - this.x = Direction.WEST; - this.y = Direction.UP; - this.z = Direction.NORTH; - break; - case SOUTH: - this.x = Direction.EAST; - this.y = Direction.UP; - this.z = Direction.SOUTH; - break; - case INTERNAL: - default: - this.x = Direction.EAST; - this.y = Direction.UP; - this.z = Direction.SOUTH; - break; - } - } + /** + * pretty much useless... + */ + public Entity getEntity() { + return this.entity; + } - /** - * pretty much useless... - */ - public Entity getEntity() - { - return this.entity; - } + @Override + public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + minX /= 16.0; + minY /= 16.0; + minZ /= 16.0; + maxX /= 16.0; + maxY /= 16.0; + maxZ /= 16.0; - @Override - public void addBox( double minX, double minY, double minZ, double maxX, double maxY, double maxZ ) - { - minX /= 16.0; - minY /= 16.0; - minZ /= 16.0; - maxX /= 16.0; - maxY /= 16.0; - maxZ /= 16.0; + double aX = minX * this.x.getXOffset() + minY * this.y.getXOffset() + minZ * this.z.getXOffset(); + double aY = minX * this.x.getYOffset() + minY * this.y.getYOffset() + minZ * this.z.getYOffset(); + double aZ = minX * this.x.getZOffset() + minY * this.y.getZOffset() + minZ * this.z.getZOffset(); - double aX = minX * this.x.getXOffset() + minY * this.y.getXOffset() + minZ * this.z.getXOffset(); - double aY = minX * this.x.getYOffset() + minY * this.y.getYOffset() + minZ * this.z.getYOffset(); - double aZ = minX * this.x.getZOffset() + minY * this.y.getZOffset() + minZ * this.z.getZOffset(); + double bX = maxX * this.x.getXOffset() + maxY * this.y.getXOffset() + maxZ * this.z.getXOffset(); + double bY = maxX * this.x.getYOffset() + maxY * this.y.getYOffset() + maxZ * this.z.getYOffset(); + double bZ = maxX * this.x.getZOffset() + maxY * this.y.getZOffset() + maxZ * this.z.getZOffset(); - double bX = maxX * this.x.getXOffset() + maxY * this.y.getXOffset() + maxZ * this.z.getXOffset(); - double bY = maxX * this.x.getYOffset() + maxY * this.y.getYOffset() + maxZ * this.z.getYOffset(); - double bZ = maxX * this.x.getZOffset() + maxY * this.y.getZOffset() + maxZ * this.z.getZOffset(); + if (this.x.getXOffset() + this.y.getXOffset() + this.z.getXOffset() < 0) { + aX += 1; + bX += 1; + } - if( this.x.getXOffset() + this.y.getXOffset() + this.z.getXOffset() < 0 ) - { - aX += 1; - bX += 1; - } + if (this.x.getYOffset() + this.y.getYOffset() + this.z.getYOffset() < 0) { + aY += 1; + bY += 1; + } - if( this.x.getYOffset() + this.y.getYOffset() + this.z.getYOffset() < 0 ) - { - aY += 1; - bY += 1; - } + if (this.x.getZOffset() + this.y.getZOffset() + this.z.getZOffset() < 0) { + aZ += 1; + bZ += 1; + } - if( this.x.getZOffset() + this.y.getZOffset() + this.z.getZOffset() < 0 ) - { - aZ += 1; - bZ += 1; - } + minX = Math.min(aX, bX); + minY = Math.min(aY, bY); + minZ = Math.min(aZ, bZ); + maxX = Math.max(aX, bX); + maxY = Math.max(aY, bY); + maxZ = Math.max(aZ, bZ); - minX = Math.min( aX, bX ); - minY = Math.min( aY, bY ); - minZ = Math.min( aZ, bZ ); - maxX = Math.max( aX, bX ); - maxY = Math.max( aY, bY ); - maxZ = Math.max( aZ, bZ ); + this.boxes.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ)); + } - this.boxes.add( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); - } + @Override + public Direction getWorldX() { + return this.x; + } - @Override - public Direction getWorldX() - { - return this.x; - } + @Override + public Direction getWorldY() { + return this.y; + } - @Override - public Direction getWorldY() - { - return this.y; - } + @Override + public Direction getWorldZ() { + return this.z; + } - @Override - public Direction getWorldZ() - { - return this.z; - } - - @Override - public boolean isBBCollision() - { - return !this.isVisual; - } + @Override + public boolean isBBCollision() { + return !this.isVisual; + } } diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index 4728357f4..1d5a7a717 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -18,13 +18,13 @@ package appeng.parts; - import java.io.IOException; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Random; import java.util.Set; + import javax.annotation.Nullable; import net.minecraft.block.BlockState; @@ -73,1225 +73,1005 @@ import appeng.me.GridConnection; import appeng.parts.networking.PartCable; import appeng.util.Platform; - -public class CableBusContainer extends CableBusStorage implements AEMultiTile, ICableBusContainer -{ - - private static final ThreadLocal IS_LOADING = new ThreadLocal<>(); - private final EnumSet myLayerFlags = EnumSet.noneOf( LayerFlags.class ); - private YesNo hasRedstone = YesNo.UNDECIDED; - private IPartHost tcb; - // TODO 1.10.2-R - does somebody seriously want to make parts TESR??? Hope not. - private boolean requiresDynamicRender = false; - private boolean inWorld = false; - - public CableBusContainer( final IPartHost host ) - { - this.tcb = host; - } - - public static boolean isLoading() - { - final Boolean is = IS_LOADING.get(); - return is != null && is; - } - - public void setHost( final IPartHost host ) - { - this.tcb.clearContainer(); - this.tcb = host; - } - - public void rotateLeft() - { - final IPart[] newSides = new IPart[6]; - - newSides[AEPartLocation.UP.ordinal()] = this.getSide( AEPartLocation.UP ); - newSides[AEPartLocation.DOWN.ordinal()] = this.getSide( AEPartLocation.DOWN ); - - newSides[AEPartLocation.EAST.ordinal()] = this.getSide( AEPartLocation.NORTH ); - newSides[AEPartLocation.SOUTH.ordinal()] = this.getSide( AEPartLocation.EAST ); - newSides[AEPartLocation.WEST.ordinal()] = this.getSide( AEPartLocation.SOUTH ); - newSides[AEPartLocation.NORTH.ordinal()] = this.getSide( AEPartLocation.WEST ); - - for( final AEPartLocation dir : AEPartLocation.SIDE_LOCATIONS ) - { - this.setSide( dir, newSides[dir.ordinal()] ); - } - - this.getFacadeContainer().rotateLeft(); - } - - @Override - public IFacadeContainer getFacadeContainer() - { - return new FacadeContainer( this ); - } - - @Override - public boolean canAddPart( ItemStack is, final AEPartLocation side ) - { - if( PartPlacement.isFacade( is, side ) != null ) - { - return true; - } - - if( is.getItem() instanceof IPartItem ) - { - final IPartItem bi = (IPartItem) is.getItem(); - - is = is.copy(); - is.setCount( 1 ); - - final IPart bp = bi.createPart(is); - if( bp != null ) - { - if( bp instanceof IPartCable ) - { - boolean canPlace = true; - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - if( this.getPart( d ) != null && !this.getPart( d ).canBePlacedOn( ( (IPartCable) bp ).supportsBuses() ) ) - { - canPlace = false; - } - } - - if( !canPlace ) - { - return false; - } - - return this.getPart( AEPartLocation.INTERNAL ) == null; - } - else if( !( bp instanceof IPartCable ) && side != AEPartLocation.INTERNAL ) - { - final IPart cable = this.getPart( AEPartLocation.INTERNAL ); - if( cable != null && !bp.canBePlacedOn( ( (IPartCable) cable ).supportsBuses() ) ) - { - return false; - } - - return this.getPart( side ) == null; - } - } - } - return false; - } - - @Override - public AEPartLocation addPart( ItemStack is, final AEPartLocation side, final @Nullable PlayerEntity player, final @Nullable Hand hand ) - { - if( this.canAddPart( is, side ) ) - { - if( is.getItem() instanceof IPartItem ) - { - final IPartItem bi = (IPartItem) is.getItem(); - - is = is.copy(); - is.setCount( 1 ); - - final IPart bp = bi.createPart(is); - if( bp instanceof IPartCable ) - { - boolean canPlace = true; - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - if( this.getPart( d ) != null && !this.getPart( d ).canBePlacedOn( ( (IPartCable) bp ).supportsBuses() ) ) - { - canPlace = false; - } - } - - if( !canPlace ) - { - return null; - } - - if( this.getPart( AEPartLocation.INTERNAL ) != null ) - { - return null; - } - - this.setCenter( (IPartCable) bp ); - bp.setPartHostInfo( AEPartLocation.INTERNAL, this, this.tcb.getTile() ); - - if( player != null ) - { - bp.onPlacement( player, hand, is, side ); - } - - if( this.inWorld ) - { - bp.addToWorld(); - } - - final IGridNode cn = this.getCenter().getGridNode(); - if( cn != null ) - { - for( final AEPartLocation ins : AEPartLocation.SIDE_LOCATIONS ) - { - final IPart sbp = this.getPart( ins ); - if( sbp != null ) - { - final IGridNode sn = sbp.getGridNode(); - if( sn != null ) - { - try - { - GridConnection.create( cn, sn, AEPartLocation.INTERNAL ); - } - catch( final FailedConnectionException e ) - { - AELog.debug( e ); - - bp.removeFromWorld(); - this.setCenter( null ); - return null; - } - } - } - } - } - - this.updateConnections(); - this.markForUpdate(); - this.markForSave(); - this.partChanged(); - return AEPartLocation.INTERNAL; - } - else if( bp != null && !( bp instanceof IPartCable ) && side != AEPartLocation.INTERNAL ) - { - final IPart cable = this.getPart( AEPartLocation.INTERNAL ); - if( cable != null && !bp.canBePlacedOn( ( (IPartCable) cable ).supportsBuses() ) ) - { - return null; - } - - this.setSide( side, bp ); - bp.setPartHostInfo( side, this, this.getTile() ); - - if( player != null ) - { - bp.onPlacement( player, hand, is, side ); - } - - if( this.inWorld ) - { - bp.addToWorld(); - } - - if( this.getCenter() != null ) - { - final IGridNode cn = this.getCenter().getGridNode(); - final IGridNode sn = bp.getGridNode(); - - if( cn != null && sn != null ) - { - try - { - GridConnection.create( cn, sn, AEPartLocation.INTERNAL ); - } - catch( final FailedConnectionException e ) - { - AELog.debug( e ); - - bp.removeFromWorld(); - this.setSide( side, null ); - return null; - } - } - } - - this.updateDynamicRender(); - this.updateConnections(); - this.markForUpdate(); - this.markForSave(); - this.partChanged(); - return side; - } - } - } - return null; - } - - @Override - public IPart getPart( final AEPartLocation partLocation ) - { - if( partLocation == AEPartLocation.INTERNAL ) - { - return this.getCenter(); - } - return this.getSide( partLocation ); - } - - @Override - public IPart getPart( final Direction side ) - { - return this.getSide( AEPartLocation.fromFacing( side ) ); - } - - @Override - public void removePart( final AEPartLocation side, final boolean suppressUpdate ) - { - if( side == AEPartLocation.INTERNAL ) - { - if( this.getCenter() != null ) - { - this.getCenter().removeFromWorld(); - } - this.setCenter( null ); - } - else - { - if( this.getSide( side ) != null ) - { - this.getSide( side ).removeFromWorld(); - } - this.setSide( side, null ); - } - - if( !suppressUpdate ) - { - this.updateDynamicRender(); - this.updateConnections(); - this.markForUpdate(); - this.markForSave(); - this.partChanged(); - } - } - - @Override - public void markForUpdate() - { - this.tcb.markForUpdate(); - } - - @Override - public DimensionalCoord getLocation() - { - return this.tcb.getLocation(); - } - - @Override - public TileEntity getTile() - { - return this.tcb.getTile(); - } - - @Override - public AEColor getColor() - { - if( this.getCenter() != null ) - { - final IPartCable c = this.getCenter(); - return c.getCableColor(); - } - return AEColor.TRANSPARENT; - } - - @Override - public void clearContainer() - { - throw new UnsupportedOperationException( "Now that is silly!" ); - } - - @Override - public boolean isBlocked( final Direction side ) - { - return this.tcb.isBlocked( side ); - } - - @Override - public SelectedPart selectPart( final Vec3d pos ) - { - for( final AEPartLocation side : AEPartLocation.values() ) - { - final IPart p = this.getPart( side ); - if( p != null ) - { - final List boxes = new ArrayList<>(); - - final IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true ); - p.getBoxes( bch ); - for( AxisAlignedBB bb : boxes ) - { - bb = bb.grow( 0.002, 0.002, 0.002 ); - if( bb.contains( pos ) ) - { - return new SelectedPart( p, side ); - } - } - } - } - - if( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades ) - { - final IFacadeContainer fc = this.getFacadeContainer(); - for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS ) - { - final IFacadePart p = fc.getFacade( side ); - if( p != null ) - { - final List boxes = new ArrayList<>(); - - final IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true ); - p.getBoxes( bch, null ); - for( AxisAlignedBB bb : boxes ) - { - bb = bb.grow( 0.01, 0.01, 0.01 ); - if( bb.contains( pos ) ) - { - return new SelectedPart( p, side ); - } - } - } - } - } - - return new SelectedPart(); - } - - @Override - public void markForSave() - { - this.tcb.markForSave(); - } - - @Override - public void partChanged() - { - if( this.getCenter() == null ) - { - final List facades = new ArrayList<>(); - - final IFacadeContainer fc = this.getFacadeContainer(); - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - final IFacadePart fp = fc.getFacade( d ); - if( fp != null ) - { - facades.add( fp.getItemStack() ); - fc.removeFacade( this.tcb, d ); - } - } - - if( !facades.isEmpty() ) - { - final TileEntity te = this.tcb.getTile(); - Platform.spawnDrops( te.getWorld(), te.getPos(), facades ); - } - } - - this.tcb.partChanged(); - } - - @Override - public boolean hasRedstone( final AEPartLocation side ) - { - if( this.hasRedstone == YesNo.UNDECIDED ) - { - this.updateRedstone(); - } - - return this.hasRedstone == YesNo.YES; - } - - @Override - public boolean isEmpty() - { - final IFacadeContainer fc = this.getFacadeContainer(); - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - return false; - } - - if( s != AEPartLocation.INTERNAL ) - { - final IFacadePart fp = fc.getFacade( s ); - if( fp != null ) - { - return false; - } - } - } - return true; - } - - @Override - public Set getLayerFlags() - { - return this.myLayerFlags; - } - - @Override - public void cleanup() - { - this.tcb.cleanup(); - } - - @Override - public void notifyNeighbors() - { - this.tcb.notifyNeighbors(); - } - - @Override - public boolean isInWorld() - { - return this.inWorld; - } - - private void updateRedstone() - { - final TileEntity te = this.getTile(); - this.hasRedstone = te.getWorld().getRedstonePowerFromNeighbors( te.getPos() ) != 0 ? YesNo.YES : YesNo.NO; - } - - private void updateDynamicRender() - { - this.requiresDynamicRender = false; - for( final AEPartLocation s : AEPartLocation.SIDE_LOCATIONS ) - { - final IPart p = this.getPart( s ); - if( p != null ) - { - this.setRequiresDynamicRender( this.isRequiresDynamicRender() || p.requireDynamicRender() ); - } - } - } - - /** - * use for FMP - */ - public void updateConnections() - { - if( this.getCenter() != null ) - { - final EnumSet sides = EnumSet.allOf( Direction.class ); - - for( final Direction s : Direction.values() ) - { - if( this.getPart( s ) != null || this.isBlocked( s ) ) - { - sides.remove( s ); - } - } - - this.getCenter().setValidSides( sides ); - final IGridNode n = this.getCenter().getGridNode(); - if( n != null ) - { - n.updateState(); - } - } - } - - public void addToWorld() - { - if( this.inWorld ) - { - return; - } - - this.inWorld = true; - IS_LOADING.set( true ); - - final TileEntity te = this.getTile(); - - // start with the center, then install the side parts into the grid. - for( int x = 6; x >= 0; x-- ) - { - final AEPartLocation s = AEPartLocation.fromOrdinal( x ); - final IPart part = this.getPart( s ); - - if( part != null ) - { - part.setPartHostInfo( s, this, te ); - part.addToWorld(); - - if( s != AEPartLocation.INTERNAL ) - { - final IGridNode sn = part.getGridNode(); - if( sn != null ) - { - // this is a really stupid if statement, why was this - // here? - // if ( !sn.getConnections().iterator().hasNext() ) - - final IPart center = this.getPart( AEPartLocation.INTERNAL ); - if( center != null ) - { - final IGridNode cn = center.getGridNode(); - if( cn != null ) - { - try - { - AEApi.instance().grid().createGridConnection( cn, sn ); - } - catch( final FailedConnectionException e ) - { - // ekk - AELog.debug( e ); - } - } - } - } - } - } - } - - this.partChanged(); - - IS_LOADING.set( false ); - } - - public void removeFromWorld() - { - if( !this.inWorld ) - { - return; - } - - this.inWorld = false; - - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - part.removeFromWorld(); - } - } - - this.partChanged(); - } - - @Override - public IGridNode getGridNode( final AEPartLocation side ) - { - final IPart part = this.getPart( side ); - if( part != null ) - { - final IGridNode n = part.getExternalFacingNode(); - if( n != null ) - { - return n; - } - } - - if( this.getCenter() != null ) - { - return this.getCenter().getGridNode(); - } - - return null; - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - final IPart part = this.getPart( dir ); - if( part instanceof IGridHost ) - { - final AECableType t = ( (IGridHost) part ).getCableConnectionType( dir ); - if( t != null && t != AECableType.NONE ) - { - return t; - } - } - - if( this.getCenter() != null ) - { - final IPartCable c = this.getCenter(); - return c.getCableConnectionType(); - } - return AECableType.NONE; - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return this.getPart( AEPartLocation.INTERNAL ) instanceof IPartCable ? this.getPart( AEPartLocation.INTERNAL ).getCableConnectionLength( cable ) : -1; - } - - @Override - public void securityBreak() - { - for( final AEPartLocation d : AEPartLocation.values() ) - { - final IPart p = this.getPart( d ); - if( p instanceof IGridHost ) - { - ( (IGridHost) p ).securityBreak(); - } - } - } - - public Iterable getSelectedBoundingBoxesFromPool( final boolean ignoreConnections, final boolean includeFacades, final Entity e, final boolean visual ) - { - final List boxes = new ArrayList<>(); - - final IFacadeContainer fc = this.getFacadeContainer(); - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPartCollisionHelper bch = new BusCollisionHelper( boxes, s, e, visual ); - - final IPart part = this.getPart( s ); - if( part != null ) - { - if( ignoreConnections && part instanceof IPartCable ) - { - bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 ); - } - else - { - part.getBoxes( bch ); - } - } - - if( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades || !visual ) - { - if( includeFacades && s != null && s != AEPartLocation.INTERNAL ) - { - final IFacadePart fp = fc.getFacade( s ); - if( fp != null ) - { - fp.getBoxes( bch, e ); - } - } - } - } - - return boxes; - } - - @Override - public int isProvidingStrongPower( final Direction side ) - { - final IPart part = this.getPart( side ); - return part != null ? part.isProvidingStrongPower() : 0; - } - - @Override - public int isProvidingWeakPower( final Direction side ) - { - final IPart part = this.getPart( side ); - return part != null ? part.isProvidingWeakPower() : 0; - } - - @Override - public boolean canConnectRedstone( final EnumSet enumSet ) - { - for( final Direction dir : enumSet ) - { - final IPart part = this.getPart( dir ); - if( part != null && part.canConnectRedstone() ) - { - return true; - } - } - return false; - } - - @Override - public void onEntityCollision( final Entity entity ) - { - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - part.onEntityCollision( entity ); - } - } - } - - @Override - public boolean activate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - final SelectedPart p = this.selectPart( pos ); - if( p != null && p.part != null ) - { - // forge sends activate even when sneaking in some cases (eg emtpy hand) - // if sneaking try shift activate first. - if( player.isCrouching() && p.part.onShiftActivate( player, hand, pos ) ) - { - return true; - } - return p.part.onActivate( player, hand, pos ); - } - return false; - } - - @Override - public boolean clicked( PlayerEntity player, Hand hand, Vec3d hitVec ) - { - final SelectedPart p = this.selectPart( hitVec ); - if( p != null && p.part != null ) - { - if( player.isCrouching() ) - { - return p.part.onShiftClicked( player, hand, hitVec ); - } - else - { - return p.part.onClicked( player, hand, hitVec ); - } - } - return false; - } - - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - this.hasRedstone = YesNo.UNDECIDED; - - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - part.onNeighborChanged( w, pos, neighbor ); - } - } - } - - @Override - public boolean isSolidOnSide( final Direction side ) - { - if( side == null ) - { - return false; - } - - // facades are solid.. - final IFacadePart fp = this.getFacadeContainer().getFacade( AEPartLocation.fromFacing( side ) ); - if( fp != null ) - { - return true; - } - - // buses can be too. - final IPart part = this.getPart( side ); - return part != null && part.isSolid(); - } - - @Override - public boolean isLadder( final LivingEntity entity ) - { - for( final AEPartLocation side : AEPartLocation.values() ) - { - final IPart p = this.getPart( side ); - if( p != null ) - { - if( p.isLadder( entity ) ) - { - return true; - } - } - } - - return false; - } - - @Override - public void animateTick( final World world, final BlockPos pos, final Random r ) - { - for( final AEPartLocation side : AEPartLocation.values() ) - { - final IPart p = this.getPart( side ); - if( p != null ) - { - p.animateTick( world, pos, r ); - } - } - } - - @Override - public int getLightValue() - { - int light = 0; - - for( final AEPartLocation d : AEPartLocation.values() ) - { - final IPart p = this.getPart( d ); - if( p != null ) - { - light = Math.max( p.getLightLevel(), light ); - } - } - - return light; - } - - public void writeToStream( final PacketBuffer data ) throws IOException - { - int sides = 0; - for( int x = 0; x < 7; x++ ) - { - final IPart p = this.getPart( AEPartLocation.fromOrdinal( x ) ); - if( p != null ) - { - sides |= ( 1 << x ); - } - } - - data.writeByte( (byte) sides ); - - for( int x = 0; x < 7; x++ ) - { - final IPart p = this.getPart( AEPartLocation.fromOrdinal( x ) ); - if( p != null ) - { - final ItemStack is = p.getItemStack( PartItemStack.NETWORK ); - - data.writeVarInt( Item.getIdFromItem( is.getItem() ) ); - - p.writeToStream( data ); - } - } - - this.getFacadeContainer().writeToStream( data ); - } - - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - final byte sides = data.readByte(); - - boolean updateBlock = false; - - for( int x = 0; x < 7; x++ ) - { - AEPartLocation side = AEPartLocation.fromOrdinal( x ); - if( ( ( sides & ( 1 << x ) ) == ( 1 << x ) ) ) - { - IPart p = this.getPart( side ); - - final int itemID = data.readVarInt(); - - final Item myItem = Item.getItemById( itemID ); - - final ItemStack current = p != null ? p.getItemStack( PartItemStack.NETWORK ) : null; - if( current != null && current.getItem() == myItem ) - { - if( p.readFromStream( data ) ) - { - updateBlock = true; - } - } - else - { - this.removePart( side, false ); - side = this.addPart( new ItemStack( myItem, 1 ), side, null, null ); - if( side != null ) - { - p = this.getPart( side ); - p.readFromStream( data ); - } - else - { - throw new IllegalStateException( "Invalid Stream For CableBus Container." ); - } - } - } - else if( this.getPart( side ) != null ) - { - this.removePart( side, false ); - } - } - - if( this.getFacadeContainer().readFromStream( data ) ) - { - return true; - } - - return updateBlock; - } - - public void writeToNBT( final CompoundNBT data ) - { - data.putInt( "hasRedstone", this.hasRedstone.ordinal() ); - - final IFacadeContainer fc = this.getFacadeContainer(); - for( final AEPartLocation s : AEPartLocation.values() ) - { - fc.writeToNBT( data ); - - final IPart part = this.getPart( s ); - if( part != null ) - { - final CompoundNBT def = new CompoundNBT(); - part.getItemStack( PartItemStack.WORLD ).write( def ); - - final CompoundNBT extra = new CompoundNBT(); - part.writeToNBT( extra ); - - data.put( "def:" + this.getSide( part ).ordinal(), def ); - data.put( "extra:" + this.getSide( part ).ordinal(), extra ); - } - } - } - - private AEPartLocation getSide( final IPart part ) - { - if( this.getCenter() == part ) - { - return AEPartLocation.INTERNAL; - } - else - { - for( final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS ) - { - if( this.getSide( side ) == part ) - { - return side; - } - } - } - - throw new IllegalStateException( "Uhh Bad Part (" + part + ") on Side." ); - } - - public void readFromNBT( final CompoundNBT data ) - { - if( data.contains( "hasRedstone" ) ) - { - this.hasRedstone = YesNo.values()[data.getInt( "hasRedstone" )]; - } - - for( int x = 0; x < 7; x++ ) - { - AEPartLocation side = AEPartLocation.fromOrdinal( x ); - - final CompoundNBT def = data.getCompound( "def:" + side.ordinal() ); - final CompoundNBT extra = data.getCompound( "extra:" + side.ordinal() ); - if( def != null && extra != null ) - { - IPart p = this.getPart( side ); - final ItemStack iss = ItemStack.read( def ); - if( iss.isEmpty() ) - { - continue; - } - - final ItemStack current = p == null ? ItemStack.EMPTY : p.getItemStack( PartItemStack.WORLD ); - - if( Platform.itemComparisons().isEqualItemType( iss, current ) ) - { - p.readFromNBT( extra ); - } - else - { - this.removePart( side, true ); - side = this.addPart( iss, side, null, null ); - if( side != null ) - { - p = this.getPart( side ); - p.readFromNBT( extra ); - } - else - { - AELog.warn( "Invalid NBT For CableBus Container: " + iss.getItem().getClass().getName() + " is not a valid part; it was ignored." ); - } - } - } - else - { - this.removePart( side, false ); - } - } - - this.getFacadeContainer().readFromNBT( data ); - } - - public List getDrops( final List drops ) - { - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - drops.add( part.getItemStack( PartItemStack.BREAK ) ); - part.getDrops( drops, false ); - } - - if( s != AEPartLocation.INTERNAL ) - { - final IFacadePart fp = this.getFacadeContainer().getFacade( s ); - if( fp != null ) - { - drops.add( fp.getItemStack() ); - } - } - } - - return drops; - } - - public List getNoDrops( final List drops ) - { - for( final AEPartLocation s : AEPartLocation.values() ) - { - final IPart part = this.getPart( s ); - if( part != null ) - { - part.getDrops( drops, false ); - } - } - - return drops; - } - - @Override - public boolean recolourBlock( final Direction side, final AEColor colour, final PlayerEntity who ) - { - final IPart cable = this.getPart( AEPartLocation.INTERNAL ); - if( cable != null ) - { - final IPartCable pc = (IPartCable) cable; - return pc.changeColor( colour, who ); - } - return false; - } - - public boolean isRequiresDynamicRender() - { - return this.requiresDynamicRender; - } - - private void setRequiresDynamicRender( final boolean requiresDynamicRender ) - { - this.requiresDynamicRender = requiresDynamicRender; - } - - @Override - public CableBusRenderState getRenderState() - { - final PartCable cable = (PartCable) this.getCenter(); - - final CableBusRenderState renderState = new CableBusRenderState(); - - if( cable != null ) - { - renderState.setCableColor( cable.getCableColor() ); - renderState.setCableType( cable.getCableConnectionType() ); - renderState.setCoreType( CableCoreType.fromCableType( cable.getCableConnectionType() ) ); - - // Check each outgoing connection for the desired characteristics - for( Direction facing : Direction.values() ) - { - // Is there a connection? - if( !cable.isConnected( facing ) ) - { - continue; - } - - // If there is one, check out which type it has, but default to this cable's type - AECableType connectionType = cable.getCableConnectionType(); - - // Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself - // Dense cables however also respect the adjacent cable-type since their outgoing connection - // point would look too big for other cable types - final BlockPos adjacentPos = this.getTile().getPos().offset( facing ); - final TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos ); - - if( adjacentTe instanceof IGridHost ) - { - final IGridHost gridHost = (IGridHost) adjacentTe; - final AECableType adjacentType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) ); - - connectionType = AECableType.min( connectionType, adjacentType ); - } - - // Check if the adjacent TE is a cable bus or not - if( adjacentTe instanceof IPartHost ) - { - renderState.getCableBusAdjacent().add( facing ); - } - - renderState.getConnectionTypes().put( facing, connectionType ); - } - - // Collect the number of channels used per side - // We have to do this even for non-smart cables since a glass cable can display a connection as smart if the - // adjacent tile requires it - for( Direction facing : Direction.values() ) - { - int channels = cable.getCableConnectionType().isSmart() ? cable.getChannelsOnSide( facing ) : 0; - renderState.getChannelsOnSide().put( facing, channels ); - } - } - - // Determine attachments and facades - for( Direction facing : Direction.values() ) - { - final FacadeRenderState facadeState = this.getFacadeRenderState( facing ); - - if( facadeState != null ) - { - renderState.getFacades().put( facing, facadeState ); - } - - final IPart part = this.getPart( facing ); - - if( part == null ) - { - continue; - } - - renderState.getPartModelData().put( facing, part.getModelData() ); - - // This will add the part's bounding boxes to the render state, which is required for facades - final AEPartLocation loc = AEPartLocation.fromFacing( facing ); - final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true ); - - part.getBoxes( bch ); - - if( part instanceof IGridHost ) - { - // Some attachments want a thicker cable than glass, account for that - final IGridHost gridHost = (IGridHost) part; - final AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL ); - - if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) ) - { - renderState.setCoreType( CableCoreType.COVERED ); - } - - int length = (int) part.getCableConnectionLength( null ); - if( length > 0 && length <= 8 ) - { - renderState.getAttachmentConnections().put( facing, length ); - } - } - - renderState.getAttachments().put( facing, part.getStaticModels() ); - } - - return renderState; - } - - private FacadeRenderState getFacadeRenderState( Direction side ) - { - // Store the "masqueraded" itemstack for the given side, if there is a facade - final IFacadePart facade = this.getFacade( side.ordinal() ); - - if( facade != null ) - { - final ItemStack textureItem = facade.getTextureItem(); - final BlockState blockState = facade.getBlockState(); - - World world = getTile().getWorld(); - if( blockState != null && textureItem != null && world != null ) - { - return new FacadeRenderState( blockState, !facade.getBlockState().isOpaqueCube(world, getTile().getPos()) ); - } - } - - return null; - } +public class CableBusContainer extends CableBusStorage implements AEMultiTile, ICableBusContainer { + + private static final ThreadLocal IS_LOADING = new ThreadLocal<>(); + private final EnumSet myLayerFlags = EnumSet.noneOf(LayerFlags.class); + private YesNo hasRedstone = YesNo.UNDECIDED; + private IPartHost tcb; + // TODO 1.10.2-R - does somebody seriously want to make parts TESR??? Hope not. + private boolean requiresDynamicRender = false; + private boolean inWorld = false; + + public CableBusContainer(final IPartHost host) { + this.tcb = host; + } + + public static boolean isLoading() { + final Boolean is = IS_LOADING.get(); + return is != null && is; + } + + public void setHost(final IPartHost host) { + this.tcb.clearContainer(); + this.tcb = host; + } + + public void rotateLeft() { + final IPart[] newSides = new IPart[6]; + + newSides[AEPartLocation.UP.ordinal()] = this.getSide(AEPartLocation.UP); + newSides[AEPartLocation.DOWN.ordinal()] = this.getSide(AEPartLocation.DOWN); + + newSides[AEPartLocation.EAST.ordinal()] = this.getSide(AEPartLocation.NORTH); + newSides[AEPartLocation.SOUTH.ordinal()] = this.getSide(AEPartLocation.EAST); + newSides[AEPartLocation.WEST.ordinal()] = this.getSide(AEPartLocation.SOUTH); + newSides[AEPartLocation.NORTH.ordinal()] = this.getSide(AEPartLocation.WEST); + + for (final AEPartLocation dir : AEPartLocation.SIDE_LOCATIONS) { + this.setSide(dir, newSides[dir.ordinal()]); + } + + this.getFacadeContainer().rotateLeft(); + } + + @Override + public IFacadeContainer getFacadeContainer() { + return new FacadeContainer(this); + } + + @Override + public boolean canAddPart(ItemStack is, final AEPartLocation side) { + if (PartPlacement.isFacade(is, side) != null) { + return true; + } + + if (is.getItem() instanceof IPartItem) { + final IPartItem bi = (IPartItem) is.getItem(); + + is = is.copy(); + is.setCount(1); + + final IPart bp = bi.createPart(is); + if (bp != null) { + if (bp instanceof IPartCable) { + boolean canPlace = true; + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + if (this.getPart(d) != null + && !this.getPart(d).canBePlacedOn(((IPartCable) bp).supportsBuses())) { + canPlace = false; + } + } + + if (!canPlace) { + return false; + } + + return this.getPart(AEPartLocation.INTERNAL) == null; + } else if (!(bp instanceof IPartCable) && side != AEPartLocation.INTERNAL) { + final IPart cable = this.getPart(AEPartLocation.INTERNAL); + if (cable != null && !bp.canBePlacedOn(((IPartCable) cable).supportsBuses())) { + return false; + } + + return this.getPart(side) == null; + } + } + } + return false; + } + + @Override + public AEPartLocation addPart(ItemStack is, final AEPartLocation side, final @Nullable PlayerEntity player, + final @Nullable Hand hand) { + if (this.canAddPart(is, side)) { + if (is.getItem() instanceof IPartItem) { + final IPartItem bi = (IPartItem) is.getItem(); + + is = is.copy(); + is.setCount(1); + + final IPart bp = bi.createPart(is); + if (bp instanceof IPartCable) { + boolean canPlace = true; + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + if (this.getPart(d) != null + && !this.getPart(d).canBePlacedOn(((IPartCable) bp).supportsBuses())) { + canPlace = false; + } + } + + if (!canPlace) { + return null; + } + + if (this.getPart(AEPartLocation.INTERNAL) != null) { + return null; + } + + this.setCenter((IPartCable) bp); + bp.setPartHostInfo(AEPartLocation.INTERNAL, this, this.tcb.getTile()); + + if (player != null) { + bp.onPlacement(player, hand, is, side); + } + + if (this.inWorld) { + bp.addToWorld(); + } + + final IGridNode cn = this.getCenter().getGridNode(); + if (cn != null) { + for (final AEPartLocation ins : AEPartLocation.SIDE_LOCATIONS) { + final IPart sbp = this.getPart(ins); + if (sbp != null) { + final IGridNode sn = sbp.getGridNode(); + if (sn != null) { + try { + GridConnection.create(cn, sn, AEPartLocation.INTERNAL); + } catch (final FailedConnectionException e) { + AELog.debug(e); + + bp.removeFromWorld(); + this.setCenter(null); + return null; + } + } + } + } + } + + this.updateConnections(); + this.markForUpdate(); + this.markForSave(); + this.partChanged(); + return AEPartLocation.INTERNAL; + } else if (bp != null && !(bp instanceof IPartCable) && side != AEPartLocation.INTERNAL) { + final IPart cable = this.getPart(AEPartLocation.INTERNAL); + if (cable != null && !bp.canBePlacedOn(((IPartCable) cable).supportsBuses())) { + return null; + } + + this.setSide(side, bp); + bp.setPartHostInfo(side, this, this.getTile()); + + if (player != null) { + bp.onPlacement(player, hand, is, side); + } + + if (this.inWorld) { + bp.addToWorld(); + } + + if (this.getCenter() != null) { + final IGridNode cn = this.getCenter().getGridNode(); + final IGridNode sn = bp.getGridNode(); + + if (cn != null && sn != null) { + try { + GridConnection.create(cn, sn, AEPartLocation.INTERNAL); + } catch (final FailedConnectionException e) { + AELog.debug(e); + + bp.removeFromWorld(); + this.setSide(side, null); + return null; + } + } + } + + this.updateDynamicRender(); + this.updateConnections(); + this.markForUpdate(); + this.markForSave(); + this.partChanged(); + return side; + } + } + } + return null; + } + + @Override + public IPart getPart(final AEPartLocation partLocation) { + if (partLocation == AEPartLocation.INTERNAL) { + return this.getCenter(); + } + return this.getSide(partLocation); + } + + @Override + public IPart getPart(final Direction side) { + return this.getSide(AEPartLocation.fromFacing(side)); + } + + @Override + public void removePart(final AEPartLocation side, final boolean suppressUpdate) { + if (side == AEPartLocation.INTERNAL) { + if (this.getCenter() != null) { + this.getCenter().removeFromWorld(); + } + this.setCenter(null); + } else { + if (this.getSide(side) != null) { + this.getSide(side).removeFromWorld(); + } + this.setSide(side, null); + } + + if (!suppressUpdate) { + this.updateDynamicRender(); + this.updateConnections(); + this.markForUpdate(); + this.markForSave(); + this.partChanged(); + } + } + + @Override + public void markForUpdate() { + this.tcb.markForUpdate(); + } + + @Override + public DimensionalCoord getLocation() { + return this.tcb.getLocation(); + } + + @Override + public TileEntity getTile() { + return this.tcb.getTile(); + } + + @Override + public AEColor getColor() { + if (this.getCenter() != null) { + final IPartCable c = this.getCenter(); + return c.getCableColor(); + } + return AEColor.TRANSPARENT; + } + + @Override + public void clearContainer() { + throw new UnsupportedOperationException("Now that is silly!"); + } + + @Override + public boolean isBlocked(final Direction side) { + return this.tcb.isBlocked(side); + } + + @Override + public SelectedPart selectPart(final Vec3d pos) { + for (final AEPartLocation side : AEPartLocation.values()) { + final IPart p = this.getPart(side); + if (p != null) { + final List boxes = new ArrayList<>(); + + final IPartCollisionHelper bch = new BusCollisionHelper(boxes, side, null, true); + p.getBoxes(bch); + for (AxisAlignedBB bb : boxes) { + bb = bb.grow(0.002, 0.002, 0.002); + if (bb.contains(pos)) { + return new SelectedPart(p, side); + } + } + } + } + + if (AEApi.instance().partHelper().getCableRenderMode().opaqueFacades) { + final IFacadeContainer fc = this.getFacadeContainer(); + for (final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS) { + final IFacadePart p = fc.getFacade(side); + if (p != null) { + final List boxes = new ArrayList<>(); + + final IPartCollisionHelper bch = new BusCollisionHelper(boxes, side, null, true); + p.getBoxes(bch, null); + for (AxisAlignedBB bb : boxes) { + bb = bb.grow(0.01, 0.01, 0.01); + if (bb.contains(pos)) { + return new SelectedPart(p, side); + } + } + } + } + } + + return new SelectedPart(); + } + + @Override + public void markForSave() { + this.tcb.markForSave(); + } + + @Override + public void partChanged() { + if (this.getCenter() == null) { + final List facades = new ArrayList<>(); + + final IFacadeContainer fc = this.getFacadeContainer(); + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + final IFacadePart fp = fc.getFacade(d); + if (fp != null) { + facades.add(fp.getItemStack()); + fc.removeFacade(this.tcb, d); + } + } + + if (!facades.isEmpty()) { + final TileEntity te = this.tcb.getTile(); + Platform.spawnDrops(te.getWorld(), te.getPos(), facades); + } + } + + this.tcb.partChanged(); + } + + @Override + public boolean hasRedstone(final AEPartLocation side) { + if (this.hasRedstone == YesNo.UNDECIDED) { + this.updateRedstone(); + } + + return this.hasRedstone == YesNo.YES; + } + + @Override + public boolean isEmpty() { + final IFacadeContainer fc = this.getFacadeContainer(); + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + return false; + } + + if (s != AEPartLocation.INTERNAL) { + final IFacadePart fp = fc.getFacade(s); + if (fp != null) { + return false; + } + } + } + return true; + } + + @Override + public Set getLayerFlags() { + return this.myLayerFlags; + } + + @Override + public void cleanup() { + this.tcb.cleanup(); + } + + @Override + public void notifyNeighbors() { + this.tcb.notifyNeighbors(); + } + + @Override + public boolean isInWorld() { + return this.inWorld; + } + + private void updateRedstone() { + final TileEntity te = this.getTile(); + this.hasRedstone = te.getWorld().getRedstonePowerFromNeighbors(te.getPos()) != 0 ? YesNo.YES : YesNo.NO; + } + + private void updateDynamicRender() { + this.requiresDynamicRender = false; + for (final AEPartLocation s : AEPartLocation.SIDE_LOCATIONS) { + final IPart p = this.getPart(s); + if (p != null) { + this.setRequiresDynamicRender(this.isRequiresDynamicRender() || p.requireDynamicRender()); + } + } + } + + /** + * use for FMP + */ + public void updateConnections() { + if (this.getCenter() != null) { + final EnumSet sides = EnumSet.allOf(Direction.class); + + for (final Direction s : Direction.values()) { + if (this.getPart(s) != null || this.isBlocked(s)) { + sides.remove(s); + } + } + + this.getCenter().setValidSides(sides); + final IGridNode n = this.getCenter().getGridNode(); + if (n != null) { + n.updateState(); + } + } + } + + public void addToWorld() { + if (this.inWorld) { + return; + } + + this.inWorld = true; + IS_LOADING.set(true); + + final TileEntity te = this.getTile(); + + // start with the center, then install the side parts into the grid. + for (int x = 6; x >= 0; x--) { + final AEPartLocation s = AEPartLocation.fromOrdinal(x); + final IPart part = this.getPart(s); + + if (part != null) { + part.setPartHostInfo(s, this, te); + part.addToWorld(); + + if (s != AEPartLocation.INTERNAL) { + final IGridNode sn = part.getGridNode(); + if (sn != null) { + // this is a really stupid if statement, why was this + // here? + // if ( !sn.getConnections().iterator().hasNext() ) + + final IPart center = this.getPart(AEPartLocation.INTERNAL); + if (center != null) { + final IGridNode cn = center.getGridNode(); + if (cn != null) { + try { + AEApi.instance().grid().createGridConnection(cn, sn); + } catch (final FailedConnectionException e) { + // ekk + AELog.debug(e); + } + } + } + } + } + } + } + + this.partChanged(); + + IS_LOADING.set(false); + } + + public void removeFromWorld() { + if (!this.inWorld) { + return; + } + + this.inWorld = false; + + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + part.removeFromWorld(); + } + } + + this.partChanged(); + } + + @Override + public IGridNode getGridNode(final AEPartLocation side) { + final IPart part = this.getPart(side); + if (part != null) { + final IGridNode n = part.getExternalFacingNode(); + if (n != null) { + return n; + } + } + + if (this.getCenter() != null) { + return this.getCenter().getGridNode(); + } + + return null; + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + final IPart part = this.getPart(dir); + if (part instanceof IGridHost) { + final AECableType t = ((IGridHost) part).getCableConnectionType(dir); + if (t != null && t != AECableType.NONE) { + return t; + } + } + + if (this.getCenter() != null) { + final IPartCable c = this.getCenter(); + return c.getCableConnectionType(); + } + return AECableType.NONE; + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return this.getPart(AEPartLocation.INTERNAL) instanceof IPartCable + ? this.getPart(AEPartLocation.INTERNAL).getCableConnectionLength(cable) + : -1; + } + + @Override + public void securityBreak() { + for (final AEPartLocation d : AEPartLocation.values()) { + final IPart p = this.getPart(d); + if (p instanceof IGridHost) { + ((IGridHost) p).securityBreak(); + } + } + } + + public Iterable getSelectedBoundingBoxesFromPool(final boolean ignoreConnections, + final boolean includeFacades, final Entity e, final boolean visual) { + final List boxes = new ArrayList<>(); + + final IFacadeContainer fc = this.getFacadeContainer(); + for (final AEPartLocation s : AEPartLocation.values()) { + final IPartCollisionHelper bch = new BusCollisionHelper(boxes, s, e, visual); + + final IPart part = this.getPart(s); + if (part != null) { + if (ignoreConnections && part instanceof IPartCable) { + bch.addBox(6.0, 6.0, 6.0, 10.0, 10.0, 10.0); + } else { + part.getBoxes(bch); + } + } + + if (AEApi.instance().partHelper().getCableRenderMode().opaqueFacades || !visual) { + if (includeFacades && s != null && s != AEPartLocation.INTERNAL) { + final IFacadePart fp = fc.getFacade(s); + if (fp != null) { + fp.getBoxes(bch, e); + } + } + } + } + + return boxes; + } + + @Override + public int isProvidingStrongPower(final Direction side) { + final IPart part = this.getPart(side); + return part != null ? part.isProvidingStrongPower() : 0; + } + + @Override + public int isProvidingWeakPower(final Direction side) { + final IPart part = this.getPart(side); + return part != null ? part.isProvidingWeakPower() : 0; + } + + @Override + public boolean canConnectRedstone(final EnumSet enumSet) { + for (final Direction dir : enumSet) { + final IPart part = this.getPart(dir); + if (part != null && part.canConnectRedstone()) { + return true; + } + } + return false; + } + + @Override + public void onEntityCollision(final Entity entity) { + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + part.onEntityCollision(entity); + } + } + } + + @Override + public boolean activate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + final SelectedPart p = this.selectPart(pos); + if (p != null && p.part != null) { + // forge sends activate even when sneaking in some cases (eg emtpy hand) + // if sneaking try shift activate first. + if (player.isCrouching() && p.part.onShiftActivate(player, hand, pos)) { + return true; + } + return p.part.onActivate(player, hand, pos); + } + return false; + } + + @Override + public boolean clicked(PlayerEntity player, Hand hand, Vec3d hitVec) { + final SelectedPart p = this.selectPart(hitVec); + if (p != null && p.part != null) { + if (player.isCrouching()) { + return p.part.onShiftClicked(player, hand, hitVec); + } else { + return p.part.onClicked(player, hand, hitVec); + } + } + return false; + } + + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + this.hasRedstone = YesNo.UNDECIDED; + + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + part.onNeighborChanged(w, pos, neighbor); + } + } + } + + @Override + public boolean isSolidOnSide(final Direction side) { + if (side == null) { + return false; + } + + // facades are solid.. + final IFacadePart fp = this.getFacadeContainer().getFacade(AEPartLocation.fromFacing(side)); + if (fp != null) { + return true; + } + + // buses can be too. + final IPart part = this.getPart(side); + return part != null && part.isSolid(); + } + + @Override + public boolean isLadder(final LivingEntity entity) { + for (final AEPartLocation side : AEPartLocation.values()) { + final IPart p = this.getPart(side); + if (p != null) { + if (p.isLadder(entity)) { + return true; + } + } + } + + return false; + } + + @Override + public void animateTick(final World world, final BlockPos pos, final Random r) { + for (final AEPartLocation side : AEPartLocation.values()) { + final IPart p = this.getPart(side); + if (p != null) { + p.animateTick(world, pos, r); + } + } + } + + @Override + public int getLightValue() { + int light = 0; + + for (final AEPartLocation d : AEPartLocation.values()) { + final IPart p = this.getPart(d); + if (p != null) { + light = Math.max(p.getLightLevel(), light); + } + } + + return light; + } + + public void writeToStream(final PacketBuffer data) throws IOException { + int sides = 0; + for (int x = 0; x < 7; x++) { + final IPart p = this.getPart(AEPartLocation.fromOrdinal(x)); + if (p != null) { + sides |= (1 << x); + } + } + + data.writeByte((byte) sides); + + for (int x = 0; x < 7; x++) { + final IPart p = this.getPart(AEPartLocation.fromOrdinal(x)); + if (p != null) { + final ItemStack is = p.getItemStack(PartItemStack.NETWORK); + + data.writeVarInt(Item.getIdFromItem(is.getItem())); + + p.writeToStream(data); + } + } + + this.getFacadeContainer().writeToStream(data); + } + + public boolean readFromStream(final PacketBuffer data) throws IOException { + final byte sides = data.readByte(); + + boolean updateBlock = false; + + for (int x = 0; x < 7; x++) { + AEPartLocation side = AEPartLocation.fromOrdinal(x); + if (((sides & (1 << x)) == (1 << x))) { + IPart p = this.getPart(side); + + final int itemID = data.readVarInt(); + + final Item myItem = Item.getItemById(itemID); + + final ItemStack current = p != null ? p.getItemStack(PartItemStack.NETWORK) : null; + if (current != null && current.getItem() == myItem) { + if (p.readFromStream(data)) { + updateBlock = true; + } + } else { + this.removePart(side, false); + side = this.addPart(new ItemStack(myItem, 1), side, null, null); + if (side != null) { + p = this.getPart(side); + p.readFromStream(data); + } else { + throw new IllegalStateException("Invalid Stream For CableBus Container."); + } + } + } else if (this.getPart(side) != null) { + this.removePart(side, false); + } + } + + if (this.getFacadeContainer().readFromStream(data)) { + return true; + } + + return updateBlock; + } + + public void writeToNBT(final CompoundNBT data) { + data.putInt("hasRedstone", this.hasRedstone.ordinal()); + + final IFacadeContainer fc = this.getFacadeContainer(); + for (final AEPartLocation s : AEPartLocation.values()) { + fc.writeToNBT(data); + + final IPart part = this.getPart(s); + if (part != null) { + final CompoundNBT def = new CompoundNBT(); + part.getItemStack(PartItemStack.WORLD).write(def); + + final CompoundNBT extra = new CompoundNBT(); + part.writeToNBT(extra); + + data.put("def:" + this.getSide(part).ordinal(), def); + data.put("extra:" + this.getSide(part).ordinal(), extra); + } + } + } + + private AEPartLocation getSide(final IPart part) { + if (this.getCenter() == part) { + return AEPartLocation.INTERNAL; + } else { + for (final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS) { + if (this.getSide(side) == part) { + return side; + } + } + } + + throw new IllegalStateException("Uhh Bad Part (" + part + ") on Side."); + } + + public void readFromNBT(final CompoundNBT data) { + if (data.contains("hasRedstone")) { + this.hasRedstone = YesNo.values()[data.getInt("hasRedstone")]; + } + + for (int x = 0; x < 7; x++) { + AEPartLocation side = AEPartLocation.fromOrdinal(x); + + final CompoundNBT def = data.getCompound("def:" + side.ordinal()); + final CompoundNBT extra = data.getCompound("extra:" + side.ordinal()); + if (def != null && extra != null) { + IPart p = this.getPart(side); + final ItemStack iss = ItemStack.read(def); + if (iss.isEmpty()) { + continue; + } + + final ItemStack current = p == null ? ItemStack.EMPTY : p.getItemStack(PartItemStack.WORLD); + + if (Platform.itemComparisons().isEqualItemType(iss, current)) { + p.readFromNBT(extra); + } else { + this.removePart(side, true); + side = this.addPart(iss, side, null, null); + if (side != null) { + p = this.getPart(side); + p.readFromNBT(extra); + } else { + AELog.warn("Invalid NBT For CableBus Container: " + iss.getItem().getClass().getName() + + " is not a valid part; it was ignored."); + } + } + } else { + this.removePart(side, false); + } + } + + this.getFacadeContainer().readFromNBT(data); + } + + public List getDrops(final List drops) { + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + drops.add(part.getItemStack(PartItemStack.BREAK)); + part.getDrops(drops, false); + } + + if (s != AEPartLocation.INTERNAL) { + final IFacadePart fp = this.getFacadeContainer().getFacade(s); + if (fp != null) { + drops.add(fp.getItemStack()); + } + } + } + + return drops; + } + + public List getNoDrops(final List drops) { + for (final AEPartLocation s : AEPartLocation.values()) { + final IPart part = this.getPart(s); + if (part != null) { + part.getDrops(drops, false); + } + } + + return drops; + } + + @Override + public boolean recolourBlock(final Direction side, final AEColor colour, final PlayerEntity who) { + final IPart cable = this.getPart(AEPartLocation.INTERNAL); + if (cable != null) { + final IPartCable pc = (IPartCable) cable; + return pc.changeColor(colour, who); + } + return false; + } + + public boolean isRequiresDynamicRender() { + return this.requiresDynamicRender; + } + + private void setRequiresDynamicRender(final boolean requiresDynamicRender) { + this.requiresDynamicRender = requiresDynamicRender; + } + + @Override + public CableBusRenderState getRenderState() { + final PartCable cable = (PartCable) this.getCenter(); + + final CableBusRenderState renderState = new CableBusRenderState(); + + if (cable != null) { + renderState.setCableColor(cable.getCableColor()); + renderState.setCableType(cable.getCableConnectionType()); + renderState.setCoreType(CableCoreType.fromCableType(cable.getCableConnectionType())); + + // Check each outgoing connection for the desired characteristics + for (Direction facing : Direction.values()) { + // Is there a connection? + if (!cable.isConnected(facing)) { + continue; + } + + // If there is one, check out which type it has, but default to this cable's + // type + AECableType connectionType = cable.getCableConnectionType(); + + // Only use the incoming cable-type of the adjacent block, if it's not a cable + // bus itself + // Dense cables however also respect the adjacent cable-type since their + // outgoing connection + // point would look too big for other cable types + final BlockPos adjacentPos = this.getTile().getPos().offset(facing); + final TileEntity adjacentTe = this.getTile().getWorld().getTileEntity(adjacentPos); + + if (adjacentTe instanceof IGridHost) { + final IGridHost gridHost = (IGridHost) adjacentTe; + final AECableType adjacentType = gridHost + .getCableConnectionType(AEPartLocation.fromFacing(facing.getOpposite())); + + connectionType = AECableType.min(connectionType, adjacentType); + } + + // Check if the adjacent TE is a cable bus or not + if (adjacentTe instanceof IPartHost) { + renderState.getCableBusAdjacent().add(facing); + } + + renderState.getConnectionTypes().put(facing, connectionType); + } + + // Collect the number of channels used per side + // We have to do this even for non-smart cables since a glass cable can display + // a connection as smart if the + // adjacent tile requires it + for (Direction facing : Direction.values()) { + int channels = cable.getCableConnectionType().isSmart() ? cable.getChannelsOnSide(facing) : 0; + renderState.getChannelsOnSide().put(facing, channels); + } + } + + // Determine attachments and facades + for (Direction facing : Direction.values()) { + final FacadeRenderState facadeState = this.getFacadeRenderState(facing); + + if (facadeState != null) { + renderState.getFacades().put(facing, facadeState); + } + + final IPart part = this.getPart(facing); + + if (part == null) { + continue; + } + + renderState.getPartModelData().put(facing, part.getModelData()); + + // This will add the part's bounding boxes to the render state, which is + // required for facades + final AEPartLocation loc = AEPartLocation.fromFacing(facing); + final IPartCollisionHelper bch = new BusCollisionHelper(renderState.getBoundingBoxes(), loc, null, true); + + part.getBoxes(bch); + + if (part instanceof IGridHost) { + // Some attachments want a thicker cable than glass, account for that + final IGridHost gridHost = (IGridHost) part; + final AECableType desiredType = gridHost.getCableConnectionType(AEPartLocation.INTERNAL); + + if (renderState.getCoreType() == CableCoreType.GLASS + && (desiredType == AECableType.SMART || desiredType == AECableType.COVERED)) { + renderState.setCoreType(CableCoreType.COVERED); + } + + int length = (int) part.getCableConnectionLength(null); + if (length > 0 && length <= 8) { + renderState.getAttachmentConnections().put(facing, length); + } + } + + renderState.getAttachments().put(facing, part.getStaticModels()); + } + + return renderState; + } + + private FacadeRenderState getFacadeRenderState(Direction side) { + // Store the "masqueraded" itemstack for the given side, if there is a facade + final IFacadePart facade = this.getFacade(side.ordinal()); + + if (facade != null) { + final ItemStack textureItem = facade.getTextureItem(); + final BlockState blockState = facade.getBlockState(); + + World world = getTile().getWorld(); + if (blockState != null && textureItem != null && world != null) { + return new FacadeRenderState(blockState, + !facade.getBlockState().isOpaqueCube(world, getTile().getPos())); + } + } + + return null; + } } diff --git a/src/main/java/appeng/parts/CableBusStorage.java b/src/main/java/appeng/parts/CableBusStorage.java index ef1f7f7bd..85a622033 100644 --- a/src/main/java/appeng/parts/CableBusStorage.java +++ b/src/main/java/appeng/parts/CableBusStorage.java @@ -18,7 +18,6 @@ package appeng.parts; - import javax.annotation.Nullable; import appeng.api.implementations.parts.IPartCable; @@ -26,121 +25,97 @@ import appeng.api.parts.IFacadePart; import appeng.api.parts.IPart; import appeng.api.util.AEPartLocation; - /** * Thin data storage to optimize memory usage for cables. */ -public class CableBusStorage -{ +public class CableBusStorage { - private IPartCable center; - private IPart[] sides; - private IFacadePart[] facades; + private IPartCable center; + private IPart[] sides; + private IFacadePart[] facades; - protected IPartCable getCenter() - { - return this.center; - } + protected IPartCable getCenter() { + return this.center; + } - protected void setCenter( final IPartCable center ) - { - this.center = center; - } + protected void setCenter(final IPartCable center) { + this.center = center; + } - protected IPart getSide( final AEPartLocation side ) - { - final int x = side.ordinal(); - if( this.sides != null && this.sides.length > x ) - { - return this.sides[x]; - } + protected IPart getSide(final AEPartLocation side) { + final int x = side.ordinal(); + if (this.sides != null && this.sides.length > x) { + return this.sides[x]; + } - return null; - } + return null; + } - protected void setSide( final AEPartLocation side, final IPart part ) - { - final int x = side.ordinal(); + protected void setSide(final AEPartLocation side, final IPart part) { + final int x = side.ordinal(); - if( this.sides != null && this.sides.length > x && part == null ) - { - this.sides[x] = null; - this.sides = this.shrink( this.sides, true ); - } - else if( part != null ) - { - this.sides = this.grow( this.sides, x, true ); - this.sides[x] = part; - } - } + if (this.sides != null && this.sides.length > x && part == null) { + this.sides[x] = null; + this.sides = this.shrink(this.sides, true); + } else if (part != null) { + this.sides = this.grow(this.sides, x, true); + this.sides[x] = part; + } + } - private T[] shrink( final T[] in, final boolean parts ) - { - int newSize = -1; - for( int x = 0; x < in.length; x++ ) - { - if( in[x] != null ) - { - newSize = x; - } - } + private T[] shrink(final T[] in, final boolean parts) { + int newSize = -1; + for (int x = 0; x < in.length; x++) { + if (in[x] != null) { + newSize = x; + } + } - if( newSize == -1 ) - { - return null; - } + if (newSize == -1) { + return null; + } - newSize++; - if( newSize == in.length ) - { - return in; - } + newSize++; + if (newSize == in.length) { + return in; + } - final T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] ); - System.arraycopy( in, 0, newArray, 0, newSize ); + final T[] newArray = (T[]) (parts ? new IPart[newSize] : new IFacadePart[newSize]); + System.arraycopy(in, 0, newArray, 0, newSize); - return newArray; - } + return newArray; + } - private T[] grow( final T[] in, final int newValue, final boolean parts ) - { - if( in != null && in.length > newValue ) - { - return in; - } + private T[] grow(final T[] in, final int newValue, final boolean parts) { + if (in != null && in.length > newValue) { + return in; + } - final int newSize = newValue + 1; + final int newSize = newValue + 1; - final T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] ); - if( in != null ) - { - System.arraycopy( in, 0, newArray, 0, in.length ); - } + final T[] newArray = (T[]) (parts ? new IPart[newSize] : new IFacadePart[newSize]); + if (in != null) { + System.arraycopy(in, 0, newArray, 0, in.length); + } - return newArray; - } + return newArray; + } - public IFacadePart getFacade( final int x ) - { - if( this.facades != null && this.facades.length > x ) - { - return this.facades[x]; - } + public IFacadePart getFacade(final int x) { + if (this.facades != null && this.facades.length > x) { + return this.facades[x]; + } - return null; - } + return null; + } - public void setFacade( final int x, @Nullable final IFacadePart facade ) - { - if( this.facades != null && this.facades.length > x && facade == null ) - { - this.facades[x] = null; - this.facades = this.shrink( this.facades, false ); - } - else - { - this.facades = this.grow( this.facades, x, false ); - this.facades[x] = facade; - } - } + public void setFacade(final int x, @Nullable final IFacadePart facade) { + if (this.facades != null && this.facades.length > x && facade == null) { + this.facades[x] = null; + this.facades = this.shrink(this.facades, false); + } else { + this.facades = this.grow(this.facades, x, false); + this.facades[x] = facade; + } + } } diff --git a/src/main/java/appeng/parts/ICableBusContainer.java b/src/main/java/appeng/parts/ICableBusContainer.java index 5f80b9e53..a4ca20f28 100644 --- a/src/main/java/appeng/parts/ICableBusContainer.java +++ b/src/main/java/appeng/parts/ICableBusContainer.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.util.EnumSet; import java.util.Random; @@ -38,39 +37,37 @@ import appeng.api.parts.SelectedPart; import appeng.api.util.AEColor; import appeng.client.render.cablebus.CableBusRenderState; +public interface ICableBusContainer { -public interface ICableBusContainer -{ + int isProvidingStrongPower(Direction opposite); - int isProvidingStrongPower( Direction opposite ); + int isProvidingWeakPower(Direction opposite); - int isProvidingWeakPower( Direction opposite ); + boolean canConnectRedstone(EnumSet of); - boolean canConnectRedstone( EnumSet of ); + void onEntityCollision(Entity e); - void onEntityCollision( Entity e ); + boolean activate(PlayerEntity player, Hand hand, Vec3d vecFromPool); - boolean activate( PlayerEntity player, Hand hand, Vec3d vecFromPool ); + boolean clicked(PlayerEntity player, Hand hand, Vec3d hitVec); - boolean clicked( PlayerEntity player, Hand hand, Vec3d hitVec ); + void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor); - void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ); + boolean isSolidOnSide(Direction side); - boolean isSolidOnSide( Direction side ); + boolean isEmpty(); - boolean isEmpty(); + SelectedPart selectPart(Vec3d v3); - SelectedPart selectPart( Vec3d v3 ); + boolean recolourBlock(Direction side, AEColor colour, PlayerEntity who); - boolean recolourBlock( Direction side, AEColor colour, PlayerEntity who ); + boolean isLadder(LivingEntity entity); - boolean isLadder( LivingEntity entity ); + @OnlyIn(Dist.CLIENT) + void animateTick(World world, BlockPos pos, Random r); - @OnlyIn( Dist.CLIENT ) - void animateTick( World world, BlockPos pos, Random r ); + int getLightValue(); - int getLightValue(); - - CableBusRenderState getRenderState(); + CableBusRenderState getRenderState(); } diff --git a/src/main/java/appeng/parts/NullCableBusContainer.java b/src/main/java/appeng/parts/NullCableBusContainer.java index e9de827a8..8f11bbdf1 100644 --- a/src/main/java/appeng/parts/NullCableBusContainer.java +++ b/src/main/java/appeng/parts/NullCableBusContainer.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.util.EnumSet; import java.util.Random; @@ -36,98 +35,81 @@ import appeng.api.parts.SelectedPart; import appeng.api.util.AEColor; import appeng.client.render.cablebus.CableBusRenderState; +public class NullCableBusContainer implements ICableBusContainer { -public class NullCableBusContainer implements ICableBusContainer -{ + @Override + public int isProvidingStrongPower(final Direction opposite) { + return 0; + } - @Override - public int isProvidingStrongPower( final Direction opposite ) - { - return 0; - } + @Override + public int isProvidingWeakPower(final Direction opposite) { + return 0; + } - @Override - public int isProvidingWeakPower( final Direction opposite ) - { - return 0; - } + @Override + public boolean canConnectRedstone(final EnumSet of) { + return false; + } - @Override - public boolean canConnectRedstone( final EnumSet of ) - { - return false; - } + @Override + public void onEntityCollision(final Entity e) { - @Override - public void onEntityCollision( final Entity e ) - { + } - } + @Override + public boolean activate(final PlayerEntity player, final Hand hand, final Vec3d vecFromPool) { + return false; + } - @Override - public boolean activate( final PlayerEntity player, final Hand hand, final Vec3d vecFromPool ) - { - return false; - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { + } - } + @Override + public boolean isSolidOnSide(final Direction side) { + return false; + } - @Override - public boolean isSolidOnSide( final Direction side ) - { - return false; - } + @Override + public boolean isEmpty() { + return true; + } - @Override - public boolean isEmpty() - { - return true; - } + @Override + public SelectedPart selectPart(final Vec3d v3) { + return new SelectedPart(); + } - @Override - public SelectedPart selectPart( final Vec3d v3 ) - { - return new SelectedPart(); - } + @Override + public boolean recolourBlock(final Direction side, final AEColor colour, final PlayerEntity who) { + return false; + } - @Override - public boolean recolourBlock( final Direction side, final AEColor colour, final PlayerEntity who ) - { - return false; - } + @Override + public boolean isLadder(final LivingEntity entity) { + return false; + } - @Override - public boolean isLadder( final LivingEntity entity ) - { - return false; - } + @Override + public void animateTick(final World world, final BlockPos pos, final Random r) { - @Override - public void animateTick( final World world, final BlockPos pos, final Random r ) - { + } - } + @Override + public int getLightValue() { + return 0; + } - @Override - public int getLightValue() - { - return 0; - } + @Override + public CableBusRenderState getRenderState() { + return new CableBusRenderState(); + } - @Override - public CableBusRenderState getRenderState() - { - return new CableBusRenderState(); - } - - @Override - public boolean clicked( PlayerEntity player, Hand hand, Vec3d hitVec ) - { - return false; - } + @Override + public boolean clicked(PlayerEntity player, Hand hand, Vec3d hitVec) { + return false; + } } diff --git a/src/main/java/appeng/parts/PartBasicState.java b/src/main/java/appeng/parts/PartBasicState.java index 4a56083cb..71d6ca102 100644 --- a/src/main/java/appeng/parts/PartBasicState.java +++ b/src/main/java/appeng/parts/PartBasicState.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.io.IOException; import net.minecraft.item.ItemStack; @@ -31,97 +30,80 @@ import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.me.GridAccessException; +public abstract class PartBasicState extends AEBasePart implements IPowerChannelState { -public abstract class PartBasicState extends AEBasePart implements IPowerChannelState -{ + protected static final int POWERED_FLAG = 1; + protected static final int CHANNEL_FLAG = 2; - protected static final int POWERED_FLAG = 1; - protected static final int CHANNEL_FLAG = 2; + private int clientFlags = 0; // sent as byte. - private int clientFlags = 0; // sent as byte. + public PartBasicState(final ItemStack is) { + super(is); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + } - public PartBasicState( final ItemStack is ) - { - super( is ); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - } + @MENetworkEventSubscribe + public void chanRender(final MENetworkChannelsChanged c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void chanRender( final MENetworkChannelsChanged c ) - { - this.getHost().markForUpdate(); - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.getHost().markForUpdate(); - } + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); + this.setClientFlags(0); - this.setClientFlags( 0 ); + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + this.setClientFlags(this.getClientFlags() | POWERED_FLAG); + } - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - this.setClientFlags( this.getClientFlags() | POWERED_FLAG ); - } + if (this.getProxy().getNode().meetsChannelRequirements()) { + this.setClientFlags(this.getClientFlags() | CHANNEL_FLAG); + } - if( this.getProxy().getNode().meetsChannelRequirements() ) - { - this.setClientFlags( this.getClientFlags() | CHANNEL_FLAG ); - } + this.setClientFlags(this.populateFlags(this.getClientFlags())); + } catch (final GridAccessException e) { + // meh + } - this.setClientFlags( this.populateFlags( this.getClientFlags() ) ); - } - catch( final GridAccessException e ) - { - // meh - } + data.writeByte((byte) this.getClientFlags()); + } - data.writeByte( (byte) this.getClientFlags() ); - } + protected int populateFlags(final int cf) { + return cf; + } - protected int populateFlags( final int cf ) - { - return cf; - } + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean eh = super.readFromStream(data); - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean eh = super.readFromStream( data ); + final int old = this.getClientFlags(); + this.setClientFlags(data.readByte()); - final int old = this.getClientFlags(); - this.setClientFlags( data.readByte() ); + return eh || old != this.getClientFlags(); + } - return eh || old != this.getClientFlags(); - } + @Override + public boolean isPowered() { + return (this.getClientFlags() & POWERED_FLAG) == POWERED_FLAG; + } - @Override - public boolean isPowered() - { - return ( this.getClientFlags() & POWERED_FLAG ) == POWERED_FLAG; - } + @Override + public boolean isActive() { + return (this.getClientFlags() & CHANNEL_FLAG) == CHANNEL_FLAG; + } - @Override - public boolean isActive() - { - return ( this.getClientFlags() & CHANNEL_FLAG ) == CHANNEL_FLAG; - } + public int getClientFlags() { + return this.clientFlags; + } - public int getClientFlags() - { - return this.clientFlags; - } - - private void setClientFlags( final int clientFlags ) - { - this.clientFlags = clientFlags; - } + private void setClientFlags(final int clientFlags) { + this.clientFlags = clientFlags; + } } diff --git a/src/main/java/appeng/parts/PartModel.java b/src/main/java/appeng/parts/PartModel.java index 727984f88..f9595b0f9 100644 --- a/src/main/java/appeng/parts/PartModel.java +++ b/src/main/java/appeng/parts/PartModel.java @@ -18,7 +18,6 @@ package appeng.parts; - import java.util.List; import com.google.common.collect.ImmutableList; @@ -27,54 +26,44 @@ import net.minecraft.util.ResourceLocation; import appeng.api.parts.IPartModel; +public class PartModel implements IPartModel { + private final boolean isSolid; -public class PartModel implements IPartModel -{ - private final boolean isSolid; + private final List resources; - private final List resources; + public PartModel(ResourceLocation resource) { + this(true, resource); + } - public PartModel( ResourceLocation resource ) - { - this( true, resource ); - } + public PartModel(ResourceLocation... resources) { + this(true, resources); + } - public PartModel( ResourceLocation... resources ) - { - this( true, resources ); - } + public PartModel(boolean isSolid, ResourceLocation resource) { + this(isSolid, ImmutableList.of(resource)); + } - public PartModel( boolean isSolid, ResourceLocation resource ) - { - this( isSolid, ImmutableList.of( resource ) ); - } + public PartModel(boolean isSolid, ResourceLocation... resources) { + this(isSolid, ImmutableList.copyOf(resources)); + } - public PartModel( boolean isSolid, ResourceLocation... resources ) - { - this( isSolid, ImmutableList.copyOf( resources ) ); - } + public PartModel(List resources) { + this(true, resources); + } - public PartModel( List resources ) - { - this( true, resources ); - } + public PartModel(boolean isSolid, List resources) { + this.isSolid = isSolid; + this.resources = resources; + } - public PartModel( boolean isSolid, List resources ) - { - this.isSolid = isSolid; - this.resources = resources; - } + @Override + public boolean requireCableConnection() { + return this.isSolid; + } - @Override - public boolean requireCableConnection() - { - return this.isSolid; - } - - @Override - public List getModels() - { - return this.resources; - } + @Override + public List getModels() { + return this.resources; + } } diff --git a/src/main/java/appeng/parts/PartPlacement.java b/src/main/java/appeng/parts/PartPlacement.java index 24f469532..41065911e 100644 --- a/src/main/java/appeng/parts/PartPlacement.java +++ b/src/main/java/appeng/parts/PartPlacement.java @@ -18,20 +18,10 @@ package appeng.parts; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; -import appeng.api.AEApi; -import appeng.api.definitions.IBlockDefinition; -import appeng.api.definitions.IItems; -import appeng.api.parts.*; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.core.AppEng; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketClick; -import appeng.core.sync.packets.PacketPartPlacement; -import appeng.facade.IFacadeItem; -import appeng.util.LookDirection; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; @@ -48,427 +38,369 @@ import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; +import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IItems; +import appeng.api.parts.*; +import appeng.api.util.AEPartLocation; +import appeng.api.util.DimensionalCoord; +import appeng.core.AppEng; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketClick; +import appeng.core.sync.packets.PacketPartPlacement; +import appeng.facade.IFacadeItem; +import appeng.util.LookDirection; +import appeng.util.Platform; +public class PartPlacement { -public class PartPlacement -{ + private static float eyeHeight = 0.0f; + private final ThreadLocal placing = new ThreadLocal<>(); + private boolean wasCanceled = false; - private static float eyeHeight = 0.0f; - private final ThreadLocal placing = new ThreadLocal<>(); - private boolean wasCanceled = false; + public static ActionResultType place(final ItemStack held, final BlockPos pos, Direction side, + final PlayerEntity player, final Hand hand, final World world, PlaceType pass, final int depth) { + if (depth > 3) { + return ActionResultType.FAIL; + } - public static ActionResultType place( final ItemStack held, final BlockPos pos, Direction side, final PlayerEntity player, final Hand hand, final World world, PlaceType pass, final int depth ) - { - if( depth > 3 ) - { - return ActionResultType.FAIL; - } + // FIXME: This was changed alot. + final LookDirection dir = Platform.getPlayerRay(player); + RayTraceContext rtc = new RayTraceContext(dir.getA(), dir.getB(), RayTraceContext.BlockMode.OUTLINE, + RayTraceContext.FluidMode.NONE, player); + final BlockRayTraceResult mop = world.rayTraceBlocks(rtc); + BlockItemUseContext useContext = new BlockItemUseContext(new ItemUseContext(player, hand, mop)); - // FIXME: This was changed alot. - final LookDirection dir = Platform.getPlayerRay( player ); - RayTraceContext rtc = new RayTraceContext(dir.getA(), dir.getB(), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player); - final BlockRayTraceResult mop = world.rayTraceBlocks( rtc ); - BlockItemUseContext useContext = new BlockItemUseContext(new ItemUseContext( - player, hand, mop - )); + if (!held.isEmpty() && Platform.isWrench(player, held, pos) && player.isCrouching()) { + if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) { + return ActionResultType.FAIL; + } - if( !held.isEmpty() && Platform.isWrench( player, held, pos ) && player.isCrouching() ) - { - if( !Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) ) - { - return ActionResultType.FAIL; - } + final TileEntity tile = world.getTileEntity(pos); + IPartHost host = null; - final TileEntity tile = world.getTileEntity( pos ); - IPartHost host = null; + if (tile instanceof IPartHost) { + host = (IPartHost) tile; + } - if( tile instanceof IPartHost ) - { - host = (IPartHost) tile; - } + if (host != null) { + if (!world.isRemote) { + if (mop.getType() == RayTraceResult.Type.BLOCK) { + final List is = new ArrayList<>(); + final SelectedPart sp = selectPart(player, host, + mop.getHitVec().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ())); - if( host != null ) - { - if( !world.isRemote ) - { - if( mop.getType() == RayTraceResult.Type.BLOCK ) - { - final List is = new ArrayList<>(); - final SelectedPart sp = selectPart( player, host, - mop.getHitVec().add( -mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ() ) ); + if (sp.part != null) { + is.add(sp.part.getItemStack(PartItemStack.WRENCH)); + sp.part.getDrops(is, true); + host.removePart(sp.side, false); + } - if( sp.part != null ) - { - is.add( sp.part.getItemStack( PartItemStack.WRENCH ) ); - sp.part.getDrops( is, true ); - host.removePart( sp.side, false ); - } + if (sp.facade != null) { + is.add(sp.facade.getItemStack()); + host.getFacadeContainer().removeFacade(host, sp.side); + Platform.notifyBlocksOfNeighbors(world, pos); + } - if( sp.facade != null ) - { - is.add( sp.facade.getItemStack() ); - host.getFacadeContainer().removeFacade( host, sp.side ); - Platform.notifyBlocksOfNeighbors( world, pos ); - } + if (host.isEmpty()) { + host.cleanup(); + } - if( host.isEmpty() ) - { - host.cleanup(); - } + if (!is.isEmpty()) { + Platform.spawnDrops(world, pos, is); + } + } + } else { + player.swingArm(hand); + NetworkHandler.instance() + .sendToServer(new PacketPartPlacement(pos, side, getEyeOffset(player), hand)); + } + return ActionResultType.SUCCESS; + } - if( !is.isEmpty() ) - { - Platform.spawnDrops( world, pos, is ); - } - } - } - else - { - player.swingArm( hand ); - NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) ); - } - return ActionResultType.SUCCESS; - } + return ActionResultType.FAIL; + } - return ActionResultType.FAIL; - } + TileEntity tile = world.getTileEntity(pos); + IPartHost host = null; - TileEntity tile = world.getTileEntity( pos ); - IPartHost host = null; + if (tile instanceof IPartHost) { + host = (IPartHost) tile; + } - if( tile instanceof IPartHost ) - { - host = (IPartHost) tile; - } + if (!held.isEmpty()) { + final IFacadePart fp = isFacade(held, AEPartLocation.fromFacing(side)); + if (fp != null) { + if (host != null) { + if (!world.isRemote) { + if (host.getPart(AEPartLocation.INTERNAL) == null) { + return ActionResultType.FAIL; + } - if( !held.isEmpty() ) - { - final IFacadePart fp = isFacade( held, AEPartLocation.fromFacing( side ) ); - if( fp != null ) - { - if( host != null ) - { - if( !world.isRemote ) - { - if( host.getPart( AEPartLocation.INTERNAL ) == null ) - { - return ActionResultType.FAIL; - } + if (host.canAddPart(held, AEPartLocation.fromFacing(side))) { + if (host.getFacadeContainer().addFacade(fp)) { + host.markForSave(); + host.markForUpdate(); + if (!player.isCreative()) { + held.grow(-1); + ; + if (held.getCount() == 0) { + player.inventory.mainInventory.set(player.inventory.currentItem, + ItemStack.EMPTY); + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held, hand)); + } + } + return ActionResultType.CONSUME; + } + } + } else { + player.swingArm(hand); + NetworkHandler.instance() + .sendToServer(new PacketPartPlacement(pos, side, getEyeOffset(player), hand)); + return ActionResultType.SUCCESS; + } + } + return ActionResultType.FAIL; + } + } - if( host.canAddPart( held, AEPartLocation.fromFacing( side ) ) ) - { - if( host.getFacadeContainer().addFacade( fp ) ) - { - host.markForSave(); - host.markForUpdate(); - if( !player.isCreative() ) - { - held.grow( -1 ); - ; - if( held.getCount() == 0 ) - { - player.inventory.mainInventory.set( player.inventory.currentItem, ItemStack.EMPTY ); - MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) ); - } - } - return ActionResultType.CONSUME; - } - } - } - else - { - player.swingArm( hand ); - NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) ); - return ActionResultType.SUCCESS; - } - } - return ActionResultType.FAIL; - } - } + if (held.isEmpty()) { + if (host != null && player.isCrouching() && world.isAirBlock(pos)) { + if (mop.getType() == RayTraceResult.Type.BLOCK) { + Vec3d hitVec = mop.getHitVec().add(-mop.getPos().getX(), -mop.getPos().getY(), + -mop.getPos().getZ()); + final SelectedPart sPart = selectPart(player, host, hitVec); + if (sPart != null && sPart.part != null) { + if (sPart.part.onShiftActivate(player, hand, hitVec)) { + if (world.isRemote) { + NetworkHandler.instance() + .sendToServer(new PacketPartPlacement(pos, side, getEyeOffset(player), hand)); + } + return ActionResultType.SUCCESS; + } + } + } + } + } - if( held.isEmpty() ) - { - if( host != null && player.isCrouching() && world.isAirBlock(pos) ) - { - if( mop.getType() == RayTraceResult.Type.BLOCK ) - { - Vec3d hitVec = mop.getHitVec().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ()); - final SelectedPart sPart = selectPart( player, host, hitVec ); - if( sPart != null && sPart.part != null ) - { - if( sPart.part.onShiftActivate( player, hand, hitVec ) ) - { - if( world.isRemote ) - { - NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) ); - } - return ActionResultType.SUCCESS; - } - } - } - } - } + if (held.isEmpty() || !(held.getItem() instanceof IPartItem)) { + return ActionResultType.PASS; + } - if( held.isEmpty() || !( held.getItem() instanceof IPartItem ) ) - { - return ActionResultType.PASS; - } + BlockPos te_pos = pos; - BlockPos te_pos = pos; + final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart(); + if (host == null && pass == PlaceType.PLACE_ITEM) { + Direction offset = null; - final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart(); - if( host == null && pass == PlaceType.PLACE_ITEM ) - { - Direction offset = null; + BlockState blockState = world.getBlockState(pos); + // FIXME isReplacable on the block state allows for more control, but requires + // an item use context + if (!blockState.isAir(world, pos) && !blockState.isReplaceable(useContext)) { + offset = side; + if (Platform.isServer()) { + side = side.getOpposite(); + } + } - BlockState blockState = world.getBlockState(pos); - // FIXME isReplacable on the block state allows for more control, but requires an item use context - if( !blockState.isAir(world, pos) && !blockState.isReplaceable(useContext) ) - { - offset = side; - if( Platform.isServer() ) - { - side = side.getOpposite(); - } - } + te_pos = offset == null ? pos : pos.offset(offset); - te_pos = offset == null ? pos : pos.offset( offset ); + tile = world.getTileEntity(te_pos); + if (tile instanceof IPartHost) { + host = (IPartHost) tile; + } - tile = world.getTileEntity( te_pos ); - if( tile instanceof IPartHost ) - { - host = (IPartHost) tile; - } + final Optional maybeMultiPartStack = multiPart.maybeStack(1); + final Optional maybeMultiPartBlock = multiPart.maybeBlock(); + final Optional maybeMultiPartBlockItem = multiPart.maybeBlockItem(); - final Optional maybeMultiPartStack = multiPart.maybeStack( 1 ); - final Optional maybeMultiPartBlock = multiPart.maybeBlock(); - final Optional maybeMultiPartBlockItem = multiPart.maybeBlockItem(); + final boolean hostIsNotPresent = host == null; + final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() + && maybeMultiPartBlockItem.isPresent(); + BlockState multiPartBlockState = maybeMultiPartBlock.get().getDefaultState(); + final boolean canMultiPartBePlaced = multiPartBlockState.isValidPosition(world, te_pos); - final boolean hostIsNotPresent = host == null; - final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartBlockItem.isPresent(); - BlockState multiPartBlockState = maybeMultiPartBlock.get().getDefaultState(); - final boolean canMultiPartBePlaced = multiPartBlockState.isValidPosition(world, te_pos); + // We cannot override the item stack of normal use context, so we use this hack + BlockItemUseContext mpUseCtx = new BlockItemUseContext( + new DirectionalPlaceContext(world, te_pos, side, maybeMultiPartStack.get(), side)); - // We cannot override the item stack of normal use context, so we use this hack - BlockItemUseContext mpUseCtx = new BlockItemUseContext(new DirectionalPlaceContext(world, te_pos, side, maybeMultiPartStack.get(), side)); + // FIXME: This is super-fishy and all needs to be re-checked. what does this + // even do??? + if (hostIsNotPresent && multiPartPresent && canMultiPartBePlaced + && maybeMultiPartBlockItem.get().tryPlace(mpUseCtx) == ActionResultType.SUCCESS) { + if (!world.isRemote) { + tile = world.getTileEntity(te_pos); - // FIXME: This is super-fishy and all needs to be re-checked. what does this even do??? - if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartBlockItem.get() - .tryPlace( mpUseCtx ) == ActionResultType.SUCCESS ) - { - if( !world.isRemote ) - { - tile = world.getTileEntity( te_pos ); + if (tile instanceof IPartHost) { + host = (IPartHost) tile; + } - if( tile instanceof IPartHost ) - { - host = (IPartHost) tile; - } + pass = PlaceType.INTERACT_SECOND_PASS; + } else { + player.swingArm(hand); + NetworkHandler.instance() + .sendToServer(new PacketPartPlacement(pos, side, getEyeOffset(player), hand)); + return ActionResultType.SUCCESS; + } + } else if (host != null && !host.canAddPart(held, AEPartLocation.fromFacing(side))) { + return ActionResultType.FAIL; + } + } - pass = PlaceType.INTERACT_SECOND_PASS; - } - else - { - player.swingArm( hand ); - NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) ); - return ActionResultType.SUCCESS; - } - } - else if( host != null && !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) ) - { - return ActionResultType.FAIL; - } - } + if (host == null) { + return ActionResultType.PASS; + } - if( host == null ) - { - return ActionResultType.PASS; - } + if (!host.canAddPart(held, AEPartLocation.fromFacing(side))) { + if (pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM) { + te_pos = pos.offset(side); - if( !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) ) - { - if( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM ) - { - te_pos = pos.offset( side ); + final BlockState blkState = world.getBlockState(te_pos); - final BlockState blkState = world.getBlockState( te_pos ); + // FIXME: this is always true (host was de-referenced above) + if (blkState.isAir(world, te_pos) || blkState.isReplaceable(useContext) || host != null) { + return place(held, te_pos, side.getOpposite(), player, hand, world, + pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS + : PlaceType.PLACE_ITEM, + depth + 1); + } + } + return ActionResultType.PASS; + } - // FIXME: this is always true (host was de-referenced above) - if( blkState.isAir(world, te_pos) || blkState.isReplaceable( useContext ) || host != null ) - { - return place( held, te_pos, side.getOpposite(), player, hand, world, - pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 ); - } - } - return ActionResultType.PASS; - } + if (!world.isRemote) { + if (mop.getType() != RayTraceResult.Type.MISS) { + final SelectedPart sp = selectPart(player, host, + mop.getHitVec().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ())); - if( !world.isRemote ) - { - if( mop.getType() != RayTraceResult.Type.MISS ) - { - final SelectedPart sp = selectPart( player, host, - mop.getHitVec().add( -mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ() ) ); + if (sp.part != null) { + if (!player.isCrouching() && sp.part.onActivate(player, hand, mop.getHitVec())) { + return ActionResultType.FAIL; + } + } + } - if( sp.part != null ) - { - if( !player.isCrouching() && sp.part.onActivate( player, hand, mop.getHitVec() ) ) - { - return ActionResultType.FAIL; - } - } - } + final DimensionalCoord dc = host.getLocation(); + if (!Platform.hasPermissions(dc, player)) { + return ActionResultType.FAIL; + } - final DimensionalCoord dc = host.getLocation(); - if( !Platform.hasPermissions( dc, player ) ) - { - return ActionResultType.FAIL; - } + final AEPartLocation mySide = host.addPart(held, AEPartLocation.fromFacing(side), player, hand); + if (mySide != null) { + multiPart.maybeBlock().ifPresent(multiPartBlock -> { + BlockState blockState = world.getBlockState(pos); + final SoundType ss = multiPartBlock.getSoundType(blockState, world, pos, player); - final AEPartLocation mySide = host.addPart( held, AEPartLocation.fromFacing( side ), player, hand ); - if( mySide != null ) - { - multiPart.maybeBlock().ifPresent( multiPartBlock -> - { - BlockState blockState = world.getBlockState(pos); - final SoundType ss = multiPartBlock.getSoundType( blockState, world, pos, player ); + world.playSound(null, pos, ss.getPlaceSound(), SoundCategory.BLOCKS, (ss.getVolume() + 1.0F) / 2.0F, + ss.getPitch() * 0.8F); + }); - world.playSound( null, pos, ss.getPlaceSound(), SoundCategory.BLOCKS, ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F ); - } ); + if (!player.isCreative()) { + held.grow(-1); + if (held.getCount() == 0) { + player.setHeldItem(hand, ItemStack.EMPTY); + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held, hand)); + } + } + } + } else { + player.swingArm(hand); + } + return ActionResultType.SUCCESS; + } - if( !player.isCreative() ) - { - held.grow( -1 ); - if( held.getCount() == 0 ) - { - player.setHeldItem( hand, ItemStack.EMPTY ); - MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) ); - } - } - } - } - else - { - player.swingArm( hand ); - } - return ActionResultType.SUCCESS; - } + private static float getEyeOffset(final PlayerEntity p) { + if (p.world.isRemote) { + return Platform.getEyeOffset(p); + } - private static float getEyeOffset( final PlayerEntity p ) - { - if( p.world.isRemote ) - { - return Platform.getEyeOffset( p ); - } + return getEyeHeight(); + } - return getEyeHeight(); - } + private static SelectedPart selectPart(final PlayerEntity player, final IPartHost host, final Vec3d pos) { + AppEng.proxy.updateRenderMode(player); + final SelectedPart sp = host.selectPart(pos); + AppEng.proxy.updateRenderMode(null); - private static SelectedPart selectPart( final PlayerEntity player, final IPartHost host, final Vec3d pos ) - { - AppEng.proxy.updateRenderMode( player ); - final SelectedPart sp = host.selectPart( pos ); - AppEng.proxy.updateRenderMode( null ); + return sp; + } - return sp; - } + public static IFacadePart isFacade(final ItemStack held, final AEPartLocation side) { + if (held.getItem() instanceof IFacadeItem) { + return ((IFacadeItem) held.getItem()).createPartFromItemStack(held, side); + } - public static IFacadePart isFacade( final ItemStack held, final AEPartLocation side ) - { - if( held.getItem() instanceof IFacadeItem ) - { - return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side ); - } + return null; + } - return null; - } + @SubscribeEvent + public void playerInteract(final TickEvent.ClientTickEvent event) { + this.wasCanceled = false; + } - @SubscribeEvent - public void playerInteract( final TickEvent.ClientTickEvent event ) - { - this.wasCanceled = false; - } + @SubscribeEvent + public void playerInteract(final PlayerInteractEvent event) { + // Only handle the main hand event + if (event.getHand() != Hand.MAIN_HAND) { + return; + } - @SubscribeEvent - public void playerInteract( final PlayerInteractEvent event ) - { - // Only handle the main hand event - if( event.getHand() != Hand.MAIN_HAND ) - { - return; - } + if (event instanceof PlayerInteractEvent.RightClickEmpty && event.getPlayer().world.isRemote) { + // re-check to see if this event was already channeled, cause these two events + // are really stupid... + final RayTraceResult mop = Platform.rayTrace(event.getPlayer(), true, false); + final Minecraft mc = Minecraft.getInstance(); - if( event instanceof PlayerInteractEvent.RightClickEmpty && event.getPlayer().world.isRemote ) - { - // re-check to see if this event was already channeled, cause these two events are really stupid... - final RayTraceResult mop = Platform.rayTrace( event.getPlayer(), true, false ); - final Minecraft mc = Minecraft.getInstance(); + final float f = 1.0F; + final double d0 = mc.playerController.getBlockReachDistance(); + final Vec3d vec3 = mc.getRenderViewEntity().getEyePosition(f); - final float f = 1.0F; - final double d0 = mc.playerController.getBlockReachDistance(); - final Vec3d vec3 = mc.getRenderViewEntity().getEyePosition( f ); + if (mop instanceof BlockRayTraceResult && mop.getHitVec().distanceTo(vec3) < d0) { + BlockRayTraceResult brtr = (BlockRayTraceResult) mop; - if( mop instanceof BlockRayTraceResult && mop.getHitVec().distanceTo( vec3 ) < d0 ) - { - BlockRayTraceResult brtr = (BlockRayTraceResult) mop; + final World w = event.getEntity().world; + final TileEntity te = w.getTileEntity(brtr.getPos()); + if (te instanceof IPartHost && this.wasCanceled) { + event.setCanceled(true); + } + } else { + final ItemStack held = event.getPlayer().getHeldItem(event.getHand()); + final IItems items = AEApi.instance().definitions().items(); - final World w = event.getEntity().world; - final TileEntity te = w.getTileEntity( brtr.getPos() ); - if( te instanceof IPartHost && this.wasCanceled ) - { - event.setCanceled( true ); - } - } - else - { - final ItemStack held = event.getPlayer().getHeldItem( event.getHand() ); - final IItems items = AEApi.instance().definitions().items(); + boolean supportedItem = items.memoryCard().isSameAs(held); + supportedItem |= items.colorApplicator().isSameAs(held); - boolean supportedItem = items.memoryCard().isSameAs( held ); - supportedItem |= items.colorApplicator().isSameAs( held ); + if (event.getPlayer().isCrouching() && !held.isEmpty() && supportedItem) { + NetworkHandler.instance().sendToServer(new PacketClick(event.getHand())); + } + } + } else if (event instanceof PlayerInteractEvent.RightClickBlock && !event.getPlayer().world.isRemote) { + if (this.placing.get() != null) { + return; + } - if( event.getPlayer().isCrouching() && !held.isEmpty() && supportedItem ) - { - NetworkHandler.instance().sendToServer( new PacketClick( event.getHand() ) ); - } - } - } - else if( event instanceof PlayerInteractEvent.RightClickBlock && !event.getPlayer().world.isRemote ) - { - if( this.placing.get() != null ) - { - return; - } + this.placing.set(event); - this.placing.set( event ); + final ItemStack held = event.getPlayer().getHeldItem(event.getHand()); + if (place(held, event.getPos(), event.getFace(), event.getPlayer(), event.getHand(), + event.getPlayer().world, PlaceType.INTERACT_FIRST_PASS, 0) == ActionResultType.SUCCESS) { + event.setCanceled(true); + this.wasCanceled = true; + } - final ItemStack held = event.getPlayer().getHeldItem( event.getHand() ); - if( place( held, event.getPos(), event.getFace(), event.getPlayer(), event.getHand(), event.getPlayer().world, - PlaceType.INTERACT_FIRST_PASS, 0 ) == ActionResultType.SUCCESS ) - { - event.setCanceled( true ); - this.wasCanceled = true; - } + this.placing.set(null); + } + } - this.placing.set( null ); - } - } + private static float getEyeHeight() { + return eyeHeight; + } - private static float getEyeHeight() - { - return eyeHeight; - } + public static void setEyeHeight(final float eyeHeight) { + PartPlacement.eyeHeight = eyeHeight; + } - public static void setEyeHeight( final float eyeHeight ) - { - PartPlacement.eyeHeight = eyeHeight; - } - - public enum PlaceType - { - PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS - } + public enum PlaceType { + PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS + } } diff --git a/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java b/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java index 94fbfffde..dffc3827a 100644 --- a/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java @@ -18,42 +18,35 @@ package appeng.parts.automation; - import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.api.config.Upgrades; import appeng.util.inv.IAEAppEngInventory; +public class BlockUpgradeInventory extends UpgradeInventory { + private final Block block; -public class BlockUpgradeInventory extends UpgradeInventory -{ - private final Block block; + public BlockUpgradeInventory(final Block block, final IAEAppEngInventory parent, final int s) { + super(parent, s); + this.block = block; + } - public BlockUpgradeInventory( final Block block, final IAEAppEngInventory parent, final int s ) - { - super( parent, s ); - this.block = block; - } + @Override + public int getMaxInstalled(final Upgrades upgrades) { + int max = 0; - @Override - public int getMaxInstalled( final Upgrades upgrades ) - { - int max = 0; + for (final ItemStack is : upgrades.getSupported().keySet()) { + final Item encodedItem = is.getItem(); - for( final ItemStack is : upgrades.getSupported().keySet() ) - { - final Item encodedItem = is.getItem(); + if (encodedItem instanceof BlockItem && Block.getBlockFromItem(encodedItem) == this.block) { + max = upgrades.getSupported().get(is); + break; + } + } - if( encodedItem instanceof BlockItem && Block.getBlockFromItem( encodedItem ) == this.block ) - { - max = upgrades.getSupported().get( is ); - break; - } - } - - return max; - } + return max; + } } diff --git a/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java b/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java index 1f065e4d6..6d706b61f 100644 --- a/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java @@ -18,39 +18,32 @@ package appeng.parts.automation; - import net.minecraft.item.ItemStack; import appeng.api.config.Upgrades; import appeng.api.definitions.IItemDefinition; import appeng.util.inv.IAEAppEngInventory; +public final class DefinitionUpgradeInventory extends UpgradeInventory { + private final IItemDefinition definition; -public final class DefinitionUpgradeInventory extends UpgradeInventory -{ - private final IItemDefinition definition; + public DefinitionUpgradeInventory(final IItemDefinition definition, final IAEAppEngInventory parent, final int s) { + super(parent, s); - public DefinitionUpgradeInventory( final IItemDefinition definition, final IAEAppEngInventory parent, final int s ) - { - super( parent, s ); + this.definition = definition; + } - this.definition = definition; - } + @Override + public int getMaxInstalled(final Upgrades upgrades) { + int max = 0; - @Override - public int getMaxInstalled( final Upgrades upgrades ) - { - int max = 0; + for (final ItemStack stack : upgrades.getSupported().keySet()) { + if (this.definition.isSameAs(stack)) { + max = upgrades.getSupported().get(stack); + break; + } + } - for( final ItemStack stack : upgrades.getSupported().keySet() ) - { - if( this.definition.isSameAs( stack ) ) - { - max = upgrades.getSupported().get( stack ); - break; - } - } - - return max; - } + return max; + } } diff --git a/src/main/java/appeng/parts/automation/PartAbstractFormationPlane.java b/src/main/java/appeng/parts/automation/PartAbstractFormationPlane.java index 37d5cf31d..aac8327da 100644 --- a/src/main/java/appeng/parts/automation/PartAbstractFormationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAbstractFormationPlane.java @@ -1,8 +1,6 @@ package appeng.parts.automation; - -import appeng.api.config.Settings; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -11,6 +9,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import appeng.api.config.Actionable; +import appeng.api.config.Settings; import appeng.api.networking.security.IActionSource; import appeng.api.parts.IPart; import appeng.api.parts.IPartCollisionHelper; @@ -25,242 +24,211 @@ import appeng.api.util.AEPartLocation; import appeng.api.util.IConfigManager; import appeng.helpers.IPriorityHost; +public abstract class PartAbstractFormationPlane> extends PartUpgradeable + implements ICellContainer, IPriorityHost, IMEInventory { -public abstract class PartAbstractFormationPlane> extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory -{ + private boolean wasActive = false; + private int priority = 0; + protected boolean blocked = false; - private boolean wasActive = false; - private int priority = 0; - protected boolean blocked = false; + public PartAbstractFormationPlane(ItemStack is) { + super(is); + } - public PartAbstractFormationPlane( ItemStack is ) - { - super( is ); - } + protected abstract void updateHandler(); - protected abstract void updateHandler(); + @Override + protected int getUpgradeSlots() { + return 5; + } - @Override - protected int getUpgradeSlots() - { - return 5; - } + @Override + public void upgradesChanged() { + this.updateHandler(); + } - @Override - public void upgradesChanged() - { - this.updateHandler(); - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.updateHandler(); + this.getHost().markForSave(); + } - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.updateHandler(); - this.getHost().markForSave(); - } + public void stateChanged() { + final boolean currentActive = this.getProxy().isActive(); + if (this.wasActive != currentActive) { + this.wasActive = currentActive; + this.updateHandler(); + this.getHost().markForUpdate(); + } + } - public void stateChanged() - { - final boolean currentActive = this.getProxy().isActive(); - if( this.wasActive != currentActive ) - { - this.wasActive = currentActive; - this.updateHandler(); - this.getHost().markForUpdate(); - } - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + int minX = 1; + int minY = 1; + int maxX = 15; + int maxY = 15; - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - int minX = 1; - int minY = 1; - int maxX = 15; - int maxY = 15; + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); + final BlockPos pos = te.getPos(); - final BlockPos pos = te.getPos(); + final Direction e = bch.getWorldX(); + final Direction u = bch.getWorldY(); - final Direction e = bch.getWorldX(); - final Direction u = bch.getWorldY(); + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) { + minX = 0; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.getSide() ) ) - { - minX = 0; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) { + maxX = 16; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) ) - { - maxX = 16; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) { + minY = 0; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.getSide() ) ) - { - minY = 0; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(u)), this.getSide())) { + maxY = 16; + } + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( u ) ), this.getSide() ) ) - { - maxY = 16; - } - } + bch.addBox(5, 5, 14, 11, 11, 15); + bch.addBox(minX, minY, 15, maxX, maxY, 16); + } - bch.addBox( 5, 5, 14, 11, 11, 15 ); - bch.addBox( minX, minY, 15, maxX, maxY, 16 ); - } + public PlaneConnections getConnections() { - public PlaneConnections getConnections() - { + final Direction facingRight, facingUp; + AEPartLocation location = this.getSide(); + switch (location) { + case UP: + facingRight = Direction.EAST; + facingUp = Direction.NORTH; + break; + case DOWN: + facingRight = Direction.WEST; + facingUp = Direction.NORTH; + break; + case NORTH: + facingRight = Direction.WEST; + facingUp = Direction.UP; + break; + case SOUTH: + facingRight = Direction.EAST; + facingUp = Direction.UP; + break; + case WEST: + facingRight = Direction.SOUTH; + facingUp = Direction.UP; + break; + case EAST: + facingRight = Direction.NORTH; + facingUp = Direction.UP; + break; + default: + case INTERNAL: + return PlaneConnections.of(false, false, false, false); + } - final Direction facingRight, facingUp; - AEPartLocation location = this.getSide(); - switch( location ) - { - case UP: - facingRight = Direction.EAST; - facingUp = Direction.NORTH; - break; - case DOWN: - facingRight = Direction.WEST; - facingUp = Direction.NORTH; - break; - case NORTH: - facingRight = Direction.WEST; - facingUp = Direction.UP; - break; - case SOUTH: - facingRight = Direction.EAST; - facingUp = Direction.UP; - break; - case WEST: - facingRight = Direction.SOUTH; - facingUp = Direction.UP; - break; - case EAST: - facingRight = Direction.NORTH; - facingUp = Direction.UP; - break; - default: - case INTERNAL: - return PlaneConnections.of( false, false, false, false ); - } + boolean left = false, right = false, down = false, up = false; - boolean left = false, right = false, down = false, up = false; + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); + final BlockPos pos = te.getPos(); - final BlockPos pos = te.getPos(); + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())), + this.getSide())) { + left = true; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) ) - { - left = true; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) { + right = true; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) ) - { - right = true; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())), + this.getSide())) { + down = true; + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) ) - { - down = true; - } + if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) { + up = true; + } + } - if( this.isTransitionPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) ) - { - up = true; - } - } + return PlaneConnections.of(up, right, down, left); + } - return PlaneConnections.of( up, right, down, left ); - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + final TileEntity te = this.getHost().getTile(); + final AEPartLocation side = this.getSide(); - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - final TileEntity te = this.getHost().getTile(); - final AEPartLocation side = this.getSide(); + final BlockPos tePos = te.getPos().offset(side.getFacing()); - final BlockPos tePos = te.getPos().offset( side.getFacing() ); + this.blocked = !w.getBlockState(tePos).getMaterial().isReplaceable(); + } + } - this.blocked = !w.getBlockState( tePos ).getMaterial().isReplaceable(); - } - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 1; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 1; - } + protected boolean isTransitionPlane(final TileEntity blockTileEntity, final AEPartLocation side) { + if (blockTileEntity instanceof IPartHost) { + final IPart p = ((IPartHost) blockTileEntity).getPart(side); + return p != null && this.getClass() == p.getClass(); + } + return false; + } - protected boolean isTransitionPlane( final TileEntity blockTileEntity, final AEPartLocation side ) - { - if( blockTileEntity instanceof IPartHost ) - { - final IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); - return p != null && this.getClass() == p.getClass(); - } - return false; - } + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + return null; + } - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - return null; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return out; - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.priority = data.getInt("priority"); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.priority = data.getInt( "priority" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putInt("priority", this.getPriority()); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putInt( "priority", this.getPriority() ); - } + @Override + public int getPriority() { + return this.priority; + } - @Override - public int getPriority() - { - return this.priority; - } + @Override + public void setPriority(final int newValue) { + this.priority = newValue; + this.getHost().markForSave(); + this.updateHandler(); + } - @Override - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.getHost().markForSave(); - this.updateHandler(); - } + @Override + public void blinkCell(final int slot) { + // :P + } - @Override - public void blinkCell( final int slot ) - { - // :P - } - - @Override - public void saveChanges( final ICellInventory cell ) - { - // nope! - } + @Override + public void saveChanges(final ICellInventory cell) { + // nope! + } } diff --git a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java index f041a0fb3..871fd7279 100644 --- a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java @@ -18,10 +18,11 @@ package appeng.parts.automation; - import java.util.Collections; import java.util.List; +import javax.annotation.Nonnull; + import com.google.common.collect.Lists; import net.minecraft.block.BlockState; @@ -38,6 +39,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.world.storage.loot.LootParameters; +import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.common.ToolType; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -71,555 +78,494 @@ import appeng.parts.PartBasicState; import appeng.util.IWorldCallable; import appeng.util.Platform; import appeng.util.item.AEItemStack; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameters; -import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.FakePlayerFactory; - -import javax.annotation.Nonnull; - - -public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable -{ - - private static final PlaneModels MODELS = new PlaneModels( "part/annihilation_plane", "part/annihilation_plane_on" ); - - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } - - private final IActionSource mySrc = new MachineSource( this ); - private boolean isAccepting = true; - private boolean breaking = false; - - public PartAnnihilationPlane( final ItemStack is ) - { - super( is ); - } - - @Override - public TickRateModulation call( final World world ) throws Exception - { - this.breaking = false; - return this.breakBlock( true ); - } - - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - int minX = 1; - int minY = 1; - int maxX = 15; - int maxY = 15; - - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); - - final BlockPos pos = te.getPos(); - - final Direction e = bch.getWorldX(); - final Direction u = bch.getWorldY(); - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.getSide() ) ) - { - minX = 0; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) ) - { - maxX = 16; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.getSide() ) ) - { - minY = 0; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) ) - { - maxY = 16; - } - } - - bch.addBox( 5, 5, 14, 11, 11, 15 ); - // The smaller collision hitbox here is needed to allow for the entity collision event - bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 ); - } - - /** - * @return An object describing which adjacent planes this plane connects to visually. - */ - public PlaneConnections getConnections() - { - - final Direction facingRight, facingUp; - AEPartLocation location = this.getSide(); - switch( location ) - { - case UP: - facingRight = Direction.EAST; - facingUp = Direction.NORTH; - break; - case DOWN: - facingRight = Direction.WEST; - facingUp = Direction.NORTH; - break; - case NORTH: - facingRight = Direction.WEST; - facingUp = Direction.UP; - break; - case SOUTH: - facingRight = Direction.EAST; - facingUp = Direction.UP; - break; - case WEST: - facingRight = Direction.SOUTH; - facingUp = Direction.UP; - break; - case EAST: - facingRight = Direction.NORTH; - facingUp = Direction.UP; - break; - default: - case INTERNAL: - return PlaneConnections.of( false, false, false, false ); - } - - boolean left = false, right = false, down = false, up = false; - - final IPartHost host = this.getHost(); - if( host != null ) - { - final TileEntity te = host.getTile(); - - final BlockPos pos = te.getPos(); - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) ) - { - left = true; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) ) - { - right = true; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) ) - { - down = true; - } - - if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) ) - { - up = true; - } - } - - return PlaneConnections.of( up, right, down, left ); - } - - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - this.refresh(); - } - } - - @Override - public void onEntityCollision( final Entity entity ) - { - if( this.isAccepting && entity instanceof ItemEntity && entity.isAlive() && Platform.isServer() && this.getProxy().isActive() ) - { - boolean capture = false; - final BlockPos pos = this.getTile().getPos(); - - // This is the middle point of the entities BB, which is better suited for comparisons that don't rely on it - // "touching" the plane - double posYMiddle = ( entity.getBoundingBox().minY + entity.getBoundingBox().maxY ) / 2.0D; - - switch( this.getSide() ) - { - case DOWN: - case UP: - if( entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1 ) - { - if( entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1 ) - { - if( ( entity.getPosY() > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP ) || ( entity.getPosY() < pos.getY() + 0.1 && this.getSide() == AEPartLocation.DOWN ) ) - { - capture = true; - } - } - } - break; - case SOUTH: - case NORTH: - if( entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1 ) - { - if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 ) - { - if( ( entity.getPosZ() > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH ) || ( entity.getPosZ() < pos.getZ() + 0.1 && this.getSide() == AEPartLocation.NORTH ) ) - { - capture = true; - } - } - } - break; - case EAST: - case WEST: - if( entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1 ) - { - if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 ) - { - if( ( entity.getPosX() > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST ) || ( entity.getPosX() < pos.getX() + 0.1 && this.getSide() == AEPartLocation.WEST ) ) - { - capture = true; - } - } - } - break; - default: - // umm? - break; - } - - if( capture ) - { - final boolean changed = this.storeEntityItem( (ItemEntity) entity ); - - if( changed ) - { - AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(), new PacketTransitionEffect( entity.getPosX(), entity.getPosY(), entity.getPosZ(), this.getSide(), false ) ); - } - } - } - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 1; - } - - /** - * Stores an {@link ItemEntity} inside the network and either marks it as dead or sets it to the leftover stackSize. - * - * @param entityItem {@link ItemEntity} to store - */ - private boolean storeEntityItem( final ItemEntity entityItem ) - { - if( entityItem.isAlive() ) - { - final IAEItemStack overflow = this.storeItemStack( entityItem.getItem() ); - - return this.handleOverflow( entityItem, overflow ); - } - - return false; - } - - /** - * Stores an {@link ItemStack} inside the network. - * - * @param item {@link ItemStack} to store - * - * @return the leftover items, which could not be stored inside the network - */ - private IAEItemStack storeItemStack( final ItemStack item ) - { - final IAEItemStack itemToStore = AEItemStack.fromItemStack( item ); - try - { - final IStorageGrid storage = this.getProxy().getStorage(); - final IEnergyGrid energy = this.getProxy().getEnergy(); - final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), itemToStore, this.mySrc ); - - this.isAccepting = overflow == null; - - return overflow; - } - catch( final GridAccessException e1 ) - { - // :P - } - - return null; - } - - /** - * Handles a possible overflow or none at all. - * It will update the entity to match the leftover stack size as well as mark it as dead without any leftover - * amount. - * - * @param entityItem the entity to update or destroy - * @param overflow the leftover {@link IAEItemStack} - * - * @return true, if the entity was changed otherwise false. - */ - private boolean handleOverflow( final ItemEntity entityItem, final IAEItemStack overflow ) - { - if( overflow == null || overflow.getStackSize() == 0 ) - { - entityItem.remove(); - return true; - } - - final int oldStackSize = entityItem.getItem().getCount(); - final int newStackSize = (int) overflow.getStackSize(); - final boolean changed = oldStackSize != newStackSize; - - entityItem.getItem().setCount( newStackSize ); - - return changed; - } - - protected boolean isAnnihilationPlane( final TileEntity blockTileEntity, final AEPartLocation side ) - { - if( blockTileEntity instanceof IPartHost ) - { - final IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); - return p != null && p.getClass() == this.getClass(); - } - return false; - } - - @Override - @MENetworkEventSubscribe - public void chanRender( final MENetworkChannelsChanged c ) - { - this.refresh(); - this.getHost().markForUpdate(); - } - - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.refresh(); - this.getHost().markForUpdate(); - } - - private TickRateModulation breakBlock( final boolean modulate ) - { - if( this.isAccepting && this.getProxy().isActive() ) - { - try - { - final TileEntity te = this.getTile(); - final ServerWorld w = (ServerWorld) te.getWorld(); - - final BlockPos pos = te.getPos().offset( this.getSide().getFacing() ); - final IEnergyGrid energy = this.getProxy().getEnergy(); - - if( this.canHandleBlock( w, pos ) ) - { - final List items = this.obtainBlockDrops( w, pos ); - final float requiredPower = this.calculateEnergyUsage( w, pos, items ); - - final boolean hasPower = energy.extractAEPower( requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > requiredPower - 0.1; - final boolean canStore = this.canStoreItemStacks( items ); - - if( hasPower && canStore ) - { - if( modulate ) - { - energy.extractAEPower( requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG ); - this.breakBlockAndStoreItems( w, pos ); - AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w, new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) ); - } - else - { - this.breaking = true; - TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this ); - } - return TickRateModulation.URGENT; - } - } - } - catch( final GridAccessException e1 ) - { - // :P - } - } - - // nothing to do here :) - return TickRateModulation.IDLE; - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.AnnihilationPlane.getMin(), TickRates.AnnihilationPlane.getMax(), false, true ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( this.breaking ) - { - return TickRateModulation.URGENT; - } - - this.isAccepting = true; - return this.breakBlock( false ); - } - - /** - * Checks if this plane can handle the block at the specific coordinates. - */ - private boolean canHandleBlock( final ServerWorld w, final BlockPos pos ) - { - final BlockState state = w.getBlockState( pos ); - final Material material = state.getMaterial(); - final float hardness = state.getBlockHardness( w, pos ); - final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA || material == Material.WATER || material.isLiquid(); - final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK; - - return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody( Platform.getPlayer( w ), pos ); - } - - protected List obtainBlockDrops( final ServerWorld w, final BlockPos pos ) - { - final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft( w ); - final BlockState state = w.getBlockState( pos ); - ItemStack harvestTool = createHarvestTool(state); - - // In case the block does NOT allow us to harvest it without a tool, or the proper tool, - // do not return anything. - if (harvestTool == null && !state.getMaterial().isToolNotRequired()) { - return Collections.emptyList(); - } - - LootContext.Builder lootContext = new LootContext.Builder(w) - .withRandom(w.rand) - .withParameter(LootParameters.POSITION, pos) - .withNullableParameter(LootParameters.TOOL, harvestTool) - .withNullableParameter(LootParameters.THIS_ENTITY, fakePlayer) - .withNullableParameter(LootParameters.BLOCK_ENTITY, w.getTileEntity(pos)); - return state.getDrops(lootContext); - } - - /** - * Checks if this plane can handle the block at the specific coordinates. - */ - protected float calculateEnergyUsage( final ServerWorld w, final BlockPos pos, final List items ) - { - final BlockState state = w.getBlockState( pos ); - final float hardness = state.getBlockHardness( w, pos ); - - float requiredEnergy = 1 + hardness; - for( final ItemStack is : items ) - { - requiredEnergy += is.getCount(); - } - - return requiredEnergy; - } - - /** - * Checks if the network can store the possible drops. - * - * 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( final List itemStacks ) - { - boolean canStore = itemStacks.isEmpty(); - - try - { - final IStorageGrid storage = this.getProxy().getStorage(); - - for( final ItemStack itemStack : itemStacks ) - { - final IAEItemStack itemToTest = AEItemStack.fromItemStack( itemStack ); - final IAEItemStack overflow = storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).injectItems( itemToTest, Actionable.SIMULATE, this.mySrc ); - if( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() ) - { - canStore = true; - } - } - } - catch( final GridAccessException e ) - { - // :P - } - - this.isAccepting = canStore; - return canStore; - } - - private void breakBlockAndStoreItems( final ServerWorld w, final BlockPos pos ) - { - w.destroyBlock( pos, true ); - - final AxisAlignedBB box = new AxisAlignedBB( pos ).grow( 0.2 ); - for( final Object ei : w.getEntitiesWithinAABB( ItemEntity.class, box ) ) - { - if( ei instanceof ItemEntity ) - { - final ItemEntity entityItem = (ItemEntity) ei; - this.storeEntityItem( entityItem ); - } - } - } - - private void refresh() - { - this.isAccepting = true; - - getTile().requestModelDataUpdate(); - - try - { - this.getProxy().getTick().alertDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } - - @Nonnull - @Override - public IModelData getModelData() { - return new PlaneModelData(getConnections()); - } - - /** - * Creates the fake (and temporary) tool that will be used to calculate the loot tables of - * a block this plane wants to break. - * @param state The state of the block about to be broken. - */ - protected ItemStack createHarvestTool(BlockState state) { - // Try to use the right tool... - ToolType harvestToolType = state.getBlock().getHarvestTool(state); - if (harvestToolType == ToolType.AXE) { - return new ItemStack(Items.DIAMOND_AXE, 1); - } else if (harvestToolType == ToolType.SHOVEL) { - return new ItemStack(Items.DIAMOND_SHOVEL, 1); - } else if (harvestToolType == ToolType.PICKAXE) { - return new ItemStack(Items.DIAMOND_PICKAXE, 1); - } else { - return null; - } - } + +public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable { + + private static final PlaneModels MODELS = new PlaneModels("part/annihilation_plane", "part/annihilation_plane_on"); + + @PartModels + public static List getModels() { + return MODELS.getModels(); + } + + private final IActionSource mySrc = new MachineSource(this); + private boolean isAccepting = true; + private boolean breaking = false; + + public PartAnnihilationPlane(final ItemStack is) { + super(is); + } + + @Override + public TickRateModulation call(final World world) throws Exception { + this.breaking = false; + return this.breakBlock(true); + } + + @Override + public void getBoxes(final IPartCollisionHelper bch) { + int minX = 1; + int minY = 1; + int maxX = 15; + int maxY = 15; + + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); + + final BlockPos pos = te.getPos(); + + final Direction e = bch.getWorldX(); + final Direction u = bch.getWorldY(); + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) { + minX = 0; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) { + maxX = 16; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) { + minY = 0; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) { + maxY = 16; + } + } + + bch.addBox(5, 5, 14, 11, 11, 15); + // The smaller collision hitbox here is needed to allow for the entity collision + // event + bch.addBox(minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16); + } + + /** + * @return An object describing which adjacent planes this plane connects to + * visually. + */ + public PlaneConnections getConnections() { + + final Direction facingRight, facingUp; + AEPartLocation location = this.getSide(); + switch (location) { + case UP: + facingRight = Direction.EAST; + facingUp = Direction.NORTH; + break; + case DOWN: + facingRight = Direction.WEST; + facingUp = Direction.NORTH; + break; + case NORTH: + facingRight = Direction.WEST; + facingUp = Direction.UP; + break; + case SOUTH: + facingRight = Direction.EAST; + facingUp = Direction.UP; + break; + case WEST: + facingRight = Direction.SOUTH; + facingUp = Direction.UP; + break; + case EAST: + facingRight = Direction.NORTH; + facingUp = Direction.UP; + break; + default: + case INTERNAL: + return PlaneConnections.of(false, false, false, false); + } + + boolean left = false, right = false, down = false, up = false; + + final IPartHost host = this.getHost(); + if (host != null) { + final TileEntity te = host.getTile(); + + final BlockPos pos = te.getPos(); + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())), + this.getSide())) { + left = true; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) { + right = true; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())), + this.getSide())) { + down = true; + } + + if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) { + up = true; + } + } + + return PlaneConnections.of(up, right, down, left); + } + + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + this.refresh(); + } + } + + @Override + public void onEntityCollision(final Entity entity) { + if (this.isAccepting && entity instanceof ItemEntity && entity.isAlive() && Platform.isServer() + && this.getProxy().isActive()) { + boolean capture = false; + final BlockPos pos = this.getTile().getPos(); + + // This is the middle point of the entities BB, which is better suited for + // comparisons that don't rely on it + // "touching" the plane + double posYMiddle = (entity.getBoundingBox().minY + entity.getBoundingBox().maxY) / 2.0D; + + switch (this.getSide()) { + case DOWN: + case UP: + if (entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1) { + if (entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1) { + if ((entity.getPosY() > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP) + || (entity.getPosY() < pos.getY() + 0.1 && this.getSide() == AEPartLocation.DOWN)) { + capture = true; + } + } + } + break; + case SOUTH: + case NORTH: + if (entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1) { + if (posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1) { + if ((entity.getPosZ() > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH) + || (entity.getPosZ() < pos.getZ() + 0.1 + && this.getSide() == AEPartLocation.NORTH)) { + capture = true; + } + } + } + break; + case EAST: + case WEST: + if (entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1) { + if (posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1) { + if ((entity.getPosX() > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST) + || (entity.getPosX() < pos.getX() + 0.1 && this.getSide() == AEPartLocation.WEST)) { + capture = true; + } + } + } + break; + default: + // umm? + break; + } + + if (capture) { + final boolean changed = this.storeEntityItem((ItemEntity) entity); + + if (changed) { + AppEng.proxy.sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, + this.getTile().getWorld(), new PacketTransitionEffect(entity.getPosX(), entity.getPosY(), + entity.getPosZ(), this.getSide(), false)); + } + } + } + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 1; + } + + /** + * Stores an {@link ItemEntity} inside the network and either marks it as dead + * or sets it to the leftover stackSize. + * + * @param entityItem {@link ItemEntity} to store + */ + private boolean storeEntityItem(final ItemEntity entityItem) { + if (entityItem.isAlive()) { + final IAEItemStack overflow = this.storeItemStack(entityItem.getItem()); + + return this.handleOverflow(entityItem, overflow); + } + + return false; + } + + /** + * Stores an {@link ItemStack} inside the network. + * + * @param item {@link ItemStack} to store + * + * @return the leftover items, which could not be stored inside the network + */ + private IAEItemStack storeItemStack(final ItemStack item) { + final IAEItemStack itemToStore = AEItemStack.fromItemStack(item); + try { + final IStorageGrid storage = this.getProxy().getStorage(); + final IEnergyGrid energy = this.getProxy().getEnergy(); + final IAEItemStack overflow = Platform.poweredInsert(energy, + storage.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)), + itemToStore, this.mySrc); + + this.isAccepting = overflow == null; + + return overflow; + } catch (final GridAccessException e1) { + // :P + } + + return null; + } + + /** + * Handles a possible overflow or none at all. It will update the entity to + * match the leftover stack size as well as mark it as dead without any leftover + * amount. + * + * @param entityItem the entity to update or destroy + * @param overflow the leftover {@link IAEItemStack} + * + * @return true, if the entity was changed otherwise false. + */ + private boolean handleOverflow(final ItemEntity entityItem, final IAEItemStack overflow) { + if (overflow == null || overflow.getStackSize() == 0) { + entityItem.remove(); + return true; + } + + final int oldStackSize = entityItem.getItem().getCount(); + final int newStackSize = (int) overflow.getStackSize(); + final boolean changed = oldStackSize != newStackSize; + + entityItem.getItem().setCount(newStackSize); + + return changed; + } + + protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) { + if (blockTileEntity instanceof IPartHost) { + final IPart p = ((IPartHost) blockTileEntity).getPart(side); + return p != null && p.getClass() == this.getClass(); + } + return false; + } + + @Override + @MENetworkEventSubscribe + public void chanRender(final MENetworkChannelsChanged c) { + this.refresh(); + this.getHost().markForUpdate(); + } + + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.refresh(); + this.getHost().markForUpdate(); + } + + private TickRateModulation breakBlock(final boolean modulate) { + if (this.isAccepting && this.getProxy().isActive()) { + try { + final TileEntity te = this.getTile(); + final ServerWorld w = (ServerWorld) te.getWorld(); + + final BlockPos pos = te.getPos().offset(this.getSide().getFacing()); + final IEnergyGrid energy = this.getProxy().getEnergy(); + + if (this.canHandleBlock(w, pos)) { + final List items = this.obtainBlockDrops(w, pos); + final float requiredPower = this.calculateEnergyUsage(w, pos, items); + + final boolean hasPower = energy.extractAEPower(requiredPower, Actionable.SIMULATE, + PowerMultiplier.CONFIG) > requiredPower - 0.1; + final boolean canStore = this.canStoreItemStacks(items); + + if (hasPower && canStore) { + if (modulate) { + energy.extractAEPower(requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG); + this.breakBlockAndStoreItems(w, pos); + AppEng.proxy.sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 64, w, + new PacketTransitionEffect(pos.getX(), pos.getY(), pos.getZ(), this.getSide(), + true)); + } else { + this.breaking = true; + TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this); + } + return TickRateModulation.URGENT; + } + } + } catch (final GridAccessException e1) { + // :P + } + } + + // nothing to do here :) + return TickRateModulation.IDLE; + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.AnnihilationPlane.getMin(), TickRates.AnnihilationPlane.getMax(), false, + true); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (this.breaking) { + return TickRateModulation.URGENT; + } + + this.isAccepting = true; + return this.breakBlock(false); + } + + /** + * Checks if this plane can handle the block at the specific coordinates. + */ + private boolean canHandleBlock(final ServerWorld w, final BlockPos pos) { + final BlockState state = w.getBlockState(pos); + final Material material = state.getMaterial(); + final float hardness = state.getBlockHardness(w, pos); + final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA + || material == Material.WATER || material.isLiquid(); + final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL + || state.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK; + + return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock(pos) && w.isBlockLoaded(pos) + && w.canMineBlockBody(Platform.getPlayer(w), pos); + } + + protected List obtainBlockDrops(final ServerWorld w, final BlockPos pos) { + final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft(w); + final BlockState state = w.getBlockState(pos); + ItemStack harvestTool = createHarvestTool(state); + + // In case the block does NOT allow us to harvest it without a tool, or the + // proper tool, + // do not return anything. + if (harvestTool == null && !state.getMaterial().isToolNotRequired()) { + return Collections.emptyList(); + } + + LootContext.Builder lootContext = new LootContext.Builder(w).withRandom(w.rand) + .withParameter(LootParameters.POSITION, pos).withNullableParameter(LootParameters.TOOL, harvestTool) + .withNullableParameter(LootParameters.THIS_ENTITY, fakePlayer) + .withNullableParameter(LootParameters.BLOCK_ENTITY, w.getTileEntity(pos)); + return state.getDrops(lootContext); + } + + /** + * Checks if this plane can handle the block at the specific coordinates. + */ + protected float calculateEnergyUsage(final ServerWorld w, final BlockPos pos, final List items) { + final BlockState state = w.getBlockState(pos); + final float hardness = state.getBlockHardness(w, pos); + + float requiredEnergy = 1 + hardness; + for (final ItemStack is : items) { + requiredEnergy += is.getCount(); + } + + return requiredEnergy; + } + + /** + * Checks if the network can store the possible drops. + * + * 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(final List itemStacks) { + boolean canStore = itemStacks.isEmpty(); + + try { + final IStorageGrid storage = this.getProxy().getStorage(); + + for (final ItemStack itemStack : itemStacks) { + final IAEItemStack itemToTest = AEItemStack.fromItemStack(itemStack); + final IAEItemStack overflow = storage + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) + .injectItems(itemToTest, Actionable.SIMULATE, this.mySrc); + if (overflow == null || itemToTest.getStackSize() > overflow.getStackSize()) { + canStore = true; + } + } + } catch (final GridAccessException e) { + // :P + } + + this.isAccepting = canStore; + return canStore; + } + + private void breakBlockAndStoreItems(final ServerWorld w, final BlockPos pos) { + w.destroyBlock(pos, true); + + final AxisAlignedBB box = new AxisAlignedBB(pos).grow(0.2); + for (final Object ei : w.getEntitiesWithinAABB(ItemEntity.class, box)) { + if (ei instanceof ItemEntity) { + final ItemEntity entityItem = (ItemEntity) ei; + this.storeEntityItem(entityItem); + } + } + } + + private void refresh() { + this.isAccepting = true; + + getTile().requestModelDataUpdate(); + + try { + this.getProxy().getTick().alertDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } + + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } + + @Nonnull + @Override + public IModelData getModelData() { + return new PlaneModelData(getConnections()); + } + + /** + * Creates the fake (and temporary) tool that will be used to calculate the loot + * tables of a block this plane wants to break. + * + * @param state The state of the block about to be broken. + */ + protected ItemStack createHarvestTool(BlockState state) { + // Try to use the right tool... + ToolType harvestToolType = state.getBlock().getHarvestTool(state); + if (harvestToolType == ToolType.AXE) { + return new ItemStack(Items.DIAMOND_AXE, 1); + } else if (harvestToolType == ToolType.SHOVEL) { + return new ItemStack(Items.DIAMOND_SHOVEL, 1); + } else if (harvestToolType == ToolType.PICKAXE) { + return new ItemStack(Items.DIAMOND_PICKAXE, 1); + } else { + return null; + } + } } diff --git a/src/main/java/appeng/parts/automation/PartExportBus.java b/src/main/java/appeng/parts/automation/PartExportBus.java index 3987e9502..1491c2239 100644 --- a/src/main/java/appeng/parts/automation/PartExportBus.java +++ b/src/main/java/appeng/parts/automation/PartExportBus.java @@ -18,11 +18,6 @@ package appeng.parts.automation; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerUpgradeable; -import appeng.fluids.container.ContainerFluidInterface; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -57,10 +52,13 @@ import appeng.api.storage.IMEMonitor; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.util.AECableType; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerUpgradeable; import appeng.core.AELog; import appeng.core.AppEng; import appeng.core.settings.TickRates; - +import appeng.fluids.container.ContainerFluidInterface; import appeng.helpers.MultiCraftingTracker; import appeng.helpers.Reflected; import appeng.items.parts.PartModels; @@ -71,309 +69,256 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.item.AEItemStack; +public class PartExportBus extends PartSharedItemBus implements ICraftingRequester { -public class PartExportBus extends PartSharedItemBus implements ICraftingRequester -{ + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/export_bus_base"); - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" ); + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/export_bus_off")); - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_off" ) ); + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/export_bus_on")); - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_on" ) ); + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/export_bus_has_channel")); - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_has_channel" ) ); + private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9); + private final IActionSource mySrc; + private long itemToSend = 1; + private boolean didSomething = false; + private int nextSlot = 0; - private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 ); - private final IActionSource mySrc; - private long itemToSend = 1; - private boolean didSomething = false; - private int nextSlot = 0; + @Reflected + public PartExportBus(final ItemStack is) { + super(is); - @Reflected - public PartExportBus( final ItemStack is ) - { - 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.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + this.mySrc = new MachineSource(this); + } - 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.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - this.mySrc = new MachineSource( this ); - } + @Override + public void readFromNBT(final CompoundNBT extra) { + super.readFromNBT(extra); + this.craftingTracker.readFromNBT(extra); + this.nextSlot = extra.getInt("nextSlot"); + } - @Override - public void readFromNBT( final CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.craftingTracker.readFromNBT( extra ); - this.nextSlot = extra.getInt( "nextSlot" ); - } + @Override + public void writeToNBT(final CompoundNBT extra) { + super.writeToNBT(extra); + this.craftingTracker.writeToNBT(extra); + extra.putInt("nextSlot", this.nextSlot); + } - @Override - public void writeToNBT( final CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.craftingTracker.writeToNBT( extra ); - extra.putInt( "nextSlot", this.nextSlot ); - } + @Override + protected TickRateModulation doBusWork() { + if (!this.getProxy().isActive() || !this.canDoBusWork()) { + return TickRateModulation.IDLE; + } - @Override - protected TickRateModulation doBusWork() - { - if( !this.getProxy().isActive() || !this.canDoBusWork() ) - { - return TickRateModulation.IDLE; - } + this.itemToSend = this.calculateItemsToSend(); + this.didSomething = false; - this.itemToSend = this.calculateItemsToSend(); - this.didSomething = false; + try { + final InventoryAdaptor destination = this.getHandler(); + final IMEMonitor inv = this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final IEnergyGrid energy = this.getProxy().getEnergy(); + final ICraftingGrid cg = this.getProxy().getCrafting(); + final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE); + final SchedulingMode schedulingMode = (SchedulingMode) this.getConfigManager() + .getSetting(Settings.SCHEDULING_MODE); - try - { - final InventoryAdaptor destination = this.getHandler(); - final IMEMonitor inv = this.getProxy() - .getStorage() - .getInventory( - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final IEnergyGrid energy = this.getProxy().getEnergy(); - final ICraftingGrid cg = this.getProxy().getCrafting(); - final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); - final SchedulingMode schedulingMode = (SchedulingMode) this.getConfigManager().getSetting( Settings.SCHEDULING_MODE ); + if (destination != null) { + int x = 0; - if( destination != null ) - { - int x = 0; + for (x = 0; x < this.availableSlots() && this.itemToSend > 0; x++) { + final int slotToExport = this.getStartingSlot(schedulingMode, x); - for( x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ ) - { - final int slotToExport = this.getStartingSlot( schedulingMode, x ); + final IAEItemStack ais = this.getConfig().getAEStackInSlot(slotToExport); - final IAEItemStack ais = this.getConfig().getAEStackInSlot( slotToExport ); + if (ais == null || this.itemToSend <= 0 || this.craftOnly()) { + if (this.isCraftingEnabled()) { + this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, + destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc) + || this.didSomething; + } + continue; + } - if( ais == null || this.itemToSend <= 0 || this.craftOnly() ) - { - if( this.isCraftingEnabled() ) - { - this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), - this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething; - } - continue; - } + final long before = this.itemToSend; - final long before = this.itemToSend; + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + for (final IAEItemStack o : ImmutableList.copyOf(inv.getStorageList().findFuzzy(ais, fzMode))) { + this.pushItemIntoTarget(destination, energy, inv, o); + if (this.itemToSend <= 0) { + break; + } + } + } else { + this.pushItemIntoTarget(destination, energy, inv, ais); + } - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - for( final IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) ) - { - this.pushItemIntoTarget( destination, energy, inv, o ); - if( this.itemToSend <= 0 ) - { - break; - } - } - } - else - { - this.pushItemIntoTarget( destination, energy, inv, ais ); - } + if (this.itemToSend == before && this.isCraftingEnabled()) { + this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, + destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc) + || this.didSomething; + } + } - if( this.itemToSend == before && this.isCraftingEnabled() ) - { - this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), - this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething; - } - } + this.updateSchedulingMode(schedulingMode, x); + } else { + return TickRateModulation.SLEEP; + } + } catch (final GridAccessException e) { + // :P + } - this.updateSchedulingMode( schedulingMode, x ); - } - else - { - return TickRateModulation.SLEEP; - } - } - catch( final GridAccessException e ) - { - // :P - } + return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } - return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER; - } + @Override + public void getBoxes(final 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 void getBoxes( final 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 float getCableConnectionLength(AECableType cable) { + return 5; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 5; - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerUpgradeable.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerUpgradeable.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.ExportBus.getMin(), TickRates.ExportBus.getMax(), this.isSleeping(), false); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.ExportBus.getMin(), TickRates.ExportBus.getMax(), this.isSleeping(), false ); - } + @Override + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); + } - @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.doBusWork(); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.doBusWork(); - } + @Override + public ImmutableSet getRequestedJobs() { + return this.craftingTracker.getRequestedJobs(); + } - @Override - public ImmutableSet getRequestedJobs() - { - return this.craftingTracker.getRequestedJobs(); - } + @Override + public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) { + final InventoryAdaptor d = this.getHandler(); - @Override - public IAEItemStack injectCraftedItems( final ICraftingLink link, final IAEItemStack items, final Actionable mode ) - { - final InventoryAdaptor d = this.getHandler(); + try { + if (d != null && this.getProxy().isActive()) { + final IEnergyGrid energy = this.getProxy().getEnergy(); + final double power = items.getStackSize(); - try - { - if( d != null && this.getProxy().isActive() ) - { - final IEnergyGrid energy = this.getProxy().getEnergy(); - final double power = items.getStackSize(); + if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) { + if (mode == Actionable.MODULATE) { + return AEItemStack.fromItemStack(d.addItems(items.createItemStack())); + } + return AEItemStack.fromItemStack(d.simulateAdd(items.createItemStack())); + } + } + } catch (final GridAccessException e) { + AELog.debug(e); + } - if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 ) - { - if( mode == Actionable.MODULATE ) - { - return AEItemStack.fromItemStack( d.addItems( items.createItemStack() ) ); - } - return AEItemStack.fromItemStack( d.simulateAdd( items.createItemStack() ) ); - } - } - } - catch( final GridAccessException e ) - { - AELog.debug( e ); - } + return items; + } - return items; - } + @Override + public void jobStateChange(final ICraftingLink link) { + this.craftingTracker.jobStateChange(link); + } - @Override - public void jobStateChange( final ICraftingLink link ) - { - this.craftingTracker.jobStateChange( link ); - } + @Override + protected boolean isSleeping() { + return this.getHandler() == null || super.isSleeping(); + } - @Override - protected boolean isSleeping() - { - return this.getHandler() == null || super.isSleeping(); - } + private boolean craftOnly() { + return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES; + } - private boolean craftOnly() - { - return this.getConfigManager().getSetting( Settings.CRAFT_ONLY ) == YesNo.YES; - } + private boolean isCraftingEnabled() { + return this.getInstalledUpgrades(Upgrades.CRAFTING) > 0; + } - private boolean isCraftingEnabled() - { - return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0; - } + private void pushItemIntoTarget(final InventoryAdaptor d, final IEnergyGrid energy, + final IMEInventory inv, IAEItemStack ais) { + final ItemStack is = ais.createItemStack(); + is.setCount((int) this.itemToSend); - private void pushItemIntoTarget( final InventoryAdaptor d, final IEnergyGrid energy, final IMEInventory inv, IAEItemStack ais ) - { - final ItemStack is = ais.createItemStack(); - is.setCount( (int) this.itemToSend ); + final ItemStack o = d.simulateAdd(is); + final long canFit = o.isEmpty() ? this.itemToSend : this.itemToSend - o.getCount(); - final ItemStack o = d.simulateAdd( is ); - final long canFit = o.isEmpty() ? this.itemToSend : this.itemToSend - o.getCount(); + if (canFit > 0) { + ais = ais.copy(); + ais.setStackSize(canFit); + final IAEItemStack itemsToAdd = Platform.poweredExtraction(energy, inv, ais, this.mySrc); - if( canFit > 0 ) - { - ais = ais.copy(); - ais.setStackSize( canFit ); - final IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, this.mySrc ); + if (itemsToAdd != null) { + this.itemToSend -= itemsToAdd.getStackSize(); - if( itemsToAdd != null ) - { - this.itemToSend -= itemsToAdd.getStackSize(); + final ItemStack failed = d.addItems(itemsToAdd.createItemStack()); + if (!failed.isEmpty()) { + ais.setStackSize(failed.getCount()); + inv.injectItems(ais, Actionable.MODULATE, this.mySrc); + } else { + this.didSomething = true; + } + } + } + } - final ItemStack failed = d.addItems( itemsToAdd.createItemStack() ); - if( !failed.isEmpty() ) - { - ais.setStackSize( failed.getCount() ); - inv.injectItems( ais, Actionable.MODULATE, this.mySrc ); - } - else - { - this.didSomething = true; - } - } - } - } + private int getStartingSlot(final SchedulingMode schedulingMode, final int x) { + if (schedulingMode == SchedulingMode.RANDOM) { + return Platform.getRandom().nextInt(this.availableSlots()); + } - private int getStartingSlot( final SchedulingMode schedulingMode, final int x ) - { - if( schedulingMode == SchedulingMode.RANDOM ) - { - return Platform.getRandom().nextInt( this.availableSlots() ); - } + if (schedulingMode == SchedulingMode.ROUNDROBIN) { + return (this.nextSlot + x) % this.availableSlots(); + } - if( schedulingMode == SchedulingMode.ROUNDROBIN ) - { - return ( this.nextSlot + x ) % this.availableSlots(); - } + return x; + } - return x; - } + private void updateSchedulingMode(final SchedulingMode schedulingMode, final int x) { + if (schedulingMode == SchedulingMode.ROUNDROBIN) { + this.nextSlot = (this.nextSlot + x) % this.availableSlots(); + } + } - private void updateSchedulingMode( final SchedulingMode schedulingMode, final int x ) - { - if( schedulingMode == SchedulingMode.ROUNDROBIN ) - { - this.nextSlot = ( this.nextSlot + x ) % this.availableSlots(); - } - } - - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/parts/automation/PartFormationPlane.java b/src/main/java/appeng/parts/automation/PartFormationPlane.java index 01f7c5e51..3694e988f 100644 --- a/src/main/java/appeng/parts/automation/PartFormationPlane.java +++ b/src/main/java/appeng/parts/automation/PartFormationPlane.java @@ -18,15 +18,13 @@ package appeng.parts.automation; - import java.util.ArrayList; import java.util.Collections; import java.util.List; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerFormationPlane; -import appeng.fluids.container.ContainerFluidInterface; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; @@ -68,8 +66,11 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.api.util.AEPartLocation; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerFormationPlane; import appeng.core.AEConfig; - +import appeng.fluids.container.ContainerFluidInterface; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; import appeng.me.storage.MEInventoryHandler; @@ -79,336 +80,289 @@ import appeng.util.inv.InvOperation; import appeng.util.prioritylist.FuzzyPriorityList; import appeng.util.prioritylist.PrecisePriorityList; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +public class PartFormationPlane extends PartAbstractFormationPlane { + private static final PlaneModels MODELS = new PlaneModels("part/formation_plane", "part/formation_plane_on"); -public class PartFormationPlane extends PartAbstractFormationPlane -{ + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - private static final PlaneModels MODELS = new PlaneModels( "part/formation_plane", "part/formation_plane_on" ); + private final MEInventoryHandler myHandler = new MEInventoryHandler<>(this, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory(this, 63); - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + public PartFormationPlane(final ItemStack is) { + super(is); - private final MEInventoryHandler myHandler = new MEInventoryHandler<>( this, AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ) ); - private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); + this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); + this.getConfigManager().registerSetting(Settings.PLACE_BLOCK, YesNo.YES); + this.updateHandler(); + } - public PartFormationPlane( final ItemStack is ) - { - super( is ); + @Override + protected void updateHandler() { + this.myHandler.setBaseAccess(AccessRestriction.WRITE); + this.myHandler.setWhitelist( + this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST); + this.myHandler.setPriority(this.getPriority()); - this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.getConfigManager().registerSetting( Settings.PLACE_BLOCK, YesNo.YES ); - this.updateHandler(); - } + final IItemList priorityList = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); - @Override - protected void updateHandler() - { - this.myHandler.setBaseAccess( AccessRestriction.WRITE ); - this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); - this.myHandler.setPriority( this.getPriority() ); + final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9; + for (int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++) { + final IAEItemStack is = this.Config.getAEStackInSlot(x); + if (is != null) { + priorityList.add(is); + } + } - final IItemList priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); + 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)); + } - final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; - for( int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++ ) - { - final IAEItemStack is = this.Config.getAEStackInSlot( x ); - if( is != null ) - { - priorityList.add( is ); - } - } + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } - 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 ) ); - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + super.onChangeInventory(inv, slot, mc, removedStack, newStack); - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + if (inv == this.Config) { + this.updateHandler(); + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - super.onChangeInventory( inv, slot, mc, removedStack, newStack ); + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.Config.readFromNBT(data, "config"); + this.updateHandler(); + } - if( inv == this.Config ) - { - this.updateHandler(); - } - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.Config.writeToNBT(data, "config"); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.Config.readFromNBT( data, "config" ); - this.updateHandler(); - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("config")) { + return this.Config; + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.Config.writeToNBT( data, "config" ); - } + return super.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "config" ) ) - { - return this.Config; - } + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.stateChanged(); + } - return super.getInventoryByName( name ); - } + @MENetworkEventSubscribe + public void updateChannels(final MENetworkChannelsChanged changedChannels) { + this.stateChanged(); + } - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.stateChanged(); - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerFormationPlane.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } - @MENetworkEventSubscribe - public void updateChannels( final MENetworkChannelsChanged changedChannels ) - { - this.stateChanged(); - } + @Override + public List getCellArray(final IStorageChannel channel) { + if (this.getProxy().isActive() + && channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + final List handler = new ArrayList<>(1); + handler.add(this.myHandler); + return handler; + } + return Collections.emptyList(); + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerFormationPlane.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final IActionSource src) { + if (this.blocked || input == null || input.getStackSize() <= 0) { + return input; + } - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - final List handler = new ArrayList<>( 1 ); - handler.add( this.myHandler ); - return handler; - } - return Collections.emptyList(); - } + final YesNo placeBlock = (YesNo) this.getConfigManager().getSetting(Settings.PLACE_BLOCK); - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src ) - { - if( this.blocked || input == null || input.getStackSize() <= 0 ) - { - return input; - } + final ItemStack is = input.createItemStack(); + final Item i = is.getItem(); - final YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK ); + long maxStorage = Math.min(input.getStackSize(), is.getMaxStackSize()); + boolean worked = false; - final ItemStack is = input.createItemStack(); - final Item i = is.getItem(); + final TileEntity te = this.getHost().getTile(); + final World w = te.getWorld(); + final AEPartLocation side = this.getSide(); - long maxStorage = Math.min( input.getStackSize(), is.getMaxStackSize() ); - boolean worked = false; + final BlockPos placePos = te.getPos().offset(side.getFacing()); - final TileEntity te = this.getHost().getTile(); - final World w = te.getWorld(); - final AEPartLocation side = this.getSide(); + if (w.getBlockState(placePos).getMaterial().isReplaceable()) { + if (placeBlock == YesNo.YES && (i instanceof BlockItem || i instanceof IPlantable + || i instanceof FireworkStarItem || i instanceof FireworkRocketItem || i instanceof IPartItem)) { + final PlayerEntity player = Platform.getPlayer((ServerWorld) w); + Platform.configurePlayer(player, side, this.getTile()); + Hand hand = player.getActiveHand(); + player.setHeldItem(hand, is); - final BlockPos placePos = te.getPos().offset( side.getFacing() ); + maxStorage = is.getCount(); + worked = true; + if (type == Actionable.MODULATE) { + // The side the plane is attached to will be considered the look direction + // in terms of placing an item + Direction lookDirection = side.getFacing(); - if( w.getBlockState( placePos ).getMaterial().isReplaceable() ) - { - if( placeBlock == YesNo.YES && ( i instanceof BlockItem || i instanceof IPlantable || i instanceof FireworkStarItem || i instanceof FireworkRocketItem || i instanceof IPartItem ) ) - { - final PlayerEntity player = Platform.getPlayer( (ServerWorld) w ); - Platform.configurePlayer( player, side, this.getTile() ); - Hand hand = player.getActiveHand(); - player.setHeldItem( hand, is ); + // FIXME No idea what any of this is _supposed_ to do, comment badly needed + if (i instanceof IPlantable || i instanceof WallOrFloorItem) { + boolean Worked = false; - maxStorage = is.getCount(); - worked = true; - if( type == Actionable.MODULATE ) - { - // The side the plane is attached to will be considered the look direction - // in terms of placing an item - Direction lookDirection = side.getFacing(); + // Up or Down, Attempt 1?? + if (side.xOffset == 0 && side.zOffset == 0) { + Worked = i.onItemUse(new DirectionalPlaceContext(w, placePos.offset(side.getFacing()), + lookDirection, is, side.getFacing())) == ActionResultType.SUCCESS; + } - // FIXME No idea what any of this is _supposed_ to do, comment badly needed - if ( i instanceof IPlantable || i instanceof WallOrFloorItem ) - { - boolean Worked = false; + // Up or Down, Attempt 2?? + if (!Worked && side.xOffset == 0 && side.zOffset == 0) { + Worked = i.onItemUse(new DirectionalPlaceContext(w, + placePos.offset(side.getFacing().getOpposite()), lookDirection, is, + side.getFacing().getOpposite())) == ActionResultType.SUCCESS; + } - // Up or Down, Attempt 1?? - if( side.xOffset == 0 && side.zOffset == 0 ) - { - Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( side.getFacing() ), lookDirection, is, side.getFacing()) ) == ActionResultType.SUCCESS; - } + // Horizontal, attempt 1?? + if (!Worked && side.yOffset == 0) { + Worked = i.onItemUse(new DirectionalPlaceContext(w, placePos.offset(Direction.DOWN), + lookDirection, is, Direction.DOWN)) == ActionResultType.SUCCESS; + } - // Up or Down, Attempt 2?? - if( !Worked && side.xOffset == 0 && side.zOffset == 0 ) - { - Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( side.getFacing().getOpposite() ), lookDirection, is, side.getFacing().getOpposite()) ) - == ActionResultType.SUCCESS; - } + if (!Worked) { + i.onItemUse(new DirectionalPlaceContext(w, placePos, lookDirection, is, + lookDirection.getOpposite())); + } - // Horizontal, attempt 1?? - if( !Worked && side.yOffset == 0 ) - { - Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( Direction.DOWN ), lookDirection, is, Direction.DOWN) ) == ActionResultType.SUCCESS; - } + maxStorage -= is.getCount(); + } else { + i.onItemUse(new DirectionalPlaceContext(w, placePos, lookDirection, is, + lookDirection.getOpposite())); + maxStorage -= is.getCount(); + } + } else { + maxStorage = 1; + } - if( !Worked ) - { - i.onItemUse( new DirectionalPlaceContext(w, placePos, lookDirection, is, lookDirection.getOpposite()) ); - } + // Safe keeping + player.setHeldItem(hand, ItemStack.EMPTY); + } else { + worked = true; - maxStorage -= is.getCount(); - } - else - { - i.onItemUse( new DirectionalPlaceContext(w, placePos, lookDirection, is, lookDirection.getOpposite()) ); - maxStorage -= is.getCount(); - } - } - else - { - maxStorage = 1; - } + final int sum = this.countEntitesAround(w, placePos); - // Safe keeping - player.setHeldItem( hand, ItemStack.EMPTY ); - } - else - { - worked = true; + if (sum < AEConfig.instance().getFormationPlaneEntityLimit()) { + if (type == Actionable.MODULATE) { + is.setCount((int) maxStorage); + final double x = (side.xOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.xOffset + + .5 + te.getPos().getX(); + final double y = (side.yOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.yOffset + + .5 + te.getPos().getY(); + final double z = (side.zOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.zOffset + + .5 + te.getPos().getZ(); - final int sum = this.countEntitesAround( w, placePos ); + final ItemEntity ei = new ItemEntity(w, x, y, z, is.copy()); - if( sum < AEConfig.instance().getFormationPlaneEntityLimit() ) - { - if( type == Actionable.MODULATE ) - { - is.setCount( (int) maxStorage ); - final double x = ( side.xOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.xOffset + .5 + te.getPos().getX(); - final double y = ( side.yOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.yOffset + .5 + te.getPos().getY(); - final double z = ( side.zOffset != 0 ? 0 : .7 * ( Platform.getRandomFloat() - .5 ) ) + side.zOffset + .5 + te.getPos().getZ(); + Entity result = ei; - final ItemEntity ei = new ItemEntity( w, x, y, z, is.copy() ); + ei.setMotion(side.xOffset * 0.2, side.yOffset * 0.2, side.zOffset * 0.2); - Entity result = ei; + if (is.getItem().hasCustomEntity(is)) { + result = is.getItem().createEntity(w, ei, is); + if (result != null) { + ei.remove(); + } else { + result = ei; + } + } - ei.setMotion( side.xOffset * 0.2, side.yOffset * 0.2, side.zOffset * 0.2 ); + if (!w.addEntity(result)) { + result.remove(); + worked = false; + } + } + } else { + worked = false; + } + } + } - if( is.getItem().hasCustomEntity( is ) ) - { - result = is.getItem().createEntity( w, ei, is ); - if( result != null ) - { - ei.remove(); - } - else - { - result = ei; - } - } + this.blocked = !w.getBlockState(placePos).getMaterial().isReplaceable(); - if( !w.addEntity( result ) ) - { - result.remove(); - worked = false; - } - } - } - else - { - worked = false; - } - } - } + if (worked) { + final IAEItemStack out = input.copy(); + out.decStackSize(maxStorage); + if (out.getStackSize() == 0) { + return null; + } + return out; + } - this.blocked = !w.getBlockState( placePos ).getMaterial().isReplaceable(); + return input; + } - if( worked ) - { - final IAEItemStack out = input.copy(); - out.decStackSize( maxStorage ); - if( out.getStackSize() == 0 ) - { - return null; - } - return out; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - return input; - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Nonnull + @Override + public IModelData getModelData() { + return new PlaneModelData(getConnections()); + } - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().formationPlane().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Nonnull - @Override - public IModelData getModelData() { - return new PlaneModelData(getConnections()); - } + @Override + public ContainerType getContainerType() { + return ContainerFormationPlane.TYPE; + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().formationPlane().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } + private int countEntitesAround(World world, BlockPos pos) { + final AxisAlignedBB t = new AxisAlignedBB(pos).grow(8); + final List list = world.getEntitiesWithinAABB(Entity.class, t); - @Override - public ContainerType getContainerType() - { - return ContainerFormationPlane.TYPE; - } + return list.size(); + } - private int countEntitesAround( World world, BlockPos pos ) - { - final AxisAlignedBB t = new AxisAlignedBB( pos ).grow( 8 ); - final List list = world.getEntitiesWithinAABB( Entity.class, t ); - - return list.size(); - } - - private class ForcedItemUseContext extends ItemUseContext { - protected ForcedItemUseContext(World worldIn, @Nullable PlayerEntity player, Hand handIn, ItemStack heldItem, BlockRayTraceResult rayTraceResultIn) { - super(worldIn, player, handIn, heldItem, rayTraceResultIn); - } - } + private class ForcedItemUseContext extends ItemUseContext { + protected ForcedItemUseContext(World worldIn, @Nullable PlayerEntity player, Hand handIn, ItemStack heldItem, + BlockRayTraceResult rayTraceResultIn) { + super(worldIn, player, handIn, heldItem, rayTraceResultIn); + } + } } diff --git a/src/main/java/appeng/parts/automation/PartIdentityAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartIdentityAnnihilationPlane.java index 23df1bfb4..a565fbe3a 100644 --- a/src/main/java/appeng/parts/automation/PartIdentityAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartIdentityAnnihilationPlane.java @@ -18,13 +18,12 @@ package appeng.parts.automation; +import java.util.List; + +import javax.annotation.Nonnull; -import appeng.api.parts.IPart; -import appeng.api.parts.IPartHost; -import appeng.api.parts.IPartModel; -import appeng.api.util.AEPartLocation; -import appeng.items.parts.PartModels; import com.google.common.collect.ImmutableMap; + import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; @@ -34,71 +33,65 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nonnull; -import java.util.List; +import appeng.api.parts.IPart; +import appeng.api.parts.IPartHost; +import appeng.api.parts.IPartModel; +import appeng.api.util.AEPartLocation; +import appeng.items.parts.PartModels; +public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane { -public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane -{ + private static final PlaneModels MODELS = new PlaneModels("part/identity_annihilation_plane", + "part/identity_annihilation_plane_on"); - private static final PlaneModels MODELS = new PlaneModels( "part/identity_annihilation_plane", "part/identity_annihilation_plane_on" ); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + private static final float SILK_TOUCH_FACTOR = 16; - private static final float SILK_TOUCH_FACTOR = 16; + public PartIdentityAnnihilationPlane(final ItemStack is) { + super(is); + } - public PartIdentityAnnihilationPlane( final ItemStack is ) - { - super( is ); - } + @Override + protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) { + if (blockTileEntity instanceof IPartHost) { + final IPart p = ((IPartHost) blockTileEntity).getPart(side); + return p != null && p.getClass() == this.getClass(); + } + return false; + } - @Override - protected boolean isAnnihilationPlane( final TileEntity blockTileEntity, final AEPartLocation side ) - { - if( blockTileEntity instanceof IPartHost ) - { - final IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); - return p != null && p.getClass() == this.getClass(); - } - return false; - } + @Override + protected float calculateEnergyUsage(final ServerWorld w, final BlockPos pos, final List items) { + final float requiredEnergy = super.calculateEnergyUsage(w, pos, items); - @Override - protected float calculateEnergyUsage(final ServerWorld w, final BlockPos pos, final List items ) - { - final float requiredEnergy = super.calculateEnergyUsage( w, pos, items ); + return requiredEnergy * SILK_TOUCH_FACTOR; + } - return requiredEnergy * SILK_TOUCH_FACTOR; - } + @Override + protected ItemStack createHarvestTool(BlockState state) { + ItemStack harvestTool = super.createHarvestTool(state); - @Override - protected ItemStack createHarvestTool(BlockState state) { - ItemStack harvestTool = super.createHarvestTool(state); + // For silk touch purposes, enchant the fake tool + if (harvestTool != null) { + EnchantmentHelper.setEnchantments(ImmutableMap.of(Enchantments.SILK_TOUCH, 1), harvestTool); + } - // For silk touch purposes, enchant the fake tool - if (harvestTool != null) { - EnchantmentHelper.setEnchantments(ImmutableMap.of( - Enchantments.SILK_TOUCH, 1 - ), harvestTool); - } + return harvestTool; + } - return harvestTool; - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } - - @Nonnull - @Override - public IModelData getModelData() { - return new PlaneModelData(getConnections()); - } + @Nonnull + @Override + public IModelData getModelData() { + return new PlaneModelData(getConnections()); + } } diff --git a/src/main/java/appeng/parts/automation/PartImportBus.java b/src/main/java/appeng/parts/automation/PartImportBus.java index 6bd3fae09..d047d979b 100644 --- a/src/main/java/appeng/parts/automation/PartImportBus.java +++ b/src/main/java/appeng/parts/automation/PartImportBus.java @@ -18,14 +18,9 @@ package appeng.parts.automation; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerUpgradeable; -import appeng.fluids.container.ContainerFluidInterface; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; @@ -48,8 +43,12 @@ import appeng.api.storage.IMEMonitor; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.util.AECableType; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerUpgradeable; import appeng.core.AppEng; import appeng.core.settings.TickRates; +import appeng.fluids.container.ContainerFluidInterface; import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; @@ -60,270 +59,219 @@ import appeng.util.Platform; import appeng.util.inv.IInventoryDestination; import appeng.util.item.AEItemStack; +public class PartImportBus extends PartSharedItemBus implements IInventoryDestination { -public class PartImportBus extends PartSharedItemBus implements IInventoryDestination -{ + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/import_bus_base"); + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/import_bus_off")); + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/import_bus_on")); + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/import_bus_has_channel")); - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/import_bus_base" ); - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_off" ) ); - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_on" ) ); - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" ) ); + private final IActionSource source; + private int itemsToSend; // used in tickingRequest + private boolean worked; // used in tickingRequest - private final IActionSource source; - private int itemsToSend; // used in tickingRequest - private boolean worked; // used in tickingRequest + @Reflected + public PartImportBus(final ItemStack is) { + super(is); - @Reflected - public PartImportBus( final 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); + } - 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 canInsert(final ItemStack stack) { + if (stack.isEmpty() || stack.getItem() == Items.AIR) { + return false; + } - @Override - public boolean canInsert( final ItemStack stack ) - { - if( stack.isEmpty() || stack.getItem() == Items.AIR ) - { - return false; - } + try { + final IMEMonitor inv = this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - try - { - final IMEMonitor inv = this.getProxy() - .getStorage() - .getInventory( - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + final IAEItemStack out = inv.injectItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack), + Actionable.SIMULATE, this.source); + if (out == null) { + return true; + } + return out.getStackSize() != stack.getCount(); + } catch (GridAccessException ex) { + return false; + } + } - final IAEItemStack out = inv.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), - Actionable.SIMULATE, - this.source ); - if( out == null ) - { - return true; - } - return out.getStackSize() != stack.getCount(); - } - catch( GridAccessException ex ) - { - return false; - } - } + @Override + public void getBoxes(final 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 void getBoxes( final 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 float getCableConnectionLength(AECableType cable) { + return 5; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 5; - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerUpgradeable.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerUpgradeable.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.ImportBus.getMin(), TickRates.ImportBus.getMax(), this.isSleeping(), false); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.ImportBus.getMin(), TickRates.ImportBus.getMax(), this.isSleeping(), false ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.doBusWork(); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.doBusWork(); - } + @Override + protected TickRateModulation doBusWork() { + if (!this.getProxy().isActive() || !this.canDoBusWork()) { + return TickRateModulation.IDLE; + } - @Override - protected TickRateModulation doBusWork() - { - if( !this.getProxy().isActive() || !this.canDoBusWork() ) - { - return TickRateModulation.IDLE; - } + this.worked = false; - this.worked = false; + final InventoryAdaptor myAdaptor = this.getHandler(); + final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE); - final InventoryAdaptor myAdaptor = this.getHandler(); - final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); + if (myAdaptor != null) { + try { + this.itemsToSend = this.calculateItemsToSend(); - if( myAdaptor != null ) - { - try - { - this.itemsToSend = this.calculateItemsToSend(); + final IMEMonitor inv = this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + final IEnergyGrid energy = this.getProxy().getEnergy(); - final IMEMonitor inv = this.getProxy() - .getStorage() - .getInventory( - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - final IEnergyGrid energy = this.getProxy().getEnergy(); + boolean Configured = false; + for (int x = 0; x < this.availableSlots(); x++) { + final IAEItemStack ais = this.getConfig().getAEStackInSlot(x); + if (ais != null && this.itemsToSend > 0) { + Configured = true; + while (this.itemsToSend > 0) { + if (this.importStuff(myAdaptor, ais, inv, energy, fzMode)) { + break; + } + } + } + } - boolean Configured = false; - for( int x = 0; x < this.availableSlots(); x++ ) - { - final IAEItemStack ais = this.getConfig().getAEStackInSlot( x ); - if( ais != null && this.itemsToSend > 0 ) - { - Configured = true; - while( this.itemsToSend > 0 ) - { - if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) ) - { - break; - } - } - } - } + if (!Configured) { + while (this.itemsToSend > 0) { + if (this.importStuff(myAdaptor, null, inv, energy, fzMode)) { + break; + } + } + } + } catch (final GridAccessException e) { + // :3 + } + } else { + return TickRateModulation.SLEEP; + } - if( !Configured ) - { - while( this.itemsToSend > 0 ) - { - if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) ) - { - break; - } - } - } - } - catch( final GridAccessException e ) - { - // :3 - } - } - else - { - return TickRateModulation.SLEEP; - } + return this.worked ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } - return this.worked ? TickRateModulation.FASTER : TickRateModulation.SLOWER; - } + private boolean importStuff(final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, + final IMEMonitor inv, final IEnergySource energy, final FuzzyMode fzMode) { + final int toSend = this.calculateMaximumAmountToImport(myAdaptor, whatToImport, inv, fzMode); + final ItemStack newItems; - private boolean importStuff( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor inv, final IEnergySource energy, final FuzzyMode fzMode ) - { - final int toSend = this.calculateMaximumAmountToImport( myAdaptor, whatToImport, inv, fzMode ); - final ItemStack newItems; + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + newItems = myAdaptor.removeSimilarItems(toSend, + whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode, this); + } else { + newItems = myAdaptor.removeItems(toSend, + whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this); + } - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode, this ); - } - else - { - newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this ); - } + if (!newItems.isEmpty()) { + final IAEItemStack aeStack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(newItems); + final IAEItemStack failed = Platform.poweredInsert(energy, inv, aeStack, this.source); - if( !newItems.isEmpty() ) - { - final IAEItemStack aeStack = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItems ); - final IAEItemStack failed = Platform.poweredInsert( energy, inv, aeStack, this.source ); + if (failed != null) { + // try unpowered insert, better be a bit lenient then void items + final IAEItemStack spill = inv.injectItems(failed, Actionable.MODULATE, this.source); + if (spill != null) { + // last resort try to put it back .. lets hope it's a chest type of thing + myAdaptor.addItems(spill.createItemStack()); + } + return true; + } else { + this.itemsToSend -= newItems.getCount(); + this.worked = true; + } + } else { + return true; + } - if( failed != null ) - { - // try unpowered insert, better be a bit lenient then void items - final IAEItemStack spill = inv.injectItems( failed, Actionable.MODULATE, this.source ); - if( spill != null ) - { - // last resort try to put it back .. lets hope it's a chest type of thing - myAdaptor.addItems( spill.createItemStack() ); - } - return true; - } - else - { - this.itemsToSend -= newItems.getCount(); - this.worked = true; - } - } - else - { - return true; - } + return false; + } - return false; - } + private int calculateMaximumAmountToImport(final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, + final IMEMonitor inv, final FuzzyMode fzMode) { + final int toSend = Math.min(this.itemsToSend, 64); + final ItemStack itemStackToImport; - private int calculateMaximumAmountToImport( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor inv, final FuzzyMode fzMode ) - { - final int toSend = Math.min( this.itemsToSend, 64 ); - final ItemStack itemStackToImport; + if (whatToImport == null) { + itemStackToImport = ItemStack.EMPTY; + } else { + itemStackToImport = whatToImport.getDefinition(); + } - if( whatToImport == null ) - { - itemStackToImport = ItemStack.EMPTY; - } - else - { - itemStackToImport = whatToImport.getDefinition(); - } + final IAEItemStack itemAmountNotStorable; + final ItemStack simResult; + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + simResult = myAdaptor.simulateSimilarRemove(toSend, itemStackToImport, fzMode, this); + itemAmountNotStorable = inv.injectItems(AEItemStack.fromItemStack(simResult), Actionable.SIMULATE, + this.source); + } else { + simResult = myAdaptor.simulateRemove(toSend, itemStackToImport, this); + itemAmountNotStorable = inv.injectItems(AEItemStack.fromItemStack(simResult), Actionable.SIMULATE, + this.source); + } - final IAEItemStack itemAmountNotStorable; - final ItemStack simResult; - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this ); - itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); - } - else - { - simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this ); - itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); - } + if (itemAmountNotStorable != null) { + return (int) Math.min(simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend); + } - if( itemAmountNotStorable != null ) - { - return (int) Math.min( simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend ); - } + return toSend; + } - return toSend; - } + @Override + protected boolean isSleeping() { + return this.getHandler() == null || super.isSleeping(); + } - @Override - protected boolean isSleeping() - { - return this.getHandler() == null || super.isSleeping(); - } + @Override + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); + } - @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); - } - - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/parts/automation/PartLevelEmitter.java b/src/main/java/appeng/parts/automation/PartLevelEmitter.java index 6f69618d4..1687ac790 100644 --- a/src/main/java/appeng/parts/automation/PartLevelEmitter.java +++ b/src/main/java/appeng/parts/automation/PartLevelEmitter.java @@ -18,13 +18,9 @@ package appeng.parts.automation; - import java.util.Collection; import java.util.Random; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerLevelEmitter; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; @@ -74,8 +70,10 @@ import appeng.api.storage.data.IItemList; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.IConfigManager; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerLevelEmitter; import appeng.core.AppEng; - import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; @@ -84,493 +82,417 @@ import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.util.Platform; import appeng.util.inv.InvOperation; - -public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver, ICraftingProvider -{ - - @PartModels - public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_off" ); - @PartModels - public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_on" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_off" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_on" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_has_channel" ); - - public static final PartModel MODEL_OFF_OFF = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_OFF ); - public static final PartModel MODEL_OFF_ON = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_ON ); - public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL ); - public static final PartModel MODEL_ON_OFF = new PartModel( MODEL_BASE_ON, MODEL_STATUS_OFF ); - public static final PartModel MODEL_ON_ON = new PartModel( MODEL_BASE_ON, MODEL_STATUS_ON ); - public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL ); - - private static final int FLAG_ON = 4; - - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 1 ); - - private boolean prevState = false; - - private long lastReportedValue = 0; - private long reportingValue = 0; - - private IStackWatcher myWatcher; - private IEnergyWatcher myEnergyWatcher; - private ICraftingWatcher myCraftingWatcher; - private double centerX; - private double centerY; - private double centerZ; - - @Reflected - public PartLevelEmitter( final 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() - { - return this.reportingValue; - } - - public void setReportingValue( final long v ) - { - this.reportingValue = v; - if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL ) - { - this.configureWatchers(); - } - else - { - this.updateState(); - } - } - - @MENetworkEventSubscribe - public void powerChanged( final MENetworkPowerStatusChange c ) - { - this.updateState(); - } - - private void updateState() - { - final boolean isOn = this.isLevelEmitterOn(); - if( this.prevState != isOn ) - { - this.getHost().markForUpdate(); - final TileEntity te = this.getHost().getTile(); - this.prevState = isOn; - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() ); - Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos().offset( this.getSide().getFacing() ) ); - } - } - - // TODO: Make private again - public boolean isLevelEmitterOn() - { - if( Platform.isClient() ) - { - return ( this.getClientFlags() & FLAG_ON ) == FLAG_ON; - } - - if( !this.getProxy().isActive() ) - { - return false; - } - - if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) - { - try - { - return this.getProxy().getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) ); - } - catch( final GridAccessException e ) - { - // :P - } - - return this.prevState; - } - - final boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL; - return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1; - } - - @MENetworkEventSubscribe - public void channelChanged( final MENetworkChannelsChanged c ) - { - this.updateState(); - } - - @Override - protected int populateFlags( final int cf ) - { - return cf | ( this.prevState ? FLAG_ON : 0 ); - } - - @Override - public void updateWatcher( final ICraftingWatcher newWatcher ) - { - this.myCraftingWatcher = newWatcher; - this.configureWatchers(); - } - - @Override - public void onRequestChange( final ICraftingGrid craftingGrid, final IAEItemStack what ) - { - this.updateState(); - } - - // update the system... - private void configureWatchers() - { - final IAEItemStack myStack = this.config.getAEStackInSlot( 0 ); - - if( this.myWatcher != null ) - { - this.myWatcher.reset(); - } - - if( this.myEnergyWatcher != null ) - { - this.myEnergyWatcher.reset(); - } - - if( this.myCraftingWatcher != null ) - { - this.myCraftingWatcher.reset(); - } - - try - { - this.getProxy().getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.getProxy().getNode() ) ); - } - catch( final GridAccessException e1 ) - { - // :/ - } - - if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) - { - if( this.myCraftingWatcher != null && myStack != null ) - { - this.myCraftingWatcher.add( myStack ); - } - - return; - } - - if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL ) - { - if( this.myEnergyWatcher != null ) - { - this.myEnergyWatcher.add( this.reportingValue ); - } - - try - { - // update to power... - this.lastReportedValue = (long) this.getProxy().getEnergy().getStoredPower(); - this.updateState(); - - // no more item stuff.. - this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this ); - } - catch( final GridAccessException e ) - { - // :P - } - - return; - } - - try - { - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null ) - { - this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).addListener( this, this.getProxy().getGrid() ); - } - else - { - this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this ); - - if( this.myWatcher != null ) - { - this.myWatcher.add( myStack ); - } - } - - this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - } - catch( final GridAccessException e ) - { - // >.> - } - } - - private void updateReportingValue( final IMEMonitor monitor ) - { - final IAEItemStack myStack = this.config.getAEStackInSlot( 0 ); - - if( myStack == null ) - { - this.lastReportedValue = 0; - for( final IAEItemStack st : monitor.getStorageList() ) - { - this.lastReportedValue += st.getStackSize(); - } - } - else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - this.lastReportedValue = 0; - final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); - final Collection fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode ); - for( final IAEItemStack st : fuzzyList ) - { - this.lastReportedValue += st.getStackSize(); - } - } - else - { - final IAEItemStack r = monitor.getStorageList().findPrecise( myStack ); - if( r == null ) - { - this.lastReportedValue = 0; - } - else - { - this.lastReportedValue = r.getStackSize(); - } - } - - this.updateState(); - } - - @Override - public void updateWatcher( final IStackWatcher newWatcher ) - { - this.myWatcher = newWatcher; - this.configureWatchers(); - } - - @Override - public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan ) - { - if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 ) - { - this.lastReportedValue = fullStack.getStackSize(); - this.updateState(); - } - } - - @Override - public void updateWatcher( final IEnergyWatcher newWatcher ) - { - this.myEnergyWatcher = newWatcher; - this.configureWatchers(); - } - - @Override - public void onThresholdPass( final IEnergyGrid energyGrid ) - { - this.lastReportedValue = (long) energyGrid.getStoredPower(); - this.updateState(); - } - - @Override - public boolean isValid( final Object effectiveGrid ) - { - try - { - return this.getProxy().getGrid() == effectiveGrid; - } - catch( final GridAccessException e ) - { - return false; - } - } - - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource actionSource ) - { - this.updateReportingValue( (IMEMonitor) monitor ); - } - - @Override - public void onListUpdate() - { - try - { - this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - } - catch( final GridAccessException e ) - { - // ;P - } - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } - - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 7, 7, 11, 9, 9, 16 ); - } - - @Override - public int isProvidingStrongPower() - { - return this.prevState ? 15 : 0; - } - - @Override - public int isProvidingWeakPower() - { - return this.prevState ? 15 : 0; - } - - @Override - public void animateTick( final World world, final BlockPos pos, final Random r ) - { - if( this.isLevelEmitterOn() ) - { - final AEPartLocation d = this.getSide(); - - final double d0 = d.xOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - final double d1 = d.yOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - final double d2 = d.zOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - - world.addParticle( RedstoneParticleData.REDSTONE_DUST, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D ); - } - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 16; - } - - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerLevelEmitter.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.configureWatchers(); - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - if( inv == this.config ) - { - this.configureWatchers(); - } - - super.onChangeInventory( inv, slot, mc, removedStack, newStack ); - } - - @Override - public void upgradesChanged() - { - this.configureWatchers(); - } - - @Override - public boolean canConnectRedstone() - { - return true; - } - - @Override - public void readFromNBT( final CompoundNBT 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 void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putLong( "lastReportedValue", this.lastReportedValue ); - data.putLong( "reportingValue", this.reportingValue ); - data.putBoolean( "prevState", this.prevState ); - this.config.writeToNBT( data, "config" ); - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "config" ) ) - { - return this.config; - } - - return super.getInventoryByName( name ); - } - - @Override - public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table ) - { - return false; - } - - @Override - public boolean isBusy() - { - return true; - } - - @Override - public void provideCrafting( final ICraftingProviderHelper craftingTracker ) - { - if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) - { - if( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES ) - { - final IAEItemStack what = this.config.getAEStackInSlot( 0 ); - if( what != null ) - { - craftingTracker.setEmitable( what ); - } - } - } - } - - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return this.isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return this.isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON; - } - else - { - return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; - } - } +public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, + ICraftingWatcherHost, IMEMonitorHandlerReceiver, ICraftingProvider { + + @PartModels + public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_base_off"); + @PartModels + public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_base_on"); + @PartModels + public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_off"); + @PartModels + public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_on"); + @PartModels + public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/level_emitter_status_has_channel"); + + public static final PartModel MODEL_OFF_OFF = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_OFF); + public static final PartModel MODEL_OFF_ON = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_ON); + public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel(MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL); + public static final PartModel MODEL_ON_OFF = new PartModel(MODEL_BASE_ON, MODEL_STATUS_OFF); + public static final PartModel MODEL_ON_ON = new PartModel(MODEL_BASE_ON, MODEL_STATUS_ON); + public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel(MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL); + + private static final int FLAG_ON = 4; + + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 1); + + private boolean prevState = false; + + private long lastReportedValue = 0; + private long reportingValue = 0; + + private IStackWatcher myWatcher; + private IEnergyWatcher myEnergyWatcher; + private ICraftingWatcher myCraftingWatcher; + private double centerX; + private double centerY; + private double centerZ; + + @Reflected + public PartLevelEmitter(final 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() { + return this.reportingValue; + } + + public void setReportingValue(final long v) { + this.reportingValue = v; + if (this.getConfigManager().getSetting(Settings.LEVEL_TYPE) == LevelType.ENERGY_LEVEL) { + this.configureWatchers(); + } else { + this.updateState(); + } + } + + @MENetworkEventSubscribe + public void powerChanged(final MENetworkPowerStatusChange c) { + this.updateState(); + } + + private void updateState() { + final boolean isOn = this.isLevelEmitterOn(); + if (this.prevState != isOn) { + this.getHost().markForUpdate(); + final TileEntity te = this.getHost().getTile(); + this.prevState = isOn; + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos()); + Platform.notifyBlocksOfNeighbors(te.getWorld(), te.getPos().offset(this.getSide().getFacing())); + } + } + + // TODO: Make private again + public boolean isLevelEmitterOn() { + if (Platform.isClient()) { + return (this.getClientFlags() & FLAG_ON) == FLAG_ON; + } + + if (!this.getProxy().isActive()) { + return false; + } + + if (this.getInstalledUpgrades(Upgrades.CRAFTING) > 0) { + try { + return this.getProxy().getCrafting().isRequesting(this.config.getAEStackInSlot(0)); + } catch (final GridAccessException e) { + // :P + } + + return this.prevState; + } + + final boolean flipState = this.getConfigManager() + .getSetting(Settings.REDSTONE_EMITTER) == RedstoneMode.LOW_SIGNAL; + return flipState ? this.reportingValue >= this.lastReportedValue + 1 + : this.reportingValue < this.lastReportedValue + 1; + } + + @MENetworkEventSubscribe + public void channelChanged(final MENetworkChannelsChanged c) { + this.updateState(); + } + + @Override + protected int populateFlags(final int cf) { + return cf | (this.prevState ? FLAG_ON : 0); + } + + @Override + public void updateWatcher(final ICraftingWatcher newWatcher) { + this.myCraftingWatcher = newWatcher; + this.configureWatchers(); + } + + @Override + public void onRequestChange(final ICraftingGrid craftingGrid, final IAEItemStack what) { + this.updateState(); + } + + // update the system... + private void configureWatchers() { + final IAEItemStack myStack = this.config.getAEStackInSlot(0); + + if (this.myWatcher != null) { + this.myWatcher.reset(); + } + + if (this.myEnergyWatcher != null) { + this.myEnergyWatcher.reset(); + } + + if (this.myCraftingWatcher != null) { + this.myCraftingWatcher.reset(); + } + + try { + this.getProxy().getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.getProxy().getNode())); + } catch (final GridAccessException e1) { + // :/ + } + + if (this.getInstalledUpgrades(Upgrades.CRAFTING) > 0) { + if (this.myCraftingWatcher != null && myStack != null) { + this.myCraftingWatcher.add(myStack); + } + + return; + } + + if (this.getConfigManager().getSetting(Settings.LEVEL_TYPE) == LevelType.ENERGY_LEVEL) { + if (this.myEnergyWatcher != null) { + this.myEnergyWatcher.add(this.reportingValue); + } + + try { + // update to power... + this.lastReportedValue = (long) this.getProxy().getEnergy().getStoredPower(); + this.updateState(); + + // no more item stuff.. + this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) + .removeListener(this); + } catch (final GridAccessException e) { + // :P + } + + return; + } + + try { + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0 || myStack == null) { + this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) + .addListener(this, this.getProxy().getGrid()); + } else { + this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) + .removeListener(this); + + if (this.myWatcher != null) { + this.myWatcher.add(myStack); + } + } + + this.updateReportingValue(this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + } catch (final GridAccessException e) { + // >.> + } + } + + private void updateReportingValue(final IMEMonitor monitor) { + final IAEItemStack myStack = this.config.getAEStackInSlot(0); + + if (myStack == null) { + this.lastReportedValue = 0; + for (final IAEItemStack st : monitor.getStorageList()) { + this.lastReportedValue += st.getStackSize(); + } + } else if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + this.lastReportedValue = 0; + final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE); + final Collection fuzzyList = monitor.getStorageList().findFuzzy(myStack, fzMode); + for (final IAEItemStack st : fuzzyList) { + this.lastReportedValue += st.getStackSize(); + } + } else { + final IAEItemStack r = monitor.getStorageList().findPrecise(myStack); + if (r == null) { + this.lastReportedValue = 0; + } else { + this.lastReportedValue = r.getStackSize(); + } + } + + this.updateState(); + } + + @Override + public void updateWatcher(final IStackWatcher newWatcher) { + this.myWatcher = newWatcher; + this.configureWatchers(); + } + + @Override + public void onStackChange(final IItemList o, final IAEStack fullStack, final IAEStack diffStack, + final IActionSource src, final IStorageChannel chan) { + if (chan == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + && fullStack.equals(this.config.getAEStackInSlot(0)) + && this.getInstalledUpgrades(Upgrades.FUZZY) == 0) { + this.lastReportedValue = fullStack.getStackSize(); + this.updateState(); + } + } + + @Override + public void updateWatcher(final IEnergyWatcher newWatcher) { + this.myEnergyWatcher = newWatcher; + this.configureWatchers(); + } + + @Override + public void onThresholdPass(final IEnergyGrid energyGrid) { + this.lastReportedValue = (long) energyGrid.getStoredPower(); + this.updateState(); + } + + @Override + public boolean isValid(final Object effectiveGrid) { + try { + return this.getProxy().getGrid() == effectiveGrid; + } catch (final GridAccessException e) { + return false; + } + } + + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource actionSource) { + this.updateReportingValue((IMEMonitor) monitor); + } + + @Override + public void onListUpdate() { + try { + this.updateReportingValue(this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + } catch (final GridAccessException e) { + // ;P + } + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } + + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(7, 7, 11, 9, 9, 16); + } + + @Override + public int isProvidingStrongPower() { + return this.prevState ? 15 : 0; + } + + @Override + public int isProvidingWeakPower() { + return this.prevState ? 15 : 0; + } + + @Override + public void animateTick(final World world, final BlockPos pos, final Random r) { + if (this.isLevelEmitterOn()) { + final AEPartLocation d = this.getSide(); + + final double d0 = d.xOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; + final double d1 = d.yOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; + final double d2 = d.zOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D; + + world.addParticle(RedstoneParticleData.REDSTONE_DUST, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, + 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 16; + } + + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerLevelEmitter.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.configureWatchers(); + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + if (inv == this.config) { + this.configureWatchers(); + } + + super.onChangeInventory(inv, slot, mc, removedStack, newStack); + } + + @Override + public void upgradesChanged() { + this.configureWatchers(); + } + + @Override + public boolean canConnectRedstone() { + return true; + } + + @Override + public void readFromNBT(final CompoundNBT 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 void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putLong("lastReportedValue", this.lastReportedValue); + data.putLong("reportingValue", this.reportingValue); + data.putBoolean("prevState", this.prevState); + this.config.writeToNBT(data, "config"); + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("config")) { + return this.config; + } + + return super.getInventoryByName(name); + } + + @Override + public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table) { + return false; + } + + @Override + public boolean isBusy() { + return true; + } + + @Override + public void provideCrafting(final ICraftingProviderHelper craftingTracker) { + if (this.getInstalledUpgrades(Upgrades.CRAFTING) > 0) { + if (this.getConfigManager().getSetting(Settings.CRAFT_VIA_REDSTONE) == YesNo.YES) { + final IAEItemStack what = this.config.getAEStackInSlot(0); + if (what != null) { + craftingTracker.setEmitable(what); + } + } + } + } + + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return this.isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL; + } else if (this.isPowered()) { + return this.isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON; + } else { + return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; + } + } } diff --git a/src/main/java/appeng/parts/automation/PartSharedItemBus.java b/src/main/java/appeng/parts/automation/PartSharedItemBus.java index 25ce1a230..7378cc025 100644 --- a/src/main/java/appeng/parts/automation/PartSharedItemBus.java +++ b/src/main/java/appeng/parts/automation/PartSharedItemBus.java @@ -18,7 +18,6 @@ package appeng.parts.automation; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -35,145 +34,119 @@ import appeng.me.GridAccessException; import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.util.InventoryAdaptor; +public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable { -public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable -{ + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9); + private boolean lastRedstone = false; - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 ); - private boolean lastRedstone = false; + public PartSharedItemBus(final ItemStack is) { + super(is); + } - public PartSharedItemBus( final ItemStack is ) - { - super( is ); - } + @Override + public void upgradesChanged() { + this.updateState(); + } - @Override - public void upgradesChanged() - { - this.updateState(); - } + @Override + public void readFromNBT(final net.minecraft.nbt.CompoundNBT extra) { + super.readFromNBT(extra); + this.getConfig().readFromNBT(extra, "config"); + } - @Override - public void readFromNBT( final net.minecraft.nbt.CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.getConfig().readFromNBT( extra, "config" ); - } + @Override + public void writeToNBT(final net.minecraft.nbt.CompoundNBT extra) { + super.writeToNBT(extra); + this.getConfig().writeToNBT(extra, "config"); + } - @Override - public void writeToNBT( final net.minecraft.nbt.CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.getConfig().writeToNBT( extra, "config" ); - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("config")) { + return this.getConfig(); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "config" ) ) - { - return this.getConfig(); - } + return super.getInventoryByName(name); + } - return super.getInventoryByName( name ); - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + this.updateState(); + if (this.lastRedstone != this.getHost().hasRedstone(this.getSide())) { + this.lastRedstone = !this.lastRedstone; + if (this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE) { + this.doBusWork(); + } + } + } - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - this.updateState(); - if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) ) - { - this.lastRedstone = !this.lastRedstone; - if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE ) - { - this.doBusWork(); - } - } - } + protected InventoryAdaptor getHandler() { + final TileEntity self = this.getHost().getTile(); + final TileEntity target = this.getTileEntity(self, self.getPos().offset(this.getSide().getFacing())); - protected InventoryAdaptor getHandler() - { - final TileEntity self = this.getHost().getTile(); - final TileEntity target = this.getTileEntity( self, self.getPos().offset( this.getSide().getFacing() ) ); + return InventoryAdaptor.getAdaptor(target, this.getSide().getFacing().getOpposite()); + } - return InventoryAdaptor.getAdaptor( target, this.getSide().getFacing().getOpposite() ); - } + private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) { + final World w = self.getWorld(); - private TileEntity getTileEntity( final TileEntity self, final BlockPos pos ) - { - final World w = self.getWorld(); + if (w.getChunkProvider().isChunkLoaded(new ChunkPos(pos))) { + return w.getTileEntity(pos); + } - if( w.getChunkProvider().isChunkLoaded( new ChunkPos( pos ) ) ) - { - return w.getTileEntity( pos ); - } + return null; + } - return null; - } + protected int availableSlots() { + return Math.min(1 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 4, this.getConfig().getSlots()); + } - protected int availableSlots() - { - return Math.min( 1 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 4, this.getConfig().getSlots() ); - } + protected int calculateItemsToSend() { + switch (this.getInstalledUpgrades(Upgrades.SPEED)) { + default: + case 0: + return 1; + case 1: + return 8; + case 2: + return 32; + case 3: + return 64; + case 4: + return 96; + } + } - protected int calculateItemsToSend() - { - switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) - { - default: - case 0: - return 1; - case 1: - return 8; - case 2: - return 32; - case 3: - return 64; - case 4: - return 96; - } - } + /** + * Checks if the bus can actually do something. + * + * Currently this tests if the chunk for the target is actually loaded. + * + * @return true, if the the bus should do its work. + */ + protected boolean canDoBusWork() { + final TileEntity self = this.getHost().getTile(); + final BlockPos selfPos = self.getPos().offset(this.getSide().getFacing()); + final World world = self.getWorld(); - /** - * Checks if the bus can actually do something. - * - * Currently this tests if the chunk for the target is actually loaded. - * - * @return true, if the the bus should do its work. - */ - protected boolean canDoBusWork() - { - final TileEntity self = this.getHost().getTile(); - final BlockPos selfPos = self.getPos().offset( this.getSide().getFacing() ); - final World world = self.getWorld(); + return world != null && world.getChunkProvider().isChunkLoaded(new ChunkPos(selfPos)); + } - return world != null && world.getChunkProvider().isChunkLoaded( new ChunkPos( selfPos ) ); - } + private void updateState() { + try { + if (!this.isSleeping()) { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } else { + this.getProxy().getTick().sleepDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } - private void updateState() - { - try - { - if( !this.isSleeping() ) - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - else - { - this.getProxy().getTick().sleepDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } + protected abstract TickRateModulation doBusWork(); - protected abstract TickRateModulation doBusWork(); - - AppEngInternalAEInventory getConfig() - { - return this.config; - } + AppEngInternalAEInventory getConfig() { + return this.config; + } } diff --git a/src/main/java/appeng/parts/automation/PartUpgradeable.java b/src/main/java/appeng/parts/automation/PartUpgradeable.java index ce6dc762b..95af40f5d 100644 --- a/src/main/java/appeng/parts/automation/PartUpgradeable.java +++ b/src/main/java/appeng/parts/automation/PartUpgradeable.java @@ -18,14 +18,13 @@ package appeng.parts.automation; - import java.util.List; -import appeng.api.config.Settings; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.api.config.RedstoneMode; +import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.util.IConfigManager; import appeng.parts.PartBasicState; @@ -34,139 +33,116 @@ import appeng.util.IConfigManagerHost; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +public abstract class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost { + private final IConfigManager manager; + private final UpgradeInventory upgrades; -public abstract class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost -{ - private final IConfigManager manager; - private final UpgradeInventory upgrades; + public PartUpgradeable(final ItemStack is) { + super(is); + this.upgrades = new StackUpgradeInventory(this.getItemStack(), this, this.getUpgradeSlots()); + this.manager = new ConfigManager(this); + } - public PartUpgradeable( final ItemStack is ) - { - super( is ); - this.upgrades = new StackUpgradeInventory( this.getItemStack(), this, this.getUpgradeSlots() ); - this.manager = new ConfigManager( this ); - } + protected int getUpgradeSlots() { + return 4; + } - protected int getUpgradeSlots() - { - return 4; - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { + } - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + if (inv == this.upgrades) { + this.upgradesChanged(); + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - if( inv == this.upgrades ) - { - this.upgradesChanged(); - } - } + public void upgradesChanged() { - public void upgradesChanged() - { + } - } + protected boolean isSleeping() { + if (this.getInstalledUpgrades(Upgrades.REDSTONE) > 0) { + switch (this.getRSMode()) { + case IGNORE: + return false; - protected boolean isSleeping() - { - if( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 ) - { - switch( this.getRSMode() ) - { - case IGNORE: - return false; + case HIGH_SIGNAL: + if (this.getHost().hasRedstone(this.getSide())) { + return false; + } - case HIGH_SIGNAL: - if( this.getHost().hasRedstone( this.getSide() ) ) - { - return false; - } + break; - break; + case LOW_SIGNAL: + if (!this.getHost().hasRedstone(this.getSide())) { + return false; + } - case LOW_SIGNAL: - if( !this.getHost().hasRedstone( this.getSide() ) ) - { - return false; - } + break; - break; + case SIGNAL_PULSE: + default: + break; + } - case SIGNAL_PULSE: - default: - break; - } + return true; + } - return true; - } + return false; + } - return false; - } + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.upgrades.getInstalledUpgrades(u); + } - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.upgrades.getInstalledUpgrades( u ); - } + @Override + public boolean canConnectRedstone() { + return this.upgrades.getMaxInstalled(Upgrades.REDSTONE) > 0; + } - @Override - public boolean canConnectRedstone() - { - return this.upgrades.getMaxInstalled( Upgrades.REDSTONE ) > 0; - } + @Override + public void readFromNBT(final net.minecraft.nbt.CompoundNBT extra) { + super.readFromNBT(extra); + this.manager.readFromNBT(extra); + this.upgrades.readFromNBT(extra, "upgrades"); + } - @Override - public void readFromNBT( final net.minecraft.nbt.CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.manager.readFromNBT( extra ); - this.upgrades.readFromNBT( extra, "upgrades" ); - } + @Override + public void writeToNBT(final net.minecraft.nbt.CompoundNBT extra) { + super.writeToNBT(extra); + this.manager.writeToNBT(extra); + this.upgrades.writeToNBT(extra, "upgrades"); + } - @Override - public void writeToNBT( final net.minecraft.nbt.CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.manager.writeToNBT( extra ); - this.upgrades.writeToNBT( extra, "upgrades" ); - } + @Override + public void getDrops(final List drops, final boolean wrenched) { + for (final ItemStack is : this.upgrades) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } - @Override - public void getDrops( final List drops, final boolean wrenched ) - { - for( final ItemStack is : this.upgrades ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + @Override + public IConfigManager getConfigManager() { + return this.manager; + } - @Override - public IConfigManager getConfigManager() - { - return this.manager; - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("upgrades")) { + return this.upgrades; + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "upgrades" ) ) - { - return this.upgrades; - } + return null; + } - return null; - } - - public RedstoneMode getRSMode() - { - return null; - } + public RedstoneMode getRSMode() { + return null; + } } diff --git a/src/main/java/appeng/parts/automation/PlaneBakedModel.java b/src/main/java/appeng/parts/automation/PlaneBakedModel.java index cb7e978d7..bed6cbf20 100644 --- a/src/main/java/appeng/parts/automation/PlaneBakedModel.java +++ b/src/main/java/appeng/parts/automation/PlaneBakedModel.java @@ -18,8 +18,8 @@ package appeng.parts.automation; - import java.util.*; + import javax.annotation.Nullable; import com.google.common.collect.ImmutableList; @@ -29,100 +29,89 @@ import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; - -import appeng.client.render.cablebus.CubeBuilder; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; +import appeng.client.render.cablebus.CubeBuilder; /** * Built-in model for annihilation planes that supports connected textures. */ -public class PlaneBakedModel implements IDynamicBakedModel -{ +public class PlaneBakedModel implements IDynamicBakedModel { - private static final PlaneConnections DEFAULT_PERMUTATION = PlaneConnections.of(false, false, false, false); + private static final PlaneConnections DEFAULT_PERMUTATION = PlaneConnections.of(false, false, false, false); - private final TextureAtlasSprite frontTexture; + private final TextureAtlasSprite frontTexture; - private final Map> quads; + private final Map> quads; - PlaneBakedModel( TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture ) - { - this.frontTexture = frontTexture; + PlaneBakedModel(TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture) { + this.frontTexture = frontTexture; - quads = new HashMap<>(PlaneConnections.PERMUTATIONS.size()); - // Create all possible permutations (16) - for (PlaneConnections permutation : PlaneConnections.PERMUTATIONS) { - List quads = new ArrayList<>(4 * 6); + quads = new HashMap<>(PlaneConnections.PERMUTATIONS.size()); + // Create all possible permutations (16) + for (PlaneConnections permutation : PlaneConnections.PERMUTATIONS) { + List quads = new ArrayList<>(4 * 6); - CubeBuilder builder = new CubeBuilder(quads); + CubeBuilder builder = new CubeBuilder(quads); - builder.setTextures(sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture); + builder.setTextures(sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture); - // Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front, - // The X-axis points left - int minX = permutation.isRight() ? 0 : 1; - int maxX = permutation.isLeft() ? 16 : 15; - int minY = permutation.isDown() ? 0 : 1; - int maxY = permutation.isUp() ? 16 : 15; + // Keep the orientation of the X axis in mind here. When looking at a quad + // facing north from the front, + // The X-axis points left + int minX = permutation.isRight() ? 0 : 1; + int maxX = permutation.isLeft() ? 16 : 15; + int minY = permutation.isDown() ? 0 : 1; + int maxY = permutation.isUp() ? 16 : 15; - builder.addCube(minX, minY, 0, maxX, maxY, 1); + builder.addCube(minX, minY, 0, maxX, maxY, 1); - this.quads.put(permutation, ImmutableList.copyOf(quads)); - } - } + this.quads.put(permutation, ImmutableList.copyOf(quads)); + } + } - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData) - { - if( side == null ) - { - PlaneConnections connections = DEFAULT_PERMUTATION; - if (modelData instanceof PlaneModelData) { - connections = ((PlaneModelData) modelData).getConnections(); - } - return this.quads.get(connections); - } - else - { - return Collections.emptyList(); - } - } + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, + IModelData modelData) { + if (side == null) { + PlaneConnections connections = DEFAULT_PERMUTATION; + if (modelData instanceof PlaneModelData) { + connections = ((PlaneModelData) modelData).getConnections(); + } + return this.quads.get(connections); + } else { + return Collections.emptyList(); + } + } - @Override - public boolean isAmbientOcclusion() - { - return false; - } + @Override + public boolean isAmbientOcclusion() { + return false; + } - @Override - public boolean isGui3d() - { - return false; - } + @Override + public boolean isGui3d() { + return false; + } - @Override - public boolean func_230044_c_() - { - return false;//TODO - } + @Override + public boolean func_230044_c_() { + return false;// TODO + } - @Override - public boolean isBuiltInRenderer() - { - return false; - } + @Override + public boolean isBuiltInRenderer() { + return false; + } - @Override - public TextureAtlasSprite getParticleTexture() - { - return this.frontTexture; - } + @Override + public TextureAtlasSprite getParticleTexture() { + return this.frontTexture; + } - @Override - public ItemOverrideList getOverrides() - { - return ItemOverrideList.EMPTY; - } + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.EMPTY; + } } diff --git a/src/main/java/appeng/parts/automation/PlaneConnections.java b/src/main/java/appeng/parts/automation/PlaneConnections.java index a5b294815..1e05c27cf 100644 --- a/src/main/java/appeng/parts/automation/PlaneConnections.java +++ b/src/main/java/appeng/parts/automation/PlaneConnections.java @@ -18,123 +18,107 @@ package appeng.parts.automation; - import java.util.ArrayList; import java.util.List; import com.google.common.base.Strings; - /** - * Models in which directions - looking at the front face - a plane (annihilation, formation, etc.) is connected to - * other planes of the same type. + * Models in which directions - looking at the front face - a plane + * (annihilation, formation, etc.) is connected to other planes of the same + * type. */ -public final class PlaneConnections -{ +public final class PlaneConnections { - private final boolean up; - private final boolean right; - private final boolean down; - private final boolean left; + private final boolean up; + private final boolean right; + private final boolean down; + private final boolean left; - private static final int BITMASK_UP = 8; - private static final int BITMASK_RIGHT = 4; - private static final int BITMASK_DOWN = 2; - private static final int BITMASK_LEFT = 1; + private static final int BITMASK_UP = 8; + private static final int BITMASK_RIGHT = 4; + private static final int BITMASK_DOWN = 2; + private static final int BITMASK_LEFT = 1; - public static final List PERMUTATIONS = generatePermutations(); + public static final List PERMUTATIONS = generatePermutations(); - private static List generatePermutations() - { - List connections = new ArrayList<>( 16 ); + private static List generatePermutations() { + List connections = new ArrayList<>(16); - for( int i = 0; i < 16; i++ ) - { - boolean up = ( i & BITMASK_UP ) != 0; - boolean right = ( i & BITMASK_RIGHT ) != 0; - boolean down = ( i & BITMASK_DOWN ) != 0; - boolean left = ( i & BITMASK_LEFT ) != 0; + for (int i = 0; i < 16; i++) { + boolean up = (i & BITMASK_UP) != 0; + boolean right = (i & BITMASK_RIGHT) != 0; + boolean down = (i & BITMASK_DOWN) != 0; + boolean left = (i & BITMASK_LEFT) != 0; - connections.add( new PlaneConnections( up, right, down, left ) ); - } + connections.add(new PlaneConnections(up, right, down, left)); + } - return connections; - } + return connections; + } - private PlaneConnections( boolean up, boolean right, boolean down, boolean left ) - { - this.up = up; - this.right = right; - this.down = down; - this.left = left; - } + private PlaneConnections(boolean up, boolean right, boolean down, boolean left) { + this.up = up; + this.right = right; + this.down = down; + this.left = left; + } - public static PlaneConnections of( boolean up, boolean right, boolean down, boolean left ) - { - return PERMUTATIONS.get( getIndex( up, right, down, left ) ); - } + public static PlaneConnections of(boolean up, boolean right, boolean down, boolean left) { + return PERMUTATIONS.get(getIndex(up, right, down, left)); + } - public boolean isUp() - { - return this.up; - } + public boolean isUp() { + return this.up; + } - public boolean isRight() - { - return this.right; - } + public boolean isRight() { + return this.right; + } - public boolean isDown() - { - return this.down; - } + public boolean isDown() { + return this.down; + } - public boolean isLeft() - { - return this.left; - } + public boolean isLeft() { + return this.left; + } - // The combination of connections expressed as a number ranging from [0,15] - public int getIndex() - { - return getIndex( this.up, this.right, this.down, this.left ); - } + // The combination of connections expressed as a number ranging from [0,15] + public int getIndex() { + return getIndex(this.up, this.right, this.down, this.left); + } - private static int getIndex( boolean up, boolean right, boolean down, boolean left ) - { - return ( up ? BITMASK_UP : 0 ) + ( right ? BITMASK_RIGHT : 0 ) + ( left ? BITMASK_LEFT : 0 ) + ( down ? BITMASK_DOWN : 0 ); - } + private static int getIndex(boolean up, boolean right, boolean down, boolean left) { + return (up ? BITMASK_UP : 0) + (right ? BITMASK_RIGHT : 0) + (left ? BITMASK_LEFT : 0) + + (down ? BITMASK_DOWN : 0); + } - // Returns a suffix that expresses the connection states as a string - public String getFilenameSuffix() - { - String suffix = Integer.toBinaryString( this.getIndex() ); - return Strings.padStart( suffix, 4, '0' ); - } + // Returns a suffix that expresses the connection states as a string + public String getFilenameSuffix() { + String suffix = Integer.toBinaryString(this.getIndex()); + return Strings.padStart(suffix, 4, '0'); + } - @Override - public boolean equals( Object o ) - { - if( this == o ) - { - return true; - } - if( o == null || this.getClass() != o.getClass() ) - { - return false; - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || this.getClass() != o.getClass()) { + return false; + } - PlaneConnections that = (PlaneConnections) o; - return this.up == that.up && this.right == that.right && this.down == that.down && this.left == that.left; - } + PlaneConnections that = (PlaneConnections) o; + return this.up == that.up && this.right == that.right && this.down == that.down && this.left == that.left; + } - @Override - public int hashCode() - { - int result = ( this.up ? 1 : 0 ); - result = 31 * result + ( this.right ? 1 : 0 ); - result = 31 * result + ( this.down ? 1 : 0 ); - result = 31 * result + ( this.left ? 1 : 0 ); - return result; - } + @Override + public int hashCode() { + int result = (this.up ? 1 : 0); + result = 31 * result + (this.right ? 1 : 0); + result = 31 * result + (this.down ? 1 : 0); + result = 31 * result + (this.left ? 1 : 0); + return result; + } } diff --git a/src/main/java/appeng/parts/automation/PlaneModel.java b/src/main/java/appeng/parts/automation/PlaneModel.java index d27429a5d..d8019ada6 100644 --- a/src/main/java/appeng/parts/automation/PlaneModel.java +++ b/src/main/java/appeng/parts/automation/PlaneModel.java @@ -18,12 +18,12 @@ package appeng.parts.automation; - import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.function.Function; + import javax.annotation.Nullable; import com.mojang.datafixers.util.Pair; @@ -35,36 +35,36 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IModelGeometry; - /** * Built-in model for annihilation planes that supports connected textures. */ -public class PlaneModel implements IModelGeometry -{ +public class PlaneModel implements IModelGeometry { - private final Material frontTexture; - private final Material sidesTexture; - private final Material backTexture; + private final Material frontTexture; + private final Material sidesTexture; + private final Material backTexture; - public PlaneModel( ResourceLocation frontTexture, ResourceLocation sidesTexture, ResourceLocation backTexture ) - { - this.frontTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, frontTexture ); - this.sidesTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, sidesTexture ); - this.backTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, backTexture ); - } + public PlaneModel(ResourceLocation frontTexture, ResourceLocation sidesTexture, ResourceLocation backTexture) { + this.frontTexture = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, frontTexture); + this.sidesTexture = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, sidesTexture); + this.backTexture = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, backTexture); + } - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { - TextureAtlasSprite frontSprite = spriteGetter.apply( this.frontTexture ); - TextureAtlasSprite sidesSprite = spriteGetter.apply( this.sidesTexture ); - TextureAtlasSprite backSprite = spriteGetter.apply( this.backTexture ); + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, + Function spriteGetter, IModelTransform modelTransform, + ItemOverrideList overrides, ResourceLocation modelLocation) { + TextureAtlasSprite frontSprite = spriteGetter.apply(this.frontTexture); + TextureAtlasSprite sidesSprite = spriteGetter.apply(this.sidesTexture); + TextureAtlasSprite backSprite = spriteGetter.apply(this.backTexture); - return new PlaneBakedModel( frontSprite, sidesSprite, backSprite ); - } + return new PlaneBakedModel(frontSprite, sidesSprite, backSprite); + } - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - return Arrays.asList( frontTexture, sidesTexture, backTexture ); - } + @Override + public Collection getTextures(IModelConfiguration owner, + Function modelGetter, Set> missingTextureErrors) { + return Arrays.asList(frontTexture, sidesTexture, backTexture); + } } diff --git a/src/main/java/appeng/parts/automation/PlaneModelLoader.java b/src/main/java/appeng/parts/automation/PlaneModelLoader.java index 1abea0feb..41ff98302 100644 --- a/src/main/java/appeng/parts/automation/PlaneModelLoader.java +++ b/src/main/java/appeng/parts/automation/PlaneModelLoader.java @@ -2,6 +2,7 @@ package appeng.parts.automation; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModelLoader; @@ -20,11 +21,8 @@ public class PlaneModelLoader implements IModelLoader { String sidesTexture = modelContents.get("sides").getAsString(); String backTexture = modelContents.get("back").getAsString(); - return new PlaneModel( - new ResourceLocation(frontTexture), - new ResourceLocation(sidesTexture), - new ResourceLocation(backTexture) - ); + return new PlaneModel(new ResourceLocation(frontTexture), new ResourceLocation(sidesTexture), + new ResourceLocation(backTexture)); } } diff --git a/src/main/java/appeng/parts/automation/PlaneModels.java b/src/main/java/appeng/parts/automation/PlaneModels.java index 93c9b9772..4223ca3a0 100644 --- a/src/main/java/appeng/parts/automation/PlaneModels.java +++ b/src/main/java/appeng/parts/automation/PlaneModels.java @@ -18,7 +18,6 @@ package appeng.parts.automation; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,54 +32,46 @@ import appeng.api.parts.IPartModel; import appeng.core.AppEng; import appeng.parts.PartModel; - /** - * Contains a mapping from a Plane's connections to the models to use for that state. + * Contains a mapping from a Plane's connections to the models to use for that + * state. */ -public class PlaneModels -{ +public class PlaneModels { - public static final ResourceLocation MODEL_CHASSIS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_off" ); - public static final ResourceLocation MODEL_CHASSIS_ON = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_on" ); - public static final ResourceLocation MODEL_CHASSIS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_has_channel" ); + public static final ResourceLocation MODEL_CHASSIS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/transition_plane_off"); + public static final ResourceLocation MODEL_CHASSIS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/transition_plane_on"); + public static final ResourceLocation MODEL_CHASSIS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/transition_plane_has_channel"); - private final IPartModel modelOff; + private final IPartModel modelOff; - private final IPartModel modelOn; + private final IPartModel modelOn; - private final IPartModel modelHasChannel; + private final IPartModel modelHasChannel; - public PlaneModels( String planeOffLocation, String planeOnLocation ) - { - ResourceLocation planeOff = new ResourceLocation( AppEng.MOD_ID, planeOffLocation ); - ResourceLocation planeOn = new ResourceLocation( AppEng.MOD_ID, planeOnLocation ); + public PlaneModels(String planeOffLocation, String planeOnLocation) { + ResourceLocation planeOff = new ResourceLocation(AppEng.MOD_ID, planeOffLocation); + ResourceLocation planeOn = new ResourceLocation(AppEng.MOD_ID, planeOnLocation); - this.modelOff = new PartModel( MODEL_CHASSIS_OFF, planeOff ); - this.modelOn = new PartModel( MODEL_CHASSIS_ON, planeOff ); - this.modelHasChannel = new PartModel( MODEL_CHASSIS_HAS_CHANNEL, planeOn ); - } + this.modelOff = new PartModel(MODEL_CHASSIS_OFF, planeOff); + this.modelOn = new PartModel(MODEL_CHASSIS_ON, planeOff); + this.modelHasChannel = new PartModel(MODEL_CHASSIS_HAS_CHANNEL, planeOn); + } - public IPartModel getModel(boolean hasPower, boolean hasChannel) - { - if( hasPower && hasChannel ) - { - return modelHasChannel; - } - else if( hasPower ) - { - return modelOn; - } - else - { - return modelOff; - } - } + public IPartModel getModel(boolean hasPower, boolean hasChannel) { + if (hasPower && hasChannel) { + return modelHasChannel; + } else if (hasPower) { + return modelOn; + } else { + return modelOff; + } + } - public List getModels() - { - return ImmutableList.of( - modelOff, modelOn, modelHasChannel - ); - } + public List getModels() { + return ImmutableList.of(modelOff, modelOn, modelHasChannel); + } } diff --git a/src/main/java/appeng/parts/automation/StackUpgradeInventory.java b/src/main/java/appeng/parts/automation/StackUpgradeInventory.java index c99afda08..4dfea0de3 100644 --- a/src/main/java/appeng/parts/automation/StackUpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/StackUpgradeInventory.java @@ -18,37 +18,30 @@ package appeng.parts.automation; - import net.minecraft.item.ItemStack; import appeng.api.config.Upgrades; import appeng.util.inv.IAEAppEngInventory; +public class StackUpgradeInventory extends UpgradeInventory { + private final ItemStack stack; -public class StackUpgradeInventory extends UpgradeInventory -{ - private final ItemStack stack; + public StackUpgradeInventory(final ItemStack stack, final IAEAppEngInventory inventory, final int s) { + super(inventory, s); + this.stack = stack; + } - public StackUpgradeInventory( final ItemStack stack, final IAEAppEngInventory inventory, final int s ) - { - super( inventory, s ); - this.stack = stack; - } + @Override + public int getMaxInstalled(final Upgrades upgrades) { + int max = 0; - @Override - public int getMaxInstalled( final Upgrades upgrades ) - { - int max = 0; + for (final ItemStack is : upgrades.getSupported().keySet()) { + if (ItemStack.areItemsEqual(this.stack, is)) { + max = upgrades.getSupported().get(is); + break; + } + } - for( final ItemStack is : upgrades.getSupported().keySet() ) - { - if( ItemStack.areItemsEqual( this.stack, is ) ) - { - max = upgrades.getSupported().get( is ); - break; - } - } - - return max; - } + return max; + } } diff --git a/src/main/java/appeng/parts/automation/UpgradeInventory.java b/src/main/java/appeng/parts/automation/UpgradeInventory.java index b79170e74..82c6e5034 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.item.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.items.IItemHandler; @@ -33,159 +32,138 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.inv.filter.IAEItemFilter; +public abstract class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory { + private final IAEAppEngInventory parent; -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 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; + public UpgradeInventory(final IAEAppEngInventory parent, final int s) { + super(null, s, 1); + this.setTileEntity(this); + this.parent = parent; + this.setFilter(new UpgradeInvFilter()); + } - public UpgradeInventory( final IAEAppEngInventory parent, final int s ) - { - super( null, s, 1 ); - this.setTileEntity( this ); - this.parent = parent; - this.setFilter( new UpgradeInvFilter() ); - } + @Override + protected boolean eventsEnabled() { + return true; + } - @Override - protected boolean eventsEnabled() - { - return true; - } + public int getInstalledUpgrades(final Upgrades u) { + if (!this.cached) { + this.updateUpgradeInfo(); + } - public int getInstalledUpgrades( final Upgrades u ) - { - if( !this.cached ) - { - this.updateUpgradeInfo(); - } + 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; + } + } - 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; - } - } + public abstract int getMaxInstalled(Upgrades upgrades); - public abstract int getMaxInstalled( Upgrades upgrades ); + private void updateUpgradeInfo() { + this.cached = true; + this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0; - private void updateUpgradeInfo() - { - this.cached = true; - this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0; + for (final ItemStack is : this) { + if (is == null || is.getItem() == Items.AIR || !(is.getItem() instanceof IUpgradeModule)) { + continue; + } - for( final ItemStack is : this ) - { - if( is == null || is.getItem() == Items.AIR || !( is.getItem() instanceof IUpgradeModule ) ) - { - continue; - } + final 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; + } + } - final 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)); + } - 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 readFromNBT(final CompoundNBT target) { + super.readFromNBT(target); + this.updateUpgradeInfo(); + } - @Override - public void readFromNBT( final CompoundNBT target ) - { - super.readFromNBT( target ); - this.updateUpgradeInfo(); - } + @Override + public void saveChanges() { + if (this.parent != null) { + this.parent.saveChanges(); + } + } - @Override - public void saveChanges() - { - if( this.parent != null ) - { - this.parent.saveChanges(); - } - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + this.cached = false; + if (this.parent != null && Platform.isServer()) { + this.parent.onChangeInventory(inv, slot, mc, removedStack, newStack); + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - this.cached = false; - if( this.parent != null && Platform.isServer() ) - { - this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack ); - } - } + private class UpgradeInvFilter implements IAEItemFilter { - private class UpgradeInvFilter implements IAEItemFilter - { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack itemstack ) - { - if( itemstack.isEmpty() ) - { - return false; - } - final Item it = itemstack.getItem(); - if( it instanceof IUpgradeModule ) - { - final Upgrades u = ( (IUpgradeModule) it ).getType( itemstack ); - if( u != null ) - { - return UpgradeInventory.this.getInstalledUpgrades( u ) < UpgradeInventory.this.getMaxInstalled( u ); - } - } - return false; - } - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack itemstack) { + if (itemstack.isEmpty()) { + return false; + } + final Item it = itemstack.getItem(); + if (it instanceof IUpgradeModule) { + final Upgrades u = ((IUpgradeModule) it).getType(itemstack); + if (u != null) { + return UpgradeInventory.this.getInstalledUpgrades(u) < UpgradeInventory.this.getMaxInstalled(u); + } + } + return false; + } + } } diff --git a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java index ebc840af9..ea53d52f5 100644 --- a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java +++ b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java @@ -18,7 +18,6 @@ package appeng.parts.misc; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -46,317 +45,271 @@ import appeng.me.storage.ITickingMonitor; import appeng.util.Platform; import appeng.util.item.AEItemStack; - /** - * Wraps an Item Handler in such a way that it can be used as an IMEInventory for items. + * Wraps an Item Handler in such a way that it can be used as an IMEInventory + * for items. */ -class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, ITickingMonitor -{ - private final Map, Object> listeners = new HashMap<>(); - private IActionSource mySource; - private final IItemHandler itemHandler; - private final IGridProxyable proxyable; - private final InventoryCache cache; +class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, ITickingMonitor { + private final Map, Object> listeners = new HashMap<>(); + private IActionSource mySource; + private final IItemHandler itemHandler; + private final IGridProxyable proxyable; + private final InventoryCache cache; - ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy ) - { - this.itemHandler = itemHandler; - this.proxyable = proxy; - this.cache = new InventoryCache( this.itemHandler ); - } + ItemHandlerAdapter(IItemHandler itemHandler, IGridProxyable proxy) { + this.itemHandler = itemHandler; + this.proxyable = proxy; + this.cache = new InventoryCache(this.itemHandler); + } - @Override - public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src ) - { - ItemStack orgInput = iox.createItemStack(); - ItemStack remaining = orgInput; + @Override + public IAEItemStack injectItems(IAEItemStack iox, Actionable type, IActionSource src) { + ItemStack orgInput = iox.createItemStack(); + ItemStack remaining = orgInput; - int slotCount = this.itemHandler.getSlots(); - boolean simulate = ( type == Actionable.SIMULATE ); + int slotCount = this.itemHandler.getSlots(); + boolean simulate = (type == Actionable.SIMULATE); - // This uses a brute force approach and tries to jam it in every slot the inventory exposes. - for( int i = 0; i < slotCount && !remaining.isEmpty(); i++ ) - { - remaining = this.itemHandler.insertItem( i, remaining, simulate ); - } + // This uses a brute force approach and tries to jam it in every slot the + // inventory exposes. + for (int i = 0; i < slotCount && !remaining.isEmpty(); i++) { + remaining = this.itemHandler.insertItem(i, remaining, simulate); + } - // At this point, we still have some items left... - if( remaining == orgInput ) - { - // The stack remained unmodified, target inventory is full - return iox; - } + // At this point, we still have some items left... + if (remaining == orgInput) { + // The stack remained unmodified, target inventory is full + return iox; + } - if( type == Actionable.MODULATE ) - { - try - { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); - } - catch( GridAccessException ex ) - { - // meh - } - } + if (type == Actionable.MODULATE) { + try { + this.proxyable.getProxy().getTick().alertDevice(this.proxyable.getProxy().getNode()); + } catch (GridAccessException ex) { + // meh + } + } - return AEItemStack.fromItemStack( remaining ); - } + return AEItemStack.fromItemStack(remaining); + } - @Override - public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src ) - { + @Override + public IAEItemStack extractItems(IAEItemStack request, Actionable mode, IActionSource src) { - ItemStack requestedItemStack = request.createItemStack(); - int remainingSize = requestedItemStack.getCount(); + ItemStack requestedItemStack = request.createItemStack(); + int remainingSize = requestedItemStack.getCount(); - // Use this to gather the requested items - ItemStack gathered = ItemStack.EMPTY; + // Use this to gather the requested items + ItemStack gathered = ItemStack.EMPTY; - final boolean simulate = ( mode == Actionable.SIMULATE ); + final boolean simulate = (mode == Actionable.SIMULATE); - for( int i = 0; i < this.itemHandler.getSlots(); i++ ) - { - ItemStack stackInInventorySlot = this.itemHandler.getStackInSlot( i ); + for (int i = 0; i < this.itemHandler.getSlots(); i++) { + ItemStack stackInInventorySlot = this.itemHandler.getStackInSlot(i); - if( !Platform.itemComparisons().isSameItem( stackInInventorySlot, requestedItemStack ) ) - { - continue; - } + if (!Platform.itemComparisons().isSameItem(stackInInventorySlot, requestedItemStack)) { + continue; + } - ItemStack extracted; - int stackSizeCurrentSlot = stackInInventorySlot.getCount(); - int remainingCurrentSlot = Math.min( remainingSize, stackSizeCurrentSlot ); + ItemStack extracted; + int stackSizeCurrentSlot = stackInInventorySlot.getCount(); + int remainingCurrentSlot = Math.min(remainingSize, stackSizeCurrentSlot); - // We have to loop here because according to the docs, the handler shouldn't return a stack with size > - // maxSize, even if we request more. So even if it returns a valid stack, it might have more stuff. - do - { - extracted = this.itemHandler.extractItem( i, remainingCurrentSlot, simulate ); - if( !extracted.isEmpty() ) - { - if( extracted.getCount() > remainingCurrentSlot ) - { - // Something broke. It should never return more than we requested... - // We're going to silently eat the remainder - AELog.warn( "Mod that provided item handler %s is broken. Returned %s items while only requesting %d.", - this.itemHandler.getClass().getName(), extracted.toString(), remainingCurrentSlot ); - extracted.setCount( remainingCurrentSlot ); - } + // We have to loop here because according to the docs, the handler shouldn't + // return a stack with size > + // maxSize, even if we request more. So even if it returns a valid stack, it + // might have more stuff. + do { + extracted = this.itemHandler.extractItem(i, remainingCurrentSlot, simulate); + if (!extracted.isEmpty()) { + if (extracted.getCount() > remainingCurrentSlot) { + // Something broke. It should never return more than we requested... + // We're going to silently eat the remainder + AELog.warn( + "Mod that provided item handler %s is broken. Returned %s items while only requesting %d.", + this.itemHandler.getClass().getName(), extracted.toString(), remainingCurrentSlot); + extracted.setCount(remainingCurrentSlot); + } - // We're just gonna use the first stack we get our hands on as the template for the rest. - // In case some stupid itemhandler (aka forge) returns an internal state we have to do a second - // expensive copy again. - if( gathered.isEmpty() ) - { - gathered = extracted.copy(); - } - else - { - gathered.grow( extracted.getCount() ); - } - remainingCurrentSlot -= extracted.getCount(); - } - } - while( !extracted.isEmpty() && remainingCurrentSlot > 0 ); + // We're just gonna use the first stack we get our hands on as the template for + // the rest. + // In case some stupid itemhandler (aka forge) returns an internal state we have + // to do a second + // expensive copy again. + if (gathered.isEmpty()) { + gathered = extracted.copy(); + } else { + gathered.grow(extracted.getCount()); + } + remainingCurrentSlot -= extracted.getCount(); + } + } while (!extracted.isEmpty() && remainingCurrentSlot > 0); - remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot; + remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot; - // Done? - if( remainingSize <= 0 ) - { - break; - } - } + // Done? + if (remainingSize <= 0) { + break; + } + } - if( !gathered.isEmpty() ) - { - if( mode == Actionable.MODULATE ) - { - try - { - this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() ); - } - catch( GridAccessException ex ) - { - // meh - } - } + if (!gathered.isEmpty()) { + if (mode == Actionable.MODULATE) { + try { + this.proxyable.getProxy().getTick().alertDevice(this.proxyable.getProxy().getNode()); + } catch (GridAccessException ex) { + // meh + } + } - return AEItemStack.fromItemStack( gathered ); - } + return AEItemStack.fromItemStack(gathered); + } - return null; - } + return null; + } - @Override - public TickRateModulation onTick() - { - List changes = this.cache.update(); - if( !changes.isEmpty() ) - { - this.postDifference( changes ); - return TickRateModulation.URGENT; - } - else - { - return TickRateModulation.SLOWER; - } - } + @Override + public TickRateModulation onTick() { + List changes = this.cache.update(); + if (!changes.isEmpty()) { + this.postDifference(changes); + return TickRateModulation.URGENT; + } else { + return TickRateModulation.SLOWER; + } + } - @Override - public void setActionSource( final IActionSource mySource ) - { - this.mySource = mySource; - } + @Override + public void setActionSource(final IActionSource mySource) { + this.mySource = mySource; + } - @Override - public IItemList getAvailableItems( IItemList out ) - { - return this.cache.getAvailableItems( out ); - } + @Override + public IItemList getAvailableItems(IItemList out) { + return this.cache.getAvailableItems(out); + } - @Override - public IItemStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public IItemStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - private void postDifference( Iterable a ) - { - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Map.Entry, Object> l = i.next(); - final IMEMonitorHandlerReceiver key = l.getKey(); - if( key.isValid( l.getValue() ) ) - { - key.postChange( this, a, this.mySource ); - } - else - { - i.remove(); - } - } - } + private void postDifference(Iterable a) { + final Iterator, Object>> i = this.listeners.entrySet() + .iterator(); + while (i.hasNext()) { + final Map.Entry, Object> l = i.next(); + final IMEMonitorHandlerReceiver key = l.getKey(); + if (key.isValid(l.getValue())) { + key.postChange(this, a, this.mySource); + } else { + i.remove(); + } + } + } - private static class InventoryCache - { - private IAEItemStack[] cachedAeStacks = new IAEItemStack[0]; - private final IItemHandler itemHandler; + private static class InventoryCache { + private IAEItemStack[] cachedAeStacks = new IAEItemStack[0]; + private final IItemHandler itemHandler; - public InventoryCache( IItemHandler itemHandler ) - { - this.itemHandler = itemHandler; - } + public InventoryCache(IItemHandler itemHandler) { + this.itemHandler = itemHandler; + } - public IItemList getAvailableItems( IItemList out ) - { - Arrays.stream( this.cachedAeStacks ).forEach( out::add ); - return out; - } + public IItemList getAvailableItems(IItemList out) { + Arrays.stream(this.cachedAeStacks).forEach(out::add); + return out; + } - public List update() - { - final List changes = new ArrayList<>(); - final int slots = this.itemHandler.getSlots(); + public List update() { + final List changes = new ArrayList<>(); + final int slots = this.itemHandler.getSlots(); - // Make room for new slots - if( slots > this.cachedAeStacks.length ) - { - this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); - } + // Make room for new slots + if (slots > this.cachedAeStacks.length) { + this.cachedAeStacks = Arrays.copyOf(this.cachedAeStacks, slots); + } - for( int slot = 0; slot < slots; slot++ ) - { - // Save the old stuff - final IAEItemStack oldAeIS = this.cachedAeStacks[slot]; - final ItemStack newIS = this.itemHandler.getStackInSlot( slot ); + for (int slot = 0; slot < slots; slot++) { + // Save the old stuff + final IAEItemStack oldAeIS = this.cachedAeStacks[slot]; + final ItemStack newIS = this.itemHandler.getStackInSlot(slot); - this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes ); - } + this.handlePossibleSlotChanges(slot, oldAeIS, newIS, changes); + } - // Handle cases where the number of slots actually is lower now than before - if( slots < this.cachedAeStacks.length ) - { - for( int slot = slots; slot < this.cachedAeStacks.length; slot++ ) - { - final IAEItemStack aeStack = this.cachedAeStacks[slot]; + // Handle cases where the number of slots actually is lower now than before + if (slots < this.cachedAeStacks.length) { + for (int slot = slots; slot < this.cachedAeStacks.length; slot++) { + final IAEItemStack aeStack = this.cachedAeStacks[slot]; - if( aeStack != null ) - { - final IAEItemStack a = aeStack.copy(); - a.setStackSize( -a.getStackSize() ); - changes.add( a ); - } - } + if (aeStack != null) { + final IAEItemStack a = aeStack.copy(); + a.setStackSize(-a.getStackSize()); + changes.add(a); + } + } - // Reduce the cache size - this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); - } + // Reduce the cache size + this.cachedAeStacks = Arrays.copyOf(this.cachedAeStacks, slots); + } - return changes; - } + return changes; + } - private void handlePossibleSlotChanges( int slot, IAEItemStack oldAeIS, ItemStack newIS, List changes ) - { - if( oldAeIS != null && oldAeIS.isSameType( newIS ) ) - { - this.handleStackSizeChanged( slot, oldAeIS, newIS, changes ); - } - else - { - this.handleItemChanged( slot, oldAeIS, newIS, changes ); - } - } + private void handlePossibleSlotChanges(int slot, IAEItemStack oldAeIS, ItemStack newIS, + List changes) { + if (oldAeIS != null && oldAeIS.isSameType(newIS)) { + this.handleStackSizeChanged(slot, oldAeIS, newIS, changes); + } else { + this.handleItemChanged(slot, oldAeIS, newIS, changes); + } + } - private void handleStackSizeChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List changes ) - { - // Still the same item, but amount might have changed - final long diff = newIS.getCount() - oldAeIS.getStackSize(); + private void handleStackSizeChanged(int slot, IAEItemStack oldAeIS, ItemStack newIS, + List changes) { + // Still the same item, but amount might have changed + final long diff = newIS.getCount() - oldAeIS.getStackSize(); - if( diff != 0 ) - { - final IAEItemStack stack = oldAeIS.copy(); - stack.setStackSize( newIS.getCount() ); + if (diff != 0) { + final IAEItemStack stack = oldAeIS.copy(); + stack.setStackSize(newIS.getCount()); - this.cachedAeStacks[slot] = stack; + this.cachedAeStacks[slot] = stack; - final IAEItemStack a = stack.copy(); - a.setStackSize( diff ); - changes.add( a ); - } - } + final IAEItemStack a = stack.copy(); + a.setStackSize(diff); + changes.add(a); + } + } - private void handleItemChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List changes ) - { - // Completely different item - this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS ); + private void handleItemChanged(int slot, IAEItemStack oldAeIS, ItemStack newIS, List changes) { + // Completely different item + this.cachedAeStacks[slot] = AEItemStack.fromItemStack(newIS); - // If we had a stack previously in this slot, notify the network about its disappearance - if( oldAeIS != null ) - { - oldAeIS.setStackSize( -oldAeIS.getStackSize() ); - changes.add( oldAeIS ); - } + // If we had a stack previously in this slot, notify the network about its + // disappearance + if (oldAeIS != null) { + oldAeIS.setStackSize(-oldAeIS.getStackSize()); + changes.add(oldAeIS); + } - // Notify the network about the new stack. Note that this is null if newIS was null - if( this.cachedAeStacks[slot] != null ) - { - changes.add( this.cachedAeStacks[slot] ); - } - } - } + // Notify the network about the new stack. Note that this is null if newIS was + // null + if (this.cachedAeStacks[slot] != null) { + changes.add(this.cachedAeStacks[slot]); + } + } + } } diff --git a/src/main/java/appeng/parts/misc/PartCableAnchor.java b/src/main/java/appeng/parts/misc/PartCableAnchor.java index ca8deee36..4655abeeb 100644 --- a/src/main/java/appeng/parts/misc/PartCableAnchor.java +++ b/src/main/java/appeng/parts/misc/PartCableAnchor.java @@ -18,7 +18,6 @@ package appeng.parts.misc; - import java.io.IOException; import java.util.List; import java.util.Random; @@ -50,206 +49,172 @@ import appeng.core.AppEng; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartCableAnchor implements IPart { -public class PartCableAnchor implements IPart -{ + @PartModels + public static final PartModel DEFAULT_MODELS = new PartModel(false, + new ResourceLocation(AppEng.MOD_ID, "part/cable_anchor")); - @PartModels - public static final PartModel DEFAULT_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor" ) ); + @PartModels + public static final PartModel FACADE_MODELS = new PartModel(false, + new ResourceLocation(AppEng.MOD_ID, "part/cable_anchor_short")); - @PartModels - public static final PartModel FACADE_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor_short" ) ); + private ItemStack is = ItemStack.EMPTY; + private IPartHost host = null; + private AEPartLocation mySide = AEPartLocation.UP; - private ItemStack is = ItemStack.EMPTY; - private IPartHost host = null; - private AEPartLocation mySide = AEPartLocation.UP; + public PartCableAnchor(final ItemStack is) { + this.is = is; + } - public PartCableAnchor( final ItemStack is ) - { - this.is = is; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + if (this.host != null && this.host.getFacadeContainer().getFacade(this.mySide) != null) { + bch.addBox(7, 7, 10, 9, 9, 14); + } else { + bch.addBox(7, 7, 10, 9, 9, 16); + } + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null ) - { - bch.addBox( 7, 7, 10, 9, 9, 14 ); - } - else - { - bch.addBox( 7, 7, 10, 9, 9, 16 ); - } - } + @Override + public ItemStack getItemStack(final PartItemStack wrenched) { + return this.is; + } - @Override - public ItemStack getItemStack( final PartItemStack wrenched ) - { - return this.is; - } + @Override + public boolean requireDynamicRender() { + return false; + } - @Override - public boolean requireDynamicRender() - { - return false; - } + @Override + public boolean isSolid() { + return false; + } - @Override - public boolean isSolid() - { - return false; - } + @Override + public boolean canConnectRedstone() { + return false; + } - @Override - public boolean canConnectRedstone() - { - return false; - } + @Override + public void writeToNBT(final CompoundNBT data) { - @Override - public void writeToNBT( final CompoundNBT data ) - { + } - } + @Override + public void readFromNBT(final CompoundNBT data) { - @Override - public void readFromNBT( final CompoundNBT data ) - { + } - } + @Override + public int getLightLevel() { + return 0; + } - @Override - public int getLightLevel() - { - return 0; - } + @Override + public boolean isLadder(final LivingEntity entity) { + return this.mySide.yOffset == 0 && (entity.collidedHorizontally || !entity.onGround); + } - @Override - public boolean isLadder( final LivingEntity entity ) - { - return this.mySide.yOffset == 0 && ( entity.collidedHorizontally || !entity.onGround ); - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { + } - } + @Override + public int isProvidingStrongPower() { + return 0; + } - @Override - public int isProvidingStrongPower() - { - return 0; - } + @Override + public int isProvidingWeakPower() { + return 0; + } - @Override - public int isProvidingWeakPower() - { - return 0; - } + @Override + public void writeToStream(final PacketBuffer data) throws IOException { - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { + } - } + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + return false; + } - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - return false; - } + @Override + public IGridNode getGridNode() { + return null; + } - @Override - public IGridNode getGridNode() - { - return null; - } + @Override + public void onEntityCollision(final Entity entity) { - @Override - public void onEntityCollision( final Entity entity ) - { + } - } + @Override + public void removeFromWorld() { - @Override - public void removeFromWorld() - { + } - } + @Override + public void addToWorld() { - @Override - public void addToWorld() - { + } - } + @Override + public IGridNode getExternalFacingNode() { + return null; + } - @Override - public IGridNode getExternalFacingNode() - { - return null; - } + @Override + public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final TileEntity tile) { + this.host = host; + this.mySide = side; + } - @Override - public void setPartHostInfo( final AEPartLocation side, final IPartHost host, final TileEntity tile ) - { - this.host = host; - this.mySide = side; - } + @Override + public boolean onActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + return false; + } - @Override - public boolean onActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - return false; - } + @Override + public boolean onShiftActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + return false; + } - @Override - public boolean onShiftActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - return false; - } + @Override + public void getDrops(final List drops, final boolean wrenched) { - @Override - public void getDrops( final List drops, final boolean wrenched ) - { + } - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 0; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 0; - } + @Override + public void animateTick(final World world, final BlockPos pos, final Random r) { - @Override - public void animateTick( final World world, final BlockPos pos, final Random r ) - { + } - } + @Override + public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { - @Override - public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { + } - } + @Override + public boolean canBePlacedOn(final BusSupport what) { + return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE; + } - @Override - public boolean canBePlacedOn( final BusSupport what ) - { - return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE; - } - - @Override - public IPartModel getStaticModels() - { - if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null ) - { - return FACADE_MODELS; - } - else - { - return DEFAULT_MODELS; - } - } + @Override + public IPartModel getStaticModels() { + if (this.host != null && this.host.getFacadeContainer().getFacade(this.mySide) != null) { + return FACADE_MODELS; + } else { + return DEFAULT_MODELS; + } + } } diff --git a/src/main/java/appeng/parts/misc/PartInterface.java b/src/main/java/appeng/parts/misc/PartInterface.java index 3c2e50017..012103c49 100644 --- a/src/main/java/appeng/parts/misc/PartInterface.java +++ b/src/main/java/appeng/parts/misc/PartInterface.java @@ -18,13 +18,9 @@ package appeng.parts.misc; - import java.util.EnumSet; import java.util.List; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerInterface; import com.google.common.collect.ImmutableSet; import net.minecraft.entity.player.PlayerEntity; @@ -63,8 +59,10 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.api.util.AECableType; import appeng.api.util.IConfigManager; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerInterface; import appeng.core.AppEng; - import appeng.helpers.DualityInterface; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; @@ -77,243 +75,206 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IInventoryDestination; import appeng.util.inv.InvOperation; +public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, + IInterfaceHost, IAEAppEngInventory, IPriorityHost { -public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, IAEAppEngInventory, IPriorityHost -{ + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/interface_base"); - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/interface_base" ); + @PartModels + public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/interface_off")); - @PartModels - public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_off" ) ); + @PartModels + public static final PartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/interface_on")); - @PartModels - public static final PartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_on" ) ); + @PartModels + public static final PartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/interface_has_channel")); - @PartModels - public static final PartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_has_channel" ) ); + private final DualityInterface duality = new DualityInterface(this.getProxy(), this); - private final DualityInterface duality = new DualityInterface( this.getProxy(), this ); + @Reflected + public PartInterface(final ItemStack is) { + super(is); + } - @Reflected - public PartInterface( final ItemStack is ) - { - super( is ); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkChannelsChanged c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkChannelsChanged c ) - { - this.duality.notifyNeighbors(); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkPowerStatusChange c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkPowerStatusChange c ) - { - this.duality.notifyNeighbors(); - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(2, 2, 14, 14, 14, 16); + bch.addBox(5, 5, 12, 11, 11, 14); + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 2, 2, 14, 14, 14, 16 ); - bch.addBox( 5, 5, 12, 11, 11, 14 ); - } + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.duality.getInstalledUpgrades(u); + } - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.duality.getInstalledUpgrades( u ); - } + @Override + public void gridChanged() { + this.duality.gridChanged(); + } - @Override - public void gridChanged() - { - this.duality.gridChanged(); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.duality.readFromNBT(data); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.duality.readFromNBT( data ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.duality.writeToNBT(data); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.duality.writeToNBT( data ); - } + @Override + public void addToWorld() { + super.addToWorld(); + this.duality.initialize(); + } - @Override - public void addToWorld() - { - super.addToWorld(); - this.duality.initialize(); - } + @Override + public void getDrops(final List drops, final boolean wrenched) { + this.duality.addDrops(drops); + } - @Override - public void getDrops( final List drops, final boolean wrenched ) - { - this.duality.addDrops( drops ); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 4; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 4; - } + @Override + public IConfigManager getConfigManager() { + return this.duality.getConfigManager(); + } - @Override - public IConfigManager getConfigManager() - { - return this.duality.getConfigManager(); - } + @Override + public IItemHandler getInventoryByName(final String name) { + return this.duality.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - return this.duality.getInventoryByName( name ); - } + @Override + public boolean onPartActivate(final PlayerEntity p, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerInterface.TYPE, p, ContainerLocator.forPart(this)); + } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity p, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerInterface.TYPE, p, ContainerLocator.forPart(this)); - } - return true; - } + @Override + public boolean canInsert(final ItemStack stack) { + return this.duality.canInsert(stack); + } - @Override - public boolean canInsert( final ItemStack stack ) - { - return this.duality.canInsert( stack ); - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + return this.duality.getInventory(channel); + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - return this.duality.getInventory( channel ); - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return this.duality.getTickingRequest(node); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return this.duality.getTickingRequest( node ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.duality.tickingRequest(node, ticksSinceLastCall); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.duality.tickingRequest( node, ticksSinceLastCall ); - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + this.duality.onChangeInventory(inv, slot, mc, removedStack, newStack); + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - this.duality.onChangeInventory( inv, slot, mc, removedStack, newStack ); - } + @Override + public DualityInterface getInterfaceDuality() { + return this.duality; + } - @Override - public DualityInterface getInterfaceDuality() - { - return this.duality; - } + @Override + public EnumSet getTargets() { + return EnumSet.of(this.getSide().getFacing()); + } - @Override - public EnumSet getTargets() - { - return EnumSet.of( this.getSide().getFacing() ); - } + @Override + public TileEntity getTileEntity() { + return super.getHost().getTile(); + } - @Override - public TileEntity getTileEntity() - { - return super.getHost().getTile(); - } + @Override + public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table) { + return this.duality.pushPattern(patternDetails, table); + } - @Override - public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table ) - { - return this.duality.pushPattern( patternDetails, table ); - } + @Override + public boolean isBusy() { + return this.duality.isBusy(); + } - @Override - public boolean isBusy() - { - return this.duality.isBusy(); - } + @Override + public void provideCrafting(final ICraftingProviderHelper craftingTracker) { + this.duality.provideCrafting(craftingTracker); + } - @Override - public void provideCrafting( final ICraftingProviderHelper craftingTracker ) - { - this.duality.provideCrafting( craftingTracker ); - } + @Override + public ImmutableSet getRequestedJobs() { + return this.duality.getRequestedJobs(); + } - @Override - public ImmutableSet getRequestedJobs() - { - return this.duality.getRequestedJobs(); - } + @Override + public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) { + return this.duality.injectCraftedItems(link, items, mode); + } - @Override - public IAEItemStack injectCraftedItems( final ICraftingLink link, final IAEItemStack items, final Actionable mode ) - { - return this.duality.injectCraftedItems( link, items, mode ); - } + @Override + public void jobStateChange(final ICraftingLink link) { + this.duality.jobStateChange(link); + } - @Override - public void jobStateChange( final ICraftingLink link ) - { - this.duality.jobStateChange( link ); - } + @Override + public int getPriority() { + return this.duality.getPriority(); + } - @Override - public int getPriority() - { - return this.duality.getPriority(); - } + @Override + public void setPriority(final int newValue) { + this.duality.setPriority(newValue); + } - @Override - public void setPriority( final int newValue ) - { - this.duality.setPriority( newValue ); - } + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public LazyOptional getCapability(Capability capabilityClass) { + return this.duality.getCapability(capabilityClass, this.getSide().getFacing()); + } - @Override - public LazyOptional getCapability(Capability capabilityClass ) - { - return this.duality.getCapability( capabilityClass, this.getSide().getFacing() ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().iface().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().iface().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerInterface.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerInterface.TYPE; + } } diff --git a/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java b/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java index 9614318c1..5aed0bb86 100644 --- a/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java +++ b/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java @@ -18,7 +18,6 @@ package appeng.parts.misc; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,47 +27,38 @@ import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartInvertedToggleBus extends PartToggleBus { + @PartModels + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, + "part/inverted_toggle_bus_base"); -public class PartInvertedToggleBus extends PartToggleBus -{ - @PartModels - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/inverted_toggle_bus_base" ); + public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_STATUS_OFF); + public static final PartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_STATUS_ON); + public static final PartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL); - public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_STATUS_OFF ); - public static final PartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_STATUS_ON ); - public static final PartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_STATUS_HAS_CHANNEL ); + @Reflected + public PartInvertedToggleBus(final ItemStack is) { + super(is); + this.getProxy().setIdlePowerUsage(0.0); + this.getOuterProxy().setIdlePowerUsage(0.0); + this.getProxy().setFlags(); + this.getOuterProxy().setFlags(); + } - @Reflected - public PartInvertedToggleBus( final ItemStack is ) - { - super( is ); - this.getProxy().setIdlePowerUsage( 0.0 ); - this.getOuterProxy().setIdlePowerUsage( 0.0 ); - this.getProxy().setFlags(); - this.getOuterProxy().setFlags(); - } + @Override + protected boolean getIntention() { + return !super.getIntention(); + } - @Override - protected boolean getIntention() - { - return !super.getIntention(); - } - - @Override - public IPartModel getStaticModels() - { - if( this.hasRedstoneFlag() && this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.hasRedstoneFlag() && this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public IPartModel getStaticModels() { + if (this.hasRedstoneFlag() && this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.hasRedstoneFlag() && this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/parts/misc/PartSharedStorageBus.java b/src/main/java/appeng/parts/misc/PartSharedStorageBus.java index ddaa6cc9c..c2dfc887a 100644 --- a/src/main/java/appeng/parts/misc/PartSharedStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartSharedStorageBus.java @@ -1,196 +1,171 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2018, 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.parts.misc; - - -import java.util.Collections; -import java.util.List; - -import appeng.api.config.Settings; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; - -import appeng.api.AEApi; -import appeng.api.networking.events.MENetworkCellArrayUpdate; -import appeng.api.networking.events.MENetworkChannelsChanged; -import appeng.api.networking.events.MENetworkEventSubscribe; -import appeng.api.networking.events.MENetworkPowerStatusChange; -import appeng.api.networking.ticking.IGridTickable; -import appeng.api.parts.IPartCollisionHelper; -import appeng.api.storage.ICellContainer; -import appeng.api.storage.ICellInventory; -import appeng.api.storage.IMEInventoryHandler; -import appeng.api.storage.IStorageChannel; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.util.AECableType; -import appeng.api.util.IConfigManager; -import appeng.helpers.IPriorityHost; -import appeng.me.GridAccessException; -import appeng.parts.automation.PartUpgradeable; - - -/** - * @author BrockWS - * @version rv6 - 22/05/2018 - * @since rv6 22/05/2018 - */ -public abstract class PartSharedStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IPriorityHost -{ - private boolean wasActive = false; - private int priority = 0; - - public PartSharedStorageBus( ItemStack is ) - { - super( is ); - } - - protected void updateStatus() - { - final boolean currentActive = this.getProxy().isActive(); - if( this.wasActive != currentActive ) - { - this.wasActive = currentActive; - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - this.getHost().markForUpdate(); - } - catch( final GridAccessException ignore ) - { - // :P - } - } - } - - @MENetworkEventSubscribe - public void updateChannels( final MENetworkChannelsChanged changedChannels ) - { - this.updateStatus(); - } - - /** - * Helper method to get this parts storage channel - * - * @return Storage channel - */ - public IStorageChannel getStorageChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } - - protected abstract void resetCache(); - - protected abstract void resetCache( boolean fullReset ); - - @Override - public List getCellArray( final IStorageChannel channel ) - { - return Collections.emptyList(); - } - - @Override - public void blinkCell( int slot ) - { - } - - @Override - public void saveChanges( ICellInventory cellInventory ) - { - } - - @Override - public int getPriority() - { - return this.priority; - } - - @Override - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.getHost().markForSave(); - this.resetCache( true ); - } - - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.updateStatus(); - } - - @Override - public void upgradesChanged() - { - super.upgradesChanged(); - this.resetCache( true ); - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.resetCache( true ); - this.getHost().markForSave(); - } - - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - this.resetCache( false ); - } - } - - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.priority = data.getInt( "priority" ); - } - - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putInt( "priority", this.priority ); - } - - @Override - public void getBoxes( final 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 - protected int getUpgradeSlots() - { - return 5; - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 4; - } -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, 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.parts.misc; + +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; + +import appeng.api.AEApi; +import appeng.api.config.Settings; +import appeng.api.networking.events.MENetworkCellArrayUpdate; +import appeng.api.networking.events.MENetworkChannelsChanged; +import appeng.api.networking.events.MENetworkEventSubscribe; +import appeng.api.networking.events.MENetworkPowerStatusChange; +import appeng.api.networking.ticking.IGridTickable; +import appeng.api.parts.IPartCollisionHelper; +import appeng.api.storage.ICellContainer; +import appeng.api.storage.ICellInventory; +import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.IStorageChannel; +import appeng.api.storage.channels.IItemStorageChannel; +import appeng.api.util.AECableType; +import appeng.api.util.IConfigManager; +import appeng.helpers.IPriorityHost; +import appeng.me.GridAccessException; +import appeng.parts.automation.PartUpgradeable; + +/** + * @author BrockWS + * @version rv6 - 22/05/2018 + * @since rv6 22/05/2018 + */ +public abstract class PartSharedStorageBus extends PartUpgradeable + implements IGridTickable, ICellContainer, IPriorityHost { + private boolean wasActive = false; + private int priority = 0; + + public PartSharedStorageBus(ItemStack is) { + super(is); + } + + protected void updateStatus() { + final boolean currentActive = this.getProxy().isActive(); + if (this.wasActive != currentActive) { + this.wasActive = currentActive; + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + this.getHost().markForUpdate(); + } catch (final GridAccessException ignore) { + // :P + } + } + } + + @MENetworkEventSubscribe + public void updateChannels(final MENetworkChannelsChanged changedChannels) { + this.updateStatus(); + } + + /** + * Helper method to get this parts storage channel + * + * @return Storage channel + */ + public IStorageChannel getStorageChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } + + protected abstract void resetCache(); + + protected abstract void resetCache(boolean fullReset); + + @Override + public List getCellArray(final IStorageChannel channel) { + return Collections.emptyList(); + } + + @Override + public void blinkCell(int slot) { + } + + @Override + public void saveChanges(ICellInventory cellInventory) { + } + + @Override + public int getPriority() { + return this.priority; + } + + @Override + public void setPriority(final int newValue) { + this.priority = newValue; + this.getHost().markForSave(); + this.resetCache(true); + } + + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.updateStatus(); + } + + @Override + public void upgradesChanged() { + super.upgradesChanged(); + this.resetCache(true); + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.resetCache(true); + this.getHost().markForSave(); + } + + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + this.resetCache(false); + } + } + + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.priority = data.getInt("priority"); + } + + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putInt("priority", this.priority); + } + + @Override + public void getBoxes(final 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 + protected int getUpgradeSlots() { + return 5; + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 4; + } +} diff --git a/src/main/java/appeng/parts/misc/PartStorageBus.java b/src/main/java/appeng/parts/misc/PartStorageBus.java index bf11358cf..8ab1b16ba 100644 --- a/src/main/java/appeng/parts/misc/PartStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartStorageBus.java @@ -18,14 +18,10 @@ package appeng.parts.misc; - import java.util.Collections; import java.util.List; import java.util.Objects; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerStorageBus; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -77,9 +73,11 @@ import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.IConfigManager; import appeng.capabilities.Capabilities; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerStorageBus; import appeng.core.AppEng; import appeng.core.settings.TickRates; - import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; import appeng.helpers.Reflected; @@ -97,561 +95,475 @@ import appeng.util.inv.InvOperation; import appeng.util.prioritylist.FuzzyPriorityList; import appeng.util.prioritylist.PrecisePriorityList; - -public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver, IPriorityHost -{ - - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_base" ); - - @PartModels - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_off" ) ); - - @PartModels - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_on" ) ); - - @PartModels - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" ) ); - - private final IActionSource mySrc; - private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); - private int priority = 0; - private boolean cached = false; - private ITickingMonitor monitor = null; - private MEInventoryHandler handler = null; - private int handlerHash = 0; - private boolean wasActive = false; - private byte resetCacheLogic = 0; - - @Reflected - public PartStorageBus( final ItemStack 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 ); - } - - @Override - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.updateStatus(); - } - - private void updateStatus() - { - final boolean currentActive = this.getProxy().isActive(); - if( this.wasActive != currentActive ) - { - this.wasActive = currentActive; - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - this.getHost().markForUpdate(); - } - catch( final GridAccessException e ) - { - // :P - } - } - } - - @MENetworkEventSubscribe - public void updateChannels( final MENetworkChannelsChanged changedChannels ) - { - this.updateStatus(); - } - - @Override - protected int getUpgradeSlots() - { - return 5; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.resetCache( true ); - this.getHost().markForSave(); - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final 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 readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.Config.readFromNBT( data, "config" ); - this.priority = data.getInt( "priority" ); - } - - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.Config.writeToNBT( data, "config" ); - data.putInt( "priority", this.priority ); - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "config" ) ) - { - return this.Config; - } - - return super.getInventoryByName( name ); - } - - private void resetCache( final boolean fullReset ) - { - if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost() - .getTile() - .getWorld().isRemote ) - { - return; - } - - if( fullReset ) - { - this.resetCacheLogic = 2; - } - else - { - this.resetCacheLogic = 1; - } - - try - { - this.getProxy().getTick().alertDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - @Override - public boolean isValid( final Object verificationToken ) - { - return this.handler == verificationToken; - } - - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource source ) - { - try - { - if( this.getProxy().isActive() ) - { - this.getProxy() - .getStorage() - .postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, - this.mySrc ); - } - } - catch( final GridAccessException e ) - { - // :( - } - } - - @Override - public void onListUpdate() - { - // not used here. - } - - @Override - public void getBoxes( final 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 void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - final TileEntity te = w.getTileEntity( neighbor ); - - // In case the TE was destroyed, we have to do a full reset immediately. - if( te == null ) - { - this.resetCache( true ); - this.resetCache(); - } - else - { - this.resetCache( false ); - } - } - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 4; - } - - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerStorageBus.TYPE, player, ContainerLocator.forPart(this)); - } - return true; - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.StorageBus.getMin(), TickRates.StorageBus.getMax(), this.monitor == null, true ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( this.resetCacheLogic != 0 ) - { - this.resetCache(); - } - - if( this.monitor != null ) - { - return this.monitor.onTick(); - } - - return TickRateModulation.SLEEP; - } - - private void resetCache() - { - final boolean fullReset = this.resetCacheLogic == 2; - this.resetCacheLogic = 0; - - final IMEInventory in = this.getInternalHandler(); - IItemList before = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - if( in != null ) - { - before = in.getAvailableItems( before ); - } - - this.cached = false; - if( fullReset ) - { - this.handlerHash = 0; - } - - final IMEInventory out = this.getInternalHandler(); - - if( in != out ) - { - IItemList after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - if( out != null ) - { - after = out.getAvailableItems( after ); - } - Platform.postListChanges( before, after, this, this.mySrc ); - } - } - - private IMEInventory getInventoryWrapper( TileEntity target ) - { - - Direction targetSide = this.getSide().getFacing().getOpposite(); - - // Prioritize a handler to directly link to another ME network - final LazyOptional accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ); - - if( accessorOpt.isPresent() ) - { - IStorageMonitorableAccessor accessor = accessorOpt.orElse( null ); - IStorageMonitorable inventory = accessor.getInventory( this.mySrc ); - if( inventory != null ) - { - return inventory.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - } - - // So this could / can be a design decision. If the tile does support our custom capability, - // but it does not return an inventory for the action source, we do NOT fall back to using - // IItemHandler's, as that might circumvent the security setings, and might also cause - // performance issues. - return null; - } - - // Check via cap for IItemHandler - final LazyOptional handlerExtOpt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide ); - if( handlerExtOpt.isPresent() ) - { - return new ItemHandlerAdapter( handlerExtOpt.orElse( null ), this ); - } - - return null; - - } - - //TODO, LazyOptionals are cacheable this might need changing? - private int createHandlerHash( TileEntity target ) - { - if( target == null ) - { - return 0; - } - - final Direction targetSide = this.getSide().getFacing().getOpposite(); - - final LazyOptional accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ); - - if( accessorOpt.isPresent() ) - { - return Objects.hash( target, accessorOpt.orElse( null ) ); - } - - final LazyOptional itemHandlerOpt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide ); - - if( itemHandlerOpt.isPresent() ) - { - IItemHandler itemHandler = itemHandlerOpt.orElse( null ); - return Objects.hash( target, itemHandler, itemHandler.getSlots() ); - } - - return 0; - } - - public MEInventoryHandler getInternalHandler() - { - if( this.cached ) - { - return this.handler; - } - - final boolean wasSleeping = this.monitor == null; - - this.cached = true; - final TileEntity self = this.getHost().getTile(); - final TileEntity target = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) ); - final int newHandlerHash = this.createHandlerHash( target ); - - if( newHandlerHash != 0 && newHandlerHash == this.handlerHash ) - { - return this.handler; - } - - this.handlerHash = newHandlerHash; - this.handler = null; - this.monitor = null; - if( target != null ) - { - IMEInventory inv = this.getInventoryWrapper( target ); - - if( inv instanceof MEMonitorIInventory ) - { - final MEMonitorIInventory h = (MEMonitorIInventory) inv; - h.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) ); - } - - if( inv instanceof ITickingMonitor ) - { - this.monitor = (ITickingMonitor) inv; - this.monitor.setActionSource( new MachineSource( this ) ); - } - - if( inv != null ) - { - this.checkInterfaceVsStorageBus( target, this.getSide().getOpposite() ); - - this.handler = new MEInventoryHandler( inv, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - - this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) ); - this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); - this.handler.setPriority( this.priority ); - - final IItemList priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); - - final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; - for( int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++ ) - { - final IAEItemStack is = this.Config.getAEStackInSlot( x ); - if( is != null ) - { - priorityList.add( is ); - } - } - - if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - this.handler - .setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager() - .getSetting( Settings.FUZZY_MODE ) ) ); - } - else - { - this.handler.setPartitionList( new PrecisePriorityList( priorityList ) ); - } - - if( inv instanceof IBaseMonitor ) - { - ( (IBaseMonitor) inv ).addListener( this, this.handler ); - } - } - } - - // update sleep state... - if( wasSleeping != ( this.monitor == null ) ) - { - try - { - final ITickManager tm = this.getProxy().getTick(); - if( this.monitor == null ) - { - tm.sleepDevice( this.getProxy().getNode() ); - } - else - { - tm.wakeDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { - // :( - } - } - - try - { - // force grid to update handlers... - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :3 - } - - return this.handler; - } - - private void checkInterfaceVsStorageBus( final TileEntity target, final AEPartLocation side ) - { - IInterfaceHost achievement = null; - - if( target instanceof IInterfaceHost ) - { - achievement = (IInterfaceHost) target; - } - - if( target instanceof IPartHost ) - { - final Object part = ( (IPartHost) target ).getPart( side ); - if( part instanceof IInterfaceHost ) - { - achievement = (IInterfaceHost) part; - } - } - - if( achievement != null && achievement.getActionableNode() != null ) - { - // Platform.addStat( achievement.getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() - // ); - // Platform.addStat( getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() ); - } - } - - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() : null; - if( out != null ) - { - return Collections.singletonList( out ); - } - } - return Collections.emptyList(); - } - - @Override - public int getPriority() - { - return this.priority; - } - - @Override - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.getHost().markForSave(); - this.resetCache( true ); - } - - @Override - public void blinkCell( final int slot ) - { - } - - // TODO: BC PIPE INTEGRATION - /* - * @Override - * @Method( iname = IntegrationType.BuildCraftTransport ) - * public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with ) - * { - * return type == PipeType.ITEM && with == this.getSide() ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT; - * } - */ - @Override - public void saveChanges( final ICellInventory cellInventory ) - { - // nope! - } - - @Override - public IPartModel getStaticModels() - { - if( this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } - - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().parts().storageBus().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerStorageBus.TYPE; - } +public class PartStorageBus extends PartUpgradeable + implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver, IPriorityHost { + + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/storage_bus_base"); + + @PartModels + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/storage_bus_off")); + + @PartModels + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/storage_bus_on")); + + @PartModels + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, + new ResourceLocation(AppEng.MOD_ID, "part/storage_bus_has_channel")); + + private final IActionSource mySrc; + private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory(this, 63); + private int priority = 0; + private boolean cached = false; + private ITickingMonitor monitor = null; + private MEInventoryHandler handler = null; + private int handlerHash = 0; + private boolean wasActive = false; + private byte resetCacheLogic = 0; + + @Reflected + public PartStorageBus(final ItemStack 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); + } + + @Override + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.updateStatus(); + } + + private void updateStatus() { + final boolean currentActive = this.getProxy().isActive(); + if (this.wasActive != currentActive) { + this.wasActive = currentActive; + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + this.getHost().markForUpdate(); + } catch (final GridAccessException e) { + // :P + } + } + } + + @MENetworkEventSubscribe + public void updateChannels(final MENetworkChannelsChanged changedChannels) { + this.updateStatus(); + } + + @Override + protected int getUpgradeSlots() { + return 5; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.resetCache(true); + this.getHost().markForSave(); + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final 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 readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.Config.readFromNBT(data, "config"); + this.priority = data.getInt("priority"); + } + + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.Config.writeToNBT(data, "config"); + data.putInt("priority", this.priority); + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("config")) { + return this.Config; + } + + return super.getInventoryByName(name); + } + + private void resetCache(final boolean fullReset) { + if (this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null + || this.getHost().getTile().getWorld().isRemote) { + return; + } + + if (fullReset) { + this.resetCacheLogic = 2; + } else { + this.resetCacheLogic = 1; + } + + try { + this.getProxy().getTick().alertDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } + + @Override + public boolean isValid(final Object verificationToken) { + return this.handler == verificationToken; + } + + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, + final IActionSource source) { + try { + if (this.getProxy().isActive()) { + this.getProxy().getStorage().postAlterationOfStoredItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), change, this.mySrc); + } + } catch (final GridAccessException e) { + // :( + } + } + + @Override + public void onListUpdate() { + // not used here. + } + + @Override + public void getBoxes(final 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 void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + final TileEntity te = w.getTileEntity(neighbor); + + // In case the TE was destroyed, we have to do a full reset immediately. + if (te == null) { + this.resetCache(true); + this.resetCache(); + } else { + this.resetCache(false); + } + } + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 4; + } + + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerStorageBus.TYPE, player, ContainerLocator.forPart(this)); + } + return true; + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.StorageBus.getMin(), TickRates.StorageBus.getMax(), this.monitor == null, + true); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (this.resetCacheLogic != 0) { + this.resetCache(); + } + + if (this.monitor != null) { + return this.monitor.onTick(); + } + + return TickRateModulation.SLEEP; + } + + private void resetCache() { + final boolean fullReset = this.resetCacheLogic == 2; + this.resetCacheLogic = 0; + + final IMEInventory in = this.getInternalHandler(); + IItemList before = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + if (in != null) { + before = in.getAvailableItems(before); + } + + this.cached = false; + if (fullReset) { + this.handlerHash = 0; + } + + final IMEInventory out = this.getInternalHandler(); + + if (in != out) { + IItemList after = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createList(); + if (out != null) { + after = out.getAvailableItems(after); + } + Platform.postListChanges(before, after, this, this.mySrc); + } + } + + private IMEInventory getInventoryWrapper(TileEntity target) { + + Direction targetSide = this.getSide().getFacing().getOpposite(); + + // Prioritize a handler to directly link to another ME network + final LazyOptional accessorOpt = target + .getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide); + + if (accessorOpt.isPresent()) { + IStorageMonitorableAccessor accessor = accessorOpt.orElse(null); + IStorageMonitorable inventory = accessor.getInventory(this.mySrc); + if (inventory != null) { + return inventory.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + } + + // So this could / can be a design decision. If the tile does support our custom + // capability, + // but it does not return an inventory for the action source, we do NOT fall + // back to using + // IItemHandler's, as that might circumvent the security setings, and might also + // cause + // performance issues. + return null; + } + + // Check via cap for IItemHandler + final LazyOptional handlerExtOpt = target + .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide); + if (handlerExtOpt.isPresent()) { + return new ItemHandlerAdapter(handlerExtOpt.orElse(null), this); + } + + return null; + + } + + // TODO, LazyOptionals are cacheable this might need changing? + private int createHandlerHash(TileEntity target) { + if (target == null) { + return 0; + } + + final Direction targetSide = this.getSide().getFacing().getOpposite(); + + final LazyOptional accessorOpt = target + .getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide); + + if (accessorOpt.isPresent()) { + return Objects.hash(target, accessorOpt.orElse(null)); + } + + final LazyOptional itemHandlerOpt = target + .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide); + + if (itemHandlerOpt.isPresent()) { + IItemHandler itemHandler = itemHandlerOpt.orElse(null); + return Objects.hash(target, itemHandler, itemHandler.getSlots()); + } + + return 0; + } + + public MEInventoryHandler getInternalHandler() { + if (this.cached) { + return this.handler; + } + + final boolean wasSleeping = this.monitor == null; + + this.cached = true; + final TileEntity self = this.getHost().getTile(); + final TileEntity target = self.getWorld().getTileEntity(self.getPos().offset(this.getSide().getFacing())); + final int newHandlerHash = this.createHandlerHash(target); + + if (newHandlerHash != 0 && newHandlerHash == this.handlerHash) { + return this.handler; + } + + this.handlerHash = newHandlerHash; + this.handler = null; + this.monitor = null; + if (target != null) { + IMEInventory inv = this.getInventoryWrapper(target); + + if (inv instanceof MEMonitorIInventory) { + final MEMonitorIInventory h = (MEMonitorIInventory) inv; + h.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER)); + } + + if (inv instanceof ITickingMonitor) { + this.monitor = (ITickingMonitor) inv; + this.monitor.setActionSource(new MachineSource(this)); + } + + if (inv != null) { + this.checkInterfaceVsStorageBus(target, this.getSide().getOpposite()); + + this.handler = new MEInventoryHandler(inv, + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + + this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS)); + this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST + : IncludeExclude.WHITELIST); + this.handler.setPriority(this.priority); + + final IItemList priorityList = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); + + final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9; + for (int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++) { + final IAEItemStack is = this.Config.getAEStackInSlot(x); + if (is != null) { + priorityList.add(is); + } + } + + if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) { + this.handler.setPartitionList(new FuzzyPriorityList(priorityList, + (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE))); + } else { + this.handler.setPartitionList(new PrecisePriorityList(priorityList)); + } + + if (inv instanceof IBaseMonitor) { + ((IBaseMonitor) inv).addListener(this, this.handler); + } + } + } + + // update sleep state... + if (wasSleeping != (this.monitor == null)) { + try { + final ITickManager tm = this.getProxy().getTick(); + if (this.monitor == null) { + tm.sleepDevice(this.getProxy().getNode()); + } else { + tm.wakeDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException e) { + // :( + } + } + + try { + // force grid to update handlers... + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :3 + } + + return this.handler; + } + + private void checkInterfaceVsStorageBus(final TileEntity target, final AEPartLocation side) { + IInterfaceHost achievement = null; + + if (target instanceof IInterfaceHost) { + achievement = (IInterfaceHost) target; + } + + if (target instanceof IPartHost) { + final Object part = ((IPartHost) target).getPart(side); + if (part instanceof IInterfaceHost) { + achievement = (IInterfaceHost) part; + } + } + + if (achievement != null && achievement.getActionableNode() != null) { + // Platform.addStat( achievement.getActionableNode().getPlayerID(), + // Achievements.Recursive.getAchievement() + // ); + // Platform.addStat( getActionableNode().getPlayerID(), + // Achievements.Recursive.getAchievement() ); + } + } + + @Override + public List getCellArray(final IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() : null; + if (out != null) { + return Collections.singletonList(out); + } + } + return Collections.emptyList(); + } + + @Override + public int getPriority() { + return this.priority; + } + + @Override + public void setPriority(final int newValue) { + this.priority = newValue; + this.getHost().markForSave(); + this.resetCache(true); + } + + @Override + public void blinkCell(final int slot) { + } + + // TODO: BC PIPE INTEGRATION + /* + * @Override + * + * @Method( iname = IntegrationType.BuildCraftTransport ) public ConnectOverride + * overridePipeConnection( PipeType type, ForgeDirection with ) { return type == + * PipeType.ITEM && with == this.getSide() ? ConnectOverride.CONNECT : + * ConnectOverride.DISCONNECT; } + */ + @Override + public void saveChanges(final ICellInventory cellInventory) { + // nope! + } + + @Override + public IPartModel getStaticModels() { + if (this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } + + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().parts().storageBus().maybeStack(1).orElse(ItemStack.EMPTY); + } + + @Override + public ContainerType getContainerType() { + return ContainerStorageBus.TYPE; + } } diff --git a/src/main/java/appeng/parts/misc/PartToggleBus.java b/src/main/java/appeng/parts/misc/PartToggleBus.java index b7a8f2551..77f211900 100644 --- a/src/main/java/appeng/parts/misc/PartToggleBus.java +++ b/src/main/java/appeng/parts/misc/PartToggleBus.java @@ -18,7 +18,6 @@ package appeng.parts.misc; - import java.util.EnumSet; import net.minecraft.entity.player.PlayerEntity; @@ -47,183 +46,154 @@ import appeng.me.helpers.AENetworkProxy; import appeng.parts.PartBasicState; import appeng.parts.PartModel; +public class PartToggleBus extends PartBasicState { -public class PartToggleBus extends PartBasicState -{ + @PartModels + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/toggle_bus_base"); + @PartModels + public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/toggle_bus_status_off"); + @PartModels + public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/toggle_bus_status_on"); + @PartModels + public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/toggle_bus_status_has_channel"); - @PartModels - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_base" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_off" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_on" ); - @PartModels - public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_has_channel" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_STATUS_HAS_CHANNEL ); + private static final int REDSTONE_FLAG = 4; + private final AENetworkProxy outerProxy = new AENetworkProxy(this, "outer", ItemStack.EMPTY, true); + private IGridConnection connection; + private boolean hasRedstone = false; - private static final int REDSTONE_FLAG = 4; - private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", ItemStack.EMPTY, true ); - private IGridConnection connection; - private boolean hasRedstone = false; + @Reflected + public PartToggleBus(final ItemStack is) { + super(is); - @Reflected - public PartToggleBus( final ItemStack is ) - { - super( is ); + this.getProxy().setIdlePowerUsage(0.0); + this.getOuterProxy().setIdlePowerUsage(0.0); + this.getProxy().setFlags(); + this.getOuterProxy().setFlags(); + } - this.getProxy().setIdlePowerUsage( 0.0 ); - this.getOuterProxy().setIdlePowerUsage( 0.0 ); - this.getProxy().setFlags(); - this.getOuterProxy().setFlags(); - } + @Override + protected int populateFlags(final int cf) { + return cf | (this.getIntention() ? REDSTONE_FLAG : 0); + } - @Override - protected int populateFlags( final int cf ) - { - return cf | ( this.getIntention() ? REDSTONE_FLAG : 0 ); - } + public boolean hasRedstoneFlag() { + return (this.getClientFlags() & REDSTONE_FLAG) == REDSTONE_FLAG; + } - public boolean hasRedstoneFlag() - { - return ( this.getClientFlags() & REDSTONE_FLAG ) == REDSTONE_FLAG; - } + protected boolean getIntention() { + return this.getHost().hasRedstone(this.getSide()); + } - protected boolean getIntention() - { - return this.getHost().hasRedstone( this.getSide() ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.GLASS; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.GLASS; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(6, 6, 11, 10, 10, 16); + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 6, 6, 11, 10, 10, 16 ); - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + final boolean oldHasRedstone = this.hasRedstone; + this.hasRedstone = this.getHost().hasRedstone(this.getSide()); - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - final boolean oldHasRedstone = this.hasRedstone; - this.hasRedstone = this.getHost().hasRedstone( this.getSide() ); + if (this.hasRedstone != oldHasRedstone) { + this.updateInternalState(); + this.getHost().markForUpdate(); + } + } - if( this.hasRedstone != oldHasRedstone ) - { - this.updateInternalState(); - this.getHost().markForUpdate(); - } - } + @Override + public void readFromNBT(final CompoundNBT extra) { + super.readFromNBT(extra); + this.getOuterProxy().readFromNBT(extra); + } - @Override - public void readFromNBT( final CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.getOuterProxy().readFromNBT( extra ); - } + @Override + public void writeToNBT(final CompoundNBT extra) { + super.writeToNBT(extra); + this.getOuterProxy().writeToNBT(extra); + } - @Override - public void writeToNBT( final CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.getOuterProxy().writeToNBT( extra ); - } + @Override + public void removeFromWorld() { + super.removeFromWorld(); + this.getOuterProxy().remove(); + } - @Override - public void removeFromWorld() - { - super.removeFromWorld(); - this.getOuterProxy().remove(); - } + @Override + public void addToWorld() { + super.addToWorld(); + this.getOuterProxy().onReady(); + this.hasRedstone = this.getHost().hasRedstone(this.getSide()); + this.updateInternalState(); + } - @Override - public void addToWorld() - { - super.addToWorld(); - this.getOuterProxy().onReady(); - this.hasRedstone = this.getHost().hasRedstone( this.getSide() ); - this.updateInternalState(); - } + @Override + public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final TileEntity tile) { + super.setPartHostInfo(side, host, tile); + this.outerProxy.setValidSides(EnumSet.of(side.getFacing())); + } - @Override - public void setPartHostInfo( final AEPartLocation side, final IPartHost host, final TileEntity tile ) - { - super.setPartHostInfo( side, host, tile ); - this.outerProxy.setValidSides( EnumSet.of( side.getFacing() ) ); - } + @Override + public IGridNode getExternalFacingNode() { + return this.getOuterProxy().getNode(); + } - @Override - public IGridNode getExternalFacingNode() - { - return this.getOuterProxy().getNode(); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 5; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 5; - } + @Override + public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { + super.onPlacement(player, hand, held, side); + this.getOuterProxy().setOwner(player); + } - @Override - public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { - super.onPlacement( player, hand, held, side ); - this.getOuterProxy().setOwner( player ); - } + private void updateInternalState() { + final boolean intention = this.getIntention(); + if (intention == (this.connection == null)) { + if (this.getProxy().getNode() != null && this.getOuterProxy().getNode() != null) { + if (intention) { + try { + this.connection = AEApi.instance().grid().createGridConnection(this.getProxy().getNode(), + this.getOuterProxy().getNode()); + } catch (final FailedConnectionException e) { + // :( + AELog.debug(e); + } + } else { + this.connection.destroy(); + this.connection = null; + } + } + } + } - private void updateInternalState() - { - final boolean intention = this.getIntention(); - if( intention == ( this.connection == null ) ) - { - if( this.getProxy().getNode() != null && this.getOuterProxy().getNode() != null ) - { - if( intention ) - { - try - { - this.connection = AEApi.instance().grid().createGridConnection( this.getProxy().getNode(), this.getOuterProxy().getNode() ); - } - catch( final FailedConnectionException e ) - { - // :( - AELog.debug( e ); - } - } - else - { - this.connection.destroy(); - this.connection = null; - } - } - } - } + AENetworkProxy getOuterProxy() { + return this.outerProxy; + } - AENetworkProxy getOuterProxy() - { - return this.outerProxy; - } - - @Override - public IPartModel getStaticModels() - { - if( this.hasRedstoneFlag() && this.isActive() && this.isPowered() ) - { - return MODELS_HAS_CHANNEL; - } - else if( this.hasRedstoneFlag() && this.isPowered() ) - { - return MODELS_ON; - } - else - { - return MODELS_OFF; - } - } + @Override + public IPartModel getStaticModels() { + if (this.hasRedstoneFlag() && this.isActive() && this.isPowered()) { + return MODELS_HAS_CHANNEL; + } else if (this.hasRedstoneFlag() && this.isPowered()) { + return MODELS_ON; + } else { + return MODELS_OFF; + } + } } diff --git a/src/main/java/appeng/parts/networking/PartCable.java b/src/main/java/appeng/parts/networking/PartCable.java index 97fabc3fb..cd01d047b 100644 --- a/src/main/java/appeng/parts/networking/PartCable.java +++ b/src/main/java/appeng/parts/networking/PartCable.java @@ -18,6 +18,14 @@ package appeng.parts.networking; +import java.io.IOException; +import java.util.EnumSet; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Direction; import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; @@ -39,394 +47,309 @@ import appeng.items.parts.ColoredPartItem; import appeng.me.GridAccessException; import appeng.parts.AEBasePart; import appeng.util.Platform; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; -import java.io.IOException; -import java.util.EnumSet; +public class PartCable extends AEBasePart implements IPartCable { + private final int[] channelsOnSide = { 0, 0, 0, 0, 0, 0 }; -public class PartCable extends AEBasePart implements IPartCable -{ + private EnumSet connections = EnumSet.noneOf(AEPartLocation.class); + private boolean powered = false; - private final int[] channelsOnSide = { 0, 0, 0, 0, 0, 0 }; + public PartCable(final ItemStack is) { + super(is); + this.getProxy().setFlags(GridFlags.PREFERRED); + this.getProxy().setIdlePowerUsage(0.0); + if (is.getItem() instanceof ColoredPartItem) { + ColoredPartItem coloredPartItem = (ColoredPartItem) is.getItem(); + this.getProxy().setColor(coloredPartItem.getColor()); + } + } - private EnumSet connections = EnumSet.noneOf( AEPartLocation.class ); - private boolean powered = false; + @Override + public BusSupport supportsBuses() { + return BusSupport.CABLE; + } - public PartCable( final ItemStack is ) - { - super( is ); - this.getProxy().setFlags( GridFlags.PREFERRED ); - this.getProxy().setIdlePowerUsage( 0.0 ); - if (is.getItem() instanceof ColoredPartItem) { - ColoredPartItem coloredPartItem = (ColoredPartItem) is.getItem(); - this.getProxy().setColor(coloredPartItem.getColor()); - } - } + @Override + public AEColor getCableColor() { + return this.getProxy().getColor(); + } - @Override - public BusSupport supportsBuses() - { - return BusSupport.CABLE; - } + @Override + public AECableType getCableConnectionType() { + return AECableType.GLASS; + } - @Override - public AEColor getCableColor() - { - return this.getProxy().getColor(); - } + @Override + public float getCableConnectionLength(AECableType cable) { + if (cable == this.getCableConnectionType()) { + return 4; + } else if (cable.ordinal() >= this.getCableConnectionType().ordinal()) { + return -1; + } else { + return 8; + } + } - @Override - public AECableType getCableConnectionType() - { - return AECableType.GLASS; - } + @Override + public boolean changeColor(final AEColor newColor, final PlayerEntity who) { + if (this.getCableColor() != newColor) { + ItemStack newPart = null; - @Override - public float getCableConnectionLength( AECableType cable ) - { - if( cable == this.getCableConnectionType() ) - { - return 4; - } - else if( cable.ordinal() >= this.getCableConnectionType().ordinal() ) - { - return -1; - } - else - { - return 8; - } - } + final IParts parts = AEApi.instance().definitions().parts(); - @Override - public boolean changeColor( final AEColor newColor, final PlayerEntity who ) - { - if( this.getCableColor() != newColor ) - { - ItemStack newPart = null; + if (this.getCableConnectionType() == AECableType.GLASS) { + newPart = parts.cableGlass().stack(newColor, 1); + } else if (this.getCableConnectionType() == AECableType.COVERED) { + newPart = parts.cableCovered().stack(newColor, 1); + } else if (this.getCableConnectionType() == AECableType.SMART) { + newPart = parts.cableSmart().stack(newColor, 1); + } else if (this.getCableConnectionType() == AECableType.DENSE_COVERED) { + newPart = parts.cableDenseCovered().stack(newColor, 1); + } else if (this.getCableConnectionType() == AECableType.DENSE_SMART) { + newPart = parts.cableDenseSmart().stack(newColor, 1); + } - final IParts parts = AEApi.instance().definitions().parts(); + boolean hasPermission = true; - if( this.getCableConnectionType() == AECableType.GLASS ) - { - newPart = parts.cableGlass().stack( newColor, 1 ); - } - else if( this.getCableConnectionType() == AECableType.COVERED ) - { - newPart = parts.cableCovered().stack( newColor, 1 ); - } - else if( this.getCableConnectionType() == AECableType.SMART ) - { - newPart = parts.cableSmart().stack( newColor, 1 ); - } - else if( this.getCableConnectionType() == AECableType.DENSE_COVERED ) - { - newPart = parts.cableDenseCovered().stack( newColor, 1 ); - } - else if( this.getCableConnectionType() == AECableType.DENSE_SMART ) - { - newPart = parts.cableDenseSmart().stack( newColor, 1 ); - } + try { + hasPermission = this.getProxy().getSecurity().hasPermission(who, SecurityPermissions.BUILD); + } catch (final GridAccessException e) { + // :P + } - boolean hasPermission = true; + if (newPart != null && hasPermission) { + if (Platform.isClient()) { + return true; + } - try - { - hasPermission = this.getProxy().getSecurity().hasPermission( who, SecurityPermissions.BUILD ); - } - catch( final GridAccessException e ) - { - // :P - } + this.getHost().removePart(AEPartLocation.INTERNAL, true); + this.getHost().addPart(newPart, AEPartLocation.INTERNAL, who, null); + return true; + } + } + return false; + } - if( newPart != null && hasPermission ) - { - if( Platform.isClient() ) - { - return true; - } + @Override + public void setValidSides(final EnumSet sides) { + this.getProxy().setValidSides(sides); + } - this.getHost().removePart( AEPartLocation.INTERNAL, true ); - this.getHost().addPart( newPart, AEPartLocation.INTERNAL, who, null ); - return true; - } - } - return false; - } + @Override + public boolean isConnected(final Direction side) { + return this.getConnections().contains(AEPartLocation.fromFacing(side)); + } - @Override - public void setValidSides( final EnumSet sides ) - { - this.getProxy().setValidSides( sides ); - } + public void markForUpdate() { + this.getHost().markForUpdate(); + } - @Override - public boolean isConnected( final Direction side ) - { - return this.getConnections().contains( AEPartLocation.fromFacing( side ) ); - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(6.0, 6.0, 6.0, 10.0, 10.0, 10.0); - public void markForUpdate() - { - this.getHost().markForUpdate(); - } + if (Platform.isServer()) { + final IGridNode n = this.getGridNode(); + if (n != null) { + this.setConnections(n.getConnectedSides()); + } else { + this.getConnections().clear(); + } + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 ); + final IPartHost ph = this.getHost(); + if (ph != null) { + for (final AEPartLocation dir : AEPartLocation.SIDE_LOCATIONS) { + final IPart p = ph.getPart(dir); + if (p instanceof IGridHost) { + final double dist = p.getCableConnectionLength(this.getCableConnectionType()); - if( Platform.isServer() ) - { - final IGridNode n = this.getGridNode(); - if( n != null ) - { - this.setConnections( n.getConnectedSides() ); - } - else - { - this.getConnections().clear(); - } - } + if (dist > 8) { + continue; + } - final IPartHost ph = this.getHost(); - if( ph != null ) - { - for( final AEPartLocation dir : AEPartLocation.SIDE_LOCATIONS ) - { - final IPart p = ph.getPart( dir ); - if( p instanceof IGridHost ) - { - final double dist = p.getCableConnectionLength( this.getCableConnectionType() ); + switch (dir) { + case DOWN: + bch.addBox(6.0, dist, 6.0, 10.0, 6.0, 10.0); + break; + case EAST: + bch.addBox(10.0, 6.0, 6.0, 16.0 - dist, 10.0, 10.0); + break; + case NORTH: + bch.addBox(6.0, 6.0, dist, 10.0, 10.0, 6.0); + break; + case SOUTH: + bch.addBox(6.0, 6.0, 10.0, 10.0, 10.0, 16.0 - dist); + break; + case UP: + bch.addBox(6.0, 10.0, 6.0, 10.0, 16.0 - dist, 10.0); + break; + case WEST: + bch.addBox(dist, 6.0, 6.0, 6.0, 10.0, 10.0); + break; + default: + } + } + } + } - if( dist > 8 ) - { - continue; - } + for (final AEPartLocation of : this.getConnections()) { + switch (of) { + case DOWN: + bch.addBox(6.0, 0.0, 6.0, 10.0, 6.0, 10.0); + break; + case EAST: + bch.addBox(10.0, 6.0, 6.0, 16.0, 10.0, 10.0); + break; + case NORTH: + bch.addBox(6.0, 6.0, 0.0, 10.0, 10.0, 6.0); + break; + case SOUTH: + bch.addBox(6.0, 6.0, 10.0, 10.0, 10.0, 16.0); + break; + case UP: + bch.addBox(6.0, 10.0, 6.0, 10.0, 16.0, 10.0); + break; + case WEST: + bch.addBox(0.0, 6.0, 6.0, 6.0, 10.0, 10.0); + break; + default: + } + } + } - switch( dir ) - { - case DOWN: - bch.addBox( 6.0, dist, 6.0, 10.0, 6.0, 10.0 ); - break; - case EAST: - bch.addBox( 10.0, 6.0, 6.0, 16.0 - dist, 10.0, 10.0 ); - break; - case NORTH: - bch.addBox( 6.0, 6.0, dist, 10.0, 10.0, 6.0 ); - break; - case SOUTH: - bch.addBox( 6.0, 6.0, 10.0, 10.0, 10.0, 16.0 - dist ); - break; - case UP: - bch.addBox( 6.0, 10.0, 6.0, 10.0, 16.0 - dist, 10.0 ); - break; - case WEST: - bch.addBox( dist, 6.0, 6.0, 6.0, 10.0, 10.0 ); - break; - default: - } - } - } - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); - for( final AEPartLocation of : this.getConnections() ) - { - switch( of ) - { - case DOWN: - bch.addBox( 6.0, 0.0, 6.0, 10.0, 6.0, 10.0 ); - break; - case EAST: - bch.addBox( 10.0, 6.0, 6.0, 16.0, 10.0, 10.0 ); - break; - case NORTH: - bch.addBox( 6.0, 6.0, 0.0, 10.0, 10.0, 6.0 ); - break; - case SOUTH: - bch.addBox( 6.0, 6.0, 10.0, 10.0, 10.0, 16.0 ); - break; - case UP: - bch.addBox( 6.0, 10.0, 6.0, 10.0, 16.0, 10.0 ); - break; - case WEST: - bch.addBox( 0.0, 6.0, 6.0, 6.0, 10.0, 10.0 ); - break; - default: - } - } - } + if (Platform.isServer()) { + final IGridNode node = this.getGridNode(); - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); + if (node != null) { + int howMany = 0; + for (final IGridConnection gc : node.getConnections()) { + howMany = Math.max(gc.getUsedChannels(), howMany); + } - if( Platform.isServer() ) - { - final IGridNode node = this.getGridNode(); + data.putByte("usedChannels", (byte) howMany); + } + } + } - if( node != null ) - { - int howMany = 0; - for( final IGridConnection gc : node.getConnections() ) - { - howMany = Math.max( gc.getUsedChannels(), howMany ); - } + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + int flags = 0; + boolean[] writeSide = new boolean[Direction.values().length]; + int[] channelsPerSide = new int[Direction.values().length]; - data.putByte( "usedChannels", (byte) howMany ); - } - } - } + for (Direction thisSide : Direction.values()) { + final IPart part = this.getHost().getPart(thisSide); + if (part != null) { + writeSide[thisSide.ordinal()] = true; + int channels = 0; + if (part.getGridNode() != null) { + final IReadOnlyCollection set = part.getGridNode().getConnections(); + for (final IGridConnection gc : set) { + channels = Math.max(channels, gc.getUsedChannels()); + } + } + channelsPerSide[thisSide.ordinal()] = channels; + } + } - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - int flags = 0; - boolean[] writeSide = new boolean[Direction.values().length]; - int[] channelsPerSide = new int[Direction.values().length]; + IGridNode n = this.getGridNode(); + if (n != null) { + for (final IGridConnection gc : n.getConnections()) { + final AEPartLocation side = gc.getDirection(n); + if (side != AEPartLocation.INTERNAL) { + writeSide[side.ordinal()] = true; + channelsPerSide[side.ordinal()] = gc.getUsedChannels(); + flags |= (1 << side.ordinal()); + } + } + } - for( Direction thisSide : Direction.values() ) - { - final IPart part = this.getHost().getPart( thisSide ); - if( part != null ) - { - writeSide[thisSide.ordinal()] = true; - int channels = 0; - if( part.getGridNode() != null ) - { - final IReadOnlyCollection set = part.getGridNode().getConnections(); - for( final IGridConnection gc : set ) - { - channels = Math.max( channels, gc.getUsedChannels() ); - } - } - channelsPerSide[thisSide.ordinal()] = channels; - } - } + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + flags |= (1 << AEPartLocation.INTERNAL.ordinal()); + } + } catch (final GridAccessException e) { + // aww... + } - IGridNode n = this.getGridNode(); - if( n != null ) - { - for( final IGridConnection gc : n.getConnections() ) - { - final AEPartLocation side = gc.getDirection( n ); - if( side != AEPartLocation.INTERNAL ) - { - writeSide[side.ordinal()] = true; - channelsPerSide[side.ordinal()] = gc.getUsedChannels(); - flags |= ( 1 << side.ordinal() ); - } - } - } + data.writeByte((byte) flags); + // Only write the used channels for sides where we have a part or another cable + for (int i = 0; i < writeSide.length; i++) { + if (writeSide[i]) { + data.writeByte(channelsPerSide[i]); + } + } + } - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - flags |= ( 1 << AEPartLocation.INTERNAL.ordinal() ); - } - } - catch( final GridAccessException e ) - { - // aww... - } + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + int cs = data.readByte(); + final EnumSet myC = this.getConnections().clone(); + final boolean wasPowered = this.powered; + this.powered = false; + boolean channelsChanged = false; - data.writeByte( (byte) flags ); - // Only write the used channels for sides where we have a part or another cable - for( int i = 0; i < writeSide.length; i++ ) - { - if( writeSide[i] ) - { - data.writeByte( channelsPerSide[i] ); - } - } - } + for (final AEPartLocation d : AEPartLocation.values()) { + if (d == AEPartLocation.INTERNAL) { + final int id = 1 << d.ordinal(); + if (id == (cs & id)) { + this.powered = true; + } + } else { + boolean conOnSide = (cs & (1 << d.ordinal())) != 0; + if (conOnSide) { + this.getConnections().add(d); + } else { + this.getConnections().remove(d); + } - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - int cs = data.readByte(); - final EnumSet myC = this.getConnections().clone(); - final boolean wasPowered = this.powered; - this.powered = false; - boolean channelsChanged = false; + int ch = 0; - for( final AEPartLocation d : AEPartLocation.values() ) - { - if( d == AEPartLocation.INTERNAL ) - { - final int id = 1 << d.ordinal(); - if( id == ( cs & id ) ) - { - this.powered = true; - } - } - else - { - boolean conOnSide = ( cs & ( 1 << d.ordinal() ) ) != 0; - if( conOnSide ) - { - this.getConnections().add( d ); - } - else - { - this.getConnections().remove( d ); - } + // Only read channels if there's a part on this side or a cable connection + // This works only because cables are always read *last* from the packet update + // for + // a cable bus + if (conOnSide || this.getHost().getPart(d) != null) { + ch = (data.readByte()) & 0xFF; + } - int ch = 0; + if (ch != this.getChannelsOnSide(d.ordinal())) { + channelsChanged = true; + this.setChannelsOnSide(d.ordinal(), ch); + } + } + } - // Only read channels if there's a part on this side or a cable connection - // This works only because cables are always read *last* from the packet update for - // a cable bus - if( conOnSide || this.getHost().getPart( d ) != null ) - { - ch = ( data.readByte() ) & 0xFF; - } + return !myC.equals(this.getConnections()) || wasPowered != this.powered || channelsChanged; + } - if( ch != this.getChannelsOnSide( d.ordinal() ) ) - { - channelsChanged = true; - this.setChannelsOnSide( d.ordinal(), ch ); - } - } - } + int getChannelsOnSide(final int i) { + return this.channelsOnSide[i]; + } - return !myC.equals( this.getConnections() ) || wasPowered != this.powered || channelsChanged; - } + public int getChannelsOnSide(Direction side) { + if (!this.powered) { + return 0; + } + return this.channelsOnSide[side.ordinal()]; + } - int getChannelsOnSide( final int i ) - { - return this.channelsOnSide[i]; - } + void setChannelsOnSide(final int i, final int channels) { + this.channelsOnSide[i] = channels; + } - public int getChannelsOnSide( Direction side ) - { - if( !this.powered ) - { - return 0; - } - return this.channelsOnSide[side.ordinal()]; - } + EnumSet getConnections() { + return this.connections; + } - void setChannelsOnSide( final int i, final int channels ) - { - this.channelsOnSide[i] = channels; - } - - EnumSet getConnections() - { - return this.connections; - } - - void setConnections( final EnumSet connections ) - { - this.connections = connections; - } + void setConnections(final EnumSet connections) { + this.connections = connections; + } } diff --git a/src/main/java/appeng/parts/networking/PartCableCovered.java b/src/main/java/appeng/parts/networking/PartCableCovered.java index ef9957f5b..5377f6263 100644 --- a/src/main/java/appeng/parts/networking/PartCableCovered.java +++ b/src/main/java/appeng/parts/networking/PartCableCovered.java @@ -18,7 +18,6 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import appeng.api.networking.IGridNode; @@ -31,75 +30,62 @@ import appeng.api.util.AEPartLocation; import appeng.helpers.Reflected; import appeng.util.Platform; +public class PartCableCovered extends PartCable { + @Reflected + public PartCableCovered(final ItemStack is) { + super(is); + } -public class PartCableCovered extends PartCable -{ - @Reflected - public PartCableCovered( final ItemStack is ) - { - super( is ); - } + @MENetworkEventSubscribe + public void channelUpdated(final MENetworkChannelsChanged c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void channelUpdated( final MENetworkChannelsChanged c ) - { - this.getHost().markForUpdate(); - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.getHost().markForUpdate(); - } + @Override + public AECableType getCableConnectionType() { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType() - { - return AECableType.COVERED; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(5.0, 5.0, 5.0, 11.0, 11.0, 11.0); - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 ); + if (Platform.isServer()) { + final IGridNode n = this.getGridNode(); + if (n != null) { + this.setConnections(n.getConnectedSides()); + } else { + this.getConnections().clear(); + } + } - if( Platform.isServer() ) - { - final IGridNode n = this.getGridNode(); - if( n != null ) - { - this.setConnections( n.getConnectedSides() ); - } - else - { - this.getConnections().clear(); - } - } - - for( final AEPartLocation of : this.getConnections() ) - { - 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: - } - } - } + for (final AEPartLocation of : this.getConnections()) { + 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: + } + } + } } diff --git a/src/main/java/appeng/parts/networking/PartCableGlass.java b/src/main/java/appeng/parts/networking/PartCableGlass.java index 4c9525e5f..946381709 100644 --- a/src/main/java/appeng/parts/networking/PartCableGlass.java +++ b/src/main/java/appeng/parts/networking/PartCableGlass.java @@ -18,17 +18,13 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import appeng.helpers.Reflected; - -public class PartCableGlass extends PartCable -{ - @Reflected - public PartCableGlass( final ItemStack is ) - { - super( is ); - } +public class PartCableGlass extends PartCable { + @Reflected + public PartCableGlass(final ItemStack is) { + super(is); + } } diff --git a/src/main/java/appeng/parts/networking/PartCableSmart.java b/src/main/java/appeng/parts/networking/PartCableSmart.java index 5997cc59f..f023b9fdd 100644 --- a/src/main/java/appeng/parts/networking/PartCableSmart.java +++ b/src/main/java/appeng/parts/networking/PartCableSmart.java @@ -18,7 +18,6 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import appeng.api.networking.IGridNode; @@ -31,75 +30,62 @@ import appeng.api.util.AEPartLocation; import appeng.helpers.Reflected; import appeng.util.Platform; +public class PartCableSmart extends PartCable { + @Reflected + public PartCableSmart(final ItemStack is) { + super(is); + } -public class PartCableSmart extends PartCable -{ - @Reflected - public PartCableSmart( final ItemStack is ) - { - super( is ); - } + @MENetworkEventSubscribe + public void channelUpdated(final MENetworkChannelsChanged c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void channelUpdated( final MENetworkChannelsChanged c ) - { - this.getHost().markForUpdate(); - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.getHost().markForUpdate(); - } + @Override + public AECableType getCableConnectionType() { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType() - { - return AECableType.SMART; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(5.0, 5.0, 5.0, 11.0, 11.0, 11.0); - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 ); + if (Platform.isServer()) { + final IGridNode n = this.getGridNode(); + if (n != null) { + this.setConnections(n.getConnectedSides()); + } else { + this.getConnections().clear(); + } + } - if( Platform.isServer() ) - { - final IGridNode n = this.getGridNode(); - if( n != null ) - { - this.setConnections( n.getConnectedSides() ); - } - else - { - this.getConnections().clear(); - } - } - - for( final AEPartLocation of : this.getConnections() ) - { - 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: - } - } - } + for (final AEPartLocation of : this.getConnections()) { + 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: + } + } + } } diff --git a/src/main/java/appeng/parts/networking/PartDenseCable.java b/src/main/java/appeng/parts/networking/PartDenseCable.java index bc7532083..3d801e4dc 100644 --- a/src/main/java/appeng/parts/networking/PartDenseCable.java +++ b/src/main/java/appeng/parts/networking/PartDenseCable.java @@ -18,7 +18,6 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -35,122 +34,103 @@ import appeng.api.util.AEPartLocation; import appeng.helpers.Reflected; import appeng.util.Platform; +public abstract class PartDenseCable extends PartCable { + @Reflected + public PartDenseCable(final ItemStack is) { + super(is); -public abstract class PartDenseCable extends PartCable -{ - @Reflected - public PartDenseCable( final ItemStack is ) - { - super( is ); + this.getProxy().setFlags(GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED); + } - this.getProxy().setFlags( GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED ); - } + @Override + public BusSupport supportsBuses() { + return BusSupport.DENSE_CABLE; + } - @Override - public BusSupport supportsBuses() - { - return BusSupport.DENSE_CABLE; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + final boolean noLadder = !bch.isBBCollision(); + final double min = noLadder ? 3.0 : 4.9; + final double max = noLadder ? 13.0 : 11.1; - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - final boolean noLadder = !bch.isBBCollision(); - final double min = noLadder ? 3.0 : 4.9; - final double max = noLadder ? 13.0 : 11.1; + bch.addBox(min, min, min, max, max, max); - bch.addBox( min, min, min, max, max, max ); + if (Platform.isServer()) { + final IGridNode n = this.getGridNode(); + if (n != null) { + this.setConnections(n.getConnectedSides()); + } else { + this.getConnections().clear(); + } + } - if( Platform.isServer() ) - { - final IGridNode n = this.getGridNode(); - if( n != null ) - { - this.setConnections( n.getConnectedSides() ); - } - else - { - this.getConnections().clear(); - } - } + for (final AEPartLocation of : this.getConnections()) { + if (this.isDense(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: + } + } else { + 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: + } + } + } + } - for( final AEPartLocation of : this.getConnections() ) - { - if( this.isDense( 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: - } - } - else - { - 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: - } - } - } - } + private boolean isDense(final AEPartLocation of) { + final TileEntity te = this.getTile().getWorld().getTileEntity(this.getTile().getPos().offset(of.getFacing())); - private boolean isDense( final AEPartLocation of ) - { - final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( of.getFacing() ) ); + if (te instanceof IGridHost) { + final AECableType t = ((IGridHost) te).getCableConnectionType(of.getOpposite()); + return t.isDense(); + } - if( te instanceof IGridHost ) - { - final AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() ); - return t.isDense(); - } + return false; + } - return false; - } + @MENetworkEventSubscribe + public void channelUpdated(final MENetworkChannelsChanged c) { + this.getHost().markForUpdate(); + } - @MENetworkEventSubscribe - public void channelUpdated( final MENetworkChannelsChanged c ) - { - this.getHost().markForUpdate(); - } - - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.getHost().markForUpdate(); - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.getHost().markForUpdate(); + } } diff --git a/src/main/java/appeng/parts/networking/PartDenseCableCovered.java b/src/main/java/appeng/parts/networking/PartDenseCableCovered.java index 1d569e13a..ceae8abcf 100644 --- a/src/main/java/appeng/parts/networking/PartDenseCableCovered.java +++ b/src/main/java/appeng/parts/networking/PartDenseCableCovered.java @@ -18,24 +18,19 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import appeng.api.util.AECableType; +public class PartDenseCableCovered extends PartDenseCable { -public class PartDenseCableCovered extends PartDenseCable -{ + public PartDenseCableCovered(ItemStack is) { + super(is); + } - public PartDenseCableCovered( ItemStack is ) - { - super( is ); - } - - @Override - public AECableType getCableConnectionType() - { - return AECableType.DENSE_COVERED; - } + @Override + public AECableType getCableConnectionType() { + return AECableType.DENSE_COVERED; + } } diff --git a/src/main/java/appeng/parts/networking/PartDenseCableSmart.java b/src/main/java/appeng/parts/networking/PartDenseCableSmart.java index fbb0fa944..893408632 100644 --- a/src/main/java/appeng/parts/networking/PartDenseCableSmart.java +++ b/src/main/java/appeng/parts/networking/PartDenseCableSmart.java @@ -18,23 +18,18 @@ package appeng.parts.networking; - import net.minecraft.item.ItemStack; import appeng.api.util.AECableType; +public class PartDenseCableSmart extends PartDenseCable { -public class PartDenseCableSmart extends PartDenseCable -{ + public PartDenseCableSmart(ItemStack is) { + super(is); + } - public PartDenseCableSmart( ItemStack is ) - { - super( is ); - } - - @Override - public AECableType getCableConnectionType() - { - return AECableType.DENSE_SMART; - } + @Override + public AECableType getCableConnectionType() { + return AECableType.DENSE_SMART; + } } diff --git a/src/main/java/appeng/parts/networking/PartQuartzFiber.java b/src/main/java/appeng/parts/networking/PartQuartzFiber.java index bcc2d11ee..d116591da 100644 --- a/src/main/java/appeng/parts/networking/PartQuartzFiber.java +++ b/src/main/java/appeng/parts/networking/PartQuartzFiber.java @@ -18,7 +18,6 @@ package appeng.parts.networking; - import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; @@ -47,153 +46,129 @@ import appeng.me.helpers.AENetworkProxy; import appeng.parts.AEBasePart; import appeng.parts.PartModel; +public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider { -public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider -{ + @PartModels + private static final IPartModel MODELS = new PartModel(new ResourceLocation(AppEng.MOD_ID, "part/quartz_fiber")); - @PartModels - private static final IPartModel MODELS = new PartModel( new ResourceLocation( AppEng.MOD_ID, "part/quartz_fiber" ) ); + private final AENetworkProxy outerProxy = new AENetworkProxy(this, "outer", + this.getProxy().getMachineRepresentation(), true); - private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", this.getProxy().getMachineRepresentation(), true ); + public PartQuartzFiber(final ItemStack is) { + super(is); + this.getProxy().setIdlePowerUsage(0); + this.getProxy().setFlags(GridFlags.CANNOT_CARRY); + this.outerProxy.setIdlePowerUsage(0); + this.outerProxy.setFlags(GridFlags.CANNOT_CARRY); + } - public PartQuartzFiber( final ItemStack is ) - { - super( is ); - this.getProxy().setIdlePowerUsage( 0 ); - this.getProxy().setFlags( GridFlags.CANNOT_CARRY ); - this.outerProxy.setIdlePowerUsage( 0 ); - this.outerProxy.setFlags( GridFlags.CANNOT_CARRY ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.GLASS; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.GLASS; - } + @Override + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(6, 6, 10, 10, 10, 16); + } - @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 6, 6, 10, 10, 10, 16 ); - } + @Override + public void readFromNBT(final CompoundNBT extra) { + super.readFromNBT(extra); + this.outerProxy.readFromNBT(extra); + } - @Override - public void readFromNBT( final CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.outerProxy.readFromNBT( extra ); - } + @Override + public void writeToNBT(final CompoundNBT extra) { + super.writeToNBT(extra); + this.outerProxy.writeToNBT(extra); + } - @Override - public void writeToNBT( final CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.outerProxy.writeToNBT( extra ); - } + @Override + public void removeFromWorld() { + super.removeFromWorld(); + this.outerProxy.remove(); + } - @Override - public void removeFromWorld() - { - super.removeFromWorld(); - this.outerProxy.remove(); - } + @Override + public void addToWorld() { + super.addToWorld(); + this.outerProxy.onReady(); + } - @Override - public void addToWorld() - { - super.addToWorld(); - this.outerProxy.onReady(); - } + @Override + public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final TileEntity tile) { + super.setPartHostInfo(side, host, tile); + this.outerProxy.setValidSides(EnumSet.of(side.getFacing())); + } - @Override - public void setPartHostInfo( final AEPartLocation side, final IPartHost host, final TileEntity tile ) - { - super.setPartHostInfo( side, host, tile ); - this.outerProxy.setValidSides( EnumSet.of( side.getFacing() ) ); - } + @Override + public IGridNode getExternalFacingNode() { + return this.outerProxy.getNode(); + } - @Override - public IGridNode getExternalFacingNode() - { - return this.outerProxy.getNode(); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return 16; + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 16; - } + @Override + public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { + super.onPlacement(player, hand, held, side); + this.outerProxy.setOwner(player); + } - @Override - public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { - super.onPlacement( player, hand, held, side ); - this.outerProxy.setOwner( player ); - } + @Override + public Collection providers() { + Collection providers = new ArrayList<>(); - @Override - public Collection providers() - { - Collection providers = new ArrayList<>(); + try { + final IEnergyGrid eg = this.getProxy().getEnergy(); - try - { - final IEnergyGrid eg = this.getProxy().getEnergy(); + providers.add(eg); + } catch (final GridAccessException e) { + // :P + } - providers.add( eg ); - } - catch( final GridAccessException e ) - { - // :P - } + try { + final IEnergyGrid eg = this.outerProxy.getEnergy(); - try - { - final IEnergyGrid eg = this.outerProxy.getEnergy(); + providers.add(eg); + } catch (final GridAccessException e) { + // :P + } - providers.add( eg ); - } - catch( final GridAccessException e ) - { - // :P - } + return providers; + } - return providers; - } + @Override + public double extractProviderPower(final double amt, final Actionable mode) { + return 0; + } - @Override - public double extractProviderPower( final double amt, final Actionable mode ) - { - return 0; - } + @Override + public double injectProviderPower(final double amt, final Actionable mode) { + return amt; + } - @Override - public double injectProviderPower( final double amt, final Actionable mode ) - { - return amt; - } + @Override + public double getProviderEnergyDemand(final double amt) { + return 0; + } - @Override - public double getProviderEnergyDemand( final double amt ) - { - return 0; - } + @Override + public double getProviderStoredEnergy() { + return 0; + } - @Override - public double getProviderStoredEnergy() - { - return 0; - } + @Override + public double getProviderMaxEnergy() { + return 0; + } - @Override - public double getProviderMaxEnergy() - { - return 0; - } - - @Override - public IPartModel getStaticModels() - { - return MODELS; - } + @Override + public IPartModel getStaticModels() { + return MODELS; + } } diff --git a/src/main/java/appeng/parts/p2p/P2PModels.java b/src/main/java/appeng/parts/p2p/P2PModels.java index 24eb1183d..362920d5e 100644 --- a/src/main/java/appeng/parts/p2p/P2PModels.java +++ b/src/main/java/appeng/parts/p2p/P2PModels.java @@ -18,7 +18,6 @@ package appeng.parts.p2p; - import java.util.ArrayList; import java.util.List; @@ -28,54 +27,48 @@ import appeng.api.parts.IPartModel; import appeng.core.AppEng; import appeng.parts.PartModel; - /** * Helper for maintaining the models used for a variant of the P2P bus. */ -class P2PModels -{ +class P2PModels { - public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_off" ); - public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_on" ); - public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_has_channel" ); - public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_frequency" ); + public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/p2p/p2p_tunnel_status_off"); + public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/p2p/p2p_tunnel_status_on"); + public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/p2p/p2p_tunnel_status_has_channel"); + public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation(AppEng.MOD_ID, + "part/p2p/p2p_tunnel_frequency"); - private final IPartModel modelsOff; - private final IPartModel modelsOn; - private final IPartModel modelsHasChannel; + private final IPartModel modelsOff; + private final IPartModel modelsOn; + private final IPartModel modelsHasChannel; - public P2PModels( String frontModelPath ) - { - ResourceLocation frontModel = new ResourceLocation( AppEng.MOD_ID, frontModelPath ); + public P2PModels(String frontModelPath) { + ResourceLocation frontModel = new ResourceLocation(AppEng.MOD_ID, frontModelPath); - this.modelsOff = new PartModel( MODEL_STATUS_OFF, MODEL_FREQUENCY, frontModel ); - this.modelsOn = new PartModel( MODEL_STATUS_ON, MODEL_FREQUENCY, frontModel ); - this.modelsHasChannel = new PartModel( MODEL_STATUS_HAS_CHANNEL, MODEL_FREQUENCY, frontModel ); - } + this.modelsOff = new PartModel(MODEL_STATUS_OFF, MODEL_FREQUENCY, frontModel); + this.modelsOn = new PartModel(MODEL_STATUS_ON, MODEL_FREQUENCY, frontModel); + this.modelsHasChannel = new PartModel(MODEL_STATUS_HAS_CHANNEL, MODEL_FREQUENCY, frontModel); + } - public IPartModel getModel( boolean hasPower, boolean hasChannel ) - { - if( hasPower && hasChannel ) - { - return this.modelsHasChannel; - } - else if( hasPower ) - { - return this.modelsOn; - } - else - { - return this.modelsOff; - } - } + public IPartModel getModel(boolean hasPower, boolean hasChannel) { + if (hasPower && hasChannel) { + return this.modelsHasChannel; + } else if (hasPower) { + return this.modelsOn; + } else { + return this.modelsOff; + } + } - public List getModels() - { - List result = new ArrayList<>(); - result.add( this.modelsOff ); - result.add( this.modelsOn ); - result.add( this.modelsHasChannel ); - return result; - } + public List getModels() { + List result = new ArrayList<>(); + result.add(this.modelsOff); + result.add(this.modelsOn); + result.add(this.modelsHasChannel); + return result; + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PFEPower.java b/src/main/java/appeng/parts/p2p/PartP2PFEPower.java index 8579ea07c..7f060ed46 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PFEPower.java +++ b/src/main/java/appeng/parts/p2p/PartP2PFEPower.java @@ -18,8 +18,8 @@ package appeng.parts.p2p; - import java.util.List; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -35,254 +35,205 @@ import appeng.capabilities.Capabilities; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; +public class PartP2PFEPower extends PartP2PTunnel { + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_fe"); + private static final IEnergyStorage NULL_ENERGY_STORAGE = new NullEnergyStorage(); + private final IEnergyStorage inputHandler = new InputEnergyStorage(); + private final IEnergyStorage outputHandler = new OutputEnergyStorage(); -public class PartP2PFEPower extends PartP2PTunnel -{ - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_fe" ); - private static final IEnergyStorage NULL_ENERGY_STORAGE = new NullEnergyStorage(); - private final IEnergyStorage inputHandler = new InputEnergyStorage(); - private final IEnergyStorage outputHandler = new OutputEnergyStorage(); + public PartP2PFEPower(ItemStack is) { + super(is); + } - public PartP2PFEPower( ItemStack is ) - { - super( is ); - } + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public void onTunnelNetworkChange() { + this.getHost().notifyNeighbors(); + } - @Override - public void onTunnelNetworkChange() - { - this.getHost().notifyNeighbors(); - } + private IEnergyStorage getAttachedEnergyStorage() { + LazyOptional energyStorageOpt = LazyOptional.empty(); + if (this.isActive()) { + final TileEntity self = this.getTile(); + final TileEntity te = self.getWorld().getTileEntity(self.getPos().offset(this.getSide().getFacing())); - private IEnergyStorage getAttachedEnergyStorage() - { - LazyOptional energyStorageOpt = LazyOptional.empty(); - if( this.isActive() ) - { - final TileEntity self = this.getTile(); - final TileEntity te = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) ); + if (te != null) { + energyStorageOpt = te.getCapability(Capabilities.FORGE_ENERGY, + this.getSide().getOpposite().getFacing()); + } + } + return energyStorageOpt.orElse(NULL_ENERGY_STORAGE); + } - if( te != null ) - { - energyStorageOpt = te.getCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() ); - } - } - return energyStorageOpt.orElse( NULL_ENERGY_STORAGE ); - } + @SuppressWarnings("unchecked") + @Nullable + @Override + public LazyOptional getCapability(@Nonnull Capability capability) { + if (capability == Capabilities.FORGE_ENERGY) { + if (this.isOutput()) { + return (LazyOptional) LazyOptional.of(() -> this.outputHandler); + } + return (LazyOptional) LazyOptional.of(() -> this.inputHandler); + } + return super.getCapability(capability); + } - @SuppressWarnings("unchecked") - @Nullable - @Override - public LazyOptional getCapability( @Nonnull Capability capability ) - { - if( capability == Capabilities.FORGE_ENERGY ) - { - if( this.isOutput() ) - { - return (LazyOptional) LazyOptional.of(() -> this.outputHandler); - } - return (LazyOptional) LazyOptional.of(() ->this.inputHandler); - } - return super.getCapability( capability ); - } + private class InputEnergyStorage implements IEnergyStorage { + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } - private class InputEnergyStorage implements IEnergyStorage - { - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - return 0; - } + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + int total = 0; - @Override - public int receiveEnergy( int maxReceive, boolean simulate ) - { - int total = 0; + try { + final int outputTunnels = PartP2PFEPower.this.getOutputs().size(); - try - { - final int outputTunnels = PartP2PFEPower.this.getOutputs().size(); + if (outputTunnels == 0 | maxReceive == 0) { + return 0; + } - if( outputTunnels == 0 | maxReceive == 0 ) - { - return 0; - } + final int amountPerOutput = maxReceive / outputTunnels; + int overflow = amountPerOutput == 0 ? maxReceive : maxReceive % amountPerOutput; - final int amountPerOutput = maxReceive / outputTunnels; - int overflow = amountPerOutput == 0 ? maxReceive : maxReceive % amountPerOutput; + for (PartP2PFEPower target : PartP2PFEPower.this.getOutputs()) { + final IEnergyStorage output = target.getAttachedEnergyStorage(); + final int toSend = amountPerOutput + overflow; + final int received = output.receiveEnergy(toSend, simulate); - for( PartP2PFEPower target : PartP2PFEPower.this.getOutputs() ) - { - final IEnergyStorage output = target.getAttachedEnergyStorage(); - final int toSend = amountPerOutput + overflow; - final int received = output.receiveEnergy( toSend, simulate ); + overflow = toSend - received; + total += received; + } - overflow = toSend - received; - total += received; - } + if (!simulate) { + PartP2PFEPower.this.queueTunnelDrain(PowerUnits.RF, total); + } + } catch (GridAccessException ignored) { + } - if( !simulate ) - { - PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total ); - } - } - catch( GridAccessException ignored ) - { - } + return total; + } - return total; - } + @Override + public boolean canExtract() { + return false; + } - @Override - public boolean canExtract() - { - return false; - } + @Override + public boolean canReceive() { + return true; + } - @Override - public boolean canReceive() - { - return true; - } + @Override + public int getMaxEnergyStored() { + int total = 0; - @Override - public int getMaxEnergyStored() - { - int total = 0; + try { + for (PartP2PFEPower t : PartP2PFEPower.this.getOutputs()) { + total += t.getAttachedEnergyStorage().getMaxEnergyStored(); + } + } catch (GridAccessException e) { + return 0; + } - try - { - for( PartP2PFEPower t : PartP2PFEPower.this.getOutputs() ) - { - total += t.getAttachedEnergyStorage().getMaxEnergyStored(); - } - } - catch( GridAccessException e ) - { - return 0; - } + return total; + } - return total; - } + @Override + public int getEnergyStored() { + int total = 0; - @Override - public int getEnergyStored() - { - int total = 0; + try { + for (PartP2PFEPower t : PartP2PFEPower.this.getOutputs()) { + total += t.getAttachedEnergyStorage().getEnergyStored(); + } + } catch (GridAccessException e) { + return 0; + } - try - { - for( PartP2PFEPower t : PartP2PFEPower.this.getOutputs() ) - { - total += t.getAttachedEnergyStorage().getEnergyStored(); - } - } - catch( GridAccessException e ) - { - return 0; - } + return total; + } + } - return total; - } - } + private class OutputEnergyStorage implements IEnergyStorage { + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + final int total = PartP2PFEPower.this.getAttachedEnergyStorage().extractEnergy(maxExtract, simulate); + if (!simulate) { + PartP2PFEPower.this.queueTunnelDrain(PowerUnits.RF, total); + } - private class OutputEnergyStorage implements IEnergyStorage - { - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - final int total = PartP2PFEPower.this.getAttachedEnergyStorage().extractEnergy( maxExtract, simulate ); + return total; + } - if( !simulate ) - { - PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total ); - } + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + return 0; + } - return total; - } + @Override + public boolean canExtract() { + return PartP2PFEPower.this.getAttachedEnergyStorage().canExtract(); + } - @Override - public int receiveEnergy( int maxReceive, boolean simulate ) - { - return 0; - } + @Override + public boolean canReceive() { + return false; + } - @Override - public boolean canExtract() - { - return PartP2PFEPower.this.getAttachedEnergyStorage().canExtract(); - } + @Override + public int getMaxEnergyStored() { + return PartP2PFEPower.this.getAttachedEnergyStorage().getMaxEnergyStored(); + } - @Override - public boolean canReceive() - { - return false; - } + @Override + public int getEnergyStored() { + return PartP2PFEPower.this.getAttachedEnergyStorage().getEnergyStored(); + } + } - @Override - public int getMaxEnergyStored() - { - return PartP2PFEPower.this.getAttachedEnergyStorage().getMaxEnergyStored(); - } + private static class NullEnergyStorage implements IEnergyStorage { - @Override - public int getEnergyStored() - { - return PartP2PFEPower.this.getAttachedEnergyStorage().getEnergyStored(); - } - } + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + return 0; + } + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } - private static class NullEnergyStorage implements IEnergyStorage - { + @Override + public int getEnergyStored() { + return 0; + } - @Override - public int receiveEnergy( int maxReceive, boolean simulate ) - { - return 0; - } + @Override + public int getMaxEnergyStored() { + return 0; + } - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - return 0; - } + @Override + public boolean canExtract() { + return false; + } - @Override - public int getEnergyStored() - { - return 0; - } - - @Override - public int getMaxEnergyStored() - { - return 0; - } - - @Override - public boolean canExtract() - { - return false; - } - - @Override - public boolean canReceive() - { - return false; - } - } + @Override + public boolean canReceive() { + return false; + } + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PFluids.java b/src/main/java/appeng/parts/p2p/PartP2PFluids.java index 57a8a8ac4..0719532d1 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PFluids.java +++ b/src/main/java/appeng/parts/p2p/PartP2PFluids.java @@ -18,7 +18,6 @@ package appeng.parts.p2p; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; @@ -42,272 +41,222 @@ import appeng.api.parts.IPartModel; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; +public class PartP2PFluids extends PartP2PTunnel implements IFluidHandler { -public class PartP2PFluids extends PartP2PTunnel implements IFluidHandler -{ + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_fluids"); - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_fluids" ); + private static final ThreadLocal> DEPTH = new ThreadLocal<>();; - private static final ThreadLocal> DEPTH = new ThreadLocal<>();; + private LazyOptional cachedTank; + private int tmpUsed; - private LazyOptional cachedTank; - private int tmpUsed; + public PartP2PFluids(final ItemStack is) { + super(is); + } - public PartP2PFluids( final ItemStack is ) - { - super( is ); - } + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + public float getPowerDrainPerTick() { + return 2.0f; + } - public float getPowerDrainPerTick() - { - return 2.0f; - } + @Override + public void onTunnelNetworkChange() { + this.cachedTank = null; + } - @Override - public void onTunnelNetworkChange() - { - this.cachedTank = null; - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + this.cachedTank = null; - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - this.cachedTank = null; + if (this.isOutput()) { + final PartP2PFluids in = this.getInput(); + if (in != null) { + in.onTunnelNetworkChange(); + } + } + } - if( this.isOutput() ) - { - final PartP2PFluids in = this.getInput(); - if( in != null ) - { - in.onTunnelNetworkChange(); - } - } - } + @SuppressWarnings("unchecked") + @Override + public LazyOptional getCapability(Capability capabilityClass) { + if (capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this); + } - @SuppressWarnings("unchecked") - @Override - public LazyOptional getCapability(Capability capabilityClass ) - { - if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() ->this); - } + return super.getCapability(capabilityClass); + } - return super.getCapability( capabilityClass ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public int getTanks() { + return 0; + } - @Override - public int getTanks() - { - return 0; - } + @Override + @Nonnull + public FluidStack getFluidInTank(int tank) { + return FluidStack.EMPTY; + } - @Override - @Nonnull - public FluidStack getFluidInTank( int tank ) - { - return FluidStack.EMPTY; - } + @Override + public int getTankCapacity(int tank) { + return 1000; + } - @Override - public int getTankCapacity( int tank ) - { - return 1000; - } + @Override + public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { + return false; + } - @Override - public boolean isFluidValid( int tank, @Nonnull FluidStack stack ) - { - return false; - } + @Override + public int fill(FluidStack resource, FluidAction action) { - @Override - public int fill( FluidStack resource, FluidAction action ) - { + final Deque stack = this.getDepth(); - final Deque stack = this.getDepth(); + for (final PartP2PFluids t : stack) { + if (t == this) { + return 0; + } + } - for( final PartP2PFluids t : stack ) - { - if( t == this ) - { - return 0; - } - } + stack.push(this); - stack.push( this ); + final List list = this.getOutputs(resource.getFluid()); + int requestTotal = 0; - final List list = this.getOutputs( resource.getFluid() ); - int requestTotal = 0; + Iterator i = list.iterator(); - Iterator i = list.iterator(); + while (i.hasNext()) { + final PartP2PFluids l = i.next(); + final IFluidHandler tank = l.getTarget().orElse(null); + if (tank != null) { + l.tmpUsed = tank.fill(resource.copy(), FluidAction.SIMULATE); + } else { + l.tmpUsed = 0; + } - while( i.hasNext() ) - { - final PartP2PFluids l = i.next(); - final IFluidHandler tank = l.getTarget().orElse( null ); - if( tank != null ) - { - l.tmpUsed = tank.fill( resource.copy(), FluidAction.SIMULATE ); - } - else - { - l.tmpUsed = 0; - } + if (l.tmpUsed <= 0) { + i.remove(); + } else { + requestTotal += l.tmpUsed; + } + } - if( l.tmpUsed <= 0 ) - { - i.remove(); - } - else - { - requestTotal += l.tmpUsed; - } - } + if (requestTotal <= 0) { + if (stack.pop() != this) { + throw new IllegalStateException("Invalid Recursion detected."); + } - if( requestTotal <= 0 ) - { - if( stack.pop() != this ) - { - throw new IllegalStateException( "Invalid Recursion detected." ); - } + return 0; + } - return 0; - } + if (action == FluidAction.EXECUTE) { + if (stack.pop() != this) { + throw new IllegalStateException("Invalid Recursion detected."); + } - if( action == FluidAction.EXECUTE ) - { - if( stack.pop() != this ) - { - throw new IllegalStateException( "Invalid Recursion detected." ); - } + return Math.min(resource.getAmount(), requestTotal); + } - return Math.min( resource.getAmount(), requestTotal ); - } + int available = resource.getAmount(); - int available = resource.getAmount(); + i = list.iterator(); + int used = 0; - i = list.iterator(); - int used = 0; + while (i.hasNext() && available > 0) { + final PartP2PFluids l = i.next(); - while( i.hasNext() && available > 0 ) - { - final PartP2PFluids l = i.next(); + final FluidStack insert = resource.copy(); + insert.setAmount((int) Math.ceil(insert.getAmount() * ((double) l.tmpUsed / (double) requestTotal))); + if (insert.getAmount() > available) { + insert.setAmount(available); + } - final FluidStack insert = resource.copy(); - insert.setAmount( (int) Math.ceil( insert.getAmount() * ( (double) l.tmpUsed / (double) requestTotal ) ) ); - if( insert.getAmount() > available ) - { - insert.setAmount( available ); - } + final IFluidHandler tank = l.getTarget().orElse(null); + if (tank != null) { + l.tmpUsed = tank.fill(insert.copy(), action); + } else { + l.tmpUsed = 0; + } - final IFluidHandler tank = l.getTarget().orElse( null ); - if( tank != null ) - { - l.tmpUsed = tank.fill( insert.copy(), action ); - } - else - { - l.tmpUsed = 0; - } + available -= insert.getAmount(); + used += l.tmpUsed; + } - available -= insert.getAmount(); - used += l.tmpUsed; - } + if (stack.pop() != this) { + throw new IllegalStateException("Invalid Recursion detected."); + } - if( stack.pop() != this ) - { - throw new IllegalStateException( "Invalid Recursion detected." ); - } + return used; + } - return used; - } + @Override + @Nonnull + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } - @Override - @Nonnull - public FluidStack drain( FluidStack resource, FluidAction action ) - { - return FluidStack.EMPTY; - } + @Override + @Nonnull + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; + } - @Override - @Nonnull - public FluidStack drain( int maxDrain, FluidAction action ) - { - return FluidStack.EMPTY; - } + private Deque getDepth() { + Deque s = DEPTH.get(); - private Deque getDepth() - { - Deque s = DEPTH.get(); + if (s == null) { + DEPTH.set(s = new ArrayDeque<>()); + } - if( s == null ) - { - DEPTH.set( s = new ArrayDeque<>() ); - } + return s; + } - return s; - } + private List getOutputs(final Fluid input) { + final List outs = new ArrayList<>(); - private List getOutputs( final Fluid input ) - { - final List outs = new ArrayList<>(); + try { + for (final PartP2PFluids l : this.getOutputs()) { + final IFluidHandler handler = l.getTarget().orElse(null); - try - { - for( final PartP2PFluids l : this.getOutputs() ) - { - final IFluidHandler handler = l.getTarget().orElse( null ); + if (handler != null) { + outs.add(l); + } + } + } catch (final GridAccessException e) { + // :P + } - if( handler != null ) - { - outs.add( l ); - } - } - } - catch( final GridAccessException e ) - { - // :P - } + return outs; + } - return outs; - } + private LazyOptional getTarget() { + if (!this.getProxy().isActive()) { + return null; + } - private LazyOptional getTarget() - { - if( !this.getProxy().isActive() ) - { - return null; - } + if (this.cachedTank != null) { + return this.cachedTank; + } - if( this.cachedTank != null ) - { - return this.cachedTank; - } - - final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) ); - - if( te != null && te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ).isPresent() ) - { - return this.cachedTank = te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - this.getSide().getFacing().getOpposite() ); - } - - return null; - } + final TileEntity te = this.getTile().getWorld() + .getTileEntity(this.getTile().getPos().offset(this.getSide().getFacing())); + if (te != null && te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, + this.getSide().getFacing().getOpposite()).isPresent()) { + return this.cachedTank = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, + this.getSide().getFacing().getOpposite()); + } + return null; + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PItems.java b/src/main/java/appeng/parts/p2p/PartP2PItems.java index 8ab77c006..574480c80 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PItems.java +++ b/src/main/java/appeng/parts/p2p/PartP2PItems.java @@ -18,10 +18,11 @@ package appeng.parts.p2p; - import java.util.ArrayList; import java.util.List; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -49,246 +50,197 @@ import appeng.me.cache.helpers.TunnelCollection; import appeng.util.Platform; import appeng.util.inv.WrapperChainedItemHandler; -import javax.annotation.Nonnull; +public class PartP2PItems extends PartP2PTunnel implements IItemHandler, IGridTickable { + private static final float POWER_DRAIN = 2.0f; + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_items"); + private boolean partVisited = false; + @PartModels + public static List getModels() { + return MODELS.getModels(); + } -public class PartP2PItems extends PartP2PTunnel implements IItemHandler, IGridTickable -{ - private static final float POWER_DRAIN = 2.0f; - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_items" ); - private boolean partVisited = false; + private int oldSize = 0; + private boolean requested; + private IItemHandler cachedInv; - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + public PartP2PItems(final ItemStack is) { + super(is); + } - private int oldSize = 0; - private boolean requested; - private IItemHandler cachedInv; + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + this.cachedInv = null; + final PartP2PItems input = this.getInput(); + if (input != null && this.isOutput()) { + input.onTunnelNetworkChange(); + } + } - public PartP2PItems( final ItemStack is ) - { - super( is ); - } + private IItemHandler getDestination() { + this.requested = true; - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - this.cachedInv = null; - final PartP2PItems input = this.getInput(); - if( input != null && this.isOutput() ) - { - input.onTunnelNetworkChange(); - } - } + if (this.cachedInv != null) { + return this.cachedInv; + } - private IItemHandler getDestination() - { - this.requested = true; + final List outs = new ArrayList(); + final TunnelCollection itemTunnels; - if( this.cachedInv != null ) - { - return this.cachedInv; - } + try { + itemTunnels = this.getOutputs(); + } catch (final GridAccessException e) { + return EmptyHandler.INSTANCE; + } - final List outs = new ArrayList(); - final TunnelCollection itemTunnels; + for (final PartP2PItems t : itemTunnels) { + final IItemHandler inv = t.getOutputInv(); + if (inv != null && inv != this) { + if (Platform.getRandomInt() % 2 == 0) { + outs.add(inv); + } else { + outs.add(0, inv); + } + } + } - try - { - itemTunnels = this.getOutputs(); - } - catch( final GridAccessException e ) - { - return EmptyHandler.INSTANCE; - } + return this.cachedInv = new WrapperChainedItemHandler(outs.toArray(new IItemHandler[outs.size()])); + } - for( final PartP2PItems t : itemTunnels ) - { - final IItemHandler inv = t.getOutputInv(); - if( inv != null && inv != this ) - { - if( Platform.getRandomInt() % 2 == 0 ) - { - outs.add( inv ); - } - else - { - outs.add( 0, inv ); - } - } - } + private IItemHandler getOutputInv() { + IItemHandler ret = null; + if (!this.partVisited) { + this.partVisited = true; + if (this.getProxy().isActive()) { + final Direction facing = this.getSide().getFacing(); + final TileEntity te = this.getTile().getWorld().getTileEntity(this.getTile().getPos().offset(facing)); - return this.cachedInv = new WrapperChainedItemHandler( outs.toArray( new IItemHandler[outs.size()] ) ); - } + if (te != null) { + ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()) + .orElse(ret); + } + } + this.partVisited = false; + } + return ret; + } - private IItemHandler getOutputInv() - { - IItemHandler ret = null; - if( !this.partVisited ) - { - this.partVisited = true; - if( this.getProxy().isActive() ) - { - final Direction facing = this.getSide().getFacing(); - final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( facing ) ); + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.ItemTunnel.getMin(), TickRates.ItemTunnel.getMax(), false, false); + } - if( te != null ) - { - ret = te.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite() ) - .orElse(ret); - } - } - this.partVisited = false; - } - return ret; - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + final boolean wasReq = this.requested; - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.ItemTunnel.getMin(), TickRates.ItemTunnel.getMax(), false, false ); - } + if (this.requested && this.cachedInv != null) { + ((WrapperChainedItemHandler) this.cachedInv).cycleOrder(); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - final boolean wasReq = this.requested; + this.requested = false; + return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } - if( this.requested && this.cachedInv != null ) - { - ( (WrapperChainedItemHandler) this.cachedInv ).cycleOrder(); - } + @MENetworkEventSubscribe + public void changeStateA(final MENetworkBootingStatusChange bs) { + if (!this.isOutput()) { + this.cachedInv = null; + final int olderSize = this.oldSize; + this.oldSize = this.getDestination().getSlots(); + if (olderSize != this.oldSize) { + this.getHost().notifyNeighbors(); + } + } + } - this.requested = false; - return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER; - } + @MENetworkEventSubscribe + public void changeStateB(final MENetworkChannelsChanged bs) { + if (!this.isOutput()) { + this.cachedInv = null; + final int olderSize = this.oldSize; + this.oldSize = this.getDestination().getSlots(); + if (olderSize != this.oldSize) { + this.getHost().notifyNeighbors(); + } + } + } - @MENetworkEventSubscribe - public void changeStateA( final MENetworkBootingStatusChange bs ) - { - if( !this.isOutput() ) - { - this.cachedInv = null; - final int olderSize = this.oldSize; - this.oldSize = this.getDestination().getSlots(); - if( olderSize != this.oldSize ) - { - this.getHost().notifyNeighbors(); - } - } - } + @MENetworkEventSubscribe + public void changeStateC(final MENetworkPowerStatusChange bs) { + if (!this.isOutput()) { + this.cachedInv = null; + final int olderSize = this.oldSize; + this.oldSize = this.getDestination().getSlots(); + if (olderSize != this.oldSize) { + this.getHost().notifyNeighbors(); + } + } + } - @MENetworkEventSubscribe - public void changeStateB( final MENetworkChannelsChanged bs ) - { - if( !this.isOutput() ) - { - this.cachedInv = null; - final int olderSize = this.oldSize; - this.oldSize = this.getDestination().getSlots(); - if( olderSize != this.oldSize ) - { - this.getHost().notifyNeighbors(); - } - } - } + @Override + public void onTunnelNetworkChange() { + if (!this.isOutput()) { + this.cachedInv = null; + final int olderSize = this.oldSize; + this.oldSize = this.getDestination().getSlots(); + if (olderSize != this.oldSize) { + this.getHost().notifyNeighbors(); + } + } else { + final PartP2PItems input = this.getInput(); + if (input != null) { + input.getHost().notifyNeighbors(); + } + } + } - @MENetworkEventSubscribe - public void changeStateC( final MENetworkPowerStatusChange bs ) - { - if( !this.isOutput() ) - { - this.cachedInv = null; - final int olderSize = this.oldSize; - this.oldSize = this.getDestination().getSlots(); - if( olderSize != this.oldSize ) - { - this.getHost().notifyNeighbors(); - } - } - } + @SuppressWarnings("unchecked") + @Override + public LazyOptional getCapability(Capability capabilityClass) { + if (capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this); + } - @Override - public void onTunnelNetworkChange() - { - if( !this.isOutput() ) - { - this.cachedInv = null; - final int olderSize = this.oldSize; - this.oldSize = this.getDestination().getSlots(); - if( olderSize != this.oldSize ) - { - this.getHost().notifyNeighbors(); - } - } - else - { - final PartP2PItems input = this.getInput(); - if( input != null ) - { - input.getHost().notifyNeighbors(); - } - } - } + return super.getCapability(capabilityClass); + } - @SuppressWarnings( "unchecked" ) - @Override - public LazyOptional getCapability(Capability capabilityClass ) - { - if( capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() ->this); - } + @Override + public int getSlots() { + return this.getDestination().getSlots(); + } - return super.getCapability( capabilityClass ); - } + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return this.getDestination().isItemValid(slot, stack); + } - @Override - public int getSlots() - { - return this.getDestination().getSlots(); - } + @Override + public ItemStack getStackInSlot(final int i) { + return this.getDestination().getStackInSlot(i); + } - @Override - public boolean isItemValid(int slot, @Nonnull ItemStack stack) { - return this.getDestination().isItemValid(slot, stack); - } + @Override + public ItemStack insertItem(final int slot, final ItemStack stack, boolean simulate) { + return this.getDestination().insertItem(slot, stack, simulate); + } - @Override - public ItemStack getStackInSlot( final int i ) - { - return this.getDestination().getStackInSlot( i ); - } + @Override + public ItemStack extractItem(final int slot, final int amount, boolean simulate) { + return this.getDestination().extractItem(slot, amount, simulate); + } - @Override - public ItemStack insertItem( final int slot, final ItemStack stack, boolean simulate ) - { - return this.getDestination().insertItem( slot, stack, simulate ); - } + @Override + public int getSlotLimit(int slot) { + return this.getDestination().getSlotLimit(slot); + } - @Override - public ItemStack extractItem( final int slot, final int amount, boolean simulate ) - { - return this.getDestination().extractItem( slot, amount, simulate ); - } + public float getPowerDrainPerTick() { + return POWER_DRAIN; + } - @Override - public int getSlotLimit( int slot ) - { - return this.getDestination().getSlotLimit( slot ); - } - - public float getPowerDrainPerTick() - { - return POWER_DRAIN; - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PLight.java b/src/main/java/appeng/parts/p2p/PartP2PLight.java index 4dde9e6f0..61538035d 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLight.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLight.java @@ -18,7 +18,6 @@ package appeng.parts.p2p; - import java.io.IOException; import java.util.List; @@ -41,197 +40,159 @@ import appeng.core.settings.TickRates; import appeng.items.parts.PartModels; import appeng.me.GridAccessException; +public class PartP2PLight extends PartP2PTunnel implements IGridTickable { -public class PartP2PLight extends PartP2PTunnel implements IGridTickable -{ + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_light"); - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_light" ); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + private int lastValue = 0; + private int opacity = -1; - private int lastValue = 0; - private int opacity = -1; + public PartP2PLight(final ItemStack is) { + super(is); + } - public PartP2PLight( final ItemStack is ) - { - super( is ); - } + @Override + public void chanRender(final MENetworkChannelsChanged c) { + this.onTunnelNetworkChange(); + super.chanRender(c); + } - @Override - public void chanRender( final MENetworkChannelsChanged c ) - { - this.onTunnelNetworkChange(); - super.chanRender( c ); - } + @Override + public void powerRender(final MENetworkPowerStatusChange c) { + this.onTunnelNetworkChange(); + super.powerRender(c); + } - @Override - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.onTunnelNetworkChange(); - super.powerRender( c ); - } + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeInt(this.isOutput() ? this.lastValue : 0); + data.writeInt(this.opacity); + } - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeInt( this.isOutput() ? this.lastValue : 0 ); - data.writeInt( this.opacity ); - } + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + super.readFromStream(data); + final int oldValue = this.lastValue; + final int oldOpacity = this.opacity; - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - super.readFromStream( data ); - final int oldValue = this.lastValue; - final int oldOpacity = this.opacity; + this.lastValue = data.readInt(); + this.opacity = data.readInt(); - this.lastValue = data.readInt(); - this.opacity = data.readInt(); + this.setOutput(this.lastValue > 0); + return this.lastValue != oldValue || oldOpacity != this.opacity; + } - this.setOutput( this.lastValue > 0 ); - return this.lastValue != oldValue || oldOpacity != this.opacity; - } + private boolean doWork() { + if (this.isOutput()) { + return false; + } - private boolean doWork() - { - if( this.isOutput() ) - { - return false; - } + final TileEntity te = this.getTile(); + final World w = te.getWorld(); - final TileEntity te = this.getTile(); - final World w = te.getWorld(); + final int newLevel = w.getLight(te.getPos().offset(this.getSide().getFacing())); - final int newLevel = w.getLight( te.getPos().offset( this.getSide().getFacing() ) ); + if (this.lastValue != newLevel && this.getProxy().isActive()) { + this.lastValue = newLevel; + try { + for (final PartP2PLight out : this.getOutputs()) { + out.setLightLevel(this.lastValue); + } + } catch (final GridAccessException e) { + // :P + } + return true; + } + return false; + } - if( this.lastValue != newLevel && this.getProxy().isActive() ) - { - this.lastValue = newLevel; - try - { - for( final PartP2PLight out : this.getOutputs() ) - { - out.setLightLevel( this.lastValue ); - } - } - catch( final GridAccessException e ) - { - // :P - } - return true; - } - return false; - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (this.isOutput() && pos.offset(this.getSide().getFacing()).equals(neighbor)) { + this.opacity = -1; + this.getHost().markForUpdate(); + } else { + this.doWork(); + } + } - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( this.isOutput() && pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - this.opacity = -1; - this.getHost().markForUpdate(); - } - else - { - this.doWork(); - } - } + @Override + public int getLightLevel() { + if (this.isOutput() && this.isPowered()) { + return this.blockLight(this.lastValue); + } - @Override - public int getLightLevel() - { - if( this.isOutput() && this.isPowered() ) - { - return this.blockLight( this.lastValue ); - } + return 0; + } - return 0; - } + private void setLightLevel(final int out) { + this.lastValue = out; + this.getHost().markForUpdate(); + } - private void setLightLevel( final int out ) - { - this.lastValue = out; - this.getHost().markForUpdate(); - } + private int blockLight(final int emit) { + if (this.opacity < 0) { + final TileEntity te = this.getTile(); + this.opacity = 255 - te.getWorld().getLight(te.getPos().offset(this.getSide().getFacing())); + } - private int blockLight( final int emit ) - { - if( this.opacity < 0 ) - { - final TileEntity te = this.getTile(); - this.opacity = 255 - te.getWorld().getLight( te.getPos().offset( this.getSide().getFacing() ) ); - } + return (int) (emit * (this.opacity / 255.0f)); + } - return (int) ( emit * ( this.opacity / 255.0f ) ); - } + @Override + public void readFromNBT(final CompoundNBT tag) { + super.readFromNBT(tag); + this.lastValue = tag.getInt("lastValue"); + } - @Override - public void readFromNBT( final CompoundNBT tag ) - { - super.readFromNBT( tag ); - this.lastValue = tag.getInt( "lastValue" ); - } + @Override + public void writeToNBT(final CompoundNBT tag) { + super.writeToNBT(tag); + tag.putInt("lastValue", this.lastValue); + } - @Override - public void writeToNBT( final CompoundNBT tag ) - { - super.writeToNBT( tag ); - tag.putInt( "lastValue", this.lastValue ); - } + @Override + public void onTunnelConfigChange() { + this.onTunnelNetworkChange(); + } - @Override - public void onTunnelConfigChange() - { - this.onTunnelNetworkChange(); - } + @Override + public void onTunnelNetworkChange() { + if (this.isOutput()) { + final PartP2PLight src = this.getInput(); + if (src != null && src.getProxy().isActive()) { + this.setLightLevel(src.lastValue); + } else { + this.getHost().markForUpdate(); + } + } else { + this.doWork(); + } + } - @Override - public void onTunnelNetworkChange() - { - if( this.isOutput() ) - { - final PartP2PLight src = this.getInput(); - if( src != null && src.getProxy().isActive() ) - { - this.setLightLevel( src.lastValue ); - } - else - { - this.getHost().markForUpdate(); - } - } - else - { - this.doWork(); - } - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.LightTunnel.getMin(), TickRates.LightTunnel.getMax(), false, false); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.LightTunnel.getMin(), TickRates.LightTunnel.getMax(), false, false ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.doWork() ? TickRateModulation.URGENT : TickRateModulation.SLOWER; + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.doWork() ? TickRateModulation.URGENT : TickRateModulation.SLOWER; - } + public float getPowerDrainPerTick() { + return 0.5f; + } - public float getPowerDrainPerTick() - { - return 0.5f; - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java index 5d41f4152..bb8817e5f 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java @@ -18,7 +18,6 @@ package appeng.parts.p2p; - import java.util.List; import net.minecraft.block.Block; @@ -40,179 +39,144 @@ import appeng.items.parts.PartModels; import appeng.me.GridAccessException; import appeng.util.Platform; +public class PartP2PRedstone extends PartP2PTunnel { -public class PartP2PRedstone extends PartP2PTunnel -{ + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_redstone"); - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_redstone" ); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + private int power; + private boolean recursive = false; - private int power; - private boolean recursive = false; + public PartP2PRedstone(final ItemStack is) { + super(is); + } - public PartP2PRedstone( final ItemStack is ) - { - super( is ); - } + @MENetworkEventSubscribe + public void changeStateA(final MENetworkBootingStatusChange bs) { + this.setNetworkReady(); + } - @MENetworkEventSubscribe - public void changeStateA( final MENetworkBootingStatusChange bs ) - { - this.setNetworkReady(); - } + private void setNetworkReady() { + if (this.isOutput()) { + final PartP2PRedstone in = this.getInput(); + if (in != null) { + this.putInput(in.power); + } + } + } - private void setNetworkReady() - { - if( this.isOutput() ) - { - final PartP2PRedstone in = this.getInput(); - if( in != null ) - { - this.putInput( in.power ); - } - } - } + private void putInput(final Object o) { + if (this.recursive) { + return; + } - private void putInput( final Object o ) - { - if( this.recursive ) - { - return; - } + this.recursive = true; + if (this.isOutput() && this.getProxy().isActive()) { + final int newPower = (Integer) o; + if (this.power != newPower) { + this.power = newPower; + this.notifyNeighbors(); + } + } + this.recursive = false; + } - this.recursive = true; - if( this.isOutput() && this.getProxy().isActive() ) - { - final int newPower = (Integer) o; - if( this.power != newPower ) - { - this.power = newPower; - this.notifyNeighbors(); - } - } - this.recursive = false; - } + private void notifyNeighbors() { + final World world = this.getTile().getWorld(); - private void notifyNeighbors() - { - final World world = this.getTile().getWorld(); + Platform.notifyBlocksOfNeighbors(world, this.getTile().getPos()); - Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos() ); + // and this cause sometimes it can go thought walls. + for (final Direction face : Direction.values()) { + Platform.notifyBlocksOfNeighbors(world, this.getTile().getPos().offset(face)); + } + } - // and this cause sometimes it can go thought walls. - for( final Direction face : Direction.values() ) - { - Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos().offset( face ) ); - } - } + @MENetworkEventSubscribe + public void changeStateB(final MENetworkChannelsChanged bs) { + this.setNetworkReady(); + } - @MENetworkEventSubscribe - public void changeStateB( final MENetworkChannelsChanged bs ) - { - this.setNetworkReady(); - } + @MENetworkEventSubscribe + public void changeStateC(final MENetworkPowerStatusChange bs) { + this.setNetworkReady(); + } - @MENetworkEventSubscribe - public void changeStateC( final MENetworkPowerStatusChange bs ) - { - this.setNetworkReady(); - } + @Override + public void readFromNBT(final CompoundNBT tag) { + super.readFromNBT(tag); + this.power = tag.getInt("power"); + } - @Override - public void readFromNBT( final CompoundNBT tag ) - { - super.readFromNBT( tag ); - this.power = tag.getInt( "power" ); - } + @Override + public void writeToNBT(final CompoundNBT tag) { + super.writeToNBT(tag); + tag.putInt("power", this.power); + } - @Override - public void writeToNBT( final CompoundNBT tag ) - { - super.writeToNBT( tag ); - tag.putInt( "power", this.power ); - } + @Override + public void onTunnelNetworkChange() { + this.setNetworkReady(); + } - @Override - public void onTunnelNetworkChange() - { - this.setNetworkReady(); - } + public float getPowerDrainPerTick() { + return 0.5f; + } - public float getPowerDrainPerTick() - { - return 0.5f; - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (!this.isOutput()) { + final BlockPos target = this.getTile().getPos().offset(this.getSide().getFacing()); - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( !this.isOutput() ) - { - final BlockPos target = this.getTile().getPos().offset( this.getSide().getFacing() ); + final BlockState state = this.getTile().getWorld().getBlockState(target); + final Block b = state.getBlock(); + if (b != null && !this.isOutput()) { + Direction srcSide = this.getSide().getFacing(); + if (b instanceof RedstoneWireBlock) { + srcSide = Direction.UP; + } - final BlockState state = this.getTile().getWorld().getBlockState( target ); - final Block b = state.getBlock(); - if( b != null && !this.isOutput() ) - { - Direction srcSide = this.getSide().getFacing(); - if( b instanceof RedstoneWireBlock ) - { - srcSide = Direction.UP; - } + this.power = b.getWeakPower(state, this.getTile().getWorld(), target, srcSide); + this.power = Math.max(this.power, b.getWeakPower(state, this.getTile().getWorld(), target, srcSide)); + this.sendToOutput(this.power); + } else { + this.sendToOutput(0); + } + } + } - this.power = b.getWeakPower( state, this.getTile().getWorld(), target, srcSide ); - this.power = Math.max( this.power, b.getWeakPower( state, this.getTile().getWorld(), target, srcSide ) ); - this.sendToOutput( this.power ); - } - else - { - this.sendToOutput( 0 ); - } - } - } + @Override + public boolean canConnectRedstone() { + return true; + } - @Override - public boolean canConnectRedstone() - { - return true; - } + @Override + public int isProvidingStrongPower() { + return this.isOutput() ? this.power : 0; + } - @Override - public int isProvidingStrongPower() - { - return this.isOutput() ? this.power : 0; - } + @Override + public int isProvidingWeakPower() { + return this.isOutput() ? this.power : 0; + } - @Override - public int isProvidingWeakPower() - { - return this.isOutput() ? this.power : 0; - } + private void sendToOutput(final int power) { + try { + for (final PartP2PRedstone rs : this.getOutputs()) { + rs.putInput(power); + } + } catch (final GridAccessException e) { + // :P + } + } - private void sendToOutput( final int power ) - { - try - { - for( final PartP2PRedstone rs : this.getOutputs() ) - { - rs.putInput( power ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index 51812529b..11df822ea 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -18,19 +18,20 @@ package appeng.parts.p2p; - import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; -import appeng.client.render.cablebus.P2PTunnelFrequencyModelData; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.model.data.ModelDataMap; +import net.minecraftforge.client.model.data.ModelProperty; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -47,409 +48,341 @@ import appeng.api.parts.PartItemStack; import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.api.util.AEPartLocation; +import appeng.client.render.cablebus.P2PTunnelFrequencyModelData; import appeng.core.AEConfig; import appeng.me.GridAccessException; import appeng.me.cache.P2PCache; import appeng.me.cache.helpers.TunnelCollection; import appeng.parts.PartBasicState; import appeng.util.Platform; -import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.client.model.data.ModelDataMap; -import net.minecraftforge.client.model.data.ModelProperty; - - -public abstract class PartP2PTunnel extends PartBasicState -{ - private final TunnelCollection type = new TunnelCollection( null, this.getClass() ); - private boolean output; - private short freq; - - public PartP2PTunnel( final ItemStack is ) - { - super( is ); - } - - public TunnelCollection getCollection( final Collection collection, final Class c ) - { - if( this.type.matches( c ) ) - { - this.type.setSource( collection ); - return this.type; - } - - return null; - } - - public T getInput() - { - if( this.getFrequency() == 0 ) - { - return null; - } - - try - { - final PartP2PTunnel tunnel = this.getProxy().getP2P().getInput( this.getFrequency() ); - if( this.getClass().isInstance( tunnel ) ) - { - return (T) tunnel; - } - } - catch( final GridAccessException e ) - { - // :P - } - return null; - } - - public TunnelCollection getOutputs() throws GridAccessException - { - if( this.getProxy().isActive() ) - { - return (TunnelCollection) this.getProxy().getP2P().getOutputs( this.getFrequency(), this.getClass() ); - } - return new TunnelCollection( new ArrayList(), this.getClass() ); - } - - @Override - public void getBoxes( final 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 ItemStack getItemStack( final 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( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.setOutput( data.getBoolean( "output" ) ); - this.freq = data.getShort( "freq" ); - } - - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putBoolean( "output", this.isOutput() ); - data.putShort( "freq", this.getFrequency() ); - } - - @Override - public boolean readFromStream( PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final short oldf = this.freq; - this.freq = data.readShort(); - return c || oldf != this.freq; - } - - @Override - public void writeToStream( PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeShort( this.getFrequency() ); - } - - @Override - public float getCableConnectionLength( AECableType cable ) - { - return 1; - } - - @Override - public boolean useStandardMemoryCard() - { - return false; - } - - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } - - if( hand == Hand.OFF_HAND ) - { - return false; - } - - final ItemStack is = player.getHeldItem( hand ); - - // UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() ); - // AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() ); - - final TunnelType tt = AEApi.instance().registries().p2pTunnel().getTunnelTypeByItem( is ); - if( !is.isEmpty() && is.getItem() instanceof IMemoryCard ) - { - final IMemoryCard mc = (IMemoryCard) is.getItem(); - final CompoundNBT data = mc.getData( is ); - - final ItemStack newType = ItemStack.read( data ); - final short freq = data.getShort( "freq" ); - - if( !newType.isEmpty() ) - { - if( newType.getItem() instanceof IPartItem ) - { - final IPart testPart = ( (IPartItem) newType.getItem() ).createPart( newType ); - if( testPart instanceof PartP2PTunnel ) - { - this.getHost().removePart( this.getSide(), true ); - final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player, hand ); - final IPart newBus = this.getHost().getPart( dir ); - - if( newBus instanceof PartP2PTunnel ) - { - final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; - newTunnel.setOutput( true ); - - try - { - final P2PCache p2p = newTunnel.getProxy().getP2P(); - p2p.updateFreq( newTunnel, freq ); - } - catch( final GridAccessException e ) - { - // :P - } - - newTunnel.onTunnelNetworkChange(); - } - - mc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); - return true; - } - } - } - mc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE ); - } - else if( tt != null ) // attunement - { - final ItemStack newType; - - final IParts parts = AEApi.instance().definitions().parts(); - - switch( tt ) - { - case LIGHT: - newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case FE_POWER: - newType = parts.p2PTunnelFE().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case FLUID: - newType = parts.p2PTunnelFluids().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case IC2_POWER: - newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case ITEM: - newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case ME: - newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - case REDSTONE: - newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - - /* - * case COMPUTER_MESSAGE: - * for( ItemStack stack : parts.p2PTunnelOpenComputers().maybeStack( 1 ).asSet() ) - * { - * newType = stack; - * } - * break; - */ - - default: - newType = ItemStack.EMPTY; - break; - } - - if( !newType.isEmpty() && !ItemStack.areItemsEqual( newType, this.getItemStack() ) ) - { - final boolean oldOutput = this.isOutput(); - final short myFreq = this.getFrequency(); - - this.getHost().removePart( this.getSide(), false ); - final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player, hand ); - final IPart newBus = this.getHost().getPart( dir ); - - if( newBus instanceof PartP2PTunnel ) - { - final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; - newTunnel.setOutput( oldOutput ); - newTunnel.onTunnelNetworkChange(); - - try - { - final P2PCache p2p = newTunnel.getProxy().getP2P(); - p2p.updateFreq( newTunnel, myFreq ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - Platform.notifyBlocksOfNeighbors( this.getTile().getWorld(), this.getTile().getPos() ); - return true; - } - } - - return false; - } - - @Override - public boolean onPartShiftActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - final ItemStack is = player.inventory.getCurrentItem(); - if( !is.isEmpty() && is.getItem() instanceof IMemoryCard ) - { - if( Platform.isClient() ) - { - return true; - } - - final IMemoryCard mc = (IMemoryCard) is.getItem(); - final CompoundNBT data = mc.getData( is ); - final short storedFrequency = data.getShort( "freq" ); - - short newFreq = this.getFrequency(); - final boolean wasOutput = this.isOutput(); - this.setOutput( false ); - - final boolean needsNewFrequency = wasOutput || this.getFrequency() == 0 || storedFrequency == newFreq; - - try - { - if( needsNewFrequency ) - { - newFreq = this.getProxy().getP2P().newFrequency(); - } - - this.getProxy().getP2P().updateFreq( this, newFreq ); - } - catch( final GridAccessException e ) - { - // :P - } - - this.onTunnelConfigChange(); - - final ItemStack p2pItem = this.getItemStack( PartItemStack.WRENCH ); - final String type = p2pItem.getTranslationKey(); - - p2pItem.write( data ); - data.putShort( "freq", this.getFrequency() ); - - final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() ); - final int[] colorCode = new int[] { - colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(), - colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(), - }; - - data.putIntArray( "colorCode", colorCode ); - - mc.setMemoryCardContents( is, type + ".name", data ); - if( needsNewFrequency ) - { - mc.notifyUser( player, MemoryCardMessages.SETTINGS_RESET ); - } - else - { - mc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); - } - return true; - } - return false; - } - - public void onTunnelConfigChange() - { - } - - public void onTunnelNetworkChange() - { - - } - - protected void queueTunnelDrain( final PowerUnits unit, final double f ) - { - final double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TUNNEL_POWER_LOSS ); - - try - { - this.getProxy().getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - public short getFrequency() - { - return this.freq; - } - - public void setFrequency( final short freq ) - { - final short oldf = this.freq; - this.freq = freq; - if( oldf != this.freq ) - { - this.getHost().markForUpdate(); - } - } - - public boolean isOutput() - { - return this.output; - } - - void setOutput( final boolean output ) - { - this.output = output; - } - - @Override - public IModelData getModelData() - { - long ret = Short.toUnsignedLong( this.getFrequency() ); - - if( this.isActive() && this.isPowered() ) - { - ret |= 0x10000L; - } - - return new P2PTunnelFrequencyModelData(ret); - } + +public abstract class PartP2PTunnel extends PartBasicState { + private final TunnelCollection type = new TunnelCollection(null, this.getClass()); + private boolean output; + private short freq; + + public PartP2PTunnel(final ItemStack is) { + super(is); + } + + public TunnelCollection getCollection(final Collection collection, + final Class c) { + if (this.type.matches(c)) { + this.type.setSource(collection); + return this.type; + } + + return null; + } + + public T getInput() { + if (this.getFrequency() == 0) { + return null; + } + + try { + final PartP2PTunnel tunnel = this.getProxy().getP2P().getInput(this.getFrequency()); + if (this.getClass().isInstance(tunnel)) { + return (T) tunnel; + } + } catch (final GridAccessException e) { + // :P + } + return null; + } + + public TunnelCollection getOutputs() throws GridAccessException { + if (this.getProxy().isActive()) { + return (TunnelCollection) this.getProxy().getP2P().getOutputs(this.getFrequency(), this.getClass()); + } + return new TunnelCollection(new ArrayList(), this.getClass()); + } + + @Override + public void getBoxes(final 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 ItemStack getItemStack(final 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(final CompoundNBT data) { + super.readFromNBT(data); + this.setOutput(data.getBoolean("output")); + this.freq = data.getShort("freq"); + } + + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putBoolean("output", this.isOutput()); + data.putShort("freq", this.getFrequency()); + } + + @Override + public boolean readFromStream(PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final short oldf = this.freq; + this.freq = data.readShort(); + return c || oldf != this.freq; + } + + @Override + public void writeToStream(PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeShort(this.getFrequency()); + } + + @Override + public float getCableConnectionLength(AECableType cable) { + return 1; + } + + @Override + public boolean useStandardMemoryCard() { + return false; + } + + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isClient()) { + return true; + } + + if (hand == Hand.OFF_HAND) { + return false; + } + + final ItemStack is = player.getHeldItem(hand); + + // UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() ); + // AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() ); + + final TunnelType tt = AEApi.instance().registries().p2pTunnel().getTunnelTypeByItem(is); + if (!is.isEmpty() && is.getItem() instanceof IMemoryCard) { + final IMemoryCard mc = (IMemoryCard) is.getItem(); + final CompoundNBT data = mc.getData(is); + + final ItemStack newType = ItemStack.read(data); + final short freq = data.getShort("freq"); + + if (!newType.isEmpty()) { + if (newType.getItem() instanceof IPartItem) { + final IPart testPart = ((IPartItem) newType.getItem()).createPart(newType); + if (testPart instanceof PartP2PTunnel) { + this.getHost().removePart(this.getSide(), true); + final AEPartLocation dir = this.getHost().addPart(newType, this.getSide(), player, hand); + final IPart newBus = this.getHost().getPart(dir); + + if (newBus instanceof PartP2PTunnel) { + final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; + newTunnel.setOutput(true); + + try { + final P2PCache p2p = newTunnel.getProxy().getP2P(); + p2p.updateFreq(newTunnel, freq); + } catch (final GridAccessException e) { + // :P + } + + newTunnel.onTunnelNetworkChange(); + } + + mc.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED); + return true; + } + } + } + mc.notifyUser(player, MemoryCardMessages.INVALID_MACHINE); + } else if (tt != null) // attunement + { + final ItemStack newType; + + final IParts parts = AEApi.instance().definitions().parts(); + + switch (tt) { + case LIGHT: + newType = parts.p2PTunnelLight().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case FE_POWER: + newType = parts.p2PTunnelFE().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case FLUID: + newType = parts.p2PTunnelFluids().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case IC2_POWER: + newType = parts.p2PTunnelEU().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case ITEM: + newType = parts.p2PTunnelItems().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case ME: + newType = parts.p2PTunnelME().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + case REDSTONE: + newType = parts.p2PTunnelRedstone().maybeStack(1).orElse(ItemStack.EMPTY); + break; + + /* + * case COMPUTER_MESSAGE: for( ItemStack stack : + * parts.p2PTunnelOpenComputers().maybeStack( 1 ).asSet() ) { newType = stack; } + * break; + */ + + default: + newType = ItemStack.EMPTY; + break; + } + + if (!newType.isEmpty() && !ItemStack.areItemsEqual(newType, this.getItemStack())) { + final boolean oldOutput = this.isOutput(); + final short myFreq = this.getFrequency(); + + this.getHost().removePart(this.getSide(), false); + final AEPartLocation dir = this.getHost().addPart(newType, this.getSide(), player, hand); + final IPart newBus = this.getHost().getPart(dir); + + if (newBus instanceof PartP2PTunnel) { + final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; + newTunnel.setOutput(oldOutput); + newTunnel.onTunnelNetworkChange(); + + try { + final P2PCache p2p = newTunnel.getProxy().getP2P(); + p2p.updateFreq(newTunnel, myFreq); + } catch (final GridAccessException e) { + // :P + } + } + + Platform.notifyBlocksOfNeighbors(this.getTile().getWorld(), this.getTile().getPos()); + return true; + } + } + + return false; + } + + @Override + public boolean onPartShiftActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + final ItemStack is = player.inventory.getCurrentItem(); + if (!is.isEmpty() && is.getItem() instanceof IMemoryCard) { + if (Platform.isClient()) { + return true; + } + + final IMemoryCard mc = (IMemoryCard) is.getItem(); + final CompoundNBT data = mc.getData(is); + final short storedFrequency = data.getShort("freq"); + + short newFreq = this.getFrequency(); + final boolean wasOutput = this.isOutput(); + this.setOutput(false); + + final boolean needsNewFrequency = wasOutput || this.getFrequency() == 0 || storedFrequency == newFreq; + + try { + if (needsNewFrequency) { + newFreq = this.getProxy().getP2P().newFrequency(); + } + + this.getProxy().getP2P().updateFreq(this, newFreq); + } catch (final GridAccessException e) { + // :P + } + + this.onTunnelConfigChange(); + + final ItemStack p2pItem = this.getItemStack(PartItemStack.WRENCH); + final String type = p2pItem.getTranslationKey(); + + p2pItem.write(data); + data.putShort("freq", this.getFrequency()); + + final AEColor[] colors = Platform.p2p().toColors(this.getFrequency()); + final int[] colorCode = new int[] { colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), + colors[1].ordinal(), colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), + colors[3].ordinal(), }; + + data.putIntArray("colorCode", colorCode); + + mc.setMemoryCardContents(is, type + ".name", data); + if (needsNewFrequency) { + mc.notifyUser(player, MemoryCardMessages.SETTINGS_RESET); + } else { + mc.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED); + } + return true; + } + return false; + } + + public void onTunnelConfigChange() { + } + + public void onTunnelNetworkChange() { + + } + + protected void queueTunnelDrain(final PowerUnits unit, final double f) { + final double ae_to_tax = unit.convertTo(PowerUnits.AE, f * AEConfig.TUNNEL_POWER_LOSS); + + try { + this.getProxy().getEnergy().extractAEPower(ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE); + } catch (final GridAccessException e) { + // :P + } + } + + public short getFrequency() { + return this.freq; + } + + public void setFrequency(final short freq) { + final short oldf = this.freq; + this.freq = freq; + if (oldf != this.freq) { + this.getHost().markForUpdate(); + } + } + + public boolean isOutput() { + return this.output; + } + + void setOutput(final boolean output) { + this.output = output; + } + + @Override + public IModelData getModelData() { + long ret = Short.toUnsignedLong(this.getFrequency()); + + if (this.isActive() && this.isPowered()) { + ret |= 0x10000L; + } + + return new P2PTunnelFrequencyModelData(ret); + } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java index f352d36e1..3f46019e1 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java @@ -18,7 +18,6 @@ package appeng.parts.p2p; - import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; @@ -50,227 +49,174 @@ import appeng.me.cache.helpers.Connections; import appeng.me.cache.helpers.TunnelConnection; import appeng.me.helpers.AENetworkProxy; +public class PartP2PTunnelME extends PartP2PTunnel implements IGridTickable { -public class PartP2PTunnelME extends PartP2PTunnel implements IGridTickable -{ + private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_me"); - private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_me" ); + @PartModels + public static List getModels() { + return MODELS.getModels(); + } - @PartModels - public static List getModels() - { - return MODELS.getModels(); - } + private final Connections connection = new Connections(this); + private final AENetworkProxy outerProxy = new AENetworkProxy(this, "outer", ItemStack.EMPTY, true); - private final Connections connection = new Connections( this ); - private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", ItemStack.EMPTY, true ); + public PartP2PTunnelME(final ItemStack is) { + super(is); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.COMPRESSED_CHANNEL); + this.outerProxy.setFlags(GridFlags.DENSE_CAPACITY, GridFlags.CANNOT_CARRY_COMPRESSED); + } - public PartP2PTunnelME( final ItemStack is ) - { - super( is ); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.COMPRESSED_CHANNEL ); - this.outerProxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.CANNOT_CARRY_COMPRESSED ); - } + @Override + public void readFromNBT(final CompoundNBT extra) { + super.readFromNBT(extra); + this.outerProxy.readFromNBT(extra); + } - @Override - public void readFromNBT( final CompoundNBT extra ) - { - super.readFromNBT( extra ); - this.outerProxy.readFromNBT( extra ); - } + @Override + public void writeToNBT(final CompoundNBT extra) { + super.writeToNBT(extra); + this.outerProxy.writeToNBT(extra); + } - @Override - public void writeToNBT( final CompoundNBT extra ) - { - super.writeToNBT( extra ); - this.outerProxy.writeToNBT( extra ); - } + @Override + public void onTunnelNetworkChange() { + super.onTunnelNetworkChange(); + if (!this.isOutput()) { + try { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } + } - @Override - public void onTunnelNetworkChange() - { - super.onTunnelNetworkChange(); - if( !this.isOutput() ) - { - try - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.DENSE_SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.DENSE_SMART; - } + @Override + public void removeFromWorld() { + super.removeFromWorld(); + this.outerProxy.remove(); + } - @Override - public void removeFromWorld() - { - super.removeFromWorld(); - this.outerProxy.remove(); - } + @Override + public void addToWorld() { + super.addToWorld(); + this.outerProxy.onReady(); + } - @Override - public void addToWorld() - { - super.addToWorld(); - this.outerProxy.onReady(); - } + @Override + public void setPartHostInfo(final AEPartLocation side, final IPartHost host, final TileEntity tile) { + super.setPartHostInfo(side, host, tile); + this.outerProxy.setValidSides(EnumSet.of(side.getFacing())); + } - @Override - public void setPartHostInfo( final AEPartLocation side, final IPartHost host, final TileEntity tile ) - { - super.setPartHostInfo( side, host, tile ); - this.outerProxy.setValidSides( EnumSet.of( side.getFacing() ) ); - } + @Override + public IGridNode getExternalFacingNode() { + return this.outerProxy.getNode(); + } - @Override - public IGridNode getExternalFacingNode() - { - return this.outerProxy.getNode(); - } + @Override + public void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { + super.onPlacement(player, hand, held, side); + this.outerProxy.setOwner(player); + } - @Override - public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { - super.onPlacement( player, hand, held, side ); - this.outerProxy.setOwner( player ); - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.METunnel.getMin(), TickRates.METunnel.getMax(), true, false); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.METunnel.getMin(), TickRates.METunnel.getMax(), true, false ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + // just move on... + try { + if (!this.getProxy().getPath().isNetworkBooting()) { + if (!this.getProxy().getEnergy().isNetworkPowered()) { + this.connection.markDestroy(); + TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection); + } else { + if (this.getProxy().isActive()) { + this.connection.markCreate(); + TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection); + } else { + this.connection.markDestroy(); + TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection); + } + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - // just move on... - try - { - if( !this.getProxy().getPath().isNetworkBooting() ) - { - if( !this.getProxy().getEnergy().isNetworkPowered() ) - { - this.connection.markDestroy(); - TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection ); - } - else - { - if( this.getProxy().isActive() ) - { - this.connection.markCreate(); - TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection ); - } - else - { - this.connection.markDestroy(); - TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection ); - } - } + return TickRateModulation.SLEEP; + } + } catch (final GridAccessException e) { + // meh? + } - return TickRateModulation.SLEEP; - } - } - catch( final GridAccessException e ) - { - // meh? - } + return TickRateModulation.IDLE; + } - return TickRateModulation.IDLE; - } + public void updateConnections(final Connections connections) { + if (connections.isDestroy()) { + for (final TunnelConnection cw : this.connection.getConnections().values()) { + cw.getConnection().destroy(); + } - public void updateConnections( final Connections connections ) - { - if( connections.isDestroy() ) - { - for( final TunnelConnection cw : this.connection.getConnections().values() ) - { - cw.getConnection().destroy(); - } + this.connection.getConnections().clear(); + } else if (connections.isCreate()) { - this.connection.getConnections().clear(); - } - else if( connections.isCreate() ) - { + final Iterator i = this.connection.getConnections().values().iterator(); + while (i.hasNext()) { + final TunnelConnection cw = i.next(); + try { + if (cw.getTunnel().getProxy().getGrid() != this.getProxy().getGrid()) { + cw.getConnection().destroy(); + i.remove(); + } else if (!cw.getTunnel().getProxy().isActive()) { + cw.getConnection().destroy(); + i.remove(); + } + } catch (final GridAccessException e) { + // :P + } + } - final Iterator i = this.connection.getConnections().values().iterator(); - while( i.hasNext() ) - { - final TunnelConnection cw = i.next(); - try - { - if( cw.getTunnel().getProxy().getGrid() != this.getProxy().getGrid() ) - { - cw.getConnection().destroy(); - i.remove(); - } - else if( !cw.getTunnel().getProxy().isActive() ) - { - cw.getConnection().destroy(); - i.remove(); - } - } - catch( final GridAccessException e ) - { - // :P - } - } + final List newSides = new ArrayList<>(); + try { + for (final PartP2PTunnelME me : this.getOutputs()) { + if (me.getProxy().isActive() && connections.getConnections().get(me.getGridNode()) == null) { + newSides.add(me); + } + } - final List newSides = new ArrayList<>(); - try - { - for( final PartP2PTunnelME me : this.getOutputs() ) - { - if( me.getProxy().isActive() && connections.getConnections().get( me.getGridNode() ) == null ) - { - newSides.add( me ); - } - } + for (final PartP2PTunnelME me : newSides) { + try { + connections.getConnections().put(me.getGridNode(), new TunnelConnection(me, AEApi.instance() + .grid().createGridConnection(this.outerProxy.getNode(), me.outerProxy.getNode()))); + } catch (final FailedConnectionException e) { + final TileEntity start = this.getTile(); + final TileEntity end = me.getTile(); - for( final PartP2PTunnelME me : newSides ) - { - try - { - connections.getConnections() - .put( me.getGridNode(), - new TunnelConnection( me, AEApi.instance() - .grid() - .createGridConnection( this.outerProxy.getNode(), - me.outerProxy.getNode() ) ) ); - } - catch( final FailedConnectionException e ) - { - final TileEntity start = this.getTile(); - final TileEntity end = me.getTile(); + AELog.debug(e); - AELog.debug( e ); + AELog.warn( + "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]", + start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), + end.getPos().getX(), end.getPos().getY(), end.getPos().getZ()); + // :( + } + } + } catch (final GridAccessException e) { + AELog.debug(e); + } + } + } - AELog.warn( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]", - start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), end.getPos().getX(), end.getPos().getY(), - end.getPos().getZ() ); - // :( - } - } - } - catch( final GridAccessException e ) - { - AELog.debug( e ); - } - } - } - - @Override - public IPartModel getStaticModels() - { - return MODELS.getModel( this.isPowered(), this.isActive() ); - } + @Override + public IPartModel getStaticModels() { + return MODELS.getModel(this.isPowered(), this.isActive()); + } } diff --git a/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java b/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java index 3fe11adeb..8e33be5a4 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java @@ -18,49 +18,48 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import appeng.core.AppEng; import appeng.items.parts.PartModels; - /** * A more sophisticated part overlapping all 3 textures. * - * Subclass this if you need want a new part and need all 3 textures. - * For more concrete implementations, the direct abstract subclasses might be a better alternative. + * Subclass this if you need want a new part and need all 3 textures. For more + * concrete implementations, the direct abstract subclasses might be a better + * alternative. * * @author AlgorithmX2 * @author yueh * @version rv3 * @since rv3 */ -public abstract class AbstractPartDisplay extends AbstractPartReporting -{ +public abstract class AbstractPartDisplay extends AbstractPartReporting { - // The base chassis of all display parts - @PartModels - protected static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/display_base" ); + // The base chassis of all display parts + @PartModels + protected static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/display_base"); - // Models that contain the status indicator light - @PartModels - protected static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/display_status_off" ); - @PartModels - protected static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/display_status_on" ); - @PartModels - protected static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/display_status_has_channel" ); + // Models that contain the status indicator light + @PartModels + protected static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/display_status_off"); + @PartModels + protected static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation(AppEng.MOD_ID, + "part/display_status_on"); + @PartModels + protected static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation(AppEng.MOD_ID, + "part/display_status_has_channel"); - public AbstractPartDisplay( final ItemStack is ) - { - super( is, true ); - } + public AbstractPartDisplay(final ItemStack is) { + super(is, true); + } - @Override - public boolean isLightSource() - { - return false; - } + @Override + public boolean isLightSource() { + return false; + } } diff --git a/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java b/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java index ac54e9fff..a56418f4b 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java @@ -18,10 +18,10 @@ package appeng.parts.reporting; - import java.io.IOException; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -55,11 +55,12 @@ import appeng.util.Platform; import appeng.util.ReadableNumberConverter; import appeng.util.item.AEItemStack; - /** - * A basic subclass for any item monitor like display with an item icon and an amount. + * A basic subclass for any item monitor like display with an item icon and an + * amount. * - * It can also be used to extract items from somewhere and spawned into the world. + * It can also be used to extract items from somewhere and spawned into the + * world. * * @author AlgorithmX2 * @author thatsIch @@ -67,309 +68,251 @@ import appeng.util.item.AEItemStack; * @version rv3 * @since rv3 */ -public abstract class AbstractPartMonitor extends AbstractPartDisplay implements IPartStorageMonitor, IStackWatcherHost -{ - private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE; - private IAEItemStack configuredItem; - private String lastHumanReadableText; - private boolean isLocked; - private IStackWatcher myWatcher; +public abstract class AbstractPartMonitor extends AbstractPartDisplay + implements IPartStorageMonitor, IStackWatcherHost { + private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE; + private IAEItemStack configuredItem; + private String lastHumanReadableText; + private boolean isLocked; + private IStackWatcher myWatcher; - @Reflected - public AbstractPartMonitor( final ItemStack is ) - { - super( is ); - } + @Reflected + public AbstractPartMonitor(final ItemStack is) { + super(is); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); - this.isLocked = data.getBoolean( "isLocked" ); + this.isLocked = data.getBoolean("isLocked"); - final CompoundNBT myItem = data.getCompound( "configuredItem" ); - this.configuredItem = AEItemStack.fromNBT( myItem ); - } + final CompoundNBT myItem = data.getCompound("configuredItem"); + this.configuredItem = AEItemStack.fromNBT(myItem); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); - data.putBoolean("isLocked", this.isLocked); + data.putBoolean("isLocked", this.isLocked); - final CompoundNBT myItem = new CompoundNBT(); - if( this.configuredItem != null ) - { - this.configuredItem.writeToNBT(myItem); - } + final CompoundNBT myItem = new CompoundNBT(); + if (this.configuredItem != null) { + this.configuredItem.writeToNBT(myItem); + } - data.put( "configuredItem", myItem ); - } + data.put("configuredItem", myItem); + } - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); - data.writeBoolean( this.isLocked ); - data.writeBoolean( this.configuredItem != null ); - if( this.configuredItem != null ) - { - this.configuredItem.writeToPacket( data ); - } - } + data.writeBoolean(this.isLocked); + data.writeBoolean(this.configuredItem != null); + if (this.configuredItem != null) { + this.configuredItem.writeToPacket(data); + } + } - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - boolean needRedraw = super.readFromStream( data ); + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + boolean needRedraw = super.readFromStream(data); - final boolean isLocked = data.readBoolean(); - needRedraw = this.isLocked != isLocked; + final boolean isLocked = data.readBoolean(); + needRedraw = this.isLocked != isLocked; - this.isLocked = isLocked; + this.isLocked = isLocked; - final boolean val = data.readBoolean(); - if( val ) - { - this.configuredItem = AEItemStack.fromPacket( data ); - } - else - { - this.configuredItem = null; - } + final boolean val = data.readBoolean(); + if (val) { + this.configuredItem = AEItemStack.fromPacket(data); + } else { + this.configuredItem = null; + } - return needRedraw; - } + return needRedraw; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (Platform.isClient()) { + return true; + } - if( !this.getProxy().isActive() ) - { - return false; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !Platform.hasPermissions( this.getLocation(), player ) ) - { - return false; - } + if (!Platform.hasPermissions(this.getLocation(), player)) { + return false; + } - if( !this.isLocked ) - { - final ItemStack eq = player.getHeldItem( hand ); - this.configuredItem = AEItemStack.fromItemStack( eq ); - this.configureWatchers(); - this.getHost().markForSave(); - this.getHost().markForUpdate(); - } - else - { - return super.onPartActivate( player, hand, pos ); - } + if (!this.isLocked) { + final ItemStack eq = player.getHeldItem(hand); + this.configuredItem = AEItemStack.fromItemStack(eq); + this.configureWatchers(); + this.getHost().markForSave(); + this.getHost().markForUpdate(); + } else { + return super.onPartActivate(player, hand, pos); + } - return true; - } + return true; + } - @Override - public boolean onPartShiftActivate( PlayerEntity player, Hand hand, Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } + @Override + public boolean onPartShiftActivate(PlayerEntity player, Hand hand, Vec3d pos) { + if (Platform.isClient()) { + return true; + } - if( !this.getProxy().isActive() ) - { - return false; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !Platform.hasPermissions( this.getLocation(), player ) ) - { - return false; - } + if (!Platform.hasPermissions(this.getLocation(), player)) { + return false; + } - if( player.getHeldItem( hand ).isEmpty() ) - { - this.isLocked = !this.isLocked; - player.sendMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() ); - this.getHost().markForSave(); - this.getHost().markForUpdate(); - } + if (player.getHeldItem(hand).isEmpty()) { + this.isLocked = !this.isLocked; + player.sendMessage((this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get()); + this.getHost().markForSave(); + this.getHost().markForUpdate(); + } - return true; - } + return true; + } - // update the system... - private void configureWatchers() - { - if( this.myWatcher != null ) - { - this.myWatcher.reset(); - } + // update the system... + private void configureWatchers() { + if (this.myWatcher != null) { + this.myWatcher.reset(); + } - try - { - if( this.configuredItem != null ) - { - if( this.myWatcher != null ) - { - this.myWatcher.add( this.configuredItem ); - } + try { + if (this.configuredItem != null) { + if (this.myWatcher != null) { + this.myWatcher.add(this.configuredItem); + } - this.updateReportingValue( - this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ); - } - } - catch( final GridAccessException e ) - { - // >.> - } - } + this.updateReportingValue(this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); + } + } catch (final GridAccessException e) { + // >.> + } + } - private void updateReportingValue( final IMEMonitor itemInventory ) - { - if( this.configuredItem != null ) - { - final IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem ); - if( result == null ) - { - this.configuredItem.setStackSize( 0 ); - } - else - { - this.configuredItem.setStackSize( result.getStackSize() ); - } - } - } + private void updateReportingValue(final IMEMonitor itemInventory) { + if (this.configuredItem != null) { + final IAEItemStack result = itemInventory.getStorageList().findPrecise(this.configuredItem); + if (result == null) { + this.configuredItem.setStackSize(0); + } else { + this.configuredItem.setStackSize(result.getStackSize()); + } + } + } - @Override - @OnlyIn( Dist.CLIENT ) - public void renderDynamic(float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) - { + @Override + @OnlyIn(Dist.CLIENT) + public void renderDynamic(float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, + int combinedLightIn, int combinedOverlayIn) { - if( ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) != ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) - { - return; - } + if ((this.getClientFlags() & (PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG)) != (PartPanel.POWERED_FLAG + | PartPanel.CHANNEL_FLAG)) { + return; + } - final IAEItemStack ais = this.getDisplayed(); + final IAEItemStack ais = this.getDisplayed(); - if( ais == null ) - { - return; - } + if (ais == null) { + return; + } - matrixStack.push(); - matrixStack.translate( 0.5, 0.5, 0.5 ); // Move into the center of the block + matrixStack.push(); + matrixStack.translate(0.5, 0.5, 0.5); // Move into the center of the block - Direction facing = this.getSide().getFacing(); + Direction facing = this.getSide().getFacing(); - TesrRenderHelper.rotateToFace( matrixStack, facing, this.getSpin() ); - TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, ais, 0.8f, 0.17f, combinedLightIn, combinedOverlayIn ); + TesrRenderHelper.rotateToFace(matrixStack, facing, this.getSpin()); + TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, ais, 0.8f, 0.17f, combinedLightIn, + combinedOverlayIn); - matrixStack.pop(); + matrixStack.pop(); - } + } - @Override - public boolean requireDynamicRender() - { - return true; - } + @Override + public boolean requireDynamicRender() { + return true; + } - @Override - public IAEItemStack getDisplayed() - { - return this.configuredItem; - } + @Override + public IAEItemStack getDisplayed() { + return this.configuredItem; + } - @Override - public boolean isLocked() - { - return this.isLocked; - } + @Override + public boolean isLocked() { + return this.isLocked; + } - @Override - public void updateWatcher( final IStackWatcher newWatcher ) - { - this.myWatcher = newWatcher; - this.configureWatchers(); - } + @Override + public void updateWatcher(final IStackWatcher newWatcher) { + this.myWatcher = newWatcher; + this.configureWatchers(); + } - @Override - public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan ) - { - if( this.configuredItem != null ) - { - if( fullStack == null ) - { - this.configuredItem.setStackSize( 0 ); - } - else - { - this.configuredItem.setStackSize( fullStack.getStackSize() ); - } + @Override + public void onStackChange(final IItemList o, final IAEStack fullStack, final IAEStack diffStack, + final IActionSource src, final IStorageChannel chan) { + if (this.configuredItem != null) { + if (fullStack == null) { + this.configuredItem.setStackSize(0); + } else { + this.configuredItem.setStackSize(fullStack.getStackSize()); + } - final long stackSize = this.configuredItem.getStackSize(); - final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ); + final long stackSize = this.configuredItem.getStackSize(); + final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm(stackSize); - if( !humanReadableText.equals( this.lastHumanReadableText ) ) - { - this.lastHumanReadableText = humanReadableText; - this.getHost().markForUpdate(); - } - } - } + if (!humanReadableText.equals(this.lastHumanReadableText)) { + this.lastHumanReadableText = humanReadableText; + this.getHost().markForUpdate(); + } + } + } - @Override - public boolean showNetworkInfo( final RayTraceResult where ) - { - return false; - } + @Override + public boolean showNetworkInfo(final RayTraceResult where) { + return false; + } - protected IPartModel selectModel( IPartModel off, IPartModel on, IPartModel hasChannel, IPartModel lockedOff, IPartModel lockedOn, IPartModel lockedHasChannel ) - { - if( this.isActive() ) - { - if( this.isLocked() ) - { - return lockedHasChannel; - } - else - { - return hasChannel; - } - } - else if( this.isPowered() ) - { - if( this.isLocked() ) - { - return lockedOn; - } - else - { - return on; - } - } - else - { - if( this.isLocked() ) - { - return lockedOff; - } - else - { - return off; - } - } - } + protected IPartModel selectModel(IPartModel off, IPartModel on, IPartModel hasChannel, IPartModel lockedOff, + IPartModel lockedOn, IPartModel lockedHasChannel) { + if (this.isActive()) { + if (this.isLocked()) { + return lockedHasChannel; + } else { + return hasChannel; + } + } else if (this.isPowered()) { + if (this.isLocked()) { + return lockedOn; + } else { + return on; + } + } else { + if (this.isLocked()) { + return lockedOff; + } else { + return off; + } + } + } } diff --git a/src/main/java/appeng/parts/reporting/AbstractPartPanel.java b/src/main/java/appeng/parts/reporting/AbstractPartPanel.java index 01e75859d..f3bb015bb 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartPanel.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartPanel.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -26,40 +25,38 @@ import appeng.api.util.AEColor; import appeng.core.AppEng; import appeng.items.parts.PartModels; - /** * A very simple part for emitting light. * - * Opposed to the other subclass of {@link AbstractPartReporting}, it will only use the bright front texture. + * Opposed to the other subclass of {@link AbstractPartReporting}, it will only + * use the bright front texture. * * @author AlgorithmX2 * @author yueh * @version rv3 * @since rv3 */ -public abstract class AbstractPartPanel extends AbstractPartReporting -{ +public abstract class AbstractPartPanel extends AbstractPartReporting { - @PartModels - public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/monitor_base" ); + @PartModels + public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/monitor_base"); - public AbstractPartPanel( final ItemStack is ) - { - super( is, false ); - } + public AbstractPartPanel(final ItemStack is) { + super(is, false); + } - @Override - public boolean isLightSource() - { - return true; - } + @Override + public boolean isLightSource() { + return true; + } - /** - * How bright the color the panel should appear. Usually it depends on a {@link AEColor} variant. - * This does not affect the actual light level of the part. - * - * @return the brightness to be used. - */ - protected abstract int getBrightnessColor(); + /** + * How bright the color the panel should appear. Usually it depends on a + * {@link AEColor} variant. This does not affect the actual light level of the + * part. + * + * @return the brightness to be used. + */ + protected abstract int getBrightnessColor(); } diff --git a/src/main/java/appeng/parts/reporting/AbstractPartReporting.java b/src/main/java/appeng/parts/reporting/AbstractPartReporting.java index f7fff0794..f781d7ffd 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartReporting.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartReporting.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import java.io.IOException; import net.minecraft.entity.player.PlayerEntity; @@ -31,6 +30,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import appeng.api.implementations.IPowerChannelState; import appeng.api.implementations.parts.IPartMonitor; @@ -44,289 +44,236 @@ import appeng.api.util.AEPartLocation; import appeng.me.GridAccessException; import appeng.parts.AEBasePart; import appeng.util.Platform; -import net.minecraft.world.World; - /** - * The most basic class for any part reporting information, like terminals or monitors. This can also include basic - * panels which just provide light. + * The most basic class for any part reporting information, like terminals or + * monitors. This can also include basic panels which just provide light. * - * It deals with the most basic functionalities like network data, grid registration or the rotation of the actual part. + * It deals with the most basic functionalities like network data, grid + * registration or the rotation of the actual part. * - * The direct abstract subclasses are usually a better entry point for adding new concrete ones. - * But this might be an ideal starting point to completely new type, which does not resemble any existing one. + * The direct abstract subclasses are usually a better entry point for adding + * new concrete ones. But this might be an ideal starting point to completely + * new type, which does not resemble any existing one. * * @author AlgorithmX2 * @author yueh * @version rv3 * @since rv3 */ -public abstract class AbstractPartReporting extends AEBasePart implements IPartMonitor, IPowerChannelState -{ +public abstract class AbstractPartReporting extends AEBasePart implements IPartMonitor, IPowerChannelState { - protected static final int POWERED_FLAG = 4; - protected static final int CHANNEL_FLAG = 16; - private static final int BOOTING_FLAG = 8; + protected static final int POWERED_FLAG = 4; + protected static final int CHANNEL_FLAG = 16; + private static final int BOOTING_FLAG = 8; - private byte spin = 0; // 0-3 - private int clientFlags = 0; // sent as byte. - private int opacity = -1; + private byte spin = 0; // 0-3 + private int clientFlags = 0; // sent as byte. + private int opacity = -1; - public AbstractPartReporting( final ItemStack is ) - { - this( is, false ); - } + public AbstractPartReporting(final ItemStack is) { + this(is, false); + } - protected AbstractPartReporting( final ItemStack is, final boolean requireChannel ) - { - super( is ); + protected AbstractPartReporting(final ItemStack is, final boolean requireChannel) { + super(is); - if( requireChannel ) - { - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.getProxy().setIdlePowerUsage( 1.0 / 2.0 ); - } - else - { - this.getProxy().setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit. - } - } + if (requireChannel) { + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.getProxy().setIdlePowerUsage(1.0 / 2.0); + } else { + this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little bit. + } + } - @MENetworkEventSubscribe - public final void bootingRender( final MENetworkBootingStatusChange c ) - { - if( !this.isLightSource() ) - { - this.getHost().markForUpdate(); - } - } + @MENetworkEventSubscribe + public final void bootingRender(final MENetworkBootingStatusChange c) { + if (!this.isLightSource()) { + this.getHost().markForUpdate(); + } + } - @MENetworkEventSubscribe - public final void powerRender( final MENetworkPowerStatusChange c ) - { - this.getHost().markForUpdate(); - } + @MENetworkEventSubscribe + public final void powerRender(final MENetworkPowerStatusChange c) { + this.getHost().markForUpdate(); + } - @Override - public final void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 2, 2, 14, 14, 14, 16 ); - bch.addBox( 4, 4, 13, 12, 12, 14 ); - } + @Override + public final void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(2, 2, 14, 14, 14, 16); + bch.addBox(4, 4, 13, 12, 12, 14); + } - @Override - public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor ) - { - if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) - { - this.opacity = -1; - this.getHost().markForUpdate(); - } - } + @Override + public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) { + if (pos.offset(this.getSide().getFacing()).equals(neighbor)) { + this.opacity = -1; + this.getHost().markForUpdate(); + } + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.spin = data.getByte( "spin" ); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.spin = data.getByte("spin"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putByte( "spin", this.getSpin() ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putByte("spin", this.getSpin()); + } - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - this.clientFlags = this.getSpin() & 3; + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + this.clientFlags = this.getSpin() & 3; - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - this.clientFlags = this.getClientFlags() | AbstractPartReporting.POWERED_FLAG; - } + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + this.clientFlags = this.getClientFlags() | AbstractPartReporting.POWERED_FLAG; + } - if( this.getProxy().getPath().isNetworkBooting() ) - { - this.clientFlags = this.getClientFlags() | AbstractPartReporting.BOOTING_FLAG; - } + if (this.getProxy().getPath().isNetworkBooting()) { + this.clientFlags = this.getClientFlags() | AbstractPartReporting.BOOTING_FLAG; + } - if( this.getProxy().getNode().meetsChannelRequirements() ) - { - this.clientFlags = this.getClientFlags() | AbstractPartReporting.CHANNEL_FLAG; - } - } - catch( final GridAccessException e ) - { - // um.. nothing. - } + if (this.getProxy().getNode().meetsChannelRequirements()) { + this.clientFlags = this.getClientFlags() | AbstractPartReporting.CHANNEL_FLAG; + } + } catch (final GridAccessException e) { + // um.. nothing. + } - data.writeByte( (byte) this.getClientFlags() ); - data.writeInt( this.opacity ); - } + data.writeByte((byte) this.getClientFlags()); + data.writeInt(this.opacity); + } - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - super.readFromStream( data ); - final int oldFlags = this.getClientFlags(); - final int oldOpacity = this.opacity; + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + super.readFromStream(data); + final int oldFlags = this.getClientFlags(); + final int oldOpacity = this.opacity; - this.clientFlags = data.readByte(); - this.opacity = data.readInt(); + this.clientFlags = data.readByte(); + this.opacity = data.readInt(); - this.spin = (byte) ( this.getClientFlags() & 3 ); - if( this.getClientFlags() == oldFlags && this.opacity == oldOpacity ) - { - return false; - } - return true; - } + this.spin = (byte) (this.getClientFlags() & 3); + if (this.getClientFlags() == oldFlags && this.opacity == oldOpacity) { + return false; + } + return true; + } - @Override - public final int getLightLevel() - { - return this.blockLight( this.isPowered() ? ( this.isLightSource() ? 15 : 9 ) : 0 ); - } + @Override + public final int getLightLevel() { + return this.blockLight(this.isPowered() ? (this.isLightSource() ? 15 : 9) : 0); + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - final TileEntity te = this.getTile(); + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + final TileEntity te = this.getTile(); - if( Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) ) - { - if( Platform.isServer() ) - { - if( this.getSpin() > 3 ) - { - this.spin = 0; - } + if (Platform.isWrench(player, player.inventory.getCurrentItem(), te.getPos())) { + if (Platform.isServer()) { + if (this.getSpin() > 3) { + this.spin = 0; + } - switch( this.getSpin() ) - { - case 0: - this.spin = 1; - break; - case 1: - this.spin = 3; - break; - case 2: - this.spin = 0; - break; - case 3: - this.spin = 2; - break; - } + switch (this.getSpin()) { + case 0: + this.spin = 1; + break; + case 1: + this.spin = 3; + break; + case 2: + this.spin = 0; + break; + case 3: + this.spin = 2; + break; + } - this.getHost().markForUpdate(); - this.saveChanges(); - } - return true; - } - else - { - return super.onPartActivate( player, hand, pos ); - } - } + this.getHost().markForUpdate(); + this.saveChanges(); + } + return true; + } else { + return super.onPartActivate(player, hand, pos); + } + } - @Override - public final void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side ) - { - super.onPlacement( player, hand, held, side ); + @Override + public final void onPlacement(final PlayerEntity player, final Hand hand, final ItemStack held, + final AEPartLocation side) { + super.onPlacement(player, hand, held, side); - final byte rotation = (byte) ( MathHelper.floor( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); - if( side == AEPartLocation.UP ) - { - this.spin = rotation; - } - else if( side == AEPartLocation.DOWN ) - { - this.spin = rotation; - } - } + final byte rotation = (byte) (MathHelper.floor((player.rotationYaw * 4F) / 360F + 2.5D) & 3); + if (side == AEPartLocation.UP) { + this.spin = rotation; + } else if (side == AEPartLocation.DOWN) { + this.spin = rotation; + } + } - private final int blockLight( final int emit ) - { - if( this.opacity < 0 ) - { - final TileEntity te = this.getTile(); - World world = te.getWorld(); - BlockPos pos = te.getPos().offset(this.getSide().getFacing()); - this.opacity = 255 - world.getBlockState(pos).getOpacity(world, pos); - } + private final int blockLight(final int emit) { + if (this.opacity < 0) { + final TileEntity te = this.getTile(); + World world = te.getWorld(); + BlockPos pos = te.getPos().offset(this.getSide().getFacing()); + this.opacity = 255 - world.getBlockState(pos).getOpacity(world, pos); + } - return (int) ( emit * ( this.opacity / 255.0f ) ); - } + return (int) (emit * (this.opacity / 255.0f)); + } - @Override - public final boolean isPowered() - { - try - { - if( Platform.isServer() ) - { - return this.getProxy().getEnergy().isNetworkPowered(); - } - else - { - return( ( this.getClientFlags() & PartPanel.POWERED_FLAG ) == PartPanel.POWERED_FLAG ); - } - } - catch( final GridAccessException e ) - { - return false; - } - } + @Override + public final boolean isPowered() { + try { + if (Platform.isServer()) { + return this.getProxy().getEnergy().isNetworkPowered(); + } else { + return ((this.getClientFlags() & PartPanel.POWERED_FLAG) == PartPanel.POWERED_FLAG); + } + } catch (final GridAccessException e) { + return false; + } + } - @Override - public final boolean isActive() - { - if( !this.isLightSource() ) - { - return( ( this.getClientFlags() & ( PartPanel.CHANNEL_FLAG | PartPanel.POWERED_FLAG ) ) == ( PartPanel.CHANNEL_FLAG | PartPanel.POWERED_FLAG ) ); - } - else - { - return this.isPowered(); - } - } + @Override + public final boolean isActive() { + if (!this.isLightSource()) { + return ((this.getClientFlags() + & (PartPanel.CHANNEL_FLAG | PartPanel.POWERED_FLAG)) == (PartPanel.CHANNEL_FLAG + | PartPanel.POWERED_FLAG)); + } else { + return this.isPowered(); + } + } - protected IPartModel selectModel( IPartModel offModels, IPartModel onModels, IPartModel hasChannelModels ) - { - if( this.isActive() ) - { - return hasChannelModels; - } - else if( this.isPowered() ) - { - return onModels; - } - else - { - return offModels; - } - } + protected IPartModel selectModel(IPartModel offModels, IPartModel onModels, IPartModel hasChannelModels) { + if (this.isActive()) { + return hasChannelModels; + } else if (this.isPowered()) { + return onModels; + } else { + return offModels; + } + } - public final int getClientFlags() - { - return this.clientFlags; - } + public final int getClientFlags() { + return this.clientFlags; + } - public final byte getSpin() - { - return this.spin; - } + public final byte getSpin() { + return this.spin; + } - /** - * Should the part emit light. This actually only affects the light level, light source use a level of 15 and non - * light source 9. - */ - public abstract boolean isLightSource(); + /** + * Should the part emit light. This actually only affects the light level, light + * source use a level of 15 and non light source 9. + */ + public abstract boolean isLightSource(); } diff --git a/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java index 755e1f41f..d7f22799c 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java @@ -18,12 +18,8 @@ package appeng.parts.reporting; - import java.util.List; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerMEMonitorable; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -42,7 +38,9 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.ITerminalHost; import appeng.api.storage.data.IAEStack; import appeng.api.util.IConfigManager; - +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerMEMonitorable; import appeng.me.GridAccessException; import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.ConfigManager; @@ -50,116 +48,98 @@ import appeng.util.IConfigManagerHost; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; - /** * Anything resembling an network terminal with view cells can reuse this. * - * Note this applies only to terminals like the ME Terminal. It does not apply for more specialized terminals like the - * Interface Terminal. + * Note this applies only to terminals like the ME Terminal. It does not apply + * for more specialized terminals like the Interface Terminal. * * @author AlgorithmX2 * @author yueh * @version rv3 * @since rv3 */ -public abstract class AbstractPartTerminal extends AbstractPartDisplay implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory -{ +public abstract class AbstractPartTerminal extends AbstractPartDisplay + implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory { - private final IConfigManager cm = new ConfigManager( this ); - private final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 ); + private final IConfigManager cm = new ConfigManager(this); + private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5); - public AbstractPartTerminal( final ItemStack is ) - { - super( is ); + public AbstractPartTerminal(final ItemStack is) { + super(is); - this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); - } + 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( final List drops, final boolean wrenched ) - { - super.getDrops( drops, wrenched ); + @Override + public void getDrops(final List drops, final boolean wrenched) { + super.getDrops(drops, wrenched); - for( final ItemStack is : this.viewCell ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + for (final ItemStack is : this.viewCell) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } - @Override - public IConfigManager getConfigManager() - { - return this.cm; - } + @Override + public IConfigManager getConfigManager() { + return this.cm; + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.cm.readFromNBT( data ); - this.viewCell.readFromNBT( data, "viewCell" ); - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.cm.readFromNBT(data); + this.viewCell.readFromNBT(data, "viewCell"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.cm.writeToNBT( data ); - this.viewCell.writeToNBT( data, "viewCell" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.cm.writeToNBT(data); + this.viewCell.writeToNBT(data, "viewCell"); + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( !super.onPartActivate( player, hand, pos ) ) - { - if( !player.world.isRemote ) - { - ContainerOpener.openContainer(getContainerType(player), player, ContainerLocator.forPart(this)); - } - } - return true; - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (!super.onPartActivate(player, hand, pos)) { + if (!player.world.isRemote) { + ContainerOpener.openContainer(getContainerType(player), player, ContainerLocator.forPart(this)); + } + } + return true; + } - public ContainerType getContainerType(final PlayerEntity player ) - { - return ContainerMEMonitorable.TYPE; - } + public ContainerType getContainerType(final PlayerEntity player) { + return ContainerMEMonitorable.TYPE; + } - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - try - { - return this.getProxy().getStorage().getInventory( channel ); - } - catch( final GridAccessException e ) - { - // err nope? - } - return null; - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + try { + return this.getProxy().getStorage().getInventory(channel); + } catch (final GridAccessException e) { + // err nope? + } + return null; + } - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { - } + } - @Override - public IItemHandler getViewCellStorage() - { - return this.viewCell; - } + @Override + public IItemHandler getViewCellStorage() { + return this.viewCell; + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - this.getHost().markForSave(); - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + this.getHost().markForSave(); + } } diff --git a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java index fc0757500..3451e396f 100644 --- a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import java.util.Collections; import java.util.List; @@ -47,229 +46,184 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.item.AEItemStack; +public class PartConversionMonitor extends AbstractPartMonitor { -public class PartConversionMonitor extends AbstractPartMonitor -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/conversion_monitor_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/conversion_monitor_on"); + @PartModels + public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/conversion_monitor_locked_off"); + @PartModels + public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation(AppEng.MOD_ID, + "part/conversion_monitor_locked_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_on" ); - @PartModels - public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_locked_off" ); - @PartModels - public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation( AppEng.MOD_ID, "part/conversion_monitor_locked_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); + public static final IPartModel MODELS_LOCKED_OFF = new PartModel(MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_LOCKED_ON = new PartModel(MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_LOCKED_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_LOCKED_ON, + MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); - public static final IPartModel MODELS_LOCKED_OFF = new PartModel( MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_LOCKED_ON = new PartModel( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_LOCKED_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_HAS_CHANNEL ); + @Reflected + public PartConversionMonitor(final ItemStack is) { + super(is); + } - @Reflected - public PartConversionMonitor( final ItemStack is ) - { - super( is ); - } + @Override + public boolean onPartActivate(PlayerEntity player, Hand hand, Vec3d pos) { + if (Platform.isClient()) { + return true; + } - @Override - public boolean onPartActivate( PlayerEntity player, Hand hand, Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !this.getProxy().isActive() ) - { - return false; - } + if (!Platform.hasPermissions(this.getLocation(), player)) { + return false; + } - if( !Platform.hasPermissions( this.getLocation(), player ) ) - { - return false; - } + final ItemStack eq = player.getHeldItem(hand); + if (this.isLocked()) { + if (eq.isEmpty()) { + this.insertItem(player, hand, true); + } else if (Platform.isWrench(player, eq, this.getLocation().getPos()) + && (this.getDisplayed() == null || !this.getDisplayed().equals(eq))) { + // wrench it + return super.onPartActivate(player, hand, pos); + } else { + this.insertItem(player, hand, false); + } + } else if (this.getDisplayed() != null && this.getDisplayed().equals(eq)) { + this.insertItem(player, hand, false); + } else { + return super.onPartActivate(player, hand, pos); + } - final ItemStack eq = player.getHeldItem( hand ); - if( this.isLocked() ) - { - if( eq.isEmpty() ) - { - this.insertItem( player, hand, true ); - } - else if( Platform.isWrench( player, eq, this.getLocation().getPos() ) && ( this.getDisplayed() == null || !this.getDisplayed().equals( eq ) ) ) - { - // wrench it - return super.onPartActivate( player, hand, pos ); - } - else - { - this.insertItem( player, hand, false ); - } - } - else if( this.getDisplayed() != null && this.getDisplayed().equals( eq ) ) - { - this.insertItem( player, hand, false ); - } - else - { - return super.onPartActivate( player, hand, pos ); - } + return true; + } - return true; - } + @Override + public boolean onClicked(PlayerEntity player, Hand hand, Vec3d pos) { + if (Platform.isClient()) { + return true; + } - @Override - public boolean onClicked( PlayerEntity player, Hand hand, Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !this.getProxy().isActive() ) - { - return false; - } + if (!Platform.hasPermissions(this.getLocation(), player)) { + return false; + } - if( !Platform.hasPermissions( this.getLocation(), player ) ) - { - return false; - } + if (this.getDisplayed() != null) { + this.extractItem(player, this.getDisplayed().getDefinition().getMaxStackSize()); + } - if( this.getDisplayed() != null ) - { - this.extractItem( player, this.getDisplayed().getDefinition().getMaxStackSize() ); - } + return true; + } - return true; - } + @Override + public boolean onShiftClicked(PlayerEntity player, Hand hand, Vec3d pos) { + if (Platform.isClient()) { + return true; + } - @Override - public boolean onShiftClicked( PlayerEntity player, Hand hand, Vec3d pos ) - { - if( Platform.isClient() ) - { - return true; - } + if (!this.getProxy().isActive()) { + return false; + } - if( !this.getProxy().isActive() ) - { - return false; - } + if (!Platform.hasPermissions(this.getLocation(), player)) { + return false; + } - if( !Platform.hasPermissions( this.getLocation(), player ) ) - { - return false; - } + if (this.getDisplayed() != null) { + this.extractItem(player, 1); + } - if( this.getDisplayed() != null ) - { - this.extractItem( player, 1 ); - } + return true; + } - return true; - } + private void insertItem(final PlayerEntity player, final Hand hand, final boolean allItems) { + try { + final IEnergySource energy = this.getProxy().getEnergy(); + final IMEMonitor cell = this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - private void insertItem( final PlayerEntity player, final Hand hand, final boolean allItems ) - { - try - { - final IEnergySource energy = this.getProxy().getEnergy(); - final IMEMonitor cell = this.getProxy() - .getStorage() - .getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + if (allItems) { + if (this.getDisplayed() != null) { + final IAEItemStack input = this.getDisplayed().copy(); + IItemHandler inv = new PlayerMainInvWrapper(player.inventory); - if( allItems ) - { - if( this.getDisplayed() != null ) - { - final IAEItemStack input = this.getDisplayed().copy(); - IItemHandler inv = new PlayerMainInvWrapper( player.inventory ); + for (int x = 0; x < inv.getSlots(); x++) { + final ItemStack targetStack = inv.getStackInSlot(x); + if (input.equals(targetStack)) { + final ItemStack canExtract = inv.extractItem(x, targetStack.getCount(), true); + if (!canExtract.isEmpty()) { + input.setStackSize(canExtract.getCount()); + final IAEItemStack failedToInsert = Platform.poweredInsert(energy, cell, input, + new PlayerSource(player, this)); + inv.extractItem(x, failedToInsert == null ? canExtract.getCount() + : canExtract.getCount() - (int) failedToInsert.getStackSize(), false); + } + } + } + } + } else { + final IAEItemStack input = AEItemStack.fromItemStack(player.getHeldItem(hand)); + final IAEItemStack failedToInsert = Platform.poweredInsert(energy, cell, input, + new PlayerSource(player, this)); + player.setHeldItem(hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack()); + } + } catch (final GridAccessException e) { + // :P + } + } - for( int x = 0; x < inv.getSlots(); x++ ) - { - final ItemStack targetStack = inv.getStackInSlot( x ); - if( input.equals( targetStack ) ) - { - final ItemStack canExtract = inv.extractItem( x, targetStack.getCount(), true ); - if( !canExtract.isEmpty() ) - { - input.setStackSize( canExtract.getCount() ); - final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) ); - inv.extractItem( x, - failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(), - false ); - } - } - } - } - } - else - { - final IAEItemStack input = AEItemStack.fromItemStack( player.getHeldItem( hand ) ); - final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) ); - player.setHeldItem( hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } + private void extractItem(final PlayerEntity player, int count) { + final IAEItemStack input = this.getDisplayed(); + if (input != null) { + try { + if (!this.getProxy().isActive()) { + return; + } - private void extractItem( final PlayerEntity player, int count ) - { - final IAEItemStack input = this.getDisplayed(); - if( input != null ) - { - try - { - if( !this.getProxy().isActive() ) - { - return; - } + final IEnergySource energy = this.getProxy().getEnergy(); + final IMEMonitor cell = this.getProxy().getStorage() + .getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); - final IEnergySource energy = this.getProxy().getEnergy(); - final IMEMonitor cell = this.getProxy() - .getStorage() - .getInventory( - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); + input.setStackSize(count); - input.setStackSize( count ); + final IAEItemStack retrieved = Platform.poweredExtraction(energy, cell, input, + new PlayerSource(player, this)); + if (retrieved != null) { + ItemStack newItems = retrieved.createItemStack(); + final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player); + newItems = adaptor.addItems(newItems); + if (!newItems.isEmpty()) { + final TileEntity te = this.getTile(); + final List list = Collections.singletonList(newItems); + Platform.spawnDrops(player.world, te.getPos().offset(this.getSide().getFacing()), list); + } - final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) ); - if( retrieved != null ) - { - ItemStack newItems = retrieved.createItemStack(); - final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player ); - newItems = adaptor.addItems( newItems ); - if( !newItems.isEmpty() ) - { - final TileEntity te = this.getTile(); - final List list = Collections.singletonList( newItems ); - Platform.spawnDrops( player.world, te.getPos().offset( this.getSide().getFacing() ), list ); - } + if (player.openContainer != null) { + player.openContainer.detectAndSendChanges(); + } + } + } catch (final GridAccessException e) { + // :P + } + } + } - if( player.openContainer != null ) - { - player.openContainer.detectAndSendChanges(); - } - } - } - catch( final GridAccessException e ) - { - // :P - } - } - } - - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL, - MODELS_LOCKED_OFF, MODELS_LOCKED_ON, MODELS_LOCKED_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL, MODELS_LOCKED_OFF, MODELS_LOCKED_ON, + MODELS_LOCKED_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java index 6027b2b18..ddc9e43ed 100644 --- a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java @@ -18,14 +18,8 @@ package appeng.parts.reporting; - import java.util.List; -import appeng.api.config.SecurityPermissions; -import appeng.api.networking.security.IActionHost; -import appeng.container.implementations.ContainerCraftingTerm; -import appeng.container.implementations.ContainerMEMonitorable; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -33,87 +27,78 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandler; +import appeng.api.config.SecurityPermissions; +import appeng.api.networking.security.IActionHost; import appeng.api.parts.IPartModel; +import appeng.container.implementations.ContainerCraftingTerm; +import appeng.container.implementations.ContainerMEMonitorable; import appeng.core.AppEng; - import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; import appeng.tile.inventory.AppEngInternalInventory; +import appeng.util.Platform; +public class PartCraftingTerminal extends AbstractPartTerminal { -public class PartCraftingTerminal extends AbstractPartTerminal -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/crafting_terminal_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/crafting_terminal_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/crafting_terminal_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/crafting_terminal_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory(this, 9); - private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 ); + @Reflected + public PartCraftingTerminal(final ItemStack is) { + super(is); + } - @Reflected - public PartCraftingTerminal( final ItemStack is ) - { - super( is ); - } + @Override + public void getDrops(final List drops, final boolean wrenched) { + super.getDrops(drops, wrenched); - @Override - public void getDrops( final List drops, final boolean wrenched ) - { - super.getDrops( drops, wrenched ); + for (final ItemStack is : this.craftingGrid) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } - for( final ItemStack is : this.craftingGrid ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.craftingGrid.readFromNBT(data, "craftingGrid"); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.craftingGrid.readFromNBT( data, "craftingGrid" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + this.craftingGrid.writeToNBT(data, "craftingGrid"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - this.craftingGrid.writeToNBT( data, "craftingGrid" ); - } + @Override + public ContainerType getContainerType(final PlayerEntity p) { + if (Platform.checkPermissions(p, this, SecurityPermissions.CRAFT, false)) { + return ContainerCraftingTerm.TYPE; + } + return ContainerMEMonitorable.TYPE; + } - @Override - public ContainerType getContainerType(final PlayerEntity p ) - { - if( Platform.checkPermissions( p, this, SecurityPermissions.CRAFT, false) ) - { - return ContainerCraftingTerm.TYPE; - } - return ContainerMEMonitorable.TYPE; - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("crafting")) { + return this.craftingGrid; + } + return super.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "crafting" ) ) - { - return this.craftingGrid; - } - return super.getInventoryByName( name ); - } - - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/parts/reporting/PartDarkPanel.java b/src/main/java/appeng/parts/reporting/PartDarkPanel.java index 268a0684a..2cf2e2db8 100644 --- a/src/main/java/appeng/parts/reporting/PartDarkPanel.java +++ b/src/main/java/appeng/parts/reporting/PartDarkPanel.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,34 +27,29 @@ import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartDarkPanel extends AbstractPartPanel { -public class PartDarkPanel extends AbstractPartPanel -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/monitor_dark_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/monitor_dark_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_dark_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_dark_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON ); + @Reflected + public PartDarkPanel(final ItemStack is) { + super(is); + } - @Reflected - public PartDarkPanel( final ItemStack is ) - { - super( is ); - } + @Override + protected int getBrightnessColor() { + return this.getColor().mediumVariant; + } - @Override - protected int getBrightnessColor() - { - return this.getColor().mediumVariant; - } - - @Override - public IPartModel getStaticModels() - { - return this.isPowered() ? MODELS_ON : MODELS_OFF; - } + @Override + public IPartModel getStaticModels() { + return this.isPowered() ? MODELS_ON : MODELS_OFF; + } } diff --git a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java index 026a9faf6..2fe258146 100644 --- a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java @@ -18,11 +18,6 @@ package appeng.parts.reporting; - -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.ContainerInscriber; -import appeng.container.implementations.ContainerInterfaceTerminal; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; @@ -30,47 +25,43 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; import appeng.api.parts.IPartModel; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.ContainerInscriber; +import appeng.container.implementations.ContainerInterfaceTerminal; import appeng.core.AppEng; - import appeng.items.parts.PartModels; import appeng.parts.PartModel; import appeng.util.Platform; +public class PartInterfaceTerminal extends AbstractPartDisplay { -public class PartInterfaceTerminal extends AbstractPartDisplay -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/interface_terminal_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/interface_terminal_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/interface_terminal_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/interface_terminal_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + public PartInterfaceTerminal(final ItemStack is) { + super(is); + } - public PartInterfaceTerminal( final ItemStack is ) - { - super( is ); - } + @Override + public boolean onPartActivate(final PlayerEntity player, final Hand hand, final Vec3d pos) { + if (!super.onPartActivate(player, hand, pos)) { + if (Platform.isServer()) { + ContainerOpener.openContainer(ContainerInterfaceTerminal.TYPE, player, ContainerLocator.forPart(this)); + } + } + return true; + } - @Override - public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos ) - { - if( !super.onPartActivate( player, hand, pos ) ) - { - if( Platform.isServer() ) - { - ContainerOpener.openContainer(ContainerInterfaceTerminal.TYPE, player, ContainerLocator.forPart(this)); - } - } - return true; - } - - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/parts/reporting/PartPanel.java b/src/main/java/appeng/parts/reporting/PartPanel.java index 78410476f..5b6f12307 100644 --- a/src/main/java/appeng/parts/reporting/PartPanel.java +++ b/src/main/java/appeng/parts/reporting/PartPanel.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,34 +27,29 @@ import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartPanel extends AbstractPartPanel { -public class PartPanel extends AbstractPartPanel -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/monitor_bright_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/monitor_bright_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_bright_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_bright_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON ); + @Reflected + public PartPanel(final ItemStack is) { + super(is); + } - @Reflected - public PartPanel( final ItemStack is ) - { - super( is ); - } + @Override + protected int getBrightnessColor() { + return this.getColor().whiteVariant; + } - @Override - protected int getBrightnessColor() - { - return this.getColor().whiteVariant; - } - - @Override - public IPartModel getStaticModels() - { - return this.isPowered() ? MODELS_ON : MODELS_OFF; - } + @Override + public IPartModel getStaticModels() { + return this.isPowered() ? MODELS_ON : MODELS_OFF; + } } diff --git a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java index c13e1a77a..7d367e5b0 100644 --- a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java @@ -18,13 +18,8 @@ package appeng.parts.reporting; - import java.util.List; -import appeng.api.config.SecurityPermissions; -import appeng.container.implementations.ContainerMEMonitorable; -import appeng.container.implementations.ContainerPatternTerm; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; @@ -32,185 +27,159 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandler; +import appeng.api.config.SecurityPermissions; import appeng.api.implementations.ICraftingPatternItem; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.parts.IPartModel; import appeng.api.storage.data.IAEItemStack; +import appeng.container.implementations.ContainerMEMonitorable; +import appeng.container.implementations.ContainerPatternTerm; import appeng.core.AppEng; - import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; import appeng.tile.inventory.AppEngInternalInventory; +import appeng.util.Platform; import appeng.util.inv.InvOperation; +public class PartPatternTerminal extends AbstractPartTerminal { -public class PartPatternTerminal extends AbstractPartTerminal -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/pattern_terminal_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/pattern_terminal_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/pattern_terminal_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/pattern_terminal_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + 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 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; + private boolean substitute = false; - private boolean craftingMode = true; - private boolean substitute = false; + @Reflected + public PartPatternTerminal(final ItemStack is) { + super(is); + } - @Reflected - public PartPatternTerminal( final ItemStack is ) - { - super( is ); - } + @Override + public void getDrops(final List drops, final boolean wrenched) { + for (final ItemStack is : this.pattern) { + if (!is.isEmpty()) { + drops.add(is); + } + } + } - @Override - public void getDrops( final List drops, final boolean wrenched ) - { - for( final ItemStack is : this.pattern ) - { - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + @Override + public void readFromNBT(final CompoundNBT data) { + super.readFromNBT(data); + this.setCraftingRecipe(data.getBoolean("craftingMode")); + this.setSubstitution(data.getBoolean("substitute")); + this.pattern.readFromNBT(data, "pattern"); + this.output.readFromNBT(data, "outputList"); + this.crafting.readFromNBT(data, "craftingGrid"); + } - @Override - public void readFromNBT( final CompoundNBT data ) - { - super.readFromNBT( data ); - this.setCraftingRecipe( data.getBoolean( "craftingMode" ) ); - this.setSubstitution( data.getBoolean( "substitute" ) ); - this.pattern.readFromNBT( data, "pattern" ); - this.output.readFromNBT( data, "outputList" ); - this.crafting.readFromNBT( data, "craftingGrid" ); - } + @Override + public void writeToNBT(final CompoundNBT data) { + super.writeToNBT(data); + data.putBoolean("craftingMode", this.craftingMode); + data.putBoolean("substitute", this.substitute); + this.pattern.writeToNBT(data, "pattern"); + this.output.writeToNBT(data, "outputList"); + this.crafting.writeToNBT(data, "craftingGrid"); + } - @Override - public void writeToNBT( final CompoundNBT data ) - { - super.writeToNBT( data ); - data.putBoolean("craftingMode", this.craftingMode); - data.putBoolean("substitute", this.substitute); - this.pattern.writeToNBT( data, "pattern" ); - this.output.writeToNBT( data, "outputList" ); - this.crafting.writeToNBT( data, "craftingGrid" ); - } + @Override + public ContainerType getContainerType(final PlayerEntity p) { + if (Platform.checkPermissions(p, this, SecurityPermissions.CRAFT, false)) { + return ContainerPatternTerm.TYPE; + } + return ContainerMEMonitorable.TYPE; + } - @Override - public ContainerType getContainerType(final PlayerEntity p ) - { - if(Platform.checkPermissions(p, this, SecurityPermissions.CRAFT, false) ) - { - return ContainerPatternTerm.TYPE; - } - return ContainerMEMonitorable.TYPE; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + if (inv == this.pattern && slot == 1) { + final ItemStack is = this.pattern.getStackInSlot(1); + if (!is.isEmpty() && is.getItem() instanceof ICraftingPatternItem) { + final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); + final ICraftingPatternDetails details = pattern.getPatternForItem(is, + this.getHost().getTile().getWorld()); + if (details != null) { + this.setCraftingRecipe(details.isCraftable()); + this.setSubstitution(details.canSubstitute()); - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - if( inv == this.pattern && slot == 1 ) - { - final ItemStack is = this.pattern.getStackInSlot( 1 ); - if( !is.isEmpty() && is.getItem() instanceof ICraftingPatternItem ) - { - final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); - final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() ); - if( details != null ) - { - this.setCraftingRecipe( details.isCraftable() ); - this.setSubstitution( details.canSubstitute() ); + for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) { + final IAEItemStack item = details.getInputs()[x]; + this.crafting.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack()); + } - for( int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++ ) - { - final IAEItemStack item = details.getInputs()[x]; - this.crafting.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() ); - } + for (int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++) { + final IAEItemStack item = details.getOutputs()[x]; + this.output.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack()); + } + } + } + } else if (inv == this.crafting) { + this.fixCraftingRecipes(); + } - for( int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++ ) - { - final IAEItemStack item = details.getOutputs()[x]; - this.output.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() ); - } - } - } - } - else if( inv == this.crafting ) - { - this.fixCraftingRecipes(); - } + this.getHost().markForSave(); + } - this.getHost().markForSave(); - } + private void fixCraftingRecipes() { + if (this.craftingMode) { + for (int x = 0; x < this.crafting.getSlots(); x++) { + final ItemStack is = this.crafting.getStackInSlot(x); + if (!is.isEmpty()) { + is.setCount(1); + } + } + } + } - private void fixCraftingRecipes() - { - if( this.craftingMode ) - { - for( int x = 0; x < this.crafting.getSlots(); x++ ) - { - final ItemStack is = this.crafting.getStackInSlot( x ); - if( !is.isEmpty() ) - { - is.setCount( 1 ); - } - } - } - } + public boolean isCraftingRecipe() { + return this.craftingMode; + } - public boolean isCraftingRecipe() - { - return this.craftingMode; - } + public void setCraftingRecipe(final boolean craftingMode) { + this.craftingMode = craftingMode; + this.fixCraftingRecipes(); + } - public void setCraftingRecipe( final boolean craftingMode ) - { - this.craftingMode = craftingMode; - this.fixCraftingRecipes(); - } + public boolean isSubstitution() { + return this.substitute; + } - public boolean isSubstitution() - { - return this.substitute; - } + public void setSubstitution(final boolean canSubstitute) { + this.substitute = canSubstitute; + } - public void setSubstitution( final boolean canSubstitute ) - { - this.substitute = canSubstitute; - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("crafting")) { + return this.crafting; + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "crafting" ) ) - { - return this.crafting; - } + if (name.equals("output")) { + return this.output; + } - if( name.equals( "output" ) ) - { - return this.output; - } + if (name.equals("pattern")) { + return this.pattern; + } - if( name.equals( "pattern" ) ) - { - return this.pattern; - } + return super.getInventoryByName(name); + } - return super.getInventoryByName( name ); - } - - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java b/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java index 0a6f3d0ef..ab535f1db 100644 --- a/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java +++ b/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,35 +27,32 @@ import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartSemiDarkPanel extends AbstractPartPanel { + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/monitor_medium_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/monitor_medium_on"); -public class PartSemiDarkPanel extends AbstractPartPanel -{ - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/monitor_medium_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/monitor_medium_on" ); + public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON); - public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON ); + @Reflected + public PartSemiDarkPanel(final ItemStack is) { + super(is); + } - @Reflected - public PartSemiDarkPanel( final ItemStack is ) - { - super( is ); - } + @Override + protected int getBrightnessColor() { + final int light = this.getColor().whiteVariant; + final int dark = this.getColor().mediumVariant; + return (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) + | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8) + | ((((light) & 0xff) + ((dark) & 0xff)) / 2); + } - @Override - protected int getBrightnessColor() - { - final int light = this.getColor().whiteVariant; - final int dark = this.getColor().mediumVariant; - return ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ); - } - - @Override - public IPartModel getStaticModels() - { - return this.isPowered() ? MODELS_ON : MODELS_OFF; - } + @Override + public IPartModel getStaticModels() { + return this.isPowered() ? MODELS_ON : MODELS_OFF; + } } diff --git a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java index 06d1fd604..688821920 100644 --- a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -28,43 +27,42 @@ import appeng.helpers.Reflected; import appeng.items.parts.PartModels; import appeng.parts.PartModel; - /** * @author AlgorithmX2 * @author thatsIch * @version rv2 * @since rv0 */ -public class PartStorageMonitor extends AbstractPartMonitor -{ +public class PartStorageMonitor extends AbstractPartMonitor { - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_on" ); - @PartModels - public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_locked_off" ); - @PartModels - public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation( AppEng.MOD_ID, "part/storage_monitor_locked_on" ); + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/storage_monitor_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/storage_monitor_on"); + @PartModels + public static final ResourceLocation MODEL_LOCKED_OFF = new ResourceLocation(AppEng.MOD_ID, + "part/storage_monitor_locked_off"); + @PartModels + public static final ResourceLocation MODEL_LOCKED_ON = new ResourceLocation(AppEng.MOD_ID, + "part/storage_monitor_locked_on"); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_LOCKED_OFF = new PartModel( MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_LOCKED_ON = new PartModel( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_LOCKED_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_HAS_CHANNEL ); + public static final IPartModel MODELS_LOCKED_OFF = new PartModel(MODEL_BASE, MODEL_LOCKED_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_LOCKED_ON = new PartModel(MODEL_BASE, MODEL_LOCKED_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_LOCKED_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_LOCKED_ON, + MODEL_STATUS_HAS_CHANNEL); - @Reflected - public PartStorageMonitor( final ItemStack is ) - { - super( is ); - } + @Reflected + public PartStorageMonitor(final ItemStack is) { + super(is); + } - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL, - MODELS_LOCKED_OFF, MODELS_LOCKED_ON, MODELS_LOCKED_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL, MODELS_LOCKED_OFF, MODELS_LOCKED_ON, + MODELS_LOCKED_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/parts/reporting/PartTerminal.java b/src/main/java/appeng/parts/reporting/PartTerminal.java index cc582b1a5..8b5958ece 100644 --- a/src/main/java/appeng/parts/reporting/PartTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartTerminal.java @@ -18,7 +18,6 @@ package appeng.parts.reporting; - import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -27,27 +26,23 @@ import appeng.core.AppEng; import appeng.items.parts.PartModels; import appeng.parts.PartModel; +public class PartTerminal extends AbstractPartTerminal { -public class PartTerminal extends AbstractPartTerminal -{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation(AppEng.MOD_ID, "part/terminal_off"); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation(AppEng.MOD_ID, "part/terminal_on"); - @PartModels - public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/terminal_off" ); - @PartModels - public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/terminal_on" ); + public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF); + public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_ON); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL); - public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); - public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); - public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + public PartTerminal(final ItemStack is) { + super(is); + } - public PartTerminal( final ItemStack is ) - { - super( is ); - } - - @Override - public IPartModel getStaticModels() - { - return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); - } + @Override + public IPartModel getStaticModels() { + return this.selectModel(MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL); + } } diff --git a/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java b/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java index d4512bfeb..a62964b03 100644 --- a/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java +++ b/src/main/java/appeng/recipes/conditions/FeaturesEnabled.java @@ -18,114 +18,95 @@ package appeng.recipes.conditions; - -import appeng.core.AEConfig; -import appeng.core.AppEng; -import appeng.api.features.AEFeature; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.crafting.conditions.ICondition; -import net.minecraftforge.common.crafting.conditions.IConditionSerializer; - import java.util.Arrays; import java.util.Locale; import java.util.Set; import java.util.stream.StreamSupport; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; -public class FeaturesEnabled implements ICondition -{ - private static final ResourceLocation NAME = new ResourceLocation( AppEng.MOD_ID, "feature" ); - private final AEFeature[] features; +import net.minecraft.util.JSONUtils; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.crafting.conditions.ICondition; +import net.minecraftforge.common.crafting.conditions.IConditionSerializer; - public FeaturesEnabled( AEFeature... features ) - { - this.features = features; - } +import appeng.api.features.AEFeature; +import appeng.core.AEConfig; +import appeng.core.AppEng; - public FeaturesEnabled( Set features ) { - this(features.toArray(new AEFeature[0])); - } +public class FeaturesEnabled implements ICondition { + private static final ResourceLocation NAME = new ResourceLocation(AppEng.MOD_ID, "feature"); + private final AEFeature[] features; - @Override - public ResourceLocation getID() - { - return NAME; - } + public FeaturesEnabled(AEFeature... features) { + this.features = features; + } - @Override - public boolean test() - { - for( AEFeature feature : features ) - { - if( !AEConfig.instance().isFeatureEnabled( feature ) ) - { - return false; - } - } + public FeaturesEnabled(Set features) { + this(features.toArray(new AEFeature[0])); + } - return true; - } + @Override + public ResourceLocation getID() { + return NAME; + } - public static class Serializer implements IConditionSerializer - { - private static final String JSON_FEATURES_KEY = "features"; + @Override + public boolean test() { + for (AEFeature feature : features) { + if (!AEConfig.instance().isFeatureEnabled(feature)) { + return false; + } + } - public static final Serializer INSTANCE = new Serializer(); + return true; + } - private Serializer() - { - } + public static class Serializer implements IConditionSerializer { + private static final String JSON_FEATURES_KEY = "features"; - @Override - public void write( JsonObject json, FeaturesEnabled value ) - { - json.add( JSON_FEATURES_KEY, Arrays.stream( value.features ) - .map( AEFeature::toString ) - .reduce( new JsonArray(), ( JsonArray array, String string ) -> { - array.add( string ); - return array; - }, ( a, b ) -> b ) ); - } + public static final Serializer INSTANCE = new Serializer(); - @Override - public FeaturesEnabled read( JsonObject jsonObject ) - { - AEFeature[] features; + private Serializer() { + } - if( JSONUtils.isJsonArray( jsonObject, JSON_FEATURES_KEY ) ) - { - final JsonArray featuresArray = JSONUtils.getJsonArray( jsonObject, JSON_FEATURES_KEY ); + @Override + public void write(JsonObject json, FeaturesEnabled value) { + json.add(JSON_FEATURES_KEY, Arrays.stream(value.features).map(AEFeature::toString).reduce(new JsonArray(), + (JsonArray array, String string) -> { + array.add(string); + return array; + }, (a, b) -> b)); + } - features = StreamSupport.stream( featuresArray.spliterator(), false ) - .filter( JsonElement::isJsonPrimitive ) - .map( JsonElement::getAsString ) - .map( s -> s.toUpperCase( Locale.ENGLISH ) ) - .map( AEFeature::valueOf ) - .toArray( AEFeature[]::new ); - } - else if( JSONUtils.isString( jsonObject, JSON_FEATURES_KEY ) ) - { - final String featureName = JSONUtils.getString( jsonObject, JSON_FEATURES_KEY ).toUpperCase( Locale.ENGLISH ); - features = new AEFeature[] { AEFeature.valueOf( featureName ) }; - } - else - { - features = new AEFeature[] {}; - } + @Override + public FeaturesEnabled read(JsonObject jsonObject) { + AEFeature[] features; - return new FeaturesEnabled( features ); - } + if (JSONUtils.isJsonArray(jsonObject, JSON_FEATURES_KEY)) { + final JsonArray featuresArray = JSONUtils.getJsonArray(jsonObject, JSON_FEATURES_KEY); - @Override - public ResourceLocation getID() - { - return NAME; - } + features = StreamSupport.stream(featuresArray.spliterator(), false).filter(JsonElement::isJsonPrimitive) + .map(JsonElement::getAsString).map(s -> s.toUpperCase(Locale.ENGLISH)).map(AEFeature::valueOf) + .toArray(AEFeature[]::new); + } else if (JSONUtils.isString(jsonObject, JSON_FEATURES_KEY)) { + final String featureName = JSONUtils.getString(jsonObject, JSON_FEATURES_KEY) + .toUpperCase(Locale.ENGLISH); + features = new AEFeature[] { AEFeature.valueOf(featureName) }; + } else { + features = new AEFeature[] {}; + } - } + return new FeaturesEnabled(features); + } + + @Override + public ResourceLocation getID() { + return NAME; + } + + } } \ No newline at end of file diff --git a/src/main/java/appeng/recipes/game/DisassembleRecipe.java b/src/main/java/appeng/recipes/game/DisassembleRecipe.java index b2edcc2f7..a07411c40 100644 --- a/src/main/java/appeng/recipes/game/DisassembleRecipe.java +++ b/src/main/java/appeng/recipes/game/DisassembleRecipe.java @@ -18,14 +18,12 @@ package appeng.recipes.game; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import javax.annotation.Nonnull; -import appeng.api.AEApi; -import appeng.api.definitions.*; -import appeng.api.storage.IMEInventory; -import appeng.api.storage.channels.IItemStorageChannel; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.core.AppEng; import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -35,152 +33,132 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import javax.annotation.Nonnull; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; +import appeng.api.AEApi; +import appeng.api.definitions.*; +import appeng.api.storage.IMEInventory; +import appeng.api.storage.channels.IItemStorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; +import appeng.core.AppEng; +public final class DisassembleRecipe extends SpecialRecipe { + public static final IRecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>( + DisassembleRecipe::new); -public final class DisassembleRecipe extends SpecialRecipe -{ - public static final IRecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>( DisassembleRecipe::new ); + static { + SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "disassemble_recipe")); + } - static - { - SERIALIZER.setRegistryName( new ResourceLocation( AppEng.MOD_ID, "disassemble_recipe" ) ); - } + private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY; - private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY; + private final Map cellMappings; + private final Map nonCellMappings; - private final Map cellMappings; - private final Map nonCellMappings; + public DisassembleRecipe(ResourceLocation id) { + super(id); - public DisassembleRecipe( ResourceLocation id ) - { - super( id ); + final IDefinitions definitions = AEApi.instance().definitions(); + final IBlocks blocks = definitions.blocks(); + final IItems items = definitions.items(); + final IMaterials mats = definitions.materials(); - final IDefinitions definitions = AEApi.instance().definitions(); - final IBlocks blocks = definitions.blocks(); - final IItems items = definitions.items(); - final IMaterials mats = definitions.materials(); + this.cellMappings = new HashMap<>(4); + this.nonCellMappings = new HashMap<>(5); - this.cellMappings = new HashMap<>( 4 ); - this.nonCellMappings = new HashMap<>( 5 ); + this.cellMappings.put(items.cell1k(), mats.cell1kPart()); + this.cellMappings.put(items.cell4k(), mats.cell4kPart()); + this.cellMappings.put(items.cell16k(), mats.cell16kPart()); + this.cellMappings.put(items.cell64k(), mats.cell64kPart()); - this.cellMappings.put( items.cell1k(), mats.cell1kPart() ); - this.cellMappings.put( items.cell4k(), mats.cell4kPart() ); - this.cellMappings.put( items.cell16k(), mats.cell16kPart() ); - this.cellMappings.put( items.cell64k(), mats.cell64kPart() ); + this.nonCellMappings.put(items.encodedPattern(), mats.blankPattern()); + this.nonCellMappings.put(blocks.craftingStorage1k(), mats.cell1kPart()); + this.nonCellMappings.put(blocks.craftingStorage4k(), mats.cell4kPart()); + this.nonCellMappings.put(blocks.craftingStorage16k(), mats.cell16kPart()); + this.nonCellMappings.put(blocks.craftingStorage64k(), mats.cell64kPart()); + } - this.nonCellMappings.put( items.encodedPattern(), mats.blankPattern() ); - this.nonCellMappings.put( blocks.craftingStorage1k(), mats.cell1kPart() ); - this.nonCellMappings.put( blocks.craftingStorage4k(), mats.cell4kPart() ); - this.nonCellMappings.put( blocks.craftingStorage16k(), mats.cell16kPart() ); - this.nonCellMappings.put( blocks.craftingStorage64k(), mats.cell64kPart() ); - } + @Override + public boolean matches(@Nonnull final CraftingInventory inv, @Nonnull final World w) { + return !this.getOutput(inv).isEmpty(); + } - @Override - public boolean matches( @Nonnull final CraftingInventory inv, @Nonnull final World w ) - { - return !this.getOutput( inv ).isEmpty(); - } + @Nonnull + private ItemStack getOutput(final IInventory inventory) { + int itemCount = 0; + ItemStack output = MISMATCHED_STACK; - @Nonnull - private ItemStack getOutput( final IInventory inventory ) - { - int itemCount = 0; - ItemStack output = MISMATCHED_STACK; + for (int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++) { + final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex); + if (!stackInSlot.isEmpty()) { + // needs a single input in the recipe + itemCount++; + if (itemCount > 1) { + return MISMATCHED_STACK; + } - for( int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++ ) - { - final ItemStack stackInSlot = inventory.getStackInSlot( slotIndex ); - if( !stackInSlot.isEmpty() ) - { - // needs a single input in the recipe - itemCount++; - if( itemCount > 1 ) - { - return MISMATCHED_STACK; - } + // handle storage cells + Optional maybeCellOutput = this.getCellOutput(stackInSlot); + if (maybeCellOutput.isPresent()) { + ItemStack storageCellStack = maybeCellOutput.get(); + // make sure the storage cell stackInSlot empty... + final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory( + stackInSlot, null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); + if (cellInv != null) { + final IItemList list = cellInv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + if (!list.isEmpty()) { + return ItemStack.EMPTY; + } + } - // handle storage cells - Optional maybeCellOutput = this.getCellOutput( stackInSlot ); - if( maybeCellOutput.isPresent() ) - { - ItemStack storageCellStack = maybeCellOutput.get(); - // make sure the storage cell stackInSlot empty... - final IMEInventory cellInv = AEApi.instance() - .registries() - .cell() - .getCellInventory( stackInSlot, null, - AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); - if( cellInv != null ) - { - final IItemList list = cellInv - .getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - if( !list.isEmpty() ) - { - return ItemStack.EMPTY; - } - } + output = storageCellStack; + } - output = storageCellStack; - } + // handle crafting storage blocks + output = this.getNonCellOutput(stackInSlot).orElse(output); + } + } - // handle crafting storage blocks - output = this.getNonCellOutput( stackInSlot ).orElse( output ); - } - } + return output; + } - return output; - } + @Nonnull + private Optional getCellOutput(final ItemStack compared) { + for (final Map.Entry entry : this.cellMappings.entrySet()) { + if (entry.getKey().isSameAs(compared)) { + return entry.getValue().maybeStack(1); + } + } - @Nonnull - private Optional getCellOutput( final ItemStack compared ) - { - for( final Map.Entry entry : this.cellMappings.entrySet() ) - { - if( entry.getKey().isSameAs( compared ) ) - { - return entry.getValue().maybeStack( 1 ); - } - } + return Optional.empty(); + } - return Optional.empty(); - } + @Nonnull + private Optional getNonCellOutput(final ItemStack compared) { + for (final Map.Entry entry : this.nonCellMappings.entrySet()) { + if (entry.getKey().isSameAs(compared)) { + return entry.getValue().maybeStack(1); + } + } - @Nonnull - private Optional getNonCellOutput( final ItemStack compared ) - { - for( final Map.Entry entry : this.nonCellMappings.entrySet() ) - { - if( entry.getKey().isSameAs( compared ) ) - { - return entry.getValue().maybeStack( 1 ); - } - } + return Optional.empty(); + } - return Optional.empty(); - } + @Nonnull + @Override + public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) { + return this.getOutput(inv); + } - @Nonnull - @Override - public ItemStack getCraftingResult( @Nonnull final CraftingInventory inv ) - { - return this.getOutput( inv ); - } + @Override + public boolean canFit(int i, int i1) { + return false; + } - @Override - public boolean canFit( int i, int i1 ) - { - return false; - } - - @Nonnull - @Override - public IRecipeSerializer getSerializer() - { - return SERIALIZER; - } + @Nonnull + @Override + public IRecipeSerializer getSerializer() { + return SERIALIZER; + } } \ 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 ee25fd147..8addc3f92 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -18,12 +18,8 @@ package appeng.recipes.game; +import javax.annotation.Nonnull; -import appeng.api.AEApi; -import appeng.api.definitions.IComparableDefinition; -import appeng.api.definitions.IDefinitions; -import appeng.core.AppEng; -import appeng.items.parts.ItemFacade; import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -33,78 +29,70 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import javax.annotation.Nonnull; +import appeng.api.AEApi; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IDefinitions; +import appeng.core.AppEng; +import appeng.items.parts.ItemFacade; +public final class FacadeRecipe extends SpecialRecipe { + public static SpecialRecipeSerializer SERIALIZER = null; -public final class FacadeRecipe extends SpecialRecipe -{ - public static SpecialRecipeSerializer SERIALIZER = null; + private final IComparableDefinition anchor; + private final ItemFacade facade; - private final IComparableDefinition anchor; - private final ItemFacade facade; + public FacadeRecipe(ResourceLocation id, ItemFacade facade) { + super(id); + this.facade = facade; + final IDefinitions definitions = AEApi.instance().definitions(); - public FacadeRecipe( ResourceLocation id, ItemFacade facade ) - { - super( id ); - this.facade = facade; - final IDefinitions definitions = AEApi.instance().definitions(); + this.anchor = definitions.parts().cableAnchor(); + } - this.anchor = definitions.parts().cableAnchor(); - } + @Override + public boolean matches(@Nonnull final CraftingInventory inv, @Nonnull final World w) { + return !this.getOutput(inv, false).isEmpty(); + } - @Override - public boolean matches( @Nonnull final CraftingInventory inv, @Nonnull final World w ) - { - return !this.getOutput( inv, false ).isEmpty(); - } + @Nonnull + private ItemStack getOutput(final IInventory inv, final boolean createFacade) { + if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(2).isEmpty() && inv.getStackInSlot(6).isEmpty() + && inv.getStackInSlot(8).isEmpty()) { + 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 ItemStack facades = this.facade.createFacadeForItem(inv.getStackInSlot(4), !createFacade); + if (!facades.isEmpty() && createFacade) { + facades.setCount(4); + } + return facades; + } + } - @Nonnull - private ItemStack getOutput( final IInventory inv, final boolean createFacade ) - { - if( inv.getStackInSlot( 0 ).isEmpty() && inv.getStackInSlot( 2 ).isEmpty() && inv.getStackInSlot( 6 ).isEmpty() && inv.getStackInSlot( 8 ).isEmpty() ) - { - 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 ItemStack facades = this.facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade ); - if( !facades.isEmpty() && createFacade ) - { - facades.setCount( 4 ); - } - return facades; - } - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) { + return this.getOutput(inv, true); + } - @Override - public ItemStack getCraftingResult( @Nonnull final CraftingInventory inv ) - { - return this.getOutput( inv, true ); - } + @Override + public boolean canFit(int i, int i1) { + return false; + } - @Override - public boolean canFit( int i, int i1 ) - { - return false; - } + @Nonnull + @Override + public IRecipeSerializer getSerializer() { + return getSerializer(facade); + } - @Nonnull - @Override - public IRecipeSerializer getSerializer() - { - return getSerializer( facade ); - } - - public static IRecipeSerializer getSerializer( ItemFacade facade ) - { - if( SERIALIZER == null ) - { - SERIALIZER = new SpecialRecipeSerializer<>( id -> new FacadeRecipe( id, facade ) ); - SERIALIZER.setRegistryName( new ResourceLocation( AppEng.MOD_ID, "facade_recipe" ) ); - } - return SERIALIZER; - } + public static IRecipeSerializer getSerializer(ItemFacade facade) { + if (SERIALIZER == null) { + SERIALIZER = new SpecialRecipeSerializer<>(id -> new FacadeRecipe(id, facade)); + SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "facade_recipe")); + } + return SERIALIZER; + } } \ No newline at end of file diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipe.java b/src/main/java/appeng/recipes/handlers/GrinderRecipe.java index 5d2089230..351ea412b 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipe.java +++ b/src/main/java/appeng/recipes/handlers/GrinderRecipe.java @@ -1,6 +1,9 @@ package appeng.recipes.handlers; +import java.util.List; + import com.google.common.collect.ImmutableList; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -11,8 +14,6 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import java.util.List; - public class GrinderRecipe implements IRecipe { public static IRecipeType TYPE; @@ -25,7 +26,8 @@ public class GrinderRecipe implements IRecipe { private final List optionalResults; private final int turns; - public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, int ingredientCount, ItemStack result, int turns, List optionalResults) { + public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, int ingredientCount, + ItemStack result, int turns, List optionalResults) { this.id = id; this.group = group; this.ingredient = ingredient; diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java b/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java index ba6ab2129..12e34d138 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java +++ b/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java @@ -1,10 +1,15 @@ package appeng.recipes.handlers; -import appeng.core.AEConfig; -import appeng.core.AppEng; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.Ingredient; @@ -14,12 +19,11 @@ import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistryEntry; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import appeng.core.AEConfig; +import appeng.core.AppEng; -public class GrinderRecipeSerializer extends ForgeRegistryEntry> implements IRecipeSerializer { +public class GrinderRecipeSerializer extends ForgeRegistryEntry> + implements IRecipeSerializer { public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer(); diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipes.java b/src/main/java/appeng/recipes/handlers/GrinderRecipes.java index 2b0481ed1..5ebe23a49 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipes.java +++ b/src/main/java/appeng/recipes/handlers/GrinderRecipes.java @@ -1,19 +1,20 @@ package appeng.recipes.handlers; +import javax.annotation.Nullable; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; -import javax.annotation.Nullable; - public final class GrinderRecipes { private GrinderRecipes() { } /** - * Search all available Grinder recipes for a recipe matching the given input or null; + * Search all available Grinder recipes for a recipe matching the given input or + * null; */ @Nullable public static GrinderRecipe findForInput(World world, ItemStack input) { @@ -27,7 +28,8 @@ public final class GrinderRecipes { } /** - * Checks if the given item stack is an ingredient in any grinder recipe, disregarding its current size. + * Checks if the given item stack is an ingredient in any grinder recipe, + * disregarding its current size. */ public static boolean isValidIngredient(World world, ItemStack stack) { for (IRecipe recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) { diff --git a/src/main/java/appeng/recipes/handlers/InscriberRecipe.java b/src/main/java/appeng/recipes/handlers/InscriberRecipe.java index d45036c2b..3cab16686 100644 --- a/src/main/java/appeng/recipes/handlers/InscriberRecipe.java +++ b/src/main/java/appeng/recipes/handlers/InscriberRecipe.java @@ -1,6 +1,7 @@ package appeng.recipes.handlers; -import appeng.api.features.InscriberProcessType; +import javax.annotation.Nullable; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -11,7 +12,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import javax.annotation.Nullable; +import appeng.api.features.InscriberProcessType; public class InscriberRecipe implements IRecipe { @@ -26,7 +27,8 @@ public class InscriberRecipe implements IRecipe { private ItemStack output; private InscriberProcessType processType; - public InscriberRecipe(ResourceLocation id, String group, Ingredient middleInput, ItemStack output, Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) { + public InscriberRecipe(ResourceLocation id, String group, Ingredient middleInput, ItemStack output, + Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) { this.id = id; this.group = group; this.middleInput = middleInput; diff --git a/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java b/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java index 78066b594..f75eb6211 100644 --- a/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java +++ b/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java @@ -1,8 +1,9 @@ package appeng.recipes.handlers; -import appeng.api.features.InscriberProcessType; -import appeng.core.AppEng; +import javax.annotation.Nullable; + import com.google.gson.JsonObject; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.Ingredient; @@ -12,9 +13,11 @@ import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistryEntry; -import javax.annotation.Nullable; +import appeng.api.features.InscriberProcessType; +import appeng.core.AppEng; -public class InscriberRecipeSerializer extends ForgeRegistryEntry> implements IRecipeSerializer { +public class InscriberRecipeSerializer extends ForgeRegistryEntry> + implements IRecipeSerializer { public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer(); @@ -26,7 +29,7 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry dispatcher) { @@ -41,8 +40,7 @@ public final class AECommand { private void add(LiteralArgumentBuilder builder, Commands subCommand) { - builder.then(literal(subCommand.name().toLowerCase()) - .requires(src -> src.hasPermissionLevel(subCommand.level)) + builder.then(literal(subCommand.name().toLowerCase()).requires(src -> src.hasPermissionLevel(subCommand.level)) .executes(ctx -> { subCommand.command.call(ServerLifecycleHooks.getCurrentServer(), new String[0], ctx.getSource()); return 1; diff --git a/src/main/java/appeng/server/AccessType.java b/src/main/java/appeng/server/AccessType.java index 0d45762ae..b1880e99e 100644 --- a/src/main/java/appeng/server/AccessType.java +++ b/src/main/java/appeng/server/AccessType.java @@ -18,36 +18,34 @@ package appeng.server; +public enum AccessType { + /** + * allows basic access to manipulate the block via gui, or other. + */ + BLOCK_ACCESS, -public enum AccessType -{ - /** - * allows basic access to manipulate the block via gui, or other. - */ - BLOCK_ACCESS, + /** + * Can player deposit items into the network. + */ + NETWORK_DEPOSIT, - /** - * Can player deposit items into the network. - */ - NETWORK_DEPOSIT, + /** + * can player withdraw items from the network. + */ + NETWORK_WITHDRAW, - /** - * can player withdraw items from the network. - */ - NETWORK_WITHDRAW, + /** + * can player issue crafting requests? + */ + NETWORK_CRAFT, - /** - * can player issue crafting requests? - */ - NETWORK_CRAFT, + /** + * can player add new blocks to the network. + */ + NETWORK_BUILD, - /** - * can player add new blocks to the network. - */ - NETWORK_BUILD, - - /** - * can player manipulate security settings. - */ - NETWORK_SECURITY + /** + * can player manipulate security settings. + */ + NETWORK_SECURITY } diff --git a/src/main/java/appeng/server/Commands.java b/src/main/java/appeng/server/Commands.java index c80e88813..c33d3fcb6 100644 --- a/src/main/java/appeng/server/Commands.java +++ b/src/main/java/appeng/server/Commands.java @@ -18,28 +18,23 @@ package appeng.server; - import appeng.server.subcommands.ChunkLogger; import appeng.server.subcommands.Supporters; +public enum Commands { + Chunklogger(4, new ChunkLogger()), Supporters(0, new Supporters()); -public enum Commands -{ - Chunklogger( 4, new ChunkLogger() ), Supporters( 0, new Supporters() ); + public final int level; + public final ISubCommand command; - public final int level; - public final ISubCommand command; + Commands(final int level, final ISubCommand w) { + this.level = level; + this.command = w; + } - Commands( final int level, final ISubCommand w ) - { - this.level = level; - this.command = w; - } - - @Override - public String toString() - { - return this.name(); - } + @Override + public String toString() { + return this.name(); + } } diff --git a/src/main/java/appeng/server/ISubCommand.java b/src/main/java/appeng/server/ISubCommand.java index bbbe45735..6d3bc62e3 100644 --- a/src/main/java/appeng/server/ISubCommand.java +++ b/src/main/java/appeng/server/ISubCommand.java @@ -18,16 +18,12 @@ package appeng.server; - -import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource; import net.minecraft.server.MinecraftServer; +public interface ISubCommand { -public interface ISubCommand -{ + String getHelp(MinecraftServer srv); - String getHelp( MinecraftServer srv ); - - void call( MinecraftServer srv, String[] args, CommandSource sender ); + void call(MinecraftServer srv, String[] args, CommandSource sender); } diff --git a/src/main/java/appeng/server/ServerHelper.java b/src/main/java/appeng/server/ServerHelper.java index b3891b564..ce405871b 100644 --- a/src/main/java/appeng/server/ServerHelper.java +++ b/src/main/java/appeng/server/ServerHelper.java @@ -18,13 +18,10 @@ package appeng.server; - import java.util.ArrayList; import java.util.List; import java.util.Random; -import appeng.core.sync.network.NetworkHandler; -import appeng.items.tools.ToolNetworkTool; import net.minecraft.client.util.InputMappings; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -43,137 +40,115 @@ import appeng.client.ActionKey; import appeng.client.EffectType; import appeng.core.CommonHelper; import appeng.core.sync.AppEngPacket; +import appeng.core.sync.network.NetworkHandler; +import appeng.items.tools.ToolNetworkTool; import appeng.util.Platform; +public class ServerHelper extends CommonHelper { -public class ServerHelper extends CommonHelper -{ + private PlayerEntity renderModeBased; - private PlayerEntity renderModeBased; + @Override + public World getWorld() { + throw new UnsupportedOperationException("This is a server..."); + } - @Override - public World getWorld() - { - throw new UnsupportedOperationException( "This is a server..." ); - } + @Override + public void bindTileEntitySpecialRenderer(final Class tile, final AEBaseBlock blk) { + throw new UnsupportedOperationException("This is a server..."); + } - @Override - public void bindTileEntitySpecialRenderer( final Class tile, final AEBaseBlock blk ) - { - throw new UnsupportedOperationException( "This is a server..." ); - } + @Override + public List getPlayers() { + if (!Platform.isClient()) { + final MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - @Override - public List getPlayers() - { - if( !Platform.isClient() ) - { - final MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); + if (server != null) { + return server.getPlayerList().getPlayers(); + } + } - if( server != null ) - { - return server.getPlayerList().getPlayers(); - } - } + return new ArrayList<>(); + } - return new ArrayList<>(); - } + @Override + public void sendToAllNearExcept(final PlayerEntity p, final double x, final double y, final double z, + final double dist, final World w, final AppEngPacket packet) { + if (Platform.isClient()) { + return; + } + for (final PlayerEntity o : this.getPlayers()) { + final ServerPlayerEntity entityplayermp = (ServerPlayerEntity) o; + if (entityplayermp != p && entityplayermp.world == w) { + final double dX = x - entityplayermp.getPosX(); + final double dY = y - entityplayermp.getPosY(); + final double dZ = z - entityplayermp.getPosZ(); + if (dX * dX + dY * dY + dZ * dZ < dist * dist) { + NetworkHandler.instance().sendTo(packet, entityplayermp); + } + } + } + } - @Override - public void sendToAllNearExcept( final PlayerEntity p, final double x, final double y, final double z, final double dist, final World w, final AppEngPacket packet ) - { - if( Platform.isClient() ) - { - return; - } - for( final PlayerEntity o : this.getPlayers() ) - { - final ServerPlayerEntity entityplayermp = (ServerPlayerEntity) o; - if( entityplayermp != p && entityplayermp.world == w ) - { - final double dX = x - entityplayermp.getPosX(); - final double dY = y - entityplayermp.getPosY(); - final double dZ = z - entityplayermp.getPosZ(); - if( dX * dX + dY * dY + dZ * dZ < dist * dist ) - { - NetworkHandler.instance().sendTo( packet, entityplayermp ); - } - } - } - } + @Override + public void spawnEffect(final EffectType type, final World world, final double posX, final double posY, + final double posZ, final Object o) { + // :P + } - @Override - public void spawnEffect( final EffectType type, final World world, final double posX, final double posY, final double posZ, final Object o ) - { - // :P - } + @Override + public boolean shouldAddParticles(final Random r) { + return false; + } - @Override - public boolean shouldAddParticles( final Random r ) - { - return false; - } + @Override + public RayTraceResult getRTR() { + return null; + } - @Override - public RayTraceResult getRTR() - { - return null; - } + @Override + public void postInit() { - @Override - public void postInit() - { + } - } + @Override + public CableRenderMode getRenderMode() { + if (this.renderModeBased == null) { + return CableRenderMode.STANDARD; + } - @Override - public CableRenderMode getRenderMode() - { - if( this.renderModeBased == null ) - { - return CableRenderMode.STANDARD; - } + return this.renderModeForPlayer(this.renderModeBased); + } - return this.renderModeForPlayer( this.renderModeBased ); - } + @Override + public void triggerUpdates() { - @Override - public void triggerUpdates() - { + } - } + @Override + public void updateRenderMode(final PlayerEntity player) { + this.renderModeBased = player; + } - @Override - public void updateRenderMode( final PlayerEntity player ) - { - this.renderModeBased = player; - } + protected CableRenderMode renderModeForPlayer(final PlayerEntity player) { + if (player != null) { + for (int x = 0; x < PlayerInventory.getHotbarSize(); x++) { + final ItemStack is = player.inventory.getStackInSlot(x); - protected CableRenderMode renderModeForPlayer( final PlayerEntity player ) - { - if( player != null ) - { - for(int x = 0; x < PlayerInventory.getHotbarSize(); x++ ) - { - final ItemStack is = player.inventory.getStackInSlot( x ); + if (!is.isEmpty() && is.getItem() instanceof ToolNetworkTool) { + final CompoundNBT c = is.getTag(); + if (c != null && c.getBoolean("hideFacades")) { + return CableRenderMode.CABLE_VIEW; + } + } + } + } - if( !is.isEmpty() && is.getItem() instanceof ToolNetworkTool) - { - final CompoundNBT c = is.getTag(); - if( c != null && c.getBoolean( "hideFacades" ) ) - { - return CableRenderMode.CABLE_VIEW; - } - } - } - } + return CableRenderMode.STANDARD; + } - return CableRenderMode.STANDARD; - } - - @Override - public boolean isActionKey( ActionKey key, InputMappings.Input input ) - { - return false; - } + @Override + public boolean isActionKey(ActionKey key, InputMappings.Input input) { + return false; + } } diff --git a/src/main/java/appeng/server/subcommands/ChunkLogger.java b/src/main/java/appeng/server/subcommands/ChunkLogger.java index 47c15d639..95ee63171 100644 --- a/src/main/java/appeng/server/subcommands/ChunkLogger.java +++ b/src/main/java/appeng/server/subcommands/ChunkLogger.java @@ -18,7 +18,6 @@ package appeng.server.subcommands; - import net.minecraft.command.CommandSource; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TranslationTextComponent; @@ -26,76 +25,60 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import appeng.api.features.AEFeature; import appeng.core.AEConfig; import appeng.core.AELog; -import appeng.api.features.AEFeature; import appeng.server.ISubCommand; +public class ChunkLogger implements ISubCommand { -public class ChunkLogger implements ISubCommand -{ + private boolean enabled = false; - private boolean enabled = false; + private void displayStack() { + if (AEConfig.instance().isFeatureEnabled(AEFeature.CHUNK_LOGGER_TRACE)) { + boolean output = false; + for (final StackTraceElement e : Thread.currentThread().getStackTrace()) { + if (output) { + AELog.info( + " " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')'); + } else { + output = e.getClassName().contains("EventBus") && e.getMethodName().contains("post"); + } + } + } + } - private void displayStack() - { - if( AEConfig.instance().isFeatureEnabled( AEFeature.CHUNK_LOGGER_TRACE ) ) - { - boolean output = false; - for( final StackTraceElement e : Thread.currentThread().getStackTrace() ) - { - if( output ) - { - AELog.info( " " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')' ); - } - else - { - output = e.getClassName().contains( "EventBus" ) && e.getMethodName().contains( "post" ); - } - } - } - } + @SubscribeEvent + public void onChunkLoadEvent(final ChunkEvent.Load event) { + if (!event.getWorld().isRemote()) { + AELog.info("Chunk Loaded: " + event.getChunk().getPos().x + ", " + event.getChunk().getPos().z); + this.displayStack(); + } + } - @SubscribeEvent - public void onChunkLoadEvent( final ChunkEvent.Load event ) - { - if( !event.getWorld().isRemote() ) - { - AELog.info( "Chunk Loaded: " + event.getChunk().getPos().x + ", " + event.getChunk().getPos().z ); - this.displayStack(); - } - } + @SubscribeEvent + public void onChunkUnloadEvent(final ChunkEvent.Unload unload) { + if (!unload.getWorld().isRemote()) { + AELog.info("Chunk Unloaded: " + unload.getChunk().getPos().x + ", " + unload.getChunk().getPos().z); + this.displayStack(); + } + } - @SubscribeEvent - public void onChunkUnloadEvent( final ChunkEvent.Unload unload ) - { - if( !unload.getWorld().isRemote() ) - { - AELog.info( "Chunk Unloaded: " + unload.getChunk().getPos().x + ", " + unload.getChunk().getPos().z ); - this.displayStack(); - } - } + @Override + public String getHelp(final MinecraftServer srv) { + return "commands.ae2.ChunkLogger"; + } - @Override - public String getHelp( final MinecraftServer srv ) - { - return "commands.ae2.ChunkLogger"; - } + @Override + public void call(final MinecraftServer srv, final String[] data, final CommandSource sender) { + this.enabled = !this.enabled; - @Override - public void call( final MinecraftServer srv, final String[] data, final CommandSource sender ) - { - this.enabled = !this.enabled; - - if( this.enabled ) - { - MinecraftForge.EVENT_BUS.register( this ); - sender.sendFeedback( new TranslationTextComponent( "commands.ae2.ChunkLoggerOn" ), true ); - } - else - { - MinecraftForge.EVENT_BUS.unregister( this ); - sender.sendFeedback( new TranslationTextComponent( "commands.ae2.ChunkLoggerOff" ), true ); - } - } + if (this.enabled) { + MinecraftForge.EVENT_BUS.register(this); + sender.sendFeedback(new TranslationTextComponent("commands.ae2.ChunkLoggerOn"), true); + } else { + MinecraftForge.EVENT_BUS.unregister(this); + sender.sendFeedback(new TranslationTextComponent("commands.ae2.ChunkLoggerOff"), true); + } + } } diff --git a/src/main/java/appeng/server/subcommands/Supporters.java b/src/main/java/appeng/server/subcommands/Supporters.java index eda9ec699..1be64c220 100644 --- a/src/main/java/appeng/server/subcommands/Supporters.java +++ b/src/main/java/appeng/server/subcommands/Supporters.java @@ -18,7 +18,6 @@ package appeng.server.subcommands; - import com.google.common.base.Joiner; import net.minecraft.command.CommandSource; @@ -27,20 +26,17 @@ import net.minecraft.util.text.StringTextComponent; import appeng.server.ISubCommand; +public class Supporters implements ISubCommand { -public class Supporters implements ISubCommand -{ + @Override + public String getHelp(final MinecraftServer srv) { + return "commands.ae2.Supporters"; + } - @Override - public String getHelp( final MinecraftServer srv ) - { - return "commands.ae2.Supporters"; - } - - @Override - public void call( final MinecraftServer srv, final String[] data, final CommandSource sender ) - { - final String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", "BevoLJ" }; - sender.sendFeedback( new StringTextComponent( "Special thanks to " + Joiner.on( ", " ).join( who ) ), true ); - } + @Override + public void call(final MinecraftServer srv, final String[] data, final CommandSource sender) { + final String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", + "BevoLJ" }; + sender.sendFeedback(new StringTextComponent("Special thanks to " + Joiner.on(", ").join(who)), true); + } } diff --git a/src/main/java/appeng/services/CompassService.java b/src/main/java/appeng/services/CompassService.java index e8df2c70f..af1c2d932 100644 --- a/src/main/java/appeng/services/CompassService.java +++ b/src/main/java/appeng/services/CompassService.java @@ -18,12 +18,12 @@ package appeng.services; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.*; + +import javax.annotation.Nonnull; -import appeng.api.AEApi; -import appeng.api.util.DimensionalCoord; -import appeng.services.compass.CompassReader; -import appeng.services.compass.ICompassCallback; -import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; @@ -34,327 +34,281 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import javax.annotation.Nonnull; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.*; +import appeng.api.AEApi; +import appeng.api.util.DimensionalCoord; +import appeng.services.compass.CompassReader; +import appeng.services.compass.ICompassCallback; +import appeng.util.Platform; +public final class CompassService { + private static final int CHUNK_SIZE = 16; -public final class CompassService -{ - private static final int CHUNK_SIZE = 16; + private final MinecraftServer server; + private final Map worldSet = new HashMap<>(10); + private final ExecutorService executor; - private final MinecraftServer server; - private final Map worldSet = new HashMap<>( 10 ); - private final ExecutorService executor; + private int jobSize; - private int jobSize; + public CompassService(MinecraftServer server, @Nonnull final ThreadFactory factory) { + this.server = server; + this.executor = Executors.newSingleThreadExecutor(factory); + this.jobSize = 0; + } - public CompassService(MinecraftServer server, @Nonnull final ThreadFactory factory) - { - this.server = server; - this.executor = Executors.newSingleThreadExecutor( factory ); - this.jobSize = 0; - } + public Future getCompassDirection(final DimensionalCoord coord, final int maxRange, final ICompassCallback cc) { + this.jobSize++; + return this.executor.submit(new CMDirectionRequest(coord, maxRange, cc)); + } - public Future getCompassDirection( final DimensionalCoord coord, final int maxRange, final ICompassCallback cc ) - { - this.jobSize++; - return this.executor.submit( new CMDirectionRequest( coord, maxRange, cc ) ); - } + /** + * Ensure the a compass service is removed once a world gets unloaded by forge. + * + * @param event the event containing the unloaded world. + */ + // FIXME this is never registered + @SubscribeEvent + public void unloadWorld(final WorldEvent.Unload event) { + DimensionType dim = event.getWorld().getDimension().getType(); - /** - * Ensure the a compass service is removed once a world gets unloaded by forge. - * - * @param event the event containing the unloaded world. - */ - // FIXME this is never registered - @SubscribeEvent - public void unloadWorld( final WorldEvent.Unload event ) - { - DimensionType dim = event.getWorld().getDimension().getType(); + if (Platform.isServer() && this.worldSet.containsKey(dim)) { + final CompassReader compassReader = this.worldSet.remove(dim); + compassReader.close(); + } + } - if( Platform.isServer() && this.worldSet.containsKey( dim ) ) - { - final CompassReader compassReader = this.worldSet.remove( dim ); - compassReader.close(); - } - } + private int jobSize() { + return this.jobSize; + } - private int jobSize() - { - return this.jobSize; - } + private void cleanUp() { + for (final CompassReader cr : this.worldSet.values()) { + cr.close(); + } + } - private void cleanUp() - { - for( final CompassReader cr : this.worldSet.values() ) - { - cr.close(); - } - } + public void updateArea(final IWorld w, final int chunkX, final int chunkZ) { + final int x = chunkX << 4; + final int z = chunkZ << 4; - public void updateArea( final IWorld w, final int chunkX, final int chunkZ ) - { - final int x = chunkX << 4; - final 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, 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); + } - 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(final IWorld w, final int x, final int y, final int z) { + this.jobSize++; - public Future updateArea( final IWorld w, final int x, final int y, final int z ) - { - this.jobSize++; + final int cx = x >> 4; + final int cdy = y >> 5; + final int cz = z >> 4; - final int cx = x >> 4; - final int cdy = y >> 5; - final int cz = z >> 4; + final int low_y = cdy << 5; + final int hi_y = low_y + 32; - final int low_y = cdy << 5; - final int hi_y = low_y + 32; + // lower level... + final IChunk c = w.getChunk(cx, cz); - // lower level... - final IChunk c = w.getChunk( cx, cz ); + DimensionType dim = w.getDimension().getType(); - DimensionType dim = w.getDimension().getType(); + Block skyStoneBlock = AEApi.instance().definitions().blocks().skyStoneBlock().block(); + BlockPos.Mutable pos = new BlockPos.Mutable(); + for (int i = 0; i < CHUNK_SIZE; i++) { + pos.setX(i); + for (int j = 0; j < CHUNK_SIZE; j++) { + pos.setZ(j); + for (int k = low_y; k < hi_y; k++) { + pos.setY(k); + final Block blk = c.getBlockState(pos).getBlock(); + if (blk == skyStoneBlock) { + return this.executor.submit(new CMUpdatePost(dim, cx, cz, cdy, true)); + } + } + } + } - Block skyStoneBlock = AEApi.instance().definitions().blocks().skyStoneBlock().block(); - BlockPos.Mutable pos = new BlockPos.Mutable(); - for( int i = 0; i < CHUNK_SIZE; i++ ) - { - pos.setX(i); - for( int j = 0; j < CHUNK_SIZE; j++ ) - { - pos.setZ(j); - for( int k = low_y; k < hi_y; k++ ) - { - pos.setY(k); - final Block blk = c.getBlockState( pos ).getBlock(); - if( blk == skyStoneBlock ) - { - return this.executor.submit( new CMUpdatePost( dim, cx, cz, cdy, true ) ); - } - } - } - } + return this.executor.submit(new CMUpdatePost(dim, cx, cz, cdy, false)); + } - return this.executor.submit( new CMUpdatePost( dim, cx, cz, cdy, false ) ); - } + public void kill() { + this.executor.shutdown(); - public void kill() - { - this.executor.shutdown(); + try { + this.executor.awaitTermination(6, TimeUnit.MINUTES); + this.jobSize = 0; - try - { - this.executor.awaitTermination( 6, TimeUnit.MINUTES ); - this.jobSize = 0; + for (final CompassReader cr : this.worldSet.values()) { + cr.close(); + } - for( final CompassReader cr : this.worldSet.values() ) - { - cr.close(); - } + this.worldSet.clear(); + } catch (final InterruptedException e) { + // wrap this up.. + } + } - this.worldSet.clear(); - } - catch( final InterruptedException e ) - { - // wrap this up.. - } - } + private CompassReader getReader(final DimensionType dim) { + CompassReader cr = this.worldSet.get(dim); - private CompassReader getReader( final DimensionType dim ) - { - CompassReader cr = this.worldSet.get( dim ); + if (cr == null) { + ServerWorld sw = server.getWorld(dim); + cr = new CompassReader(sw); + this.worldSet.put(dim, cr); + } - if( cr == null ) - { - ServerWorld sw = server.getWorld(dim); - cr = new CompassReader(sw); - this.worldSet.put( dim, cr ); - } + return cr; + } - return cr; - } + private int dist(final int ax, final int az, final int bx, final int bz) { + final int up = (bz - az) * CHUNK_SIZE; + final int side = (bx - ax) * CHUNK_SIZE; - private int dist( final int ax, final int az, final int bx, final int bz ) - { - final int up = ( bz - az ) * CHUNK_SIZE; - final int side = ( bx - ax ) * CHUNK_SIZE; + return up * up + side * side; + } - return up * up + side * side; - } + private double rad(final int ax, final int az, final int bx, final int bz) { + final int up = bz - az; + final int side = bx - ax; - private double rad( final int ax, final int az, final int bx, final int bz ) - { - final int up = bz - az; - final int side = bx - ax; + return Math.atan2(-up, side) - Math.PI / 2.0; + } - return Math.atan2( -up, side ) - Math.PI / 2.0; - } + private class CMUpdatePost implements Runnable { - private class CMUpdatePost implements Runnable - { + public final DimensionType dim; - public final DimensionType dim; + public final int chunkX; + public final int chunkZ; + public final int doubleChunkY; // 32 blocks instead of 16. + public final boolean value; - public final int chunkX; - public final int chunkZ; - public final int doubleChunkY; // 32 blocks instead of 16. - public final boolean value; + public CMUpdatePost(final DimensionType dim, final int cx, final int cz, final int dcy, final boolean val) { + this.dim = dim; + this.chunkX = cx; + this.doubleChunkY = dcy; + this.chunkZ = cz; + this.value = val; + } - public CMUpdatePost(final DimensionType dim, final int cx, final int cz, final int dcy, final boolean val ) - { - this.dim = dim; - this.chunkX = cx; - this.doubleChunkY = dcy; - this.chunkZ = cz; - this.value = val; - } + @Override + public void run() { + CompassService.this.jobSize--; - @Override - public void run() - { - CompassService.this.jobSize--; + final CompassReader cr = CompassService.this.getReader(this.dim); + cr.setHasBeacon(this.chunkX, this.chunkZ, this.doubleChunkY, this.value); - final CompassReader cr = CompassService.this.getReader( this.dim ); - cr.setHasBeacon( this.chunkX, this.chunkZ, this.doubleChunkY, this.value ); + if (CompassService.this.jobSize() < 2) { + CompassService.this.cleanUp(); + } + } + } - if( CompassService.this.jobSize() < 2 ) - { - CompassService.this.cleanUp(); - } - } - } + private class CMDirectionRequest implements Runnable { - private class CMDirectionRequest implements Runnable - { + public final int maxRange; + public final DimensionalCoord coord; + public final ICompassCallback callback; - public final int maxRange; - public final DimensionalCoord coord; - public final ICompassCallback callback; + public CMDirectionRequest(final DimensionalCoord coord, final int getMaxRange, final ICompassCallback cc) { + this.coord = coord; + this.maxRange = getMaxRange; + this.callback = cc; + } - public CMDirectionRequest( final DimensionalCoord coord, final int getMaxRange, final ICompassCallback cc ) - { - this.coord = coord; - this.maxRange = getMaxRange; - this.callback = cc; - } + @Override + public void run() { + CompassService.this.jobSize--; - @Override - public void run() - { - CompassService.this.jobSize--; + final int cx = this.coord.x >> 4; + final int cz = this.coord.z >> 4; - final int cx = this.coord.x >> 4; - final int cz = this.coord.z >> 4; + final CompassReader cr = CompassService.this.getReader(this.coord.getWorld().getDimension().getType()); - final CompassReader cr = CompassService.this.getReader( this.coord.getWorld().getDimension().getType() ); + // Am I standing on it? + if (cr.hasBeacon(cx, cz)) { + this.callback.calculatedDirection(true, true, -999, 0); - // Am I standing on it? - if( cr.hasBeacon( cx, cz ) ) - { - this.callback.calculatedDirection( true, true, -999, 0 ); + if (CompassService.this.jobSize() < 2) { + CompassService.this.cleanUp(); + } - if( CompassService.this.jobSize() < 2 ) - { - CompassService.this.cleanUp(); - } + return; + } - return; - } + // spiral outward... + for (int offset = 1; offset < this.maxRange; offset++) { + final int minX = cx - offset; + final int minZ = cz - offset; + final int maxX = cx + offset; + final int maxZ = cz + offset; - // spiral outward... - for( int offset = 1; offset < this.maxRange; offset++ ) - { - final int minX = cx - offset; - final int minZ = cz - offset; - final int maxX = cx + offset; - final int maxZ = cz + offset; + int closest = Integer.MAX_VALUE; + int chosen_x = cx; + int chosen_z = cz; - int closest = Integer.MAX_VALUE; - int chosen_x = cx; - int chosen_z = cz; + for (int z = minZ; z <= maxZ; z++) { + if (cr.hasBeacon(minX, z)) { + final int closeness = CompassService.this.dist(cx, cz, minX, z); + if (closeness < closest) { + closest = closeness; + chosen_x = minX; + chosen_z = z; + } + } - for( int z = minZ; z <= maxZ; z++ ) - { - if( cr.hasBeacon( minX, z ) ) - { - final int closeness = CompassService.this.dist( cx, cz, minX, z ); - if( closeness < closest ) - { - closest = closeness; - chosen_x = minX; - chosen_z = z; - } - } + if (cr.hasBeacon(maxX, z)) { + final int closeness = CompassService.this.dist(cx, cz, maxX, z); + if (closeness < closest) { + closest = closeness; + chosen_x = maxX; + chosen_z = z; + } + } + } - if( cr.hasBeacon( maxX, z ) ) - { - final int closeness = CompassService.this.dist( cx, cz, maxX, z ); - if( closeness < closest ) - { - closest = closeness; - chosen_x = maxX; - chosen_z = z; - } - } - } + for (int x = minX + 1; x < maxX; x++) { + if (cr.hasBeacon(x, minZ)) { + final int closeness = CompassService.this.dist(cx, cz, x, minZ); + if (closeness < closest) { + closest = closeness; + chosen_x = x; + chosen_z = minZ; + } + } - for( int x = minX + 1; x < maxX; x++ ) - { - if( cr.hasBeacon( x, minZ ) ) - { - final int closeness = CompassService.this.dist( cx, cz, x, minZ ); - if( closeness < closest ) - { - closest = closeness; - chosen_x = x; - chosen_z = minZ; - } - } + if (cr.hasBeacon(x, maxZ)) { + final int closeness = CompassService.this.dist(cx, cz, x, maxZ); + if (closeness < closest) { + closest = closeness; + chosen_x = x; + chosen_z = maxZ; + } + } + } - if( cr.hasBeacon( x, maxZ ) ) - { - final int closeness = CompassService.this.dist( cx, cz, x, maxZ ); - if( closeness < closest ) - { - closest = closeness; - chosen_x = x; - chosen_z = maxZ; - } - } - } + if (closest < Integer.MAX_VALUE) { + this.callback.calculatedDirection(true, false, CompassService.this.rad(cx, cz, chosen_x, chosen_z), + CompassService.this.dist(cx, cz, chosen_x, chosen_z)); - if( closest < Integer.MAX_VALUE ) - { - this.callback.calculatedDirection( true, false, CompassService.this.rad( cx, cz, chosen_x, chosen_z ), - CompassService.this.dist( cx, cz, chosen_x, chosen_z ) ); + if (CompassService.this.jobSize() < 2) { + CompassService.this.cleanUp(); + } - if( CompassService.this.jobSize() < 2 ) - { - CompassService.this.cleanUp(); - } + return; + } + } - return; - } - } + // didn't find shit... + this.callback.calculatedDirection(false, true, -999, 999); - // didn't find shit... - this.callback.calculatedDirection( false, true, -999, 999 ); - - if( CompassService.this.jobSize() < 2 ) - { - CompassService.this.cleanUp(); - } - } - } + if (CompassService.this.jobSize() < 2) { + CompassService.this.cleanUp(); + } + } + } } diff --git a/src/main/java/appeng/services/compass/CompassException.java b/src/main/java/appeng/services/compass/CompassException.java index e61c09c2d..d4d4917da 100644 --- a/src/main/java/appeng/services/compass/CompassException.java +++ b/src/main/java/appeng/services/compass/CompassException.java @@ -18,16 +18,13 @@ package appeng.services.compass; +public class CompassException extends RuntimeException { -public class CompassException extends RuntimeException -{ + private static final long serialVersionUID = 8825268683203860877L; - private static final long serialVersionUID = 8825268683203860877L; + private final Throwable inner; - private final Throwable inner; - - public CompassException( final Throwable t ) - { - this.inner = t; - } + public CompassException(final Throwable t) { + this.inner = t; + } } diff --git a/src/main/java/appeng/services/compass/CompassReader.java b/src/main/java/appeng/services/compass/CompassReader.java index 2b63465cc..c9b5ca7f4 100644 --- a/src/main/java/appeng/services/compass/CompassReader.java +++ b/src/main/java/appeng/services/compass/CompassReader.java @@ -18,62 +18,53 @@ package appeng.services.compass; - -import com.google.common.base.Preconditions; -import net.minecraft.world.server.ServerWorld; - import java.util.HashMap; import java.util.Map; +import com.google.common.base.Preconditions; -public final class CompassReader -{ - private final Map regions = new HashMap<>( 100 ); - private final ServerWorld world; +import net.minecraft.world.server.ServerWorld; - public CompassReader( ServerWorld world ) - { - this.world = Preconditions.checkNotNull( world ); - } +public final class CompassReader { + private final Map regions = new HashMap<>(100); + private final ServerWorld world; - public void close() - { - for( final CompassRegion r : this.regions.values() ) - { - r.close(); - } + public CompassReader(ServerWorld world) { + this.world = Preconditions.checkNotNull(world); + } - this.regions.clear(); - } + public void close() { + for (final CompassRegion r : this.regions.values()) { + r.close(); + } - public void setHasBeacon( final int cx, final int cz, final int cdy, final boolean hasBeacon ) - { - final CompassRegion r = this.getRegion( cx, cz ); + this.regions.clear(); + } - r.setHasBeacon( cx, cz, cdy, hasBeacon ); - } + public void setHasBeacon(final int cx, final int cz, final int cdy, final boolean hasBeacon) { + final CompassRegion r = this.getRegion(cx, cz); - public boolean hasBeacon( final int cx, final int cz ) - { - final CompassRegion r = this.getRegion( cx, cz ); + r.setHasBeacon(cx, cz, cdy, hasBeacon); + } - return r.hasBeacon( cx, cz ); - } + public boolean hasBeacon(final int cx, final int cz) { + final CompassRegion r = this.getRegion(cx, cz); - private CompassRegion getRegion( final int cx, final int cz ) - { - long pos = cx >> 10; - pos <<= 32; - pos |= ( cz >> 10 ); + return r.hasBeacon(cx, cz); + } - CompassRegion cr = this.regions.get( pos ); + private CompassRegion getRegion(final int cx, final int cz) { + long pos = cx >> 10; + pos <<= 32; + pos |= (cz >> 10); - if( cr == null ) - { - cr = new CompassRegion( world, cx, cz ); - this.regions.put( pos, cr ); - } + CompassRegion cr = this.regions.get(pos); - return cr; - } + if (cr == null) { + cr = new CompassRegion(world, cx, cz); + this.regions.put(pos, cr); + } + + return cr; + } } diff --git a/src/main/java/appeng/services/compass/CompassRegion.java b/src/main/java/appeng/services/compass/CompassRegion.java index 32bdb6891..02b25e69a 100644 --- a/src/main/java/appeng/services/compass/CompassRegion.java +++ b/src/main/java/appeng/services/compass/CompassRegion.java @@ -18,145 +18,126 @@ package appeng.services.compass; - import com.google.common.base.Preconditions; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.WorldSavedData; -final class CompassRegion -{ - private final int lowX; - private final int lowZ; - private final ServerWorld world; - private SaveData data; +final class CompassRegion { + private final int lowX; + private final int lowZ; + private final ServerWorld world; + private SaveData data; - public CompassRegion(ServerWorld world, final int cx, final int cz ) - { - Preconditions.checkNotNull( world ); + public CompassRegion(ServerWorld world, final int cx, final int cz) { + Preconditions.checkNotNull(world); - this.world = world; + this.world = world; - final int region_x = cx >> 10; - final int region_z = cz >> 10; + final int region_x = cx >> 10; + final int region_z = cz >> 10; - this.lowX = region_x << 10; - this.lowZ = region_z << 10; + this.lowX = region_x << 10; + this.lowZ = region_z << 10; - this.openData(false); - } + this.openData(false); + } - void close() - { - if( this.data != null ) - { - this.data = null; - } - } + void close() { + if (this.data != null) { + this.data = null; + } + } - boolean hasBeacon( int cx, int cz ) - { - if( this.data != null ) - { - cx &= 0x3FF; - cz &= 0x3FF; + boolean hasBeacon(int cx, int cz) { + if (this.data != null) { + cx &= 0x3FF; + cz &= 0x3FF; - final int val = this.read( cx, cz ); - return val != 0; - } + final int val = this.read(cx, cz); + return val != 0; + } - return false; - } + return false; + } - void setHasBeacon( int cx, int cz, final int cdy, final boolean hasBeacon ) - { - cx &= 0x3FF; - cz &= 0x3FF; + void setHasBeacon(int cx, int cz, final int cdy, final boolean hasBeacon) { + cx &= 0x3FF; + cz &= 0x3FF; - this.openData( hasBeacon ); + this.openData(hasBeacon); - if( this.data != null ) - { - int val = this.read( cx, cz ); - final int originalVal = val; + if (this.data != null) { + int val = this.read(cx, cz); + final int originalVal = val; - if( hasBeacon ) - { - val |= 1 << cdy; - } - else - { - val &= ~( 1 << cdy ); - } + if (hasBeacon) { + val |= 1 << cdy; + } else { + val &= ~(1 << cdy); + } - if( originalVal != val ) - { - this.write( cx, cz, val ); - } - } - } + if (originalVal != val) { + this.write(cx, cz, val); + } + } + } - private void openData(final boolean create ) - { - if( this.data != null ) - { - return; - } + private void openData(final boolean create) { + if (this.data != null) { + return; + } - String name = this.lowX + "_" + this.lowZ; + String name = this.lowX + "_" + this.lowZ; - if (create) { - this.data = world.getSavedData().getOrCreate(() -> new SaveData(name), name); - if (this.data.bitmap == null) { - this.data.bitmap = new byte[SaveData.BITMAP_LENGTH]; - } - } else { - this.data = world.getSavedData().get(() -> new SaveData(name), name); - } - } + if (create) { + this.data = world.getSavedData().getOrCreate(() -> new SaveData(name), name); + if (this.data.bitmap == null) { + this.data.bitmap = new byte[SaveData.BITMAP_LENGTH]; + } + } else { + this.data = world.getSavedData().get(() -> new SaveData(name), name); + } + } - private int read( final int cx, final int cz ) - { - try - { - return this.data.bitmap[cx + cz * 0x400]; - } - catch( final IndexOutOfBoundsException outOfBounds ) - { - return 0; - } - } + private int read(final int cx, final int cz) { + try { + return this.data.bitmap[cx + cz * 0x400]; + } catch (final IndexOutOfBoundsException outOfBounds) { + return 0; + } + } - private void write( final int cx, final int cz, final int val ) - { - this.data.bitmap[cx + cz * 0x400] = (byte) val; - this.data.markDirty(); - } + private void write(final int cx, final int cz, final int val) { + this.data.bitmap[cx + cz * 0x400] = (byte) val; + this.data.markDirty(); + } - private static class SaveData extends WorldSavedData { + private static class SaveData extends WorldSavedData { - private static final int BITMAP_LENGTH = 0x400 * 0x400; + private static final int BITMAP_LENGTH = 0x400 * 0x400; - private byte[] bitmap; + private byte[] bitmap; - public SaveData(String name) { - super(name); - } + public SaveData(String name) { + super(name); + } - @Override - public void read(CompoundNBT nbt) { - this.bitmap = nbt.getByteArray("b"); - if (this.bitmap.length != BITMAP_LENGTH) { - throw new IllegalStateException("Invalid bitmap length: " + bitmap.length); - } - } + @Override + public void read(CompoundNBT nbt) { + this.bitmap = nbt.getByteArray("b"); + if (this.bitmap.length != BITMAP_LENGTH) { + throw new IllegalStateException("Invalid bitmap length: " + bitmap.length); + } + } - @Override - public CompoundNBT write(CompoundNBT compound) { - compound.putByteArray("b", bitmap); - return compound; - } + @Override + public CompoundNBT write(CompoundNBT compound) { + compound.putByteArray("b", bitmap); + return compound; + } - } + } } diff --git a/src/main/java/appeng/services/compass/CompassThreadFactory.java b/src/main/java/appeng/services/compass/CompassThreadFactory.java index 0c9ac26e4..39e43906f 100644 --- a/src/main/java/appeng/services/compass/CompassThreadFactory.java +++ b/src/main/java/appeng/services/compass/CompassThreadFactory.java @@ -18,26 +18,22 @@ package appeng.services.compass; - import java.util.concurrent.ThreadFactory; import javax.annotation.Nonnull; import com.google.common.base.Preconditions; - /** * @author thatsIch * @version rv3 - 31.05.2015 * @since rv3 31.05.2015 */ -public final class CompassThreadFactory implements ThreadFactory -{ - @Override - public Thread newThread( @Nonnull final Runnable job ) - { - Preconditions.checkNotNull( job ); +public final class CompassThreadFactory implements ThreadFactory { + @Override + public Thread newThread(@Nonnull final Runnable job) { + Preconditions.checkNotNull(job); - return new Thread( job, "AE Compass Service" ); - } + return new Thread(job, "AE Compass Service"); + } } diff --git a/src/main/java/appeng/services/compass/ICompassCallback.java b/src/main/java/appeng/services/compass/ICompassCallback.java index 06cf52d38..1906379f7 100644 --- a/src/main/java/appeng/services/compass/ICompassCallback.java +++ b/src/main/java/appeng/services/compass/ICompassCallback.java @@ -18,17 +18,15 @@ package appeng.services.compass; +public interface ICompassCallback { -public interface ICompassCallback -{ - - /** - * Called from another thread. - * - * @param hasResult true if found a target - * @param spin true if should spin - * @param radians radians - * @param dist distance - */ - void calculatedDirection( boolean hasResult, boolean spin, double radians, double dist ); + /** + * Called from another thread. + * + * @param hasResult true if found a target + * @param spin true if should spin + * @param radians radians + * @param dist distance + */ + void calculatedDirection(boolean hasResult, boolean spin, double radians, double dist); } diff --git a/src/main/java/appeng/spatial/CachedPlane.java b/src/main/java/appeng/spatial/CachedPlane.java index add4b3732..76e4b7e54 100644 --- a/src/main/java/appeng/spatial/CachedPlane.java +++ b/src/main/java/appeng/spatial/CachedPlane.java @@ -18,7 +18,6 @@ package appeng.spatial; - import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; @@ -33,6 +32,9 @@ import net.minecraft.world.ITickList; import net.minecraft.world.NextTickListEntry; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkSection; +import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.world.server.ServerTickList; import appeng.api.AEApi; import appeng.api.movable.IMovableHandler; @@ -42,425 +44,367 @@ import appeng.api.util.WorldCoord; import appeng.core.AELog; import appeng.core.worlddata.WorldData; import appeng.util.Platform; -import net.minecraft.world.chunk.ChunkSection; -import net.minecraft.world.server.ServerChunkProvider; -import net.minecraft.world.server.ServerTickList; - - -public class CachedPlane -{ - private final int x_size; - private final int z_size; - private final int cx_size; - private final int cz_size; - private final int x_offset; - private final int y_offset; - private final int z_offset; - private final int y_size; - private final Chunk[][] myChunks; - private final Column[][] myColumns; - private final List tiles = new ArrayList<>(); - private final List> ticks = new ArrayList<>(); - private final World world; - private final IMovableRegistry reg = AEApi.instance().registries().movable(); - private final List updates = new ArrayList<>(); - private int verticalBits; - private final BlockState matrixBlockState; - - public CachedPlane( final World w, final int minX, final int minY, final int minZ, final int maxX, final int maxY, final int maxZ ) - { - - Block matrixFrameBlock = AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().orElse( null ); - if( matrixFrameBlock != null ) - { - this.matrixBlockState = matrixFrameBlock.getDefaultState(); - } - else - { - this.matrixBlockState = null; - } - - this.world = w; - - this.x_size = maxX - minX + 1; - this.y_size = maxY - minY + 1; - this.z_size = maxZ - minZ + 1; - - this.x_offset = minX; - this.y_offset = minY; - this.z_offset = minZ; - - final int minCX = minX >> 4; - final int minCY = minY >> 4; - final int minCZ = minZ >> 4; - final int maxCX = maxX >> 4; - final int maxCY = maxY >> 4; - final int maxCZ = maxZ >> 4; - - this.cx_size = maxCX - minCX + 1; - final int cy_size = maxCY - minCY + 1; - this.cz_size = maxCZ - minCZ + 1; - - this.myChunks = new Chunk[this.cx_size][this.cz_size]; - this.myColumns = new Column[this.x_size][this.z_size]; - - this.verticalBits = 0; - for( int cy = 0; cy < cy_size; cy++ ) - { - this.verticalBits |= 1 << ( minCY + cy ); - } - - 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.getChunk( ( minX + x ) >> 4, ( minZ + z ) >> 4 ), ( minX + x ) & 0xF, ( minZ + z ) & 0xF, minCY, cy_size ); - } - } - - final IMovableRegistry mr = AEApi.instance().registries().movable(); - - for( int cx = 0; cx < this.cx_size; cx++ ) - { - for( int cz = 0; cz < this.cz_size; cz++ ) - { - final List deadTiles = new ArrayList<>(); - - final Chunk c = w.getChunk( minCX + cx, minCZ + cz ); - this.myChunks[cx][cz] = c; - - final List> rawTiles = new ArrayList<>(c.getTileEntityMap().entrySet()); - for( final Entry tx : rawTiles ) - { - final BlockPos cp = tx.getKey(); - final TileEntity te = tx.getValue(); - - final BlockPos tePOS = te.getPos(); - if( tePOS.getX() >= minX && tePOS.getX() <= maxX && tePOS.getY() >= minY && tePOS.getY() <= maxY && tePOS.getZ() >= minZ && tePOS - .getZ() <= maxZ ) - { - if( mr.askToMove( te ) ) - { - this.tiles.add( te ); - deadTiles.add( cp ); - } - else - { - final BlockStorageData details = new BlockStorageData(); - this.myColumns[tePOS.getX() - minX][tePOS.getZ() - minZ].fillData( tePOS.getY(), details ); - - // don't skip air, just let the code replace it... - if( details.state != null && details.state.getBlock() == Platform.AIR_BLOCK && details.state.getMaterial().isReplaceable() ) - { - w.removeBlock( tePOS, false ); - } - else - { - this.myColumns[tePOS.getX() - minX][tePOS.getZ() - minZ].setSkip( tePOS.getY() ); - } - } - } - } - - for( final BlockPos cp : deadTiles ) - { - c.getTileEntityMap().remove( cp ); - } - - final long gameTime = this.getWorld().getGameTime(); - final ITickList pendingBlockTicks = this.getWorld().getPendingBlockTicks(); - if (pendingBlockTicks instanceof ServerTickList) { - List> pending = ((ServerTickList) pendingBlockTicks).getPending(c.getPos(), false, true); - for (final NextTickListEntry entry : pending) { - final BlockPos tePOS = entry.position; - if (tePOS.getX() >= minX && tePOS.getX() <= maxX && tePOS.getY() >= minY && tePOS.getY() <= maxY && tePOS.getZ() >= minZ && tePOS - .getZ() <= maxZ) { - this.ticks.add(new NextTickListEntry<>(tePOS, entry.getTarget(), entry.scheduledTime - gameTime, entry.priority)); - } - } - } - } - } - - for( final TileEntity te : this.tiles ) - { - try - { - this.getWorld().loadedTileEntityList.remove( te ); - if( te instanceof ITickableTileEntity) - { - this.getWorld().tickableTileEntities.remove( te ); - } - } - catch( final Exception e ) - { - AELog.debug( e ); - } - } - } - - private IMovableHandler getHandler( final TileEntity te ) - { - final IMovableRegistry mr = AEApi.instance().registries().movable(); - return mr.getHandler( te ); - } - - void swap( final CachedPlane dst ) - { - final IMovableRegistry mr = AEApi.instance().registries().movable(); - - if( dst.x_size == this.x_size && dst.y_size == this.y_size && dst.z_size == this.z_size ) - { - AELog.info( "Block Copy Scale: " + this.x_size + ", " + this.y_size + ", " + this.z_size ); - - long startTime = System.nanoTime(); - final BlockStorageData aD = new BlockStorageData(); - final BlockStorageData bD = new BlockStorageData(); - - for( int x = 0; x < this.x_size; x++ ) - { - for( int z = 0; z < this.z_size; z++ ) - { - final Column a = this.myColumns[x][z]; - final Column b = dst.myColumns[x][z]; - - for( int y = 0; y < this.y_size; y++ ) - { - final int src_y = y + this.y_offset; - final int dst_y = y + dst.y_offset; - - if( a.doNotSkip( src_y ) && b.doNotSkip( dst_y ) ) - { - a.fillData( src_y, aD ); - b.fillData( dst_y, bD ); - - a.setBlockState( src_y, bD ); - b.setBlockState( dst_y, aD ); - } - else - { - this.markForUpdate( x + this.x_offset, src_y, z + this.z_offset ); - dst.markForUpdate( x + dst.x_offset, dst_y, z + dst.z_offset ); - } - } - } - } - - long endTime = System.nanoTime(); - long duration = endTime - startTime; - AELog.info( "Block Copy Time: " + duration ); - - for( final TileEntity te : this.tiles ) - { - final BlockPos tePOS = te.getPos(); - dst.addTile( tePOS.getX() - this.x_offset, tePOS.getY() - this.y_offset, tePOS.getZ() - this.z_offset, te, this, mr ); - } - - for( final TileEntity te : dst.tiles ) - { - final BlockPos tePOS = te.getPos(); - this.addTile( tePOS.getX() - dst.x_offset, tePOS.getY() - dst.y_offset, tePOS.getZ() - dst.z_offset, te, dst, mr ); - } - - for( final NextTickListEntry entry : this.ticks ) - { - final BlockPos tePOS = entry.position; - dst.addTick( tePOS.getX() - this.x_offset, tePOS.getY() - this.y_offset, tePOS.getZ() - this.z_offset, entry ); - } - - for( final NextTickListEntry entry : dst.ticks ) - { - final BlockPos tePOS = entry.position; - this.addTick( tePOS.getX() - dst.x_offset, tePOS.getY() - dst.y_offset, tePOS.getZ() - dst.z_offset, entry ); - } - - startTime = System.nanoTime(); - this.updateChunks(); - dst.updateChunks(); - endTime = System.nanoTime(); - - duration = endTime - startTime; - AELog.info( "Update Time: " + duration ); - } - } - - private void markForUpdate( final int x, final int y, final int z ) - { - this.updates.add( new WorldCoord( x, y, z ) ); - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - this.updates.add( new WorldCoord( x + d.xOffset, y + d.yOffset, z + d.zOffset ) ); - } - } - - private void addTick( final int x, final int y, final int z, final NextTickListEntry entry ) - { - BlockPos where = new BlockPos(x + this.x_offset, y + this.y_offset, z + this.z_offset); - this.world.getPendingBlockTicks().scheduleTick(where, entry.getTarget(), (int) entry.scheduledTime, entry.priority); - } - - private void addTile( final int x, final int y, final int z, final TileEntity te, final CachedPlane alternateDestination, final IMovableRegistry mr ) - { - try - { - final Column c = this.myColumns[x][z]; - - if( c.doNotSkip( y + this.y_offset ) || alternateDestination == null ) - { - final IMovableHandler handler = this.getHandler( te ); - - try - { - handler.moveTile( te, this.world, new BlockPos( x + this.x_offset, y + this.y_offset, z + this.z_offset ) ); - } - catch( final Throwable e ) - { - AELog.debug( e ); - - final BlockPos pos = new BlockPos( x, y, z ); - - // attempt recovery... - c.c.addTileEntity(te); - - this.world.notifyBlockUpdate( pos, this.world.getBlockState( pos ), this.world.getBlockState( pos ), z ); - } - - mr.doneMoving( te ); - } - else - { - alternateDestination.addTile( x, y, z, te, null, mr ); - } - } - catch( final Throwable e ) - { - AELog.debug( e ); - } - } - - private void updateChunks() - { - - // update shit.. - for( int x = 0; x < this.cx_size; x++ ) - { - for( int z = 0; z < this.cz_size; z++ ) - { - final Chunk c = this.myChunks[x][z]; - // FIXME: Light shit - c.markDirty(); - } - } - - // send shit... - for( int x = 0; x < this.cx_size; x++ ) - { - for( int z = 0; z < this.cz_size; z++ ) - { - - final Chunk c = this.myChunks[x][z]; - - for( int y = 1; y < 255; y += 32 ) - { - WorldData.instance().compassData().service().updateArea( this.getWorld(), c.getPos().x << 4, y, c.getPos().z << 4 ); - } - - // FIXME this was sending chunks to players... - SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits); - ((ServerChunkProvider) world.getChunkProvider()).chunkManager.getTrackingPlayers(c.getPos(), false) - .forEach(spe -> spe.connection.sendPacket(cdp)); - - } - } - - // FIXME check if this makes any sense at all to send changes to players asap - ServerChunkProvider serverChunkProvider = (ServerChunkProvider) world.getChunkProvider(); - serverChunkProvider.tick(() -> false); - } - - List getUpdates() - { - return this.updates; - } - - World getWorld() - { - return this.world; - } - - private static class BlockStorageData - { - public BlockState state; - public int light; - } - - private class Column - { - private final int x; - private final int z; - private final Chunk c; - private List skipThese = null; - - public Column( final Chunk chunk, final int x, final int z, final int chunkY, final int chunkHeight ) - { - this.x = x; - this.z = z; - this.c = chunk; - - final ChunkSection[] storage = this.c.getSections(); - - // make sure storage exists before hand... - for( int ay = 0; ay < chunkHeight; ay++ ) - { - final int by = ( ay + chunkY ); - ChunkSection extendedblockstorage = storage[by]; - if( extendedblockstorage == null ) - { - extendedblockstorage = storage[by] = new ChunkSection( by << 4 ); - } - } - } - - private void setBlockState(final int y, BlockStorageData data ) - { - if( data.state == CachedPlane.this.matrixBlockState ) - { - data.state = Platform.AIR_BLOCK.getDefaultState(); - } - final ChunkSection[] storage = this.c.getSections(); - final ChunkSection extendedBlockStorage = storage[y >> 4]; - extendedBlockStorage.setBlockState( this.x, y & 15, this.z, data.state ); - // FIXME extendedBlockStorage.setBlockLight( this.x, y & 15, this.z, data.light ); - } - - private void fillData( final int y, BlockStorageData data ) - { - final ChunkSection[] storage = this.c.getSections(); - final ChunkSection extendedblockstorage = storage[y >> 4]; - - data.state = extendedblockstorage.getBlockState( this.x, y & 15, this.z ); - // FIXME data.light = extendedblockstorage.getBlockLight( this.x, y & 15, this.z ); - } - - private boolean doNotSkip( final int y ) - { - final ChunkSection[] storage = this.c.getSections(); - final ChunkSection extendedblockstorage = storage[y >> 4]; - if( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.getBlockState( this.x, y & 15, this.z ).getBlock() ) ) - { - return false; - } - - return this.skipThese == null || !this.skipThese.contains( y ); - } - - private void setSkip( final int yCoord ) - { - if( this.skipThese == null ) - { - this.skipThese = new ArrayList<>(); - } - this.skipThese.add( yCoord ); - } - } + +public class CachedPlane { + private final int x_size; + private final int z_size; + private final int cx_size; + private final int cz_size; + private final int x_offset; + private final int y_offset; + private final int z_offset; + private final int y_size; + private final Chunk[][] myChunks; + private final Column[][] myColumns; + private final List tiles = new ArrayList<>(); + private final List> ticks = new ArrayList<>(); + private final World world; + private final IMovableRegistry reg = AEApi.instance().registries().movable(); + private final List updates = new ArrayList<>(); + private int verticalBits; + private final BlockState matrixBlockState; + + public CachedPlane(final World w, final int minX, final int minY, final int minZ, final int maxX, final int maxY, + final int maxZ) { + + Block matrixFrameBlock = AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().orElse(null); + if (matrixFrameBlock != null) { + this.matrixBlockState = matrixFrameBlock.getDefaultState(); + } else { + this.matrixBlockState = null; + } + + this.world = w; + + this.x_size = maxX - minX + 1; + this.y_size = maxY - minY + 1; + this.z_size = maxZ - minZ + 1; + + this.x_offset = minX; + this.y_offset = minY; + this.z_offset = minZ; + + final int minCX = minX >> 4; + final int minCY = minY >> 4; + final int minCZ = minZ >> 4; + final int maxCX = maxX >> 4; + final int maxCY = maxY >> 4; + final int maxCZ = maxZ >> 4; + + this.cx_size = maxCX - minCX + 1; + final int cy_size = maxCY - minCY + 1; + this.cz_size = maxCZ - minCZ + 1; + + this.myChunks = new Chunk[this.cx_size][this.cz_size]; + this.myColumns = new Column[this.x_size][this.z_size]; + + this.verticalBits = 0; + for (int cy = 0; cy < cy_size; cy++) { + this.verticalBits |= 1 << (minCY + cy); + } + + 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.getChunk((minX + x) >> 4, (minZ + z) >> 4), (minX + x) & 0xF, + (minZ + z) & 0xF, minCY, cy_size); + } + } + + final IMovableRegistry mr = AEApi.instance().registries().movable(); + + for (int cx = 0; cx < this.cx_size; cx++) { + for (int cz = 0; cz < this.cz_size; cz++) { + final List deadTiles = new ArrayList<>(); + + final Chunk c = w.getChunk(minCX + cx, minCZ + cz); + this.myChunks[cx][cz] = c; + + final List> rawTiles = new ArrayList<>(c.getTileEntityMap().entrySet()); + for (final Entry tx : rawTiles) { + final BlockPos cp = tx.getKey(); + final TileEntity te = tx.getValue(); + + final BlockPos tePOS = te.getPos(); + if (tePOS.getX() >= minX && tePOS.getX() <= maxX && tePOS.getY() >= minY && tePOS.getY() <= maxY + && tePOS.getZ() >= minZ && tePOS.getZ() <= maxZ) { + if (mr.askToMove(te)) { + this.tiles.add(te); + deadTiles.add(cp); + } else { + final BlockStorageData details = new BlockStorageData(); + this.myColumns[tePOS.getX() - minX][tePOS.getZ() - minZ].fillData(tePOS.getY(), details); + + // don't skip air, just let the code replace it... + if (details.state != null && details.state.getBlock() == Platform.AIR_BLOCK + && details.state.getMaterial().isReplaceable()) { + w.removeBlock(tePOS, false); + } else { + this.myColumns[tePOS.getX() - minX][tePOS.getZ() - minZ].setSkip(tePOS.getY()); + } + } + } + } + + for (final BlockPos cp : deadTiles) { + c.getTileEntityMap().remove(cp); + } + + final long gameTime = this.getWorld().getGameTime(); + final ITickList pendingBlockTicks = this.getWorld().getPendingBlockTicks(); + if (pendingBlockTicks instanceof ServerTickList) { + List> pending = ((ServerTickList) pendingBlockTicks) + .getPending(c.getPos(), false, true); + for (final NextTickListEntry entry : pending) { + final BlockPos tePOS = entry.position; + if (tePOS.getX() >= minX && tePOS.getX() <= maxX && tePOS.getY() >= minY && tePOS.getY() <= maxY + && tePOS.getZ() >= minZ && tePOS.getZ() <= maxZ) { + this.ticks.add(new NextTickListEntry<>(tePOS, entry.getTarget(), + entry.scheduledTime - gameTime, entry.priority)); + } + } + } + } + } + + for (final TileEntity te : this.tiles) { + try { + this.getWorld().loadedTileEntityList.remove(te); + if (te instanceof ITickableTileEntity) { + this.getWorld().tickableTileEntities.remove(te); + } + } catch (final Exception e) { + AELog.debug(e); + } + } + } + + private IMovableHandler getHandler(final TileEntity te) { + final IMovableRegistry mr = AEApi.instance().registries().movable(); + return mr.getHandler(te); + } + + void swap(final CachedPlane dst) { + final IMovableRegistry mr = AEApi.instance().registries().movable(); + + if (dst.x_size == this.x_size && dst.y_size == this.y_size && dst.z_size == this.z_size) { + AELog.info("Block Copy Scale: " + this.x_size + ", " + this.y_size + ", " + this.z_size); + + long startTime = System.nanoTime(); + final BlockStorageData aD = new BlockStorageData(); + final BlockStorageData bD = new BlockStorageData(); + + for (int x = 0; x < this.x_size; x++) { + for (int z = 0; z < this.z_size; z++) { + final Column a = this.myColumns[x][z]; + final Column b = dst.myColumns[x][z]; + + for (int y = 0; y < this.y_size; y++) { + final int src_y = y + this.y_offset; + final int dst_y = y + dst.y_offset; + + if (a.doNotSkip(src_y) && b.doNotSkip(dst_y)) { + a.fillData(src_y, aD); + b.fillData(dst_y, bD); + + a.setBlockState(src_y, bD); + b.setBlockState(dst_y, aD); + } else { + this.markForUpdate(x + this.x_offset, src_y, z + this.z_offset); + dst.markForUpdate(x + dst.x_offset, dst_y, z + dst.z_offset); + } + } + } + } + + long endTime = System.nanoTime(); + long duration = endTime - startTime; + AELog.info("Block Copy Time: " + duration); + + for (final TileEntity te : this.tiles) { + final BlockPos tePOS = te.getPos(); + dst.addTile(tePOS.getX() - this.x_offset, tePOS.getY() - this.y_offset, tePOS.getZ() - this.z_offset, + te, this, mr); + } + + for (final TileEntity te : dst.tiles) { + final BlockPos tePOS = te.getPos(); + this.addTile(tePOS.getX() - dst.x_offset, tePOS.getY() - dst.y_offset, tePOS.getZ() - dst.z_offset, te, + dst, mr); + } + + for (final NextTickListEntry entry : this.ticks) { + final BlockPos tePOS = entry.position; + dst.addTick(tePOS.getX() - this.x_offset, tePOS.getY() - this.y_offset, tePOS.getZ() - this.z_offset, + entry); + } + + for (final NextTickListEntry entry : dst.ticks) { + final BlockPos tePOS = entry.position; + this.addTick(tePOS.getX() - dst.x_offset, tePOS.getY() - dst.y_offset, tePOS.getZ() - dst.z_offset, + entry); + } + + startTime = System.nanoTime(); + this.updateChunks(); + dst.updateChunks(); + endTime = System.nanoTime(); + + duration = endTime - startTime; + AELog.info("Update Time: " + duration); + } + } + + private void markForUpdate(final int x, final int y, final int z) { + this.updates.add(new WorldCoord(x, y, z)); + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + this.updates.add(new WorldCoord(x + d.xOffset, y + d.yOffset, z + d.zOffset)); + } + } + + private void addTick(final int x, final int y, final int z, final NextTickListEntry entry) { + BlockPos where = new BlockPos(x + this.x_offset, y + this.y_offset, z + this.z_offset); + this.world.getPendingBlockTicks().scheduleTick(where, entry.getTarget(), (int) entry.scheduledTime, + entry.priority); + } + + private void addTile(final int x, final int y, final int z, final TileEntity te, + final CachedPlane alternateDestination, final IMovableRegistry mr) { + try { + final Column c = this.myColumns[x][z]; + + if (c.doNotSkip(y + this.y_offset) || alternateDestination == null) { + final IMovableHandler handler = this.getHandler(te); + + try { + handler.moveTile(te, this.world, + new BlockPos(x + this.x_offset, y + this.y_offset, z + this.z_offset)); + } catch (final Throwable e) { + AELog.debug(e); + + final BlockPos pos = new BlockPos(x, y, z); + + // attempt recovery... + c.c.addTileEntity(te); + + this.world.notifyBlockUpdate(pos, this.world.getBlockState(pos), this.world.getBlockState(pos), z); + } + + mr.doneMoving(te); + } else { + alternateDestination.addTile(x, y, z, te, null, mr); + } + } catch (final Throwable e) { + AELog.debug(e); + } + } + + private void updateChunks() { + + // update shit.. + for (int x = 0; x < this.cx_size; x++) { + for (int z = 0; z < this.cz_size; z++) { + final Chunk c = this.myChunks[x][z]; + // FIXME: Light shit + c.markDirty(); + } + } + + // send shit... + for (int x = 0; x < this.cx_size; x++) { + for (int z = 0; z < this.cz_size; z++) { + + final Chunk c = this.myChunks[x][z]; + + for (int y = 1; y < 255; y += 32) { + WorldData.instance().compassData().service().updateArea(this.getWorld(), c.getPos().x << 4, y, + c.getPos().z << 4); + } + + // FIXME this was sending chunks to players... + SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits); + ((ServerChunkProvider) world.getChunkProvider()).chunkManager.getTrackingPlayers(c.getPos(), false) + .forEach(spe -> spe.connection.sendPacket(cdp)); + + } + } + + // FIXME check if this makes any sense at all to send changes to players asap + ServerChunkProvider serverChunkProvider = (ServerChunkProvider) world.getChunkProvider(); + serverChunkProvider.tick(() -> false); + } + + List getUpdates() { + return this.updates; + } + + World getWorld() { + return this.world; + } + + private static class BlockStorageData { + public BlockState state; + public int light; + } + + private class Column { + private final int x; + private final int z; + private final Chunk c; + private List skipThese = null; + + public Column(final Chunk chunk, final int x, final int z, final int chunkY, final int chunkHeight) { + this.x = x; + this.z = z; + this.c = chunk; + + final ChunkSection[] storage = this.c.getSections(); + + // make sure storage exists before hand... + for (int ay = 0; ay < chunkHeight; ay++) { + final int by = (ay + chunkY); + ChunkSection extendedblockstorage = storage[by]; + if (extendedblockstorage == null) { + extendedblockstorage = storage[by] = new ChunkSection(by << 4); + } + } + } + + private void setBlockState(final int y, BlockStorageData data) { + if (data.state == CachedPlane.this.matrixBlockState) { + data.state = Platform.AIR_BLOCK.getDefaultState(); + } + final ChunkSection[] storage = this.c.getSections(); + final ChunkSection extendedBlockStorage = storage[y >> 4]; + extendedBlockStorage.setBlockState(this.x, y & 15, this.z, data.state); + // FIXME extendedBlockStorage.setBlockLight( this.x, y & 15, this.z, data.light + // ); + } + + private void fillData(final int y, BlockStorageData data) { + final ChunkSection[] storage = this.c.getSections(); + final ChunkSection extendedblockstorage = storage[y >> 4]; + + data.state = extendedblockstorage.getBlockState(this.x, y & 15, this.z); + // FIXME data.light = extendedblockstorage.getBlockLight( this.x, y & 15, this.z + // ); + } + + private boolean doNotSkip(final int y) { + final ChunkSection[] storage = this.c.getSections(); + final ChunkSection extendedblockstorage = storage[y >> 4]; + if (CachedPlane.this.reg + .isBlacklisted(extendedblockstorage.getBlockState(this.x, y & 15, this.z).getBlock())) { + return false; + } + + return this.skipThese == null || !this.skipThese.contains(y); + } + + private void setSkip(final int yCoord) { + if (this.skipThese == null) { + this.skipThese = new ArrayList<>(); + } + this.skipThese.add(yCoord); + } + } } diff --git a/src/main/java/appeng/spatial/DefaultSpatialHandler.java b/src/main/java/appeng/spatial/DefaultSpatialHandler.java index 4ae60937f..49b90f815 100644 --- a/src/main/java/appeng/spatial/DefaultSpatialHandler.java +++ b/src/main/java/appeng/spatial/DefaultSpatialHandler.java @@ -18,7 +18,6 @@ package appeng.spatial; - import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -27,36 +26,31 @@ import net.minecraft.world.chunk.Chunk; import appeng.api.movable.IMovableHandler; +public class DefaultSpatialHandler implements IMovableHandler { -public class DefaultSpatialHandler implements IMovableHandler -{ + /** + * never called for the default. + * + * @param tile tile entity + * + * @return true + */ + @Override + public boolean canHandle(final Class myClass, final TileEntity tile) { + return true; + } - /** - * never called for the default. - * - * @param tile tile entity - * - * @return true - */ - @Override - public boolean canHandle( final Class myClass, final TileEntity tile ) - { - return true; - } + @Override + public void moveTile(final TileEntity te, final World w, final BlockPos newPosition) { + te.setWorldAndPos(w, newPosition); - @Override - public void moveTile( final TileEntity te, final World w, final BlockPos newPosition ) - { - te.setWorldAndPos( w, newPosition ); + final Chunk c = w.getChunkAt(newPosition); + c.addTileEntity(newPosition, te); - final Chunk c = w.getChunkAt( newPosition ); - c.addTileEntity( newPosition, te ); - - if( w.getChunkProvider().isChunkLoaded(c.getPos()) ) - { - final BlockState state = w.getBlockState( newPosition ); - w.addTileEntity( te ); - w.notifyBlockUpdate( newPosition, state, state, 1 ); - } - } + if (w.getChunkProvider().isChunkLoaded(c.getPos())) { + final BlockState state = w.getBlockState(newPosition); + w.addTileEntity(te); + w.notifyBlockUpdate(newPosition, state, state, 1); + } + } } diff --git a/src/main/java/appeng/spatial/ISpatialVisitor.java b/src/main/java/appeng/spatial/ISpatialVisitor.java index dd2784526..4a89d1359 100644 --- a/src/main/java/appeng/spatial/ISpatialVisitor.java +++ b/src/main/java/appeng/spatial/ISpatialVisitor.java @@ -18,12 +18,9 @@ package appeng.spatial; - import net.minecraft.util.math.BlockPos; +public interface ISpatialVisitor { -public interface ISpatialVisitor -{ - - void visit( BlockPos pos ); + void visit(BlockPos pos); } diff --git a/src/main/java/appeng/spatial/SpatialDimensionExtraData.java b/src/main/java/appeng/spatial/SpatialDimensionExtraData.java index eeaded2b9..5912c87f2 100644 --- a/src/main/java/appeng/spatial/SpatialDimensionExtraData.java +++ b/src/main/java/appeng/spatial/SpatialDimensionExtraData.java @@ -1,17 +1,20 @@ package appeng.spatial; -import appeng.core.AELog; -import io.netty.buffer.Unpooled; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; - import javax.annotation.Nullable; +import io.netty.buffer.Unpooled; + +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; + +import appeng.core.AELog; + /** - * Helps with encoding and decoding the extra data we attach to the - * spatial {@link net.minecraft.world.dimension.DimensionType} as "extra data". - * Keep in mind this data will also be sent to the client unless - * {@link net.minecraftforge.common.ModDimension#write(PacketBuffer, boolean)} is overridden. + * Helps with encoding and decoding the extra data we attach to the spatial + * {@link net.minecraft.world.dimension.DimensionType} as "extra data". Keep in + * mind this data will also be sent to the client unless + * {@link net.minecraftforge.common.ModDimension#write(PacketBuffer, boolean)} + * is overridden. */ public final class SpatialDimensionExtraData { @@ -19,8 +22,9 @@ public final class SpatialDimensionExtraData { private static final int CURRENT_FORMAT = 1; /** - * The storage size of this dimension. This is dicateted by the pylon structure size used to perform - * the first transfer into this dimension. Once it's set, it cannot be changed anymore. + * The storage size of this dimension. This is dicateted by the pylon structure + * size used to perform the first transfer into this dimension. Once it's set, + * it cannot be changed anymore. */ private final BlockPos size; @@ -50,7 +54,8 @@ public final class SpatialDimensionExtraData { buf.readerIndex(0); byte version = buf.readByte(); if (version != CURRENT_FORMAT) { - // Currently no new format has been defined, as such anything but the current version is invalid + // Currently no new format has been defined, as such anything but the current + // version is invalid return null; } diff --git a/src/main/java/appeng/spatial/SpatialDimensionManager.java b/src/main/java/appeng/spatial/SpatialDimensionManager.java index 437a702fb..7d92e0801 100644 --- a/src/main/java/appeng/spatial/SpatialDimensionManager.java +++ b/src/main/java/appeng/spatial/SpatialDimensionManager.java @@ -18,11 +18,11 @@ package appeng.spatial; +import java.util.List; +import java.util.Locale; + +import javax.annotation.Nullable; -import appeng.api.storage.ISpatialDimension; -import appeng.core.AELog; -import appeng.core.AppEng; -import appeng.core.localization.GuiText; import net.minecraft.network.PacketBuffer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; @@ -33,144 +33,138 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.server.ServerLifecycleHooks; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Locale; +import appeng.api.storage.ISpatialDimension; +import appeng.core.AELog; +import appeng.core.AppEng; +import appeng.core.localization.GuiText; +public final class SpatialDimensionManager implements ISpatialDimension { -public final class SpatialDimensionManager implements ISpatialDimension -{ + public static final ISpatialDimension INSTANCE = new SpatialDimensionManager(); - public static final ISpatialDimension INSTANCE = new SpatialDimensionManager(); + private static final String DIM_ID_PREFIX = "spatial_"; - private static final String DIM_ID_PREFIX = "spatial_"; + private SpatialDimensionManager() { + } - private SpatialDimensionManager() { - } + @Override + public ServerWorld getWorld(DimensionType cellDim) { + return DimensionManager.getWorld(getServer(), cellDim, true, true); + } - @Override - public ServerWorld getWorld(DimensionType cellDim) { - return DimensionManager.getWorld(getServer(), cellDim, true, true); - } + @Override + public DimensionType createNewCellDimension(BlockPos size) { + ResourceLocation dimKey = findFreeDimensionId(); + AELog.info("Allocating storage cell dimension '%s'", dimKey); - @Override - public DimensionType createNewCellDimension(BlockPos size) - { - ResourceLocation dimKey = findFreeDimensionId(); - AELog.info("Allocating storage cell dimension '%s'", dimKey); + PacketBuffer extraData = new SpatialDimensionExtraData(size).write(); - PacketBuffer extraData = new SpatialDimensionExtraData(size).write(); + return DimensionManager.registerDimension(dimKey, StorageCellModDimension.INSTANCE, extraData, true); + } - return DimensionManager.registerDimension(dimKey, StorageCellModDimension.INSTANCE, extraData, true); - } + /** + * Tries finding the next free storage cell dimension ID based on the currently + * registered storage cell dimensions. + */ + private ResourceLocation findFreeDimensionId() { + int maxId = 0; + for (DimensionType dimensionType : DimensionType.getAll()) { + ResourceLocation regName = dimensionType.getRegistryName(); + if (regName == null || !AppEng.MOD_ID.equals(regName.getNamespace())) { + continue; + } - /** - * Tries finding the next free storage cell dimension ID based on the currently registered storage - * cell dimensions. - */ - private ResourceLocation findFreeDimensionId() { - int maxId = 0; - for (DimensionType dimensionType : DimensionType.getAll()) { - ResourceLocation regName = dimensionType.getRegistryName(); - if (regName == null || !AppEng.MOD_ID.equals(regName.getNamespace())) { - continue; - } + String path = regName.getPath(); + if (!path.startsWith(DIM_ID_PREFIX)) { + continue; + } - String path = regName.getPath(); - if (!path.startsWith(DIM_ID_PREFIX)) { - continue; - } + try { + String numericIdPart = path.substring(DIM_ID_PREFIX.length()); + maxId = Math.max(Integer.parseUnsignedInt(numericIdPart), maxId); + } catch (NumberFormatException e) { + AELog.warn("Unparsable storage cell dimension id '%s'", path, e); + } + } - try { - String numericIdPart = path.substring(DIM_ID_PREFIX.length()); - maxId = Math.max(Integer.parseUnsignedInt(numericIdPart), maxId); - } catch (NumberFormatException e) { - AELog.warn("Unparsable storage cell dimension id '%s'", path, e); - } - } + ++maxId; - ++maxId; + return new ResourceLocation(AppEng.MOD_ID, DIM_ID_PREFIX + maxId); + } - return new ResourceLocation(AppEng.MOD_ID, DIM_ID_PREFIX + maxId); - } + @Override + public void deleteCellDimension(DimensionType cellDim) { + AELog.info("Unregistering storage cell dimension %s", cellDim.getRegistryName()); + MinecraftServer server = getServer(); + ServerWorld world = DimensionManager.getWorld(server, cellDim, false, false); + if (world != null) { + DimensionManager.unloadWorld(world); + } + DimensionManager.unloadWorlds(server, true); + DimensionManager.unregisterDimension(cellDim.getId()); + } - @Override - public void deleteCellDimension( DimensionType cellDim ) - { - AELog.info("Unregistering storage cell dimension %s", cellDim.getRegistryName()); - MinecraftServer server = getServer(); - ServerWorld world = DimensionManager.getWorld(server, cellDim, false, false); - if (world != null) { - DimensionManager.unloadWorld(world); - } - DimensionManager.unloadWorlds(server, true); - DimensionManager.unregisterDimension(cellDim.getId()); - } + @Override + public boolean isCellDimension(DimensionType cellDim) { + // Check if the cell dimension type is even registered + if (cellDim.getRegistryName() == null || !cellDim.getRegistryName().equals(DimensionType.getKey(cellDim))) { + return false; + } - @Override - public boolean isCellDimension( DimensionType cellDim ) - { - // Check if the cell dimension type is even registered - if (cellDim.getRegistryName() == null || !cellDim.getRegistryName().equals(DimensionType.getKey(cellDim))) { - return false; - } + return cellDim.getModType() instanceof StorageCellModDimension; + } - return cellDim.getModType() instanceof StorageCellModDimension; - } + @Override + public BlockPos getCellDimensionOrigin(DimensionType cellDim) { + return StorageCellDimension.REGION_CENTER; + } - @Override - public BlockPos getCellDimensionOrigin( DimensionType cellDim ) - { - return StorageCellDimension.REGION_CENTER; - } + @Override + public BlockPos getCellDimensionSize(DimensionType cellDim) { + SpatialDimensionExtraData extraData = getExtraData(cellDim); + return extraData != null ? extraData.getSize() : BlockPos.ZERO; + } - @Override - public BlockPos getCellDimensionSize(DimensionType cellDim ) - { - SpatialDimensionExtraData extraData = getExtraData(cellDim); - return extraData != null ? extraData.getSize() : BlockPos.ZERO; - } + @Override + public void addCellDimensionTooltip(DimensionType cellDim, List lines) { + // Check if the cell dimension type is even registered + ResourceLocation registryName = cellDim.getRegistryName(); + if (registryName == null || !AppEng.MOD_ID.equals(registryName.getNamespace())) { + return; + } - @Override - public void addCellDimensionTooltip(DimensionType cellDim, List lines) { - // Check if the cell dimension type is even registered - ResourceLocation registryName = cellDim.getRegistryName(); - if (registryName == null || !AppEng.MOD_ID.equals(registryName.getNamespace())) { - return; - } + if (!registryName.getPath().startsWith(DIM_ID_PREFIX)) { + return; + } - if (!registryName.getPath().startsWith(DIM_ID_PREFIX)) { - return; - } + // Add the actual stored size + BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(cellDim); + lines.add(GuiText.StoredSize.textComponent(size.getX(), size.getY(), size.getZ())); - // Add the actual stored size - BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(cellDim); - lines.add( GuiText.StoredSize.textComponent(size.getX(), size.getY(), size.getZ())); + // Add a serial number to allows players to keep different cells apart + int dimId; + try { + String numericIdPart = registryName.getPath().substring(DIM_ID_PREFIX.length()); + dimId = Integer.parseUnsignedInt(numericIdPart); + } catch (NumberFormatException ignored) { + return; + } - // Add a serial number to allows players to keep different cells apart - int dimId; - try { - String numericIdPart = registryName.getPath().substring(DIM_ID_PREFIX.length()); - dimId = Integer.parseUnsignedInt(numericIdPart); - } catch (NumberFormatException ignored) { - return; - } + // Try to make this a little more flavorful. + String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId); + lines.add(GuiText.SerialNumber.textComponent(serialNumber)); + } - // Try to make this a little more flavorful. - String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId); - lines.add(GuiText.SerialNumber.textComponent(serialNumber)); - } + @Nullable + private SpatialDimensionExtraData getExtraData(DimensionType cellDim) { + if (!(cellDim.getModType() instanceof StorageCellModDimension)) { + return null; + } + return SpatialDimensionExtraData.read(cellDim.getData()); + } - @Nullable - private SpatialDimensionExtraData getExtraData( DimensionType cellDim) { - if (!(cellDim.getModType() instanceof StorageCellModDimension)) { - return null; - } - return SpatialDimensionExtraData.read(cellDim.getData()); - } - - private static MinecraftServer getServer() { - return ServerLifecycleHooks.getCurrentServer(); - } + private static MinecraftServer getServer() { + return ServerLifecycleHooks.getCurrentServer(); + } } diff --git a/src/main/java/appeng/spatial/StorageCellBiome.java b/src/main/java/appeng/spatial/StorageCellBiome.java index 9225af502..9da3c6d7b 100644 --- a/src/main/java/appeng/spatial/StorageCellBiome.java +++ b/src/main/java/appeng/spatial/StorageCellBiome.java @@ -18,7 +18,6 @@ package appeng.spatial; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; @@ -26,30 +25,19 @@ import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +public class StorageCellBiome extends Biome { -public class StorageCellBiome extends Biome -{ + public static final StorageCellBiome INSTANCE = new StorageCellBiome(); - public static final StorageCellBiome INSTANCE = new StorageCellBiome(); + static { + INSTANCE.setRegistryName("appliedenergistics2:storage"); + } - static { - INSTANCE.setRegistryName("appliedenergistics2:storage"); - } - - public StorageCellBiome() - { - super( new Biome.Builder() - .surfaceBuilder(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG) - .precipitation(RainType.NONE) - .category(Category.NONE) - .depth(0) - .scale(1) - // Copied from the vanilla void biome - .temperature(0.5F) - .downfall(0.5F) - .waterColor(4159204) - .waterFogColor(329011) - .parent(null) ); + public StorageCellBiome() { + super(new Biome.Builder().surfaceBuilder(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG) + .precipitation(RainType.NONE).category(Category.NONE).depth(0).scale(1) + // Copied from the vanilla void biome + .temperature(0.5F).downfall(0.5F).waterColor(4159204).waterFogColor(329011).parent(null)); // FIXME this.decorator.treesPerChunk = 0; // FIXME this.decorator.flowersPerChunk = 0; // FIXME this.decorator.grassPerChunk = 0; @@ -58,26 +46,26 @@ public class StorageCellBiome extends Biome // FIXME this.spawnableCreatureList.clear(); // FIXME this.spawnableWaterCreatureList.clear(); // FIXME this.spawnableCaveCreatureList.clear(); - } + } - @OnlyIn(Dist.CLIENT) - public int getSkyColor() { - return 0x111111; - } + @OnlyIn(Dist.CLIENT) + public int getSkyColor() { + return 0x111111; + } - @Override - public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos pos) { - return false; - } + @Override + public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos pos) { + return false; + } - @Override - public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos water, boolean mustBeAtEdge) { - return false; - } + @Override + public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos water, boolean mustBeAtEdge) { + return false; + } - @Override - public boolean doesSnowGenerate(IWorldReader worldIn, BlockPos pos) { - return false; - } + @Override + public boolean doesSnowGenerate(IWorldReader worldIn, BlockPos pos) { + return false; + } } diff --git a/src/main/java/appeng/spatial/StorageCellDimension.java b/src/main/java/appeng/spatial/StorageCellDimension.java index 4f65a3058..3a7647710 100644 --- a/src/main/java/appeng/spatial/StorageCellDimension.java +++ b/src/main/java/appeng/spatial/StorageCellDimension.java @@ -18,6 +18,7 @@ package appeng.spatial; +import javax.annotation.Nullable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; @@ -28,123 +29,107 @@ import net.minecraft.world.chunk.Chunk; import net.minecraft.world.dimension.Dimension; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.ChunkGenerator; -import net.minecraftforge.client.IRenderHandler; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.IRenderHandler; import appeng.client.render.SpatialSkyRender; import appeng.core.AppEng; -import javax.annotation.Nullable; +public class StorageCellDimension extends Dimension { -public class StorageCellDimension extends Dimension -{ + // A region file is 512x512 blocks (32x32 chunks), + // to avoid creating the 4 regions around 0,0,0, + // we move the origin to the middle of region 0,0 + public static final BlockPos REGION_CENTER = new BlockPos(512 / 2, 64, 512 / 2); - // A region file is 512x512 blocks (32x32 chunks), - // to avoid creating the 4 regions around 0,0,0, - // we move the origin to the middle of region 0,0 - public static final BlockPos REGION_CENTER = new BlockPos(512 / 2, 64, 512 / 2); + public StorageCellDimension(World world, DimensionType dimensionType) { + // FIXME: check light value + super(world, dimensionType, 1.0f); + } - public StorageCellDimension(World world, DimensionType dimensionType) { - // FIXME: check light value - super(world, dimensionType, 1.0f); - } + @Override + public ChunkGenerator createChunkGenerator() { + return new StorageChunkGenerator(this.world); + } - @Override - public ChunkGenerator createChunkGenerator() - { - return new StorageChunkGenerator( this.world ); - } + @Override + public float calculateCelestialAngle(final long par1, final float par3) { + return 0; + } - @Override - public float calculateCelestialAngle( final long par1, final float par3 ) - { - return 0; - } + @Override + public boolean isSurfaceWorld() { + return false; + } - @Override - public boolean isSurfaceWorld() - { - return false; - } + @Override + @OnlyIn(Dist.CLIENT) + public float[] calcSunriseSunsetColors(final float celestialAngle, final float partialTicks) { + return null; + } - @Override - @OnlyIn( Dist.CLIENT ) - public float[] calcSunriseSunsetColors( final float celestialAngle, final float partialTicks ) - { - return null; - } + @Override + public Vec3d getFogColor(final float par1, final float par2) { + return new Vec3d(0.07, 0.07, 0.07); + } - @Override - public Vec3d getFogColor( final float par1, final float par2 ) - { - return new Vec3d( 0.07, 0.07, 0.07 ); - } + @Override + public boolean canRespawnHere() { + return false; + } - @Override - public boolean canRespawnHere() - { - return false; - } + @Override + @OnlyIn(Dist.CLIENT) + public boolean isSkyColored() { + return true; + } - @Override - @OnlyIn( Dist.CLIENT ) - public boolean isSkyColored() - { - return true; - } + @Override + public boolean doesXZShowFog(final int par1, final int par2) { + return false; + } - @Override - public boolean doesXZShowFog( final int par1, final int par2 ) - { - return false; - } + @Override + public IRenderHandler getSkyRenderer() { + return SpatialSkyRender.getInstance(); + } - @Override - public IRenderHandler getSkyRenderer() - { - return SpatialSkyRender.getInstance(); - } + @Override + public boolean isDaytime() { + return false; + } - @Override - public boolean isDaytime() - { - return false; - } + @Override + public BlockPos getSpawnCoordinate() { + return REGION_CENTER; + } - @Override - public BlockPos getSpawnCoordinate() - { - return REGION_CENTER; - } + @Override + public boolean isHighHumidity(final BlockPos pos) { + return false; + } - @Override - public boolean isHighHumidity( final BlockPos pos ) - { - return false; - } + @Override + public boolean canDoLightning(final Chunk chunk) { + return false; + } - @Override - public boolean canDoLightning( final Chunk chunk ) - { - return false; - } + @Override + public boolean canDoRainSnowIce(Chunk chunk) { + return false; + } - @Override - public boolean canDoRainSnowIce(Chunk chunk) { - return false; - } + @Nullable + @Override + public BlockPos findSpawn(ChunkPos chunkPosIn, boolean checkValid) { + return getSpawnCoordinate(); + } - @Nullable - @Override - public BlockPos findSpawn(ChunkPos chunkPosIn, boolean checkValid) { - return getSpawnCoordinate(); - } - - @Nullable - @Override - public BlockPos findSpawn(int posX, int posZ, boolean checkValid) { - return getSpawnCoordinate(); - } + @Nullable + @Override + public BlockPos findSpawn(int posX, int posZ, boolean checkValid) { + return getSpawnCoordinate(); + } } diff --git a/src/main/java/appeng/spatial/StorageCellModDimension.java b/src/main/java/appeng/spatial/StorageCellModDimension.java index 2f4e4c845..6307f50b6 100644 --- a/src/main/java/appeng/spatial/StorageCellModDimension.java +++ b/src/main/java/appeng/spatial/StorageCellModDimension.java @@ -18,27 +18,26 @@ package appeng.spatial; +import java.util.function.BiFunction; -import appeng.core.AppEng; import net.minecraft.world.World; import net.minecraft.world.dimension.Dimension; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.common.ModDimension; -import java.util.function.BiFunction; +import appeng.core.AppEng; -public class StorageCellModDimension extends ModDimension -{ +public class StorageCellModDimension extends ModDimension { - public static final StorageCellModDimension INSTANCE = new StorageCellModDimension(); + public static final StorageCellModDimension INSTANCE = new StorageCellModDimension(); - static { - INSTANCE.setRegistryName(AppEng.MOD_ID, "storage_cell"); - } + static { + INSTANCE.setRegistryName(AppEng.MOD_ID, "storage_cell"); + } - @Override - public BiFunction getFactory() { - return StorageCellDimension::new; - } + @Override + public BiFunction getFactory() { + return StorageCellDimension::new; + } } diff --git a/src/main/java/appeng/spatial/StorageChunkGenerator.java b/src/main/java/appeng/spatial/StorageChunkGenerator.java index 8dabc34e8..045945440 100644 --- a/src/main/java/appeng/spatial/StorageChunkGenerator.java +++ b/src/main/java/appeng/spatial/StorageChunkGenerator.java @@ -18,8 +18,6 @@ package appeng.spatial; - - import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; @@ -29,76 +27,70 @@ import net.minecraft.world.biome.provider.SingleBiomeProvider; import net.minecraft.world.biome.provider.SingleBiomeProviderSettings; import net.minecraft.world.chunk.IChunk; import net.minecraft.world.gen.ChunkGenerator; - -import appeng.api.AEApi; import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.WorldGenRegion; +import appeng.api.AEApi; -public class StorageChunkGenerator extends ChunkGenerator -{ +public class StorageChunkGenerator extends ChunkGenerator { - private final BlockState defaultBlockState; + private final BlockState defaultBlockState; - public StorageChunkGenerator(final World world ) - { - super( world, createBiomeProvider(), createSettings() ); - this.defaultBlockState = AEApi.instance().definitions().blocks().matrixFrame().block().getDefaultState(); - } + public StorageChunkGenerator(final World world) { + super(world, createBiomeProvider(), createSettings()); + this.defaultBlockState = AEApi.instance().definitions().blocks().matrixFrame().block().getDefaultState(); + } - private static BiomeProvider createBiomeProvider() { - SingleBiomeProviderSettings biomeSettings = new SingleBiomeProviderSettings(null); - biomeSettings.setBiome(StorageCellBiome.INSTANCE); - return new SingleBiomeProvider(biomeSettings); - } + private static BiomeProvider createBiomeProvider() { + SingleBiomeProviderSettings biomeSettings = new SingleBiomeProviderSettings(null); + biomeSettings.setBiome(StorageCellBiome.INSTANCE); + return new SingleBiomeProvider(biomeSettings); + } - private static GenerationSettings createSettings() { - return new GenerationSettings(); - } + private static GenerationSettings createSettings() { + return new GenerationSettings(); + } - @Override - public void generateSurface(WorldGenRegion region, IChunk chunk) { - this.fillChunk( chunk ); - chunk.setModified( false ); - } + @Override + public void generateSurface(WorldGenRegion region, IChunk chunk) { + this.fillChunk(chunk); + chunk.setModified(false); + } - private void fillChunk( IChunk chunk ) - { - BlockPos.Mutable mutPos = new BlockPos.Mutable(); - for( int cx = 0; cx < 16; cx++ ) - { - mutPos.setX(cx); - for( int cz = 0; cz < 16; cz++ ) - { - // FIXME: It's likely a bad idea to fill Y in the inner-loop given the storage layout of chunks - mutPos.setZ(cz); - for( int cy = 0; cy < 256; cy++ ) - { - mutPos.setY(cy); - chunk.setBlockState(mutPos, defaultBlockState, false); - } - } - } - } + private void fillChunk(IChunk chunk) { + BlockPos.Mutable mutPos = new BlockPos.Mutable(); + for (int cx = 0; cx < 16; cx++) { + mutPos.setX(cx); + for (int cz = 0; cz < 16; cz++) { + // FIXME: It's likely a bad idea to fill Y in the inner-loop given the storage + // layout of chunks + mutPos.setZ(cz); + for (int cy = 0; cy < 256; cy++) { + mutPos.setY(cy); + chunk.setBlockState(mutPos, defaultBlockState, false); + } + } + } + } - @Override - public int getGroundHeight() { - return 0; - } + @Override + public int getGroundHeight() { + return 0; + } - @Override - public void makeBase(IWorld worldIn, IChunk chunkIn) { - } + @Override + public void makeBase(IWorld worldIn, IChunk chunkIn) { + } - @Override - public int func_222529_a(int p_222529_1_, int p_222529_2_, Heightmap.Type heightmapType) { - return 0; - } + @Override + public int func_222529_a(int p_222529_1_, int p_222529_2_, Heightmap.Type heightmapType) { + return 0; + } - @Override - public void decorate(WorldGenRegion region) { - // Do not decorate chunks at all - } + @Override + public void decorate(WorldGenRegion region) { + // Do not decorate chunks at all + } } diff --git a/src/main/java/appeng/spatial/StorageHelper.java b/src/main/java/appeng/spatial/StorageHelper.java index 86517c91e..414291b6f 100644 --- a/src/main/java/appeng/spatial/StorageHelper.java +++ b/src/main/java/appeng/spatial/StorageHelper.java @@ -18,7 +18,6 @@ package appeng.spatial; - import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -40,245 +39,219 @@ import appeng.api.util.WorldCoord; import appeng.core.AppEng; import appeng.util.Platform; +public class StorageHelper { -public class StorageHelper -{ + private static StorageHelper instance; - private static StorageHelper instance; + public static StorageHelper getInstance() { + if (instance == null) { + instance = new StorageHelper(); + } + return instance; + } - public static StorageHelper getInstance() - { - if( instance == null ) - { - instance = new StorageHelper(); - } - return instance; - } + /** + * Mostly from dimensional doors.. which mostly got it form X-Comp. + * + * @param entity to be teleported entity + * @param link destination + * + * @return teleported entity + */ + private Entity teleportEntity(Entity entity, final TelDestination link) { + final ServerWorld oldWorld; + final ServerWorld newWorld; - /** - * Mostly from dimensional doors.. which mostly got it form X-Comp. - * - * @param entity to be teleported entity - * @param link destination - * - * @return teleported entity - */ - private Entity teleportEntity( Entity entity, final TelDestination link ) - { - final ServerWorld oldWorld; - final ServerWorld newWorld; + try { + oldWorld = (ServerWorld) entity.world; + newWorld = (ServerWorld) link.dim; + } catch (final Throwable e) { + return entity; + } - try - { - oldWorld = (ServerWorld) entity.world; - newWorld = (ServerWorld) link.dim; - } - catch( final Throwable e ) - { - return entity; - } + if (oldWorld == null) { + return entity; + } + if (newWorld == null) { + return entity; + } + if (newWorld == oldWorld) { + return entity; + } - if( oldWorld == null ) - { - return entity; - } - if( newWorld == null ) - { - return entity; - } - if( newWorld == oldWorld ) - { - return entity; - } + // Are we riding something? Teleport it instead. + if (entity.isPassenger()) { + return this.teleportEntity(entity.getRidingEntity(), link); + } - // Are we riding something? Teleport it instead. - if( entity.isPassenger() ) - { - return this.teleportEntity( entity.getRidingEntity(), link ); - } + // Is something riding us? Handle it first. + final List passengers = entity.getPassengers(); + final List passengersOnOtherSide = new ArrayList<>(passengers.size()); + for (Entity passenger : passengers) { + passenger.stopRiding(); + passengersOnOtherSide.add(this.teleportEntity(passenger, link)); + } + // We keep track of all so we can remount them on the other side. - // Is something riding us? Handle it first. - final List passengers = entity.getPassengers(); - final List passengersOnOtherSide = new ArrayList<>(passengers.size()); - for( Entity passenger : passengers ) - { - passenger.stopRiding(); - passengersOnOtherSide.add( this.teleportEntity( passenger, link ) ); - } - // We keep track of all so we can remount them on the other side. + // load the chunk! + newWorld.getChunkProvider().getChunk(MathHelper.floor(link.x) >> 4, MathHelper.floor(link.z) >> 4, + ChunkStatus.FULL, true); - // load the chunk! - newWorld.getChunkProvider().getChunk( MathHelper.floor( link.x ) >> 4, MathHelper.floor( link.z ) >> 4, ChunkStatus.FULL, true ); + if (entity instanceof ServerPlayerEntity && link.dim.getDimension() instanceof StorageCellDimension) { + AppEng.instance().getAdvancementTriggers().getSpatialExplorer().trigger((ServerPlayerEntity) entity); + } - if( entity instanceof ServerPlayerEntity && link.dim.getDimension() instanceof StorageCellDimension) - { - AppEng.instance().getAdvancementTriggers().getSpatialExplorer().trigger( (ServerPlayerEntity) entity ); - } + entity.changeDimension(link.dim.getDimension().getType(), new METeleporter(link)); - entity.changeDimension( link.dim.getDimension().getType(), new METeleporter( link ) ); + if (!passengersOnOtherSide.isEmpty()) { + for (Entity passanger : passengersOnOtherSide) { + passanger.startRiding(entity, true); + } + } - if( !passengersOnOtherSide.isEmpty() ) - { - for( Entity passanger : passengersOnOtherSide ) - { - passanger.startRiding( entity, true ); - } - } + return entity; + } - return entity; - } + private void transverseEdges(final int minX, final int minY, final int minZ, final int maxX, final int maxY, + final int maxZ, final ISpatialVisitor visitor) { + for (int y = minY; y < maxY; y++) { + for (int z = minZ; z < maxZ; z++) { + visitor.visit(new BlockPos(minX, y, z)); + visitor.visit(new BlockPos(maxX, y, z)); + } + } - private void transverseEdges( final int minX, final int minY, final int minZ, final int maxX, final int maxY, final int maxZ, final ISpatialVisitor visitor ) - { - for( int y = minY; y < maxY; y++ ) - { - for( int z = minZ; z < maxZ; z++ ) - { - visitor.visit( new BlockPos( minX, y, z ) ); - visitor.visit( new BlockPos( maxX, y, z ) ); - } - } + for (int x = minX; x < maxX; x++) { + for (int z = minZ; z < maxZ; z++) { + visitor.visit(new BlockPos(x, minY, z)); + visitor.visit(new BlockPos(x, maxY, z)); + } + } - for( int x = minX; x < maxX; x++ ) - { - for( int z = minZ; z < maxZ; z++ ) - { - visitor.visit( new BlockPos( x, minY, z ) ); - visitor.visit( new BlockPos( x, maxY, z ) ); - } - } + for (int x = minX; x < maxX; x++) { + for (int y = minY; y < maxY; y++) { + visitor.visit(new BlockPos(x, y, minZ)); + visitor.visit(new BlockPos(x, y, maxZ)); + } + } + } - for( int x = minX; x < maxX; x++ ) - { - for( int y = minY; y < maxY; y++ ) - { - visitor.visit( new BlockPos( x, y, minZ ) ); - visitor.visit( new BlockPos( x, y, maxZ ) ); - } - } - } + public void swapRegions(final World srcWorld, final int srcX, final int srcY, final int srcZ, final World dstWorld, + final int dstX, final int dstY, final int dstZ, final int scaleX, final int scaleY, final int scaleZ) { + AEApi.instance().definitions().blocks().matrixFrame().maybeBlock() + .ifPresent(matrixFrameBlock -> this.transverseEdges(dstX - 1, dstY - 1, dstZ - 1, dstX + scaleX + 1, + dstY + scaleY + 1, dstZ + scaleZ + 1, + new WrapInMatrixFrame(matrixFrameBlock.getDefaultState(), dstWorld))); - public void swapRegions( final World srcWorld, final int srcX, final int srcY, final int srcZ, final World dstWorld, final int dstX, final int dstY, final int dstZ, final int scaleX, final int scaleY, final int scaleZ ) - { - AEApi.instance() - .definitions() - .blocks() - .matrixFrame() - .maybeBlock() - .ifPresent( matrixFrameBlock -> this.transverseEdges( dstX - 1, dstY - 1, dstZ - 1, - dstX + scaleX + 1, dstY + scaleY + 1, dstZ + scaleZ + 1, new WrapInMatrixFrame( matrixFrameBlock.getDefaultState(), dstWorld ) ) ); + final AxisAlignedBB srcBox = new AxisAlignedBB(srcX, srcY, srcZ, srcX + scaleX + 1, srcY + scaleY + 1, + srcZ + scaleZ + 1); - final AxisAlignedBB srcBox = new AxisAlignedBB( srcX, srcY, srcZ, srcX + scaleX + 1, srcY + scaleY + 1, srcZ + scaleZ + 1 ); + final AxisAlignedBB dstBox = new AxisAlignedBB(dstX, dstY, dstZ, dstX + scaleX + 1, dstY + scaleY + 1, + dstZ + scaleZ + 1); - final AxisAlignedBB dstBox = new AxisAlignedBB( dstX, dstY, dstZ, dstX + scaleX + 1, dstY + scaleY + 1, dstZ + scaleZ + 1 ); + final CachedPlane cDst = new CachedPlane(dstWorld, dstX, dstY, dstZ, dstX + scaleX, dstY + scaleY, + dstZ + scaleZ); + final CachedPlane cSrc = new CachedPlane(srcWorld, srcX, srcY, srcZ, srcX + scaleX, srcY + scaleY, + srcZ + scaleZ); - final CachedPlane cDst = new CachedPlane( dstWorld, dstX, dstY, dstZ, dstX + scaleX, dstY + scaleY, dstZ + scaleZ ); - final CachedPlane cSrc = new CachedPlane( srcWorld, srcX, srcY, srcZ, srcX + scaleX, srcY + scaleY, srcZ + scaleZ ); + // do nearly all the work... swaps blocks, tiles, and block ticks + cSrc.swap(cDst); - // do nearly all the work... swaps blocks, tiles, and block ticks - cSrc.swap( cDst ); + final List srcE = srcWorld.getEntitiesWithinAABB(Entity.class, srcBox); + final List dstE = dstWorld.getEntitiesWithinAABB(Entity.class, dstBox); - final List srcE = srcWorld.getEntitiesWithinAABB( Entity.class, srcBox ); - final List dstE = dstWorld.getEntitiesWithinAABB( Entity.class, dstBox ); + for (final Entity e : dstE) { + this.teleportEntity(e, new TelDestination(srcWorld, srcBox, e.getPosX(), e.getPosY(), e.getPosZ(), + -dstX + srcX, -dstY + srcY, -dstZ + srcZ)); + } - for( final Entity e : dstE ) - { - this.teleportEntity( e, new TelDestination( srcWorld, srcBox, e.getPosX(), e.getPosY(), e.getPosZ(), -dstX + srcX, -dstY + srcY, -dstZ + srcZ ) ); - } + for (final Entity e : srcE) { + this.teleportEntity(e, new TelDestination(dstWorld, dstBox, e.getPosX(), e.getPosY(), e.getPosZ(), + -srcX + dstX, -srcY + dstY, -srcZ + dstZ)); + } - for( final Entity e : srcE ) - { - this.teleportEntity( e, new TelDestination( dstWorld, dstBox, e.getPosX(), e.getPosY(), e.getPosZ(), -srcX + dstX, -srcY + dstY, -srcZ + dstZ ) ); - } + for (final WorldCoord wc : cDst.getUpdates()) { + cSrc.getWorld().notifyNeighborsOfStateChange(wc.getPos(), Platform.AIR_BLOCK); + } - for( final WorldCoord wc : cDst.getUpdates() ) - { - cSrc.getWorld().notifyNeighborsOfStateChange( wc.getPos(), Platform.AIR_BLOCK ); - } + for (final WorldCoord wc : cSrc.getUpdates()) { + cSrc.getWorld().notifyNeighborsOfStateChange(wc.getPos(), Platform.AIR_BLOCK); + } - for( final WorldCoord wc : cSrc.getUpdates() ) - { - cSrc.getWorld().notifyNeighborsOfStateChange( wc.getPos(), Platform.AIR_BLOCK ); - } + this.transverseEdges(srcX - 1, srcY - 1, srcZ - 1, srcX + scaleX + 1, srcY + scaleY + 1, srcZ + scaleZ + 1, + new TriggerUpdates(srcWorld)); + this.transverseEdges(dstX - 1, dstY - 1, dstZ - 1, dstX + scaleX + 1, dstY + scaleY + 1, dstZ + scaleZ + 1, + new TriggerUpdates(dstWorld)); - this.transverseEdges( srcX - 1, srcY - 1, srcZ - 1, srcX + scaleX + 1, srcY + scaleY + 1, srcZ + scaleZ + 1, new TriggerUpdates( srcWorld ) ); - this.transverseEdges( dstX - 1, dstY - 1, dstZ - 1, dstX + scaleX + 1, dstY + scaleY + 1, dstZ + scaleZ + 1, new TriggerUpdates( dstWorld ) ); + this.transverseEdges(srcX, srcY, srcZ, srcX + scaleX, srcY + scaleY, srcZ + scaleZ, + new TriggerUpdates(srcWorld)); + this.transverseEdges(dstX, dstY, dstZ, dstX + scaleX, dstY + scaleY, dstZ + scaleZ, + new TriggerUpdates(dstWorld)); + } - this.transverseEdges( srcX, srcY, srcZ, srcX + scaleX, srcY + scaleY, srcZ + scaleZ, new TriggerUpdates( srcWorld ) ); - this.transverseEdges( dstX, dstY, dstZ, dstX + scaleX, dstY + scaleY, dstZ + scaleZ, new TriggerUpdates( dstWorld ) ); - } + private static class TriggerUpdates implements ISpatialVisitor { - private static class TriggerUpdates implements ISpatialVisitor - { + private final World dst; - private final World dst; + public TriggerUpdates(final World dst2) { + this.dst = dst2; + } - public TriggerUpdates( final World dst2 ) - { - this.dst = dst2; - } + @Override + public void visit(final BlockPos pos) { + final BlockState state = this.dst.getBlockState(pos); + final Block blk = state.getBlock(); + blk.neighborChanged(state, this.dst, pos, blk, pos, false); + } + } - @Override - public void visit( final BlockPos pos ) - { - final BlockState state = this.dst.getBlockState( pos ); - final Block blk = state.getBlock(); - blk.neighborChanged( state, this.dst, pos, blk, pos, false ); - } - } + private static class WrapInMatrixFrame implements ISpatialVisitor { - private static class WrapInMatrixFrame implements ISpatialVisitor - { + private final World dst; + private final BlockState state; - private final World dst; - private final BlockState state; + public WrapInMatrixFrame(final BlockState state, final World dst2) { + this.dst = dst2; + this.state = state; + } - public WrapInMatrixFrame( final BlockState state, final World dst2 ) - { - this.dst = dst2; - this.state = state; - } + @Override + public void visit(final BlockPos pos) { + this.dst.setBlockState(pos, this.state); + } + } - @Override - public void visit( final BlockPos pos ) - { - this.dst.setBlockState( pos, this.state ); - } - } + private static class TelDestination { + private final World dim; + private final double x; + private final double y; + private final double z; - private static class TelDestination - { - private final World dim; - private final double x; - private final double y; - private final double z; + TelDestination(final World dimension, final AxisAlignedBB srcBox, final double x, final double y, + final double z, final int tileX, final int tileY, final int tileZ) { + this.dim = dimension; + this.x = Math.min(srcBox.maxX - 0.5, Math.max(srcBox.minX + 0.5, x + tileX)); + this.y = Math.min(srcBox.maxY - 0.5, Math.max(srcBox.minY + 0.5, y + tileY)); + this.z = Math.min(srcBox.maxZ - 0.5, Math.max(srcBox.minZ + 0.5, z + tileZ)); + } + } - TelDestination( final World dimension, final AxisAlignedBB srcBox, final double x, final double y, final double z, final int tileX, final int tileY, final int tileZ ) - { - this.dim = dimension; - this.x = Math.min( srcBox.maxX - 0.5, Math.max( srcBox.minX + 0.5, x + tileX ) ); - this.y = Math.min( srcBox.maxY - 0.5, Math.max( srcBox.minY + 0.5, y + tileY ) ); - this.z = Math.min( srcBox.maxZ - 0.5, Math.max( srcBox.minZ + 0.5, z + tileZ ) ); - } - } + private static class METeleporter implements ITeleporter { - private static class METeleporter implements ITeleporter - { + private final TelDestination destination; - private final TelDestination destination; + METeleporter(final TelDestination d) { + this.destination = d; + } - METeleporter( final TelDestination d ) - { - this.destination = d; - } - - @Override - public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function repositionEntity) { - Entity newEntity = repositionEntity.apply(false); - newEntity.rotationYaw = yaw; - newEntity.setPositionAndUpdate( this.destination.x, this.destination.y, this.destination.z ); - newEntity.setMotion(0, 0, 0); - return newEntity; - } - } + @Override + public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, + Function repositionEntity) { + Entity newEntity = repositionEntity.apply(false); + newEntity.rotationYaw = yaw; + newEntity.setPositionAndUpdate(this.destination.x, this.destination.y, this.destination.z); + newEntity.setMotion(0, 0, 0); + return newEntity; + } + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/math/InterpHelper.java b/src/main/java/appeng/thirdparty/codechicken/lib/math/InterpHelper.java index 2f6a72c93..c7d4de369 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/math/InterpHelper.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/math/InterpHelper.java @@ -18,112 +18,101 @@ package appeng.thirdparty.codechicken.lib.math; - /** * @author covers1624 */ -public class InterpHelper -{ +public class InterpHelper { - private float[][] posCache = new float[4][2]; - private float[] valCache = new float[4]; + private float[][] posCache = new float[4][2]; + private float[] valCache = new float[4]; - private float x0; - private float x1; - private float y0; - private float y1; + private float x0; + private float x1; + private float y0; + private float y1; - private float rX; - private float rY; + private float rX; + private float rY; - private int p00; - private int p10; - private int p11; - private int p01; + private int p00; + private int p10; + private int p11; + private int p01; - /** - * Resets the interp helper with the given quad. Does not care what order the vertices are in. - */ - public void reset( float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3 ) - { + /** + * Resets the interp helper with the given quad. Does not care what order the + * vertices are in. + */ + public void reset(float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) { - float[] vec0 = this.posCache[0]; - float[] vec1 = this.posCache[1]; - float[] vec2 = this.posCache[2]; - float[] vec3 = this.posCache[3]; + float[] vec0 = this.posCache[0]; + float[] vec1 = this.posCache[1]; + float[] vec2 = this.posCache[2]; + float[] vec3 = this.posCache[3]; - vec0[0] = dx0; - vec1[0] = dx1; - vec2[0] = dx2; - vec3[0] = dx3; + vec0[0] = dx0; + vec1[0] = dx1; + vec2[0] = dx2; + vec3[0] = dx3; - vec0[1] = dy0; - vec1[1] = dy1; - vec2[1] = dy2; - vec3[1] = dy3; - } + vec0[1] = dy0; + vec1[1] = dy1; + vec2[1] = dy2; + vec3[1] = dy3; + } - /** - * Call when you are ready to use the InterpHelper. - */ - public void setup() - { - this.p00 = 0;// Bottom Left is always first. - this.x0 = this.posCache[this.p00][0]; - this.y0 = this.posCache[this.p00][1]; - for( int i = 1; i < 4; i++ ) - { - float x = this.posCache[i][0]; - float y = this.posCache[i][1]; - if( this.y0 == y ) - { - this.p10 = i;// Bottom right. - this.x1 = x; - } - else if( this.x0 == x ) - { - this.p01 = i;// Top left. - this.y1 = y; - } - else - { - // Top right. - this.p11 = i; - } - } - } + /** + * Call when you are ready to use the InterpHelper. + */ + public void setup() { + this.p00 = 0;// Bottom Left is always first. + this.x0 = this.posCache[this.p00][0]; + this.y0 = this.posCache[this.p00][1]; + for (int i = 1; i < 4; i++) { + float x = this.posCache[i][0]; + float y = this.posCache[i][1]; + if (this.y0 == y) { + this.p10 = i;// Bottom right. + this.x1 = x; + } else if (this.x0 == x) { + this.p01 = i;// Top left. + this.y1 = y; + } else { + // Top right. + this.p11 = i; + } + } + } - /** - * Computes the coefficients for the interpolation. - * - * @param x X interp location. - * @param y Y interp location. - */ - public void locate( float x, float y ) - { - this.rX = ( x - this.x0 ) / ( this.x1 - this.x0 ); - this.rY = ( y - this.y0 ) / ( this.y1 - this.y0 ); - } + /** + * Computes the coefficients for the interpolation. + * + * @param x X interp location. + * @param y Y interp location. + */ + public void locate(float x, float y) { + this.rX = (x - this.x0) / (this.x1 - this.x0); + this.rY = (y - this.y0) / (this.y1 - this.y0); + } - /** - * Interpolates using the already computed coefficients. - * - * @param q0 Value at dx0 dy0 - * @param q1 Value at dx1 dy1 - * @param q2 Value at dx2 dy2 - * @param q3 Value at dx3 dy3 - * - * @return The result. - */ - public float interpolate( float q0, float q1, float q2, float q3 ) - { - this.valCache[0] = q0; - this.valCache[1] = q1; - this.valCache[2] = q2; - this.valCache[3] = q3; - float f0 = ( this.valCache[this.p00] * ( 1 - this.rX ) ) + ( this.valCache[this.p10] * this.rX ); - float f1 = ( this.valCache[this.p01] * ( 1 - this.rX ) ) + ( this.valCache[this.p11] * this.rX ); + /** + * Interpolates using the already computed coefficients. + * + * @param q0 Value at dx0 dy0 + * @param q1 Value at dx1 dy1 + * @param q2 Value at dx2 dy2 + * @param q3 Value at dx3 dy3 + * + * @return The result. + */ + public float interpolate(float q0, float q1, float q2, float q3) { + this.valCache[0] = q0; + this.valCache[1] = q1; + this.valCache[2] = q2; + this.valCache[3] = q3; + float f0 = (this.valCache[this.p00] * (1 - this.rX)) + (this.valCache[this.p10] * this.rX); + float f1 = (this.valCache[this.p01] * (1 - this.rX)) + (this.valCache[this.p11] * this.rX); - return ( f0 * ( 1 - this.rY ) ) + ( f1 * this.rY ); - } + return (f0 * (1 - this.rY)) + (f1 * this.rY); + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/CachedFormat.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/CachedFormat.java index d59d52690..2637e0fdd 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/CachedFormat.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/CachedFormat.java @@ -18,156 +18,138 @@ package appeng.thirdparty.codechicken.lib.model; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormatElement; - /** - * A simple VertexFormat cache. - * This caches the existence of attributes and their indexes. + * A simple VertexFormat cache. This caches the existence of attributes and + * their indexes. * * @author covers1624 */ -public class CachedFormat -{ +public class CachedFormat { - public static final Map formatCache = new ConcurrentHashMap<>(); + public static final Map formatCache = new ConcurrentHashMap<>(); - /** - * Lookup or create the CachedFormat for a given VertexFormat. - * - * @param format The format to lookup. - * - * @return The CachedFormat. - */ - public static CachedFormat lookup( VertexFormat format ) - { - return formatCache.computeIfAbsent( format, CachedFormat::new ); - } + /** + * Lookup or create the CachedFormat for a given VertexFormat. + * + * @param format The format to lookup. + * + * @return The CachedFormat. + */ + public static CachedFormat lookup(VertexFormat format) { + return formatCache.computeIfAbsent(format, CachedFormat::new); + } - public VertexFormat format; + public VertexFormat format; - public boolean hasPosition; - public boolean hasNormal; - public boolean hasColor; - public boolean hasUV; - public boolean hasOverlay; - public boolean hasLightMap; + public boolean hasPosition; + public boolean hasNormal; + public boolean hasColor; + public boolean hasUV; + public boolean hasOverlay; + public boolean hasLightMap; - public int positionIndex = -1; - public int normalIndex = -1; - public int colorIndex = -1; - public int uvIndex = -1; - public int overlayIndex = -1; - public int lightMapIndex = -1; + public int positionIndex = -1; + public int normalIndex = -1; + public int colorIndex = -1; + public int uvIndex = -1; + public int overlayIndex = -1; + public int lightMapIndex = -1; - public int elementCount; + public int elementCount; - /** - * Caches the vertex format element indexes for efficiency. - * - * @param format The format. - */ - public CachedFormat( VertexFormat format ) - { - this.format = format; - this.elementCount = format.getElements().size(); - for( int i = 0; i < this.elementCount; i++ ) - { - VertexFormatElement element = format.getElements().get( i ); - switch( element.getUsage() ) - { - case POSITION: - if( this.hasPosition ) - { - throw new IllegalStateException( "Found 2 position elements.." ); - } - this.hasPosition = true; - this.positionIndex = i; - break; - case NORMAL: - if( this.hasNormal ) - { - throw new IllegalStateException( "Found 2 normal elements.." ); - } - this.hasNormal = true; - this.normalIndex = i; - break; - case COLOR: - if( this.hasColor ) - { - throw new IllegalStateException( "Found 2 color elements.." ); - } - this.hasColor = true; - this.colorIndex = i; - break; - case UV: - switch( element.getIndex() ) - { - case 0: - if( hasUV ) - { - throw new IllegalStateException( "Found 2 UV elements.." ); - } - hasUV = true; - uvIndex = i; - break; - case 1: - if( hasOverlay ) - { - throw new IllegalStateException( "Found 2 Overlay elements.." ); - } - hasOverlay = true; - overlayIndex = i; - break; - case 2: - if( hasLightMap ) - { - throw new IllegalStateException( "Found 2 LightMap elements.." ); - } - hasLightMap = true; - lightMapIndex = i; - break; - } - break; - } - } - } + /** + * Caches the vertex format element indexes for efficiency. + * + * @param format The format. + */ + public CachedFormat(VertexFormat format) { + this.format = format; + this.elementCount = format.getElements().size(); + for (int i = 0; i < this.elementCount; i++) { + VertexFormatElement element = format.getElements().get(i); + switch (element.getUsage()) { + case POSITION: + if (this.hasPosition) { + throw new IllegalStateException("Found 2 position elements.."); + } + this.hasPosition = true; + this.positionIndex = i; + break; + case NORMAL: + if (this.hasNormal) { + throw new IllegalStateException("Found 2 normal elements.."); + } + this.hasNormal = true; + this.normalIndex = i; + break; + case COLOR: + if (this.hasColor) { + throw new IllegalStateException("Found 2 color elements.."); + } + this.hasColor = true; + this.colorIndex = i; + break; + case UV: + switch (element.getIndex()) { + case 0: + if (hasUV) { + throw new IllegalStateException("Found 2 UV elements.."); + } + hasUV = true; + uvIndex = i; + break; + case 1: + if (hasOverlay) { + throw new IllegalStateException("Found 2 Overlay elements.."); + } + hasOverlay = true; + overlayIndex = i; + break; + case 2: + if (hasLightMap) { + throw new IllegalStateException("Found 2 LightMap elements.."); + } + hasLightMap = true; + lightMapIndex = i; + break; + } + break; + } + } + } - @Override - public boolean equals( Object obj ) - { - if( this == obj ) - { - return true; - } - if( !( obj instanceof CachedFormat ) ) - { - return false; - } - CachedFormat other = (CachedFormat) obj; - return other.elementCount == this.elementCount && // - other.positionIndex == this.positionIndex && // - other.normalIndex == this.normalIndex && // - other.colorIndex == this.colorIndex && // - other.uvIndex == this.uvIndex && // - other.lightMapIndex == this.lightMapIndex; - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CachedFormat)) { + return false; + } + CachedFormat other = (CachedFormat) obj; + return other.elementCount == this.elementCount && // + other.positionIndex == this.positionIndex && // + other.normalIndex == this.normalIndex && // + other.colorIndex == this.colorIndex && // + other.uvIndex == this.uvIndex && // + other.lightMapIndex == this.lightMapIndex; + } - @Override - public int hashCode() - { - int result = 1; - result = 31 * result + this.elementCount; - result = 31 * result + this.positionIndex; - result = 31 * result + this.normalIndex; - result = 31 * result + this.colorIndex; - result = 31 * result + this.uvIndex; - result = 31 * result + this.lightMapIndex; - return result; - } + @Override + public int hashCode() { + int result = 1; + result = 31 * result + this.elementCount; + result = 31 * result + this.positionIndex; + result = 31 * result + this.normalIndex; + result = 31 * result + this.colorIndex; + result = 31 * result + this.uvIndex; + result = 31 * result + this.lightMapIndex; + return result; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/ISmartVertexConsumer.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/ISmartVertexConsumer.java index b09676f09..600e1c78c 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/ISmartVertexConsumer.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/ISmartVertexConsumer.java @@ -18,25 +18,21 @@ package appeng.thirdparty.codechicken.lib.model; - import net.minecraftforge.client.model.pipeline.IVertexConsumer; - /** * Marks a standard IVertexConsumer as compatible with {@link Quad}. * * @author covers1624 */ -public interface ISmartVertexConsumer extends IVertexConsumer -{ +public interface ISmartVertexConsumer extends IVertexConsumer { - /** - * Assumes the data is already completely unpacked. - * You must always copy the data from the quad provided to an internal cache. - * basically: - * this.quad.put(quad); - * - * @param quad The quad to copy data from. - */ - void put( Quad quad ); + /** + * Assumes the data is already completely unpacked. You must always copy the + * data from the quad provided to an internal cache. basically: + * this.quad.put(quad); + * + * @param quad The quad to copy data from. + */ + void put(Quad quad); } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/Quad.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/Quad.java index 5d25c2a12..9c002376d 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/Quad.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/Quad.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model; - import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -33,529 +32,460 @@ import net.minecraftforge.client.model.pipeline.LightUtil; import appeng.thirdparty.codechicken.lib.math.InterpHelper; - /** - * A simple easy to manipulate quad format. Can be reset and then used on a different format. + * A simple easy to manipulate quad format. Can be reset and then used on a + * different format. * * @author covers1624 */ -public class Quad implements IVertexProducer, ISmartVertexConsumer -{ +public class Quad implements IVertexProducer, ISmartVertexConsumer { - public CachedFormat format; + public CachedFormat format; - public int tintIndex = -1; - public Direction orientation; - public boolean diffuseLighting = true; - public TextureAtlasSprite sprite; + public int tintIndex = -1; + public Direction orientation; + public boolean diffuseLighting = true; + public TextureAtlasSprite sprite; - public Vertex[] vertices = new Vertex[4]; - public boolean full; + public Vertex[] vertices = new Vertex[4]; + public boolean full; - // Not copied. - private int vertexIndex = 0; - // Cache for normal computation. - private Vector3f v1 = new Vector3f(); - private Vector3f v2 = new Vector3f(); - private Vector3f t = new Vector3f(); - private Vector3f normal = new Vector3f(); + // Not copied. + private int vertexIndex = 0; + // Cache for normal computation. + private Vector3f v1 = new Vector3f(); + private Vector3f v2 = new Vector3f(); + private Vector3f t = new Vector3f(); + private Vector3f normal = new Vector3f(); - /** - * Use this if you reset the quad each time you use it. - */ - public Quad() - { - } + /** + * Use this if you reset the quad each time you use it. + */ + public Quad() { + } - /** - * use this if you want to initialize the quad with a format. - * - * @param format The format. - */ - public Quad( CachedFormat format ) - { - this.format = format; - } + /** + * use this if you want to initialize the quad with a format. + * + * @param format The format. + */ + public Quad(CachedFormat format) { + this.format = format; + } - @Override - public VertexFormat getVertexFormat() - { - return this.format.format; - } + @Override + public VertexFormat getVertexFormat() { + return this.format.format; + } - @Override - public void setQuadTint( int tint ) - { - this.tintIndex = tint; - } + @Override + public void setQuadTint(int tint) { + this.tintIndex = tint; + } - @Override - public void setQuadOrientation( Direction orientation ) - { - this.orientation = orientation; - } + @Override + public void setQuadOrientation(Direction orientation) { + this.orientation = orientation; + } - @Override - public void setApplyDiffuseLighting( boolean diffuse ) - { - this.diffuseLighting = diffuse; - } + @Override + public void setApplyDiffuseLighting(boolean diffuse) { + this.diffuseLighting = diffuse; + } - @Override - public void setTexture( TextureAtlasSprite texture ) - { - this.sprite = texture; - } + @Override + public void setTexture(TextureAtlasSprite texture) { + this.sprite = texture; + } - @Override - public void put( int element, float... data ) - { - if( this.full ) - { - throw new RuntimeException( "Unable to add data when full." ); - } - Vertex v = this.vertices[this.vertexIndex]; - if( v == null ) - { - v = new Vertex( this.format ); - this.vertices[this.vertexIndex] = v; - } - System.arraycopy( data, 0, v.raw[element], 0, data.length ); - if( element == ( this.format.elementCount - 1 ) ) - { - this.vertexIndex++; - if( this.vertexIndex == 4 ) - { - this.vertexIndex = 0; - this.full = true; - if( this.orientation == null ) - { - this.calculateOrientation( false ); - } - } - } - } + @Override + public void put(int element, float... data) { + if (this.full) { + throw new RuntimeException("Unable to add data when full."); + } + Vertex v = this.vertices[this.vertexIndex]; + if (v == null) { + v = new Vertex(this.format); + this.vertices[this.vertexIndex] = v; + } + System.arraycopy(data, 0, v.raw[element], 0, data.length); + if (element == (this.format.elementCount - 1)) { + this.vertexIndex++; + if (this.vertexIndex == 4) { + this.vertexIndex = 0; + this.full = true; + if (this.orientation == null) { + this.calculateOrientation(false); + } + } + } + } - @Override - public void put( Quad quad ) - { - this.copyFrom( quad ); - } + @Override + public void put(Quad quad) { + this.copyFrom(quad); + } - @Override - public void pipe( IVertexConsumer consumer ) - { - if( consumer instanceof ISmartVertexConsumer ) - { - ( (ISmartVertexConsumer) consumer ).put( this ); - } - else - { - consumer.setQuadTint( this.tintIndex ); - consumer.setQuadOrientation( this.orientation ); - consumer.setApplyDiffuseLighting( this.diffuseLighting ); - consumer.setTexture( this.sprite ); - for( Vertex v : this.vertices ) - { - for( int e = 0; e < this.format.elementCount; e++ ) - { - consumer.put( e, v.raw[e] ); - } - } - } - } + @Override + public void pipe(IVertexConsumer consumer) { + if (consumer instanceof ISmartVertexConsumer) { + ((ISmartVertexConsumer) consumer).put(this); + } else { + consumer.setQuadTint(this.tintIndex); + consumer.setQuadOrientation(this.orientation); + consumer.setApplyDiffuseLighting(this.diffuseLighting); + consumer.setTexture(this.sprite); + for (Vertex v : this.vertices) { + for (int e = 0; e < this.format.elementCount; e++) { + consumer.put(e, v.raw[e]); + } + } + } + } - /** - * Used to reset the interpolation values inside the provided helper. - * - * @param helper The helper. - * @param s The axis. side >> 1; - * - * @return The same helper. - */ - public InterpHelper resetInterp( InterpHelper helper, int s ) - { - helper.reset( // - this.vertices[0].dx( s ), this.vertices[0].dy( s ), // - this.vertices[1].dx( s ), this.vertices[1].dy( s ), // - this.vertices[2].dx( s ), this.vertices[2].dy( s ), // - this.vertices[3].dx( s ), this.vertices[3].dy( s ) ); - return helper; - } + /** + * Used to reset the interpolation values inside the provided helper. + * + * @param helper The helper. + * @param s The axis. side >> 1; + * + * @return The same helper. + */ + public InterpHelper resetInterp(InterpHelper helper, int s) { + helper.reset( // + this.vertices[0].dx(s), this.vertices[0].dy(s), // + this.vertices[1].dx(s), this.vertices[1].dy(s), // + this.vertices[2].dx(s), this.vertices[2].dy(s), // + this.vertices[3].dx(s), this.vertices[3].dy(s)); + return helper; + } - /** - * Clamps the Quad inside the box. - * - * @param bb The box. - */ - public void clamp( AxisAlignedBB bb ) - { - for( Vertex vertex : this.vertices ) - { - float[] vec = vertex.vec; - vec[0] = (float) MathHelper.clamp( vec[0], bb.minX, bb.maxX ); - vec[1] = (float) MathHelper.clamp( vec[1], bb.minY, bb.maxY ); - vec[2] = (float) MathHelper.clamp( vec[2], bb.minZ, bb.maxZ ); - } - this.calculateOrientation( true ); - } + /** + * Clamps the Quad inside the box. + * + * @param bb The box. + */ + public void clamp(AxisAlignedBB bb) { + for (Vertex vertex : this.vertices) { + float[] vec = vertex.vec; + vec[0] = (float) MathHelper.clamp(vec[0], bb.minX, bb.maxX); + vec[1] = (float) MathHelper.clamp(vec[1], bb.minY, bb.maxY); + vec[2] = (float) MathHelper.clamp(vec[2], bb.minZ, bb.maxZ); + } + this.calculateOrientation(true); + } - /** - * Re-calculates the Orientation of this quad, - * optionally the normal vector. - * - * @param setNormal If the normal vector should be updated. - */ - public void calculateOrientation( boolean setNormal ) - { - this.v1.set( this.vertices[3].vec ); - this.t.set( this.vertices[1].vec ); - this.v1.sub( this.t ); + /** + * Re-calculates the Orientation of this quad, optionally the normal vector. + * + * @param setNormal If the normal vector should be updated. + */ + public void calculateOrientation(boolean setNormal) { + this.v1.set(this.vertices[3].vec); + this.t.set(this.vertices[1].vec); + this.v1.sub(this.t); - this.v2.set( this.vertices[2].vec ); - this.t.set( this.vertices[0].vec ); - this.v2.sub( this.t ); + this.v2.set(this.vertices[2].vec); + this.t.set(this.vertices[0].vec); + this.v2.sub(this.t); - this.normal.set( this.v2.getX(), this.v2.getY(), this.v2.getZ() ); - this.normal.cross( this.v1 ); - this.normal.normalize(); + this.normal.set(this.v2.getX(), this.v2.getY(), this.v2.getZ()); + this.normal.cross(this.v1); + this.normal.normalize(); - if( this.format.hasNormal && setNormal ) - { - for( Vertex vertex : this.vertices ) - { - vertex.normal[0] = this.normal.getX(); - vertex.normal[1] = this.normal.getY(); - vertex.normal[2] = this.normal.getZ(); - vertex.normal[3] = 0; - } - } - this.orientation = Direction.getFacingFromVector( this.normal.getX(), this.normal.getY(), this.normal.getZ() ); - } + if (this.format.hasNormal && setNormal) { + for (Vertex vertex : this.vertices) { + vertex.normal[0] = this.normal.getX(); + vertex.normal[1] = this.normal.getY(); + vertex.normal[2] = this.normal.getZ(); + vertex.normal[3] = 0; + } + } + this.orientation = Direction.getFacingFromVector(this.normal.getX(), this.normal.getY(), this.normal.getZ()); + } - /** - * Used to create a new quad complete copy of this one. - * - * @return The new quad. - */ - public Quad copy() - { - if( !this.full ) - { - throw new RuntimeException( "Only copying full quads is supported." ); - } - Quad quad = new Quad( this.format ); - quad.tintIndex = this.tintIndex; - quad.orientation = this.orientation; - quad.diffuseLighting = this.diffuseLighting; - quad.sprite = this.sprite; - quad.full = true; - for( int i = 0; i < 4; i++ ) - { - quad.vertices[i] = this.vertices[i].copy(); - } - return quad; - } + /** + * Used to create a new quad complete copy of this one. + * + * @return The new quad. + */ + public Quad copy() { + if (!this.full) { + throw new RuntimeException("Only copying full quads is supported."); + } + Quad quad = new Quad(this.format); + quad.tintIndex = this.tintIndex; + quad.orientation = this.orientation; + quad.diffuseLighting = this.diffuseLighting; + quad.sprite = this.sprite; + quad.full = true; + for (int i = 0; i < 4; i++) { + quad.vertices[i] = this.vertices[i].copy(); + } + return quad; + } - /** - * Copies the data inside the given quad to this one. This ignores VertexFormat, please make sure your quads are in - * the same format. - * - * @param quad The Quad to copy from. - * - * @return This quad. - */ - public Quad copyFrom( Quad quad ) - { - this.tintIndex = quad.tintIndex; - this.orientation = quad.orientation; - this.diffuseLighting = quad.diffuseLighting; - this.sprite = quad.sprite; - this.full = quad.full; - for( int v = 0; v < 4; v++ ) - { - for( int e = 0; e < this.format.elementCount; e++ ) - { - System.arraycopy( quad.vertices[v].raw[e], 0, this.vertices[v].raw[e], 0, 4 ); - } - } - return this; - } + /** + * Copies the data inside the given quad to this one. This ignores VertexFormat, + * please make sure your quads are in the same format. + * + * @param quad The Quad to copy from. + * + * @return This quad. + */ + public Quad copyFrom(Quad quad) { + this.tintIndex = quad.tintIndex; + this.orientation = quad.orientation; + this.diffuseLighting = quad.diffuseLighting; + this.sprite = quad.sprite; + this.full = quad.full; + for (int v = 0; v < 4; v++) { + for (int e = 0; e < this.format.elementCount; e++) { + System.arraycopy(quad.vertices[v].raw[e], 0, this.vertices[v].raw[e], 0, 4); + } + } + return this; + } - /** - * Reset the quad to the new format. - * - * @param format The new format. - */ - public void reset( CachedFormat format ) - { - this.format = format; - this.tintIndex = -1; - this.orientation = null; - this.diffuseLighting = true; - this.sprite = null; - for( int i = 0; i < this.vertices.length; i++ ) - { - Vertex v = this.vertices[i]; - if( v == null ) - { - this.vertices[i] = v = new Vertex( format ); - } - v.reset( format ); - } - this.vertexIndex = 0; - this.full = false; - } + /** + * Reset the quad to the new format. + * + * @param format The new format. + */ + public void reset(CachedFormat format) { + this.format = format; + this.tintIndex = -1; + this.orientation = null; + this.diffuseLighting = true; + this.sprite = null; + for (int i = 0; i < this.vertices.length; i++) { + Vertex v = this.vertices[i]; + if (v == null) { + this.vertices[i] = v = new Vertex(format); + } + v.reset(format); + } + this.vertexIndex = 0; + this.full = false; + } - /** - * Bakes this Quad to a BakedQuad. - * - * @return The BakedQuad. - */ - public BakedQuad bake() - { - if( format.format != DefaultVertexFormats.BLOCK ) - { - throw new IllegalStateException( "Unable to bake this quad to the specified format. " + format.format ); - } - int[] packedData = new int[this.format.format.getSize()]; - for( int v = 0; v < 4; v++ ) - { - for( int e = 0; e < this.format.elementCount; e++ ) - { - LightUtil.pack( this.vertices[v].raw[e], packedData, this.format.format, v, e ); - } - } - return new BakedQuad( packedData, this.tintIndex, this.orientation, this.sprite, this.diffuseLighting ); - } + /** + * Bakes this Quad to a BakedQuad. + * + * @return The BakedQuad. + */ + public BakedQuad bake() { + if (format.format != DefaultVertexFormats.BLOCK) { + throw new IllegalStateException("Unable to bake this quad to the specified format. " + format.format); + } + int[] packedData = new int[this.format.format.getSize()]; + for (int v = 0; v < 4; v++) { + for (int e = 0; e < this.format.elementCount; e++) { + LightUtil.pack(this.vertices[v].raw[e], packedData, this.format.format, v, e); + } + } + return new BakedQuad(packedData, this.tintIndex, this.orientation, this.sprite, this.diffuseLighting); + } - /** - * A simple vertex format. - */ - public static class Vertex - { + /** + * A simple vertex format. + */ + public static class Vertex { - public CachedFormat format; + public CachedFormat format; - /** - * The raw data. - */ - public float[][] raw; + /** + * The raw data. + */ + public float[][] raw; - // References to the arrays inside raw. - public float[] vec; - public float[] normal; - public float[] color; - public float[] uv; - public float[] overlay; - public float[] lightmap; + // References to the arrays inside raw. + public float[] vec; + public float[] normal; + public float[] color; + public float[] uv; + public float[] overlay; + public float[] lightmap; - /** - * Create a new Vertex. - * - * @param format The format for the vertex. - */ - public Vertex( CachedFormat format ) - { - this.format = format; - this.raw = new float[format.elementCount][4]; - this.preProcess(); - } + /** + * Create a new Vertex. + * + * @param format The format for the vertex. + */ + public Vertex(CachedFormat format) { + this.format = format; + this.raw = new float[format.elementCount][4]; + this.preProcess(); + } - /** - * Creates a new Vertex using the data inside the other. A copy! - * - * @param other The other. - */ - public Vertex( Vertex other ) - { - this.format = other.format; - this.raw = other.raw.clone(); - for( int v = 0; v < this.format.elementCount; v++ ) - { - this.raw[v] = other.raw[v].clone(); - } - this.preProcess(); - } + /** + * Creates a new Vertex using the data inside the other. A copy! + * + * @param other The other. + */ + public Vertex(Vertex other) { + this.format = other.format; + this.raw = other.raw.clone(); + for (int v = 0; v < this.format.elementCount; v++) { + this.raw[v] = other.raw[v].clone(); + } + this.preProcess(); + } - /** - * Pulls references to the individual element's arrays inside raw. Modifying the individual element arrays will - * update raw. - */ - public void preProcess() - { - if( this.format.hasPosition ) - { - this.vec = this.raw[this.format.positionIndex]; - } - if( this.format.hasNormal ) - { - this.normal = this.raw[this.format.normalIndex]; - } - if( this.format.hasColor ) - { - this.color = this.raw[this.format.colorIndex]; - } - if( this.format.hasUV ) - { - this.uv = this.raw[this.format.uvIndex]; - } - if( format.hasOverlay ) - { - overlay = raw[format.overlayIndex]; - } - if( this.format.hasLightMap ) - { - this.lightmap = this.raw[this.format.lightMapIndex]; - } - } + /** + * Pulls references to the individual element's arrays inside raw. Modifying the + * individual element arrays will update raw. + */ + public void preProcess() { + if (this.format.hasPosition) { + this.vec = this.raw[this.format.positionIndex]; + } + if (this.format.hasNormal) { + this.normal = this.raw[this.format.normalIndex]; + } + if (this.format.hasColor) { + this.color = this.raw[this.format.colorIndex]; + } + if (this.format.hasUV) { + this.uv = this.raw[this.format.uvIndex]; + } + if (format.hasOverlay) { + overlay = raw[format.overlayIndex]; + } + if (this.format.hasLightMap) { + this.lightmap = this.raw[this.format.lightMapIndex]; + } + } - /** - * Gets the 2d X coord for the given axis. - * - * @param s The axis. side >> 1 - * - * @return The x coord. - */ - public float dx( int s ) - { - if( s <= 1 ) - { - return this.vec[0]; - } - else - { - return this.vec[2]; - } - } + /** + * Gets the 2d X coord for the given axis. + * + * @param s The axis. side >> 1 + * + * @return The x coord. + */ + public float dx(int s) { + if (s <= 1) { + return this.vec[0]; + } else { + return this.vec[2]; + } + } - /** - * Gets the 2d Y coord for the given axis. - * - * @param s The axis. side >> 1 - * - * @return The y coord. - */ - public float dy( int s ) - { - if( s > 0 ) - { - return this.vec[1]; - } - else - { - return this.vec[2]; - } - } + /** + * Gets the 2d Y coord for the given axis. + * + * @param s The axis. side >> 1 + * + * @return The y coord. + */ + public float dy(int s) { + if (s > 0) { + return this.vec[1]; + } else { + return this.vec[2]; + } + } - /** - * Interpolates the new color values for this Vertex using the others as a reference. - * - * @param interpHelper The InterpHelper to use. - * @param others The other Vertices to use as a template. - * - * @return The same Vertex. - */ - public Vertex interpColorFrom( InterpHelper interpHelper, Vertex[] others ) - { - for( int e = 0; e < 4; e++ ) - { - float p1 = others[0].color[e]; - float p2 = others[1].color[e]; - float p3 = others[2].color[e]; - float p4 = others[3].color[e]; - // Only interpolate if colors are different. - if( p1 != p2 || p2 != p3 || p3 != p4 ) - { - this.color[e] = interpHelper.interpolate( p1, p2, p3, p4 ); - } - } - return this; - } + /** + * Interpolates the new color values for this Vertex using the others as a + * reference. + * + * @param interpHelper The InterpHelper to use. + * @param others The other Vertices to use as a template. + * + * @return The same Vertex. + */ + public Vertex interpColorFrom(InterpHelper interpHelper, Vertex[] others) { + for (int e = 0; e < 4; e++) { + float p1 = others[0].color[e]; + float p2 = others[1].color[e]; + float p3 = others[2].color[e]; + float p4 = others[3].color[e]; + // Only interpolate if colors are different. + if (p1 != p2 || p2 != p3 || p3 != p4) { + this.color[e] = interpHelper.interpolate(p1, p2, p3, p4); + } + } + return this; + } - /** - * Interpolates the new UV values for this Vertex using the others as a reference. - * - * @param interpHelper The InterpHelper to use. - * @param others The other Vertices to use as a template. - * - * @return The same Vertex. - */ - public Vertex interpUVFrom( InterpHelper interpHelper, Vertex[] others ) - { - for( int e = 0; e < 2; e++ ) - { - float p1 = others[0].uv[e]; - float p2 = others[1].uv[e]; - float p3 = others[2].uv[e]; - float p4 = others[3].uv[e]; - if( p1 != p2 || p2 != p3 || p3 != p4 ) - { - this.uv[e] = interpHelper.interpolate( p1, p2, p3, p4 ); - } - } - return this; - } + /** + * Interpolates the new UV values for this Vertex using the others as a + * reference. + * + * @param interpHelper The InterpHelper to use. + * @param others The other Vertices to use as a template. + * + * @return The same Vertex. + */ + public Vertex interpUVFrom(InterpHelper interpHelper, Vertex[] others) { + for (int e = 0; e < 2; e++) { + float p1 = others[0].uv[e]; + float p2 = others[1].uv[e]; + float p3 = others[2].uv[e]; + float p4 = others[3].uv[e]; + if (p1 != p2 || p2 != p3 || p3 != p4) { + this.uv[e] = interpHelper.interpolate(p1, p2, p3, p4); + } + } + return this; + } - /** - * Interpolates the new LightMap values for this Vertex using the others as a reference. - * - * @param interpHelper The InterpHelper to use. - * @param others The other Vertices to use as a template. - * - * @return The same Vertex. - */ - public Vertex interpLightMapFrom( InterpHelper interpHelper, Vertex[] others ) - { - for( int e = 0; e < 2; e++ ) - { - float p1 = others[0].lightmap[e]; - float p2 = others[1].lightmap[e]; - float p3 = others[2].lightmap[e]; - float p4 = others[3].lightmap[e]; - if( p1 != p2 || p2 != p3 || p3 != p4 ) - { - this.lightmap[e] = interpHelper.interpolate( p1, p2, p3, p4 ); - } - } - return this; - } + /** + * Interpolates the new LightMap values for this Vertex using the others as a + * reference. + * + * @param interpHelper The InterpHelper to use. + * @param others The other Vertices to use as a template. + * + * @return The same Vertex. + */ + public Vertex interpLightMapFrom(InterpHelper interpHelper, Vertex[] others) { + for (int e = 0; e < 2; e++) { + float p1 = others[0].lightmap[e]; + float p2 = others[1].lightmap[e]; + float p3 = others[2].lightmap[e]; + float p4 = others[3].lightmap[e]; + if (p1 != p2 || p2 != p3 || p3 != p4) { + this.lightmap[e] = interpHelper.interpolate(p1, p2, p3, p4); + } + } + return this; + } - /** - * Copies this Vertex to a new one. - * - * @return The new Vertex. - */ - public Vertex copy() - { - return new Vertex( this ); - } + /** + * Copies this Vertex to a new one. + * + * @return The new Vertex. + */ + public Vertex copy() { + return new Vertex(this); + } - /** - * Resets the Vertex to a new format. Expands the raw array if needed. - * - * @param format The format to reset to. - */ - public void reset( CachedFormat format ) - { - // If the format is different and our raw array is smaller, then expand it. - if( !this.format.equals( format ) && format.elementCount > this.raw.length ) - { - this.raw = new float[format.elementCount][4]; - } - this.format = format; + /** + * Resets the Vertex to a new format. Expands the raw array if needed. + * + * @param format The format to reset to. + */ + public void reset(CachedFormat format) { + // If the format is different and our raw array is smaller, then expand it. + if (!this.format.equals(format) && format.elementCount > this.raw.length) { + this.raw = new float[format.elementCount][4]; + } + this.format = format; - this.vec = null; - this.normal = null; - this.color = null; - this.uv = null; - this.lightmap = null; + this.vec = null; + this.normal = null; + this.color = null; + this.uv = null; + this.lightmap = null; - // for (float[] f : raw) { - // Arrays.fill(f, 0F); - // } + // for (float[] f : raw) { + // Arrays.fill(f, 0F); + // } - this.preProcess(); - } - } + this.preProcess(); + } + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/BakedPipeline.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/BakedPipeline.java index a8920e286..8318e439a 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/BakedPipeline.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/BakedPipeline.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline; - import java.util.Arrays; import java.util.LinkedList; import java.util.Map; @@ -34,402 +33,369 @@ import appeng.thirdparty.codechicken.lib.model.CachedFormat; import appeng.thirdparty.codechicken.lib.model.ISmartVertexConsumer; import appeng.thirdparty.codechicken.lib.model.Quad; - /** - * The BakedPipeline! - * Basically this allows us to efficiently transform a BakedQuad, - * the Pipeline has Elements, each element has a name, state and a transformer, - * you can enable and disable elements easily, you can also grab the underlying - * transformer for the element if you need to set its state before rendering. + * The BakedPipeline! Basically this allows us to efficiently transform a + * BakedQuad, the Pipeline has Elements, each element has a name, state and a + * transformer, you can enable and disable elements easily, you can also grab + * the underlying transformer for the element if you need to set its state + * before rendering. * * The BakedPipeline is final once created, you cannot add or remove elements, * you should not need to add or remove them runtime, enable and disable exist. * - * You must use the Builder class to construct a BakedPipeline, see {@link #builder} + * You must use the Builder class to construct a BakedPipeline, see + * {@link #builder} * - * Transformers run on a mutable state inside each transformer, allowing for easy reuse. - * It is recommended to store your pipeline inside a ThreadLocal because 'minecraft'. + * Transformers run on a mutable state inside each transformer, allowing for + * easy reuse. It is recommended to store your pipeline inside a ThreadLocal + * because 'minecraft'. * - * Each Transformer should be smart enough to expand itself for each newly sized VertexFormat it comes across, - * meaning that the internal states for the transformers can be safely shared across VertexFormats, this reduces - * array creations, and generally makes the system as efficient as it is. + * Each Transformer should be smart enough to expand itself for each newly sized + * VertexFormat it comes across, meaning that the internal states for the + * transformers can be safely shared across VertexFormats, this reduces array + * creations, and generally makes the system as efficient as it is. * - * To use the system: - * Grab any elements you need to set state data on first, using {@link #getElement(String, Class)} - * transformers should NOT clear their state on pipeline Reset's so set any global data on elements now. - * Assuming you are looping over a set of quads to transform, next you need to {@link #reset} the pipeline, - * Now you should disable / enable any optional elements that are needed, NOTE: Element states are reset when resetting - * the pipeline. - * Now you will need to call {@link #prepare(IVertexConsumer)} on the pipeline, here you will pass your collector, - * usually this is some form of (Unpacked)BakedQuadBuilder, See {@link QuadBuilder} for a simple and fast implementation - * for standard BakedQuads, and {@link UnpackedBakedQuad.Builder} for UnpackedBakedQuads. - * Now final step, simply pipe the quad you want to transform INTO the pipeline 'quad.pipe(pipeline)' - * And that's it! hell, Pipe a pipeline into each other for all i care, the system is efficient enough that there - * would be no performance penalty for doing so. + * To use the system: Grab any elements you need to set state data on first, + * using {@link #getElement(String, Class)} transformers should NOT clear their + * state on pipeline Reset's so set any global data on elements now. Assuming + * you are looping over a set of quads to transform, next you need to + * {@link #reset} the pipeline, Now you should disable / enable any optional + * elements that are needed, NOTE: Element states are reset when resetting the + * pipeline. Now you will need to call {@link #prepare(IVertexConsumer)} on the + * pipeline, here you will pass your collector, usually this is some form of + * (Unpacked)BakedQuadBuilder, See {@link QuadBuilder} for a simple and fast + * implementation for standard BakedQuads, and {@link UnpackedBakedQuad.Builder} + * for UnpackedBakedQuads. Now final step, simply pipe the quad you want to + * transform INTO the pipeline 'quad.pipe(pipeline)' And that's it! hell, Pipe a + * pipeline into each other for all i care, the system is efficient enough that + * there would be no performance penalty for doing so. * * @author covers1624 */ -public class BakedPipeline implements ISmartVertexConsumer -{ +public class BakedPipeline implements ISmartVertexConsumer { - private PipelineElement[] elements; - private Map nameLookup; - private IPipelineConsumer first; + private PipelineElement[] elements; + private Map nameLookup; + private IPipelineConsumer first; - private Quad unpacker = new Quad(); + private Quad unpacker = new Quad(); - private BakedPipeline( PipelineElement[] elements ) - { - this.elements = elements; - this.nameLookup = Arrays.stream( elements ).collect( Collectors.toMap( e -> e.name, e -> e ) ); - } + private BakedPipeline(PipelineElement[] elements) { + this.elements = elements; + this.nameLookup = Arrays.stream(elements).collect(Collectors.toMap(e -> e.name, e -> e)); + } - /** - * Used to create a BakedPipeline. - * - * @return The builder. - */ - public static Builder builder() - { - return new Builder(); - } + /** + * Used to create a BakedPipeline. + * + * @return The builder. + */ + public static Builder builder() { + return new Builder(); + } - /** - * Used to reset the pipeline for the next quad. - * MUST be called between quads. - * - * @param format The format. - */ - public void reset( VertexFormat format ) - { - this.reset( CachedFormat.lookup( format ) ); - } + /** + * Used to reset the pipeline for the next quad. MUST be called between quads. + * + * @param format The format. + */ + public void reset(VertexFormat format) { + this.reset(CachedFormat.lookup(format)); + } - /** - * Used to reset the pipeline for the next quad. - * MUST be called between quads. - * - * @param format The format. - */ - public void reset( CachedFormat format ) - { - this.unpacker.reset( format ); - for( PipelineElement element : this.elements ) - { - element.reset( format ); - } - this.first = null; - } + /** + * Used to reset the pipeline for the next quad. MUST be called between quads. + * + * @param format The format. + */ + public void reset(CachedFormat format) { + this.unpacker.reset(format); + for (PipelineElement element : this.elements) { + element.reset(format); + } + this.first = null; + } - /** - * Get an element from the pipeline. - * - * @param name The name of the element. - * @param clazz The Class of the element, used to safe cast. - * - * @return The element. - */ - public T getElement( String name, Class clazz ) - { - PipelineElement element = this.nameLookup.get( name ); - if( element != null ) - { - if( !clazz.isAssignableFrom( element.consumer.getClass() ) ) - { - throw new IllegalArgumentException( "Element with name " + name + " is not assignable from reference class." ); - } - return clazz.cast( element.consumer ); - } - throw new IllegalArgumentException( "Element with name " + name + " does not exist." ); - } + /** + * Get an element from the pipeline. + * + * @param name The name of the element. + * @param clazz The Class of the element, used to safe cast. + * + * @return The element. + */ + public T getElement(String name, Class clazz) { + PipelineElement element = this.nameLookup.get(name); + if (element != null) { + if (!clazz.isAssignableFrom(element.consumer.getClass())) { + throw new IllegalArgumentException( + "Element with name " + name + " is not assignable from reference class."); + } + return clazz.cast(element.consumer); + } + throw new IllegalArgumentException("Element with name " + name + " does not exist."); + } - /** - * Used to enable an element on the pipeline with the specified name. - * - * @param name The elements name. - */ - public void enableElement( String name ) - { - this.setElementState( name, true ); - } + /** + * Used to enable an element on the pipeline with the specified name. + * + * @param name The elements name. + */ + public void enableElement(String name) { + this.setElementState(name, true); + } - /** - * Used to disable an element on the pipeline with the specified name. - * - * @param name The elements name. - */ - public void disableElement( String name ) - { - this.setElementState( name, false ); - } + /** + * Used to disable an element on the pipeline with the specified name. + * + * @param name The elements name. + */ + public void disableElement(String name) { + this.setElementState(name, false); + } - /** - * Used to set the state of an element on the pipeline. - * - * @param name The name of the element. - * @param enabled The state to set it to. - */ - public void setElementState( String name, boolean enabled ) - { - PipelineElement element = this.nameLookup.get( name ); - if( element != null ) - { - element.isEnabled = enabled; - return; - } - throw new IllegalArgumentException( "Element with name " + name + " does not exist." ); - } + /** + * Used to set the state of an element on the pipeline. + * + * @param name The name of the element. + * @param enabled The state to set it to. + */ + public void setElementState(String name, boolean enabled) { + PipelineElement element = this.nameLookup.get(name); + if (element != null) { + element.isEnabled = enabled; + return; + } + throw new IllegalArgumentException("Element with name " + name + " does not exist."); + } - /** - * Call when you are ready to use the pipeline. - * This builds the internal state of the Elements getting things ready to transform. - * - * @param collector The IVertexConsumer that should collect the transformed quad. - */ - public void prepare( IVertexConsumer collector ) - { - IPipelineConsumer next = null; - for( PipelineElement element : this.elements ) - { - if( element.isEnabled ) - { - if( this.first == null ) - { - this.first = element.consumer; - } - else - { - next.setParent( element.consumer ); - } - next = element.consumer; - } - } - next.setParent( collector ); - } + /** + * Call when you are ready to use the pipeline. This builds the internal state + * of the Elements getting things ready to transform. + * + * @param collector The IVertexConsumer that should collect the transformed + * quad. + */ + public void prepare(IVertexConsumer collector) { + IPipelineConsumer next = null; + for (PipelineElement element : this.elements) { + if (element.isEnabled) { + if (this.first == null) { + this.first = element.consumer; + } else { + next.setParent(element.consumer); + } + next = element.consumer; + } + } + next.setParent(collector); + } - @Override - public VertexFormat getVertexFormat() - { - this.check(); - return this.first.getVertexFormat(); - } + @Override + public VertexFormat getVertexFormat() { + this.check(); + return this.first.getVertexFormat(); + } - @Override - public void setQuadTint( int tint ) - { - this.check(); - this.unpacker.setQuadTint( tint ); - } + @Override + public void setQuadTint(int tint) { + this.check(); + this.unpacker.setQuadTint(tint); + } - @Override - public void setQuadOrientation( Direction orientation ) - { - this.check(); - this.unpacker.setQuadOrientation( orientation ); - } + @Override + public void setQuadOrientation(Direction orientation) { + this.check(); + this.unpacker.setQuadOrientation(orientation); + } - @Override - public void setApplyDiffuseLighting( boolean diffuse ) - { - this.check(); - this.unpacker.setApplyDiffuseLighting( diffuse ); - } + @Override + public void setApplyDiffuseLighting(boolean diffuse) { + this.check(); + this.unpacker.setApplyDiffuseLighting(diffuse); + } - @Override - public void setTexture( TextureAtlasSprite texture ) - { - this.check(); - this.unpacker.setTexture( texture ); - } + @Override + public void setTexture(TextureAtlasSprite texture) { + this.check(); + this.unpacker.setTexture(texture); + } - @Override - public void put( int element, float... data ) - { - this.check(); - this.unpacker.put( element, data ); - if( this.unpacker.full ) - { - this.onFull(); - } - } + @Override + public void put(int element, float... data) { + this.check(); + this.unpacker.put(element, data); + if (this.unpacker.full) { + this.onFull(); + } + } - @Override - public void put( Quad quad ) - { - this.check(); - this.unpacker.put( quad ); - } + @Override + public void put(Quad quad) { + this.check(); + this.unpacker.put(quad); + } - private void check() - { - if( this.first == null ) - { - throw new IllegalStateException( "Pipeline used before prepare was called." ); - } - } + private void check() { + if (this.first == null) { + throw new IllegalStateException("Pipeline used before prepare was called."); + } + } - private void onFull() - { - this.first.setInputQuad( this.unpacker ); - this.first.put( this.unpacker ); - } + private void onFull() { + this.first.setInputQuad(this.unpacker); + this.first.put(this.unpacker); + } - /** - * Internal class, used to hold a PipelineElement's state. - */ - public static class PipelineElement - { + /** + * Internal class, used to hold a PipelineElement's state. + */ + public static class PipelineElement { - public String name; - public boolean defaultState; - public T consumer; - public boolean isEnabled; + public String name; + public boolean defaultState; + public T consumer; + public boolean isEnabled; - public void reset( CachedFormat format ) - { - this.isEnabled = this.defaultState; - this.consumer.setParent( null ); - this.consumer.reset( format ); - } - } + public void reset(CachedFormat format) { + this.isEnabled = this.defaultState; + this.consumer.setParent(null); + this.consumer.reset(format); + } + } - /** - * The builder associated with the BakedPipeline. - * You must create a BakedPipeline with this, - * once created a pipeline cannot be modified, - * modifying should not be needed as you can enable - * and disable elements with ease. - */ - public static class Builder - { + /** + * The builder associated with the BakedPipeline. You must create a + * BakedPipeline with this, once created a pipeline cannot be modified, + * modifying should not be needed as you can enable and disable elements with + * ease. + */ + public static class Builder { - private LinkedList elements = new LinkedList<>(); + private LinkedList elements = new LinkedList<>(); - /** - * Inserts an element to the front of the list, Useful if you have a more complex system - * and each system need to be independent from each other, but this element must be first. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * - * @return The same builder. - */ - public Builder addFirst( String name, IPipelineElementFactory factory ) - { - return this.addFirst( name, factory, true ); - } + /** + * Inserts an element to the front of the list, Useful if you have a more + * complex system and each system need to be independent from each other, but + * this element must be first. + * + * @param name The name to identify this element, used as an identifier when + * setting state, and retrieving the element. + * @param factory The factory used to create the Transformer. + * + * @return The same builder. + */ + public Builder addFirst(String name, IPipelineElementFactory factory) { + return this.addFirst(name, factory, true); + } - /** - * Inserts an element to the front of the list, Useful if you have a more complex system - * and each system need to be independent from each other, but this element must be first. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * @param defaultState The default state for this element. - * - * @return The same builder. - */ - public Builder addFirst( String name, IPipelineElementFactory factory, boolean defaultState ) - { - return this.addFirst( name, factory, defaultState, e -> - { - } ); - } + /** + * Inserts an element to the front of the list, Useful if you have a more + * complex system and each system need to be independent from each other, but + * this element must be first. + * + * @param name The name to identify this element, used as an identifier + * when setting state, and retrieving the element. + * @param factory The factory used to create the Transformer. + * @param defaultState The default state for this element. + * + * @return The same builder. + */ + public Builder addFirst(String name, IPipelineElementFactory factory, boolean defaultState) { + return this.addFirst(name, factory, defaultState, e -> { + }); + } - /** - * Inserts an element to the front of the list, Useful if you have a more complex system - * and each system need to be independent from each other, but this element must be first. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * @param defaultState The default state for this element. - * @param defaultsSetter A callback used to set any defaults on the transformer. - * - * @return The same builder. - */ - public Builder addFirst( String name, IPipelineElementFactory factory, boolean defaultState, Consumer defaultsSetter ) - { - PipelineElement element = this.makeElement( name, factory, defaultState ); - defaultsSetter.accept( element.consumer ); - this.elements.addFirst( element ); - return this; - } + /** + * Inserts an element to the front of the list, Useful if you have a more + * complex system and each system need to be independent from each other, but + * this element must be first. + * + * @param name The name to identify this element, used as an + * identifier when setting state, and retrieving the + * element. + * @param factory The factory used to create the Transformer. + * @param defaultState The default state for this element. + * @param defaultsSetter A callback used to set any defaults on the transformer. + * + * @return The same builder. + */ + public Builder addFirst(String name, IPipelineElementFactory factory, + boolean defaultState, Consumer defaultsSetter) { + PipelineElement element = this.makeElement(name, factory, defaultState); + defaultsSetter.accept(element.consumer); + this.elements.addFirst(element); + return this; + } - /** - * Adds an element at the end of the transform list, Suitable for 99% of cases. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * - * @return The same builder. - */ - public Builder addElement( String name, IPipelineElementFactory factory ) - { - return this.addElement( name, factory, true ); - } + /** + * Adds an element at the end of the transform list, Suitable for 99% of cases. + * + * @param name The name to identify this element, used as an identifier when + * setting state, and retrieving the element. + * @param factory The factory used to create the Transformer. + * + * @return The same builder. + */ + public Builder addElement(String name, IPipelineElementFactory factory) { + return this.addElement(name, factory, true); + } - /** - * Adds an element at the end of the transform list, Suitable for 99% of cases. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * @param defaultState The default state for this element. - * - * @return The same builder. - */ - public Builder addElement( String name, IPipelineElementFactory factory, boolean defaultState ) - { - return this.addElement( name, factory, defaultState, e -> - { - } ); - } + /** + * Adds an element at the end of the transform list, Suitable for 99% of cases. + * + * @param name The name to identify this element, used as an identifier + * when setting state, and retrieving the element. + * @param factory The factory used to create the Transformer. + * @param defaultState The default state for this element. + * + * @return The same builder. + */ + public Builder addElement(String name, IPipelineElementFactory factory, boolean defaultState) { + return this.addElement(name, factory, defaultState, e -> { + }); + } - /** - * Adds an element at the end of the transform list, Suitable for 99% of cases. - * - * @param name The name to identify this element, used as an identifier when setting state, and retrieving the - * element. - * @param factory The factory used to create the Transformer. - * @param defaultState The default state for this element. - * @param defaultsSetter A callback used to set any defaults on the transformer. - * - * @return The same builder. - */ - public Builder addElement( String name, IPipelineElementFactory factory, boolean defaultState, Consumer defaultsSetter ) - { - PipelineElement element = this.makeElement( name, factory, defaultState ); - defaultsSetter.accept( element.consumer ); - this.elements.add( element ); - return this; - } + /** + * Adds an element at the end of the transform list, Suitable for 99% of cases. + * + * @param name The name to identify this element, used as an + * identifier when setting state, and retrieving the + * element. + * @param factory The factory used to create the Transformer. + * @param defaultState The default state for this element. + * @param defaultsSetter A callback used to set any defaults on the transformer. + * + * @return The same builder. + */ + public Builder addElement(String name, IPipelineElementFactory factory, + boolean defaultState, Consumer defaultsSetter) { + PipelineElement element = this.makeElement(name, factory, defaultState); + defaultsSetter.accept(element.consumer); + this.elements.add(element); + return this; + } - // Internal method, used to construct the PipelineElement class. - private PipelineElement makeElement( String name, IPipelineElementFactory factory, boolean defaultState ) - { - if( this.elements.stream().anyMatch( p -> p.name.equals( name ) ) ) - { - throw new IllegalArgumentException( "Unable to add element with duplicate name: " + name ); - } - PipelineElement element = new PipelineElement<>(); - element.name = name; - element.consumer = factory.create(); - element.defaultState = defaultState; - return element; - } + // Internal method, used to construct the PipelineElement class. + private PipelineElement makeElement(String name, + IPipelineElementFactory factory, boolean defaultState) { + if (this.elements.stream().anyMatch(p -> p.name.equals(name))) { + throw new IllegalArgumentException("Unable to add element with duplicate name: " + name); + } + PipelineElement element = new PipelineElement<>(); + element.name = name; + element.consumer = factory.create(); + element.defaultState = defaultState; + return element; + } - /** - * Call this once you are finished to build your BakedPipeline! - * - * @return The new Pipeline. - */ - public BakedPipeline build() - { - return new BakedPipeline( this.elements.toArray( new PipelineElement[0] ) ); - } - } + /** + * Call this once you are finished to build your BakedPipeline! + * + * @return The new Pipeline. + */ + public BakedPipeline build() { + return new BakedPipeline(this.elements.toArray(new PipelineElement[0])); + } + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineConsumer.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineConsumer.java index 1eca87fa8..9eb41bc62 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineConsumer.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineConsumer.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline; - import net.minecraftforge.client.model.pipeline.IVertexConsumer; import appeng.thirdparty.codechicken.lib.model.CachedFormat; @@ -26,39 +25,36 @@ import appeng.thirdparty.codechicken.lib.model.ISmartVertexConsumer; import appeng.thirdparty.codechicken.lib.model.Quad; import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadReInterpolator; - /** * Anything implementing this may be used in the BakedPipeline. * * @author covers1624 */ -public interface IPipelineConsumer extends ISmartVertexConsumer -{ +public interface IPipelineConsumer extends ISmartVertexConsumer { - /** - * The quad at the start of the transformation. - * This is useful for obtaining the vertex data before any transformations have been applied, - * such as interpolation, See {@link QuadReInterpolator}. - * When overriding this make sure you call setInputQuad on your parent consumer too. - * - * @param quad The quad. - */ - void setInputQuad( Quad quad ); + /** + * The quad at the start of the transformation. This is useful for obtaining the + * vertex data before any transformations have been applied, such as + * interpolation, See {@link QuadReInterpolator}. When overriding this make sure + * you call setInputQuad on your parent consumer too. + * + * @param quad The quad. + */ + void setInputQuad(Quad quad); - /** - * Resets the Consumer to the new format. - * This should resize any internal arrays if needed, ready for the new vertex data. - * - * @param format The format to reset to. - */ - void reset( CachedFormat format ); + /** + * Resets the Consumer to the new format. This should resize any internal arrays + * if needed, ready for the new vertex data. + * + * @param format The format to reset to. + */ + void reset(CachedFormat format); - /** - * Sets the parent consumer. - * This consumer may choose to not pipe any data, - * that's fine, but if it does, it MUST pipe the data to the one provided here. - * - * @param parent The parent. - */ - void setParent( IVertexConsumer parent ); + /** + * Sets the parent consumer. This consumer may choose to not pipe any data, + * that's fine, but if it does, it MUST pipe the data to the one provided here. + * + * @param parent The parent. + */ + void setParent(IVertexConsumer parent); } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineElementFactory.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineElementFactory.java index d2fec2541..6ecd87589 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineElementFactory.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/IPipelineElementFactory.java @@ -18,13 +18,11 @@ package appeng.thirdparty.codechicken.lib.model.pipeline; - /** * @author covers1624 */ @FunctionalInterface -public interface IPipelineElementFactory -{ +public interface IPipelineElementFactory { - T create(); + T create(); } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/QuadTransformer.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/QuadTransformer.java index 64bb26868..c2f60eb58 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/QuadTransformer.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/QuadTransformer.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline; - import javax.annotation.OverridingMethodsMustInvokeSuper; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -30,146 +29,121 @@ import appeng.thirdparty.codechicken.lib.model.CachedFormat; import appeng.thirdparty.codechicken.lib.model.ISmartVertexConsumer; import appeng.thirdparty.codechicken.lib.model.Quad; - /** - * Base class for a simple QuadTransformer. - * Operates on BakedQuads. + * Base class for a simple QuadTransformer. Operates on BakedQuads. * QuadTransformers can be piped into each other at no performance penalty. * * @author covers1624 */ -public abstract class QuadTransformer implements IVertexConsumer, ISmartVertexConsumer, IPipelineConsumer -{ +public abstract class QuadTransformer implements IVertexConsumer, ISmartVertexConsumer, IPipelineConsumer { - protected CachedFormat format; - protected IVertexConsumer consumer; - protected Quad quad; + protected CachedFormat format; + protected IVertexConsumer consumer; + protected Quad quad; - /** - * Used for the BakedPipeline. - */ - protected QuadTransformer() - { - this.quad = new Quad(); - } + /** + * Used for the BakedPipeline. + */ + protected QuadTransformer() { + this.quad = new Quad(); + } - public QuadTransformer( IVertexConsumer consumer ) - { - this( consumer.getVertexFormat(), consumer ); - } + public QuadTransformer(IVertexConsumer consumer) { + this(consumer.getVertexFormat(), consumer); + } - public QuadTransformer( VertexFormat format, IVertexConsumer consumer ) - { - this( CachedFormat.lookup( format ), consumer ); - } + public QuadTransformer(VertexFormat format, IVertexConsumer consumer) { + this(CachedFormat.lookup(format), consumer); + } - public QuadTransformer( CachedFormat format, IVertexConsumer consumer ) - { - this.format = format; - this.consumer = consumer; - this.quad = new Quad( format ); - } + public QuadTransformer(CachedFormat format, IVertexConsumer consumer) { + this.format = format; + this.consumer = consumer; + this.quad = new Quad(format); + } - @Override - @OverridingMethodsMustInvokeSuper - public void reset( CachedFormat format ) - { - this.format = format; - this.quad.reset( format ); - } + @Override + @OverridingMethodsMustInvokeSuper + public void reset(CachedFormat format) { + this.format = format; + this.quad.reset(format); + } - @Override - public void setParent( IVertexConsumer parent ) - { - this.consumer = parent; - } + @Override + public void setParent(IVertexConsumer parent) { + this.consumer = parent; + } - @Override - @OverridingMethodsMustInvokeSuper - public void setInputQuad( Quad quad ) - { - if( this.consumer instanceof IPipelineConsumer ) - { - ( (IPipelineConsumer) this.consumer ).setInputQuad( quad ); - } - } + @Override + @OverridingMethodsMustInvokeSuper + public void setInputQuad(Quad quad) { + if (this.consumer instanceof IPipelineConsumer) { + ((IPipelineConsumer) this.consumer).setInputQuad(quad); + } + } - // @formatter:off - @Override - public VertexFormat getVertexFormat() - { - return this.format.format; - } + // @formatter:off + @Override + public VertexFormat getVertexFormat() { + return this.format.format; + } - @Override - public void setQuadTint( int tint ) - { - this.quad.setQuadTint( tint ); - } + @Override + public void setQuadTint(int tint) { + this.quad.setQuadTint(tint); + } - @Override - public void setQuadOrientation( Direction orientation ) - { - this.quad.setQuadOrientation( orientation ); - } + @Override + public void setQuadOrientation(Direction orientation) { + this.quad.setQuadOrientation(orientation); + } - @Override - public void setApplyDiffuseLighting( boolean diffuse ) - { - this.quad.setApplyDiffuseLighting( diffuse ); - } + @Override + public void setApplyDiffuseLighting(boolean diffuse) { + this.quad.setApplyDiffuseLighting(diffuse); + } - @Override - public void setTexture( TextureAtlasSprite texture ) - { - this.quad.setTexture( texture ); - } - // @formatter:on + @Override + public void setTexture(TextureAtlasSprite texture) { + this.quad.setTexture(texture); + } + // @formatter:on - @Override - public void put( int element, float... data ) - { - this.quad.put( element, data ); - if( this.quad.full ) - { - this.onFull(); - } - } + @Override + public void put(int element, float... data) { + this.quad.put(element, data); + if (this.quad.full) { + this.onFull(); + } + } - @Override - public void put( Quad quad ) - { - this.quad.put( quad ); - this.onFull(); - } + @Override + public void put(Quad quad) { + this.quad.put(quad); + this.onFull(); + } - /** - * Called to transform the vertices. - * - * @return If the transformer should pipe the quad. - */ - public abstract boolean transform(); + /** + * Called to transform the vertices. + * + * @return If the transformer should pipe the quad. + */ + public abstract boolean transform(); - public void onFull() - { - if( this.transform() ) - { - this.quad.pipe( this.consumer ); - } - } + public void onFull() { + if (this.transform()) { + this.quad.pipe(this.consumer); + } + } - // Should be small enough. - private final static double EPSILON = 0.00001; + // Should be small enough. + private final static double EPSILON = 0.00001; - public static boolean epsComp( float a, float b ) - { - if( a == b ) - { - return true; - } - else - { - return Math.abs( a - b ) < EPSILON; - } - } + public static boolean epsComp(float a, float b) { + if (a == b) { + return true; + } else { + return Math.abs(a - b) < EPSILON; + } + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadAlphaOverride.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadAlphaOverride.java index 37bbeb03a..e66f60e97 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadAlphaOverride.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadAlphaOverride.java @@ -18,54 +18,45 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import net.minecraftforge.client.model.pipeline.IVertexConsumer; import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer simply overrides the alpha of the quad. - * Only operates if the format has color. + * This transformer simply overrides the alpha of the quad. Only operates if the + * format has color. * * @author covers1624 */ -public class QuadAlphaOverride extends QuadTransformer -{ +public class QuadAlphaOverride extends QuadTransformer { - public static final IPipelineElementFactory FACTORY = QuadAlphaOverride::new; + public static final IPipelineElementFactory FACTORY = QuadAlphaOverride::new; - private float alphaOverride; + private float alphaOverride; - QuadAlphaOverride() - { - super(); - } + QuadAlphaOverride() { + super(); + } - public QuadAlphaOverride( IVertexConsumer consumer, float alphaOverride ) - { - super( consumer ); - this.alphaOverride = alphaOverride; - } + public QuadAlphaOverride(IVertexConsumer consumer, float alphaOverride) { + super(consumer); + this.alphaOverride = alphaOverride; + } - public QuadAlphaOverride setAlphaOverride( float alphaOverride ) - { - this.alphaOverride = alphaOverride; - return this; - } + public QuadAlphaOverride setAlphaOverride(float alphaOverride) { + this.alphaOverride = alphaOverride; + return this; + } - @Override - public boolean transform() - { - if( this.format.hasColor ) - { - for( Vertex v : this.quad.vertices ) - { - v.color[3] = this.alphaOverride; - } - } - return true; - } + @Override + public boolean transform() { + if (this.format.hasColor) { + for (Vertex v : this.quad.vertices) { + v.color[3] = this.alphaOverride; + } + } + return true; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadClamper.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadClamper.java index a460fa4fa..23c06180d 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadClamper.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadClamper.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.client.model.pipeline.IVertexConsumer; @@ -26,58 +25,53 @@ import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer simply clamps the vertices inside the provided box. - * You probably want to Re-Interpolate the UV's, Color, and Lmap, see {@link QuadReInterpolator} + * This transformer simply clamps the vertices inside the provided box. You + * probably want to Re-Interpolate the UV's, Color, and Lmap, see + * {@link QuadReInterpolator} * * @author covers1624 */ -public class QuadClamper extends QuadTransformer -{ +public class QuadClamper extends QuadTransformer { - public static IPipelineElementFactory FACTORY = QuadClamper::new; + public static IPipelineElementFactory FACTORY = QuadClamper::new; - private AxisAlignedBB clampBounds; + private AxisAlignedBB clampBounds; - QuadClamper() - { - super(); - } + QuadClamper() { + super(); + } - public QuadClamper( IVertexConsumer parent, AxisAlignedBB bounds ) - { - super( parent ); - this.clampBounds = bounds; - } + public QuadClamper(IVertexConsumer parent, AxisAlignedBB bounds) { + super(parent); + this.clampBounds = bounds; + } - public void setClampBounds( AxisAlignedBB bounds ) - { - this.clampBounds = bounds; - } + public void setClampBounds(AxisAlignedBB bounds) { + this.clampBounds = bounds; + } - @Override - public boolean transform() - { - int s = this.quad.orientation.ordinal() >> 1; + @Override + public boolean transform() { + int s = this.quad.orientation.ordinal() >> 1; - this.quad.clamp( this.clampBounds ); + this.quad.clamp(this.clampBounds); - // Check if the quad would be invisible and cull it. - Vertex[] vertices = this.quad.vertices; - float x1 = vertices[0].dx( s ); - float x2 = vertices[1].dx( s ); - float x3 = vertices[2].dx( s ); - float x4 = vertices[3].dx( s ); + // Check if the quad would be invisible and cull it. + Vertex[] vertices = this.quad.vertices; + float x1 = vertices[0].dx(s); + float x2 = vertices[1].dx(s); + float x3 = vertices[2].dx(s); + float x4 = vertices[3].dx(s); - float y1 = vertices[0].dy( s ); - float y2 = vertices[1].dy( s ); - float y3 = vertices[2].dy( s ); - float y4 = vertices[3].dy( s ); + float y1 = vertices[0].dy(s); + float y2 = vertices[1].dy(s); + float y3 = vertices[2].dy(s); + float y4 = vertices[3].dy(s); - // These comparisons are safe as we are comparing clamped values. - boolean flag1 = x1 == x2 && x2 == x3 && x3 == x4; - boolean flag2 = y1 == y2 && y2 == y3 && y3 == y4; - return !flag1 && !flag2; - } + // These comparisons are safe as we are comparing clamped values. + boolean flag1 = x1 == x2 && x2 == x3 && x3 == x4; + boolean flag2 = y1 == y2 && y2 == y3 && y3 == y4; + return !flag1 && !flag2; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadCornerKicker.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadCornerKicker.java index cbc50adbf..b2e5be753 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadCornerKicker.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadCornerKicker.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import static net.minecraft.util.Direction.AxisDirection.NEGATIVE; import static net.minecraft.util.Direction.AxisDirection.POSITIVE; @@ -31,189 +30,161 @@ import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer is a little complicated. - * Basically a Facade / Cover can use this to 'kick' the edges - * in of quads to fix z-Fighting in the corners. - * Use it by specifying the side of the block you are on, - * the bitmask for where the other Facades / Cover's are, - * the bounding box of the facade, NOT the hole piece, - * and the thickness of your Facade / Cover, this is used - * as the kick amount. + * This transformer is a little complicated. Basically a Facade / Cover can use + * this to 'kick' the edges in of quads to fix z-Fighting in the corners. Use it + * by specifying the side of the block you are on, the bitmask for where the + * other Facades / Cover's are, the bounding box of the facade, NOT the hole + * piece, and the thickness of your Facade / Cover, this is used as the kick + * amount. * * @author covers1624 */ -public class QuadCornerKicker extends QuadTransformer -{ +public class QuadCornerKicker extends QuadTransformer { - // The factory for pipeline creation. - public static final IPipelineElementFactory FACTORY = QuadCornerKicker::new; + // The factory for pipeline creation. + public static final IPipelineElementFactory FACTORY = QuadCornerKicker::new; - // Simple horizonal lookups. - public static int[][] horizonals = new int[][] { - // Around Y axis, NSWE. - { 2, 3, 4, 5 }, // - { 2, 3, 4, 5 }, // + // Simple horizonal lookups. + public static int[][] horizonals = new int[][] { + // Around Y axis, NSWE. + { 2, 3, 4, 5 }, // + { 2, 3, 4, 5 }, // - // Around Z axis, DUWE. - { 0, 1, 4, 5 }, // - { 0, 1, 4, 5 }, // + // Around Z axis, DUWE. + { 0, 1, 4, 5 }, // + { 0, 1, 4, 5 }, // - // Around X axis, DUNS. - { 0, 1, 2, 3 }, // - { 0, 1, 2, 3 } - }; + // Around X axis, DUNS. + { 0, 1, 2, 3 }, // + { 0, 1, 2, 3 } }; - private int mySide; - private int facadeMask; - private AxisAlignedBB box; - private double thickness; + private int mySide; + private int facadeMask; + private AxisAlignedBB box; + private double thickness; - QuadCornerKicker() - { - super(); - } + QuadCornerKicker() { + super(); + } - /** - * Set's the side this Facade / Cover is attached to. - * - * @param side The side. - */ - public void setSide( int side ) - { - this.mySide = side; - } + /** + * Set's the side this Facade / Cover is attached to. + * + * @param side The side. + */ + public void setSide(int side) { + this.mySide = side; + } - /** - * Sets the bitmask of Facades / Covers in the blockspace. - * This is as simple as, mask = (1 << side) - * - * @param mask The mask. - */ - public void setFacadeMask( int mask ) - { - this.facadeMask = mask; - } + /** + * Sets the bitmask of Facades / Covers in the blockspace. This is as simple as, + * mask = (1 << side) + * + * @param mask The mask. + */ + public void setFacadeMask(int mask) { + this.facadeMask = mask; + } - /** - * Sets the bounding box of the Facade / Cover, - * this should be the full box, not just a piece - * of the hole's 'ring'. - * - * @param box The BoundingBox. - */ - public void setBox( AxisAlignedBB box ) - { - this.box = box; - } + /** + * Sets the bounding box of the Facade / Cover, this should be the full box, not + * just a piece of the hole's 'ring'. + * + * @param box The BoundingBox. + */ + public void setBox(AxisAlignedBB box) { + this.box = box; + } - /** - * Sets the amount to kick the vertex in by, - * this is your facades thickness. - * - * @param thickness The thickness. - */ - public void setThickness( double thickness ) - { - this.thickness = thickness; - } + /** + * Sets the amount to kick the vertex in by, this is your facades thickness. + * + * @param thickness The thickness. + */ + public void setThickness(double thickness) { + this.thickness = thickness; + } - @Override - public boolean transform() - { + @Override + public boolean transform() { - int side = this.quad.orientation.ordinal(); - if( side != this.mySide && side != ( this.mySide ^ 1 ) ) - { - for( int hoz : horizonals[this.mySide] ) - { - if( side != hoz && side != ( hoz ^ 1 ) ) - { - if( ( this.facadeMask & ( 1 << hoz ) ) != 0 ) - { - Corner corner = Corner.fromSides( this.mySide ^ 1, side, hoz ); - for( Vertex vertex : this.quad.vertices ) - { - float x = vertex.vec[0]; - float y = vertex.vec[1]; - float z = vertex.vec[2]; - if( epsComp( x, corner.pX( this.box ) ) && epsComp( y, corner.pY( this.box ) ) && epsComp( z, corner.pZ( this.box ) ) ) - { - Vec3i vec = Direction.values()[hoz].getDirectionVec(); - x -= vec.getX() * this.thickness; - y -= vec.getY() * this.thickness; - z -= vec.getZ() * this.thickness; - vertex.vec[0] = x; - vertex.vec[1] = y; - vertex.vec[2] = z; - } - } - } - } - } - } + int side = this.quad.orientation.ordinal(); + if (side != this.mySide && side != (this.mySide ^ 1)) { + for (int hoz : horizonals[this.mySide]) { + if (side != hoz && side != (hoz ^ 1)) { + if ((this.facadeMask & (1 << hoz)) != 0) { + Corner corner = Corner.fromSides(this.mySide ^ 1, side, hoz); + for (Vertex vertex : this.quad.vertices) { + float x = vertex.vec[0]; + float y = vertex.vec[1]; + float z = vertex.vec[2]; + if (epsComp(x, corner.pX(this.box)) && epsComp(y, corner.pY(this.box)) + && epsComp(z, corner.pZ(this.box))) { + Vec3i vec = Direction.values()[hoz].getDirectionVec(); + x -= vec.getX() * this.thickness; + y -= vec.getY() * this.thickness; + z -= vec.getZ() * this.thickness; + vertex.vec[0] = x; + vertex.vec[1] = y; + vertex.vec[2] = z; + } + } + } + } + } + } - return true; - } + return true; + } - public enum Corner - { + public enum Corner { - MIN_X_MIN_Y_MIN_Z( NEGATIVE, NEGATIVE, NEGATIVE ), - MIN_X_MIN_Y_MAX_Z( NEGATIVE, NEGATIVE, POSITIVE ), - MIN_X_MAX_Y_MIN_Z( NEGATIVE, POSITIVE, NEGATIVE ), - MIN_X_MAX_Y_MAX_Z( NEGATIVE, POSITIVE, POSITIVE ), + MIN_X_MIN_Y_MIN_Z(NEGATIVE, NEGATIVE, NEGATIVE), MIN_X_MIN_Y_MAX_Z(NEGATIVE, NEGATIVE, POSITIVE), + MIN_X_MAX_Y_MIN_Z(NEGATIVE, POSITIVE, NEGATIVE), MIN_X_MAX_Y_MAX_Z(NEGATIVE, POSITIVE, POSITIVE), - MAX_X_MIN_Y_MIN_Z( POSITIVE, NEGATIVE, NEGATIVE ), - MAX_X_MIN_Y_MAX_Z( POSITIVE, NEGATIVE, POSITIVE ), - MAX_X_MAX_Y_MIN_Z( POSITIVE, POSITIVE, NEGATIVE ), - MAX_X_MAX_Y_MAX_Z( POSITIVE, POSITIVE, POSITIVE ); + MAX_X_MIN_Y_MIN_Z(POSITIVE, NEGATIVE, NEGATIVE), MAX_X_MIN_Y_MAX_Z(POSITIVE, NEGATIVE, POSITIVE), + MAX_X_MAX_Y_MIN_Z(POSITIVE, POSITIVE, NEGATIVE), MAX_X_MAX_Y_MAX_Z(POSITIVE, POSITIVE, POSITIVE); - private AxisDirection xAxis; - private AxisDirection yAxis; - private AxisDirection zAxis; + private AxisDirection xAxis; + private AxisDirection yAxis; + private AxisDirection zAxis; - private static final int[] sideMask = { 0, 2, 0, 1, 0, 4 }; + private static final int[] sideMask = { 0, 2, 0, 1, 0, 4 }; - Corner( AxisDirection xAxis, AxisDirection yAxis, AxisDirection zAxis ) - { - this.xAxis = xAxis; - this.yAxis = yAxis; - this.zAxis = zAxis; - } + Corner(AxisDirection xAxis, AxisDirection yAxis, AxisDirection zAxis) { + this.xAxis = xAxis; + this.yAxis = yAxis; + this.zAxis = zAxis; + } - /** - * Used to find what corner is at the 3 sides. - * This method assumes you pass in the X axis side, Y axis side, and Z axis side, - * it will NOT complain about an invalid side, you will just get garbage data. - * This method also does not care what order the 3 axes are in. - * - * @param sideA Side one. - * @param sideB Side two. - * @param sideC Side three. - * - * @return The corner at the 3 sides. - */ - public static Corner fromSides( int sideA, int sideB, int sideC ) - { - // <3 Chicken-Bones. - return values()[sideMask[sideA] | sideMask[sideB] | sideMask[sideC]]; - } + /** + * Used to find what corner is at the 3 sides. This method assumes you pass in + * the X axis side, Y axis side, and Z axis side, it will NOT complain about an + * invalid side, you will just get garbage data. This method also does not care + * what order the 3 axes are in. + * + * @param sideA Side one. + * @param sideB Side two. + * @param sideC Side three. + * + * @return The corner at the 3 sides. + */ + public static Corner fromSides(int sideA, int sideB, int sideC) { + // <3 Chicken-Bones. + return values()[sideMask[sideA] | sideMask[sideB] | sideMask[sideC]]; + } - public float pX( AxisAlignedBB box ) - { - return (float) ( this.xAxis == NEGATIVE ? box.minX : box.maxX ); - } + public float pX(AxisAlignedBB box) { + return (float) (this.xAxis == NEGATIVE ? box.minX : box.maxX); + } - public float pY( AxisAlignedBB box ) - { - return (float) ( this.yAxis == NEGATIVE ? box.minY : box.maxY ); - } + public float pY(AxisAlignedBB box) { + return (float) (this.yAxis == NEGATIVE ? box.minY : box.maxY); + } - public float pZ( AxisAlignedBB box ) - { - return (float) ( this.zAxis == NEGATIVE ? box.minZ : box.maxZ ); - } - } + public float pZ(AxisAlignedBB box) { + return (float) (this.zAxis == NEGATIVE ? box.minZ : box.maxZ); + } + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadFaceStripper.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadFaceStripper.java index bc4074b69..ed7bd03d2 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadFaceStripper.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadFaceStripper.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import static net.minecraft.util.Direction.AxisDirection.POSITIVE; import net.minecraft.util.Direction.AxisDirection; @@ -29,100 +28,85 @@ import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer strips quads that are on faces. - * Simply set the bounds for the faces, and the strip mask. + * This transformer strips quads that are on faces. Simply set the bounds for + * the faces, and the strip mask. * * @author covers1624 */ -public class QuadFaceStripper extends QuadTransformer -{ +public class QuadFaceStripper extends QuadTransformer { - public static final IPipelineElementFactory FACTORY = QuadFaceStripper::new; + public static final IPipelineElementFactory FACTORY = QuadFaceStripper::new; - private AxisAlignedBB bounds; - private int mask; + private AxisAlignedBB bounds; + private int mask; - QuadFaceStripper() - { - super(); - } + QuadFaceStripper() { + super(); + } - public QuadFaceStripper( IVertexConsumer parent, AxisAlignedBB bounds, int mask ) - { - super( parent ); - this.bounds = bounds; - this.mask = mask; - } + public QuadFaceStripper(IVertexConsumer parent, AxisAlignedBB bounds, int mask) { + super(parent); + this.bounds = bounds; + this.mask = mask; + } - /** - * The bounds of the faces, - * used as the .. bounds, if all vertices of a quad - * lay on the bounds, it is up for stripping. - * - * @param bounds The bounds. - */ - public void setBounds( AxisAlignedBB bounds ) - { - this.bounds = bounds; - } + /** + * The bounds of the faces, used as the .. bounds, if all vertices of a quad lay + * on the bounds, it is up for stripping. + * + * @param bounds The bounds. + */ + public void setBounds(AxisAlignedBB bounds) { + this.bounds = bounds; + } - /** - * The mask to strip edges. - * This is an opt in system, - * the mask is simple 'mask = (1 << side)'. - * - * @param mask The mask. - */ - public void setMask( int mask ) - { - this.mask = mask; - } + /** + * The mask to strip edges. This is an opt in system, the mask is simple 'mask = + * (1 << side)'. + * + * @param mask The mask. + */ + public void setMask(int mask) { + this.mask = mask; + } - @Override - public boolean transform() - { - if( this.mask == 0 ) - { - return true;// No mask, nothing changes. - } - // If the bit for this quad is set, then check if we should strip. - if( ( this.mask & ( 1 << this.quad.orientation.ordinal() ) ) != 0 ) - { - AxisDirection dir = this.quad.orientation.getAxisDirection(); - Vertex[] vertices = this.quad.vertices; - switch( this.quad.orientation.getAxis() ) - { - case X: - { - float bound = (float) ( dir == POSITIVE ? this.bounds.maxX : this.bounds.minX ); - float x1 = vertices[0].vec[0]; - float x2 = vertices[1].vec[0]; - float x3 = vertices[2].vec[0]; - float x4 = vertices[3].vec[0]; - return x1 != x2 || x2 != x3 || x3 != x4 || x4 != bound; - } - case Y: - { - float bound = (float) ( dir == POSITIVE ? this.bounds.maxY : this.bounds.minY ); - float y1 = vertices[0].vec[1]; - float y2 = vertices[1].vec[1]; - float y3 = vertices[2].vec[1]; - float y4 = vertices[3].vec[1]; - return y1 != y2 || y2 != y3 || y3 != y4 || y4 != bound; - } - case Z: - { - float bound = (float) ( dir == POSITIVE ? this.bounds.maxZ : this.bounds.minZ ); - float z1 = vertices[0].vec[2]; - float z2 = vertices[1].vec[2]; - float z3 = vertices[2].vec[2]; - float z4 = vertices[3].vec[2]; - return z1 != z2 || z2 != z3 || z3 != z4 || z4 != bound; - } - } - } - return true; - } + @Override + public boolean transform() { + if (this.mask == 0) { + return true;// No mask, nothing changes. + } + // If the bit for this quad is set, then check if we should strip. + if ((this.mask & (1 << this.quad.orientation.ordinal())) != 0) { + AxisDirection dir = this.quad.orientation.getAxisDirection(); + Vertex[] vertices = this.quad.vertices; + switch (this.quad.orientation.getAxis()) { + case X: { + float bound = (float) (dir == POSITIVE ? this.bounds.maxX : this.bounds.minX); + float x1 = vertices[0].vec[0]; + float x2 = vertices[1].vec[0]; + float x3 = vertices[2].vec[0]; + float x4 = vertices[3].vec[0]; + return x1 != x2 || x2 != x3 || x3 != x4 || x4 != bound; + } + case Y: { + float bound = (float) (dir == POSITIVE ? this.bounds.maxY : this.bounds.minY); + float y1 = vertices[0].vec[1]; + float y2 = vertices[1].vec[1]; + float y3 = vertices[2].vec[1]; + float y4 = vertices[3].vec[1]; + return y1 != y2 || y2 != y3 || y3 != y4 || y4 != bound; + } + case Z: { + float bound = (float) (dir == POSITIVE ? this.bounds.maxZ : this.bounds.minZ); + float z1 = vertices[0].vec[2]; + float z2 = vertices[1].vec[2]; + float z3 = vertices[2].vec[2]; + float z4 = vertices[3].vec[2]; + return z1 != z2 || z2 != z3 || z3 != z4 || z4 != bound; + } + } + } + return true; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadMatrixTransformer.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadMatrixTransformer.java index 27894f657..34211862d 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadMatrixTransformer.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadMatrixTransformer.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Vector4f; import net.minecraft.util.Direction; @@ -28,67 +27,58 @@ import appeng.thirdparty.codechicken.lib.model.Quad; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** * Created by covers1624 on 2/6/20. */ -public class QuadMatrixTransformer extends QuadTransformer -{ - public static IPipelineElementFactory FACTORY = QuadMatrixTransformer::new; - private static final Matrix4f identity; +public class QuadMatrixTransformer extends QuadTransformer { + public static IPipelineElementFactory FACTORY = QuadMatrixTransformer::new; + private static final Matrix4f identity; - static - { - identity = new Matrix4f(); - identity.setIdentity(); - } + static { + identity = new Matrix4f(); + identity.setIdentity(); + } - private final Vector4f storage = new Vector4f(); - private Matrix4f matrix; - private boolean identityMatrix; + private final Vector4f storage = new Vector4f(); + private Matrix4f matrix; + private boolean identityMatrix; - QuadMatrixTransformer() - { - super(); - } + QuadMatrixTransformer() { + super(); + } - public QuadMatrixTransformer( IVertexConsumer parent, Matrix4f matrix ) - { - super( parent ); - this.matrix = matrix; - this.identityMatrix = matrix.equals( identity ); - } + public QuadMatrixTransformer(IVertexConsumer parent, Matrix4f matrix) { + super(parent); + this.matrix = matrix; + this.identityMatrix = matrix.equals(identity); + } - public void setMatrix( Matrix4f matrix ) - { - this.matrix = matrix; - this.identityMatrix = matrix.equals( identity ); - } + public void setMatrix(Matrix4f matrix) { + this.matrix = matrix; + this.identityMatrix = matrix.equals(identity); + } - @Override - public boolean transform() - { - if( identityMatrix ) - { - return true; - } - for( Quad.Vertex vertex : this.quad.vertices ) - { - storage.set( vertex.vec[0], vertex.vec[1], vertex.vec[2], 1 ); - storage.transform( matrix ); - vertex.vec[0] = storage.getX(); - vertex.vec[1] = storage.getY(); - vertex.vec[2] = storage.getZ(); + @Override + public boolean transform() { + if (identityMatrix) { + return true; + } + for (Quad.Vertex vertex : this.quad.vertices) { + storage.set(vertex.vec[0], vertex.vec[1], vertex.vec[2], 1); + storage.transform(matrix); + vertex.vec[0] = storage.getX(); + vertex.vec[1] = storage.getY(); + vertex.vec[2] = storage.getZ(); - storage.set( vertex.normal[0], vertex.normal[1], vertex.normal[2], 0 ); - storage.transform( matrix ); - storage.normalize(); - vertex.normal[0] = storage.getX(); - vertex.normal[1] = storage.getY(); - vertex.normal[2] = storage.getZ(); - } - Quad.Vertex v0 = quad.vertices[0]; - quad.orientation = Direction.getFacingFromVector( v0.normal[0], v0.normal[1], v0.normal[2] ); - return true; - } + storage.set(vertex.normal[0], vertex.normal[1], vertex.normal[2], 0); + storage.transform(matrix); + storage.normalize(); + vertex.normal[0] = storage.getX(); + vertex.normal[1] = storage.getY(); + vertex.normal[2] = storage.getZ(); + } + Quad.Vertex v0 = quad.vertices[0]; + quad.orientation = Direction.getFacingFromVector(v0.normal[0], v0.normal[1], v0.normal[2]); + return true; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadReInterpolator.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadReInterpolator.java index 95e52fe3c..ff3ed4713 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadReInterpolator.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadReInterpolator.java @@ -18,7 +18,6 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import appeng.thirdparty.codechicken.lib.math.InterpHelper; import appeng.thirdparty.codechicken.lib.model.CachedFormat; import appeng.thirdparty.codechicken.lib.model.Quad; @@ -26,67 +25,56 @@ import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer Re-Interpolates the Color, UV's and LightMaps. - * Use this after all transformations that translate vertices in the pipeline. + * This transformer Re-Interpolates the Color, UV's and LightMaps. Use this + * after all transformations that translate vertices in the pipeline. * * This Transformation can only be used in the BakedPipeline. * * @author covers1624 */ -public class QuadReInterpolator extends QuadTransformer -{ +public class QuadReInterpolator extends QuadTransformer { - public static final IPipelineElementFactory FACTORY = QuadReInterpolator::new; + public static final IPipelineElementFactory FACTORY = QuadReInterpolator::new; - private Quad interpCache = new Quad(); - private InterpHelper interpHelper = new InterpHelper(); + private Quad interpCache = new Quad(); + private InterpHelper interpHelper = new InterpHelper(); - QuadReInterpolator() - { - super(); - } + QuadReInterpolator() { + super(); + } - @Override - public void reset( CachedFormat format ) - { - super.reset( format ); - this.interpCache.reset( format ); - } + @Override + public void reset(CachedFormat format) { + super.reset(format); + this.interpCache.reset(format); + } - @Override - public void setInputQuad( Quad quad ) - { - super.setInputQuad( quad ); - quad.resetInterp( this.interpHelper, quad.orientation.ordinal() >> 1 ); - } + @Override + public void setInputQuad(Quad quad) { + super.setInputQuad(quad); + quad.resetInterp(this.interpHelper, quad.orientation.ordinal() >> 1); + } - @Override - public boolean transform() - { - int s = this.quad.orientation.ordinal() >> 1; - if( this.format.hasColor || this.format.hasUV || this.format.hasLightMap ) - { - this.interpCache.copyFrom( this.quad ); - this.interpHelper.setup(); - for( Vertex v : this.quad.vertices ) - { - this.interpHelper.locate( v.dx( s ), v.dy( s ) ); - if( this.format.hasColor ) - { - v.interpColorFrom( this.interpHelper, this.interpCache.vertices ); - } - if( this.format.hasUV ) - { - v.interpUVFrom( this.interpHelper, this.interpCache.vertices ); - } - if( this.format.hasLightMap ) - { - v.interpLightMapFrom( this.interpHelper, this.interpCache.vertices ); - } - } - } - return true; - } + @Override + public boolean transform() { + int s = this.quad.orientation.ordinal() >> 1; + if (this.format.hasColor || this.format.hasUV || this.format.hasLightMap) { + this.interpCache.copyFrom(this.quad); + this.interpHelper.setup(); + for (Vertex v : this.quad.vertices) { + this.interpHelper.locate(v.dx(s), v.dy(s)); + if (this.format.hasColor) { + v.interpColorFrom(this.interpHelper, this.interpCache.vertices); + } + if (this.format.hasUV) { + v.interpUVFrom(this.interpHelper, this.interpCache.vertices); + } + if (this.format.hasLightMap) { + v.interpLightMapFrom(this.interpHelper, this.interpCache.vertices); + } + } + } + return true; + } } diff --git a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadTinter.java b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadTinter.java index 760fbb6df..54afe8089 100644 --- a/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadTinter.java +++ b/src/main/java/appeng/thirdparty/codechicken/lib/model/pipeline/transformers/QuadTinter.java @@ -18,61 +18,52 @@ package appeng.thirdparty.codechicken.lib.model.pipeline.transformers; - import net.minecraftforge.client.model.pipeline.IVertexConsumer; import appeng.thirdparty.codechicken.lib.model.Quad.Vertex; import appeng.thirdparty.codechicken.lib.model.pipeline.IPipelineElementFactory; import appeng.thirdparty.codechicken.lib.model.pipeline.QuadTransformer; - /** - * This transformer tints quads.. - * Feed it the output of BlockColors.colorMultiplier. + * This transformer tints quads.. Feed it the output of + * BlockColors.colorMultiplier. * * @author covers1624 */ -public class QuadTinter extends QuadTransformer -{ +public class QuadTinter extends QuadTransformer { - public static final IPipelineElementFactory FACTORY = QuadTinter::new; + public static final IPipelineElementFactory FACTORY = QuadTinter::new; - private int tint; + private int tint; - QuadTinter() - { - super(); - } + QuadTinter() { + super(); + } - public QuadTinter( IVertexConsumer consumer, int tint ) - { - super( consumer ); - this.tint = tint; - } + public QuadTinter(IVertexConsumer consumer, int tint) { + super(consumer); + this.tint = tint; + } - public QuadTinter setTint( int tint ) - { - this.tint = tint; - return this; - } + public QuadTinter setTint(int tint) { + this.tint = tint; + return this; + } - @Override - public boolean transform() - { - // Nuke tintIndex. - this.quad.tintIndex = -1; - if( this.format.hasColor ) - { - float r = ( this.tint >> 0x10 & 0xFF ) / 255F; - float g = ( this.tint >> 0x08 & 0xFF ) / 255F; - float b = ( this.tint & 0xFF ) / 255F; - for( Vertex v : this.quad.vertices ) - { - v.color[0] *= r; - v.color[1] *= g; - v.color[2] *= b; - } - } - return true; - } + @Override + public boolean transform() { + // Nuke tintIndex. + this.quad.tintIndex = -1; + if (this.format.hasColor) { + float r = (this.tint >> 0x10 & 0xFF) / 255F; + float g = (this.tint >> 0x08 & 0xFF) / 255F; + float b = (this.tint & 0xFF) / 255F; + for (Vertex v : this.quad.vertices) { + v.color[0] *= r; + v.color[1] *= g; + v.color[2] *= b; + } + } + return true; + } } diff --git a/src/main/java/appeng/tile/AEBaseInvTile.java b/src/main/java/appeng/tile/AEBaseInvTile.java index 4672c95d3..adf30211a 100644 --- a/src/main/java/appeng/tile/AEBaseInvTile.java +++ b/src/main/java/appeng/tile/AEBaseInvTile.java @@ -18,7 +18,6 @@ package appeng.tile; - import java.util.List; import javax.annotation.Nonnull; @@ -39,94 +38,78 @@ import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory { -public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory -{ + public AEBaseInvTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public AEBaseInvTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + final IItemHandler inv = this.getInternalInventory(); + if (inv != EmptyHandler.INSTANCE) { + final CompoundNBT opt = data.getCompound("inv"); + for (int x = 0; x < inv.getSlots(); x++) { + final CompoundNBT item = opt.getCompound("item" + x); + ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.read(item)); + } + } + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - final IItemHandler inv = this.getInternalInventory(); - if( inv != EmptyHandler.INSTANCE ) - { - final CompoundNBT opt = data.getCompound( "inv" ); - for( int x = 0; x < inv.getSlots(); x++ ) - { - final CompoundNBT item = opt.getCompound( "item" + x ); - ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.read(item) ); - } - } - } + public abstract @Nonnull IItemHandler getInternalInventory(); - public abstract @Nonnull IItemHandler getInternalInventory(); + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + final IItemHandler inv = this.getInternalInventory(); + if (inv != EmptyHandler.INSTANCE) { + final CompoundNBT opt = new CompoundNBT(); + for (int x = 0; x < inv.getSlots(); x++) { + final CompoundNBT item = new CompoundNBT(); + final ItemStack is = inv.getStackInSlot(x); + if (!is.isEmpty()) { + is.write(item); + } + opt.put("item" + x, item); + } + data.put("inv", opt); + } + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - final IItemHandler inv = this.getInternalInventory(); - if( inv != EmptyHandler.INSTANCE ) - { - final CompoundNBT opt = new CompoundNBT(); - for( int x = 0; x < inv.getSlots(); x++ ) - { - final CompoundNBT item = new CompoundNBT(); - final ItemStack is = inv.getStackInSlot( x ); - if( !is.isEmpty() ) - { - is.write(item); - } - opt.put( "item" + x, item ); - } - data.put( "inv", opt ); - } - return data; - } + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + final IItemHandler inv = this.getInternalInventory(); - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - final IItemHandler inv = this.getInternalInventory(); + for (int l = 0; l < inv.getSlots(); l++) { + final ItemStack is = inv.getStackInSlot(l); + if (!is.isEmpty()) { + drops.add(is); + } + } + } - for( int l = 0; l < inv.getSlots(); l++ ) - { - final ItemStack is = inv.getStackInSlot( l ); - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + @Override + public abstract void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removed, + ItemStack added); - @Override - public abstract void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ); + protected @Nonnull IItemHandler getItemHandlerForSide(@Nonnull Direction side) { + return this.getInternalInventory(); + } - protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull Direction side ) - { - return this.getInternalInventory(); - } - - @SuppressWarnings("unchecked") - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { - if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) - { - if( facing == null ) - { - return (LazyOptional) LazyOptional.of(this::getInternalInventory); - } - else - { - return (LazyOptional) LazyOptional.of(() -> getItemHandlerForSide( facing )); - } - } - return super.getCapability( capability, facing ); - } + @SuppressWarnings("unchecked") + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { + if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (facing == null) { + return (LazyOptional) LazyOptional.of(this::getInternalInventory); + } else { + return (LazyOptional) LazyOptional.of(() -> getItemHandlerForSide(facing)); + } + } + return super.getCapability(capability, facing); + } } diff --git a/src/main/java/appeng/tile/AEBaseTile.java b/src/main/java/appeng/tile/AEBaseTile.java index 929d7e3d5..891e60606 100644 --- a/src/main/java/appeng/tile/AEBaseTile.java +++ b/src/main/java/appeng/tile/AEBaseTile.java @@ -18,23 +18,17 @@ package appeng.tile; +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.api.implementations.tiles.ISegmentedInventory; -import appeng.api.util.ICommonTile; -import appeng.api.util.IConfigManager; -import appeng.api.util.IConfigurableObject; -import appeng.api.util.IOrientable; -import appeng.block.AEBaseTileBlock; -import appeng.client.render.model.AEModelData; -import appeng.core.AELog; -import appeng.core.features.IStackSrc; -import appeng.helpers.ICustomNameObject; -import appeng.helpers.IPriorityHost; -import appeng.hooks.TickHandler; -import appeng.tile.inventory.AppEngInternalAEInventory; -import appeng.util.Platform; -import appeng.util.SettingsFrom; import io.netty.buffer.Unpooled; + import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; @@ -53,476 +47,414 @@ import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.items.IItemHandler; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject -{ - - private static final ThreadLocal> DROP_NO_ITEMS = new ThreadLocal<>(); - private static final Map, IStackSrc> ITEM_STACKS = new HashMap<>(); - private int renderFragment = 0; - @Nullable - private String customName; - private Direction forward = Direction.NORTH; - private Direction up = Direction.UP; - private boolean markDirtyQueued = false; - - public AEBaseTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } - - public static void registerTileItem( final Class c, final IStackSrc wat ) - { - ITEM_STACKS.put( c, wat ); - } - - public boolean dropItems() - { - final WeakReference what = DROP_NO_ITEMS.get(); - return what == null || what.get() != this; - } - - public boolean notLoaded() - { - return !this.world.isBlockLoaded( this.pos ); - } - - @Nonnull - public TileEntity getTile() - { - return this; - } - - @Nullable - protected ItemStack getItemFromTile( final Object obj ) - { - final IStackSrc src = ITEM_STACKS.get( obj.getClass() ); - if( src == null ) - { - return ItemStack.EMPTY; - } - return src.stack( 1 ); - } - - @Override - public void read( final CompoundNBT data ) - { - super.read( data ); - - if( data.contains( "customName" ) ) - { - this.customName = data.getString( "customName" ); - } - else - { - this.customName = null; - } - - try - { - if( this.canBeRotated() ) - { - this.forward = Direction.valueOf( data.getString( "forward" ) ); - this.up = Direction.valueOf( data.getString( "up" ) ); - } - } - catch( final IllegalArgumentException ignored ) - { - } - } - - @Override - public CompoundNBT write( final CompoundNBT data ) - { - super.write( data ); - - if( this.canBeRotated() ) - { - data.putString( "forward", this.getForward().name() ); - data.putString( "up", this.getUp().name() ); - } - - if( this.customName != null ) - { - data.putString( "customName", this.customName ); - } - - return data; - } - - @Override - public SUpdateTileEntityPacket getUpdatePacket() - { - return new SUpdateTileEntityPacket( this.pos, 64, this.getUpdateTag() ); - } - - @Override - public void onDataPacket( final NetworkManager net, final SUpdateTileEntityPacket pkt ) - { - // / pkt.actionType - if( pkt.getTileEntityType() == 64 ) - { - this.handleUpdateTag( pkt.getNbtCompound() ); - } - } - - public void onReady() - { - } - - /** - * This builds a tag with the actual data that should be sent to the client for update syncs. - * If the tile entity doesn't need update syncs, it returns null. - */ - private CompoundNBT writeUpdateData() - { - final CompoundNBT data = new CompoundNBT(); - - final PacketBuffer stream = new PacketBuffer( Unpooled.buffer() ); - - try - { - this.writeToStream( stream ); - if( stream.readableBytes() == 0 ) - { - return null; - } - } - catch( final Throwable t ) - { - AELog.debug( t ); - } - - stream.capacity( stream.readableBytes() ); - data.putByteArray( "X", stream.array() ); - return data; - } - - private boolean readUpdateData( PacketBuffer stream ) - { - boolean output = false; - - try - { - this.renderFragment = 100; - - output = this.readFromStream( stream ); - - if( ( this.renderFragment & 1 ) == 1 ) - { - output = true; - } - this.renderFragment = 0; - } - catch( final Throwable t ) - { - AELog.debug( t ); - } - - return output; - } - - /** - * Handles tile entites that are being sent to the client as part of a full chunk. - */ - @Override - public CompoundNBT getUpdateTag() - { - final CompoundNBT data = this.writeUpdateData(); - - if( data == null ) - { - return new CompoundNBT(); - } - - data.putInt( "x", this.pos.getX() ); - data.putInt( "y", this.pos.getY() ); - data.putInt( "z", this.pos.getZ() ); - return data; - } - - /** - * Handles tile entites that are being received by the client as part of a full chunk. - */ - @Override - public void handleUpdateTag( CompoundNBT tag ) - { - final PacketBuffer stream = new PacketBuffer( Unpooled.copiedBuffer( tag.getByteArray( "X" ) ) ); - - if( this.readUpdateData( stream ) ) - { - this.markForUpdate(); - } - } - - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - if( this.canBeRotated() ) - { - final Direction old_Forward = this.forward; - final Direction old_Up = this.up; - - final byte orientation = data.readByte(); - this.forward = Direction.values()[orientation & 0x7]; - this.up = Direction.values()[orientation >> 3]; - - return this.forward != old_Forward || this.up != old_Up; - } - return false; - } - - protected void writeToStream( final PacketBuffer data ) throws IOException - { - if( this.canBeRotated() ) - { - final byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() ); - data.writeByte( orientation ); - } - } - - public void markForUpdate() - { - if( this.renderFragment > 0 ) - { - this.renderFragment |= 1; - } - else - { - // TODO: Optimize Network Load - if( this.world != null ) - { - this.requestModelDataUpdate(); - - boolean alreadyUpdated = false; - // Let the block update it's own state with our internal state changes - BlockState currentState = getBlockState(); - if (currentState.getBlock() instanceof AEBaseTileBlock) { - AEBaseTileBlock tileBlock = (AEBaseTileBlock) currentState.getBlock(); - BlockState newState = tileBlock.getTileEntityBlockState(currentState, this); - if (currentState != newState) { - AELog.blockUpdate(this.pos, currentState, newState, this); - this.world.setBlockState(pos, newState); - alreadyUpdated = true; - } - } - - if (!alreadyUpdated) { - this.world.notifyBlockUpdate(this.pos, currentState, currentState, 1); - } - } - } - } - - /** - * By default all blocks can have orientation, this handles saving, and loading, as well as synchronization. - * - * @return true if tile can be rotated - */ - @Override - public boolean canBeRotated() - { - return true; - } - - @Override - public Direction getForward() - { - return this.forward; - } - - @Override - public Direction getUp() - { - return this.up; - } - - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - this.forward = inForward; - this.up = inUp; - this.markForUpdate(); - Platform.notifyBlocksOfNeighbors( this.world, this.pos ); - } - - public void onPlacement(BlockItemUseContext context) - { - ItemStack stack = context.getItem(); - if( stack.hasTag() ) - { - this.uploadSettings( SettingsFrom.DISMANTLE_ITEM, stack.getTag() ); - } - } - - /** - * depending on the from, different settings will be accepted, don't call this with null - * - * @param from source of settings - * @param compound compound of source - */ - public void uploadSettings( final SettingsFrom from, final CompoundNBT compound ) - { - if( this instanceof IConfigurableObject ) - { - final IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager(); - if( cm != null ) - { - cm.readFromNBT( compound ); - } - } - - if( this instanceof IPriorityHost ) - { - final IPriorityHost pHost = (IPriorityHost) this; - pHost.setPriority( compound.getInt( "priority" ) ); - } - - if( this instanceof ISegmentedInventory ) - { - final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" ); - if( inv instanceof AppEngInternalAEInventory ) - { - final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv; - final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() ); - tmp.readFromNBT( compound, "config" ); - for( int x = 0; x < tmp.getSlots(); x++ ) - { - target.setStackInSlot( x, tmp.getStackInSlot( x ) ); - } - } - } - } - - /** - * returns the contents of the tile entity, into the world, defaults to dropping everything in the inventory. - * - * @param w world - * @param pos block position - * @param drops drops of tile entity - */ - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - - } - - public void getNoDrops( final World w, final BlockPos pos, final List drops ) - { - - } - - /** - * null means nothing to store... - * - * @param from source of settings - * - * @return compound of source - */ - public CompoundNBT downloadSettings( final SettingsFrom from ) - { - final CompoundNBT output = new CompoundNBT(); - - if( this.hasCustomInventoryName() ) - { - final CompoundNBT dsp = new CompoundNBT(); - dsp.putString( "Name", this.customName ); - output.put( "display", dsp ); - } - - if( this instanceof IConfigurableObject ) - { - final IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager(); - if( cm != null ) - { - cm.writeToNBT( output ); - } - } - - if( this instanceof IPriorityHost) - { - final IPriorityHost pHost = (IPriorityHost) this; - output.putInt( "priority", pHost.getPriority() ); - } - - if( this instanceof ISegmentedInventory) - { - final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" ); - if( inv instanceof AppEngInternalAEInventory) - { - ( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" ); - } - } - - return output.isEmpty() ? null : output; - } - - @Override - public ITextComponent getCustomInventoryName() - { - return new StringTextComponent(this.hasCustomInventoryName() ? this.customName : this.getClass().getSimpleName()); - } - - @Override - public boolean hasCustomInventoryName() - { - return this.customName != null && !this.customName.isEmpty(); - } - - public void securityBreak() - { - this.world.destroyBlock( this.pos, true ); - this.disableDrops(); - } - - /** - * Checks if this tile entity is remote (we are running on the logical client side). - */ - public boolean isRemote() { - World world = getWorld(); - return world == null || world.isRemote(); - } - - public void disableDrops() - { - DROP_NO_ITEMS.set( new WeakReference<>( this ) ); - } - - public void saveChanges() - { - if( this.world != null ) - { - this.world.markChunkDirty( this.pos, this ); - if( !this.markDirtyQueued ) - { - TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick ); - this.markDirtyQueued = true; - } - } - } - - private Object markDirtyAtEndOfTick( final World w ) - { - this.markDirty(); - this.markDirtyQueued = false; - return null; - } - - public void setName( final String name ) - { - this.customName = name; - } - - @Nonnull - @Override - public IModelData getModelData() { - return new AEModelData(up, forward); - } +import appeng.api.implementations.tiles.ISegmentedInventory; +import appeng.api.util.ICommonTile; +import appeng.api.util.IConfigManager; +import appeng.api.util.IConfigurableObject; +import appeng.api.util.IOrientable; +import appeng.block.AEBaseTileBlock; +import appeng.client.render.model.AEModelData; +import appeng.core.AELog; +import appeng.core.features.IStackSrc; +import appeng.helpers.ICustomNameObject; +import appeng.helpers.IPriorityHost; +import appeng.hooks.TickHandler; +import appeng.tile.inventory.AppEngInternalAEInventory; +import appeng.util.Platform; +import appeng.util.SettingsFrom; + +public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject { + + private static final ThreadLocal> DROP_NO_ITEMS = new ThreadLocal<>(); + private static final Map, IStackSrc> ITEM_STACKS = new HashMap<>(); + private int renderFragment = 0; + @Nullable + private String customName; + private Direction forward = Direction.NORTH; + private Direction up = Direction.UP; + private boolean markDirtyQueued = false; + + public AEBaseTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } + + public static void registerTileItem(final Class c, final IStackSrc wat) { + ITEM_STACKS.put(c, wat); + } + + public boolean dropItems() { + final WeakReference what = DROP_NO_ITEMS.get(); + return what == null || what.get() != this; + } + + public boolean notLoaded() { + return !this.world.isBlockLoaded(this.pos); + } + + @Nonnull + public TileEntity getTile() { + return this; + } + + @Nullable + protected ItemStack getItemFromTile(final Object obj) { + final IStackSrc src = ITEM_STACKS.get(obj.getClass()); + if (src == null) { + return ItemStack.EMPTY; + } + return src.stack(1); + } + + @Override + public void read(final CompoundNBT data) { + super.read(data); + + if (data.contains("customName")) { + this.customName = data.getString("customName"); + } else { + this.customName = null; + } + + try { + if (this.canBeRotated()) { + this.forward = Direction.valueOf(data.getString("forward")); + this.up = Direction.valueOf(data.getString("up")); + } + } catch (final IllegalArgumentException ignored) { + } + } + + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + + if (this.canBeRotated()) { + data.putString("forward", this.getForward().name()); + data.putString("up", this.getUp().name()); + } + + if (this.customName != null) { + data.putString("customName", this.customName); + } + + return data; + } + + @Override + public SUpdateTileEntityPacket getUpdatePacket() { + return new SUpdateTileEntityPacket(this.pos, 64, this.getUpdateTag()); + } + + @Override + public void onDataPacket(final NetworkManager net, final SUpdateTileEntityPacket pkt) { + // / pkt.actionType + if (pkt.getTileEntityType() == 64) { + this.handleUpdateTag(pkt.getNbtCompound()); + } + } + + public void onReady() { + } + + /** + * This builds a tag with the actual data that should be sent to the client for + * update syncs. If the tile entity doesn't need update syncs, it returns null. + */ + private CompoundNBT writeUpdateData() { + final CompoundNBT data = new CompoundNBT(); + + final PacketBuffer stream = new PacketBuffer(Unpooled.buffer()); + + try { + this.writeToStream(stream); + if (stream.readableBytes() == 0) { + return null; + } + } catch (final Throwable t) { + AELog.debug(t); + } + + stream.capacity(stream.readableBytes()); + data.putByteArray("X", stream.array()); + return data; + } + + private boolean readUpdateData(PacketBuffer stream) { + boolean output = false; + + try { + this.renderFragment = 100; + + output = this.readFromStream(stream); + + if ((this.renderFragment & 1) == 1) { + output = true; + } + this.renderFragment = 0; + } catch (final Throwable t) { + AELog.debug(t); + } + + return output; + } + + /** + * Handles tile entites that are being sent to the client as part of a full + * chunk. + */ + @Override + public CompoundNBT getUpdateTag() { + final CompoundNBT data = this.writeUpdateData(); + + if (data == null) { + return new CompoundNBT(); + } + + data.putInt("x", this.pos.getX()); + data.putInt("y", this.pos.getY()); + data.putInt("z", this.pos.getZ()); + return data; + } + + /** + * Handles tile entites that are being received by the client as part of a full + * chunk. + */ + @Override + public void handleUpdateTag(CompoundNBT tag) { + final PacketBuffer stream = new PacketBuffer(Unpooled.copiedBuffer(tag.getByteArray("X"))); + + if (this.readUpdateData(stream)) { + this.markForUpdate(); + } + } + + protected boolean readFromStream(final PacketBuffer data) throws IOException { + if (this.canBeRotated()) { + final Direction old_Forward = this.forward; + final Direction old_Up = this.up; + + final byte orientation = data.readByte(); + this.forward = Direction.values()[orientation & 0x7]; + this.up = Direction.values()[orientation >> 3]; + + return this.forward != old_Forward || this.up != old_Up; + } + return false; + } + + protected void writeToStream(final PacketBuffer data) throws IOException { + if (this.canBeRotated()) { + final byte orientation = (byte) ((this.up.ordinal() << 3) | this.forward.ordinal()); + data.writeByte(orientation); + } + } + + public void markForUpdate() { + if (this.renderFragment > 0) { + this.renderFragment |= 1; + } else { + // TODO: Optimize Network Load + if (this.world != null) { + this.requestModelDataUpdate(); + + boolean alreadyUpdated = false; + // Let the block update it's own state with our internal state changes + BlockState currentState = getBlockState(); + if (currentState.getBlock() instanceof AEBaseTileBlock) { + AEBaseTileBlock tileBlock = (AEBaseTileBlock) currentState.getBlock(); + BlockState newState = tileBlock.getTileEntityBlockState(currentState, this); + if (currentState != newState) { + AELog.blockUpdate(this.pos, currentState, newState, this); + this.world.setBlockState(pos, newState); + alreadyUpdated = true; + } + } + + if (!alreadyUpdated) { + this.world.notifyBlockUpdate(this.pos, currentState, currentState, 1); + } + } + } + } + + /** + * By default all blocks can have orientation, this handles saving, and loading, + * as well as synchronization. + * + * @return true if tile can be rotated + */ + @Override + public boolean canBeRotated() { + return true; + } + + @Override + public Direction getForward() { + return this.forward; + } + + @Override + public Direction getUp() { + return this.up; + } + + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + this.forward = inForward; + this.up = inUp; + this.markForUpdate(); + Platform.notifyBlocksOfNeighbors(this.world, this.pos); + } + + public void onPlacement(BlockItemUseContext context) { + ItemStack stack = context.getItem(); + if (stack.hasTag()) { + this.uploadSettings(SettingsFrom.DISMANTLE_ITEM, stack.getTag()); + } + } + + /** + * depending on the from, different settings will be accepted, don't call this + * with null + * + * @param from source of settings + * @param compound compound of source + */ + public void uploadSettings(final SettingsFrom from, final CompoundNBT compound) { + if (this instanceof IConfigurableObject) { + final IConfigManager cm = ((IConfigurableObject) this).getConfigManager(); + if (cm != null) { + cm.readFromNBT(compound); + } + } + + if (this instanceof IPriorityHost) { + final IPriorityHost pHost = (IPriorityHost) this; + pHost.setPriority(compound.getInt("priority")); + } + + if (this instanceof ISegmentedInventory) { + final IItemHandler inv = ((ISegmentedInventory) this).getInventoryByName("config"); + if (inv instanceof AppEngInternalAEInventory) { + final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv; + final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory(null, target.getSlots()); + tmp.readFromNBT(compound, "config"); + for (int x = 0; x < tmp.getSlots(); x++) { + target.setStackInSlot(x, tmp.getStackInSlot(x)); + } + } + } + } + + /** + * returns the contents of the tile entity, into the world, defaults to dropping + * everything in the inventory. + * + * @param w world + * @param pos block position + * @param drops drops of tile entity + */ + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + + } + + public void getNoDrops(final World w, final BlockPos pos, final List drops) { + + } + + /** + * null means nothing to store... + * + * @param from source of settings + * + * @return compound of source + */ + public CompoundNBT downloadSettings(final SettingsFrom from) { + final CompoundNBT output = new CompoundNBT(); + + if (this.hasCustomInventoryName()) { + final CompoundNBT dsp = new CompoundNBT(); + dsp.putString("Name", this.customName); + output.put("display", dsp); + } + + if (this instanceof IConfigurableObject) { + final IConfigManager cm = ((IConfigurableObject) this).getConfigManager(); + if (cm != null) { + cm.writeToNBT(output); + } + } + + if (this instanceof IPriorityHost) { + final IPriorityHost pHost = (IPriorityHost) this; + output.putInt("priority", pHost.getPriority()); + } + + if (this instanceof ISegmentedInventory) { + final IItemHandler inv = ((ISegmentedInventory) this).getInventoryByName("config"); + if (inv instanceof AppEngInternalAEInventory) { + ((AppEngInternalAEInventory) inv).writeToNBT(output, "config"); + } + } + + return output.isEmpty() ? null : output; + } + + @Override + public ITextComponent getCustomInventoryName() { + return new StringTextComponent( + this.hasCustomInventoryName() ? this.customName : this.getClass().getSimpleName()); + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && !this.customName.isEmpty(); + } + + public void securityBreak() { + this.world.destroyBlock(this.pos, true); + this.disableDrops(); + } + + /** + * Checks if this tile entity is remote (we are running on the logical client + * side). + */ + public boolean isRemote() { + World world = getWorld(); + return world == null || world.isRemote(); + } + + public void disableDrops() { + DROP_NO_ITEMS.set(new WeakReference<>(this)); + } + + public void saveChanges() { + if (this.world != null) { + this.world.markChunkDirty(this.pos, this); + if (!this.markDirtyQueued) { + TickHandler.INSTANCE.addCallable(null, this::markDirtyAtEndOfTick); + this.markDirtyQueued = true; + } + } + } + + private Object markDirtyAtEndOfTick(final World w) { + this.markDirty(); + this.markDirtyQueued = false; + return null; + } + + public void setName(final String name) { + this.customName = name; + } + + @Nonnull + @Override + public IModelData getModelData() { + return new AEModelData(up, forward); + } } diff --git a/src/main/java/appeng/tile/crafting/CraftingCubeModelData.java b/src/main/java/appeng/tile/crafting/CraftingCubeModelData.java index e0980a84f..89763c7ca 100644 --- a/src/main/java/appeng/tile/crafting/CraftingCubeModelData.java +++ b/src/main/java/appeng/tile/crafting/CraftingCubeModelData.java @@ -1,15 +1,18 @@ package appeng.tile.crafting; -import appeng.client.render.model.AEModelData; -import com.google.common.base.Preconditions; -import net.minecraft.util.Direction; - import java.util.EnumSet; import java.util.Objects; +import com.google.common.base.Preconditions; + +import net.minecraft.util.Direction; + +import appeng.client.render.model.AEModelData; + public class CraftingCubeModelData extends AEModelData { - // Contains information on which sides of the block are connected to other parts of a formed crafting cube + // Contains information on which sides of the block are connected to other parts + // of a formed crafting cube private final EnumSet connections; public CraftingCubeModelData(Direction up, Direction forward, EnumSet connections) { @@ -28,9 +31,12 @@ public class CraftingCubeModelData extends AEModelData { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; CraftingCubeModelData that = (CraftingCubeModelData) o; return connections.equals(that.connections); } diff --git a/src/main/java/appeng/tile/crafting/CraftingMonitorModelData.java b/src/main/java/appeng/tile/crafting/CraftingMonitorModelData.java index 8a5dca732..40d426470 100644 --- a/src/main/java/appeng/tile/crafting/CraftingMonitorModelData.java +++ b/src/main/java/appeng/tile/crafting/CraftingMonitorModelData.java @@ -1,12 +1,14 @@ package appeng.tile.crafting; -import appeng.api.util.AEColor; -import com.google.common.base.Preconditions; -import net.minecraft.util.Direction; - import java.util.EnumSet; import java.util.Objects; +import com.google.common.base.Preconditions; + +import net.minecraft.util.Direction; + +import appeng.api.util.AEColor; + public class CraftingMonitorModelData extends CraftingCubeModelData { private final AEColor color; @@ -22,9 +24,12 @@ public class CraftingMonitorModelData extends CraftingCubeModelData { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; CraftingMonitorModelData that = (CraftingMonitorModelData) o; return color == that.color; } diff --git a/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java b/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java index c06cf411a..a03c3e11c 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java @@ -18,10 +18,11 @@ package appeng.tile.crafting; - import java.io.IOException; import java.util.Optional; +import javax.annotation.Nonnull; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -30,176 +31,145 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.model.data.IModelData; import appeng.api.AEApi; import appeng.api.implementations.tiles.IColorableTile; import appeng.api.storage.data.IAEItemStack; import appeng.api.util.AEColor; import appeng.util.item.AEItemStack; -import net.minecraftforge.client.model.data.IModelData; -import javax.annotation.Nonnull; +public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile { + @OnlyIn(Dist.CLIENT) + private Integer dspList; -public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile -{ + @OnlyIn(Dist.CLIENT) + private boolean updateList; - @OnlyIn( Dist.CLIENT ) - private Integer dspList; + private IAEItemStack dspPlay; + private AEColor paintedColor = AEColor.TRANSPARENT; - @OnlyIn( Dist.CLIENT ) - private boolean updateList; + public TileCraftingMonitorTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - private IAEItemStack dspPlay; - private AEColor paintedColor = AEColor.TRANSPARENT; + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final AEColor oldPaintedColor = this.paintedColor; + this.paintedColor = AEColor.values()[data.readByte()]; - public TileCraftingMonitorTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + final boolean hasItem = data.readBoolean(); - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final AEColor oldPaintedColor = this.paintedColor; - this.paintedColor = AEColor.values()[data.readByte()]; + if (hasItem) { + this.dspPlay = AEItemStack.fromPacket(data); + } else { + this.dspPlay = null; + } - final boolean hasItem = data.readBoolean(); + this.setUpdateList(true); + return oldPaintedColor != this.paintedColor || c; // tesr! + } - if( hasItem ) - { - this.dspPlay = AEItemStack.fromPacket( data ); - } - else - { - this.dspPlay = null; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeByte(this.paintedColor.ordinal()); - this.setUpdateList( true ); - return oldPaintedColor != this.paintedColor || c; // tesr! - } + if (this.dspPlay == null) { + data.writeBoolean(false); + } else { + data.writeBoolean(true); + this.dspPlay.writeToPacket(data); + } + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeByte( this.paintedColor.ordinal() ); + @Override + public void read(final CompoundNBT data) { + super.read(data); + if (data.contains("paintedColor")) { + this.paintedColor = AEColor.values()[data.getByte("paintedColor")]; + } + } - if( this.dspPlay == null ) - { - data.writeBoolean( false ); - } - else - { - data.writeBoolean( true ); - this.dspPlay.writeToPacket( data ); - } - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putByte("paintedColor", (byte) this.paintedColor.ordinal()); + return data; + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - if( data.contains("paintedColor") ) - { - this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; - } - } + @Override + public boolean isAccelerator() { + return false; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() ); - return data; - } + @Override + public boolean isStatus() { + return true; + } - @Override - public boolean isAccelerator() - { - return false; - } + public void setJob(final IAEItemStack is) { + if ((is == null) != (this.dspPlay == null)) { + this.dspPlay = is == null ? null : is.copy(); + this.markForUpdate(); + } else if (is != null && this.dspPlay != null) { + if (is.getStackSize() != this.dspPlay.getStackSize()) { + this.dspPlay = is.copy(); + this.markForUpdate(); + } + } + } - @Override - public boolean isStatus() - { - return true; - } + public IAEItemStack getJobProgress() { + return this.dspPlay; // AEItemStack.create( new ItemStack( Items.DIAMOND, 64 ) ); + } - public void setJob( final IAEItemStack is ) - { - if( ( is == null ) != ( this.dspPlay == null ) ) - { - this.dspPlay = is == null ? null : is.copy(); - this.markForUpdate(); - } - else if( is != null && this.dspPlay != null ) - { - if( is.getStackSize() != this.dspPlay.getStackSize() ) - { - this.dspPlay = is.copy(); - this.markForUpdate(); - } - } - } + @Override + public AEColor getColor() { + return this.paintedColor; + } - public IAEItemStack getJobProgress() - { - return this.dspPlay; // AEItemStack.create( new ItemStack( Items.DIAMOND, 64 ) ); - } + @Override + public boolean recolourBlock(final Direction side, final AEColor newPaintedColor, final PlayerEntity who) { + if (this.paintedColor == newPaintedColor) { + return false; + } - @Override - public AEColor getColor() - { - return this.paintedColor; - } + this.paintedColor = newPaintedColor; + this.saveChanges(); + this.markForUpdate(); + return true; + } - @Override - public boolean recolourBlock( final Direction side, final AEColor newPaintedColor, final PlayerEntity who ) - { - if( this.paintedColor == newPaintedColor ) - { - return false; - } + public Integer getDisplayList() { + return this.dspList; + } - this.paintedColor = newPaintedColor; - this.saveChanges(); - this.markForUpdate(); - return true; - } + public void setDisplayList(final Integer dspList) { + this.dspList = dspList; + } - public Integer getDisplayList() - { - return this.dspList; - } + public boolean isUpdateList() { + return this.updateList; + } - public void setDisplayList( final Integer dspList ) - { - this.dspList = dspList; - } + public void setUpdateList(final boolean updateList) { + this.updateList = updateList; + } - public boolean isUpdateList() - { - return this.updateList; - } + @Override + protected ItemStack getItemFromTile(final Object obj) { + final Optional is = AEApi.instance().definitions().blocks().craftingMonitor().maybeStack(1); - public void setUpdateList( final boolean updateList ) - { - this.updateList = updateList; - } + return is.orElseGet(() -> super.getItemFromTile(obj)); + } - @Override - protected ItemStack getItemFromTile( final Object obj ) - { - final Optional is = AEApi.instance().definitions().blocks().craftingMonitor().maybeStack( 1 ); - - return is.orElseGet( () -> super.getItemFromTile( obj ) ); - } - - @Nonnull - @Override - public IModelData getModelData() { - return new CraftingMonitorModelData(getUp(), getForward(), getConnections(), getColor()); - } + @Nonnull + @Override + public IModelData getModelData() { + return new CraftingMonitorModelData(getUp(), getForward(), getConnections(), getColor()); + } } diff --git a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java index 707965ba3..9aab84106 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java @@ -18,87 +18,78 @@ package appeng.tile.crafting; - import java.util.Optional; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityType; import appeng.api.AEApi; import appeng.api.definitions.IBlocks; import appeng.block.crafting.AbstractCraftingUnitBlock; -import net.minecraft.tileentity.TileEntityType; +public class TileCraftingStorageTile extends TileCraftingTile { + private static final int KILO_SCALAR = 1024; -public class TileCraftingStorageTile extends TileCraftingTile -{ - private static final int KILO_SCALAR = 1024; + public TileCraftingStorageTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileCraftingStorageTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + protected ItemStack getItemFromTile(final Object obj) { + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final int storage = ((TileCraftingTile) obj).getStorageBytes() / KILO_SCALAR; - @Override - protected ItemStack getItemFromTile( final Object obj ) - { - final IBlocks blocks = AEApi.instance().definitions().blocks(); - final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR; + Optional is; - Optional is; + switch (storage) { + case 1: + is = blocks.craftingStorage1k().maybeStack(1); + break; + case 4: + is = blocks.craftingStorage4k().maybeStack(1); + break; + case 16: + is = blocks.craftingStorage16k().maybeStack(1); + break; + case 64: + is = blocks.craftingStorage64k().maybeStack(1); + break; + default: + is = Optional.empty(); + break; + } - switch( storage ) - { - case 1: - is = blocks.craftingStorage1k().maybeStack( 1 ); - break; - case 4: - is = blocks.craftingStorage4k().maybeStack( 1 ); - break; - case 16: - is = blocks.craftingStorage16k().maybeStack( 1 ); - break; - case 64: - is = blocks.craftingStorage64k().maybeStack( 1 ); - break; - default: - is = Optional.empty(); - break; - } + return is.orElseGet(() -> super.getItemFromTile(obj)); + } - return is.orElseGet( () -> super.getItemFromTile( obj ) ); - } + @Override + public boolean isAccelerator() { + return false; + } - @Override - public boolean isAccelerator() - { - return false; - } + @Override + public boolean isStorage() { + return true; + } - @Override - public boolean isStorage() - { - return true; - } + @Override + public int getStorageBytes() { + if (this.world == null || this.notLoaded() || this.isRemoved()) { + return 0; + } - @Override - public int getStorageBytes() - { - if( this.world == null || this.notLoaded() || this.isRemoved() ) - { - return 0; - } - - final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock(); - switch( unit.type ) - { - default: - case STORAGE_1K: - return 1024; - case STORAGE_4K: - return 4 * 1024; - case STORAGE_16K: - return 16 * 1024; - case STORAGE_64K: - return 64 * 1024; - } - } + final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState(this.pos) + .getBlock(); + switch (unit.type) { + default: + case STORAGE_1K: + return 1024; + case STORAGE_4K: + return 4 * 1024; + case STORAGE_16K: + return 16 * 1024; + case STORAGE_64K: + return 64 * 1024; + } + } } diff --git a/src/main/java/appeng/tile/crafting/TileCraftingTile.java b/src/main/java/appeng/tile/crafting/TileCraftingTile.java index 62b811f2f..49c336511 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingTile.java @@ -18,19 +18,26 @@ package appeng.tile.crafting; - import java.util.Collections; import java.util.EnumSet; import java.util.Iterator; import java.util.LinkedList; import java.util.Optional; +import javax.annotation.Nonnull; + import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.model.data.ModelDataMap; +import net.minecraftforge.common.util.Constants; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -55,380 +62,312 @@ import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.AENetworkProxyMultiblock; import appeng.tile.grid.AENetworkTile; import appeng.util.Platform; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.client.model.data.EmptyModelData; -import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.client.model.data.ModelDataMap; -import net.minecraftforge.common.util.Constants; -import javax.annotation.Nonnull; +public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState { + private final CraftingCPUCalculator calc = new CraftingCPUCalculator(this); + private CompoundNBT previousState = null; + private boolean isCoreBlock = false; + private CraftingCPUCluster cluster; -public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState -{ + public TileCraftingTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setFlags(GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } - private final CraftingCPUCalculator calc = new CraftingCPUCalculator( this ); - private CompoundNBT previousState = null; - private boolean isCoreBlock = false; - private CraftingCPUCluster cluster; + @Override + protected AENetworkProxy createProxy() { + return new AENetworkProxyMultiblock(this, "proxy", this.getItemFromTile(this), true); + } - public TileCraftingTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL ); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } + @Override + protected ItemStack getItemFromTile(final Object obj) { + Optional is; - @Override - protected AENetworkProxy createProxy() - { - return new AENetworkProxyMultiblock( this, "proxy", this.getItemFromTile( this ), true ); - } + if (((TileCraftingTile) obj).isAccelerator()) { + is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack(1); + } else { + is = AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1); + } - @Override - protected ItemStack getItemFromTile( final Object obj ) - { - Optional is; + return is.orElseGet(() -> super.getItemFromTile(obj)); + } - if( ( (TileCraftingTile) obj ).isAccelerator() ) - { - is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ); - } - else - { - is = AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ); - } + @Override + public boolean canBeRotated() { + return true;// return BlockCraftingUnit.checkType( world.getBlockMetadata( xCoord, yCoord, + // zCoord ), + // BlockCraftingUnit.BASE_MONITOR ); + } - return is.orElseGet( () -> super.getItemFromTile( obj ) ); - } + @Override + public void setName(final String name) { + super.setName(name); + if (this.cluster != null) { + this.cluster.updateName(); + } + } - @Override - public boolean canBeRotated() - { - return true;// return BlockCraftingUnit.checkType( world.getBlockMetadata( xCoord, yCoord, zCoord ), - // BlockCraftingUnit.BASE_MONITOR ); - } + public boolean isAccelerator() { + if (this.world == null) { + return false; + } - @Override - public void setName( final String name ) - { - super.setName( name ); - if( this.cluster != null ) - { - this.cluster.updateName(); - } - } + final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState(this.pos) + .getBlock(); + return unit.type == CraftingUnitType.ACCELERATOR; + } - public boolean isAccelerator() - { - if( this.world == null ) - { - return false; - } + @Override + public void onReady() { + super.onReady(); + this.getProxy().setVisualRepresentation(this.getItemFromTile(this)); + this.updateMultiBlock(); + } - final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState( this.pos ).getBlock(); - return unit.type == CraftingUnitType.ACCELERATOR; - } + public void updateMultiBlock() { + this.calc.calculateMultiblock(this.world, this.getLocation()); + } - @Override - public void onReady() - { - super.onReady(); - this.getProxy().setVisualRepresentation( this.getItemFromTile( this ) ); - this.updateMultiBlock(); - } + public void updateStatus(final CraftingCPUCluster c) { + if (this.cluster != null && this.cluster != c) { + this.cluster.breakCluster(); + } - public void updateMultiBlock() - { - this.calc.calculateMultiblock( this.world, this.getLocation() ); - } + this.cluster = c; + this.updateMeta(true); + } - public void updateStatus( final CraftingCPUCluster c ) - { - if( this.cluster != null && this.cluster != c ) - { - this.cluster.breakCluster(); - } + public void updateMeta(final boolean updateFormed) { + if (this.world == null || this.notLoaded() || this.isRemoved()) { + return; + } - this.cluster = c; - this.updateMeta( true ); - } + final boolean formed = this.isFormed(); + boolean power = false; - public void updateMeta( final boolean updateFormed ) - { - if( this.world == null || this.notLoaded() || this.isRemoved() ) - { - return; - } + if (this.getProxy().isReady()) { + power = this.getProxy().isActive(); + } - final boolean formed = this.isFormed(); - boolean power = false; + final BlockState current = this.world.getBlockState(this.pos); - if( this.getProxy().isReady() ) - { - power = this.getProxy().isActive(); - } + // The tile might try to update while being destroyed + if (current.getBlock() instanceof AbstractCraftingUnitBlock) { + final BlockState newState = current.with(AbstractCraftingUnitBlock.POWERED, power) + .with(AbstractCraftingUnitBlock.FORMED, formed); - final BlockState current = this.world.getBlockState( this.pos ); + if (current != newState) { + // Not using flag 2 here (only send to clients, prevent block update) will cause + // infinite loops + // In case there is an inconsistency in the crafting clusters. + this.world.setBlockState(this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE); + } + } - // The tile might try to update while being destroyed - if( current.getBlock() instanceof AbstractCraftingUnitBlock) - { - final BlockState newState = current.with( AbstractCraftingUnitBlock.POWERED, power ).with( AbstractCraftingUnitBlock.FORMED, formed ); + if (updateFormed) { + if (formed) { + this.getProxy().setValidSides(EnumSet.allOf(Direction.class)); + } else { + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } + } + } - if( current != newState ) - { - // Not using flag 2 here (only send to clients, prevent block update) will cause infinite loops - // In case there is an inconsistency in the crafting clusters. - this.world.setBlockState( this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE); - } - } + public boolean isFormed() { + if (isRemote()) { + return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.FORMED); + } + return this.cluster != null; + } - if( updateFormed ) - { - if( formed ) - { - this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) ); - } - else - { - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } - } - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putBoolean("core", this.isCoreBlock()); + if (this.isCoreBlock() && this.cluster != null) { + this.cluster.writeToNBT(data); + } + return data; + } - public boolean isFormed() - { - if( isRemote() ) - { - return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.FORMED ); - } - return this.cluster != null; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.setCoreBlock(data.getBoolean("core")); + if (this.isCoreBlock()) { + if (this.cluster != null) { + this.cluster.readFromNBT(data); + } else { + this.setPreviousState(data.copy()); + } + } + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putBoolean("core", this.isCoreBlock()); - if( this.isCoreBlock() && this.cluster != null ) - { - this.cluster.writeToNBT( data ); - } - return data; - } + @Override + public void disconnect(final boolean update) { + if (this.cluster != null) { + this.cluster.destroy(); + if (update) { + this.updateMeta(true); + } + } + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.setCoreBlock( data.getBoolean( "core" ) ); - if( this.isCoreBlock() ) - { - if( this.cluster != null ) - { - this.cluster.readFromNBT( data ); - } - else - { - this.setPreviousState( data.copy() ); - } - } - } + @Override + public IAECluster getCluster() { + return this.cluster; + } - @Override - public void disconnect( final boolean update ) - { - if( this.cluster != null ) - { - this.cluster.destroy(); - if( update ) - { - this.updateMeta( true ); - } - } - } + @Override + public boolean isValid() { + return true; + } - @Override - public IAECluster getCluster() - { - return this.cluster; - } + @MENetworkEventSubscribe + public void onPowerStateChange(final MENetworkChannelsChanged ev) { + this.updateMeta(false); + } - @Override - public boolean isValid() - { - return true; - } + @MENetworkEventSubscribe + public void onPowerStateChange(final MENetworkPowerStatusChange ev) { + this.updateMeta(false); + } - @MENetworkEventSubscribe - public void onPowerStateChange( final MENetworkChannelsChanged ev ) - { - this.updateMeta( false ); - } + public boolean isStatus() { + return false; + } - @MENetworkEventSubscribe - public void onPowerStateChange( final MENetworkPowerStatusChange ev ) - { - this.updateMeta( false ); - } + public boolean isStorage() { + return false; + } - public boolean isStatus() - { - return false; - } + public int getStorageBytes() { + return 0; + } - public boolean isStorage() - { - return false; - } + public void breakCluster() { + if (this.cluster != null) { + this.cluster.cancel(); + final IMEInventory inv = this.cluster.getInventory(); - public int getStorageBytes() - { - return 0; - } + final LinkedList places = new LinkedList<>(); - public void breakCluster() - { - if( this.cluster != null ) - { - this.cluster.cancel(); - final IMEInventory inv = this.cluster.getInventory(); + final Iterator i = this.cluster.getTiles(); + while (i.hasNext()) { + final IGridHost h = i.next(); + if (h == this) { + places.add(new WorldCoord(this)); + } else { + final TileEntity te = (TileEntity) h; - final LinkedList places = new LinkedList<>(); + for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) { + final WorldCoord wc = new WorldCoord(te); + wc.add(d, 1); + if (this.world.isAirBlock(wc.getPos())) { + places.add(wc); + } + } + } + } - final Iterator i = this.cluster.getTiles(); - while( i.hasNext() ) - { - final IGridHost h = i.next(); - if( h == this ) - { - places.add( new WorldCoord( this ) ); - } - else - { - final TileEntity te = (TileEntity) h; + Collections.shuffle(places); - for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS ) - { - final WorldCoord wc = new WorldCoord( te ); - wc.add( d, 1 ); - if( this.world.isAirBlock( wc.getPos() ) ) - { - places.add( wc ); - } - } - } - } + if (places.isEmpty()) { + throw new IllegalStateException( + this.cluster + " does not contain any kind of blocks, which were destroyed."); + } - Collections.shuffle( places ); + for (IAEItemStack ais : inv.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList())) { + ais = ais.copy(); + ais.setStackSize(ais.getDefinition().getMaxStackSize()); + while (true) { + final IAEItemStack g = inv.extractItems(ais.copy(), Actionable.MODULATE, + this.cluster.getActionSource()); + if (g == null) { + break; + } - if( places.isEmpty() ) - { - throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." ); - } + final WorldCoord wc = places.poll(); + places.add(wc); - for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ) ) - { - ais = ais.copy(); - ais.setStackSize( ais.getDefinition().getMaxStackSize() ); - while( true ) - { - final IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() ); - if( g == null ) - { - break; - } + Platform.spawnDrops(this.world, wc.getPos(), Collections.singletonList(g.createItemStack())); + } + } - final WorldCoord wc = places.poll(); - places.add( wc ); + this.cluster.destroy(); + } + } - Platform.spawnDrops( this.world, wc.getPos(), Collections.singletonList( g.createItemStack() ) ); - } - } + @Override + public boolean isPowered() { + if (isRemote()) { + return this.world.getBlockState(this.pos).get(AbstractCraftingUnitBlock.POWERED); + } + return this.getProxy().isActive(); + } - this.cluster.destroy(); - } - } + @Override + public boolean isActive() { + if (Platform.isServer()) { + return this.getProxy().isActive(); + } + return this.isPowered() && this.isFormed(); + } - @Override - public boolean isPowered() - { - if( isRemote() ) - { - return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.POWERED ); - } - return this.getProxy().isActive(); - } + public boolean isCoreBlock() { + return this.isCoreBlock; + } - @Override - public boolean isActive() - { - if( Platform.isServer() ) - { - return this.getProxy().isActive(); - } - return this.isPowered() && this.isFormed(); - } + public void setCoreBlock(final boolean isCoreBlock) { + this.isCoreBlock = isCoreBlock; + } - public boolean isCoreBlock() - { - return this.isCoreBlock; - } + public CompoundNBT getPreviousState() { + return this.previousState; + } - public void setCoreBlock( final boolean isCoreBlock ) - { - this.isCoreBlock = isCoreBlock; - } + public void setPreviousState(final CompoundNBT previousState) { + this.previousState = previousState; + } - public CompoundNBT getPreviousState() - { - return this.previousState; - } + @Nonnull + @Override + public IModelData getModelData() { + return new CraftingCubeModelData(getUp(), getForward(), getConnections()); + } - public void setPreviousState( final CompoundNBT previousState ) - { - this.previousState = previousState; - } + protected EnumSet getConnections() { + if (world == null) { + return EnumSet.noneOf(Direction.class); + } - @Nonnull - @Override - public IModelData getModelData() { - return new CraftingCubeModelData(getUp(), getForward(), getConnections()); - } + EnumSet connections = EnumSet.noneOf(Direction.class); - protected EnumSet getConnections() { - if (world == null) { - return EnumSet.noneOf(Direction.class); - } + for (Direction facing : Direction.values()) { + if (this.isConnected(world, pos, facing)) { + connections.add(facing); + } + } - EnumSet connections = EnumSet.noneOf( Direction.class ); + return connections; + } - for( Direction facing : Direction.values() ) - { - if( this.isConnected( world, pos, facing ) ) - { - connections.add( facing ); - } - } + private boolean isConnected(IBlockReader world, BlockPos pos, Direction side) { + BlockPos adjacentPos = pos.offset(side); + return world.getBlockState(adjacentPos).getBlock() instanceof AbstractCraftingUnitBlock; + } - return connections; - } - - private boolean isConnected( IBlockReader world, BlockPos pos, Direction side ) - { - BlockPos adjacentPos = pos.offset( side ); - return world.getBlockState( adjacentPos ).getBlock() instanceof AbstractCraftingUnitBlock; - } - - /** - * When the block state changes (i.e. becoming formed or unformed), we need to update the - * model data since it contains connections to neighboring tiles. - */ - @Override - public void updateContainingBlockInfo() { - super.updateContainingBlockInfo(); - requestModelDataUpdate(); - } + /** + * When the block state changes (i.e. becoming formed or unformed), we need to + * update the model data since it contains connections to neighboring tiles. + */ + @Override + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + requestModelDataUpdate(); + } } diff --git a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java index 940c958f9..e49b32a65 100644 --- a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java +++ b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java @@ -18,11 +18,9 @@ package appeng.tile.crafting; - import java.io.IOException; import java.util.List; -import appeng.core.sync.network.TargetPoint; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -60,6 +58,7 @@ import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; import appeng.container.ContainerNull; import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.network.TargetPoint; import appeng.core.sync.packets.PacketAssemblerAnimation; import appeng.items.misc.ItemEncodedPattern; import appeng.me.GridAccessException; @@ -78,573 +77,481 @@ import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.IAEItemFilter; import appeng.util.item.AEItemStack; - -public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState -{ - private final CraftingInventory craftingInv; - private final AppEngInternalInventory gridInv = new AppEngInternalInventory( this, 9 + 1, 1 ); - private final AppEngInternalInventory patternInv = new AppEngInternalInventory( this, 1, 1 ); - private final IItemHandler gridInvExt = new WrapperFilteredItemHandler( this.gridInv, new CraftingGridFilter() ); - private final IItemHandler internalInv = new WrapperChainedItemHandler( this.gridInv, this.patternInv ); - private final IConfigManager settings; - private final UpgradeInventory upgrades; - private boolean isPowered = false; - private AEPartLocation pushDirection = AEPartLocation.INTERNAL; - private ItemStack myPattern = ItemStack.EMPTY; - private ICraftingPatternDetails myPlan = null; - private double progress = 0; - private boolean isAwake = false; - private boolean forcePlan = false; - private boolean reboot = true; - - public TileMolecularAssembler(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - final ITileDefinition assembler = AEApi.instance().definitions().blocks().molecularAssembler(); - - this.settings = new ConfigManager( this ); - this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.getProxy().setIdlePowerUsage( 0.0 ); - this.upgrades = new DefinitionUpgradeInventory( assembler, this, this.getUpgradeSlots() ); - this.craftingInv = new CraftingInventory( new ContainerNull(), 3, 3 ); - - } - - private int getUpgradeSlots() - { - return 5; - } - - @Override - public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table, final Direction where ) - { - if( this.myPattern.isEmpty() ) - { - boolean isEmpty = ItemHandlerUtil.isEmpty( this.gridInv ) && ItemHandlerUtil.isEmpty( this.patternInv ); - - if( isEmpty && patternDetails.isCraftable() ) - { - this.forcePlan = true; - this.myPlan = patternDetails; - this.pushDirection = AEPartLocation.fromFacing( where ); - - for( int x = 0; x < table.getSizeInventory(); x++ ) - { - this.gridInv.setStackInSlot( x, table.getStackInSlot( x ) ); - } - - this.updateSleepiness(); - this.saveChanges(); - return true; - } - } - return false; - } - - private void updateSleepiness() - { - final boolean wasEnabled = this.isAwake; - this.isAwake = this.myPlan != null && this.hasMats() || this.canPush(); - if( wasEnabled != this.isAwake ) - { - try - { - if( this.isAwake ) - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - else - { - this.getProxy().getTick().sleepDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - } - - private boolean canPush() - { - return !this.gridInv.getStackInSlot( 9 ).isEmpty(); - } - - private boolean hasMats() - { - if( this.myPlan == null ) - { - return false; - } - - for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) - { - this.craftingInv.setInventorySlotContents( x, this.gridInv.getStackInSlot( x ) ); - } - - return !this.myPlan.getOutput( this.craftingInv, this.getWorld() ).isEmpty(); - } - - @Override - public boolean acceptsPlans() - { - return ItemHandlerUtil.isEmpty( this.patternInv ); - } - - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.upgrades.getInstalledUpgrades( u ); - } - - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final boolean oldPower = this.isPowered; - this.isPowered = data.readBoolean(); - return this.isPowered != oldPower || c; - } - - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeBoolean( this.isPowered ); - } - - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - if( this.forcePlan && this.myPlan != null ) - { - final ItemStack pattern = this.myPlan.getPattern(); - if( !pattern.isEmpty() ) - { - final CompoundNBT compound = new CompoundNBT(); - pattern.write(compound); - data.put( "myPlan", compound ); - data.putInt( "pushDirection", this.pushDirection.ordinal() ); - } - } - - this.upgrades.writeToNBT( data, "upgrades" ); - this.settings.writeToNBT( data ); - return data; - } - - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - if( data.contains("myPlan") ) - { - final ItemStack myPat = ItemStack.read( data.getCompound( "myPlan" ) ); - - if( !myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern ) - { - final World w = this.getWorld(); - final ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); - final ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w ); - if( ph != null && ph.isCraftable() ) - { - this.forcePlan = true; - this.myPlan = ph; - this.pushDirection = AEPartLocation.fromOrdinal( data.getInt( "pushDirection" ) ); - } - } - } - - this.upgrades.readFromNBT( data, "upgrades" ); - this.settings.readFromNBT( data ); - this.recalculatePlan(); - } - - private void recalculatePlan() - { - this.reboot = true; - - if( this.forcePlan ) - { - return; - } - - final ItemStack is = this.patternInv.getStackInSlot( 0 ); - - if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern ) - { - if( !ItemStack.areItemsEqual( is, this.myPattern ) ) - { - final World w = this.getWorld(); - final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - final ICraftingPatternDetails ph = iep.getPatternForItem( is, w ); - - if( ph != null && ph.isCraftable() ) - { - this.progress = 0; - this.myPattern = is; - this.myPlan = ph; - } - } - } - else - { - this.progress = 0; - this.forcePlan = false; - this.myPlan = null; - this.myPattern = ItemStack.EMPTY; - this.pushDirection = AEPartLocation.INTERNAL; - } - - this.updateSleepiness(); - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } - - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } - - @Override - public IConfigManager getConfigManager() - { - return this.settings; - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "upgrades" ) ) - { - return this.upgrades; - } - - if( name.equals( "mac" ) ) - { - return this.internalInv; - } - - return null; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - - } - - @Override - public IItemHandler getInternalInventory() - { - return this.internalInv; - } - - @Override - protected IItemHandler getItemHandlerForSide( Direction side ) - { - return this.gridInvExt; - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( inv == this.gridInv || inv == this.patternInv ) - { - this.recalculatePlan(); - } - } - - public int getCraftingProgress() - { - return (int) this.progress; - } - - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - super.getDrops( w, pos, drops ); - - for( int h = 0; h < this.upgrades.getSlots(); h++ ) - { - final ItemStack is = this.upgrades.getStackInSlot( h ); - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - this.recalculatePlan(); - this.updateSleepiness(); - return new TickingRequest( 1, 1, !this.isAwake, false ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, int ticksSinceLastCall ) - { - if( !this.gridInv.getStackInSlot( 9 ).isEmpty() ) - { - this.pushOut( this.gridInv.getStackInSlot( 9 ) ); - - // did it eject? - if( this.gridInv.getStackInSlot( 9 ).isEmpty() ) - { - this.saveChanges(); - } - - this.ejectHeldItems(); - this.updateSleepiness(); - this.progress = 0; - return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP; - } - - if( this.myPlan == null ) - { - this.updateSleepiness(); - return TickRateModulation.SLEEP; - } - - if( this.reboot ) - { - ticksSinceLastCall = 1; - } - - if( !this.isAwake ) - { - return TickRateModulation.SLEEP; - } - - this.reboot = false; - int speed = 10; - 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; - } - - if( this.progress >= 100 ) - { - for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) - { - this.craftingInv.setInventorySlotContents( x, this.gridInv.getStackInSlot( x ) ); - } - - this.progress = 0; - final ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorld() ); - if( !output.isEmpty() ) - { - BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) this.getWorld() ), output, this.craftingInv ); - - this.pushOut( output.copy() ); - - for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) - { - this.gridInv.setStackInSlot( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) ); - } - - if( ItemHandlerUtil.isEmpty( this.patternInv ) ) - { - this.forcePlan = false; - this.myPlan = null; - this.pushDirection = AEPartLocation.INTERNAL; - } - - this.ejectHeldItems(); - - final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() ); - final IAEItemStack item = AEItemStack.fromItemStack( output ); - NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where ); - - this.saveChanges(); - this.updateSleepiness(); - return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP; - } - } - - return TickRateModulation.FASTER; - } - - private void ejectHeldItems() - { - if( this.gridInv.getStackInSlot( 9 ).isEmpty() ) - { - for( int x = 0; x < 9; x++ ) - { - final ItemStack is = this.gridInv.getStackInSlot( x ); - if( !is.isEmpty() ) - { - if( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.world ) ) - { - this.gridInv.setStackInSlot( 9, is ); - this.gridInv.setStackInSlot( x, ItemStack.EMPTY ); - this.saveChanges(); - return; - } - } - } - } - } - - private int userPower( final int ticksPassed, final int bonusValue, final double acceleratorTax ) - { - try - { - return (int) ( this.getProxy() - .getEnergy() - .extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, - PowerMultiplier.CONFIG ) / acceleratorTax ); - } - catch( final GridAccessException e ) - { - return 0; - } - } - - private void pushOut( ItemStack output ) - { - if( this.pushDirection == AEPartLocation.INTERNAL ) - { - for( final Direction d : Direction.values() ) - { - output = this.pushTo( output, d ); - } - } - else - { - output = this.pushTo( output, this.pushDirection.getFacing() ); - } - - if( output.isEmpty() && this.forcePlan ) - { - this.forcePlan = false; - this.recalculatePlan(); - } - - this.gridInv.setStackInSlot( 9, output ); - } - - private ItemStack pushTo( ItemStack output, final Direction d ) - { - if( output.isEmpty() ) - { - return output; - } - - final TileEntity te = this.getWorld().getTileEntity( this.pos.offset( d ) ); - - if( te == null ) - { - return output; - } - - final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() ); - - if( adaptor == null ) - { - return output; - } - - final int size = output.getCount(); - output = adaptor.addItems( output ); - final int newSize = output.isEmpty() ? 0 : output.getCount(); - - if( size != newSize ) - { - this.saveChanges(); - } - - return output; - } - - @MENetworkEventSubscribe - public void onPowerEvent( final MENetworkPowerStatusChange p ) - { - this.updatePowerState(); - } - - private void updatePowerState() - { - boolean newState = false; - - try - { - newState = this.getProxy().isActive() && this.getProxy().getEnergy().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.0001; - } - catch( final GridAccessException ignored ) - { - - } - - if( newState != this.isPowered ) - { - this.isPowered = newState; - this.markForUpdate(); - } - } - - @Override - public boolean isPowered() - { - return this.isPowered; - } - - @Override - public boolean isActive() - { - return this.isPowered; - } - - private class CraftingGridFilter implements IAEItemFilter - { - private boolean hasPattern() - { - return TileMolecularAssembler.this.myPlan != null && !ItemHandlerUtil.isEmpty( TileMolecularAssembler.this.patternInv ); - } - - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return slot == 9; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - if( slot >= 9 ) - { - return false; - } - - if( this.hasPattern() ) - { - return TileMolecularAssembler.this.myPlan.isValidItemForSlot( slot, stack, TileMolecularAssembler.this.getWorld() ); - } - return false; - } - } +public class TileMolecularAssembler extends AENetworkInvTile + implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState { + private final CraftingInventory craftingInv; + private final AppEngInternalInventory gridInv = new AppEngInternalInventory(this, 9 + 1, 1); + private final AppEngInternalInventory patternInv = new AppEngInternalInventory(this, 1, 1); + private final IItemHandler gridInvExt = new WrapperFilteredItemHandler(this.gridInv, new CraftingGridFilter()); + private final IItemHandler internalInv = new WrapperChainedItemHandler(this.gridInv, this.patternInv); + private final IConfigManager settings; + private final UpgradeInventory upgrades; + private boolean isPowered = false; + private AEPartLocation pushDirection = AEPartLocation.INTERNAL; + private ItemStack myPattern = ItemStack.EMPTY; + private ICraftingPatternDetails myPlan = null; + private double progress = 0; + private boolean isAwake = false; + private boolean forcePlan = false; + private boolean reboot = true; + + public TileMolecularAssembler(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + final ITileDefinition assembler = AEApi.instance().definitions().blocks().molecularAssembler(); + + this.settings = new ConfigManager(this); + this.settings.registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + this.getProxy().setIdlePowerUsage(0.0); + this.upgrades = new DefinitionUpgradeInventory(assembler, this, this.getUpgradeSlots()); + this.craftingInv = new CraftingInventory(new ContainerNull(), 3, 3); + + } + + private int getUpgradeSlots() { + return 5; + } + + @Override + public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table, + final Direction where) { + if (this.myPattern.isEmpty()) { + boolean isEmpty = ItemHandlerUtil.isEmpty(this.gridInv) && ItemHandlerUtil.isEmpty(this.patternInv); + + if (isEmpty && patternDetails.isCraftable()) { + this.forcePlan = true; + this.myPlan = patternDetails; + this.pushDirection = AEPartLocation.fromFacing(where); + + for (int x = 0; x < table.getSizeInventory(); x++) { + this.gridInv.setStackInSlot(x, table.getStackInSlot(x)); + } + + this.updateSleepiness(); + this.saveChanges(); + return true; + } + } + return false; + } + + private void updateSleepiness() { + final boolean wasEnabled = this.isAwake; + this.isAwake = this.myPlan != null && this.hasMats() || this.canPush(); + if (wasEnabled != this.isAwake) { + try { + if (this.isAwake) { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } else { + this.getProxy().getTick().sleepDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + } + + private boolean canPush() { + return !this.gridInv.getStackInSlot(9).isEmpty(); + } + + private boolean hasMats() { + if (this.myPlan == null) { + return false; + } + + for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) { + this.craftingInv.setInventorySlotContents(x, this.gridInv.getStackInSlot(x)); + } + + return !this.myPlan.getOutput(this.craftingInv, this.getWorld()).isEmpty(); + } + + @Override + public boolean acceptsPlans() { + return ItemHandlerUtil.isEmpty(this.patternInv); + } + + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.upgrades.getInstalledUpgrades(u); + } + + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final boolean oldPower = this.isPowered; + this.isPowered = data.readBoolean(); + return this.isPowered != oldPower || c; + } + + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeBoolean(this.isPowered); + } + + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + if (this.forcePlan && this.myPlan != null) { + final ItemStack pattern = this.myPlan.getPattern(); + if (!pattern.isEmpty()) { + final CompoundNBT compound = new CompoundNBT(); + pattern.write(compound); + data.put("myPlan", compound); + data.putInt("pushDirection", this.pushDirection.ordinal()); + } + } + + this.upgrades.writeToNBT(data, "upgrades"); + this.settings.writeToNBT(data); + return data; + } + + @Override + public void read(final CompoundNBT data) { + super.read(data); + if (data.contains("myPlan")) { + final ItemStack myPat = ItemStack.read(data.getCompound("myPlan")); + + if (!myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern) { + final World w = this.getWorld(); + final ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); + final ICraftingPatternDetails ph = iep.getPatternForItem(myPat, w); + if (ph != null && ph.isCraftable()) { + this.forcePlan = true; + this.myPlan = ph; + this.pushDirection = AEPartLocation.fromOrdinal(data.getInt("pushDirection")); + } + } + } + + this.upgrades.readFromNBT(data, "upgrades"); + this.settings.readFromNBT(data); + this.recalculatePlan(); + } + + private void recalculatePlan() { + this.reboot = true; + + if (this.forcePlan) { + return; + } + + final ItemStack is = this.patternInv.getStackInSlot(0); + + if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) { + if (!ItemStack.areItemsEqual(is, this.myPattern)) { + final World w = this.getWorld(); + final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); + final ICraftingPatternDetails ph = iep.getPatternForItem(is, w); + + if (ph != null && ph.isCraftable()) { + this.progress = 0; + this.myPattern = is; + this.myPlan = ph; + } + } + } else { + this.progress = 0; + this.forcePlan = false; + this.myPlan = null; + this.myPattern = ItemStack.EMPTY; + this.pushDirection = AEPartLocation.INTERNAL; + } + + this.updateSleepiness(); + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } + + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } + + @Override + public IConfigManager getConfigManager() { + return this.settings; + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("upgrades")) { + return this.upgrades; + } + + if (name.equals("mac")) { + return this.internalInv; + } + + return null; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + + } + + @Override + public IItemHandler getInternalInventory() { + return this.internalInv; + } + + @Override + protected IItemHandler getItemHandlerForSide(Direction side) { + return this.gridInvExt; + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (inv == this.gridInv || inv == this.patternInv) { + this.recalculatePlan(); + } + } + + public int getCraftingProgress() { + return (int) this.progress; + } + + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + super.getDrops(w, pos, drops); + + for (int h = 0; h < this.upgrades.getSlots(); h++) { + final ItemStack is = this.upgrades.getStackInSlot(h); + if (!is.isEmpty()) { + drops.add(is); + } + } + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + this.recalculatePlan(); + this.updateSleepiness(); + return new TickingRequest(1, 1, !this.isAwake, false); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, int ticksSinceLastCall) { + if (!this.gridInv.getStackInSlot(9).isEmpty()) { + this.pushOut(this.gridInv.getStackInSlot(9)); + + // did it eject? + if (this.gridInv.getStackInSlot(9).isEmpty()) { + this.saveChanges(); + } + + this.ejectHeldItems(); + this.updateSleepiness(); + this.progress = 0; + return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP; + } + + if (this.myPlan == null) { + this.updateSleepiness(); + return TickRateModulation.SLEEP; + } + + if (this.reboot) { + ticksSinceLastCall = 1; + } + + if (!this.isAwake) { + return TickRateModulation.SLEEP; + } + + this.reboot = false; + int speed = 10; + 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; + } + + if (this.progress >= 100) { + for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) { + this.craftingInv.setInventorySlotContents(x, this.gridInv.getStackInSlot(x)); + } + + this.progress = 0; + final ItemStack output = this.myPlan.getOutput(this.craftingInv, this.getWorld()); + if (!output.isEmpty()) { + BasicEventHooks.firePlayerCraftingEvent(Platform.getPlayer((ServerWorld) this.getWorld()), output, + this.craftingInv); + + this.pushOut(output.copy()); + + for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) { + this.gridInv.setStackInSlot(x, Platform.getContainerItem(this.craftingInv.getStackInSlot(x))); + } + + if (ItemHandlerUtil.isEmpty(this.patternInv)) { + this.forcePlan = false; + this.myPlan = null; + this.pushDirection = AEPartLocation.INTERNAL; + } + + this.ejectHeldItems(); + + final TargetPoint where = new TargetPoint(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, + this.world.getDimension().getType()); + final IAEItemStack item = AEItemStack.fromItemStack(output); + NetworkHandler.instance().sendToAllAround(new PacketAssemblerAnimation(this.pos, (byte) speed, item), + where); + + this.saveChanges(); + this.updateSleepiness(); + return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP; + } + } + + return TickRateModulation.FASTER; + } + + private void ejectHeldItems() { + if (this.gridInv.getStackInSlot(9).isEmpty()) { + for (int x = 0; x < 9; x++) { + final ItemStack is = this.gridInv.getStackInSlot(x); + if (!is.isEmpty()) { + if (this.myPlan == null || !this.myPlan.isValidItemForSlot(x, is, this.world)) { + this.gridInv.setStackInSlot(9, is); + this.gridInv.setStackInSlot(x, ItemStack.EMPTY); + this.saveChanges(); + return; + } + } + } + } + } + + private int userPower(final int ticksPassed, final int bonusValue, final double acceleratorTax) { + try { + return (int) (this.getProxy().getEnergy().extractAEPower(ticksPassed * bonusValue * acceleratorTax, + Actionable.MODULATE, PowerMultiplier.CONFIG) / acceleratorTax); + } catch (final GridAccessException e) { + return 0; + } + } + + private void pushOut(ItemStack output) { + if (this.pushDirection == AEPartLocation.INTERNAL) { + for (final Direction d : Direction.values()) { + output = this.pushTo(output, d); + } + } else { + output = this.pushTo(output, this.pushDirection.getFacing()); + } + + if (output.isEmpty() && this.forcePlan) { + this.forcePlan = false; + this.recalculatePlan(); + } + + this.gridInv.setStackInSlot(9, output); + } + + private ItemStack pushTo(ItemStack output, final Direction d) { + if (output.isEmpty()) { + return output; + } + + final TileEntity te = this.getWorld().getTileEntity(this.pos.offset(d)); + + if (te == null) { + return output; + } + + final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(te, d.getOpposite()); + + if (adaptor == null) { + return output; + } + + final int size = output.getCount(); + output = adaptor.addItems(output); + final int newSize = output.isEmpty() ? 0 : output.getCount(); + + if (size != newSize) { + this.saveChanges(); + } + + return output; + } + + @MENetworkEventSubscribe + public void onPowerEvent(final MENetworkPowerStatusChange p) { + this.updatePowerState(); + } + + private void updatePowerState() { + boolean newState = false; + + try { + newState = this.getProxy().isActive() && this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, + PowerMultiplier.CONFIG) > 0.0001; + } catch (final GridAccessException ignored) { + + } + + if (newState != this.isPowered) { + this.isPowered = newState; + this.markForUpdate(); + } + } + + @Override + public boolean isPowered() { + return this.isPowered; + } + + @Override + public boolean isActive() { + return this.isPowered; + } + + private class CraftingGridFilter implements IAEItemFilter { + private boolean hasPattern() { + return TileMolecularAssembler.this.myPlan != null + && !ItemHandlerUtil.isEmpty(TileMolecularAssembler.this.patternInv); + } + + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return slot == 9; + } + + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + if (slot >= 9) { + return false; + } + + if (this.hasPattern()) { + return TileMolecularAssembler.this.myPlan.isValidItemForSlot(slot, stack, + TileMolecularAssembler.this.getWorld()); + } + return false; + } + } } diff --git a/src/main/java/appeng/tile/grid/AENetworkInvTile.java b/src/main/java/appeng/tile/grid/AENetworkInvTile.java index 0aa3e6a2f..0e46ed6d0 100644 --- a/src/main/java/appeng/tile/grid/AENetworkInvTile.java +++ b/src/main/java/appeng/tile/grid/AENetworkInvTile.java @@ -18,8 +18,8 @@ package appeng.tile.grid; - import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; @@ -27,82 +27,69 @@ import appeng.api.util.AEPartLocation; import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.tile.AEBaseInvTile; -import net.minecraft.tileentity.TileEntityType; +public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable { -public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable -{ + private final AENetworkProxy gridProxy = new AENetworkProxy(this, "proxy", this.getItemFromTile(this), true); - private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true ); + public AENetworkInvTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public AENetworkInvTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.getProxy().readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.getProxy().readFromNBT( data ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.getProxy().writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.getProxy().writeToNBT( data ); - return data; - } + @Override + public AENetworkProxy getProxy() { + return this.gridProxy; + } - @Override - public AENetworkProxy getProxy() - { - return this.gridProxy; - } + @Override + public void gridChanged() { - @Override - public void gridChanged() - { + } - } + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + return this.getProxy().getNode(); + } - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - return this.getProxy().getNode(); - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + this.getProxy().onChunkUnloaded(); + } - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); - this.getProxy().onChunkUnloaded(); - } + @Override + public void onReady() { + super.onReady(); + this.getProxy().onReady(); + } - @Override - public void onReady() - { - super.onReady(); - this.getProxy().onReady(); - } + @Override + public void remove() { + super.remove(); + this.getProxy().remove(); + } - @Override - public void remove() - { - super.remove(); - this.getProxy().remove(); - } + @Override + public void validate() { + super.validate(); + this.getProxy().validate(); + } - @Override - public void validate() - { - super.validate(); - this.getProxy().validate(); - } - - @Override - public IGridNode getActionableNode() - { - return this.getProxy().getNode(); - } + @Override + public IGridNode getActionableNode() { + return this.getProxy().getNode(); + } } diff --git a/src/main/java/appeng/tile/grid/AENetworkPowerTile.java b/src/main/java/appeng/tile/grid/AENetworkPowerTile.java index e3758f433..d7a665765 100644 --- a/src/main/java/appeng/tile/grid/AENetworkPowerTile.java +++ b/src/main/java/appeng/tile/grid/AENetworkPowerTile.java @@ -18,8 +18,8 @@ package appeng.tile.grid; - import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; @@ -29,95 +29,80 @@ import appeng.api.util.DimensionalCoord; import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.tile.powersink.AEBasePoweredTile; -import net.minecraft.tileentity.TileEntityType; +public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IActionHost, IGridProxyable { -public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IActionHost, IGridProxyable -{ + private final AENetworkProxy gridProxy = new AENetworkProxy(this, "proxy", this.getItemFromTile(this), true); - private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true ); + public AENetworkPowerTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public AENetworkPowerTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.getProxy().readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.getProxy().readFromNBT( data ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.getProxy().writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.getProxy().writeToNBT( data ); - return data; - } + @Override + public AENetworkProxy getProxy() { + return this.gridProxy; + } - @Override - public AENetworkProxy getProxy() - { - return this.gridProxy; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + public void gridChanged() { - @Override - public void gridChanged() - { + } - } + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + return this.getProxy().getNode(); + } - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - return this.getProxy().getNode(); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public void validate() { + super.validate(); + this.getProxy().validate(); + } - @Override - public void validate() - { - super.validate(); - this.getProxy().validate(); - } + @Override + public void remove() { + super.remove(); + this.getProxy().remove(); + } - @Override - public void remove() - { - super.remove(); - this.getProxy().remove(); - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + this.getProxy().onChunkUnloaded(); + } - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); - this.getProxy().onChunkUnloaded(); - } + @Override + public void onReady() { + super.onReady(); + this.getProxy().onReady(); + } - @Override - public void onReady() - { - super.onReady(); - this.getProxy().onReady(); - } - - @Override - public IGridNode getActionableNode() - { - return this.getProxy().getNode(); - } + @Override + public IGridNode getActionableNode() { + return this.getProxy().getNode(); + } } diff --git a/src/main/java/appeng/tile/grid/AENetworkTile.java b/src/main/java/appeng/tile/grid/AENetworkTile.java index 02795c4ce..c00cf6819 100644 --- a/src/main/java/appeng/tile/grid/AENetworkTile.java +++ b/src/main/java/appeng/tile/grid/AENetworkTile.java @@ -18,8 +18,8 @@ package appeng.tile.grid; - import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; @@ -29,99 +29,83 @@ import appeng.api.util.DimensionalCoord; import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.tile.AEBaseTile; -import net.minecraft.tileentity.TileEntityType; +public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable { -public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable -{ + private final AENetworkProxy gridProxy = this.createProxy(); - private final AENetworkProxy gridProxy = this.createProxy(); + public AENetworkTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public AENetworkTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.getProxy().readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.getProxy().readFromNBT( data ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.getProxy().writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.getProxy().writeToNBT( data ); - return data; - } + protected AENetworkProxy createProxy() { + return new AENetworkProxy(this, "proxy", this.getItemFromTile(this), true); + } - protected AENetworkProxy createProxy() - { - return new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true ); - } + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + return this.getProxy().getNode(); + } - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - return this.getProxy().getNode(); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + this.getProxy().onChunkUnloaded(); + } - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); - this.getProxy().onChunkUnloaded(); - } + @Override + public void onReady() { + super.onReady(); + this.getProxy().onReady(); + } - @Override - public void onReady() - { - super.onReady(); - this.getProxy().onReady(); - } + @Override + public void remove() { + super.remove(); + this.getProxy().remove(); + } - @Override - public void remove() - { - super.remove(); - this.getProxy().remove(); - } + @Override + public void validate() { + super.validate(); + this.getProxy().validate(); + } - @Override - public void validate() - { - super.validate(); - this.getProxy().validate(); - } + @Override + public AENetworkProxy getProxy() { + return this.gridProxy; + } - @Override - public AENetworkProxy getProxy() - { - return this.gridProxy; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + public void gridChanged() { - @Override - public void gridChanged() - { + } - } - - @Override - public IGridNode getActionableNode() - { - return this.getProxy().getNode(); - } + @Override + public IGridNode getActionableNode() { + return this.getProxy().getNode(); + } } diff --git a/src/main/java/appeng/tile/grindstone/TileCrank.java b/src/main/java/appeng/tile/grindstone/TileCrank.java index 6fa075df3..23200207c 100644 --- a/src/main/java/appeng/tile/grindstone/TileCrank.java +++ b/src/main/java/appeng/tile/grindstone/TileCrank.java @@ -18,9 +18,8 @@ package appeng.tile.grindstone; +import java.io.IOException; -import appeng.api.implementations.tiles.ICrankable; -import appeng.tile.AEBaseTile; import net.minecraft.block.BlockState; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.ITickableTileEntity; @@ -28,130 +27,107 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import java.io.IOException; +import appeng.api.implementations.tiles.ICrankable; +import appeng.tile.AEBaseTile; +public class TileCrank extends AEBaseTile implements ITickableTileEntity { -public class TileCrank extends AEBaseTile implements ITickableTileEntity -{ + private final int ticksPerRotation = 18; - private final int ticksPerRotation = 18; + // sided values.. + private float visibleRotation = 0; // This is in degrees + private int charge = 0; - // sided values.. - private float visibleRotation = 0; // This is in degrees - private int charge = 0; + private int hits = 0; + private int rotation = 0; - private int hits = 0; - private int rotation = 0; + public TileCrank(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileCrank(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void tick() { + if (this.rotation > 0) { + this.setVisibleRotation(this.getVisibleRotation() - 360.0f / (this.ticksPerRotation)); + this.charge++; + if (this.charge >= this.ticksPerRotation) { + this.charge -= this.ticksPerRotation; + final ICrankable g = this.getGrinder(); + if (g != null) { + g.applyTurn(); + } + } - @Override - public void tick() - { - if( this.rotation > 0 ) - { - this.setVisibleRotation( this.getVisibleRotation() - 360.0f / ( this.ticksPerRotation ) ); - this.charge++; - if( this.charge >= this.ticksPerRotation ) - { - this.charge -= this.ticksPerRotation; - final ICrankable g = this.getGrinder(); - if( g != null ) - { - g.applyTurn(); - } - } + this.rotation--; + } + } - this.rotation--; - } - } + private ICrankable getGrinder() { + if (isRemote()) { + return null; + } - private ICrankable getGrinder() - { - if( isRemote() ) - { - return null; - } + final Direction grinder = this.getUp().getOpposite(); + final TileEntity te = this.world.getTileEntity(this.pos.offset(grinder)); + if (te instanceof ICrankable) { + return (ICrankable) te; + } + return null; + } - final Direction grinder = this.getUp().getOpposite(); - final TileEntity te = this.world.getTileEntity( this.pos.offset( grinder ) ); - if( te instanceof ICrankable ) - { - return (ICrankable) te; - } - return null; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + this.rotation = data.readInt(); + return c; + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - this.rotation = data.readInt(); - return c; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeInt(this.rotation); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeInt( this.rotation ); - } + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + final BlockState state = this.world.getBlockState(this.pos); + state.getBlock().neighborChanged(state, this.world, this.pos, state.getBlock(), this.pos, false); + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - final BlockState state = this.world.getBlockState( this.pos ); - state.getBlock().neighborChanged( state, this.world, this.pos, state.getBlock(), this.pos, false ); - } + /** + * return true if this should count towards stats. + */ + public boolean power() { + if (isRemote()) { + return false; + } - /** - * return true if this should count towards stats. - */ - public boolean power() - { - if( isRemote() ) - { - return false; - } + if (this.rotation < 3) { + final ICrankable g = this.getGrinder(); + if (g != null) { + if (g.canTurn()) { + this.hits = 0; + this.rotation += this.ticksPerRotation; + this.markForUpdate(); + return true; + } else { + this.hits++; + if (this.hits > 10) { + this.world.destroyBlock(this.pos, false); + } + } + } + } - if( this.rotation < 3 ) - { - final ICrankable g = this.getGrinder(); - if( g != null ) - { - if( g.canTurn() ) - { - this.hits = 0; - this.rotation += this.ticksPerRotation; - this.markForUpdate(); - return true; - } - else - { - this.hits++; - if( this.hits > 10 ) - { - this.world.destroyBlock( this.pos, false ); - } - } - } - } + return false; + } - return false; - } + public float getVisibleRotation() { + return this.visibleRotation; + } - - - public float getVisibleRotation() - { - return this.visibleRotation; - } - - private void setVisibleRotation( final float visibleRotation ) - { - this.visibleRotation = visibleRotation; - } + private void setVisibleRotation(final float visibleRotation) { + this.visibleRotation = visibleRotation; + } } diff --git a/src/main/java/appeng/tile/grindstone/TileGrinder.java b/src/main/java/appeng/tile/grindstone/TileGrinder.java index e361963cd..24131d7e2 100644 --- a/src/main/java/appeng/tile/grindstone/TileGrinder.java +++ b/src/main/java/appeng/tile/grindstone/TileGrinder.java @@ -18,6 +18,15 @@ package appeng.tile.grindstone; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.Direction; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.wrapper.RangedWrapper; import appeng.api.implementations.tiles.ICrankable; import appeng.recipes.handlers.GrinderOptionalResult; @@ -31,173 +40,140 @@ import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.InvOperation; import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.IAEItemFilter; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.wrapper.RangedWrapper; -import java.util.ArrayList; -import java.util.List; +public class TileGrinder extends AEBaseInvTile implements ICrankable { + private static final int SLOT_PROCESSING = 6; + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 7); + private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new GrinderFilter()); + private int points; -public class TileGrinder extends AEBaseInvTile implements ICrankable -{ - private static final int SLOT_PROCESSING = 6; + public TileGrinder(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 7 ); - private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new GrinderFilter() ); - private int points; + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + final BlockState state = this.world.getBlockState(this.pos); + state.getBlock().neighborChanged(state, this.world, this.pos, state.getBlock(), this.pos, false); + } - public TileGrinder(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - final BlockState state = this.world.getBlockState( this.pos ); - state.getBlock().neighborChanged( state, this.world, this.pos, state.getBlock(), this.pos, false ); - } + @Override + protected IItemHandler getItemHandlerForSide(Direction side) { + return this.invExt; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { - @Override - protected IItemHandler getItemHandlerForSide( Direction side ) - { - return this.invExt; - } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { + @Override + public boolean canTurn() { + if (isRemote()) { + return false; + } - } + if (this.inv.getStackInSlot(6).isEmpty()) // Add if there isn't one... + { + for (int x = 0; x < 3; x++) { + ItemStack item = this.inv.getStackInSlot(x); + if (item.isEmpty()) { + continue; + } - @Override - public boolean canTurn() - { - if( isRemote() ) - { - return false; - } + GrinderRecipe r = GrinderRecipes.findForInput(world, item); + if (r != null) { + final ItemStack ais = item.copy(); + ais.setCount(r.getIngredientCount()); + item.shrink(r.getIngredientCount()); - if( this.inv.getStackInSlot( 6 ).isEmpty() ) // Add if there isn't one... - { - for( int x = 0; x < 3; x++ ) - { - ItemStack item = this.inv.getStackInSlot( x ); - if( item.isEmpty() ) - { - continue; - } + if (item.getCount() <= 0) { + item = ItemStack.EMPTY; + } - GrinderRecipe r = GrinderRecipes.findForInput(world, item); - if( r != null ) - { - final ItemStack ais = item.copy(); - ais.setCount( r.getIngredientCount() ); - item.shrink( r.getIngredientCount() ); + this.inv.setStackInSlot(x, item); + this.inv.setStackInSlot(6, ais); + return true; + } + } + return false; + } + return true; + } - if( item.getCount() <= 0 ) - { - item = ItemStack.EMPTY; - } + @Override + public void applyTurn() { + if (isRemote()) { + return; + } - this.inv.setStackInSlot( x, item ); - this.inv.setStackInSlot( 6, ais ); - return true; - } - } - return false; - } - return true; - } + this.points++; - @Override - public void applyTurn() - { - if( isRemote() ) - { - return; - } + final ItemStack processing = this.inv.getStackInSlot(SLOT_PROCESSING); + GrinderRecipe r = GrinderRecipes.findForInput(world, processing); + if (r != null) { + if (r.getTurns() > this.points) { + return; + } - this.points++; + this.points = 0; + final InventoryAdaptor sia = new AdaptorItemHandler(new RangedWrapper(this.inv, 3, 6)); - final ItemStack processing = this.inv.getStackInSlot(SLOT_PROCESSING); - GrinderRecipe r = GrinderRecipes.findForInput(world, processing); - if( r != null ) - { - if( r.getTurns() > this.points ) - { - return; - } + this.addItem(sia, r.getRecipeOutput()); - this.points = 0; - final InventoryAdaptor sia = new AdaptorItemHandler( new RangedWrapper( this.inv, 3, 6 ) ); + for (GrinderOptionalResult optionalResult : r.getOptionalResults()) { + final float chance = (Platform.getRandomInt() % 2000) / 2000.0f; - this.addItem( sia, r.getRecipeOutput()); + if (chance <= optionalResult.getChance()) { + this.addItem(sia, optionalResult.getResult()); + } + } - for (GrinderOptionalResult optionalResult : r.getOptionalResults()) { - final float chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f; + this.inv.setStackInSlot(6, ItemStack.EMPTY); + } + } - if( chance <= optionalResult.getChance() ) - { - this.addItem( sia, optionalResult.getResult() ); - } - } + private void addItem(final InventoryAdaptor sia, final ItemStack output) { + if (output.isEmpty()) { + return; + } - this.inv.setStackInSlot( 6, ItemStack.EMPTY ); - } - } + final ItemStack notAdded = sia.addItems(output); + if (!notAdded.isEmpty()) { + final List out = new ArrayList<>(); + out.add(notAdded); - private void addItem( final InventoryAdaptor sia, final ItemStack output ) - { - if( output.isEmpty() ) - { - return; - } + Platform.spawnDrops(this.world, this.pos.offset(this.getForward()), out); + } + } - final ItemStack notAdded = sia.addItems( output ); - if( !notAdded.isEmpty() ) - { - final List out = new ArrayList<>(); - out.add( notAdded ); + @Override + public boolean canCrankAttach(final Direction directionToCrank) { + return this.getUp() == directionToCrank; + } - Platform.spawnDrops( this.world, this.pos.offset( this.getForward() ), out ); - } - } + private class GrinderFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slotIndex, int amount) { + return slotIndex >= 3 && slotIndex <= 5; + } - @Override - public boolean canCrankAttach( final Direction directionToCrank ) - { - return this.getUp() == directionToCrank; - } + @Override + public boolean allowInsert(IItemHandler inv, int slotIndex, ItemStack stack) { + if (!GrinderRecipes.isValidIngredient(world, stack)) { + return false; + } - private class GrinderFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slotIndex, int amount ) - { - return slotIndex >= 3 && slotIndex <= 5; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slotIndex, ItemStack stack ) - { - if( !GrinderRecipes.isValidIngredient(world, stack) ) - { - return false; - } - - return slotIndex >= 0 && slotIndex <= 2; - } - } + return slotIndex >= 0 && slotIndex <= 2; + } + } } diff --git a/src/main/java/appeng/tile/inventory/AppEngCellInventory.java b/src/main/java/appeng/tile/inventory/AppEngCellInventory.java index 1dff4422c..c0945b031 100644 --- a/src/main/java/appeng/tile/inventory/AppEngCellInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngCellInventory.java @@ -1,7 +1,6 @@ package appeng.tile.inventory; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; @@ -10,109 +9,89 @@ import appeng.api.storage.ICellInventoryHandler; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.filter.IAEItemFilter; +public class AppEngCellInventory implements IItemHandlerModifiable { + private final AppEngInternalInventory inv; + private final ICellInventoryHandler handlerForSlot[]; -public class AppEngCellInventory implements IItemHandlerModifiable -{ - private final AppEngInternalInventory inv; - private final ICellInventoryHandler handlerForSlot[]; + public AppEngCellInventory(final IAEAppEngInventory host, final int slots) { + this.inv = new AppEngInternalInventory(host, slots, 1); + this.handlerForSlot = new ICellInventoryHandler[slots]; + } - public AppEngCellInventory( final IAEAppEngInventory host, final int slots ) - { - this.inv = new AppEngInternalInventory( host, slots, 1 ); - this.handlerForSlot = new ICellInventoryHandler[slots]; - } + public void setHandler(final int slot, final ICellInventoryHandler handler) { + this.handlerForSlot[slot] = handler; + } - public void setHandler( final int slot, final ICellInventoryHandler handler ) - { - this.handlerForSlot[slot] = handler; - } + public void setFilter(IAEItemFilter filter) { + this.inv.setFilter(filter); + } - public void setFilter( IAEItemFilter filter ) - { - this.inv.setFilter( filter ); - } + @Override + public void setStackInSlot(int slot, ItemStack stack) { + this.persist(slot); + this.inv.setStackInSlot(slot, stack); + this.cleanup(slot); + } - @Override - public void setStackInSlot( int slot, ItemStack stack ) - { - this.persist( slot ); - this.inv.setStackInSlot( slot, stack ); - this.cleanup( slot ); - } + @Override + public int getSlots() { + return this.inv.getSlots(); + } - @Override - public int getSlots() - { - return this.inv.getSlots(); - } + @Override + public ItemStack getStackInSlot(int slot) { + this.persist(slot); + return this.inv.getStackInSlot(slot); + } - @Override - public ItemStack getStackInSlot( int slot ) - { - this.persist( slot ); - return this.inv.getStackInSlot( slot ); - } + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + this.persist(slot); + final ItemStack ret = this.inv.insertItem(slot, stack, simulate); + this.cleanup(slot); + return ret; + } - @Override - public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) - { - this.persist( slot ); - final ItemStack ret = this.inv.insertItem( slot, stack, simulate ); - this.cleanup( slot ); - return ret; - } + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + this.persist(slot); + final ItemStack ret = this.inv.extractItem(slot, amount, simulate); + this.cleanup(slot); + return ret; + } - @Override - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - this.persist( slot ); - final ItemStack ret = this.inv.extractItem( slot, amount, simulate ); - this.cleanup( slot ); - return ret; - } + @Override + public int getSlotLimit(int slot) { + return this.inv.getSlotLimit(slot); + } - @Override - public int getSlotLimit( int slot ) - { - return this.inv.getSlotLimit( slot ); - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + return this.inv.isItemValid(slot, stack); + } - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - return this.inv.isItemValid( slot, stack ); - } + public void persist() { + for (int i = 0; i < this.getSlots(); ++i) { + this.persist(i); + } + } - public void persist() - { - for( int i = 0; i < this.getSlots(); ++i ) - { - this.persist( i ); - } - } + private void persist(int slot) { + if (this.handlerForSlot[slot] != null) { + final ICellInventory ci = this.handlerForSlot[slot].getCellInv(); + if (ci != null) { + ci.persist(); + } + } + } - private void persist( int slot ) - { - if( this.handlerForSlot[slot] != null ) - { - final ICellInventory ci = this.handlerForSlot[slot].getCellInv(); - if( ci != null ) - { - ci.persist(); - } - } - } + private void cleanup(int slot) { + if (this.handlerForSlot[slot] != null) { + final ICellInventory ci = this.handlerForSlot[slot].getCellInv(); - private void cleanup( int slot ) - { - if( this.handlerForSlot[slot] != null ) - { - final ICellInventory ci = this.handlerForSlot[slot].getCellInv(); - - if( ci == null || ci.getItemStack() != this.inv.getStackInSlot( slot ) ) - { - this.handlerForSlot[slot] = null; - } - } - } + if (ci == null || ci.getItemStack() != this.inv.getStackInSlot(slot)) { + this.handlerForSlot[slot] = null; + } + } + } } diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java index 3481b9cd4..e2529307a 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java @@ -18,7 +18,6 @@ package appeng.tile.inventory; - import java.util.Iterator; import javax.annotation.Nonnull; @@ -39,250 +38,197 @@ import appeng.util.item.AEItemStack; import appeng.util.iterators.AEInvIterator; import appeng.util.iterators.InvIterator; +public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterable { + private final IAEAppEngInventory te; + private final IAEItemStack[] inv; + private final int size; + private int maxStack; + private boolean dirtyFlag = false; -public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterable -{ - private final IAEAppEngInventory te; - private final IAEItemStack[] inv; - private final int size; - private int maxStack; - private boolean dirtyFlag = false; + public AppEngInternalAEInventory(final IAEAppEngInventory te, final int s) { + this.te = te; + this.size = s; + this.maxStack = 64; + this.inv = new IAEItemStack[s]; + } - public AppEngInternalAEInventory( final IAEAppEngInventory te, final int s ) - { - this.te = te; - this.size = s; - this.maxStack = 64; - this.inv = new IAEItemStack[s]; - } + public void setMaxStackSize(final int s) { + this.maxStack = s; + } - public void setMaxStackSize( final int s ) - { - this.maxStack = s; - } + public IAEItemStack getAEStackInSlot(final int var1) { + return this.inv[var1]; + } - public IAEItemStack getAEStackInSlot( final int var1 ) - { - return this.inv[var1]; - } + public void writeToNBT(final CompoundNBT data, final String name) { + final CompoundNBT c = new CompoundNBT(); + this.writeToNBT(c); + data.put(name, c); + } - public void writeToNBT( final CompoundNBT data, final String name ) - { - final CompoundNBT c = new CompoundNBT(); - this.writeToNBT( c ); - data.put( name, c ); - } + private void writeToNBT(final CompoundNBT target) { + for (int x = 0; x < this.size; x++) { + try { + final CompoundNBT c = new CompoundNBT(); - private void writeToNBT( final CompoundNBT target ) - { - for( int x = 0; x < this.size; x++ ) - { - try - { - final CompoundNBT c = new CompoundNBT(); + if (this.inv[x] != null) { + this.inv[x].writeToNBT(c); + } - if( this.inv[x] != null ) - { - this.inv[x].writeToNBT(c); - } + target.put("#" + x, c); + } catch (final Exception ignored) { + } + } + } - target.put( "#" + x, c ); - } - catch( final Exception ignored ) - { - } - } - } + public void readFromNBT(final CompoundNBT data, final String name) { + final CompoundNBT c = data.getCompound(name); + if (c != null) { + this.readFromNBT(c); + } + } - public void readFromNBT( final CompoundNBT data, final String name ) - { - final CompoundNBT c = data.getCompound( name ); - if( c != null ) - { - this.readFromNBT( c ); - } - } + private void readFromNBT(final CompoundNBT target) { + for (int x = 0; x < this.size; x++) { + try { + final CompoundNBT c = target.getCompound("#" + x); - private void readFromNBT( final CompoundNBT target ) - { - for( int x = 0; x < this.size; x++ ) - { - try - { - final CompoundNBT c = target.getCompound( "#" + x ); + if (c != null) { + this.inv[x] = AEItemStack.fromNBT(c); + } + } catch (final Exception e) { + AELog.debug(e); + } + } + } - if( c != null ) - { - this.inv[x] = AEItemStack.fromNBT( c ); - } - } - catch( final Exception e ) - { - AELog.debug( e ); - } - } - } + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { + return Math.min(this.getSlotLimit(slot), stack.getMaxStackSize()); + } - protected int getStackLimit( int slot, @Nonnull ItemStack stack ) - { - return Math.min( this.getSlotLimit( slot ), stack.getMaxStackSize() ); - } + @Override + public int getSlots() { + return this.size; + } - @Override - public int getSlots() - { - return this.size; - } + @Override + public ItemStack getStackInSlot(final int var1) { + if (this.inv[var1] == null) { + return ItemStack.EMPTY; + } - @Override - public ItemStack getStackInSlot( final int var1 ) - { - if( this.inv[var1] == null ) - { - return ItemStack.EMPTY; - } + return this.inv[var1].createItemStack(); + } - return this.inv[var1].createItemStack(); - } + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + if (stack.isEmpty()) { + return ItemStack.EMPTY; + } - @Override - public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) - { - if( stack.isEmpty() ) - { - return ItemStack.EMPTY; - } + ItemStack existing = this.getStackInSlot(slot); + int limit = this.getStackLimit(slot, stack); - ItemStack existing = this.getStackInSlot( slot ); - int limit = this.getStackLimit( slot, stack ); + if (!existing.isEmpty()) { + if (!ItemHandlerHelper.canItemStacksStack(stack, existing)) { + return stack; + } - if( !existing.isEmpty() ) - { - if( !ItemHandlerHelper.canItemStacksStack( stack, existing ) ) - { - return stack; - } + limit -= existing.getCount(); + } - limit -= existing.getCount(); - } + if (limit <= 0) { + return stack; + } - if( limit <= 0 ) - { - return stack; - } + boolean reachedLimit = stack.getCount() > limit; - boolean reachedLimit = stack.getCount() > limit; + if (!simulate) { + if (existing.isEmpty()) { + this.inv[slot] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack); + } else { + existing.grow(reachedLimit ? limit : stack.getCount()); + } + this.fireOnChangeInventory(slot, InvOperation.INSERT, ItemStack.EMPTY, + reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack); + } + return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY; + } - if( !simulate ) - { - if( existing.isEmpty() ) - { - this.inv[slot] = AEApi.instance() - .storage() - .getStorageChannel( IItemStorageChannel.class ) - .createStack( - reachedLimit ? ItemHandlerHelper.copyStackWithSize( stack, limit ) : stack ); - } - else - { - existing.grow( reachedLimit ? limit : stack.getCount() ); - } - this.fireOnChangeInventory( slot, InvOperation.INSERT, ItemStack.EMPTY, - reachedLimit ? ItemHandlerHelper.copyStackWithSize( stack, limit ) : stack ); - } - return reachedLimit ? ItemHandlerHelper.copyStackWithSize( stack, stack.getCount() - limit ) : ItemStack.EMPTY; - } + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (this.inv[slot] != null) { + final ItemStack split = this.getStackInSlot(slot); - @Override - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - if( this.inv[slot] != null ) - { - final ItemStack split = this.getStackInSlot( slot ); + if (amount >= split.getCount()) { + if (!simulate) { + this.inv[slot] = null; + this.fireOnChangeInventory(slot, InvOperation.EXTRACT, split, ItemStack.EMPTY); + } + return split; + } else { + if (!simulate) { + split.grow(-amount); + this.fireOnChangeInventory(slot, InvOperation.EXTRACT, + ItemHandlerHelper.copyStackWithSize(split, amount), ItemStack.EMPTY); + } + return ItemHandlerHelper.copyStackWithSize(split, amount); + } + } + return ItemStack.EMPTY; + } - if( amount >= split.getCount() ) - { - if( !simulate ) - { - this.inv[slot] = null; - this.fireOnChangeInventory( slot, InvOperation.EXTRACT, split, ItemStack.EMPTY ); - } - return split; - } - else - { - if( !simulate ) - { - split.grow( -amount ); - this.fireOnChangeInventory( slot, InvOperation.EXTRACT, ItemHandlerHelper.copyStackWithSize( split, amount ), ItemStack.EMPTY ); - } - return ItemHandlerHelper.copyStackWithSize( split, amount ); - } - } - return ItemStack.EMPTY; - } + @Override + public void setStackInSlot(final int slot, final ItemStack newItemStack) { + ItemStack oldStack = this.getStackInSlot(slot).copy(); + this.inv[slot] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) + .createStack(newItemStack); - @Override - public void setStackInSlot( final int slot, final ItemStack newItemStack ) - { - ItemStack oldStack = this.getStackInSlot( slot ).copy(); - this.inv[slot] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItemStack ); + if (this.te != null && Platform.isServer()) { + ItemStack newStack = newItemStack.copy(); + InvOperation op = InvOperation.SET; - if( this.te != null && Platform.isServer() ) - { - ItemStack newStack = newItemStack.copy(); - InvOperation op = InvOperation.SET; + if (ItemStack.areItemsEqual(oldStack, newStack)) { + if (newStack.getCount() > oldStack.getCount()) { + newStack.shrink(oldStack.getCount()); + oldStack = ItemStack.EMPTY; + op = InvOperation.INSERT; + } else { + oldStack.shrink(newStack.getCount()); + newStack = ItemStack.EMPTY; + op = InvOperation.EXTRACT; + } + } + this.fireOnChangeInventory(slot, op, oldStack, newStack); + } + } - if( ItemStack.areItemsEqual( oldStack, newStack ) ) - { - if( newStack.getCount() > oldStack.getCount() ) - { - newStack.shrink( oldStack.getCount() ); - oldStack = ItemStack.EMPTY; - op = InvOperation.INSERT; - } - else - { - oldStack.shrink( newStack.getCount() ); - newStack = ItemStack.EMPTY; - op = InvOperation.EXTRACT; - } - } - this.fireOnChangeInventory( slot, op, oldStack, newStack ); - } - } + private void fireOnChangeInventory(int slot, InvOperation op, ItemStack removed, ItemStack inserted) { + if (this.te != null && Platform.isServer() && !this.dirtyFlag) { + this.dirtyFlag = true; + this.te.onChangeInventory(this, slot, op, removed, inserted); + this.te.saveChanges(); + this.dirtyFlag = false; + } + } - private void fireOnChangeInventory( int slot, InvOperation op, ItemStack removed, ItemStack inserted ) - { - if( this.te != null && Platform.isServer() && !this.dirtyFlag ) - { - this.dirtyFlag = true; - this.te.onChangeInventory( this, slot, op, removed, inserted ); - this.te.saveChanges(); - this.dirtyFlag = false; - } - } + @Override + public int getSlotLimit(int slot) { + return this.maxStack > 64 ? 64 : this.maxStack; + } - @Override - public int getSlotLimit( int slot ) - { - return this.maxStack > 64 ? 64 : this.maxStack; - } + @Override + public Iterator iterator() { + return new InvIterator(this); + } - @Override - public Iterator iterator() - { - return new InvIterator( this ); - } + public Iterator getNewAEIterator() { + return new AEInvIterator(this); + } - public Iterator getNewAEIterator() - { - return new AEInvIterator( this ); - } - - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - return true; - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + return true; + } } diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java index fa43be6a0..abcb70f25 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java @@ -18,7 +18,6 @@ package appeng.tile.inventory; - import java.util.Arrays; import java.util.Collections; import java.util.Iterator; @@ -34,185 +33,152 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.inv.filter.IAEItemFilter; +public class AppEngInternalInventory extends ItemStackHandler implements Iterable { + private boolean enableClientEvents = false; + private IAEAppEngInventory te; + private final int[] maxStack; + private ItemStack previousStack = ItemStack.EMPTY; + private IAEItemFilter filter; + private boolean dirtyFlag = false; -public class AppEngInternalInventory extends ItemStackHandler implements Iterable -{ - private boolean enableClientEvents = false; - private IAEAppEngInventory te; - private final int[] maxStack; - private ItemStack previousStack = ItemStack.EMPTY; - private IAEItemFilter filter; - private boolean dirtyFlag = false; + public AppEngInternalInventory(final IAEAppEngInventory inventory, final int size, final int maxStack, + IAEItemFilter filter) { + super(size); + this.setTileEntity(inventory); + this.setFilter(filter); + this.maxStack = new int[size]; + Arrays.fill(this.maxStack, maxStack); + } - public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size, final int maxStack, IAEItemFilter filter ) - { - super( size ); - this.setTileEntity( inventory ); - this.setFilter( filter ); - this.maxStack = new int[size]; - Arrays.fill( this.maxStack, maxStack ); - } + public AppEngInternalInventory(final IAEAppEngInventory inventory, final int size, final int maxStack) { + this(inventory, size, maxStack, null); + } - public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size, final int maxStack ) - { - this( inventory, size, maxStack, null ); - } + public AppEngInternalInventory(final IAEAppEngInventory inventory, final int size) { + this(inventory, size, 64); + } - public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size ) - { - this( inventory, size, 64 ); - } + public void setFilter(IAEItemFilter filter) { + this.filter = filter; + } - public void setFilter( IAEItemFilter filter ) - { - this.filter = filter; - } + @Override + public int getSlotLimit(int slot) { + return this.maxStack[slot]; + } - @Override - public int getSlotLimit( int slot ) - { - return this.maxStack[slot]; - } + @Override + public void setStackInSlot(int slot, @Nonnull ItemStack stack) { + this.previousStack = this.getStackInSlot(slot).copy(); + super.setStackInSlot(slot, stack); + } - @Override - public void setStackInSlot( int slot, @Nonnull ItemStack stack ) - { - this.previousStack = this.getStackInSlot( slot ).copy(); - super.setStackInSlot( slot, stack ); - } + @Override + @Nonnull + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if (this.filter != null && !this.filter.allowInsert(this, slot, stack)) { + return stack; + } - @Override - @Nonnull - public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate ) - { - if( this.filter != null && !this.filter.allowInsert( this, slot, stack ) ) - { - return stack; - } + if (!simulate) { + this.previousStack = this.getStackInSlot(slot).copy(); + } + return super.insertItem(slot, stack, simulate); + } - if( !simulate ) - { - this.previousStack = this.getStackInSlot( slot ).copy(); - } - return super.insertItem( slot, stack, simulate ); - } + @Override + @Nonnull + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (this.filter != null && !this.filter.allowExtract(this, slot, amount)) { + return ItemStack.EMPTY; + } - @Override - @Nonnull - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - if( this.filter != null && !this.filter.allowExtract( this, slot, amount ) ) - { - return ItemStack.EMPTY; - } + if (!simulate) { + this.previousStack = this.getStackInSlot(slot).copy(); + } + return super.extractItem(slot, amount, simulate); + } - if( !simulate ) - { - this.previousStack = this.getStackInSlot( slot ).copy(); - } - return super.extractItem( slot, amount, simulate ); - } + @Override + protected void onContentsChanged(int slot) { + if (this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag) { + this.dirtyFlag = true; + ItemStack newStack = this.getStackInSlot(slot).copy(); + ItemStack oldStack = this.previousStack; + InvOperation op = InvOperation.SET; - @Override - protected void onContentsChanged( int slot ) - { - if( this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag ) - { - this.dirtyFlag = true; - ItemStack newStack = this.getStackInSlot( slot ).copy(); - ItemStack oldStack = this.previousStack; - InvOperation op = InvOperation.SET; + if (newStack.isEmpty() || oldStack.isEmpty() || ItemStack.areItemsEqual(newStack, oldStack)) { + if (newStack.getCount() > oldStack.getCount()) { + newStack.shrink(oldStack.getCount()); + oldStack = ItemStack.EMPTY; + op = InvOperation.INSERT; + } else { + oldStack.shrink(newStack.getCount()); + newStack = ItemStack.EMPTY; + op = InvOperation.EXTRACT; + } + } - if( newStack.isEmpty() || oldStack.isEmpty() || ItemStack.areItemsEqual( newStack, oldStack ) ) - { - if( newStack.getCount() > oldStack.getCount() ) - { - newStack.shrink( oldStack.getCount() ); - oldStack = ItemStack.EMPTY; - op = InvOperation.INSERT; - } - else - { - oldStack.shrink( newStack.getCount() ); - newStack = ItemStack.EMPTY; - op = InvOperation.EXTRACT; - } - } + this.getTileEntity().onChangeInventory(this, slot, op, oldStack, newStack); + this.getTileEntity().saveChanges(); + this.previousStack = ItemStack.EMPTY; + this.dirtyFlag = false; + } + super.onContentsChanged(slot); + } - this.getTileEntity().onChangeInventory( this, slot, op, oldStack, newStack ); - this.getTileEntity().saveChanges(); - this.previousStack = ItemStack.EMPTY; - this.dirtyFlag = false; - } - super.onContentsChanged( slot ); - } + protected boolean eventsEnabled() { + return Platform.isServer() || this.isEnableClientEvents(); + } - protected boolean eventsEnabled() - { - return Platform.isServer() || this.isEnableClientEvents(); - } + public void setMaxStackSize(final int slot, final int size) { + this.maxStack[slot] = size; + } - public void setMaxStackSize( final int slot, final int size ) - { - this.maxStack[slot] = size; - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + if (this.maxStack[slot] == 0) { + return false; + } + if (this.filter != null) { + return this.filter.allowInsert(this, slot, stack); + } + return true; + } - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - if( this.maxStack[slot] == 0 ) - { - return false; - } - if( this.filter != null ) - { - return this.filter.allowInsert( this, slot, stack ); - } - return true; - } + public void writeToNBT(final CompoundNBT data, final String name) { + data.put(name, this.serializeNBT()); + } - public void writeToNBT( final CompoundNBT data, final String name ) - { - data.put( name, this.serializeNBT() ); - } + public void readFromNBT(final CompoundNBT data, final String name) { + final CompoundNBT c = data.getCompound(name); + if (c != null) { + this.readFromNBT(c); + } + } - public void readFromNBT( final CompoundNBT data, final String name ) - { - final CompoundNBT c = data.getCompound( name ); - if( c != null ) - { - this.readFromNBT( c ); - } - } + public void readFromNBT(final CompoundNBT data) { + this.deserializeNBT(data); + } - public void readFromNBT( final CompoundNBT data ) - { - this.deserializeNBT( data ); - } + @Override + public Iterator iterator() { + return Collections.unmodifiableList(super.stacks).iterator(); + } - @Override - public Iterator iterator() - { - return Collections.unmodifiableList( super.stacks ).iterator(); - } + private boolean isEnableClientEvents() { + return this.enableClientEvents; + } - private boolean isEnableClientEvents() - { - return this.enableClientEvents; - } + public void setEnableClientEvents(final boolean enableClientEvents) { + this.enableClientEvents = enableClientEvents; + } - public void setEnableClientEvents( final boolean enableClientEvents ) - { - this.enableClientEvents = enableClientEvents; - } + private IAEAppEngInventory getTileEntity() { + return this.te; + } - private IAEAppEngInventory getTileEntity() - { - return this.te; - } - - public void setTileEntity( final IAEAppEngInventory te ) - { - this.te = te; - } + public void setTileEntity(final IAEAppEngInventory te) { + this.te = te; + } } diff --git a/src/main/java/appeng/tile/misc/CondenserItemInventory.java b/src/main/java/appeng/tile/misc/CondenserItemInventory.java index d9b121a3b..64f1d74bd 100644 --- a/src/main/java/appeng/tile/misc/CondenserItemInventory.java +++ b/src/main/java/appeng/tile/misc/CondenserItemInventory.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; @@ -41,165 +40,136 @@ import appeng.me.storage.ITickingMonitor; import appeng.util.item.AEItemStack; import appeng.util.item.ItemList; +class CondenserItemInventory implements IMEMonitor, ITickingMonitor { + private final HashMap, Object> listeners = new HashMap<>(); + private final TileCondenser target; + private boolean hasChanged = true; + private final ItemList cachedList = new ItemList(); + private IActionSource actionSource = new BaseActionSource(); + private ItemList changeSet = new ItemList(); -class CondenserItemInventory implements IMEMonitor, ITickingMonitor -{ - private final HashMap, Object> listeners = new HashMap<>(); - private final TileCondenser target; - private boolean hasChanged = true; - private final ItemList cachedList = new ItemList(); - private IActionSource actionSource = new BaseActionSource(); - private ItemList changeSet = new ItemList(); + CondenserItemInventory(final TileCondenser te) { + this.target = te; + } - CondenserItemInventory( final TileCondenser te ) - { - this.target = te; - } + @Override + public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final IActionSource src) { + if (mode == Actionable.MODULATE && input != null) { + this.target.addPower(input.getStackSize()); + } + return null; + } - @Override - public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.MODULATE && input != null ) - { - this.target.addPower( input.getStackSize() ); - } - return null; - } + @Override + public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) { + AEItemStack ret = null; + ItemStack slotItem = this.target.getOutputSlot().getStackInSlot(0); + if (!slotItem.isEmpty() && request.isSameType(slotItem)) { + int count = (int) Math.min(request.getStackSize(), Integer.MAX_VALUE); + ret = AEItemStack + .fromItemStack(this.target.getOutputSlot().extractItem(0, count, mode == Actionable.SIMULATE)); + } + return ret; + } - @Override - public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) - { - AEItemStack ret = null; - ItemStack slotItem = this.target.getOutputSlot().getStackInSlot( 0 ); - if( !slotItem.isEmpty() && request.isSameType( slotItem ) ) - { - int count = (int) Math.min( request.getStackSize(), Integer.MAX_VALUE ); - ret = AEItemStack.fromItemStack( this.target.getOutputSlot().extractItem( 0, count, mode == Actionable.SIMULATE ) ); - } - return ret; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + if (!this.target.getOutputSlot().getStackInSlot(0).isEmpty()) { + out.add(AEItemStack.fromItemStack(this.target.getOutputSlot().getStackInSlot(0))); + } + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - if( !this.target.getOutputSlot().getStackInSlot( 0 ).isEmpty() ) - { - out.add( AEItemStack.fromItemStack( this.target.getOutputSlot().getStackInSlot( 0 ) ) ); - } - return out; - } + @Override + public IItemList getStorageList() { + if (this.hasChanged) { + this.hasChanged = false; + this.cachedList.resetStatus(); + return this.getAvailableItems(this.cachedList); + } + return this.cachedList; + } - @Override - public IItemList getStorageList() - { - if( this.hasChanged ) - { - this.hasChanged = false; - this.cachedList.resetStatus(); - return this.getAvailableItems( this.cachedList ); - } - return this.cachedList; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.READ_WRITE; - } + @Override + public boolean isPrioritized(final IAEItemStack input) { + return false; + } - @Override - public boolean isPrioritized( final IAEItemStack input ) - { - return false; - } + @Override + public boolean canAccept(final IAEItemStack input) { + return true; + } - @Override - public boolean canAccept( final IAEItemStack input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return i == 2; + } - @Override - public boolean validForPass( final int i ) - { - return i == 2; - } + @Override + public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) { + this.listeners.put(l, verificationToken); + } - @Override - public void addListener( final IMEMonitorHandlerReceiver l, final Object verificationToken ) - { - this.listeners.put( l, verificationToken ); - } + @Override + public void removeListener(final IMEMonitorHandlerReceiver l) { + this.listeners.remove(l); + } - @Override - public void removeListener( final IMEMonitorHandlerReceiver l ) - { - this.listeners.remove( l ); - } + public void updateOutput(ItemStack added, ItemStack removed) { + this.hasChanged = true; + if (!added.isEmpty()) { + this.changeSet.add(AEItemStack.fromItemStack(added)); + } + if (!removed.isEmpty()) { + this.changeSet.add(AEItemStack.fromItemStack(removed).setStackSize(-removed.getCount())); + } + } - public void updateOutput( ItemStack added, ItemStack removed ) - { - this.hasChanged = true; - if( !added.isEmpty() ) - { - this.changeSet.add( AEItemStack.fromItemStack( added ) ); - } - if( !removed.isEmpty() ) - { - this.changeSet.add( AEItemStack.fromItemStack( removed ).setStackSize( -removed.getCount() ) ); - } - } + @Override + public TickRateModulation onTick() { + final ItemList currentChanges = this.changeSet; - @Override - public TickRateModulation onTick() - { - final ItemList currentChanges = this.changeSet; + if (currentChanges.isEmpty()) { + return TickRateModulation.IDLE; + } - if( currentChanges.isEmpty() ) - { - return TickRateModulation.IDLE; - } + this.changeSet = new ItemList(); + final Iterator, Object>> i = this.listeners.entrySet().iterator(); + while (i.hasNext()) { + final Entry, Object> l = i.next(); + final IMEMonitorHandlerReceiver key = l.getKey(); + if (key.isValid(l.getValue())) { + key.postChange(this, currentChanges, this.actionSource); + } else { + i.remove(); + } + } - this.changeSet = new ItemList(); - final Iterator, Object>> i = this.listeners.entrySet().iterator(); - while( i.hasNext() ) - { - final Entry, Object> l = i.next(); - final IMEMonitorHandlerReceiver key = l.getKey(); - if( key.isValid( l.getValue() ) ) - { - key.postChange( this, currentChanges, this.actionSource ); - } - else - { - i.remove(); - } - } + return TickRateModulation.URGENT; + } - return TickRateModulation.URGENT; - } - - @Override - public void setActionSource( IActionSource actionSource ) - { - this.actionSource = actionSource; - } + @Override + public void setActionSource(IActionSource actionSource) { + this.actionSource = actionSource; + } } diff --git a/src/main/java/appeng/tile/misc/CondenserVoidInventory.java b/src/main/java/appeng/tile/misc/CondenserVoidInventory.java index 2f833c309..b7a937e4c 100644 --- a/src/main/java/appeng/tile/misc/CondenserVoidInventory.java +++ b/src/main/java/appeng/tile/misc/CondenserVoidInventory.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; import appeng.api.networking.security.IActionSource; @@ -28,103 +27,86 @@ import appeng.api.storage.IStorageChannel; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +class CondenserVoidInventory> implements IMEMonitor { -class CondenserVoidInventory> implements IMEMonitor -{ + private final TileCondenser target; + private final IStorageChannel channel; - private final TileCondenser target; - private final IStorageChannel channel; + CondenserVoidInventory(final TileCondenser te, final IStorageChannel channel) { + this.target = te; + this.channel = channel; + } - CondenserVoidInventory( final TileCondenser te, final IStorageChannel channel ) - { - this.target = te; - this.channel = channel; - } + @Override + public T injectItems(final T input, final Actionable mode, final IActionSource src) { + if (mode == Actionable.SIMULATE) { + return null; + } - @Override - public T injectItems( final T input, final Actionable mode, final IActionSource src ) - { - if( mode == Actionable.SIMULATE ) - { - return null; - } + if (input != null) { + this.target.addPower(input.getStackSize() / (double) this.channel.transferFactor()); + } + return null; + } - if( input != null ) - { - this.target.addPower( input.getStackSize() / (double) this.channel.transferFactor() ); - } - return null; - } + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + return null; + } - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - return null; - } + @Override + public IItemList getAvailableItems(final IItemList out) { + return out; + } - @Override - public IItemList getAvailableItems( final IItemList out ) - { - return out; - } + @Override + public IItemList getStorageList() { + return this.channel.createList(); + } - @Override - public IItemList getStorageList() - { - return this.channel.createList(); - } + @Override + public IStorageChannel getChannel() { + return this.channel; + } - @Override - public IStorageChannel getChannel() - { - return this.channel; - } + @Override + public AccessRestriction getAccess() { + return AccessRestriction.WRITE; + } - @Override - public AccessRestriction getAccess() - { - return AccessRestriction.WRITE; - } + @Override + public boolean isPrioritized(final T input) { + return false; + } - @Override - public boolean isPrioritized( final T input ) - { - return false; - } + @Override + public boolean canAccept(final T input) { + return true; + } - @Override - public boolean canAccept( final T input ) - { - return true; - } + @Override + public int getPriority() { + return 0; + } - @Override - public int getPriority() - { - return 0; - } + @Override + public int getSlot() { + return 0; + } - @Override - public int getSlot() - { - return 0; - } + @Override + public boolean validForPass(final int i) { + return i == 2; + } - @Override - public boolean validForPass( final int i ) - { - return i == 2; - } + @Override + public void addListener(IMEMonitorHandlerReceiver l, Object verificationToken) { + // Not implemented since the Condenser automatically voids everything, and there + // are no updates + } - @Override - public void addListener( IMEMonitorHandlerReceiver l, Object verificationToken ) - { - // Not implemented since the Condenser automatically voids everything, and there are no updates - } - - @Override - public void removeListener( IMEMonitorHandlerReceiver l ) - { - // Not implemented since we don't remember registered listeners anyway - } + @Override + public void removeListener(IMEMonitorHandlerReceiver l) { + // Not implemented since we don't remember registered listeners anyway + } } diff --git a/src/main/java/appeng/tile/misc/InscriberRecipes.java b/src/main/java/appeng/tile/misc/InscriberRecipes.java index f37fa62f3..93f166021 100644 --- a/src/main/java/appeng/tile/misc/InscriberRecipes.java +++ b/src/main/java/appeng/tile/misc/InscriberRecipes.java @@ -1,11 +1,11 @@ package appeng.tile.misc; -import appeng.api.AEApi; -import appeng.api.definitions.IComparableDefinition; -import appeng.api.features.InscriberProcessType; -import appeng.core.AppEng; -import appeng.recipes.handlers.InscriberRecipe; +import java.util.Collection; + +import javax.annotation.Nullable; + import com.google.common.collect.Iterables; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -14,12 +14,16 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import javax.annotation.Nullable; -import java.util.Collection; +import appeng.api.AEApi; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.features.InscriberProcessType; +import appeng.core.AppEng; +import appeng.recipes.handlers.InscriberRecipe; /** - * This class indexes all inscriber recipes to find valid inputs for the top and bottom - * optional slots. This speeds up checks whether inputs for those two slots are valid. + * This class indexes all inscriber recipes to find valid inputs for the top and + * bottom optional slots. This speeds up checks whether inputs for those two + * slots are valid. */ public final class InscriberRecipes { @@ -32,12 +36,14 @@ public final class InscriberRecipes { * Returns an unmodifiable view of all registered inscriber recipes. */ public static Iterable getRecipes(World world) { - Collection> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE).values(); + Collection> unfilteredRecipes = world.getRecipeManager().getRecipes(InscriberRecipe.TYPE) + .values(); return Iterables.filter(unfilteredRecipes, InscriberRecipe.class); } @Nullable - public static InscriberRecipe findRecipe(World world, ItemStack input, ItemStack plateA, ItemStack plateB, boolean supportNamePress) { + public static InscriberRecipe findRecipe(World world, ItemStack input, ItemStack plateA, ItemStack plateB, + boolean supportNamePress) { if (supportNamePress) { IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress(); boolean isNameA = namePress.isSameAs(plateA); @@ -50,14 +56,12 @@ public final class InscriberRecipes { } } - for( final InscriberRecipe recipe : getRecipes(world) ) - { + for (final InscriberRecipe recipe : getRecipes(world)) { // The recipe can be flipped at will final boolean matchA = recipe.getTopOptional().test(plateA) && recipe.getBottomOptional().test(plateB); final boolean matchB = recipe.getTopOptional().test(plateB) && recipe.getBottomOptional().test(plateA); - if( matchA || matchB ) - { + if (matchA || matchB) { if (recipe.getMiddleInput().test(input)) { return recipe; } @@ -67,57 +71,45 @@ public final class InscriberRecipes { return null; } - private static InscriberRecipe makeNamePressRecipe( ItemStack input, ItemStack plateA, ItemStack plateB ) - { + private static InscriberRecipe makeNamePressRecipe(ItemStack input, ItemStack plateA, ItemStack plateB) { String name = ""; - if( !plateA.isEmpty() ) - { + if (!plateA.isEmpty()) { final CompoundNBT tag = plateA.getOrCreateTag(); - name += tag.getString( "InscribeName" ); + name += tag.getString("InscribeName"); } - if( !plateB.isEmpty() ) - { + if (!plateB.isEmpty()) { final CompoundNBT tag = plateB.getOrCreateTag(); - name += " " + tag.getString( "InscribeName" ); + name += " " + tag.getString("InscribeName"); } final Ingredient startingItem = Ingredient.fromStacks(input.copy()); final ItemStack renamedItem = input.copy(); - final CompoundNBT display = renamedItem.getOrCreateChildTag( "display" ); - if( !name.isEmpty() ) - { + final CompoundNBT display = renamedItem.getOrCreateChildTag("display"); + if (!name.isEmpty()) { display.putString("Name", name); - } - else - { - display.remove( "Name" ); + } else { + display.remove("Name"); } final InscriberProcessType type = InscriberProcessType.INSCRIBE; - return new InscriberRecipe( - NAMEPLATE_RECIPE_ID, - "", - startingItem, - renamedItem, + return new InscriberRecipe(NAMEPLATE_RECIPE_ID, "", startingItem, renamedItem, plateA.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateA), - plateB.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateB), - type - ); + plateB.isEmpty() ? Ingredient.EMPTY : Ingredient.fromStacks(plateB), type); } /** - * Checks if there is an inscriber recipe that supports the given combination of top/bottom presses. - * Both the given combination and the reverse will be searched. + * Checks if there is an inscriber recipe that supports the given combination of + * top/bottom presses. Both the given combination and the reverse will be + * searched. */ public static boolean isValidOptionalIngredientCombination(World world, ItemStack pressA, ItemStack pressB) { for (InscriberRecipe recipe : getRecipes(world)) { if (recipe.getTopOptional().test(pressA) && recipe.getBottomOptional().test(pressB) - || recipe.getTopOptional().test(pressB) && recipe.getBottomOptional().test(pressA)) - { + || recipe.getTopOptional().test(pressB) && recipe.getBottomOptional().test(pressA)) { return true; } } @@ -126,14 +118,13 @@ public final class InscriberRecipes { } /** - * Checks if there is an inscriber recipe that would use the given item stack as an optional ingredient. - * Bottom and top can be used interchangeably here, because the inscriber will flip the recipe if needed. + * Checks if there is an inscriber recipe that would use the given item stack as + * an optional ingredient. Bottom and top can be used interchangeably here, + * because the inscriber will flip the recipe if needed. */ public static boolean isValidOptionalIngredient(World world, ItemStack is) { for (InscriberRecipe recipe : getRecipes(world)) { - if (recipe.getTopOptional().test(is) - || recipe.getBottomOptional().test(is)) - { + if (recipe.getTopOptional().test(is) || recipe.getBottomOptional().test(is)) { return true; } } diff --git a/src/main/java/appeng/tile/misc/TileCellWorkbench.java b/src/main/java/appeng/tile/misc/TileCellWorkbench.java index 6144c8b06..faeabeb15 100644 --- a/src/main/java/appeng/tile/misc/TileCellWorkbench.java +++ b/src/main/java/appeng/tile/misc/TileCellWorkbench.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.util.List; import net.minecraft.item.ItemStack; @@ -43,215 +42,176 @@ import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost { -public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost -{ + private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1); + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 63); + private final ConfigManager manager = new ConfigManager(this); - private final AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 ); - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 ); - private final ConfigManager manager = new ConfigManager( this ); + private IItemHandler cacheUpgrades = null; + private IItemHandler cacheConfig = null; + private boolean locked = false; - private IItemHandler cacheUpgrades = null; - private IItemHandler cacheConfig = null; - private boolean locked = false; + public TileCellWorkbench(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.manager.registerSetting(Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE); + this.cell.setEnableClientEvents(true); + } - public TileCellWorkbench(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.manager.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE ); - this.cell.setEnableClientEvents( true ); - } + public IItemHandler getCellUpgradeInventory() { + if (this.cacheUpgrades == null) { + final ICellWorkbenchItem cell = this.getCell(); + if (cell == null) { + return null; + } - public IItemHandler getCellUpgradeInventory() - { - if( this.cacheUpgrades == null ) - { - final ICellWorkbenchItem cell = this.getCell(); - if( cell == null ) - { - return null; - } + final ItemStack is = this.cell.getStackInSlot(0); + if (is.isEmpty()) { + return null; + } - final ItemStack is = this.cell.getStackInSlot( 0 ); - if( is.isEmpty() ) - { - return null; - } + final IItemHandler inv = cell.getUpgradesInventory(is); + if (inv == null) { + return null; + } - final IItemHandler inv = cell.getUpgradesInventory( is ); - if( inv == null ) - { - return null; - } + return this.cacheUpgrades = inv; + } + return this.cacheUpgrades; + } - return this.cacheUpgrades = inv; - } - return this.cacheUpgrades; - } + public ICellWorkbenchItem getCell() { + if (this.cell.getStackInSlot(0).isEmpty()) { + return null; + } - public ICellWorkbenchItem getCell() - { - if( this.cell.getStackInSlot( 0 ).isEmpty() ) - { - return null; - } + if (this.cell.getStackInSlot(0).getItem() instanceof ICellWorkbenchItem) { + return ((ICellWorkbenchItem) this.cell.getStackInSlot(0).getItem()); + } - if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem ) - { - return( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() ); - } + return null; + } - return null; - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.cell.writeToNBT(data, "cell"); + this.config.writeToNBT(data, "config"); + this.manager.writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.cell.writeToNBT( data, "cell" ); - this.config.writeToNBT( data, "config" ); - this.manager.writeToNBT( data ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.cell.readFromNBT(data, "cell"); + this.config.readFromNBT(data, "config"); + this.manager.readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.cell.readFromNBT( data, "cell" ); - this.config.readFromNBT( data, "config" ); - this.manager.readFromNBT( data ); - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("config")) { + return this.config; + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "config" ) ) - { - return this.config; - } + if (name.equals("cell")) { + return this.cell; + } - if( name.equals( "cell" ) ) - { - return this.cell; - } + return null; + } - return null; - } + @Override + public int getInstalledUpgrades(final Upgrades u) { + return 0; + } - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return 0; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { + if (inv == this.cell && !this.locked) { + this.locked = true; - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { - if( inv == this.cell && !this.locked ) - { - this.locked = true; + this.cacheUpgrades = null; + this.cacheConfig = null; - this.cacheUpgrades = null; - this.cacheConfig = null; + final IItemHandler configInventory = this.getCellConfigInventory(); + if (configInventory != null) { + boolean cellHasConfig = false; + for (int x = 0; x < configInventory.getSlots(); x++) { + if (!configInventory.getStackInSlot(x).isEmpty()) { + cellHasConfig = true; + break; + } + } - final IItemHandler configInventory = this.getCellConfigInventory(); - if( configInventory != null ) - { - boolean cellHasConfig = false; - for( int x = 0; x < configInventory.getSlots(); x++ ) - { - if( !configInventory.getStackInSlot( x ).isEmpty() ) - { - cellHasConfig = true; - break; - } - } + if (cellHasConfig) { + for (int x = 0; x < this.config.getSlots(); x++) { + this.config.setStackInSlot(x, configInventory.getStackInSlot(x)); + } + } else { + ItemHandlerUtil.copy(this.config, configInventory, false); + } + } else if (this.manager.getSetting(Settings.COPY_MODE) == CopyMode.CLEAR_ON_REMOVE) { + for (int x = 0; x < this.config.getSlots(); x++) { + this.config.setStackInSlot(x, ItemStack.EMPTY); + } - if( cellHasConfig ) - { - for( int x = 0; x < this.config.getSlots(); x++ ) - { - this.config.setStackInSlot( x, configInventory.getStackInSlot( x ) ); - } - } - else - { - ItemHandlerUtil.copy( this.config, configInventory, false ); - } - } - else if( this.manager.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE ) - { - for( int x = 0; x < this.config.getSlots(); x++ ) - { - this.config.setStackInSlot( x, ItemStack.EMPTY ); - } + this.saveChanges(); + } - this.saveChanges(); - } + this.locked = false; + } else if (inv == this.config && !this.locked) { + this.locked = true; + final IItemHandler c = this.getCellConfigInventory(); + if (c != null) { + ItemHandlerUtil.copy(this.config, c, false); + // copy items back. The ConfigInventory may changed the items on insert + ItemHandlerUtil.copy(c, this.config, false); + } + this.locked = false; + } + } - this.locked = false; - } - else if( inv == this.config && !this.locked ) - { - this.locked = true; - final IItemHandler c = this.getCellConfigInventory(); - if( c != null ) - { - ItemHandlerUtil.copy( this.config, c, false ); - // copy items back. The ConfigInventory may changed the items on insert - ItemHandlerUtil.copy( c, this.config, false ); - } - this.locked = false; - } - } + private IItemHandler getCellConfigInventory() { + if (this.cacheConfig == null) { + final ICellWorkbenchItem cell = this.getCell(); + if (cell == null) { + return null; + } - private IItemHandler getCellConfigInventory() - { - if( this.cacheConfig == null ) - { - final ICellWorkbenchItem cell = this.getCell(); - if( cell == null ) - { - return null; - } + final ItemStack is = this.cell.getStackInSlot(0); + if (is.isEmpty()) { + return null; + } - final ItemStack is = this.cell.getStackInSlot( 0 ); - if( is.isEmpty() ) - { - return null; - } + final IItemHandler inv = cell.getConfigInventory(is); + if (inv == null) { + return null; + } - final IItemHandler inv = cell.getConfigInventory( is ); - if( inv == null ) - { - return null; - } + this.cacheConfig = inv; + } + return this.cacheConfig; + } - this.cacheConfig = inv; - } - return this.cacheConfig; - } + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + super.getDrops(w, pos, drops); - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - super.getDrops( w, pos, drops ); + if (this.cell.getStackInSlot(0) != null) { + drops.add(this.cell.getStackInSlot(0)); + } + } - if( this.cell.getStackInSlot( 0 ) != null ) - { - drops.add( this.cell.getStackInSlot( 0 ) ); - } - } + @Override + public IConfigManager getConfigManager() { + return this.manager; + } - @Override - public IConfigManager getConfigManager() - { - return this.manager; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - // nothing here.. - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + // nothing here.. + } } diff --git a/src/main/java/appeng/tile/misc/TileCharger.java b/src/main/java/appeng/tile/misc/TileCharger.java index 508dd7e66..18ce89585 100644 --- a/src/main/java/appeng/tile/misc/TileCharger.java +++ b/src/main/java/appeng/tile/misc/TileCharger.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.ArrayList; import java.util.EnumSet; @@ -56,262 +55,222 @@ import appeng.util.inv.InvOperation; import appeng.util.inv.filter.IAEItemFilter; import appeng.util.item.AEItemStack; +public class TileCharger extends AENetworkPowerTile implements ICrankable, IGridTickable { + private static final int POWER_MAXIMUM_AMOUNT = 1600; + private static final int POWER_THRESHOLD = POWER_MAXIMUM_AMOUNT - 1; + private static final int POWER_PER_CRANK_TURN = 160; -public class TileCharger extends AENetworkPowerTile implements ICrankable, IGridTickable -{ - private static final int POWER_MAXIMUM_AMOUNT = 1600; - private static final int POWER_THRESHOLD = POWER_MAXIMUM_AMOUNT - 1; - private static final int POWER_PER_CRANK_TURN = 160; + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1, 1, new ChargerInvFilter()); - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1, 1, new ChargerInvFilter() ); + public TileCharger(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + this.getProxy().setFlags(); + this.setInternalMaxPower(POWER_MAXIMUM_AMOUNT); + this.getProxy().setIdlePowerUsage(0); + } - public TileCharger(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - this.getProxy().setFlags(); - this.setInternalMaxPower( POWER_MAXIMUM_AMOUNT ); - this.getProxy().setIdlePowerUsage( 0 ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + try { + final IAEItemStack item = AEItemStack.fromPacket(data); + final ItemStack is = item.createItemStack(); + this.inv.setStackInSlot(0, is); + } catch (final Throwable t) { + this.inv.setStackInSlot(0, ItemStack.EMPTY); + } + return c; // TESR doesn't need updates! + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - try - { - final IAEItemStack item = AEItemStack.fromPacket( data ); - final ItemStack is = item.createItemStack(); - this.inv.setStackInSlot( 0, is ); - } - catch( final Throwable t ) - { - this.inv.setStackInSlot( 0, ItemStack.EMPTY ); - } - return c; // TESR doesn't need updates! - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + final AEItemStack is = AEItemStack.fromItemStack(this.inv.getStackInSlot(0)); + if (is != null) { + is.writeToPacket(data); + } + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - final AEItemStack is = AEItemStack.fromItemStack( this.inv.getStackInSlot( 0 ) ); - if( is != null ) - { - is.writeToPacket( data ); - } - } + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + this.getProxy().setValidSides(EnumSet.of(this.getUp(), this.getUp().getOpposite())); + this.setPowerSides(EnumSet.of(this.getUp(), this.getUp().getOpposite())); + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) ); - this.setPowerSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) ); - } + @Override + public boolean canTurn() { + return this.getInternalCurrentPower() < this.getInternalMaxPower(); + } - @Override - public boolean canTurn() - { - return this.getInternalCurrentPower() < this.getInternalMaxPower(); - } + @Override + public void applyTurn() { + this.injectExternalPower(PowerUnits.AE, POWER_PER_CRANK_TURN, Actionable.MODULATE); - @Override - public void applyTurn() - { - this.injectExternalPower( PowerUnits.AE, POWER_PER_CRANK_TURN, Actionable.MODULATE ); + final ItemStack myItem = this.inv.getStackInSlot(0); + if (this.getInternalCurrentPower() > POWER_THRESHOLD) { + final IMaterials materials = AEApi.instance().definitions().materials(); - final ItemStack myItem = this.inv.getStackInSlot( 0 ); - if( this.getInternalCurrentPower() > POWER_THRESHOLD ) - { - final IMaterials materials = AEApi.instance().definitions().materials(); + if (materials.certusQuartzCrystal().isSameAs(myItem)) { + this.extractAEPower(this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG); - if( materials.certusQuartzCrystal().isSameAs( myItem ) ) - { - this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG ); + materials.certusQuartzCrystalCharged().maybeStack(myItem.getCount()) + .ifPresent(charged -> this.inv.setStackInSlot(0, charged)); + } + } + } - materials.certusQuartzCrystalCharged().maybeStack( myItem.getCount() ).ifPresent( charged -> this.inv.setStackInSlot( 0, charged ) ); - } - } - } + @Override + public boolean canCrankAttach(final Direction directionToCrank) { + return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank; + } - @Override - public boolean canCrankAttach( final Direction directionToCrank ) - { - return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank; - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + try { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - try - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } + this.markForUpdate(); + } - this.markForUpdate(); - } + public void activate(final PlayerEntity player) { + if (!Platform.hasPermissions(new DimensionalCoord(this), player)) { + return; + } - public void activate( final PlayerEntity player ) - { - if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) ) - { - return; - } + final ItemStack myItem = this.inv.getStackInSlot(0); + if (myItem.isEmpty()) { + ItemStack held = player.inventory.getCurrentItem(); - final ItemStack myItem = this.inv.getStackInSlot( 0 ); - if( myItem.isEmpty() ) - { - ItemStack held = player.inventory.getCurrentItem(); + if (AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs(held) + || Platform.isChargeable(held)) { + held = player.inventory.decrStackSize(player.inventory.currentItem, 1); + this.inv.setStackInSlot(0, held); + } + } else { + final List drops = new ArrayList<>(); + drops.add(myItem); + this.inv.setStackInSlot(0, ItemStack.EMPTY); + Platform.spawnDrops(this.world, this.pos.offset(this.getForward()), drops); + } + } - if( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) ) - { - held = player.inventory.decrStackSize( player.inventory.currentItem, 1 ); - this.inv.setStackInSlot( 0, held ); - } - } - else - { - final List drops = new ArrayList<>(); - drops.add( myItem ); - this.inv.setStackInSlot( 0, ItemStack.EMPTY ); - Platform.spawnDrops( this.world, this.pos.offset( this.getForward() ), drops ); - } - } + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(TickRates.Charger.getMin(), TickRates.Charger.getMin(), false, true); + } - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( TickRates.Charger.getMin(), TickRates.Charger.getMin(), false, true ); - } + @Override + public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) { + return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLEEP; + } - @Override - public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) - { - return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLEEP; - } + private boolean doWork() { + final ItemStack myItem = this.inv.getStackInSlot(0); + boolean changed = false; - private boolean doWork() - { - final ItemStack myItem = this.inv.getStackInSlot( 0 ); - boolean changed = false; + if (!myItem.isEmpty()) { + final IMaterials materials = AEApi.instance().definitions().materials(); - if( !myItem.isEmpty() ) - { - final IMaterials materials = AEApi.instance().definitions().materials(); + if (Platform.isChargeable(myItem)) { + final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem(); - if( Platform.isChargeable( myItem ) ) - { - final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem(); + if (ps.getAEMaxPower(myItem) > ps.getAECurrentPower(myItem)) { + final double chargeRate = AEApi.instance().registries().charger().getChargeRate(myItem.getItem()); - if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) ) - { - final double chargeRate = AEApi.instance().registries().charger().getChargeRate( myItem.getItem() ); + double extractedAmount = this.extractAEPower(chargeRate, Actionable.MODULATE, + PowerMultiplier.CONFIG); - double extractedAmount = this.extractAEPower( chargeRate, Actionable.MODULATE, PowerMultiplier.CONFIG ); + final double missingChargeRate = chargeRate - extractedAmount; + final double missingAEPower = ps.getAEMaxPower(myItem) - ps.getAECurrentPower(myItem); + final double toExtract = Math.min(missingChargeRate, missingAEPower); - final double missingChargeRate = chargeRate - extractedAmount; - final double missingAEPower = ps.getAEMaxPower( myItem ) - ps.getAECurrentPower( myItem ); - final double toExtract = Math.min( missingChargeRate, missingAEPower ); + try { + extractedAmount += this.getProxy().getEnergy().extractAEPower(toExtract, Actionable.MODULATE, + PowerMultiplier.ONE); + } catch (GridAccessException e1) { + // Ignore. + } - try - { - extractedAmount += this.getProxy().getEnergy().extractAEPower( toExtract, Actionable.MODULATE, PowerMultiplier.ONE ); - } - catch( GridAccessException e1 ) - { - // Ignore. - } + if (extractedAmount > 0) { + final double adjustment = ps.injectAEPower(myItem, extractedAmount, Actionable.MODULATE); - if( extractedAmount > 0 ) - { - final double adjustment = ps.injectAEPower( myItem, extractedAmount, Actionable.MODULATE ); + this.setInternalCurrentPower(this.getInternalCurrentPower() + adjustment); - this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment ); + changed = true; + } + } + } else if (this.getInternalCurrentPower() > POWER_THRESHOLD + && materials.certusQuartzCrystal().isSameAs(myItem)) { + if (Platform.getRandomFloat() > 0.8f) // simulate wait + { + this.extractAEPower(this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG); - changed = true; - } - } - } - else if( this.getInternalCurrentPower() > POWER_THRESHOLD && materials.certusQuartzCrystal().isSameAs( myItem ) ) - { - if( Platform.getRandomFloat() > 0.8f ) // simulate wait - { - this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG ); + materials.certusQuartzCrystalCharged().maybeStack(myItem.getCount()) + .ifPresent(charged -> this.inv.setStackInSlot(0, charged)); - materials.certusQuartzCrystalCharged().maybeStack( myItem.getCount() ).ifPresent( charged -> this.inv.setStackInSlot( 0, charged ) ); + changed = true; + } + } + } - changed = true; - } - } - } + // charge from the network! + if (this.getInternalCurrentPower() < POWER_THRESHOLD) { + try { + final double toExtract = Math.min(800.0, this.getInternalMaxPower() - this.getInternalCurrentPower()); + final double extracted = this.getProxy().getEnergy().extractAEPower(toExtract, Actionable.MODULATE, + PowerMultiplier.ONE); - // charge from the network! - if( this.getInternalCurrentPower() < POWER_THRESHOLD ) - { - try - { - final double toExtract = Math.min( 800.0, this.getInternalMaxPower() - this.getInternalCurrentPower() ); - final double extracted = this.getProxy().getEnergy().extractAEPower( toExtract, Actionable.MODULATE, PowerMultiplier.ONE ); + this.injectExternalPower(PowerUnits.AE, extracted, Actionable.MODULATE); + } catch (final GridAccessException e) { + // continue! + } - this.injectExternalPower( PowerUnits.AE, extracted, Actionable.MODULATE ); - } - catch( final GridAccessException e ) - { - // continue! - } + changed = true; + } - changed = true; - } + if (changed) { + this.markForUpdate(); + } - if( changed ) - { - this.markForUpdate(); - } + return true; + } - return true; - } + private class ChargerInvFilter implements IAEItemFilter { + @Override + public boolean allowInsert(IItemHandler inv, final int i, final ItemStack itemstack) { + final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal(); - private class ChargerInvFilter implements IAEItemFilter - { - @Override - public boolean allowInsert( IItemHandler inv, final int i, final ItemStack itemstack ) - { - final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal(); + return Platform.isChargeable(itemstack) || cert.isSameAs(itemstack); + } - return Platform.isChargeable( itemstack ) || cert.isSameAs( itemstack ); - } + @Override + public boolean allowExtract(IItemHandler inv, final int slotIndex, int amount) { + ItemStack extractedItem = inv.getStackInSlot(slotIndex); - @Override - public boolean allowExtract( IItemHandler inv, final int slotIndex, int amount ) - { - ItemStack extractedItem = inv.getStackInSlot( slotIndex ); + if (Platform.isChargeable(extractedItem)) { + final IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem(); + if (ips.getAECurrentPower(extractedItem) >= ips.getAEMaxPower(extractedItem)) { + return true; + } + } - if( Platform.isChargeable( extractedItem ) ) - { - final IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem(); - if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) ) - { - return true; - } - } - - return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem ); - } - } + return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs(extractedItem); + } + } } diff --git a/src/main/java/appeng/tile/misc/TileCondenser.java b/src/main/java/appeng/tile/misc/TileCondenser.java index 349a3d356..040676345 100644 --- a/src/main/java/appeng/tile/misc/TileCondenser.java +++ b/src/main/java/appeng/tile/misc/TileCondenser.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -62,340 +61,295 @@ import appeng.util.inv.WrapperChainedItemHandler; import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.AEItemFilters; +public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, IConfigurableObject { -public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, IConfigurableObject -{ + public static final int BYTE_MULTIPLIER = 8; - public static final int BYTE_MULTIPLIER = 8; + private final ConfigManager cm = new ConfigManager(this); - private final ConfigManager cm = new ConfigManager( this ); + private final AppEngInternalInventory outputSlot = new AppEngInternalInventory(this, 1); + private final AppEngInternalInventory storageSlot = new AppEngInternalInventory(this, 1); + private final IItemHandler inputSlot = new CondenseItemHandler(); + private final IFluidHandler fluidHandler = new FluidHandler(); + private final MEHandler meHandler = new MEHandler(); - private final AppEngInternalInventory outputSlot = new AppEngInternalInventory( this, 1 ); - private final AppEngInternalInventory storageSlot = new AppEngInternalInventory( this, 1 ); - private final IItemHandler inputSlot = new CondenseItemHandler(); - private final IFluidHandler fluidHandler = new FluidHandler(); - private final MEHandler meHandler = new MEHandler(); + private final IItemHandler externalInv = new WrapperChainedItemHandler(this.inputSlot, + new WrapperFilteredItemHandler(this.outputSlot, AEItemFilters.EXTRACT_ONLY)); + private final IItemHandler combinedInv = new WrapperChainedItemHandler(this.inputSlot, this.outputSlot, + this.storageSlot); - private final IItemHandler externalInv = new WrapperChainedItemHandler( this.inputSlot, new WrapperFilteredItemHandler( this.outputSlot, AEItemFilters.EXTRACT_ONLY ) ); - private final IItemHandler combinedInv = new WrapperChainedItemHandler( this.inputSlot, this.outputSlot, this.storageSlot ); + private double storedPower = 0; - private double storedPower = 0; + public TileCondenser(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.cm.registerSetting(Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH); + } - public TileCondenser(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.cm.writeToNBT(data); + data.putDouble("storedPower", this.getStoredPower()); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.cm.writeToNBT( data ); - data.putDouble("storedPower", this.getStoredPower()); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.cm.readFromNBT(data); + this.setStoredPower(data.getDouble("storedPower")); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.cm.readFromNBT( data ); - this.setStoredPower( data.getDouble( "storedPower" ) ); - } + public double getStorage() { + final ItemStack is = this.storageSlot.getStackInSlot(0); + if (!is.isEmpty()) { + if (is.getItem() instanceof IStorageComponent) { + final IStorageComponent sc = (IStorageComponent) is.getItem(); + if (sc.isStorageComponent(is)) { + return sc.getBytes(is) * BYTE_MULTIPLIER; + } + } + } + return 0; + } - public double getStorage() - { - final ItemStack is = this.storageSlot.getStackInSlot( 0 ); - if( !is.isEmpty() ) - { - if( is.getItem() instanceof IStorageComponent ) - { - final IStorageComponent sc = (IStorageComponent) is.getItem(); - if( sc.isStorageComponent( is ) ) - { - return sc.getBytes( is ) * BYTE_MULTIPLIER; - } - } - } - return 0; - } + public void addPower(final double rawPower) { + this.setStoredPower(this.getStoredPower() + rawPower); + this.setStoredPower(Math.max(0.0, Math.min(this.getStorage(), this.getStoredPower()))); - public void addPower( final double rawPower ) - { - this.setStoredPower( this.getStoredPower() + rawPower ); - this.setStoredPower( Math.max( 0.0, Math.min( this.getStorage(), this.getStoredPower() ) ) ); + final double requiredPower = this.getRequiredPower(); + final ItemStack output = this.getOutput(); + while (requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0) { + if (this.canAddOutput(output)) { + this.setStoredPower(this.getStoredPower() - requiredPower); + this.addOutput(output); + } else { + break; + } + } + } - final double requiredPower = this.getRequiredPower(); - final ItemStack output = this.getOutput(); - while( requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0 ) - { - if( this.canAddOutput( output ) ) - { - this.setStoredPower( this.getStoredPower() - requiredPower ); - this.addOutput( output ); - } - else - { - break; - } - } - } + private boolean canAddOutput(final ItemStack output) { + return this.outputSlot.insertItem(0, output, true).isEmpty(); + } - private boolean canAddOutput( final ItemStack output ) - { - return this.outputSlot.insertItem( 0, output, true ).isEmpty(); - } + /** + * make sure you validate with canAddOutput prior to this. + * + * @param output to be added output + */ + private void addOutput(final ItemStack output) { + this.outputSlot.insertItem(0, output, false); + } - /** - * make sure you validate with canAddOutput prior to this. - * - * @param output to be added output - */ - private void addOutput( final ItemStack output ) - { - this.outputSlot.insertItem( 0, output, false ); - } + IItemHandler getOutputSlot() { + return this.outputSlot; + } - IItemHandler getOutputSlot() - { - return this.outputSlot; - } + private ItemStack getOutput() { + final IMaterials materials = AEApi.instance().definitions().materials(); - private ItemStack getOutput() - { - final IMaterials materials = AEApi.instance().definitions().materials(); + switch ((CondenserOutput) this.cm.getSetting(Settings.CONDENSER_OUTPUT)) { + case MATTER_BALLS: + return materials.matterBall().maybeStack(1).orElse(ItemStack.EMPTY); - switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ) - { - case MATTER_BALLS: - return materials.matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + case SINGULARITY: + return materials.singularity().maybeStack(1).orElse(ItemStack.EMPTY); - case SINGULARITY: - return materials.singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + case TRASH: + default: + return ItemStack.EMPTY; + } + } - case TRASH: - default: - return ItemStack.EMPTY; - } - } + public double getRequiredPower() { + return ((CondenserOutput) this.cm.getSetting(Settings.CONDENSER_OUTPUT)).requiredPower; + } - public double getRequiredPower() - { - return ( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ).requiredPower; - } + @Override + public IItemHandler getInternalInventory() { + return this.combinedInv; + } - @Override - public IItemHandler getInternalInventory() - { - return this.combinedInv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (inv == this.outputSlot) { + this.meHandler.outputChanged(added, removed); + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( inv == this.outputSlot ) - { - this.meHandler.outputChanged( added, removed ); - } - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.addPower(0); + } - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.addPower( 0 ); - } + @Override + public IConfigManager getConfigManager() { + return this.cm; + } - @Override - public IConfigManager getConfigManager() - { - return this.cm; - } + public double getStoredPower() { + return this.storedPower; + } - public double getStoredPower() - { - return this.storedPower; - } + private void setStoredPower(final double storedPower) { + this.storedPower = storedPower; + } - private void setStoredPower( final double storedPower ) - { - this.storedPower = storedPower; - } + @SuppressWarnings("unchecked") + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this.externalInv); + } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { + return (LazyOptional) LazyOptional.of(() -> this.fluidHandler); + } else if (capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR) { + return (LazyOptional) LazyOptional.of(() -> this.meHandler); + } + return super.getCapability(capability, facing); + } - @SuppressWarnings( "unchecked" ) - @Override - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() -> this.externalInv); - } - else if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ) - { - return (LazyOptional) LazyOptional.of(() -> this.fluidHandler); - } - else if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR ) - { - return (LazyOptional) LazyOptional.of(() -> this.meHandler); - } - return super.getCapability( capability, facing ); - } + private class CondenseItemHandler implements IItemHandler { - private class CondenseItemHandler implements IItemHandler - { + @Override + public int getSlots() { + // We only expose the void slot + return 1; + } - @Override - public int getSlots() - { - // We only expose the void slot - return 1; - } + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return slot == 0; + } - @Override - public boolean isItemValid(int slot, @Nonnull ItemStack stack) { - return slot == 0; - } + @Override + public ItemStack getStackInSlot(int slot) { + // The void slot never has any content + return ItemStack.EMPTY; + } - @Override - public ItemStack getStackInSlot( int slot ) - { - // The void slot never has any content - return ItemStack.EMPTY; - } + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + if (slot != 0) { + return stack; + } + if (!simulate && !stack.isEmpty()) { + TileCondenser.this.addPower(stack.getCount()); + } + return ItemStack.EMPTY; + } - @Override - public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) - { - if( slot != 0 ) - { - return stack; - } - if( !simulate && !stack.isEmpty() ) - { - TileCondenser.this.addPower( stack.getCount() ); - } - return ItemStack.EMPTY; - } + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + return ItemStack.EMPTY; + } - @Override - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - return ItemStack.EMPTY; - } + @Override + public int getSlotLimit(int slot) { + return 64; + } + } - @Override - public int getSlotLimit( int slot ) - { - return 64; - } - } + /** + * A fluid handler that exposes a 1 bucket tank that can only be filled, and - + * when filled - will add power to this condenser. + */ + private class FluidHandler implements IFluidTank, IFluidHandler { - /** - * A fluid handler that exposes a 1 bucket tank that can only be filled, and - when filled - will add power - * to this condenser. - */ - private class FluidHandler implements IFluidTank, IFluidHandler - { + @Nonnull + @Override + public FluidStack getFluid() { + return FluidStack.EMPTY; + } - @Nonnull - @Override - public FluidStack getFluid() { - return FluidStack.EMPTY; - } + @Override + public int getFluidAmount() { + return 0; + } - @Override - public int getFluidAmount() { - return 0; - } + @Override + public int getCapacity() { + return FluidAttributes.BUCKET_VOLUME; + } - @Override - public int getCapacity() { - return FluidAttributes.BUCKET_VOLUME; - } + @Override + public boolean isFluidValid(FluidStack stack) { + return stack != FluidStack.EMPTY; + } - @Override - public boolean isFluidValid(FluidStack stack) { - return stack != FluidStack.EMPTY; - } + @Override + public int fill(FluidStack resource, FluidAction action) { + if (action == FluidAction.EXECUTE) { + final IStorageChannel chan = AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class); + TileCondenser.this + .addPower((resource == null ? 0.0 : (double) resource.getAmount()) / chan.transferFactor()); + } - @Override - public int fill(FluidStack resource, FluidAction action) { - if( action == FluidAction.EXECUTE ) - { - final IStorageChannel chan = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ); - TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.getAmount() ) / chan.transferFactor() ); - } + return resource == null ? 0 : resource.getAmount(); + } - return resource == null ? 0 : resource.getAmount(); - } + @Nonnull + @Override + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; + } - @Nonnull - @Override - public FluidStack drain(int maxDrain, FluidAction action) { - return FluidStack.EMPTY; - } + @Nonnull + @Override + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } - @Nonnull - @Override - public FluidStack drain(FluidStack resource, FluidAction action) { - return FluidStack.EMPTY; - } + @Override + public int getTanks() { + return 1; + } - @Override - public int getTanks() { - return 1; - } + @Nonnull + @Override + public FluidStack getFluidInTank(int tank) { + return FluidStack.EMPTY; + } - @Nonnull - @Override - public FluidStack getFluidInTank(int tank) { - return FluidStack.EMPTY; - } + @Override + public int getTankCapacity(int tank) { + return tank == 0 ? getCapacity() : 0; + } - @Override - public int getTankCapacity(int tank) { - return tank == 0 ? getCapacity() : 0; - } + @Override + public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { + return tank == 0 && isFluidValid(stack); + } + } - @Override - public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { - return tank == 0 && isFluidValid(stack); - } - } + /** + * This is used to expose a fake ME subnetwork that is only composed of this + * condenser tile. The purpose of this is to enable the condenser to override + * the {@link appeng.api.storage.IMEInventoryHandler#validForPass(int)} method + * to make sure a condenser is only ever used if an item can't go anywhere else. + */ + private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable { + private final CondenserItemInventory itemInventory = new CondenserItemInventory(TileCondenser.this); - /** - * This is used to expose a fake ME subnetwork that is only composed of this condenser tile. The purpose of this is - * to enable the condenser to - * override the {@link appeng.api.storage.IMEInventoryHandler#validForPass(int)} method to make sure a condenser is - * only ever used if an item - * can't go anywhere else. - */ - private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable - { - private final CondenserItemInventory itemInventory = new CondenserItemInventory( TileCondenser.this ); + void outputChanged(ItemStack added, ItemStack removed) { + this.itemInventory.updateOutput(added, removed); + } - void outputChanged( ItemStack added, ItemStack removed ) - { - this.itemInventory.updateOutput( added, removed ); - } + @Nullable + @Override + public IStorageMonitorable getInventory(IActionSource src) { + return this; + } - @Nullable - @Override - public IStorageMonitorable getInventory( IActionSource src ) - { - return this; - } - - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - return (IMEMonitor) this.itemInventory; - } - else - { - return new CondenserVoidInventory<>( TileCondenser.this, channel ); - } - } - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + return (IMEMonitor) this.itemInventory; + } else { + return new CondenserVoidInventory<>(TileCondenser.this, channel); + } + } + } } diff --git a/src/main/java/appeng/tile/misc/TileInscriber.java b/src/main/java/appeng/tile/misc/TileInscriber.java index f83c7f245..f4a113514 100644 --- a/src/main/java/appeng/tile/misc/TileInscriber.java +++ b/src/main/java/appeng/tile/misc/TileInscriber.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.EnumSet; import java.util.List; @@ -26,9 +25,6 @@ import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import appeng.api.config.Settings; -import appeng.recipes.handlers.InscriberRecipe; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; @@ -42,6 +38,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; +import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.api.definitions.ITileDefinition; import appeng.api.features.InscriberProcessType; @@ -59,6 +56,7 @@ import appeng.core.settings.TickRates; import appeng.me.GridAccessException; import appeng.parts.automation.DefinitionUpgradeInventory; import appeng.parts.automation.UpgradeInventory; +import appeng.recipes.handlers.InscriberRecipe; import appeng.tile.grid.AENetworkPowerTile; import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.ConfigManager; @@ -69,447 +67,370 @@ import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.IAEItemFilter; import appeng.util.item.AEItemStack; - /** * @author AlgorithmX2 * @author thatsIch * @version rv2 * @since rv0 */ -public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost -{ - private final int maxProcessingTime = 100; +public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost { + private final int maxProcessingTime = 100; - private final IConfigManager settings; - private final UpgradeInventory upgrades; - private int processingTime = 0; - // cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the normal routine. - private boolean smash; - private int finalStep; - private long clientStart; - private final AppEngInternalInventory topItemHandler = new AppEngInternalInventory( this, 1, 1 ); - private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory( this, 1, 1 ); - private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory( this, 2, 1 ); + private final IConfigManager settings; + private final UpgradeInventory upgrades; + private int processingTime = 0; + // cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the + // normal routine. + private boolean smash; + private int finalStep; + private long clientStart; + private final AppEngInternalInventory topItemHandler = new AppEngInternalInventory(this, 1, 1); + private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory(this, 1, 1); + private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory(this, 2, 1); - private final IItemHandler topItemHandlerExtern; - private final IItemHandler bottomItemHandlerExtern; - private final IItemHandler sideItemHandlerExtern; + private final IItemHandler topItemHandlerExtern; + private final IItemHandler bottomItemHandlerExtern; + private final IItemHandler sideItemHandlerExtern; - private InscriberRecipe cachedTask = null; + private InscriberRecipe cachedTask = null; - private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler ); + private final IItemHandlerModifiable inv = new WrapperChainedItemHandler(this.topItemHandler, + this.bottomItemHandler, this.sideItemHandler); - public TileInscriber(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); + public TileInscriber(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - this.setInternalMaxPower( 1600 ); - this.getProxy().setIdlePowerUsage( 0 ); - this.settings = new ConfigManager( this ); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + this.setInternalMaxPower(1600); + this.getProxy().setIdlePowerUsage(0); + this.settings = new ConfigManager(this); - final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber(); - this.upgrades = new DefinitionUpgradeInventory( inscriberDefinition, this, this.getUpgradeSlots() ); + final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber(); + this.upgrades = new DefinitionUpgradeInventory(inscriberDefinition, this, this.getUpgradeSlots()); - this.sideItemHandler.setMaxStackSize( 1, 64 ); + this.sideItemHandler.setMaxStackSize(1, 64); - final IAEItemFilter filter = new ItemHandlerFilter(); - this.topItemHandlerExtern = new WrapperFilteredItemHandler( this.topItemHandler, filter ); - this.bottomItemHandlerExtern = new WrapperFilteredItemHandler( this.bottomItemHandler, filter ); - this.sideItemHandlerExtern = new WrapperFilteredItemHandler( this.sideItemHandler, filter ); - } + final IAEItemFilter filter = new ItemHandlerFilter(); + this.topItemHandlerExtern = new WrapperFilteredItemHandler(this.topItemHandler, filter); + this.bottomItemHandlerExtern = new WrapperFilteredItemHandler(this.bottomItemHandler, filter); + this.sideItemHandlerExtern = new WrapperFilteredItemHandler(this.sideItemHandler, filter); + } - private int getUpgradeSlots() - { - return 3; - } + private int getUpgradeSlots() { + return 3; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.upgrades.writeToNBT( data, "upgrades" ); - this.settings.writeToNBT( data ); - return data; - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.upgrades.writeToNBT(data, "upgrades"); + this.settings.writeToNBT(data); + return data; + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.upgrades.readFromNBT( data, "upgrades" ); - this.settings.readFromNBT( data ); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.upgrades.readFromNBT(data, "upgrades"); + this.settings.readFromNBT(data); + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final int slot = data.readByte(); + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final int slot = data.readByte(); - final boolean oldSmash = this.isSmash(); - final boolean newSmash = ( slot & 64 ) == 64; + final boolean oldSmash = this.isSmash(); + final boolean newSmash = (slot & 64) == 64; - if( oldSmash != newSmash && newSmash ) - { - this.setSmash( true ); - this.setClientStart( System.currentTimeMillis() ); - } + if (oldSmash != newSmash && newSmash) { + this.setSmash(true); + this.setClientStart(System.currentTimeMillis()); + } - for( int num = 0; num < this.inv.getSlots(); num++ ) - { - if( ( slot & ( 1 << num ) ) > 0 ) - { - this.inv.setStackInSlot( num, AEItemStack.fromPacket( data ).createItemStack() ); - } - else - { - this.inv.setStackInSlot( num, ItemStack.EMPTY ); - } - } - this.cachedTask = null; + for (int num = 0; num < this.inv.getSlots(); num++) { + if ((slot & (1 << num)) > 0) { + this.inv.setStackInSlot(num, AEItemStack.fromPacket(data).createItemStack()); + } else { + this.inv.setStackInSlot(num, ItemStack.EMPTY); + } + } + this.cachedTask = null; - return c; - } + return c; + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - int slot = this.isSmash() ? 64 : 0; + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + int slot = this.isSmash() ? 64 : 0; - for( int num = 0; num < this.inv.getSlots(); num++ ) - { - if( !this.inv.getStackInSlot( num ).isEmpty() ) - { - slot |= ( 1 << num ); - } - } + for (int num = 0; num < this.inv.getSlots(); num++) { + if (!this.inv.getStackInSlot(num).isEmpty()) { + slot |= (1 << num); + } + } - data.writeByte( slot ); - for( int num = 0; num < this.inv.getSlots(); num++ ) - { - if( ( slot & ( 1 << num ) ) > 0 ) - { - final AEItemStack st = AEItemStack.fromItemStack( this.inv.getStackInSlot( num ) ); - st.writeToPacket( data ); - } - } - } + data.writeByte(slot); + for (int num = 0; num < this.inv.getSlots(); num++) { + if ((slot & (1 << num)) > 0) { + final AEItemStack st = AEItemStack.fromItemStack(this.inv.getStackInSlot(num)); + st.writeToPacket(data); + } + } + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); - this.setPowerSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); - } + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + this.getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(this.getForward()))); + this.setPowerSides(EnumSet.complementOf(EnumSet.of(this.getForward()))); + } - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - super.getDrops( w, pos, drops ); + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + super.getDrops(w, pos, drops); - for( int h = 0; h < this.upgrades.getSlots(); h++ ) - { - final ItemStack is = this.upgrades.getStackInSlot( h ); - if( !is.isEmpty() ) - { - drops.add( is ); - } - } - } + for (int h = 0; h < this.upgrades.getSlots(); h++) { + final ItemStack is = this.upgrades.getStackInSlot(h); + if (!is.isEmpty()) { + drops.add(is); + } + } + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - try - { - if( slot == 0 ) - { - this.setProcessingTime( 0 ); - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + try { + if (slot == 0) { + this.setProcessingTime(0); + } - if( !this.isSmash() ) - { - this.markForUpdate(); - } + if (!this.isSmash()) { + this.markForUpdate(); + } - this.cachedTask = null; - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + this.cachedTask = null; + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // :P + } + } - // - // @Override - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.Inscriber.getMin(), TickRates.Inscriber.getMax(), !this.hasWork(), false ); - } + // + // @Override + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.Inscriber.getMin(), TickRates.Inscriber.getMax(), !this.hasWork(), false); + } - private boolean hasWork() - { - if( this.getTask() != null ) - { - return true; - } + private boolean hasWork() { + if (this.getTask() != null) { + return true; + } - this.setProcessingTime( 0 ); - return this.isSmash(); - } + this.setProcessingTime(0); + return this.isSmash(); + } - @Nullable - public InscriberRecipe getTask() - { - if ( this.cachedTask == null && world != null ) - { - ItemStack input = this.sideItemHandler.getStackInSlot(0); - ItemStack plateA = this.topItemHandler.getStackInSlot(0); - ItemStack plateB = this.bottomItemHandler.getStackInSlot(0); - // If the player somehow managed to insert more than one item, we bail here - if( input.getCount() > 1 || plateA.getCount() > 1 || plateB.getCount() > 1 ) - { - return null; - } + @Nullable + public InscriberRecipe getTask() { + if (this.cachedTask == null && world != null) { + ItemStack input = this.sideItemHandler.getStackInSlot(0); + ItemStack plateA = this.topItemHandler.getStackInSlot(0); + ItemStack plateB = this.bottomItemHandler.getStackInSlot(0); + // If the player somehow managed to insert more than one item, we bail here + if (input.getCount() > 1 || plateA.getCount() > 1 || plateB.getCount() > 1) { + return null; + } - this.cachedTask = InscriberRecipes.findRecipe( world, input, plateA, plateB, true); - } - return this.cachedTask; - } + this.cachedTask = InscriberRecipes.findRecipe(world, input, plateA, plateB, true); + } + return this.cachedTask; + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( this.isSmash() ) - { - this.finalStep++; - if( this.finalStep == 8 ) - { - final InscriberRecipe out = this.getTask(); - if( out != null ) - { - final ItemStack outputCopy = out.getOutput().copy(); + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (this.isSmash()) { + this.finalStep++; + if (this.finalStep == 8) { + final InscriberRecipe out = this.getTask(); + if (out != null) { + final ItemStack outputCopy = out.getOutput().copy(); - if( this.sideItemHandler.insertItem( 1, outputCopy, false ).isEmpty() ) - { - this.setProcessingTime( 0 ); - if( out.getProcessType() == InscriberProcessType.PRESS ) - { - this.topItemHandler.setStackInSlot( 0, ItemStack.EMPTY ); - this.bottomItemHandler.setStackInSlot( 0, ItemStack.EMPTY ); - } - this.sideItemHandler.setStackInSlot( 0, ItemStack.EMPTY ); - } - } - this.saveChanges(); - } - else if( this.finalStep == 16 ) - { - this.finalStep = 0; - this.setSmash( false ); - this.markForUpdate(); - } - } - else - { - try - { - final IEnergyGrid eg = this.getProxy().getEnergy(); - IEnergySource src = this; + if (this.sideItemHandler.insertItem(1, outputCopy, false).isEmpty()) { + this.setProcessingTime(0); + if (out.getProcessType() == InscriberProcessType.PRESS) { + this.topItemHandler.setStackInSlot(0, ItemStack.EMPTY); + this.bottomItemHandler.setStackInSlot(0, ItemStack.EMPTY); + } + this.sideItemHandler.setStackInSlot(0, ItemStack.EMPTY); + } + } + this.saveChanges(); + } else if (this.finalStep == 16) { + this.finalStep = 0; + this.setSmash(false); + this.markForUpdate(); + } + } else { + try { + final IEnergyGrid eg = this.getProxy().getEnergy(); + IEnergySource src = this; - // Base 1, increase by 1 for each card - final int speedFactor = 1 + this.upgrades.getInstalledUpgrades( Upgrades.SPEED ); - final int powerConsumption = 10 * speedFactor; - final double powerThreshold = powerConsumption - 0.01; - double powerReq = this.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG ); + // Base 1, increase by 1 for each card + final int speedFactor = 1 + this.upgrades.getInstalledUpgrades(Upgrades.SPEED); + final int powerConsumption = 10 * speedFactor; + final double powerThreshold = powerConsumption - 0.01; + double powerReq = this.extractAEPower(powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG); - if( powerReq <= powerThreshold ) - { - src = eg; - powerReq = eg.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG ); - } + if (powerReq <= powerThreshold) { + src = eg; + powerReq = eg.extractAEPower(powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG); + } - if( powerReq > powerThreshold ) - { - src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG ); + if (powerReq > powerThreshold) { + src.extractAEPower(powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG); - if( this.getProcessingTime() == 0 ) - { - this.setProcessingTime( this.getProcessingTime() + speedFactor ); - } - else - { - this.setProcessingTime( this.getProcessingTime() + ticksSinceLastCall * speedFactor ); - } - } - } - catch( final GridAccessException e ) - { - // :P - } + if (this.getProcessingTime() == 0) { + this.setProcessingTime(this.getProcessingTime() + speedFactor); + } else { + this.setProcessingTime(this.getProcessingTime() + ticksSinceLastCall * speedFactor); + } + } + } catch (final GridAccessException e) { + // :P + } - if( this.getProcessingTime() > this.getMaxProcessingTime() ) - { - this.setProcessingTime( this.getMaxProcessingTime() ); - final InscriberRecipe out = this.getTask(); - if( out != null ) - { - final ItemStack outputCopy = out.getOutput().copy(); - if( this.sideItemHandler.insertItem( 1, outputCopy, true ).isEmpty() ) - { - this.setSmash( true ); - this.finalStep = 0; - this.markForUpdate(); - } - } - } - } + if (this.getProcessingTime() > this.getMaxProcessingTime()) { + this.setProcessingTime(this.getMaxProcessingTime()); + final InscriberRecipe out = this.getTask(); + if (out != null) { + final ItemStack outputCopy = out.getOutput().copy(); + if (this.sideItemHandler.insertItem(1, outputCopy, true).isEmpty()) { + this.setSmash(true); + this.finalStep = 0; + this.markForUpdate(); + } + } + } + } - return this.hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP; - } + return this.hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP; + } - @Override - public IConfigManager getConfigManager() - { - return this.settings; - } + @Override + public IConfigManager getConfigManager() { + return this.settings; + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "inv" ) ) - { - return this.getInternalInventory(); - } + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("inv")) { + return this.getInternalInventory(); + } - if( name.equals( "upgrades" ) ) - { - return this.upgrades; - } + if (name.equals("upgrades")) { + return this.upgrades; + } - return null; - } + return null; + } - @Override - protected IItemHandler getItemHandlerForSide( @Nonnull Direction facing ) - { - if( facing == this.getUp() ) - { - return this.topItemHandlerExtern; - } - else if( facing == this.getUp().getOpposite() ) - { - return this.bottomItemHandlerExtern; - } - else - { - return this.sideItemHandlerExtern; - } - } + @Override + protected IItemHandler getItemHandlerForSide(@Nonnull Direction facing) { + if (facing == this.getUp()) { + return this.topItemHandlerExtern; + } else if (facing == this.getUp().getOpposite()) { + return this.bottomItemHandlerExtern; + } else { + return this.sideItemHandlerExtern; + } + } - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.upgrades.getInstalledUpgrades( u ); - } + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.upgrades.getInstalledUpgrades(u); + } - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + } - public long getClientStart() - { - return this.clientStart; - } + public long getClientStart() { + return this.clientStart; + } - private void setClientStart( final long clientStart ) - { - this.clientStart = clientStart; - } + private void setClientStart(final long clientStart) { + this.clientStart = clientStart; + } - public boolean isSmash() - { - return this.smash; - } + public boolean isSmash() { + return this.smash; + } - public void setSmash( final boolean smash ) - { - this.smash = smash; - } + public void setSmash(final boolean smash) { + this.smash = smash; + } - public int getMaxProcessingTime() - { - return this.maxProcessingTime; - } + public int getMaxProcessingTime() { + return this.maxProcessingTime; + } - public int getProcessingTime() - { - return this.processingTime; - } + public int getProcessingTime() { + return this.processingTime; + } - private void setProcessingTime( final int processingTime ) - { - this.processingTime = processingTime; - } + private void setProcessingTime(final int processingTime) { + this.processingTime = processingTime; + } - /** - * This is an item handler that exposes the inscribers inventory while providing simulation capabilities that do not - * reset the progress if there's already an item in a slot. Previously, the progress of the inscriber was reset when - * another mod attempted insertion of items when there were already items in the slot. - */ - private class ItemHandlerFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - if( TileInscriber.this.isSmash() ) - { - return false; - } + /** + * This is an item handler that exposes the inscribers inventory while providing + * simulation capabilities that do not reset the progress if there's already an + * item in a slot. Previously, the progress of the inscriber was reset when + * another mod attempted insertion of items when there were already items in the + * slot. + */ + private class ItemHandlerFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + if (TileInscriber.this.isSmash()) { + return false; + } - return inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler || slot == 1; - } + return inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler || slot == 1; + } - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - // output slot - if( slot == 1 ) - { - return false; - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + // output slot + if (slot == 1) { + return false; + } - if( TileInscriber.this.isSmash() ) - { - return false; - } + if (TileInscriber.this.isSmash()) { + return false; + } - if( inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler ) - { - if( AEApi.instance().definitions().materials().namePress().isSameAs( stack ) ) - { - return true; - } - return InscriberRecipes.isValidOptionalIngredient(getWorld(), stack); - } - return true; - } - } + if (inv == TileInscriber.this.topItemHandler || inv == TileInscriber.this.bottomItemHandler) { + if (AEApi.instance().definitions().materials().namePress().isSameAs(stack)) { + return true; + } + return InscriberRecipes.isValidOptionalIngredient(getWorld(), stack); + } + return true; + } + } } diff --git a/src/main/java/appeng/tile/misc/TileInterface.java b/src/main/java/appeng/tile/misc/TileInterface.java index 1da40b644..ae41fe2c5 100644 --- a/src/main/java/appeng/tile/misc/TileInterface.java +++ b/src/main/java/appeng/tile/misc/TileInterface.java @@ -18,14 +18,12 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.EnumSet; import java.util.List; import javax.annotation.Nullable; -import appeng.container.implementations.ContainerInterface; import com.google.common.collect.ImmutableSet; import net.minecraft.inventory.CraftingInventory; @@ -60,7 +58,7 @@ import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; - +import appeng.container.implementations.ContainerInterface; import appeng.helpers.DualityInterface; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; @@ -69,302 +67,250 @@ import appeng.util.Platform; import appeng.util.inv.IInventoryDestination; import appeng.util.inv.InvOperation; +public class TileInterface extends AENetworkInvTile + implements IGridTickable, IInventoryDestination, IInterfaceHost, IPriorityHost { -public class TileInterface extends AENetworkInvTile implements IGridTickable, IInventoryDestination, IInterfaceHost, IPriorityHost -{ + private final DualityInterface duality = new DualityInterface(this.getProxy(), this); - private final DualityInterface duality = new DualityInterface( this.getProxy(), this ); + // Indicates that this interface has no specific direction set + private boolean omniDirectional = true; - // Indicates that this interface has no specific direction set - private boolean omniDirectional = true; + public TileInterface(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileInterface(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkChannelsChanged c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkChannelsChanged c ) - { - this.duality.notifyNeighbors(); - } + @MENetworkEventSubscribe + public void stateChange(final MENetworkPowerStatusChange c) { + this.duality.notifyNeighbors(); + } - @MENetworkEventSubscribe - public void stateChange( final MENetworkPowerStatusChange c ) - { - this.duality.notifyNeighbors(); - } + public void setSide(final Direction facing) { + if (isRemote()) { + return; + } - public void setSide( final Direction facing ) - { - if( isRemote() ) - { - return; - } + Direction newForward = facing; - Direction newForward = facing; + if (!this.omniDirectional && this.getForward() == facing.getOpposite()) { + newForward = facing; + } else if (!this.omniDirectional + && (this.getForward() == facing || this.getForward() == facing.getOpposite())) { + this.omniDirectional = true; + } else if (this.omniDirectional) { + newForward = facing.getOpposite(); + this.omniDirectional = false; + } else { + newForward = Platform.rotateAround(this.getForward(), facing); + } - if( !this.omniDirectional && this.getForward() == facing.getOpposite() ) - { - newForward = facing; - } - else if( !this.omniDirectional && ( this.getForward() == facing || this.getForward() == facing.getOpposite() ) ) - { - this.omniDirectional = true; - } - else if( this.omniDirectional ) - { - newForward = facing.getOpposite(); - this.omniDirectional = false; - } - else - { - newForward = Platform.rotateAround( this.getForward(), facing ); - } + if (this.omniDirectional) { + this.setOrientation(Direction.NORTH, Direction.UP); + } else { + Direction newUp = Direction.UP; + if (newForward == Direction.UP || newForward == Direction.DOWN) { + newUp = Direction.NORTH; + } + this.setOrientation(newForward, newUp); + } - if( this.omniDirectional ) - { - this.setOrientation( Direction.NORTH, Direction.UP ); - } - else - { - Direction newUp = Direction.UP; - if( newForward == Direction.UP || newForward == Direction.DOWN ) - { - newUp = Direction.NORTH; - } - this.setOrientation( newForward, newUp ); - } + this.configureNodeSides(); + this.markForUpdate(); + this.saveChanges(); + } - this.configureNodeSides(); - this.markForUpdate(); - this.saveChanges(); - } + private void configureNodeSides() { + if (this.omniDirectional) { + this.getProxy().setValidSides(EnumSet.allOf(Direction.class)); + } else { + this.getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(this.getForward()))); + } + } - private void configureNodeSides() - { - if( this.omniDirectional ) - { - this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) ); - } - else - { - this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); - } - } + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + this.duality.addDrops(drops); + } - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - this.duality.addDrops( drops ); - } + @Override + public void gridChanged() { + this.duality.gridChanged(); + } - @Override - public void gridChanged() - { - this.duality.gridChanged(); - } + @Override + public void onReady() { + this.configureNodeSides(); - @Override - public void onReady() - { - this.configureNodeSides(); + super.onReady(); + this.duality.initialize(); + } - super.onReady(); - this.duality.initialize(); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putBoolean("omniDirectional", this.omniDirectional); + this.duality.writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putBoolean("omniDirectional", this.omniDirectional); - this.duality.writeToNBT( data ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.omniDirectional = data.getBoolean("omniDirectional"); - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.omniDirectional = data.getBoolean( "omniDirectional" ); + this.duality.readFromNBT(data); + } - this.duality.readFromNBT( data ); - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + boolean oldOmniDirectional = this.omniDirectional; + this.omniDirectional = data.readBoolean(); + return oldOmniDirectional != this.omniDirectional || c; + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - boolean oldOmniDirectional = this.omniDirectional; - this.omniDirectional = data.readBoolean(); - return oldOmniDirectional != this.omniDirectional || c; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeBoolean(this.omniDirectional); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeBoolean( this.omniDirectional ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return this.duality.getCableConnectionType(dir); + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return this.duality.getCableConnectionType( dir ); - } + @Override + public DimensionalCoord getLocation() { + return this.duality.getLocation(); + } - @Override - public DimensionalCoord getLocation() - { - return this.duality.getLocation(); - } + @Override + public boolean canInsert(final ItemStack stack) { + return this.duality.canInsert(stack); + } - @Override - public boolean canInsert( final ItemStack stack ) - { - return this.duality.canInsert( stack ); - } + @Override + public IItemHandler getInventoryByName(final String name) { + return this.duality.getInventoryByName(name); + } - @Override - public IItemHandler getInventoryByName( final String name ) - { - return this.duality.getInventoryByName( name ); - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return this.duality.getTickingRequest(node); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return this.duality.getTickingRequest( node ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + return this.duality.tickingRequest(node, ticksSinceLastCall); + } - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - return this.duality.tickingRequest( node, ticksSinceLastCall ); - } + @Override + public IItemHandler getInternalInventory() { + return this.duality.getInternalInventory(); + } - @Override - public IItemHandler getInternalInventory() - { - return this.duality.getInternalInventory(); - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + this.duality.onChangeInventory(inv, slot, mc, removed, added); + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - this.duality.onChangeInventory( inv, slot, mc, removed, added ); - } + @Override + public DualityInterface getInterfaceDuality() { + return this.duality; + } - @Override - public DualityInterface getInterfaceDuality() - { - return this.duality; - } + @Override + public EnumSet getTargets() { + if (this.omniDirectional) { + return EnumSet.allOf(Direction.class); + } + return EnumSet.of(this.getForward()); + } - @Override - public EnumSet getTargets() - { - if( this.omniDirectional ) - { - return EnumSet.allOf( Direction.class ); - } - return EnumSet.of( this.getForward() ); - } + @Override + public TileEntity getTileEntity() { + return this; + } - @Override - public TileEntity getTileEntity() - { - return this; - } + @Override + public IConfigManager getConfigManager() { + return this.duality.getConfigManager(); + } - @Override - public IConfigManager getConfigManager() - { - return this.duality.getConfigManager(); - } + @Override + public boolean pushPattern(final ICraftingPatternDetails patternDetails, final CraftingInventory table) { + return this.duality.pushPattern(patternDetails, table); + } - @Override - public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table ) - { - return this.duality.pushPattern( patternDetails, table ); - } + @Override + public boolean isBusy() { + return this.duality.isBusy(); + } - @Override - public boolean isBusy() - { - return this.duality.isBusy(); - } + @Override + public void provideCrafting(final ICraftingProviderHelper craftingTracker) { + this.duality.provideCrafting(craftingTracker); + } - @Override - public void provideCrafting( final ICraftingProviderHelper craftingTracker ) - { - this.duality.provideCrafting( craftingTracker ); - } + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.duality.getInstalledUpgrades(u); + } - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.duality.getInstalledUpgrades( u ); - } + @Override + public ImmutableSet getRequestedJobs() { + return this.duality.getRequestedJobs(); + } - @Override - public ImmutableSet getRequestedJobs() - { - return this.duality.getRequestedJobs(); - } + @Override + public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) { + return this.duality.injectCraftedItems(link, items, mode); + } - @Override - public IAEItemStack injectCraftedItems( final ICraftingLink link, final IAEItemStack items, final Actionable mode ) - { - return this.duality.injectCraftedItems( link, items, mode ); - } + @Override + public void jobStateChange(final ICraftingLink link) { + this.duality.jobStateChange(link); + } - @Override - public void jobStateChange( final ICraftingLink link ) - { - this.duality.jobStateChange( link ); - } + @Override + public int getPriority() { + return this.duality.getPriority(); + } - @Override - public int getPriority() - { - return this.duality.getPriority(); - } + @Override + public void setPriority(final int newValue) { + this.duality.setPriority(newValue); + } - @Override - public void setPriority( final int newValue ) - { - this.duality.setPriority( newValue ); - } + /** + * @return True if this interface is omni-directional. + */ + public boolean isOmniDirectional() { + return this.omniDirectional; + } - /** - * @return True if this interface is omni-directional. - */ - public boolean isOmniDirectional() - { - return this.omniDirectional; - } + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + LazyOptional result = this.duality.getCapability(capability, facing); + if (result.isPresent()) { + return result; + } + return super.getCapability(capability, facing); + } - @Override - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - LazyOptional result = this.duality.getCapability( capability, facing ); - if( result.isPresent() ) - { - return result; - } - return super.getCapability( capability, facing ); - } + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().blocks().iface().maybeStack(1).orElse(ItemStack.EMPTY); + } - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().blocks().iface().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - return ContainerInterface.TYPE; - } + @Override + public ContainerType getContainerType() { + return ContainerInterface.TYPE; + } } diff --git a/src/main/java/appeng/tile/misc/TileLightDetector.java b/src/main/java/appeng/tile/misc/TileLightDetector.java index 8e3005860..9c6176251 100644 --- a/src/main/java/appeng/tile/misc/TileLightDetector.java +++ b/src/main/java/appeng/tile/misc/TileLightDetector.java @@ -18,54 +18,45 @@ package appeng.tile.misc; - - -import appeng.tile.AEBaseTile; -import appeng.util.Platform; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; +import appeng.tile.AEBaseTile; +import appeng.util.Platform; -public class TileLightDetector extends AEBaseTile implements ITickableTileEntity -{ +public class TileLightDetector extends AEBaseTile implements ITickableTileEntity { - private int lastCheck = 30; - private int lastLight = 0; + private int lastCheck = 30; + private int lastLight = 0; - public TileLightDetector(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + public TileLightDetector(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public boolean isReady() - { - return this.lastLight > 0; - } + public boolean isReady() { + return this.lastLight > 0; + } - @Override - public void tick() - { - this.lastCheck++; - if( this.lastCheck > 30 ) - { - this.lastCheck = 0; - this.updateLight(); - } - } + @Override + public void tick() { + this.lastCheck++; + if (this.lastCheck > 30) { + this.lastCheck = 0; + this.updateLight(); + } + } - public void updateLight() - { - final int val = this.world.getLight( this.pos ); + public void updateLight() { + final int val = this.world.getLight(this.pos); - if( this.lastLight != val ) - { - this.lastLight = val; - Platform.notifyBlocksOfNeighbors( this.world, this.pos ); - } - } + if (this.lastLight != val) { + this.lastLight = val; + Platform.notifyBlocksOfNeighbors(this.world, this.pos); + } + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public boolean canBeRotated() { + return false; + } } diff --git a/src/main/java/appeng/tile/misc/TilePaint.java b/src/main/java/appeng/tile/misc/TilePaint.java index f053dada3..84d0c7c07 100644 --- a/src/main/java/appeng/tile/misc/TilePaint.java +++ b/src/main/java/appeng/tile/misc/TilePaint.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -26,7 +25,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import appeng.block.paint.PaintSplotches; +import javax.annotation.Nonnull; + import io.netty.buffer.Unpooled; import net.minecraft.block.BlockState; @@ -38,266 +38,220 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.LightType; - -import appeng.api.util.AEColor; -import appeng.helpers.Splotch; -import appeng.items.misc.ItemPaintBall; -import appeng.tile.AEBaseTile; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nonnull; +import appeng.api.util.AEColor; +import appeng.block.paint.PaintSplotches; +import appeng.helpers.Splotch; +import appeng.items.misc.ItemPaintBall; +import appeng.tile.AEBaseTile; +public class TilePaint extends AEBaseTile { -public class TilePaint extends AEBaseTile -{ + public static final ModelProperty SPLOTCHES = new ModelProperty<>(); - public static final ModelProperty SPLOTCHES = new ModelProperty<>(); + private static final int LIGHT_PER_DOT = 12; - private static final int LIGHT_PER_DOT = 12; + private int isLit = 0; + private List dots = null; - private int isLit = 0; - private List dots = null; + public TilePaint(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TilePaint(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + final PacketBuffer myDat = new PacketBuffer(Unpooled.buffer()); + this.writeBuffer(myDat); + if (myDat.hasArray()) { + data.putByteArray("dots", myDat.array()); + } + return data; + } - @Override - public CompoundNBT write( final CompoundNBT data ) - { - super.write( data ); - final PacketBuffer myDat = new PacketBuffer( Unpooled.buffer() ); - this.writeBuffer( myDat ); - if( myDat.hasArray() ) - { - data.putByteArray( "dots", myDat.array() ); - } - return data; - } + private void writeBuffer(final PacketBuffer out) { + if (this.dots == null) { + out.writeByte(0); + return; + } - private void writeBuffer( final PacketBuffer out ) - { - if( this.dots == null ) - { - out.writeByte( 0 ); - return; - } + out.writeByte(this.dots.size()); - out.writeByte( this.dots.size() ); + for (final Splotch s : this.dots) { + s.writeToStream(out); + } + } - for( final Splotch s : this.dots ) - { - s.writeToStream( out ); - } - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + if (data.contains("dots")) { + this.readBuffer(new PacketBuffer(Unpooled.copiedBuffer(data.getByteArray("dots")))); + } + } - @Override - public void read( final CompoundNBT data ) - { - super.read( data ); - if( data.contains( "dots" ) ) - { - this.readBuffer( new PacketBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) ) ); - } - } + private void readBuffer(final PacketBuffer in) { + final byte howMany = in.readByte(); - private void readBuffer( final PacketBuffer in ) - { - final byte howMany = in.readByte(); + if (howMany == 0) { + this.isLit = 0; + this.dots = null; + return; + } - if( howMany == 0 ) - { - this.isLit = 0; - this.dots = null; - return; - } + this.dots = new ArrayList(howMany); + for (int x = 0; x < howMany; x++) { + this.dots.add(new Splotch(in)); + } - this.dots = new ArrayList( howMany ); - for( int x = 0; x < howMany; x++ ) - { - this.dots.add( new Splotch( in ) ); - } + this.isLit = 0; + for (final Splotch s : this.dots) { + if (s.isLumen()) { + this.isLit += LIGHT_PER_DOT; + } + } - this.isLit = 0; - for( final Splotch s : this.dots ) - { - if( s.isLumen() ) - { - this.isLit += LIGHT_PER_DOT; - } - } + this.maxLit(); + } - this.maxLit(); - } + private void maxLit() { + if (this.isLit > 14) { + this.isLit = 14; + } - private void maxLit() - { - if( this.isLit > 14 ) - { - this.isLit = 14; - } + if (this.world != null) { + this.world.getLightFor(LightType.BLOCK, this.pos); + } + } - if( this.world != null ) - { - this.world.getLightFor( LightType.BLOCK, this.pos ); - } - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + this.writeBuffer(data); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - this.writeBuffer( data ); - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + super.readFromStream(data); + this.readBuffer(data); + return true; + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - super.readFromStream( data ); - this.readBuffer( data ); - return true; - } + public void neighborChanged() { + if (this.dots == null) { + return; + } - public void neighborChanged() - { - if( this.dots == null ) - { - return; - } + for (final Direction side : Direction.values()) { + if (!this.isSideValid(side)) { + this.removeSide(side); + } + } - for( final Direction side : Direction.values() ) - { - if( !this.isSideValid( side ) ) - { - this.removeSide( side ); - } - } + this.updateData(); + } - this.updateData(); - } + public boolean isSideValid(final Direction side) { + final BlockPos p = this.pos.offset(side); + final BlockState blk = this.world.getBlockState(p); + return blk.isSolidSide(world, p, side.getOpposite()); + } - public boolean isSideValid( final Direction side ) - { - final BlockPos p = this.pos.offset( side ); - final BlockState blk = this.world.getBlockState( p ); - return blk.isSolidSide( world, p, side.getOpposite() ); - } + private void removeSide(final Direction side) { + final Iterator i = this.dots.iterator(); + while (i.hasNext()) { + final Splotch s = i.next(); + if (s.getSide() == side) { + i.remove(); + } + } - private void removeSide( final Direction side ) - { - final Iterator i = this.dots.iterator(); - while( i.hasNext() ) - { - final Splotch s = i.next(); - if( s.getSide() == side ) - { - i.remove(); - } - } + this.markForUpdate(); + this.saveChanges(); + } - this.markForUpdate(); - this.saveChanges(); - } + private void updateData() { + this.isLit = 0; + for (final Splotch s : this.dots) { + if (s.isLumen()) { + this.isLit += LIGHT_PER_DOT; + } + } - private void updateData() - { - this.isLit = 0; - for( final Splotch s : this.dots ) - { - if( s.isLumen() ) - { - this.isLit += LIGHT_PER_DOT; - } - } + this.maxLit(); - this.maxLit(); + if (this.dots.isEmpty()) { + this.dots = null; + } - if( this.dots.isEmpty() ) - { - this.dots = null; - } + if (this.dots == null) { + this.world.removeBlock(this.pos, false); + } + } - if( this.dots == null ) - { - this.world.removeBlock( this.pos, false ); - } - } + public void cleanSide(final Direction side) { + if (this.dots == null) { + return; + } - public void cleanSide( final Direction side ) - { - if( this.dots == null ) - { - return; - } + this.removeSide(side); - this.removeSide( side ); + this.updateData(); + } - this.updateData(); - } + public int getLightLevel() { + return this.isLit; + } - public int getLightLevel() - { - return this.isLit; - } + public void addBlot(final ItemStack type, final Direction side, final Vec3d hitVec) { + final BlockPos p = this.pos.offset(side); - public void addBlot( final ItemStack type, final Direction side, final Vec3d hitVec ) - { - final BlockPos p = this.pos.offset( side ); + final BlockState blk = this.world.getBlockState(p); + if (blk.isSolidSide(this.world, p, side.getOpposite())) { + final ItemPaintBall ipb = (ItemPaintBall) type.getItem(); - final BlockState blk = this.world.getBlockState( p ); - if( blk.isSolidSide( this.world, p, side.getOpposite() ) ) - { - final ItemPaintBall ipb = (ItemPaintBall) type.getItem(); + final AEColor col = ipb.getColor(); + final boolean lit = ipb.isLumen(); - final AEColor col = ipb.getColor(); - final boolean lit = ipb.isLumen(); + if (this.dots == null) { + this.dots = new ArrayList<>(); + } - if( this.dots == null ) - { - this.dots = new ArrayList<>(); - } + if (this.dots.size() > 20) { + this.dots.remove(0); + } - if( this.dots.size() > 20 ) - { - this.dots.remove( 0 ); - } + this.dots.add(new Splotch(col, lit, side, hitVec)); + if (lit) { + this.isLit += LIGHT_PER_DOT; + } - this.dots.add( new Splotch( col, lit, side, hitVec ) ); - if( lit ) - { - this.isLit += LIGHT_PER_DOT; - } + this.maxLit(); + this.markForUpdate(); + this.saveChanges(); + } + } - this.maxLit(); - this.markForUpdate(); - this.saveChanges(); - } - } + public Collection getDots() { + if (this.dots == null) { + return Collections.emptyList(); + } - public Collection getDots() - { - if( this.dots == null ) - { - return Collections.emptyList(); - } + return this.dots; + } - return this.dots; - } - - @Nonnull - @Override - public IModelData getModelData() { - // FIXME update trigger - return new ModelDataMap.Builder() - .withInitial(SPLOTCHES, new PaintSplotches(getDots())) - .build(); - } + @Nonnull + @Override + public IModelData getModelData() { + // FIXME update trigger + return new ModelDataMap.Builder().withInitial(SPLOTCHES, new PaintSplotches(getDots())).build(); + } } diff --git a/src/main/java/appeng/tile/misc/TileQuartzGrowthAccelerator.java b/src/main/java/appeng/tile/misc/TileQuartzGrowthAccelerator.java index 7d81f6d31..888f37dec 100644 --- a/src/main/java/appeng/tile/misc/TileQuartzGrowthAccelerator.java +++ b/src/main/java/appeng/tile/misc/TileQuartzGrowthAccelerator.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.EnumSet; @@ -36,87 +35,71 @@ import appeng.me.GridAccessException; import appeng.tile.grid.AENetworkTile; import appeng.util.Platform; +public class TileQuartzGrowthAccelerator extends AENetworkTile + implements IPowerChannelState, ICrystalGrowthAccelerator { -public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState, ICrystalGrowthAccelerator -{ + private boolean hasPower = false; - private boolean hasPower = false; + public TileQuartzGrowthAccelerator(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + this.getProxy().setFlags(); + this.getProxy().setIdlePowerUsage(8); + } - public TileQuartzGrowthAccelerator(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - this.getProxy().setFlags(); - this.getProxy().setIdlePowerUsage( 8 ); - } + @MENetworkEventSubscribe + public void onPower(final MENetworkPowerStatusChange ch) { + this.markForUpdate(); + } - @MENetworkEventSubscribe - public void onPower( final MENetworkPowerStatusChange ch ) - { - this.markForUpdate(); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + public boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final boolean hadPower = this.isPowered(); + this.setPowered(data.readBoolean()); + return this.isPowered() != hadPower || c; + } - @Override - public boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final boolean hadPower = this.isPowered(); - this.setPowered( data.readBoolean() ); - return this.isPowered() != hadPower || c; - } + @Override + public void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + try { + data.writeBoolean(this.getProxy().getEnergy().isNetworkPowered()); + } catch (final GridAccessException e) { + data.writeBoolean(false); + } + } - @Override - public void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - try - { - data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() ); - } - catch( final GridAccessException e ) - { - data.writeBoolean( false ); - } - } + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + this.getProxy().setValidSides(EnumSet.of(this.getUp(), this.getUp().getOpposite())); + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) ); - } + @Override + public boolean isPowered() { + if (Platform.isServer()) { + try { + return this.getProxy().getEnergy().isNetworkPowered(); + } catch (final GridAccessException e) { + return false; + } + } - @Override - public boolean isPowered() - { - if( Platform.isServer() ) - { - try - { - return this.getProxy().getEnergy().isNetworkPowered(); - } - catch( final GridAccessException e ) - { - return false; - } - } + return this.hasPower; + } - return this.hasPower; - } + @Override + public boolean isActive() { + return this.isPowered(); + } - @Override - public boolean isActive() - { - return this.isPowered(); - } - - private void setPowered( final boolean hasPower ) - { - this.hasPower = hasPower; - } + private void setPowered(final boolean hasPower) { + this.hasPower = hasPower; + } } diff --git a/src/main/java/appeng/tile/misc/TileSecurityStation.java b/src/main/java/appeng/tile/misc/TileSecurityStation.java index 1e8de0712..8114cf795 100644 --- a/src/main/java/appeng/tile/misc/TileSecurityStation.java +++ b/src/main/java/appeng/tile/misc/TileSecurityStation.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import java.util.EnumSet; import java.util.List; @@ -27,8 +26,8 @@ import java.util.Map; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.INBT; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; @@ -81,299 +80,256 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import appeng.util.item.AEItemStack; +public class TileSecurityStation extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, + IConfigManagerHost, ISecurityProvider, IColorableTile { -public class TileSecurityStation extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile -{ + private static int difference = 0; + private final AppEngInternalInventory configSlot = new AppEngInternalInventory(this, 1); + private final IConfigManager cm = new ConfigManager(this); + private final SecurityStationInventory inventory = new SecurityStationInventory(this); + private final MEMonitorHandler securityMonitor = new MEMonitorHandler<>(this.inventory); + private long securityKey; + private AEColor paintedColor = AEColor.TRANSPARENT; + private boolean isActive = false; - private static int difference = 0; - private final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 ); - private final IConfigManager cm = new ConfigManager( this ); - private final SecurityStationInventory inventory = new SecurityStationInventory( this ); - private final MEMonitorHandler securityMonitor = new MEMonitorHandler<>( this.inventory ); - private long securityKey; - private AEColor paintedColor = AEColor.TRANSPARENT; - private boolean isActive = false; + public TileSecurityStation(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.getProxy().setIdlePowerUsage(2.0); + difference++; - public TileSecurityStation(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.getProxy().setIdlePowerUsage( 2.0 ); - difference++; + this.securityKey = System.currentTimeMillis() * 10 + difference; + if (difference > 10) { + difference = 0; + } - this.securityKey = System.currentTimeMillis() * 10 + difference; - if( difference > 10 ) - { - difference = 0; - } + this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + this.cm.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); + } - 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 onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removedStack, final ItemStack newStack) { - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + } - } + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + if (!ItemHandlerUtil.isEmpty(this.getConfigSlot())) { + drops.add(this.getConfigSlot().getStackInSlot(0)); + } - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - if( !ItemHandlerUtil.isEmpty( this.getConfigSlot() ) ) - { - drops.add( this.getConfigSlot().getStackInSlot( 0 ) ); - } + for (final IAEItemStack ais : this.inventory.getStoredItems()) { + drops.add(ais.createItemStack()); + } + } - for( final IAEItemStack ais : this.inventory.getStoredItems() ) - { - drops.add( ais.createItemStack() ); - } - } + IMEInventoryHandler getSecurityInventory() { + return this.inventory; + } - IMEInventoryHandler getSecurityInventory() - { - return this.inventory; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final boolean wasActive = this.isActive; + this.isActive = data.readBoolean(); - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final boolean wasActive = this.isActive; - this.isActive = data.readBoolean(); + final AEColor oldPaintedColor = this.paintedColor; + this.paintedColor = AEColor.values()[data.readByte()]; - final AEColor oldPaintedColor = this.paintedColor; - this.paintedColor = AEColor.values()[data.readByte()]; + return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c; + } - return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeBoolean(this.getProxy().isActive()); + data.writeByte(this.paintedColor.ordinal()); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeBoolean( this.getProxy().isActive() ); - data.writeByte( this.paintedColor.ordinal() ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.cm.writeToNBT(data); + data.putByte("paintedColor", (byte) this.paintedColor.ordinal()); - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.cm.writeToNBT( data ); - data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() ); + data.putLong("securityKey", this.securityKey); + this.getConfigSlot().writeToNBT(data, "config"); - data.putLong( "securityKey", this.securityKey ); - this.getConfigSlot().writeToNBT( data, "config" ); + final CompoundNBT storedItems = new CompoundNBT(); - final CompoundNBT storedItems = new CompoundNBT(); + int offset = 0; + for (final IAEItemStack ais : this.inventory.getStoredItems()) { + final CompoundNBT it = new CompoundNBT(); + ais.createItemStack().write(it); + storedItems.put(String.valueOf(offset), it); + offset++; + } - int offset = 0; - for( final IAEItemStack ais : this.inventory.getStoredItems() ) - { - final CompoundNBT it = new CompoundNBT(); - ais.createItemStack().write(it); - storedItems.put( String.valueOf( offset ), it ); - offset++; - } + data.put("storedItems", storedItems); + return data; + } - data.put( "storedItems", storedItems ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.cm.readFromNBT(data); + if (data.contains("paintedColor")) { + this.paintedColor = AEColor.values()[data.getByte("paintedColor")]; + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.cm.readFromNBT( data ); - if( data.contains("paintedColor") ) - { - this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; - } + this.securityKey = data.getLong("securityKey"); + this.getConfigSlot().readFromNBT(data, "config"); - this.securityKey = data.getLong( "securityKey" ); - this.getConfigSlot().readFromNBT( data, "config" ); + final CompoundNBT storedItems = data.getCompound("storedItems"); + for (final Object key : storedItems.keySet()) { + final INBT obj = storedItems.get((String) key); + if (obj instanceof CompoundNBT) { + this.inventory.getStoredItems().add(AEItemStack.fromItemStack(ItemStack.read((CompoundNBT) obj))); + } + } + } - final CompoundNBT storedItems = data.getCompound( "storedItems" ); - for( final Object key : storedItems.keySet() ) - { - final INBT obj = storedItems.get( (String) key ); - if( obj instanceof CompoundNBT ) - { - this.inventory.getStoredItems().add( AEItemStack.fromItemStack( ItemStack.read((CompoundNBT) obj) ) ); - } - } - } + public void inventoryChanged() { + try { + this.saveChanges(); + this.getProxy().getGrid().postEvent(new MENetworkSecurityChange()); + } catch (final GridAccessException e) { + // :P + } + } - public void inventoryChanged() - { - try - { - this.saveChanges(); - this.getProxy().getGrid().postEvent( new MENetworkSecurityChange() ); - } - catch( final GridAccessException e ) - { - // :P - } - } + @MENetworkEventSubscribe + public void bootUpdate(final MENetworkChannelsChanged changed) { + this.markForUpdate(); + } - @MENetworkEventSubscribe - public void bootUpdate( final MENetworkChannelsChanged changed ) - { - this.markForUpdate(); - } + @MENetworkEventSubscribe + public void powerUpdate(final MENetworkPowerStatusChange changed) { + this.markForUpdate(); + } - @MENetworkEventSubscribe - public void powerUpdate( final MENetworkPowerStatusChange changed ) - { - this.markForUpdate(); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER)); + this.isActive = false; + } - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) ); - this.isActive = false; - } + @Override + public void onReady() { + super.onReady(); + if (Platform.isServer()) { + this.isActive = true; + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.REGISTER)); + } + } - @Override - public void onReady() - { - super.onReady(); - if( Platform.isServer() ) - { - this.isActive = true; - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.REGISTER ) ); - } - } + @Override + public void remove() { + super.remove(); + MinecraftForge.EVENT_BUS.post(new LocatableEventAnnounce(this, LocatableEvent.UNREGISTER)); + this.isActive = false; + } - @Override - public void remove() - { - super.remove(); - MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.UNREGISTER ) ); - this.isActive = false; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + public boolean isActive() { + if (world != null && !world.isRemote) { + return isPowered(); + } else { + return this.isActive; + } + } - public boolean isActive() - { - if (world != null && !world.isRemote) { - return isPowered(); - } else { - return this.isActive; - } - } + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { + return (IMEMonitor) this.securityMonitor; + } + return null; - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - return (IMEMonitor) this.securityMonitor; - } - return null; + } - } + @Override + public long getLocatableSerial() { + return this.securityKey; + } - @Override - public long getLocatableSerial() - { - return this.securityKey; - } + public boolean isPowered() { + return this.getProxy().isActive(); + } - public boolean isPowered() - { - return this.getProxy().isActive(); - } + @Override + public IConfigManager getConfigManager() { + return this.cm; + } - @Override - public IConfigManager getConfigManager() - { - return this.cm; - } + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { + } - } + @Override + public long getSecurityKey() { + return this.securityKey; + } - @Override - public long getSecurityKey() - { - return this.securityKey; - } + @Override + public void readPermissions(final Map> playerPerms) { + final IPlayerRegistry pr = AEApi.instance().registries().players(); - @Override - public void readPermissions( final Map> playerPerms ) - { - final IPlayerRegistry pr = AEApi.instance().registries().players(); + // read permissions + for (final IAEItemStack ais : this.inventory.getStoredItems()) { + final ItemStack is = ais.createItemStack(); + final Item i = is.getItem(); + if (i instanceof IBiometricCard) { + final IBiometricCard bc = (IBiometricCard) i; + bc.registerPermissions(new PlayerSecurityWrapper(playerPerms), pr, is); + } + } - // read permissions - for( final IAEItemStack ais : this.inventory.getStoredItems() ) - { - final ItemStack is = ais.createItemStack(); - final Item i = is.getItem(); - if( i instanceof IBiometricCard ) - { - final IBiometricCard bc = (IBiometricCard) i; - bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is ); - } - } + // make sure thea admin is Boss. + playerPerms.put(this.getProxy().getNode().getPlayerID(), EnumSet.allOf(SecurityPermissions.class)); + } - // make sure thea admin is Boss. - playerPerms.put( this.getProxy().getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) ); - } + @Override + public boolean isSecurityEnabled() { + return this.isActive && this.getProxy().isActive(); + } - @Override - public boolean isSecurityEnabled() - { - return this.isActive && this.getProxy().isActive(); - } + @Override + public int getOwner() { + return this.getProxy().getNode().getPlayerID(); + } - @Override - public int getOwner() - { - return this.getProxy().getNode().getPlayerID(); - } + @Override + public AEColor getColor() { + return this.paintedColor; + } - @Override - public AEColor getColor() - { - return this.paintedColor; - } + @Override + public boolean recolourBlock(final Direction side, final AEColor newPaintedColor, final PlayerEntity who) { + if (this.paintedColor == newPaintedColor) { + return false; + } - @Override - public boolean recolourBlock( final Direction side, final AEColor newPaintedColor, final PlayerEntity who ) - { - if( this.paintedColor == newPaintedColor ) - { - return false; - } + this.paintedColor = newPaintedColor; + this.saveChanges(); + this.markForUpdate(); + return true; + } - this.paintedColor = newPaintedColor; - this.saveChanges(); - this.markForUpdate(); - return true; - } - - public AppEngInternalInventory getConfigSlot() - { - return this.configSlot; - } + public AppEngInternalInventory getConfigSlot() { + return this.configSlot; + } } diff --git a/src/main/java/appeng/tile/misc/TileSkyCompass.java b/src/main/java/appeng/tile/misc/TileSkyCompass.java index 50f076964..d731a78ab 100644 --- a/src/main/java/appeng/tile/misc/TileSkyCompass.java +++ b/src/main/java/appeng/tile/misc/TileSkyCompass.java @@ -18,16 +18,14 @@ package appeng.tile.misc; - -import appeng.tile.AEBaseTile; import net.minecraft.tileentity.TileEntityType; +import appeng.tile.AEBaseTile; -public class TileSkyCompass extends AEBaseTile -{ +public class TileSkyCompass extends AEBaseTile { - public TileSkyCompass(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + public TileSkyCompass(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } } diff --git a/src/main/java/appeng/tile/misc/TileVibrationChamber.java b/src/main/java/appeng/tile/misc/TileVibrationChamber.java index fca49bd9b..eea5cf04a 100644 --- a/src/main/java/appeng/tile/misc/TileVibrationChamber.java +++ b/src/main/java/appeng/tile/misc/TileVibrationChamber.java @@ -18,7 +18,6 @@ package appeng.tile.misc; - import java.io.IOException; import javax.annotation.Nonnull; @@ -50,283 +49,233 @@ import appeng.util.inv.InvOperation; import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.IAEItemFilter; +public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable { + public static final double POWER_PER_TICK = 5; + public static final int MIN_BURN_SPEED = 20; + public static final int MAX_BURN_SPEED = 200; + public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1); + private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new FuelSlotFilter()); -public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable -{ - public static final double POWER_PER_TICK = 5; - public static final int MIN_BURN_SPEED = 20; - public static final int MAX_BURN_SPEED = 200; - public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 ); - private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new FuelSlotFilter() ); + private int burnSpeed = 100; + private double burnTime = 0; + private double maxBurnTime = 0; - private int burnSpeed = 100; - private double burnTime = 0; - private double maxBurnTime = 0; + // client side.. + public boolean isOn; - // client side.. - public boolean isOn; + public TileVibrationChamber(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setIdlePowerUsage(0); + this.getProxy().setFlags(); + } - public TileVibrationChamber(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setIdlePowerUsage( 0 ); - this.getProxy().setFlags(); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final boolean wasOn = this.isOn; - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final boolean wasOn = this.isOn; + this.isOn = data.readBoolean(); - this.isOn = data.readBoolean(); + return wasOn != this.isOn || c; // TESR doesn't need updates! + } - return wasOn != this.isOn || c; // TESR doesn't need updates! - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeBoolean(this.getBurnTime() > 0); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeBoolean( this.getBurnTime() > 0 ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putDouble("burnTime", this.getBurnTime()); + data.putDouble("maxBurnTime", this.getMaxBurnTime()); + data.putInt("burnSpeed", this.getBurnSpeed()); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putDouble("burnTime", this.getBurnTime()); - data.putDouble("maxBurnTime", this.getMaxBurnTime()); - data.putInt( "burnSpeed", this.getBurnSpeed() ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.setBurnTime(data.getDouble("burnTime")); + this.setMaxBurnTime(data.getDouble("maxBurnTime")); + this.setBurnSpeed(data.getInt("burnSpeed")); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.setBurnTime( data.getDouble( "burnTime" ) ); - this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) ); - this.setBurnSpeed( data.getInt( "burnSpeed" ) ); - } + @Override + protected IItemHandler getItemHandlerForSide(@Nonnull Direction facing) { + return this.invExt; + } - @Override - protected IItemHandler getItemHandlerForSide( @Nonnull Direction facing ) - { - return this.invExt; - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (this.getBurnTime() <= 0) { + if (this.canEatFuel()) { + try { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // wake up! + } + } + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( this.getBurnTime() <= 0 ) - { - if( this.canEatFuel() ) - { - try - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // wake up! - } - } - } - } + private boolean canEatFuel() { + final ItemStack is = this.inv.getStackInSlot(0); + if (!is.isEmpty()) { + final int newBurnTime = ForgeHooks.getBurnTime(is); + if (newBurnTime > 0 && is.getCount() > 0) { + return true; + } + } + return false; + } - private boolean canEatFuel() - { - final ItemStack is = this.inv.getStackInSlot( 0 ); - if( !is.isEmpty() ) - { - final int newBurnTime = ForgeHooks.getBurnTime( is ); - if( newBurnTime > 0 && is.getCount() > 0 ) - { - return true; - } - } - return false; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + if (this.getBurnTime() <= 0) { + this.eatFuel(); + } - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - if( this.getBurnTime() <= 0 ) - { - this.eatFuel(); - } + return new TickingRequest(TickRates.VibrationChamber.getMin(), TickRates.VibrationChamber.getMax(), + this.getBurnTime() <= 0, false); + } - return new TickingRequest( TickRates.VibrationChamber.getMin(), TickRates.VibrationChamber.getMax(), this.getBurnTime() <= 0, false ); - } + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (this.getBurnTime() <= 0) { + this.eatFuel(); - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( this.getBurnTime() <= 0 ) - { - this.eatFuel(); + if (this.getBurnTime() > 0) { + return TickRateModulation.URGENT; + } - if( this.getBurnTime() > 0 ) - { - return TickRateModulation.URGENT; - } + this.setBurnSpeed(100); + return TickRateModulation.SLEEP; + } - this.setBurnSpeed( 100 ); - return TickRateModulation.SLEEP; - } + this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED))); + final double dilation = this.getBurnSpeed() / DILATION_SCALING; - this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) ); - final double dilation = this.getBurnSpeed() / DILATION_SCALING; + double timePassed = ticksSinceLastCall * dilation; + this.setBurnTime(this.getBurnTime() - timePassed); + if (this.getBurnTime() < 0) { + timePassed += this.getBurnTime(); + this.setBurnTime(0); + } - double timePassed = ticksSinceLastCall * dilation; - this.setBurnTime( this.getBurnTime() - timePassed ); - if( this.getBurnTime() < 0 ) - { - timePassed += this.getBurnTime(); - this.setBurnTime( 0 ); - } + try { + final IEnergyGrid grid = this.getProxy().getEnergy(); + final double newPower = timePassed * POWER_PER_TICK; + final double overFlow = grid.injectPower(newPower, Actionable.SIMULATE); - try - { - final IEnergyGrid grid = this.getProxy().getEnergy(); - final double newPower = timePassed * POWER_PER_TICK; - final double overFlow = grid.injectPower( newPower, Actionable.SIMULATE ); + // burn the over flow. + grid.injectPower(Math.max(0.0, newPower - overFlow), Actionable.MODULATE); - // burn the over flow. - grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE ); + if (overFlow > 0) { + this.setBurnSpeed(this.getBurnSpeed() - ticksSinceLastCall); + } else { + this.setBurnSpeed(this.getBurnSpeed() + ticksSinceLastCall); + } - if( overFlow > 0 ) - { - this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall ); - } - else - { - this.setBurnSpeed( this.getBurnSpeed() + ticksSinceLastCall ); - } + this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED))); + return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER; + } catch (final GridAccessException e) { + this.setBurnSpeed(this.getBurnSpeed() - ticksSinceLastCall); + this.setBurnSpeed(Math.max(MIN_BURN_SPEED, Math.min(this.getBurnSpeed(), MAX_BURN_SPEED))); + return TickRateModulation.SLOWER; + } + } - this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) ); - return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER; - } - catch( final GridAccessException e ) - { - this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall ); - this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) ); - return TickRateModulation.SLOWER; - } - } + private void eatFuel() { + final ItemStack is = this.inv.getStackInSlot(0); + if (!is.isEmpty()) { + final int newBurnTime = ForgeHooks.getBurnTime(is); + if (newBurnTime > 0 && is.getCount() > 0) { + this.setBurnTime(this.getBurnTime() + newBurnTime); + this.setMaxBurnTime(this.getBurnTime()); - private void eatFuel() - { - final ItemStack is = this.inv.getStackInSlot( 0 ); - if( !is.isEmpty() ) - { - final int newBurnTime = ForgeHooks.getBurnTime( is ); - if( newBurnTime > 0 && is.getCount() > 0 ) - { - this.setBurnTime( this.getBurnTime() + newBurnTime ); - this.setMaxBurnTime( this.getBurnTime() ); + final Item fuelItem = is.getItem(); + is.shrink(1); - final Item fuelItem = is.getItem(); - is.shrink( 1 ); + if (is.isEmpty()) { + this.inv.setStackInSlot(0, fuelItem.getContainerItem(is)); + } else { + this.inv.setStackInSlot(0, is); + } + this.saveChanges(); + } + } - if( is.isEmpty() ) - { - this.inv.setStackInSlot( 0, fuelItem.getContainerItem( is ) ); - } - else - { - this.inv.setStackInSlot( 0, is ); - } - this.saveChanges(); - } - } + if (this.getBurnTime() > 0) { + try { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } catch (final GridAccessException e) { + // gah! + } + } - if( this.getBurnTime() > 0 ) - { - try - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - catch( final GridAccessException e ) - { - // gah! - } - } + // state change + if ((!this.isOn && this.getBurnTime() > 0) || (this.isOn && this.getBurnTime() <= 0)) { + this.isOn = this.getBurnTime() > 0; + this.markForUpdate(); - // state change - if( ( !this.isOn && this.getBurnTime() > 0 ) || ( this.isOn && this.getBurnTime() <= 0 ) ) - { - this.isOn = this.getBurnTime() > 0; - this.markForUpdate(); + if (this.hasWorld()) { + Platform.notifyBlocksOfNeighbors(this.world, this.pos); + } + } + } - if( this.hasWorld() ) - { - Platform.notifyBlocksOfNeighbors( this.world, this.pos ); - } - } - } + public int getBurnSpeed() { + return this.burnSpeed; + } - public int getBurnSpeed() - { - return this.burnSpeed; - } + private void setBurnSpeed(final int burnSpeed) { + this.burnSpeed = burnSpeed; + } - private void setBurnSpeed( final int burnSpeed ) - { - this.burnSpeed = burnSpeed; - } + public double getMaxBurnTime() { + return this.maxBurnTime; + } - public double getMaxBurnTime() - { - return this.maxBurnTime; - } + private void setMaxBurnTime(final double maxBurnTime) { + this.maxBurnTime = maxBurnTime; + } - private void setMaxBurnTime( final double maxBurnTime ) - { - this.maxBurnTime = maxBurnTime; - } + public double getBurnTime() { + return this.burnTime; + } - public double getBurnTime() - { - return this.burnTime; - } + private void setBurnTime(final double burnTime) { + this.burnTime = burnTime; + } - private void setBurnTime( final double burnTime ) - { - this.burnTime = burnTime; - } + private class FuelSlotFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return ForgeHooks.getBurnTime(inv.getStackInSlot(slot)) == 0; + } - private class FuelSlotFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return ForgeHooks.getBurnTime( inv.getStackInSlot( slot ) ) == 0; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return ForgeHooks.getBurnTime( stack ) != 0; - } - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return ForgeHooks.getBurnTime(stack) != 0; + } + } } diff --git a/src/main/java/appeng/tile/networking/CableBusTESR.java b/src/main/java/appeng/tile/networking/CableBusTESR.java index b9a3eec08..3be3551ba 100644 --- a/src/main/java/appeng/tile/networking/CableBusTESR.java +++ b/src/main/java/appeng/tile/networking/CableBusTESR.java @@ -18,8 +18,8 @@ package appeng.tile.networking; - import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -28,27 +28,24 @@ import net.minecraft.util.Direction; import appeng.api.parts.IPart; import appeng.tile.AEBaseTile; +public class CableBusTESR extends TileEntityRenderer { -public class CableBusTESR extends TileEntityRenderer -{ + public CableBusTESR(TileEntityRendererDispatcher rendererDispatcherIn) { + super(rendererDispatcherIn); + } - public CableBusTESR(TileEntityRendererDispatcher rendererDispatcherIn) { - super(rendererDispatcherIn); - } + @Override + public void render(TileCableBus te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, + int combinedLightIn, int combinedOverlayIn) { + if (!te.getCableBus().isRequiresDynamicRender()) { + return; + } - @Override - public void render(TileCableBus te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) { - if (!te.getCableBus().isRequiresDynamicRender()) { - return; - } - - for( Direction facing : Direction.values() ) - { - IPart part = te.getPart( facing ); - if( part != null && part.requireDynamicRender() ) - { - part.renderDynamic(partialTicks, ms, buffers, combinedLightIn, combinedOverlayIn); - } - } - } + for (Direction facing : Direction.values()) { + IPart part = te.getPart(facing); + if (part != null && part.requireDynamicRender()) { + part.renderDynamic(partialTicks, ms, buffers, combinedLightIn, combinedOverlayIn); + } + } + } } diff --git a/src/main/java/appeng/tile/networking/TileCableBus.java b/src/main/java/appeng/tile/networking/TileCableBus.java index 7f389ed80..ed8ce2261 100644 --- a/src/main/java/appeng/tile/networking/TileCableBus.java +++ b/src/main/java/appeng/tile/networking/TileCableBus.java @@ -18,23 +18,13 @@ package appeng.tile.networking; +import java.io.IOException; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import appeng.api.networking.IGridNode; -import appeng.api.parts.IFacadeContainer; -import appeng.api.parts.IPart; -import appeng.api.parts.LayerFlags; -import appeng.api.parts.SelectedPart; -import appeng.api.util.AECableType; -import appeng.api.util.AEColor; -import appeng.api.util.AEPartLocation; -import appeng.api.util.DimensionalCoord; -import appeng.block.networking.BlockCableBus; -import appeng.client.render.cablebus.CableBusRenderState; -import appeng.helpers.AEMultiTile; -import appeng.hooks.TickHandler; -import appeng.parts.CableBusContainer; -import appeng.tile.AEBaseTile; -import appeng.util.Platform; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -52,69 +42,73 @@ import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.List; -import java.util.Set; +import appeng.api.networking.IGridNode; +import appeng.api.parts.IFacadeContainer; +import appeng.api.parts.IPart; +import appeng.api.parts.LayerFlags; +import appeng.api.parts.SelectedPart; +import appeng.api.util.AECableType; +import appeng.api.util.AEColor; +import appeng.api.util.AEPartLocation; +import appeng.api.util.DimensionalCoord; +import appeng.block.networking.BlockCableBus; +import appeng.client.render.cablebus.CableBusRenderState; +import appeng.helpers.AEMultiTile; +import appeng.hooks.TickHandler; +import appeng.parts.CableBusContainer; +import appeng.tile.AEBaseTile; +import appeng.util.Platform; +public class TileCableBus extends AEBaseTile implements AEMultiTile { -public class TileCableBus extends AEBaseTile implements AEMultiTile -{ + private CableBusContainer cb = new CableBusContainer(this); - private CableBusContainer cb = new CableBusContainer( this ); + private int oldLV = -1; // on re-calculate light when it changes - private int oldLV = -1; // on re-calculate light when it changes + public TileCableBus(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - public TileCableBus(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.getCableBus().readFromNBT(data); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.getCableBus().readFromNBT( data ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.getCableBus().writeToNBT(data); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.getCableBus().writeToNBT( data ); - return data; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + boolean ret = this.getCableBus().readFromStream(data); - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - boolean ret = this.getCableBus().readFromStream( data ); + final int newLV = this.getCableBus().getLightValue(); + if (newLV != this.oldLV) { + this.oldLV = newLV; + this.world.getLightManager().checkBlock(this.pos); + ret = true; + } - final int newLV = this.getCableBus().getLightValue(); - if( newLV != this.oldLV ) - { - this.oldLV = newLV; - this.world.getLightManager().checkBlock( this.pos ); - ret = true; - } + this.updateTileSetting(); + return ret || c; + } - this.updateTileSetting(); - return ret || c; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + this.getCableBus().writeToStream(data); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - this.getCableBus().writeToStream( data ); - } - - /** - * Changes this tile to the TESR version if any of the parts require dynamic rendering. - */ - protected void updateTileSetting() - { + /** + * Changes this tile to the TESR version if any of the parts require dynamic + * rendering. + */ + protected void updateTileSetting() { // FIXME if( this.getCableBus().isRequiresDynamicRender() ) // FIXME { // FIXME try @@ -128,279 +122,234 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile // FIXME // FIXME } // FIXME } - } + } - protected void copyFrom( final TileCableBus oldTile ) - { - final CableBusContainer tmpCB = this.getCableBus(); - this.setCableBus( oldTile.getCableBus() ); - this.oldLV = oldTile.oldLV; - oldTile.setCableBus( tmpCB ); - } + protected void copyFrom(final TileCableBus oldTile) { + final CableBusContainer tmpCB = this.getCableBus(); + this.setCableBus(oldTile.getCableBus()); + this.oldLV = oldTile.oldLV; + oldTile.setCableBus(tmpCB); + } - @Override - public double getMaxRenderDistanceSquared() - { - return 900.0; - } + @Override + public double getMaxRenderDistanceSquared() { + return 900.0; + } - @Override - public void remove() - { - super.remove(); - this.getCableBus().removeFromWorld(); - } + @Override + public void remove() { + super.remove(); + this.getCableBus().removeFromWorld(); + } - @Override - public void validate() - { - super.validate(); - TickHandler.INSTANCE.addInit( this ); - } + @Override + public void validate() { + super.validate(); + TickHandler.INSTANCE.addInit(this); + } - @Override - public IGridNode getGridNode( final AEPartLocation dir ) - { - return this.getCableBus().getGridNode( dir ); - } + @Override + public IGridNode getGridNode(final AEPartLocation dir) { + return this.getCableBus().getGridNode(dir); + } - @Override - public AECableType getCableConnectionType( final AEPartLocation side ) - { - return this.getCableBus().getCableConnectionType( side ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation side) { + return this.getCableBus().getCableConnectionType(side); + } - @Override - public float getCableConnectionLength( AECableType cable ) - { - return this.getCableBus().getCableConnectionLength( cable ); - } + @Override + public float getCableConnectionLength(AECableType cable) { + return this.getCableBus().getCableConnectionLength(cable); + } - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); - this.getCableBus().removeFromWorld(); - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + this.getCableBus().removeFromWorld(); + } - @Override - public void markForUpdate() - { - if( this.world == null ) - { - return; - } + @Override + public void markForUpdate() { + if (this.world == null) { + return; + } - final int newLV = this.getCableBus().getLightValue(); - if( newLV != this.oldLV ) - { - this.oldLV = newLV; - this.world.getLightManager().checkBlock( this.pos ); - } + final int newLV = this.getCableBus().getLightValue(); + if (newLV != this.oldLV) { + this.oldLV = newLV; + this.world.getLightManager().checkBlock(this.pos); + } - super.markForUpdate(); - } + super.markForUpdate(); + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - this.getCableBus().getDrops( drops ); - } + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + this.getCableBus().getDrops(drops); + } - @Override - public void getNoDrops( final World w, final BlockPos pos, final List drops ) - { - this.getCableBus().getNoDrops( drops ); - } + @Override + public void getNoDrops(final World w, final BlockPos pos, final List drops) { + this.getCableBus().getNoDrops(drops); + } - @Override - public void onReady() - { - super.onReady(); - if( this.getCableBus().isEmpty() ) - { - if( this.world.getTileEntity( this.pos ) == this ) - { - this.world.destroyBlock( this.pos, true ); - } - } - else - { - this.getCableBus().addToWorld(); - } - } + @Override + public void onReady() { + super.onReady(); + if (this.getCableBus().isEmpty()) { + if (this.world.getTileEntity(this.pos) == this) { + this.world.destroyBlock(this.pos, true); + } + } else { + this.getCableBus().addToWorld(); + } + } - @Override - public IFacadeContainer getFacadeContainer() - { - return this.getCableBus().getFacadeContainer(); - } + @Override + public IFacadeContainer getFacadeContainer() { + return this.getCableBus().getFacadeContainer(); + } - @Override - public boolean canAddPart( final ItemStack is, final AEPartLocation side ) - { - return this.getCableBus().canAddPart( is, side ); - } + @Override + public boolean canAddPart(final ItemStack is, final AEPartLocation side) { + return this.getCableBus().canAddPart(is, side); + } - @Override - public AEPartLocation addPart( final ItemStack is, final AEPartLocation side, final PlayerEntity player, final Hand hand ) - { - return this.getCableBus().addPart( is, side, player, hand ); - } + @Override + public AEPartLocation addPart(final ItemStack is, final AEPartLocation side, final PlayerEntity player, + final Hand hand) { + return this.getCableBus().addPart(is, side, player, hand); + } - @Override - public IPart getPart( final AEPartLocation side ) - { - return this.cb.getPart( side ); - } + @Override + public IPart getPart(final AEPartLocation side) { + return this.cb.getPart(side); + } - @Override - public IPart getPart( final Direction side ) - { - return this.getCableBus().getPart( side ); - } + @Override + public IPart getPart(final Direction side) { + return this.getCableBus().getPart(side); + } - @Override - public void removePart( final AEPartLocation side, final boolean suppressUpdate ) - { - this.getCableBus().removePart( side, suppressUpdate ); - } + @Override + public void removePart(final AEPartLocation side, final boolean suppressUpdate) { + this.getCableBus().removePart(side, suppressUpdate); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public AEColor getColor() - { - return this.getCableBus().getColor(); - } + @Override + public AEColor getColor() { + return this.getCableBus().getColor(); + } - @Override - public void clearContainer() - { - this.setCableBus( new CableBusContainer( this ) ); - } + @Override + public void clearContainer() { + this.setCableBus(new CableBusContainer(this)); + } - @Override - public boolean isBlocked( final Direction side ) - { - // TODO 1.10.2-R - Stuff. - return false; - } + @Override + public boolean isBlocked(final Direction side) { + // TODO 1.10.2-R - Stuff. + return false; + } - @Override - public SelectedPart selectPart( final Vec3d pos ) - { - return this.getCableBus().selectPart( pos ); - } + @Override + public SelectedPart selectPart(final Vec3d pos) { + return this.getCableBus().selectPart(pos); + } - @Override - public void markForSave() - { - this.saveChanges(); - } + @Override + public void markForSave() { + this.saveChanges(); + } - @Override - public void partChanged() - { - this.notifyNeighbors(); - } + @Override + public void partChanged() { + this.notifyNeighbors(); + } - @Override - public boolean hasRedstone( final AEPartLocation side ) - { - return this.getCableBus().hasRedstone( side ); - } + @Override + public boolean hasRedstone(final AEPartLocation side) { + return this.getCableBus().hasRedstone(side); + } - @Override - public boolean isEmpty() - { - return this.getCableBus().isEmpty(); - } + @Override + public boolean isEmpty() { + return this.getCableBus().isEmpty(); + } - @Override - public Set getLayerFlags() - { - return this.getCableBus().getLayerFlags(); - } + @Override + public Set getLayerFlags() { + return this.getCableBus().getLayerFlags(); + } - @Override - public void cleanup() - { - this.getWorld().removeBlock(this.pos, false); - } + @Override + public void cleanup() { + this.getWorld().removeBlock(this.pos, false); + } - @Override - public void notifyNeighbors() - { - if( this.world != null && this.world.isBlockLoaded( this.pos ) && !CableBusContainer.isLoading() ) - { - Platform.notifyBlocksOfNeighbors( this.world, this.pos ); - } - } + @Override + public void notifyNeighbors() { + if (this.world != null && this.world.isBlockLoaded(this.pos) && !CableBusContainer.isLoading()) { + Platform.notifyBlocksOfNeighbors(this.world, this.pos); + } + } - @Override - public boolean isInWorld() - { - return this.getCableBus().isInWorld(); - } + @Override + public boolean isInWorld() { + return this.getCableBus().isInWorld(); + } - @Override - public boolean recolourBlock( final Direction side, final AEColor colour, final PlayerEntity who ) - { - return this.getCableBus().recolourBlock( side, colour, who ); - } + @Override + public boolean recolourBlock(final Direction side, final AEColor colour, final PlayerEntity who) { + return this.getCableBus().recolourBlock(side, colour, who); + } - public CableBusContainer getCableBus() - { - return this.cb; - } + public CableBusContainer getCableBus() { + return this.cb; + } - private void setCableBus( final CableBusContainer cb ) - { - this.cb = cb; - } + private void setCableBus(final CableBusContainer cb) { + this.cb = cb; + } - @Override - public LazyOptional getCapability(Capability capabilityClass, @Nullable Direction fromSide ) - { - // Note that null will be translated to INTERNAL here - AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide ); + @Override + public LazyOptional getCapability(Capability capabilityClass, @Nullable Direction fromSide) { + // Note that null will be translated to INTERNAL here + AEPartLocation partLocation = AEPartLocation.fromFacing(fromSide); - IPart part = this.getPart( partLocation ); - LazyOptional result = part == null ? LazyOptional.empty() : part.getCapability(capabilityClass); + IPart part = this.getPart(partLocation); + LazyOptional result = part == null ? LazyOptional.empty() : part.getCapability(capabilityClass); - if( result != null ) - { - return result; - } + if (result != null) { + return result; + } - return super.getCapability( capabilityClass, fromSide ); - } + return super.getCapability(capabilityClass, fromSide); + } - @Nonnull - @Override - public IModelData getModelData() { - World world = getWorld(); - if (world == null) { - return EmptyModelData.INSTANCE; - } + @Nonnull + @Override + public IModelData getModelData() { + World world = getWorld(); + if (world == null) { + return EmptyModelData.INSTANCE; + } - CableBusRenderState renderState = this.cb.getRenderState(); - renderState.setWorld(world); - renderState.setPos(pos); - return new ModelDataMap.Builder() - .withInitial(CableBusRenderState.PROPERTY, renderState) - .build(); + CableBusRenderState renderState = this.cb.getRenderState(); + renderState.setWorld(world); + renderState.setPos(pos); + return new ModelDataMap.Builder().withInitial(CableBusRenderState.PROPERTY, renderState).build(); - } + } } diff --git a/src/main/java/appeng/tile/networking/TileCableBusTESR.java b/src/main/java/appeng/tile/networking/TileCableBusTESR.java index ac061041d..8ca2df45b 100644 --- a/src/main/java/appeng/tile/networking/TileCableBusTESR.java +++ b/src/main/java/appeng/tile/networking/TileCableBusTESR.java @@ -18,24 +18,22 @@ package appeng.tile.networking; - -import appeng.block.networking.BlockCableBus; import net.minecraft.tileentity.TileEntityType; +import appeng.block.networking.BlockCableBus; -public class TileCableBusTESR extends TileCableBus -{ +public class TileCableBusTESR extends TileCableBus { - public TileCableBusTESR(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - } + public TileCableBusTESR(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } - /** - * Changes this tile to the non-TESR version, if none of the parts require dynamic rendering. - */ - @Override - protected void updateTileSetting() - { + /** + * Changes this tile to the non-TESR version, if none of the parts require + * dynamic rendering. + */ + @Override + protected void updateTileSetting() { // FIXME if( !this.getCableBus().isRequiresDynamicRender() ) // FIXME { // FIXME try @@ -49,5 +47,5 @@ public class TileCableBusTESR extends TileCableBus // FIXME // FIXME } // FIXME } - } + } } diff --git a/src/main/java/appeng/tile/networking/TileController.java b/src/main/java/appeng/tile/networking/TileController.java index d8d3acf8b..be6af9254 100644 --- a/src/main/java/appeng/tile/networking/TileController.java +++ b/src/main/java/appeng/tile/networking/TileController.java @@ -18,7 +18,6 @@ package appeng.tile.networking; - import java.util.EnumSet; import net.minecraft.item.ItemStack; @@ -46,176 +45,148 @@ import appeng.me.GridAccessException; import appeng.tile.grid.AENetworkPowerTile; import appeng.util.inv.InvOperation; +public class TileController extends AENetworkPowerTile { + private boolean isValid = false; -public class TileController extends AENetworkPowerTile -{ - private boolean isValid = false; + public TileController(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.setInternalMaxPower(8000); + this.setInternalPublicPowerStorage(true); + this.getProxy().setIdlePowerUsage(3); + this.getProxy().setFlags(GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY); + } - public TileController(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.setInternalMaxPower( 8000 ); - this.setInternalPublicPowerStorage( true ); - this.getProxy().setIdlePowerUsage( 3 ); - this.getProxy().setFlags( GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.DENSE_SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.DENSE_SMART; - } + @Override + public void onReady() { + this.onNeighborChange(true); + super.onReady(); + } - @Override - public void onReady() - { - this.onNeighborChange( true ); - super.onReady(); - } + public void onNeighborChange(final boolean force) { + final boolean xx = this.checkController(this.pos.offset(Direction.EAST)) + && this.checkController(this.pos.offset(Direction.WEST)); + final boolean yy = this.checkController(this.pos.offset(Direction.UP)) + && this.checkController(this.pos.offset(Direction.DOWN)); + final boolean zz = this.checkController(this.pos.offset(Direction.NORTH)) + && this.checkController(this.pos.offset(Direction.SOUTH)); - public void onNeighborChange( final boolean force ) - { - final boolean xx = this.checkController( this.pos.offset( Direction.EAST ) ) && this.checkController( this.pos.offset( Direction.WEST ) ); - final boolean yy = this.checkController( this.pos.offset( Direction.UP ) ) && this.checkController( this.pos.offset( Direction.DOWN ) ); - final boolean zz = this.checkController( this.pos.offset( Direction.NORTH ) ) && this.checkController( this.pos.offset( Direction.SOUTH ) ); + // int meta = world.getBlockMetadata( xCoord, yCoord, zCoord ); + // boolean hasPower = meta > 0; + // boolean isConflict = meta == 2; - // int meta = world.getBlockMetadata( xCoord, yCoord, zCoord ); - // boolean hasPower = meta > 0; - // boolean isConflict = meta == 2; + final boolean oldValid = this.isValid; - final boolean oldValid = this.isValid; + this.isValid = (xx && !yy && !zz) || (!xx && yy && !zz) || (!xx && !yy && zz) + || ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) <= 1); - this.isValid = ( xx && !yy && !zz ) || ( !xx && yy && !zz ) || ( !xx && !yy && zz ) || ( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) <= 1 ); + if (oldValid != this.isValid || force) { + if (this.isValid) { + this.getProxy().setValidSides(EnumSet.allOf(Direction.class)); + } else { + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } - if( oldValid != this.isValid || force ) - { - if( this.isValid ) - { - this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) ); - } - else - { - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } + this.updateMeta(); + } - this.updateMeta(); - } + } - } + private void updateMeta() { + if (!this.getProxy().isReady()) { + return; + } - private void updateMeta() - { - if( !this.getProxy().isReady() ) - { - return; - } + ControllerBlockState metaState = ControllerBlockState.offline; - ControllerBlockState metaState = ControllerBlockState.offline; + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + metaState = ControllerBlockState.online; - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - metaState = ControllerBlockState.online; + if (this.getProxy().getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT) { + metaState = ControllerBlockState.conflicted; + } + } + } catch (final GridAccessException e) { + metaState = ControllerBlockState.offline; + } - if( this.getProxy().getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT ) - { - metaState = ControllerBlockState.conflicted; - } - } - } - catch( final GridAccessException e ) - { - metaState = ControllerBlockState.offline; - } + if (this.checkController(this.pos) + && this.world.getBlockState(this.pos).get(BlockController.CONTROLLER_STATE) != metaState) { + this.world.setBlockState(this.pos, + this.world.getBlockState(this.pos).with(BlockController.CONTROLLER_STATE, metaState)); + } - if( this.checkController( this.pos ) && this.world.getBlockState( this.pos ).get( BlockController.CONTROLLER_STATE ) != metaState ) - { - this.world.setBlockState( this.pos, this.world.getBlockState( this.pos ).with( BlockController.CONTROLLER_STATE, metaState ) ); - } + } - } + @Override + protected double getFunnelPowerDemand(final double maxReceived) { + try { + final IEnergyGrid grid = this.getProxy().getEnergy(); - @Override - protected double getFunnelPowerDemand( final double maxReceived ) - { - try - { - final IEnergyGrid grid = this.getProxy().getEnergy(); + return grid.getEnergyDemand(maxReceived); + } catch (final GridAccessException e) { + // no grid? use local... + return super.getFunnelPowerDemand(maxReceived); + } + } - return grid.getEnergyDemand( maxReceived ); - } - catch( final GridAccessException e ) - { - // no grid? use local... - return super.getFunnelPowerDemand( maxReceived ); - } - } + @Override + protected double funnelPowerIntoStorage(final double power, final Actionable mode) { + try { + final IEnergyGrid grid = this.getProxy().getEnergy(); + final double leftOver = grid.injectPower(power, mode); - @Override - protected double funnelPowerIntoStorage( final double power, final Actionable mode ) - { - try - { - final IEnergyGrid grid = this.getProxy().getEnergy(); - final double leftOver = grid.injectPower( power, mode ); + return leftOver; + } catch (final GridAccessException e) { + // no grid? use local... + return super.funnelPowerIntoStorage(power, mode); + } + } - return leftOver; - } - catch( final GridAccessException e ) - { - // no grid? use local... - return super.funnelPowerIntoStorage( power, mode ); - } - } + @Override + protected void PowerEvent(final PowerEventType x) { + try { + this.getProxy().getGrid().postEvent(new MENetworkPowerStorage(this, x)); + } catch (final GridAccessException e) { + // not ready! + } + } - @Override - protected void PowerEvent( final PowerEventType x ) - { - try - { - this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, x ) ); - } - catch( final GridAccessException e ) - { - // not ready! - } - } + @MENetworkEventSubscribe + public void onControllerChange(final MENetworkControllerChange status) { + this.updateMeta(); + } - @MENetworkEventSubscribe - public void onControllerChange( final MENetworkControllerChange status ) - { - this.updateMeta(); - } + @MENetworkEventSubscribe + public void onPowerChange(final MENetworkPowerStatusChange status) { + this.updateMeta(); + } - @MENetworkEventSubscribe - public void onPowerChange( final MENetworkPowerStatusChange status ) - { - this.updateMeta(); - } + @Override + public IItemHandler getInternalInventory() { + return EmptyHandler.INSTANCE; + } - @Override - public IItemHandler getInternalInventory() - { - return EmptyHandler.INSTANCE; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - } + /** + * Check for a controller at this coordinates as well as is it loaded. + * + * @return true if there is a loaded controller + */ + private boolean checkController(final BlockPos pos) { + if (this.world.getChunkProvider().isChunkLoaded(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4))) { + return this.world.getTileEntity(pos) instanceof TileController; + } - /** - * Check for a controller at this coordinates as well as is it loaded. - * - * @return true if there is a loaded controller - */ - private boolean checkController( final BlockPos pos ) - { - if( this.world.getChunkProvider().isChunkLoaded( new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4)) ) - { - return this.world.getTileEntity( pos ) instanceof TileController; - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/tile/networking/TileCreativeEnergyCell.java b/src/main/java/appeng/tile/networking/TileCreativeEnergyCell.java index d9b38fea2..309529205 100644 --- a/src/main/java/appeng/tile/networking/TileCreativeEnergyCell.java +++ b/src/main/java/appeng/tile/networking/TileCreativeEnergyCell.java @@ -18,6 +18,7 @@ package appeng.tile.networking; +import net.minecraft.tileentity.TileEntityType; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; @@ -26,56 +27,46 @@ import appeng.api.networking.energy.IAEPowerStorage; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.tile.grid.AENetworkTile; -import net.minecraft.tileentity.TileEntityType; +public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage { -public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage -{ + public TileCreativeEnergyCell(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setIdlePowerUsage(0); + } - public TileCreativeEnergyCell(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setIdlePowerUsage( 0 ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + public double injectAEPower(final double amt, final Actionable mode) { + return 0; + } - @Override - public double injectAEPower( final double amt, final Actionable mode ) - { - return 0; - } + @Override + public double getAEMaxPower() { + return Long.MAX_VALUE / 10000; + } - @Override - public double getAEMaxPower() - { - return Long.MAX_VALUE / 10000; - } + @Override + public double getAECurrentPower() { + return Long.MAX_VALUE / 10000; + } - @Override - public double getAECurrentPower() - { - return Long.MAX_VALUE / 10000; - } + @Override + public boolean isAEPublicPowerStorage() { + return true; + } - @Override - public boolean isAEPublicPowerStorage() - { - return true; - } + @Override + public AccessRestriction getPowerFlow() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getPowerFlow() - { - return AccessRestriction.READ_WRITE; - } - - @Override - public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm ) - { - return amt; - } + @Override + public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) { + return amt; + } } diff --git a/src/main/java/appeng/tile/networking/TileDenseEnergyCell.java b/src/main/java/appeng/tile/networking/TileDenseEnergyCell.java index 37e986386..ae4d6252f 100644 --- a/src/main/java/appeng/tile/networking/TileDenseEnergyCell.java +++ b/src/main/java/appeng/tile/networking/TileDenseEnergyCell.java @@ -18,15 +18,13 @@ package appeng.tile.networking; - import net.minecraft.tileentity.TileEntityType; -public class TileDenseEnergyCell extends TileEnergyCell -{ +public class TileDenseEnergyCell extends TileEnergyCell { - public TileDenseEnergyCell(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.setInternalMaxPower( 200000 * 8 ); - } + public TileDenseEnergyCell(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.setInternalMaxPower(200000 * 8); + } } diff --git a/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java b/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java index 33929e591..0e775136b 100644 --- a/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java +++ b/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java @@ -18,7 +18,6 @@ package appeng.tile.networking; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.items.IItemHandler; @@ -32,62 +31,50 @@ import appeng.me.GridAccessException; import appeng.tile.grid.AENetworkPowerTile; import appeng.util.inv.InvOperation; +public class TileEnergyAcceptor extends AENetworkPowerTile { -public class TileEnergyAcceptor extends AENetworkPowerTile -{ + public TileEnergyAcceptor(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setIdlePowerUsage(0.0); + this.setInternalMaxPower(0); + } - public TileEnergyAcceptor(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setIdlePowerUsage( 0.0 ); - this.setInternalMaxPower( 0 ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + protected double getFunnelPowerDemand(final double maxRequired) { + try { + final IEnergyGrid grid = this.getProxy().getEnergy(); - @Override - protected double getFunnelPowerDemand( final double maxRequired ) - { - try - { - final IEnergyGrid grid = this.getProxy().getEnergy(); + return grid.getEnergyDemand(maxRequired); + } catch (final GridAccessException e) { + return this.getInternalMaxPower(); + } + } - return grid.getEnergyDemand( maxRequired ); - } - catch( final GridAccessException e ) - { - return this.getInternalMaxPower(); - } - } + @Override + protected double funnelPowerIntoStorage(final double power, final Actionable mode) { + try { + final IEnergyGrid grid = this.getProxy().getEnergy(); + final double leftOver = grid.injectPower(power, mode); - @Override - protected double funnelPowerIntoStorage( final double power, final Actionable mode ) - { - try - { - final IEnergyGrid grid = this.getProxy().getEnergy(); - final double leftOver = grid.injectPower( power, mode ); + return leftOver; + } catch (final GridAccessException e) { + return super.funnelPowerIntoStorage(power, mode); + } + } - return leftOver; - } - catch( final GridAccessException e ) - { - return super.funnelPowerIntoStorage( power, mode ); - } - } + @Override + public IItemHandler getInternalInventory() { + return EmptyHandler.INSTANCE; + } - @Override - public IItemHandler getInternalInventory() - { - return EmptyHandler.INSTANCE; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - - } + } } diff --git a/src/main/java/appeng/tile/networking/TileEnergyCell.java b/src/main/java/appeng/tile/networking/TileEnergyCell.java index afde5fadf..bc5ecf35c 100644 --- a/src/main/java/appeng/tile/networking/TileEnergyCell.java +++ b/src/main/java/appeng/tile/networking/TileEnergyCell.java @@ -18,8 +18,8 @@ package appeng.tile.networking; - import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; @@ -33,225 +33,189 @@ import appeng.block.networking.BlockEnergyCell; import appeng.me.GridAccessException; import appeng.tile.grid.AENetworkTile; import appeng.util.SettingsFrom; -import net.minecraft.tileentity.TileEntityType; +public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage { -public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage -{ + private double internalCurrentPower = 0.0; + private double internalMaxPower = 200000.0; - private double internalCurrentPower = 0.0; - private double internalMaxPower = 200000.0; + private byte currentMeta = -1; - private byte currentMeta = -1; + public TileEnergyCell(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setIdlePowerUsage(0); + } - public TileEnergyCell(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setIdlePowerUsage( 0 ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.COVERED; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.COVERED; - } + @Override + public void onReady() { + super.onReady(); + final int value = this.world.getBlockState(this.pos).get(BlockEnergyCell.ENERGY_STORAGE); + this.currentMeta = (byte) value; + this.changePowerLevel(); + } - @Override - public void onReady() - { - super.onReady(); - final int value = this.world.getBlockState( this.pos ).get( BlockEnergyCell.ENERGY_STORAGE ); - this.currentMeta = (byte) value; - this.changePowerLevel(); - } + /** + * Given a fill factor, return the storage level (0-7) used for the state of the + * block. This is also used for determining the item model. + */ + public static int getStorageLevelFromFillFactor(double fillFactor) { + byte boundMetadata = (byte) (8.0 * (fillFactor)); - /** - * Given a fill factor, return the storage level (0-7) used for the state of the block. - * This is also used for determining the item model. - */ - public static int getStorageLevelFromFillFactor( double fillFactor ) - { - byte boundMetadata = (byte) ( 8.0 * ( fillFactor ) ); + if (boundMetadata > 7) { + boundMetadata = 7; + } + if (boundMetadata < 0) { + boundMetadata = 0; + } + return boundMetadata; + } - if( boundMetadata > 7 ) - { - boundMetadata = 7; - } - if( boundMetadata < 0 ) - { - boundMetadata = 0; - } - return boundMetadata; - } + private void changePowerLevel() { + if (this.notLoaded() || this.isRemoved()) { + return; + } - private void changePowerLevel() - { - if( this.notLoaded() || this.isRemoved() ) - { - return; - } + int storageLevel = getStorageLevelFromFillFactor(this.internalCurrentPower / this.getInternalMaxPower()); - int storageLevel = getStorageLevelFromFillFactor( this.internalCurrentPower / this.getInternalMaxPower() ); + if (this.currentMeta != storageLevel) { + this.currentMeta = (byte) storageLevel; + this.world.setBlockState(this.pos, + this.world.getBlockState(this.pos).with(BlockEnergyCell.ENERGY_STORAGE, storageLevel)); + } + } - if( this.currentMeta != storageLevel ) - { - this.currentMeta = (byte) storageLevel; - this.world.setBlockState( this.pos, this.world.getBlockState( this.pos ).with( BlockEnergyCell.ENERGY_STORAGE, storageLevel ) ); - } - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putDouble("internalCurrentPower", this.internalCurrentPower); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putDouble("internalCurrentPower", this.internalCurrentPower); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.internalCurrentPower = data.getDouble("internalCurrentPower"); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.internalCurrentPower = data.getDouble( "internalCurrentPower" ); - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + public void uploadSettings(final SettingsFrom from, final CompoundNBT compound) { + if (from == SettingsFrom.DISMANTLE_ITEM) { + this.internalCurrentPower = compound.getDouble("internalCurrentPower"); + } + } - @Override - public void uploadSettings( final SettingsFrom from, final CompoundNBT compound ) - { - if( from == SettingsFrom.DISMANTLE_ITEM ) - { - this.internalCurrentPower = compound.getDouble( "internalCurrentPower" ); - } - } + @Override + public CompoundNBT downloadSettings(final SettingsFrom from) { + if (from == SettingsFrom.DISMANTLE_ITEM) { + final CompoundNBT tag = new CompoundNBT(); + tag.putDouble("internalCurrentPower", this.internalCurrentPower); + tag.putDouble("internalMaxPower", this.getInternalMaxPower()); // used for tool tip. + return tag; + } + return null; + } - @Override - public CompoundNBT downloadSettings( final SettingsFrom from ) - { - if( from == SettingsFrom.DISMANTLE_ITEM ) - { - final CompoundNBT tag = new CompoundNBT(); - tag.putDouble("internalCurrentPower", this.internalCurrentPower); - tag.putDouble("internalMaxPower", this.getInternalMaxPower()); // used for tool tip. - return tag; - } - return null; - } + @Override + public final double injectAEPower(double amt, final Actionable mode) { + if (mode == Actionable.SIMULATE) { + final double fakeBattery = this.internalCurrentPower + amt; + if (fakeBattery > this.getInternalMaxPower()) { + return fakeBattery - this.getInternalMaxPower(); + } - @Override - public final double injectAEPower( double amt, final Actionable mode ) - { - if( mode == Actionable.SIMULATE ) - { - final double fakeBattery = this.internalCurrentPower + amt; - if( fakeBattery > this.getInternalMaxPower() ) - { - return fakeBattery - this.getInternalMaxPower(); - } + return 0; + } - return 0; - } + if (this.internalCurrentPower < 0.01 && amt > 0.01) { + this.getProxy().getNode().getGrid() + .postEvent(new MENetworkPowerStorage(this, PowerEventType.PROVIDE_POWER)); + } - if( this.internalCurrentPower < 0.01 && amt > 0.01 ) - { - this.getProxy().getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) ); - } + this.internalCurrentPower += amt; + if (this.internalCurrentPower > this.getInternalMaxPower()) { + amt = this.internalCurrentPower - this.getInternalMaxPower(); + this.internalCurrentPower = this.getInternalMaxPower(); - this.internalCurrentPower += amt; - if( this.internalCurrentPower > this.getInternalMaxPower() ) - { - amt = this.internalCurrentPower - this.getInternalMaxPower(); - this.internalCurrentPower = this.getInternalMaxPower(); + this.changePowerLevel(); + return amt; + } - this.changePowerLevel(); - return amt; - } + this.changePowerLevel(); + return 0; + } - this.changePowerLevel(); - return 0; - } + @Override + public double getAEMaxPower() { + return this.getInternalMaxPower(); + } - @Override - public double getAEMaxPower() - { - return this.getInternalMaxPower(); - } + @Override + public double getAECurrentPower() { + return this.internalCurrentPower; + } - @Override - public double getAECurrentPower() - { - return this.internalCurrentPower; - } + @Override + public boolean isAEPublicPowerStorage() { + return true; + } - @Override - public boolean isAEPublicPowerStorage() - { - return true; - } + @Override + public AccessRestriction getPowerFlow() { + return AccessRestriction.READ_WRITE; + } - @Override - public AccessRestriction getPowerFlow() - { - return AccessRestriction.READ_WRITE; - } + @Override + public final double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) { + return pm.divide(this.extractAEPower(pm.multiply(amt), mode)); + } - @Override - public final double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm ) - { - return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) ); - } + private double extractAEPower(double amt, final Actionable mode) { + if (mode == Actionable.SIMULATE) { + if (this.internalCurrentPower > amt) { + return amt; + } + return this.internalCurrentPower; + } - private double extractAEPower( double amt, final Actionable mode ) - { - if( mode == Actionable.SIMULATE ) - { - if( this.internalCurrentPower > amt ) - { - return amt; - } - return this.internalCurrentPower; - } + final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001; - final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001; + if (wasFull && amt > 0.001) { + try { + this.getProxy().getGrid().postEvent(new MENetworkPowerStorage(this, PowerEventType.REQUEST_POWER)); + } catch (final GridAccessException ignored) { - if( wasFull && amt > 0.001 ) - { - try - { - this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) ); - } - catch( final GridAccessException ignored ) - { + } + } - } - } + if (this.internalCurrentPower > amt) { + this.internalCurrentPower -= amt; - if( this.internalCurrentPower > amt ) - { - this.internalCurrentPower -= amt; + this.changePowerLevel(); + return amt; + } - this.changePowerLevel(); - return amt; - } + amt = this.internalCurrentPower; + this.internalCurrentPower = 0; - amt = this.internalCurrentPower; - this.internalCurrentPower = 0; + this.changePowerLevel(); + return amt; + } - this.changePowerLevel(); - return amt; - } + private double getInternalMaxPower() { + return this.internalMaxPower; + } - private double getInternalMaxPower() - { - return this.internalMaxPower; - } - - void setInternalMaxPower( final double internalMaxPower ) - { - this.internalMaxPower = internalMaxPower; - } + void setInternalMaxPower(final double internalMaxPower) { + this.internalMaxPower = internalMaxPower; + } } diff --git a/src/main/java/appeng/tile/networking/TileWireless.java b/src/main/java/appeng/tile/networking/TileWireless.java index 2553aa895..c79cdec3f 100644 --- a/src/main/java/appeng/tile/networking/TileWireless.java +++ b/src/main/java/appeng/tile/networking/TileWireless.java @@ -18,7 +18,6 @@ package appeng.tile.networking; - import java.io.IOException; import java.util.EnumSet; @@ -47,171 +46,142 @@ import appeng.util.Platform; import appeng.util.inv.InvOperation; import appeng.util.inv.filter.AEItemDefinitionFilter; +public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoint, IPowerChannelState { -public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoint, IPowerChannelState -{ + public static final int POWERED_FLAG = 1; + public static final int CHANNEL_FLAG = 2; - public static final int POWERED_FLAG = 1; - public static final int CHANNEL_FLAG = 2; + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1); - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 ); + private int clientFlags = 0; - private int clientFlags = 0; + public TileWireless(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.inv.setFilter(new AEItemDefinitionFilter(AEApi.instance().definitions().materials().wirelessBooster())); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } - public TileWireless(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.inv.setFilter( new AEItemDefinitionFilter( AEApi.instance().definitions().materials().wirelessBooster() ) ); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } + @Override + public void setOrientation(final Direction inForward, final Direction inUp) { + super.setOrientation(inForward, inUp); + this.getProxy().setValidSides(EnumSet.of(this.getForward().getOpposite())); + } - @Override - public void setOrientation( final Direction inForward, final Direction inUp ) - { - super.setOrientation( inForward, inUp ); - this.getProxy().setValidSides( EnumSet.of( this.getForward().getOpposite() ) ); - } + @MENetworkEventSubscribe + public void chanRender(final MENetworkChannelsChanged c) { + this.markForUpdate(); + } - @MENetworkEventSubscribe - public void chanRender( final MENetworkChannelsChanged c ) - { - this.markForUpdate(); - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.markForUpdate(); + } - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.markForUpdate(); - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final int old = this.getClientFlags(); + this.setClientFlags(data.readByte()); - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final int old = this.getClientFlags(); - this.setClientFlags( data.readByte() ); + return old != this.getClientFlags() || c; + } - return old != this.getClientFlags() || c; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + this.setClientFlags(0); - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - this.setClientFlags( 0 ); + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + this.setClientFlags(this.getClientFlags() | POWERED_FLAG); + } - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - this.setClientFlags( this.getClientFlags() | POWERED_FLAG ); - } + if (this.getProxy().getNode().meetsChannelRequirements()) { + this.setClientFlags(this.getClientFlags() | CHANNEL_FLAG); + } + } catch (final GridAccessException e) { + // meh + } - if( this.getProxy().getNode().meetsChannelRequirements() ) - { - this.setClientFlags( this.getClientFlags() | CHANNEL_FLAG ); - } - } - catch( final GridAccessException e ) - { - // meh - } + data.writeByte((byte) this.getClientFlags()); + } - data.writeByte( (byte) this.getClientFlags() ); - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + // :P + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - // :P - } + @Override + public void onReady() { + this.updatePower(); + super.onReady(); + } - @Override - public void onReady() - { - this.updatePower(); - super.onReady(); - } + private void updatePower() { + this.getProxy().setIdlePowerUsage(AEConfig.instance().wireless_getPowerDrain(this.getBoosters())); + } - private void updatePower() - { - this.getProxy().setIdlePowerUsage( AEConfig.instance().wireless_getPowerDrain( this.getBoosters() ) ); - } + private int getBoosters() { + final ItemStack boosters = this.inv.getStackInSlot(0); + return boosters == null ? 0 : boosters.getCount(); + } - private int getBoosters() - { - final ItemStack boosters = this.inv.getStackInSlot( 0 ); - return boosters == null ? 0 : boosters.getCount(); - } + @Override + public void saveChanges() { + this.updatePower(); + super.saveChanges(); + } - @Override - public void saveChanges() - { - this.updatePower(); - super.saveChanges(); - } + @Override + public double getRange() { + return AEConfig.instance().wireless_getMaxRange(this.getBoosters()); + } - @Override - public double getRange() - { - return AEConfig.instance().wireless_getMaxRange( this.getBoosters() ); - } + @Override + public boolean isActive() { + if (isRemote()) { + return this.isPowered() && (CHANNEL_FLAG == (this.getClientFlags() & CHANNEL_FLAG)); + } - @Override - public boolean isActive() - { - if( isRemote() ) - { - return this.isPowered() && ( CHANNEL_FLAG == ( this.getClientFlags() & CHANNEL_FLAG ) ); - } + return this.getProxy().isActive(); + } - return this.getProxy().isActive(); - } + @Override + public IGrid getGrid() { + try { + return this.getProxy().getGrid(); + } catch (final GridAccessException e) { + return null; + } + } - @Override - public IGrid getGrid() - { - try - { - return this.getProxy().getGrid(); - } - catch( final GridAccessException e ) - { - return null; - } - } + @Override + public boolean isPowered() { + return POWERED_FLAG == (this.getClientFlags() & POWERED_FLAG); + } - @Override - public boolean isPowered() - { - return POWERED_FLAG == ( this.getClientFlags() & POWERED_FLAG ); - } + public int getClientFlags() { + return this.clientFlags; + } - public int getClientFlags() - { - return this.clientFlags; - } - - private void setClientFlags( final int clientFlags ) - { - this.clientFlags = clientFlags; - } + private void setClientFlags(final int clientFlags) { + this.clientFlags = clientFlags; + } } diff --git a/src/main/java/appeng/tile/powersink/AEBasePoweredTile.java b/src/main/java/appeng/tile/powersink/AEBasePoweredTile.java index f65737492..f754609f5 100644 --- a/src/main/java/appeng/tile/powersink/AEBasePoweredTile.java +++ b/src/main/java/appeng/tile/powersink/AEBasePoweredTile.java @@ -18,13 +18,13 @@ package appeng.tile.powersink; - import java.util.EnumSet; import java.util.Set; import javax.annotation.Nonnull; import com.google.common.collect.ImmutableSet; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; @@ -41,262 +41,223 @@ import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType; import appeng.capabilities.Capabilities; import appeng.tile.AEBaseInvTile; +public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink { -public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink -{ + // values that determine general function, are set by inheriting classes if + // needed. These should generally remain static. + private double internalMaxPower = 10000; + private boolean internalPublicPowerStorage = false; + private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE; + // the current power buffer. + private double internalCurrentPower = 0; + private static final Set ALL_SIDES = ImmutableSet.copyOf(EnumSet.allOf(Direction.class)); + private Set internalPowerSides = ALL_SIDES; + private final IEnergyStorage forgeEnergyAdapter; + // Cache the optional to not continuously re-allocate it or the supplier + private final LazyOptional forgeEnergyAdapterOptional; - // values that determine general function, are set by inheriting classes if - // needed. These should generally remain static. - private double internalMaxPower = 10000; - private boolean internalPublicPowerStorage = false; - private AccessRestriction internalPowerFlow = AccessRestriction.READ_WRITE; - // the current power buffer. - private double internalCurrentPower = 0; - private static final Set ALL_SIDES = ImmutableSet.copyOf(EnumSet.allOf( Direction.class )); - private Set internalPowerSides = ALL_SIDES; - private final IEnergyStorage forgeEnergyAdapter; - // Cache the optional to not continuously re-allocate it or the supplier - private final LazyOptional forgeEnergyAdapterOptional; + // IC2 private IC2PowerSink ic2Sink; - // IC2 private IC2PowerSink ic2Sink; + public AEBasePoweredTile(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.forgeEnergyAdapter = new ForgeEnergyAdapter(this); + this.forgeEnergyAdapterOptional = LazyOptional.of(() -> forgeEnergyAdapter); + // IC2 this.ic2Sink = Integrations.ic2().createPowerSink( this, this ); + // IC2 this.ic2Sink.setValidFaces( this.internalPowerSides ); + } - public AEBasePoweredTile(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.forgeEnergyAdapter = new ForgeEnergyAdapter( this ); - this.forgeEnergyAdapterOptional = LazyOptional.of(() -> forgeEnergyAdapter); - // IC2 this.ic2Sink = Integrations.ic2().createPowerSink( this, this ); - // IC2 this.ic2Sink.setValidFaces( this.internalPowerSides ); - } + protected final Set getPowerSides() { + return this.internalPowerSides; + } - protected final Set getPowerSides() - { - return this.internalPowerSides; - } + protected void setPowerSides(final Set sides) { + this.internalPowerSides = ImmutableSet.copyOf(sides); + // IC2 this.ic2Sink.setValidFaces( sides ); + // trigger re-calc! + } - protected void setPowerSides( final Set sides ) - { - this.internalPowerSides = ImmutableSet.copyOf(sides); - // IC2 this.ic2Sink.setValidFaces( sides ); - // trigger re-calc! - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putDouble("internalCurrentPower", this.getInternalCurrentPower()); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putDouble("internalCurrentPower", this.getInternalCurrentPower()); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.setInternalCurrentPower(data.getDouble("internalCurrentPower")); + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) ); - } + @Override + public final double getExternalPowerDemand(final PowerUnits externalUnit, final double maxPowerRequired) { + return PowerUnits.AE.convertTo(externalUnit, + Math.max(0.0, this.getFunnelPowerDemand(externalUnit.convertTo(PowerUnits.AE, maxPowerRequired)))); + } - @Override - public final double getExternalPowerDemand( final PowerUnits externalUnit, final double maxPowerRequired ) - { - return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, this.getFunnelPowerDemand( externalUnit.convertTo( PowerUnits.AE, maxPowerRequired ) ) ) ); - } + protected double getFunnelPowerDemand(final double maxRequired) { + return this.getInternalMaxPower() - this.getInternalCurrentPower(); + } - protected double getFunnelPowerDemand( final double maxRequired ) - { - return this.getInternalMaxPower() - this.getInternalCurrentPower(); - } + @Override + public final double injectExternalPower(final PowerUnits input, final double amt, Actionable mode) { + return PowerUnits.AE.convertTo(input, this.funnelPowerIntoStorage(input.convertTo(PowerUnits.AE, amt), mode)); + } - @Override - public final double injectExternalPower( final PowerUnits input, final double amt, Actionable mode ) - { - return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), mode ) ); - } + protected double funnelPowerIntoStorage(final double power, final Actionable mode) { + return this.injectAEPower(power, mode); + } - protected double funnelPowerIntoStorage( final double power, final Actionable mode ) - { - return this.injectAEPower( power, mode ); - } + @Override + public final double injectAEPower(double amt, final Actionable mode) { + if (amt < 0.000001) { + return 0; + } - @Override - public final double injectAEPower( double amt, final Actionable mode ) - { - if( amt < 0.000001 ) - { - return 0; - } + final double required = this.getAEMaxPower() - this.getAECurrentPower(); + final double insertable = Math.min(required, amt); - final double required = this.getAEMaxPower() - this.getAECurrentPower(); - final double insertable = Math.min( required, amt ); + if (mode == Actionable.MODULATE) { + if (this.getInternalCurrentPower() < 0.01 && insertable > 0.01) { + this.PowerEvent(PowerEventType.PROVIDE_POWER); + } - if( mode == Actionable.MODULATE ) - { - if( this.getInternalCurrentPower() < 0.01 && insertable > 0.01 ) - { - this.PowerEvent( PowerEventType.PROVIDE_POWER ); - } + this.setInternalCurrentPower(this.getInternalCurrentPower() + insertable); + } - this.setInternalCurrentPower( this.getInternalCurrentPower() + insertable ); - } + return amt - insertable; + } - return amt - insertable; - } + protected void PowerEvent(final PowerEventType x) { + // nothing. + } - protected void PowerEvent( final PowerEventType x ) - { - // nothing. - } + @Override + public final double getAEMaxPower() { + return this.getInternalMaxPower(); + } - @Override - public final double getAEMaxPower() - { - return this.getInternalMaxPower(); - } + @Override + public final double getAECurrentPower() { + return this.getInternalCurrentPower(); + } - @Override - public final double getAECurrentPower() - { - return this.getInternalCurrentPower(); - } + @Override + public final boolean isAEPublicPowerStorage() { + return this.isInternalPublicPowerStorage(); + } - @Override - public final boolean isAEPublicPowerStorage() - { - return this.isInternalPublicPowerStorage(); - } + @Override + public final AccessRestriction getPowerFlow() { + return this.getInternalPowerFlow(); + } - @Override - public final AccessRestriction getPowerFlow() - { - return this.getInternalPowerFlow(); - } + @Override + public final double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier multiplier) { + return multiplier.divide(this.extractAEPower(multiplier.multiply(amt), mode)); + } - @Override - public final double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier multiplier ) - { - return multiplier.divide( this.extractAEPower( multiplier.multiply( amt ), mode ) ); - } + protected double extractAEPower(double amt, final Actionable mode) { + if (mode == Actionable.SIMULATE) { + if (this.getInternalCurrentPower() > amt) { + return amt; + } + return this.getInternalCurrentPower(); + } - protected double extractAEPower( double amt, final Actionable mode ) - { - if( mode == Actionable.SIMULATE ) - { - if( this.getInternalCurrentPower() > amt ) - { - return amt; - } - return this.getInternalCurrentPower(); - } + final boolean wasFull = this.getInternalCurrentPower() >= this.getInternalMaxPower() - 0.001; + if (wasFull && amt > 0.001) { + this.PowerEvent(PowerEventType.REQUEST_POWER); + } - final boolean wasFull = this.getInternalCurrentPower() >= this.getInternalMaxPower() - 0.001; - if( wasFull && amt > 0.001 ) - { - this.PowerEvent( PowerEventType.REQUEST_POWER ); - } + if (this.getInternalCurrentPower() > amt) { + this.setInternalCurrentPower(this.getInternalCurrentPower() - amt); + return amt; + } - if( this.getInternalCurrentPower() > amt ) - { - this.setInternalCurrentPower( this.getInternalCurrentPower() - amt ); - return amt; - } + amt = this.getInternalCurrentPower(); + this.setInternalCurrentPower(0); + return amt; + } - amt = this.getInternalCurrentPower(); - this.setInternalCurrentPower( 0 ); - return amt; - } + public double getInternalCurrentPower() { + return this.internalCurrentPower; + } - public double getInternalCurrentPower() - { - return this.internalCurrentPower; - } + public void setInternalCurrentPower(final double internalCurrentPower) { + this.internalCurrentPower = internalCurrentPower; + } - public void setInternalCurrentPower( final double internalCurrentPower ) - { - this.internalCurrentPower = internalCurrentPower; - } + public double getInternalMaxPower() { + return this.internalMaxPower; + } - public double getInternalMaxPower() - { - return this.internalMaxPower; - } + public void setInternalMaxPower(final double internalMaxPower) { + this.internalMaxPower = internalMaxPower; + } - public void setInternalMaxPower( final double internalMaxPower ) - { - this.internalMaxPower = internalMaxPower; - } + private boolean isInternalPublicPowerStorage() { + return this.internalPublicPowerStorage; + } - private boolean isInternalPublicPowerStorage() - { - return this.internalPublicPowerStorage; - } + public void setInternalPublicPowerStorage(final boolean internalPublicPowerStorage) { + this.internalPublicPowerStorage = internalPublicPowerStorage; + } - public void setInternalPublicPowerStorage( final boolean internalPublicPowerStorage ) - { - this.internalPublicPowerStorage = internalPublicPowerStorage; - } + private AccessRestriction getInternalPowerFlow() { + return this.internalPowerFlow; + } - private AccessRestriction getInternalPowerFlow() - { - return this.internalPowerFlow; - } + public void setInternalPowerFlow(final AccessRestriction internalPowerFlow) { + this.internalPowerFlow = internalPowerFlow; + } - public void setInternalPowerFlow( final AccessRestriction internalPowerFlow ) - { - this.internalPowerFlow = internalPowerFlow; - } + @Override + public void onReady() { + super.onReady(); - @Override - public void onReady() - { - super.onReady(); + // IC2 this.ic2Sink.onLoad(); + } - // IC2 this.ic2Sink.onLoad(); - } + @Override + public void onChunkUnloaded() { + super.onChunkUnloaded(); + // IC2 this.ic2Sink.onChunkUnloaded(); + } + @Override + public void remove() { + super.remove(); - @Override - public void onChunkUnloaded() - { - super.onChunkUnloaded(); + // IC2 this.ic2Sink.invalidate(); + } - // IC2 this.ic2Sink.onChunkUnloaded(); - } + @SuppressWarnings("unchecked") + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability capability) { - @Override - public void remove() - { - super.remove(); + if (capability == Capabilities.FORGE_ENERGY) { + if (this.getPowerSides().equals(ALL_SIDES)) { + return (LazyOptional) this.forgeEnergyAdapterOptional; + } + } - // IC2 this.ic2Sink.invalidate(); - } + return super.getCapability(capability); - @SuppressWarnings("unchecked") - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability capability) { + } - if( capability == Capabilities.FORGE_ENERGY ) { - if (this.getPowerSides().equals(ALL_SIDES)) { - return (LazyOptional) this.forgeEnergyAdapterOptional; - } - } - - return super.getCapability( capability ); - - } - - @SuppressWarnings("unchecked") - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { - if( capability == Capabilities.FORGE_ENERGY ) - { - if( this.getPowerSides().contains( facing ) ) - { - return (LazyOptional) this.forgeEnergyAdapterOptional; - } - } - return super.getCapability( capability, facing ); - } + @SuppressWarnings("unchecked") + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { + if (capability == Capabilities.FORGE_ENERGY) { + if (this.getPowerSides().contains(facing)) { + return (LazyOptional) this.forgeEnergyAdapterOptional; + } + } + return super.getCapability(capability, facing); + } } diff --git a/src/main/java/appeng/tile/powersink/ForgeEnergyAdapter.java b/src/main/java/appeng/tile/powersink/ForgeEnergyAdapter.java index 2ffed9fb4..160679037 100644 --- a/src/main/java/appeng/tile/powersink/ForgeEnergyAdapter.java +++ b/src/main/java/appeng/tile/powersink/ForgeEnergyAdapter.java @@ -1,63 +1,54 @@ package appeng.tile.powersink; - import net.minecraftforge.energy.IEnergyStorage; import appeng.api.config.Actionable; import appeng.api.config.PowerUnits; - /** * Adapts an {@link IExternalPowerSink} to Forges {@link IEnergyStorage}. */ -class ForgeEnergyAdapter implements IEnergyStorage -{ +class ForgeEnergyAdapter implements IEnergyStorage { - private final IExternalPowerSink sink; + private final IExternalPowerSink sink; - ForgeEnergyAdapter( IExternalPowerSink sink ) - { - this.sink = sink; - } + ForgeEnergyAdapter(IExternalPowerSink sink) { + this.sink = sink; + } - @Override - public final int receiveEnergy( int maxReceive, boolean simulate ) - { - final double offered = maxReceive; - final double overflow = this.sink.injectExternalPower( PowerUnits.RF, offered, simulate ? Actionable.SIMULATE : Actionable.MODULATE ); + @Override + public final int receiveEnergy(int maxReceive, boolean simulate) { + final double offered = maxReceive; + final double overflow = this.sink.injectExternalPower(PowerUnits.RF, offered, + simulate ? Actionable.SIMULATE : Actionable.MODULATE); - return (int) ( maxReceive - overflow ); - } + return (int) (maxReceive - overflow); + } - @Override - public final int getEnergyStored() - { - return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.sink.getAECurrentPower() ) ); - } + @Override + public final int getEnergyStored() { + return (int) Math.floor(PowerUnits.AE.convertTo(PowerUnits.RF, this.sink.getAECurrentPower())); + } - @Override - public final int getMaxEnergyStored() - { - return (int) Math.floor( PowerUnits.AE.convertTo( PowerUnits.RF, this.sink.getAEMaxPower() ) ); - } + @Override + public final int getMaxEnergyStored() { + return (int) Math.floor(PowerUnits.AE.convertTo(PowerUnits.RF, this.sink.getAEMaxPower())); + } - @Override - public int extractEnergy( int maxExtract, boolean simulate ) - { - return 0; - } + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } - @Override - public boolean canExtract() - { - return false; - } + @Override + public boolean canExtract() { + return false; + } - @Override - public boolean canReceive() - { - return true; - } + @Override + public boolean canReceive() { + return true; + } } diff --git a/src/main/java/appeng/tile/powersink/IExternalPowerSink.java b/src/main/java/appeng/tile/powersink/IExternalPowerSink.java index 568bc6961..e9ef88125 100644 --- a/src/main/java/appeng/tile/powersink/IExternalPowerSink.java +++ b/src/main/java/appeng/tile/powersink/IExternalPowerSink.java @@ -18,31 +18,28 @@ package appeng.tile.powersink; - import appeng.api.config.Actionable; import appeng.api.config.PowerUnits; import appeng.api.networking.energy.IAEPowerStorage; +public interface IExternalPowerSink extends IAEPowerStorage { -public interface IExternalPowerSink extends IAEPowerStorage -{ + /** + * Inject power into the network + * + * @param externalUnit The {@link PowerUnits} used by the input + * @param amount The amount offered to the sink. + * @param mode Modulate or simulate the operation. + * @return The unused amount, which could not be inserted into the sink. + */ + double injectExternalPower(PowerUnits externalUnit, double amount, Actionable mode); - /** - * Inject power into the network - * - * @param externalUnit The {@link PowerUnits} used by the input - * @param amount The amount offered to the sink. - * @param mode Modulate or simulate the operation. - * @return The unused amount, which could not be inserted into the sink. - */ - double injectExternalPower( PowerUnits externalUnit, double amount, Actionable mode ); - - /** - * - * @param externalUnit The {@link PowerUnits} used by the input - * @param maxPowerRequired Limit the demand to this upper bound. - * @return The amount of power demanded by the sink. - */ - double getExternalPowerDemand( PowerUnits externalUnit, double maxPowerRequired ); + /** + * + * @param externalUnit The {@link PowerUnits} used by the input + * @param maxPowerRequired Limit the demand to this upper bound. + * @return The amount of power demanded by the sink. + */ + double getExternalPowerDemand(PowerUnits externalUnit, double maxPowerRequired); } diff --git a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java index 07b7ac0bb..731ad9258 100644 --- a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java +++ b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java @@ -18,12 +18,12 @@ package appeng.tile.qnb; - import java.io.IOException; import java.util.EnumSet; import java.util.Optional; -import appeng.block.qnb.QnbFormedState; +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -46,6 +46,7 @@ import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; +import appeng.block.qnb.QnbFormedState; import appeng.me.GridAccessException; import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAEMultiBlock; @@ -56,317 +57,257 @@ import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.Platform; import appeng.util.inv.InvOperation; -import javax.annotation.Nonnull; +public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickableTileEntity { + public static final ModelProperty FORMED_STATE = new ModelProperty<>(); -public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickableTileEntity -{ + private final byte corner = 16; + private final AppEngInternalInventory internalInventory = new AppEngInternalInventory(this, 1, 1); + private final byte hasSingularity = 32; + private final byte powered = 64; - public static final ModelProperty FORMED_STATE = new ModelProperty<>(); + private final QuantumCalculator calc = new QuantumCalculator(this); + private byte constructed = -1; + private QuantumCluster cluster; + private boolean updateStatus = false; - private final byte corner = 16; - private final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1, 1 ); - private final byte hasSingularity = 32; - private final byte powered = 64; + public TileQuantumBridge(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + this.getProxy().setFlags(GridFlags.DENSE_CAPACITY); + this.getProxy().setIdlePowerUsage(22); + } - private final QuantumCalculator calc = new QuantumCalculator( this ); - private byte constructed = -1; - private QuantumCluster cluster; - private boolean updateStatus = false; + @Override + public void tick() { + if (this.updateStatus) { + this.updateStatus = false; + if (this.cluster != null) { + this.cluster.updateStatus(true); + } + this.markForUpdate(); + } + } - public TileQuantumBridge(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - this.getProxy().setFlags( GridFlags.DENSE_CAPACITY ); - this.getProxy().setIdlePowerUsage( 22 ); - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + int out = this.constructed; - @Override - public void tick() - { - if( this.updateStatus ) - { - this.updateStatus = false; - if( this.cluster != null ) - { - this.cluster.updateStatus( true ); - } - this.markForUpdate(); - } - } + if (!this.internalInventory.getStackInSlot(0).isEmpty() && this.constructed != -1) { + out |= this.hasSingularity; + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - int out = this.constructed; + if (this.getProxy().isActive() && this.constructed != -1) { + out |= this.powered; + } - if( !this.internalInventory.getStackInSlot( 0 ).isEmpty() && this.constructed != -1 ) - { - out |= this.hasSingularity; - } + data.writeByte((byte) out); + } - if( this.getProxy().isActive() && this.constructed != -1 ) - { - out |= this.powered; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final int oldValue = this.constructed; + this.constructed = data.readByte(); + return this.constructed != oldValue || c; + } - data.writeByte( (byte) out ); - } + @Override + public IItemHandler getInternalInventory() { + return this.internalInventory; + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final int oldValue = this.constructed; - this.constructed = data.readByte(); - return this.constructed != oldValue || c; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (this.cluster != null) { + this.cluster.updateStatus(true); + } + } - @Override - public IItemHandler getInternalInventory() - { - return this.internalInventory; - } + @Override + protected IItemHandler getItemHandlerForSide(Direction side) { + if (this.isCenter()) { + return this.internalInventory; + } + return EmptyHandler.INSTANCE; + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( this.cluster != null ) - { - this.cluster.updateStatus( true ); - } - } + private boolean isCenter() { + return AEApi.instance().definitions().blocks().quantumLink().maybeBlock() + .map(link -> this.getBlockState().getBlock() == link).orElse(false); + } - @Override - protected IItemHandler getItemHandlerForSide( Direction side ) - { - if( this.isCenter() ) - { - return this.internalInventory; - } - return EmptyHandler.INSTANCE; - } + @MENetworkEventSubscribe + public void onPowerStatusChange(final MENetworkPowerStatusChange c) { + this.updateStatus = true; + } - private boolean isCenter() - { - return AEApi.instance() - .definitions() - .blocks() - .quantumLink() - .maybeBlock() - .map( link -> this.getBlockState().getBlock() == link ) - .orElse( false ); - } + @Override + public void onChunkUnloaded() { + this.disconnect(false); + super.onChunkUnloaded(); + } - @MENetworkEventSubscribe - public void onPowerStatusChange( final MENetworkPowerStatusChange c ) - { - this.updateStatus = true; - } + @Override + public void onReady() { + super.onReady(); - @Override - public void onChunkUnloaded() - { - this.disconnect( false ); - super.onChunkUnloaded(); - } + final IBlockDefinition quantumRing = AEApi.instance().definitions().blocks().quantumRing(); + final Optional maybeLinkBlock = quantumRing.maybeBlock(); + final Optional maybeLinkStack = quantumRing.maybeStack(1); - @Override - public void onReady() - { - super.onReady(); + final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent(); - final IBlockDefinition quantumRing = AEApi.instance().definitions().blocks().quantumRing(); - final Optional maybeLinkBlock = quantumRing.maybeBlock(); - final Optional maybeLinkStack = quantumRing.maybeStack( 1 ); + if (isPresent && this.getBlockState().getBlock() == maybeLinkBlock.get()) { + final ItemStack linkStack = maybeLinkStack.get(); - final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent(); + this.getProxy().setVisualRepresentation(linkStack); + } + } - if( isPresent && this.getBlockState().getBlock() == maybeLinkBlock.get() ) - { - final ItemStack linkStack = maybeLinkStack.get(); + @Override + public void remove() { + this.disconnect(false); + super.remove(); + } - this.getProxy().setVisualRepresentation( linkStack ); - } - } + @Override + public void disconnect(final boolean affectWorld) { + if (this.cluster != null) { + if (!affectWorld) { + this.cluster.setUpdateStatus(false); + } - @Override - public void remove() - { - this.disconnect( false ); - super.remove(); - } + this.cluster.destroy(); + } - @Override - public void disconnect( final boolean affectWorld ) - { - if( this.cluster != null ) - { - if( !affectWorld ) - { - this.cluster.setUpdateStatus( false ); - } + this.cluster = null; - this.cluster.destroy(); - } + if (affectWorld) { + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } + } - this.cluster = null; + @Override + public IAECluster getCluster() { + return this.cluster; + } - if( affectWorld ) - { - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } - } + @Override + public boolean isValid() { + return !this.isRemoved(); + } - @Override - public IAECluster getCluster() - { - return this.cluster; - } + public void updateStatus(final QuantumCluster c, final byte flags, final boolean affectWorld) { + this.cluster = c; - @Override - public boolean isValid() - { - return !this.isRemoved(); - } + if (affectWorld) { + if (this.constructed != flags) { + this.constructed = flags; + this.markForUpdate(); + } - public void updateStatus( final QuantumCluster c, final byte flags, final boolean affectWorld ) - { - this.cluster = c; + if (this.isCorner() || this.isCenter()) { + final EnumSet sides = EnumSet.noneOf(Direction.class); + for (final Direction dir : this.getAdjacentQuantumBridges()) { + sides.add(dir); + } - if( affectWorld ) - { - if( this.constructed != flags ) - { - this.constructed = flags; - this.markForUpdate(); - } + this.getProxy().setValidSides(sides); + } else { + this.getProxy().setValidSides(EnumSet.allOf(Direction.class)); + } + } + } - if( this.isCorner() || this.isCenter() ) - { - final EnumSet sides = EnumSet.noneOf( Direction.class ); - for( final Direction dir : this.getAdjacentQuantumBridges() ) - { - sides.add( dir ); - } + public boolean isCorner() { + return (this.constructed & this.getCorner()) == this.getCorner() && this.constructed != -1; + } - this.getProxy().setValidSides( sides ); - } - else - { - this.getProxy().setValidSides( EnumSet.allOf( Direction.class ) ); - } - } - } + public EnumSet getAdjacentQuantumBridges() { + final EnumSet set = EnumSet.noneOf(Direction.class); - public boolean isCorner() - { - return ( this.constructed & this.getCorner() ) == this.getCorner() && this.constructed != -1; - } + for (final Direction d : Direction.values()) { + final TileEntity te = this.world.getTileEntity(this.pos.offset(d)); + if (te instanceof TileQuantumBridge) { + set.add(d); + } + } - public EnumSet getAdjacentQuantumBridges() - { - final EnumSet set = EnumSet.noneOf( Direction.class ); + return set; + } - for( final Direction d : Direction.values() ) - { - final TileEntity te = this.world.getTileEntity( this.pos.offset( d ) ); - if( te instanceof TileQuantumBridge ) - { - set.add( d ); - } - } + public long getQEFrequency() { + final ItemStack is = this.internalInventory.getStackInSlot(0); + if (!is.isEmpty()) { + final CompoundNBT c = is.getTag(); + if (c != null) { + return c.getLong("freq"); + } + } + return 0; + } - return set; - } + public boolean isPowered() { + if (isRemote()) { + return (this.constructed & this.powered) == this.powered && this.constructed != -1; + } - public long getQEFrequency() - { - final ItemStack is = this.internalInventory.getStackInSlot( 0 ); - if( !is.isEmpty() ) - { - final CompoundNBT c = is.getTag(); - if( c != null ) - { - return c.getLong( "freq" ); - } - } - return 0; - } + try { + return this.getProxy().getEnergy().isNetworkPowered(); + } catch (final GridAccessException e) { + // :P + } - public boolean isPowered() - { - if( isRemote() ) - { - return ( this.constructed & this.powered ) == this.powered && this.constructed != -1; - } + return false; + } - try - { - return this.getProxy().getEnergy().isNetworkPowered(); - } - catch( final GridAccessException e ) - { - // :P - } + public boolean isFormed() { + return this.constructed != -1; + } - return false; - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.DENSE_SMART; + } - public boolean isFormed() - { - return this.constructed != -1; - } + public void neighborUpdate() { + this.calc.calculateMultiblock(this.world, this.getLocation()); + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.DENSE_SMART; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - public void neighborUpdate() - { - this.calc.calculateMultiblock( this.world, this.getLocation() ); - } + public boolean hasQES() { + if (this.constructed == -1) { + return false; + } + return (this.constructed & this.hasSingularity) == this.hasSingularity; + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + public void breakCluster() { + if (this.cluster != null) { + this.cluster.destroy(); + } + } - public boolean hasQES() - { - if( this.constructed == -1 ) - { - return false; - } - return ( this.constructed & this.hasSingularity ) == this.hasSingularity; - } + public byte getCorner() { + return this.corner; + } - public void breakCluster() - { - if( this.cluster != null ) - { - this.cluster.destroy(); - } - } + @Nonnull + @Override + public IModelData getModelData() { + // FIXME must trigger model data updates - public byte getCorner() - { - return this.corner; - } + return new ModelDataMap.Builder() + .withInitial(FORMED_STATE, new QnbFormedState(getAdjacentQuantumBridges(), isCorner(), isPowered())) + .build(); - @Nonnull - @Override - public IModelData getModelData() { - // FIXME must trigger model data updates - - return new ModelDataMap.Builder() - .withInitial(FORMED_STATE, new QnbFormedState( getAdjacentQuantumBridges(), isCorner(), isPowered() )) - .build(); - - } + } } diff --git a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java index eca81acda..5a4a408cc 100644 --- a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java +++ b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java @@ -18,7 +18,6 @@ package appeng.tile.spatial; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -52,167 +51,139 @@ import appeng.util.inv.InvOperation; import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.IAEItemFilter; +public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable { -public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable -{ + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 2); + private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter()); + private YesNo lastRedstoneState = YesNo.UNDECIDED; - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 ); - private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new SpatialIOFilter() ); - private YesNo lastRedstoneState = YesNo.UNDECIDED; + public TileSpatialIOPort(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + } - public TileSpatialIOPort(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - } + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal()); + return data; + } - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() ); - return data; - } + @Override + public void read(final CompoundNBT data) { + super.read(data); + if (data.contains("lastRedstoneState")) { + this.lastRedstoneState = YesNo.values()[data.getInt("lastRedstoneState")]; + } + } - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - if( data.contains("lastRedstoneState") ) - { - this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )]; - } - } + public boolean getRedstoneState() { + if (this.lastRedstoneState == YesNo.UNDECIDED) { + this.updateRedstoneState(); + } - public boolean getRedstoneState() - { - if( this.lastRedstoneState == YesNo.UNDECIDED ) - { - this.updateRedstoneState(); - } + return this.lastRedstoneState == YesNo.YES; + } - return this.lastRedstoneState == YesNo.YES; - } + public void updateRedstoneState() { + final YesNo currentState = this.world.getRedstonePowerFromNeighbors(this.pos) != 0 ? YesNo.YES : YesNo.NO; + if (this.lastRedstoneState != currentState) { + this.lastRedstoneState = currentState; + if (this.lastRedstoneState == YesNo.YES) { + this.triggerTransition(); + } + } + } - public void updateRedstoneState() - { - final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO; - if( this.lastRedstoneState != currentState ) - { - this.lastRedstoneState = currentState; - if( this.lastRedstoneState == YesNo.YES ) - { - this.triggerTransition(); - } - } - } + private void triggerTransition() { + if (Platform.isServer()) { + final ItemStack cell = this.inv.getStackInSlot(0); + if (this.isSpatialCell(cell)) { + TickHandler.INSTANCE.addCallable(null, this);// this needs to be cross world synced. + } + } + } - private void triggerTransition() - { - if( Platform.isServer() ) - { - final ItemStack cell = this.inv.getStackInSlot( 0 ); - if( this.isSpatialCell( cell ) ) - { - TickHandler.INSTANCE.addCallable( null, this );// this needs to be cross world synced. - } - } - } + private boolean isSpatialCell(final ItemStack cell) { + if (!cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell) { + final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem(); + return sc != null && sc.isSpatialStorage(cell); + } + return false; + } - private boolean isSpatialCell( final ItemStack cell ) - { - if( !cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell ) - { - final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem(); - return sc != null && sc.isSpatialStorage( cell ); - } - return false; - } + @Override + public Void call(final World world) throws Exception { + final ItemStack cell = this.inv.getStackInSlot(0); + if (this.isSpatialCell(cell) && this.inv.getStackInSlot(1).isEmpty()) { + final IGrid gi = this.getProxy().getGrid(); + final IEnergyGrid energy = this.getProxy().getEnergy(); - @Override - public Void call( final World world ) throws Exception - { - final ItemStack cell = this.inv.getStackInSlot( 0 ); - if( this.isSpatialCell( cell ) && this.inv.getStackInSlot( 1 ).isEmpty() ) - { - final IGrid gi = this.getProxy().getGrid(); - final IEnergyGrid energy = this.getProxy().getEnergy(); + final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem(); - final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem(); + final SpatialPylonCache spc = gi.getCache(ISpatialCache.class); + if (spc.hasRegion() && spc.isValidRegion()) { + final double req = spc.requiredPower(); + final double pr = energy.extractAEPower(req, Actionable.SIMULATE, PowerMultiplier.CONFIG); + if (Math.abs(pr - req) < req * 0.001) { + final MENetworkEvent res = gi.postEvent(new MENetworkSpatialEvent(this, req)); + if (!res.isCanceled()) { + int playerId = -1; + if (this.getProxy().getSecurity().isAvailable()) { + playerId = this.getProxy().getSecurity().getOwner(); + } - final SpatialPylonCache spc = gi.getCache( ISpatialCache.class ); - if( spc.hasRegion() && spc.isValidRegion() ) - { - final double req = spc.requiredPower(); - final double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG ); - if( Math.abs( pr - req ) < req * 0.001 ) - { - final MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) ); - if( !res.isCanceled() ) - { - int playerId = -1; - if( this.getProxy().getSecurity().isAvailable() ) - { - playerId = this.getProxy().getSecurity().getOwner(); - } + final TransitionResult tr = sc.doSpatialTransition(cell, this.world, spc.getMin(), spc.getMax(), + playerId); + if (tr.success) { + energy.extractAEPower(req, Actionable.MODULATE, PowerMultiplier.CONFIG); + this.inv.setStackInSlot(0, ItemStack.EMPTY); + this.inv.setStackInSlot(1, cell); + } + } + } + } + } - final TransitionResult tr = sc.doSpatialTransition( cell, this.world, spc.getMin(), spc.getMax(), playerId ); - if( tr.success ) - { - energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG ); - this.inv.setStackInSlot( 0, ItemStack.EMPTY ); - this.inv.setStackInSlot( 1, cell ); - } - } - } - } - } + return null; + } - return null; - } + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } + @Override + protected @Nonnull IItemHandler getItemHandlerForSide(@Nonnull Direction side) { + return this.invExt; + } - @Override - protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull Direction side ) - { - return this.invExt; - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { + } - } + private class SpatialIOFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return slot == 1; + } - private class SpatialIOFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return slot == 1; - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return (slot == 0 && TileSpatialIOPort.this.isSpatialCell(stack)); + } - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return( slot == 0 && TileSpatialIOPort.this.isSpatialCell( stack ) ); - } - - } + } } diff --git a/src/main/java/appeng/tile/spatial/TileSpatialPylon.java b/src/main/java/appeng/tile/spatial/TileSpatialPylon.java index 272ff3acf..3ce3b679e 100644 --- a/src/main/java/appeng/tile/spatial/TileSpatialPylon.java +++ b/src/main/java/appeng/tile/spatial/TileSpatialPylon.java @@ -18,13 +18,17 @@ package appeng.tile.spatial; - import java.io.IOException; import java.util.EnumSet; +import javax.annotation.Nonnull; + import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.model.data.ModelDataMap; +import net.minecraftforge.client.model.data.ModelProperty; import appeng.api.networking.GridFlags; import appeng.api.networking.events.MENetworkChannelsChanged; @@ -37,234 +41,192 @@ import appeng.me.cluster.implementations.SpatialPylonCluster; import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.AENetworkProxyMultiblock; import appeng.tile.grid.AENetworkTile; -import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.client.model.data.ModelDataMap; -import net.minecraftforge.client.model.data.ModelProperty; -import javax.annotation.Nonnull; +public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock { + public static final ModelProperty STATE = new ModelProperty<>(value -> { + // The lower 6 bits are used + return (value & ~0x3F) == 0; + }); -public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock -{ + public static final int DISPLAY_END_MIN = 0x01; + public static final int DISPLAY_END_MAX = 0x02; + public static final int DISPLAY_MIDDLE = 0x01 + 0x02; + public static final int DISPLAY_X = 0x04; + public static final int DISPLAY_Y = 0x08; + public static final int DISPLAY_Z = 0x04 + 0x08; + public static final int MB_STATUS = 0x01 + 0x02 + 0x04 + 0x08; - public static final ModelProperty STATE = new ModelProperty<>(value -> { - // The lower 6 bits are used - return ( value & ~0x3F ) == 0; - }); + public static final int DISPLAY_ENABLED = 0x10; + public static final int DISPLAY_POWERED_ENABLED = 0x20; + public static final int NET_STATUS = 0x10 + 0x20; - public static final int DISPLAY_END_MIN = 0x01; - public static final int DISPLAY_END_MAX = 0x02; - public static final int DISPLAY_MIDDLE = 0x01 + 0x02; - public static final int DISPLAY_X = 0x04; - public static final int DISPLAY_Y = 0x08; - public static final int DISPLAY_Z = 0x04 + 0x08; - public static final int MB_STATUS = 0x01 + 0x02 + 0x04 + 0x08; + private final SpatialPylonCalculator calc = new SpatialPylonCalculator(this); + private int displayBits = 0; + private SpatialPylonCluster cluster; + private boolean didHaveLight = false; - public static final int DISPLAY_ENABLED = 0x10; - public static final int DISPLAY_POWERED_ENABLED = 0x20; - public static final int NET_STATUS = 0x10 + 0x20; + public TileSpatialPylon(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK); + this.getProxy().setIdlePowerUsage(0.5); + this.getProxy().setValidSides(EnumSet.noneOf(Direction.class)); + } - private final SpatialPylonCalculator calc = new SpatialPylonCalculator( this ); - private int displayBits = 0; - private SpatialPylonCluster cluster; - private boolean didHaveLight = false; + @Override + protected AENetworkProxy createProxy() { + return new AENetworkProxyMultiblock(this, "proxy", this.getItemFromTile(this), true); + } - public TileSpatialPylon(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK ); - this.getProxy().setIdlePowerUsage( 0.5 ); - this.getProxy().setValidSides( EnumSet.noneOf( Direction.class ) ); - } + @Override + public void onChunkUnloaded() { + this.disconnect(false); + super.onChunkUnloaded(); + } - @Override - protected AENetworkProxy createProxy() - { - return new AENetworkProxyMultiblock( this, "proxy", this.getItemFromTile( this ), true ); - } + @Override + public void onReady() { + super.onReady(); + this.neighborChanged(); + } - @Override - public void onChunkUnloaded() - { - this.disconnect( false ); - super.onChunkUnloaded(); - } + @Override + public void remove() { + this.disconnect(false); + super.remove(); + } - @Override - public void onReady() - { - super.onReady(); - this.neighborChanged(); - } + public void neighborChanged() { + this.calc.calculateMultiblock(this.world, this.getLocation()); + } - @Override - public void remove() - { - this.disconnect( false ); - super.remove(); - } + @Override + public void disconnect(final boolean b) { + if (this.cluster != null) { + this.cluster.destroy(); + this.updateStatus(null); + } + } - public void neighborChanged() - { - this.calc.calculateMultiblock( this.world, this.getLocation() ); - } + @Override + public SpatialPylonCluster getCluster() { + return this.cluster; + } - @Override - public void disconnect( final boolean b ) - { - if( this.cluster != null ) - { - this.cluster.destroy(); - this.updateStatus( null ); - } - } + @Override + public boolean isValid() { + return true; + } - @Override - public SpatialPylonCluster getCluster() - { - return this.cluster; - } + public void updateStatus(final SpatialPylonCluster c) { + this.cluster = c; + this.getProxy().setValidSides(c == null ? EnumSet.noneOf(Direction.class) : EnumSet.allOf(Direction.class)); + this.recalculateDisplay(); + } - @Override - public boolean isValid() - { - return true; - } + public void recalculateDisplay() { + final int oldBits = this.displayBits; - public void updateStatus( final SpatialPylonCluster c ) - { - this.cluster = c; - this.getProxy().setValidSides( c == null ? EnumSet.noneOf( Direction.class ) : EnumSet.allOf( Direction.class ) ); - this.recalculateDisplay(); - } + this.displayBits = 0; - public void recalculateDisplay() - { - final int oldBits = this.displayBits; + if (this.cluster != null) { + if (this.cluster.getMin().equals(this.getLocation())) { + this.displayBits = DISPLAY_END_MIN; + } else if (this.cluster.getMax().equals(this.getLocation())) { + this.displayBits = DISPLAY_END_MAX; + } else { + this.displayBits = DISPLAY_MIDDLE; + } - this.displayBits = 0; + switch (this.cluster.getCurrentAxis()) { + case X: + this.displayBits |= DISPLAY_X; + break; + case Y: + this.displayBits |= DISPLAY_Y; + break; + case Z: + this.displayBits |= DISPLAY_Z; + break; + default: + this.displayBits = 0; + break; + } - if( this.cluster != null ) - { - if( this.cluster.getMin().equals( this.getLocation() ) ) - { - this.displayBits = DISPLAY_END_MIN; - } - else if( this.cluster.getMax().equals( this.getLocation() ) ) - { - this.displayBits = DISPLAY_END_MAX; - } - else - { - this.displayBits = DISPLAY_MIDDLE; - } + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { + this.displayBits |= DISPLAY_POWERED_ENABLED; + } - switch( this.cluster.getCurrentAxis() ) - { - case X: - this.displayBits |= DISPLAY_X; - break; - case Y: - this.displayBits |= DISPLAY_Y; - break; - case Z: - this.displayBits |= DISPLAY_Z; - break; - default: - this.displayBits = 0; - break; - } + if (this.cluster.isValid() && this.getProxy().isActive()) { + this.displayBits |= DISPLAY_ENABLED; + } + } catch (final GridAccessException e) { + // nothing? + } + } - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { - this.displayBits |= DISPLAY_POWERED_ENABLED; - } + if (oldBits != this.displayBits) { + this.markForUpdate(); + } + } - if( this.cluster.isValid() && this.getProxy().isActive() ) - { - this.displayBits |= DISPLAY_ENABLED; - } - } - catch( final GridAccessException e ) - { - // nothing? - } - } + @Override + public void markForUpdate() { + super.markForUpdate(); + final boolean hasLight = this.getLightValue() > 0; + if (hasLight != this.didHaveLight) { + this.didHaveLight = hasLight; + this.world.getLightManager().checkBlock(this.pos); + } + } - if( oldBits != this.displayBits ) - { - this.markForUpdate(); - } - } + @Override + public boolean canBeRotated() { + return false; + } - @Override - public void markForUpdate() - { - super.markForUpdate(); - final boolean hasLight = this.getLightValue() > 0; - if( hasLight != this.didHaveLight ) - { - this.didHaveLight = hasLight; - this.world.getLightManager().checkBlock( this.pos ); - } - } + public int getLightValue() { + if ((this.displayBits & DISPLAY_POWERED_ENABLED) == DISPLAY_POWERED_ENABLED) { + return 8; + } + return 0; + } - @Override - public boolean canBeRotated() - { - return false; - } + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final int old = this.displayBits; + this.displayBits = data.readByte(); + return old != this.displayBits || c; + } - public int getLightValue() - { - if( ( this.displayBits & DISPLAY_POWERED_ENABLED ) == DISPLAY_POWERED_ENABLED ) - { - return 8; - } - return 0; - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeByte(this.displayBits); + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final int old = this.displayBits; - this.displayBits = data.readByte(); - return old != this.displayBits || c; - } + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.recalculateDisplay(); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeByte( this.displayBits ); - } + @MENetworkEventSubscribe + public void activeRender(final MENetworkChannelsChanged c) { + this.recalculateDisplay(); + } - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.recalculateDisplay(); - } + public int getDisplayBits() { + return this.displayBits; + } - @MENetworkEventSubscribe - public void activeRender( final MENetworkChannelsChanged c ) - { - this.recalculateDisplay(); - } - - public int getDisplayBits() - { - return this.displayBits; - } - - @Nonnull - @Override - public IModelData getModelData() { - // FIXME: Must force model data update on changes, should potentially be moved to block state (?) - return new ModelDataMap.Builder() - .withInitial(STATE, getDisplayBits()) - .build(); - } + @Nonnull + @Override + public IModelData getModelData() { + // FIXME: Must force model data update on changes, should potentially be moved + // to block state (?) + return new ModelDataMap.Builder().withInitial(STATE, getDisplayBits()).build(); + } } diff --git a/src/main/java/appeng/tile/storage/TileChest.java b/src/main/java/appeng/tile/storage/TileChest.java index e6af08a2e..f2249e474 100644 --- a/src/main/java/appeng/tile/storage/TileChest.java +++ b/src/main/java/appeng/tile/storage/TileChest.java @@ -18,7 +18,6 @@ package appeng.tile.storage; - import java.io.IOException; import java.util.Collections; import java.util.List; @@ -26,8 +25,6 @@ import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import appeng.container.implementations.ContainerMEMonitorable; -import appeng.fluids.container.ContainerFluidTerminal; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.Item; @@ -91,7 +88,8 @@ import appeng.api.storage.data.IAEStack; import appeng.api.util.AEColor; import appeng.api.util.IConfigManager; import appeng.capabilities.Capabilities; - +import appeng.container.implementations.ContainerMEMonitorable; +import appeng.fluids.container.ContainerFluidTerminal; import appeng.fluids.util.AEFluidStack; import appeng.helpers.IPriorityHost; import appeng.me.GridAccessException; @@ -109,870 +107,728 @@ import appeng.util.inv.WrapperChainedItemHandler; import appeng.util.inv.filter.IAEItemFilter; import appeng.util.item.AEItemStack; - -public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity -{ - private final AppEngInternalInventory inputInventory = new AppEngInternalInventory( this, 1 ); - private final AppEngInternalInventory cellInventory = new AppEngInternalInventory( this, 1 ); - private final IItemHandler internalInventory = new WrapperChainedItemHandler( this.inputInventory, this.cellInventory ); - - private final IActionSource mySrc = new MachineSource( this ); - private final IConfigManager config = new ConfigManager( this ); - private long lastStateChange = 0; - private int priority = 0; - private int state = 0; - private boolean wasActive = false; - private AEColor paintedColor = AEColor.TRANSPARENT; - private boolean isCached = false; - private ChestMonitorHandler cellHandler; - private Accessor accessor; - private IFluidHandler fluidHandler; - - public TileChest(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.setInternalMaxPower( PowerMultiplier.CONFIG.multiply( 40 ) ); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.config.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.config.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.config.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); - - this.setInternalPublicPowerStorage( true ); - this.setInternalPowerFlow( AccessRestriction.WRITE ); - - this.inputInventory.setFilter( new InputInventoryFilter() ); - this.cellInventory.setFilter(new CellInventoryFilter()); - } - - public ItemStack getCell() - { - return this.cellInventory.getStackInSlot( 0 ); - } - - @Override - protected void PowerEvent( final PowerEventType x ) - { - if( x == PowerEventType.REQUEST_POWER ) - { - try - { - this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) ); - } - catch( final GridAccessException e ) - { - // :( - } - } - else - { - this.recalculateDisplay(); - } - } - - private void recalculateDisplay() - { - final int oldState = this.state; - - for( int x = 0; x < this.getCellCount(); x++ ) - { - this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); - } - - if( this.isPowered() ) - { - this.state |= 0x40; - } - else - { - this.state &= ~0x40; - } - - final boolean currentActive = this.getProxy().isActive(); - if( this.wasActive != currentActive ) - { - this.wasActive = currentActive; - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - if( oldState != this.state ) - { - this.markForUpdate(); - } - } - - @Override - public int getCellCount() - { - return 1; - } - - @SuppressWarnings( "unchecked" ) - private void updateHandler() - { - if( !this.isCached ) - { - this.cellHandler = null; - this.accessor = null; - this.fluidHandler = null; - - final ItemStack is = this.getCell(); - if( !is.isEmpty() ) - { - this.isCached = true; - ICellHandler cellHandler = AEApi.instance().registries().cell().getHandler( is ); - if( cellHandler != null ) - { - double power = 1.0; - - for( IStorageChannel channel : AEApi.instance().storage().storageChannels() ) - { - final ICellInventoryHandler newCell = cellHandler.getCellInventory( is, this, channel ); - if( newCell != null ) - { - power += cellHandler.cellIdleDrain( is, newCell ); - this.cellHandler = this.wrap( newCell ); - break; - } - } - - this.getProxy().setIdlePowerUsage( power ); - this.accessor = new Accessor(); - - if( this.cellHandler != null && this.cellHandler - .getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) - { - this.fluidHandler = new FluidHandler(); - } - } - } - } - } - - private > ChestMonitorHandler wrap( final IMEInventoryHandler h ) - { - if( h == null ) - { - return null; - } - - final MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() ); - ih.setPriority( this.priority ); - - final ChestMonitorHandler g = new ChestMonitorHandler( ih ); - g.addListener( new ChestNetNotifier( h.getChannel() ), g ); - - return g; - } - - @Override - public int getCellStatus( final int slot ) - { - if( isRemote() ) - { - return ( this.state >> ( slot * 3 ) ) & 3; - } - - this.updateHandler(); - - final ItemStack cell = this.getCell(); - final ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell ); - - if( this.cellHandler != null && ch != null ) - { - return ch.getStatusForCell( cell, this.cellHandler.getInternalHandler() ); - } - - return 0; - } - - @Nullable - @Override - public Item getCellItem(int slot) { - if (slot != 0) { - return null; - } - ItemStack cell = getCell(); - return cell.isEmpty() ? null : cell.getItem(); - } - - @Override - public boolean isPowered() - { - if( isRemote() ) - { - return ( this.state & 0x40 ) == 0x40; - } - - boolean gridPowered = this.getAECurrentPower() > 64; - - if( !gridPowered ) - { - try - { - gridPowered = this.getProxy().getEnergy().isNetworkPowered(); - } - catch( final GridAccessException ignored ) - { - } - } - - return super.getAECurrentPower() > 1 || gridPowered; - } - - @Override - public boolean isCellBlinking( final int slot ) - { - final long now = this.world.getGameTime(); - if( now - this.lastStateChange > 8 ) - { - return false; - } - - return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01; - } - - @Override - protected double extractAEPower( final double amt, final Actionable mode ) - { - double stash = 0.0; - - try - { - final IEnergyGrid eg = this.getProxy().getEnergy(); - stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE ); - if( stash >= amt ) - { - return stash; - } - } - catch( final GridAccessException e ) - { - // no grid :( - } - - // local battery! - return super.extractAEPower( amt - stash, mode ) + stash; - } - - @Override - public void tick() - { - if( this.world.isRemote ) - { - return; - } - - final double idleUsage = this.getProxy().getIdlePowerUsage(); - - try - { - if( !this.getProxy().getEnergy().isNetworkPowered() ) - { - final double powerUsed = this.extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain - if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 ) - { - this.recalculateDisplay(); - } - } - } - catch( final GridAccessException e ) - { - final double powerUsed = this.extractAEPower( this.getProxy().getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain - if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 ) - { - this.recalculateDisplay(); - } - } - - if( !ItemHandlerUtil.isEmpty( this.inputInventory ) ) - { - this.tryToStoreContents(); - } - } - - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - - if( this.world.getGameTime() - this.lastStateChange > 8 ) - { - this.state = 0; - } - else - { - this.state &= 0x24924924; // just keep the blinks... - } - - for( int x = 0; x < this.getCellCount(); x++ ) - { - this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); - } - - if( this.isPowered() ) - { - this.state |= 0x40; - } - else - { - this.state &= ~0x40; - } - - data.writeByte( this.state ); - data.writeByte( this.paintedColor.ordinal() ); - } - - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - - final int oldState = this.state; - - this.state = data.readByte(); - final AEColor oldPaintedColor = this.paintedColor; - this.paintedColor = AEColor.values()[data.readByte()]; - - this.lastStateChange = this.world.getGameTime(); - - return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || c; - } - - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.config.readFromNBT( data ); - this.priority = data.getInt( "priority" ); - if( data.contains("paintedColor") ) - { - this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; - } - } - - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.config.writeToNBT( data ); - data.putInt( "priority", this.priority ); - data.putByte( "paintedColor", (byte) this.paintedColor.ordinal() ); - return data; - } - - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.recalculateDisplay(); - } - - @MENetworkEventSubscribe - public void channelRender( final MENetworkChannelsChanged c ) - { - this.recalculateDisplay(); - } - - @SuppressWarnings( "unchecked" ) - @Override - public > IMEMonitor getInventory( IStorageChannel channel ) - { - this.updateHandler(); - - if( this.cellHandler != null && this.cellHandler.getChannel() == channel ) - { - return this.cellHandler; - } - return null; - } - - @Override - public IItemHandler getInternalInventory() - { - return this.internalInventory; - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( inv == this.cellInventory ) - { - this.cellHandler = null; - this.isCached = false; // recalculate the storage cell. - - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - final IStorageGrid gs = this.getProxy().getStorage(); - Platform.postChanges( gs, removed, added, this.mySrc ); - } - catch( final GridAccessException ignored ) - { - - } - - // update the neighbors - if( this.world != null ) - { - Platform.notifyBlocksOfNeighbors( this.world, this.pos ); - this.markForUpdate(); - } - } - if( inv == this.inputInventory && mc == InvOperation.INSERT ) - { - this.tryToStoreContents(); - } - } - - @Override - protected IItemHandler getItemHandlerForSide( @Nonnull Direction side ) - { - if( side == this.getForward() ) - { - return this.cellInventory; - } - else - { - return this.inputInventory; - } - } - - private void tryToStoreContents() - { - if( !ItemHandlerUtil.isEmpty( this.inputInventory ) ) - { - this.updateHandler(); - - if( this.cellHandler != null && this.cellHandler.getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - final IAEItemStack returns = Platform.poweredInsert( this, this.cellHandler, - AEItemStack.fromItemStack( this.inputInventory.getStackInSlot( 0 ) ), this.mySrc ); - - if( returns == null ) - { - this.inputInventory.setStackInSlot( 0, ItemStack.EMPTY ); - } - else - { - this.inputInventory.setStackInSlot( 0, returns.createItemStack() ); - } - } - } - } - - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( this.getProxy().isActive() ) - { - this.updateHandler(); - - if( this.cellHandler != null && this.cellHandler.getChannel() == channel ) - { - return Collections.singletonList( this.cellHandler ); - } - } - return Collections.emptyList(); - } - - @Override - public int getPriority() - { - return this.priority; - } - - @Override - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.cellHandler = null; - this.isCached = false; // recalculate the storage cell. - - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - @Override - public void blinkCell( final int slot ) - { - final long now = this.world.getGameTime(); - if( now - this.lastStateChange > 8 ) - { - this.state = 0; - } - this.lastStateChange = now; - - this.state |= 1 << ( slot * 3 + 2 ); - - this.recalculateDisplay(); - } - - @Override - public IConfigManager getConfigManager() - { - return this.config; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - - } - - public boolean openGui( final PlayerEntity p ) - { - this.updateHandler(); - if( this.cellHandler != null ) - { - final ICellHandler ch = AEApi.instance().registries().cell().getHandler( this.getCell() ); - - if( ch != null ) - { - final ICellGuiHandler chg = AEApi.instance().registries().cell().getGuiHandler( this.cellHandler.getChannel(), this.getCell() ); - if( chg != null ) - { - chg.openChestGui( p, this, ch, this.cellHandler, this.getCell(), this.cellHandler.getChannel() ); - return true; - } - } - - } - - return false; - } - - @Override - public AEColor getColor() - { - return this.paintedColor; - } - - @Override - public boolean recolourBlock( final Direction side, final AEColor newPaintedColor, final PlayerEntity who ) - { - if( this.paintedColor == newPaintedColor ) - { - return false; - } - - this.paintedColor = newPaintedColor; - this.saveChanges(); - this.markForUpdate(); - return true; - } - - @Override - public void saveChanges( final ICellInventory cellInventory ) - { - if( cellInventory != null ) - { - cellInventory.persist(); - } - this.world.markChunkDirty( this.pos, this ); - } - - private class ChestNetNotifier> implements IMEMonitorHandlerReceiver - { - - private final IStorageChannel chan; - - public ChestNetNotifier( final IStorageChannel chan ) - { - this.chan = chan; - } - - @Override - public boolean isValid( final Object verificationToken ) - { - TileChest.this.updateHandler(); - if( TileChest.this.cellHandler != null && this.chan == TileChest.this.cellHandler.getChannel() ) - { - return verificationToken == TileChest.this.cellHandler; - } - return false; - } - - @Override - public void postChange( final IBaseMonitor monitor, final Iterable change, final IActionSource source ) - { - if( source == TileChest.this.mySrc || source.machine().map( machine -> machine == TileChest.this ).orElse( false ) ) - { - try - { - if( TileChest.this.getProxy().isActive() ) - { - TileChest.this.getProxy().getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc ); - } - } - catch( final GridAccessException e ) - { - // :( - } - } - - TileChest.this.blinkCell( 0 ); - } - - @Override - public void onListUpdate() - { - // not used here - } - } - - private class ChestMonitorHandler> extends MEMonitorHandler - { - - public ChestMonitorHandler( final IMEInventoryHandler t ) - { - super( t ); - } - - private ICellInventoryHandler getInternalHandler() - { - final IMEInventoryHandler h = this.getHandler(); - if( h instanceof MEInventoryHandler ) - { - return (ICellInventoryHandler) ( (MEInventoryHandler) h ).getInternal(); - } - return (ICellInventoryHandler) this.getHandler(); - } - - @Override - public T injectItems( final T input, final Actionable mode, final IActionSource src ) - { - if( src.player().map( player -> !this.securityCheck( player, SecurityPermissions.INJECT ) ).orElse( false ) ) - { - return input; - } - return super.injectItems( input, mode, src ); - } - - private boolean securityCheck( final PlayerEntity player, final SecurityPermissions requiredPermission ) - { - if( TileChest.this.getTile() instanceof IActionHost && requiredPermission != null ) - { - - final IGridNode gn = ( (IActionHost) TileChest.this.getTile() ).getActionableNode(); - if( gn != null ) - { - final IGrid g = gn.getGrid(); - if( g != null ) - { - final boolean requirePower = false; - if( requirePower ) - { - final IEnergyGrid eg = g.getCache( IEnergyGrid.class ); - if( !eg.isNetworkPowered() ) - { - return false; - } - } - - final ISecurityGrid sg = g.getCache( ISecurityGrid.class ); - if( sg.hasPermission( player, requiredPermission ) ) - { - return true; - } - } - } - - return false; - } - return true; - } - - @Override - public T extractItems( final T request, final Actionable mode, final IActionSource src ) - { - if( src.player().map( player -> !this.securityCheck( player, SecurityPermissions.EXTRACT ) ).orElse( false ) ) - { - return null; - } - return super.extractItems( request, mode, src ); - } - } - - @SuppressWarnings( "unchecked" ) - @Override - public LazyOptional getCapability(Capability capability, @Nullable Direction facing ) - { - this.updateHandler(); - if( capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null && facing != this.getForward() ) - { - return (LazyOptional) LazyOptional.of(() -> this.fluidHandler); - } - if( capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null && facing != this.getForward() ) - { - return (LazyOptional) LazyOptional.of(() -> this.accessor); - } - return super.getCapability( capability, facing ); - } - - private class Accessor implements IStorageMonitorableAccessor - { - @Nullable - @Override - public IStorageMonitorable getInventory( IActionSource src ) - { - if( Platform.canAccess( TileChest.this.getProxy(), src ) ) - { - return TileChest.this; - } - return null; - } - } - - private class FluidHandler implements IFluidHandler, IFluidTank - { - - private boolean canAcceptLiquids() { - return TileChest.this.cellHandler != null && TileChest.this.cellHandler.getChannel() == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class); - } - - @Nonnull - @Override - public FluidStack getFluid() { - return FluidStack.EMPTY; - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public int getCapacity() { - return canAcceptLiquids() ? FluidAttributes.BUCKET_VOLUME : 0; - } - - @Override - public boolean isFluidValid(FluidStack stack) { - return canAcceptLiquids(); - } - - @Override - public int getTanks() { - return 1; - } - - @Nonnull - @Override - public FluidStack getFluidInTank(int tank) { - return FluidStack.EMPTY; - } - - @Override - public int getTankCapacity(int tank) { - return tank == 0 ? FluidAttributes.BUCKET_VOLUME : 0; - } - - @Override - public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { - return tank == 0; - } - - @Override - public int fill(FluidStack resource, FluidAction action) { - TileChest.this.updateHandler(); - if( canAcceptLiquids() ) - { - final IAEFluidStack results = Platform.poweredInsert( TileChest.this, TileChest.this.cellHandler, AEFluidStack.fromFluidStack( resource ), - TileChest.this.mySrc, action == FluidAction.EXECUTE ? Actionable.MODULATE : Actionable.SIMULATE ); - - if( results == null ) - { - return resource.getAmount(); - } - return resource.getAmount() - (int) results.getStackSize(); - } - return 0; - } - - @Nonnull - @Override - public FluidStack drain(FluidStack resource, FluidAction action) { - return FluidStack.EMPTY; - } - - @Nonnull - @Override - public FluidStack drain(int maxDrain, FluidAction action) { - return FluidStack.EMPTY; - } - } - - private class InputInventoryFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return false; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - if( TileChest.this.isPowered() ) - { - TileChest.this.updateHandler(); - return TileChest.this.cellHandler != null && TileChest.this.cellHandler - .getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } - return false; - } - } - - private static class CellInventoryFilter implements IAEItemFilter - { - - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return AEApi.instance().registries().cell().getHandler( stack ) != null; - } - - } - - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().blocks().chest().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Override - public ContainerType getContainerType() - { - this.updateHandler(); - if( this.cellHandler != null ) - { - if( this.cellHandler.getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) - { - return ContainerMEMonitorable.TYPE; - } - if( this.cellHandler.getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) - { - return ContainerFluidTerminal.TYPE; - } - } - return null; - } +public class TileChest extends AENetworkPowerTile + implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity { + private final AppEngInternalInventory inputInventory = new AppEngInternalInventory(this, 1); + private final AppEngInternalInventory cellInventory = new AppEngInternalInventory(this, 1); + private final IItemHandler internalInventory = new WrapperChainedItemHandler(this.inputInventory, + this.cellInventory); + + private final IActionSource mySrc = new MachineSource(this); + private final IConfigManager config = new ConfigManager(this); + private long lastStateChange = 0; + private int priority = 0; + private int state = 0; + private boolean wasActive = false; + private AEColor paintedColor = AEColor.TRANSPARENT; + private boolean isCached = false; + private ChestMonitorHandler cellHandler; + private Accessor accessor; + private IFluidHandler fluidHandler; + + public TileChest(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.setInternalMaxPower(PowerMultiplier.CONFIG.multiply(40)); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.config.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.config.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + this.config.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); + + this.setInternalPublicPowerStorage(true); + this.setInternalPowerFlow(AccessRestriction.WRITE); + + this.inputInventory.setFilter(new InputInventoryFilter()); + this.cellInventory.setFilter(new CellInventoryFilter()); + } + + public ItemStack getCell() { + return this.cellInventory.getStackInSlot(0); + } + + @Override + protected void PowerEvent(final PowerEventType x) { + if (x == PowerEventType.REQUEST_POWER) { + try { + this.getProxy().getGrid().postEvent(new MENetworkPowerStorage(this, PowerEventType.REQUEST_POWER)); + } catch (final GridAccessException e) { + // :( + } + } else { + this.recalculateDisplay(); + } + } + + private void recalculateDisplay() { + final int oldState = this.state; + + for (int x = 0; x < this.getCellCount(); x++) { + this.state |= (this.getCellStatus(x) << (3 * x)); + } + + if (this.isPowered()) { + this.state |= 0x40; + } else { + this.state &= ~0x40; + } + + final boolean currentActive = this.getProxy().isActive(); + if (this.wasActive != currentActive) { + this.wasActive = currentActive; + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } + + if (oldState != this.state) { + this.markForUpdate(); + } + } + + @Override + public int getCellCount() { + return 1; + } + + @SuppressWarnings("unchecked") + private void updateHandler() { + if (!this.isCached) { + this.cellHandler = null; + this.accessor = null; + this.fluidHandler = null; + + final ItemStack is = this.getCell(); + if (!is.isEmpty()) { + this.isCached = true; + ICellHandler cellHandler = AEApi.instance().registries().cell().getHandler(is); + if (cellHandler != null) { + double power = 1.0; + + for (IStorageChannel channel : AEApi.instance().storage().storageChannels()) { + final ICellInventoryHandler newCell = cellHandler.getCellInventory(is, this, + channel); + if (newCell != null) { + power += cellHandler.cellIdleDrain(is, newCell); + this.cellHandler = this.wrap(newCell); + break; + } + } + + this.getProxy().setIdlePowerUsage(power); + this.accessor = new Accessor(); + + if (this.cellHandler != null && this.cellHandler.getChannel() == AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class)) { + this.fluidHandler = new FluidHandler(); + } + } + } + } + } + + private > ChestMonitorHandler wrap(final IMEInventoryHandler h) { + if (h == null) { + return null; + } + + final MEInventoryHandler ih = new MEInventoryHandler(h, h.getChannel()); + ih.setPriority(this.priority); + + final ChestMonitorHandler g = new ChestMonitorHandler(ih); + g.addListener(new ChestNetNotifier(h.getChannel()), g); + + return g; + } + + @Override + public int getCellStatus(final int slot) { + if (isRemote()) { + return (this.state >> (slot * 3)) & 3; + } + + this.updateHandler(); + + final ItemStack cell = this.getCell(); + final ICellHandler ch = AEApi.instance().registries().cell().getHandler(cell); + + if (this.cellHandler != null && ch != null) { + return ch.getStatusForCell(cell, this.cellHandler.getInternalHandler()); + } + + return 0; + } + + @Nullable + @Override + public Item getCellItem(int slot) { + if (slot != 0) { + return null; + } + ItemStack cell = getCell(); + return cell.isEmpty() ? null : cell.getItem(); + } + + @Override + public boolean isPowered() { + if (isRemote()) { + return (this.state & 0x40) == 0x40; + } + + boolean gridPowered = this.getAECurrentPower() > 64; + + if (!gridPowered) { + try { + gridPowered = this.getProxy().getEnergy().isNetworkPowered(); + } catch (final GridAccessException ignored) { + } + } + + return super.getAECurrentPower() > 1 || gridPowered; + } + + @Override + public boolean isCellBlinking(final int slot) { + final long now = this.world.getGameTime(); + if (now - this.lastStateChange > 8) { + return false; + } + + return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01; + } + + @Override + protected double extractAEPower(final double amt, final Actionable mode) { + double stash = 0.0; + + try { + final IEnergyGrid eg = this.getProxy().getEnergy(); + stash = eg.extractAEPower(amt, mode, PowerMultiplier.ONE); + if (stash >= amt) { + return stash; + } + } catch (final GridAccessException e) { + // no grid :( + } + + // local battery! + return super.extractAEPower(amt - stash, mode) + stash; + } + + @Override + public void tick() { + if (this.world.isRemote) { + return; + } + + final double idleUsage = this.getProxy().getIdlePowerUsage(); + + try { + if (!this.getProxy().getEnergy().isNetworkPowered()) { + final double powerUsed = this.extractAEPower(idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG); // drain + if (powerUsed + 0.1 >= idleUsage != (this.state & 0x40) > 0) { + this.recalculateDisplay(); + } + } + } catch (final GridAccessException e) { + final double powerUsed = this.extractAEPower(this.getProxy().getIdlePowerUsage(), Actionable.MODULATE, + PowerMultiplier.CONFIG); // drain + if (powerUsed + 0.1 >= idleUsage != (this.state & 0x40) > 0) { + this.recalculateDisplay(); + } + } + + if (!ItemHandlerUtil.isEmpty(this.inputInventory)) { + this.tryToStoreContents(); + } + } + + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + + if (this.world.getGameTime() - this.lastStateChange > 8) { + this.state = 0; + } else { + this.state &= 0x24924924; // just keep the blinks... + } + + for (int x = 0; x < this.getCellCount(); x++) { + this.state |= (this.getCellStatus(x) << (3 * x)); + } + + if (this.isPowered()) { + this.state |= 0x40; + } else { + this.state &= ~0x40; + } + + data.writeByte(this.state); + data.writeByte(this.paintedColor.ordinal()); + } + + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + + final int oldState = this.state; + + this.state = data.readByte(); + final AEColor oldPaintedColor = this.paintedColor; + this.paintedColor = AEColor.values()[data.readByte()]; + + this.lastStateChange = this.world.getGameTime(); + + return oldPaintedColor != this.paintedColor || (this.state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || c; + } + + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.config.readFromNBT(data); + this.priority = data.getInt("priority"); + if (data.contains("paintedColor")) { + this.paintedColor = AEColor.values()[data.getByte("paintedColor")]; + } + } + + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.config.writeToNBT(data); + data.putInt("priority", this.priority); + data.putByte("paintedColor", (byte) this.paintedColor.ordinal()); + return data; + } + + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.recalculateDisplay(); + } + + @MENetworkEventSubscribe + public void channelRender(final MENetworkChannelsChanged c) { + this.recalculateDisplay(); + } + + @SuppressWarnings("unchecked") + @Override + public > IMEMonitor getInventory(IStorageChannel channel) { + this.updateHandler(); + + if (this.cellHandler != null && this.cellHandler.getChannel() == channel) { + return this.cellHandler; + } + return null; + } + + @Override + public IItemHandler getInternalInventory() { + return this.internalInventory; + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (inv == this.cellInventory) { + this.cellHandler = null; + this.isCached = false; // recalculate the storage cell. + + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + final IStorageGrid gs = this.getProxy().getStorage(); + Platform.postChanges(gs, removed, added, this.mySrc); + } catch (final GridAccessException ignored) { + + } + + // update the neighbors + if (this.world != null) { + Platform.notifyBlocksOfNeighbors(this.world, this.pos); + this.markForUpdate(); + } + } + if (inv == this.inputInventory && mc == InvOperation.INSERT) { + this.tryToStoreContents(); + } + } + + @Override + protected IItemHandler getItemHandlerForSide(@Nonnull Direction side) { + if (side == this.getForward()) { + return this.cellInventory; + } else { + return this.inputInventory; + } + } + + private void tryToStoreContents() { + if (!ItemHandlerUtil.isEmpty(this.inputInventory)) { + this.updateHandler(); + + if (this.cellHandler != null && this.cellHandler.getChannel() == AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class)) { + final IAEItemStack returns = Platform.poweredInsert(this, this.cellHandler, + AEItemStack.fromItemStack(this.inputInventory.getStackInSlot(0)), this.mySrc); + + if (returns == null) { + this.inputInventory.setStackInSlot(0, ItemStack.EMPTY); + } else { + this.inputInventory.setStackInSlot(0, returns.createItemStack()); + } + } + } + } + + @Override + public List getCellArray(final IStorageChannel channel) { + if (this.getProxy().isActive()) { + this.updateHandler(); + + if (this.cellHandler != null && this.cellHandler.getChannel() == channel) { + return Collections.singletonList(this.cellHandler); + } + } + return Collections.emptyList(); + } + + @Override + public int getPriority() { + return this.priority; + } + + @Override + public void setPriority(final int newValue) { + this.priority = newValue; + this.cellHandler = null; + this.isCached = false; // recalculate the storage cell. + + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } + + @Override + public void blinkCell(final int slot) { + final long now = this.world.getGameTime(); + if (now - this.lastStateChange > 8) { + this.state = 0; + } + this.lastStateChange = now; + + this.state |= 1 << (slot * 3 + 2); + + this.recalculateDisplay(); + } + + @Override + public IConfigManager getConfigManager() { + return this.config; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + + } + + public boolean openGui(final PlayerEntity p) { + this.updateHandler(); + if (this.cellHandler != null) { + final ICellHandler ch = AEApi.instance().registries().cell().getHandler(this.getCell()); + + if (ch != null) { + final ICellGuiHandler chg = AEApi.instance().registries().cell() + .getGuiHandler(this.cellHandler.getChannel(), this.getCell()); + if (chg != null) { + chg.openChestGui(p, this, ch, this.cellHandler, this.getCell(), this.cellHandler.getChannel()); + return true; + } + } + + } + + return false; + } + + @Override + public AEColor getColor() { + return this.paintedColor; + } + + @Override + public boolean recolourBlock(final Direction side, final AEColor newPaintedColor, final PlayerEntity who) { + if (this.paintedColor == newPaintedColor) { + return false; + } + + this.paintedColor = newPaintedColor; + this.saveChanges(); + this.markForUpdate(); + return true; + } + + @Override + public void saveChanges(final ICellInventory cellInventory) { + if (cellInventory != null) { + cellInventory.persist(); + } + this.world.markChunkDirty(this.pos, this); + } + + private class ChestNetNotifier> implements IMEMonitorHandlerReceiver { + + private final IStorageChannel chan; + + public ChestNetNotifier(final IStorageChannel chan) { + this.chan = chan; + } + + @Override + public boolean isValid(final Object verificationToken) { + TileChest.this.updateHandler(); + if (TileChest.this.cellHandler != null && this.chan == TileChest.this.cellHandler.getChannel()) { + return verificationToken == TileChest.this.cellHandler; + } + return false; + } + + @Override + public void postChange(final IBaseMonitor monitor, final Iterable change, final IActionSource source) { + if (source == TileChest.this.mySrc + || source.machine().map(machine -> machine == TileChest.this).orElse(false)) { + try { + if (TileChest.this.getProxy().isActive()) { + TileChest.this.getProxy().getStorage().postAlterationOfStoredItems(this.chan, change, + TileChest.this.mySrc); + } + } catch (final GridAccessException e) { + // :( + } + } + + TileChest.this.blinkCell(0); + } + + @Override + public void onListUpdate() { + // not used here + } + } + + private class ChestMonitorHandler> extends MEMonitorHandler { + + public ChestMonitorHandler(final IMEInventoryHandler t) { + super(t); + } + + private ICellInventoryHandler getInternalHandler() { + final IMEInventoryHandler h = this.getHandler(); + if (h instanceof MEInventoryHandler) { + return (ICellInventoryHandler) ((MEInventoryHandler) h).getInternal(); + } + return (ICellInventoryHandler) this.getHandler(); + } + + @Override + public T injectItems(final T input, final Actionable mode, final IActionSource src) { + if (src.player().map(player -> !this.securityCheck(player, SecurityPermissions.INJECT)).orElse(false)) { + return input; + } + return super.injectItems(input, mode, src); + } + + private boolean securityCheck(final PlayerEntity player, final SecurityPermissions requiredPermission) { + if (TileChest.this.getTile() instanceof IActionHost && requiredPermission != null) { + + final IGridNode gn = ((IActionHost) TileChest.this.getTile()).getActionableNode(); + if (gn != null) { + final IGrid g = gn.getGrid(); + if (g != null) { + final boolean requirePower = false; + if (requirePower) { + final IEnergyGrid eg = g.getCache(IEnergyGrid.class); + if (!eg.isNetworkPowered()) { + return false; + } + } + + final ISecurityGrid sg = g.getCache(ISecurityGrid.class); + if (sg.hasPermission(player, requiredPermission)) { + return true; + } + } + } + + return false; + } + return true; + } + + @Override + public T extractItems(final T request, final Actionable mode, final IActionSource src) { + if (src.player().map(player -> !this.securityCheck(player, SecurityPermissions.EXTRACT)).orElse(false)) { + return null; + } + return super.extractItems(request, mode, src); + } + } + + @SuppressWarnings("unchecked") + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + this.updateHandler(); + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && this.fluidHandler != null + && facing != this.getForward()) { + return (LazyOptional) LazyOptional.of(() -> this.fluidHandler); + } + if (capability == Capabilities.STORAGE_MONITORABLE_ACCESSOR && this.accessor != null + && facing != this.getForward()) { + return (LazyOptional) LazyOptional.of(() -> this.accessor); + } + return super.getCapability(capability, facing); + } + + private class Accessor implements IStorageMonitorableAccessor { + @Nullable + @Override + public IStorageMonitorable getInventory(IActionSource src) { + if (Platform.canAccess(TileChest.this.getProxy(), src)) { + return TileChest.this; + } + return null; + } + } + + private class FluidHandler implements IFluidHandler, IFluidTank { + + private boolean canAcceptLiquids() { + return TileChest.this.cellHandler != null && TileChest.this.cellHandler.getChannel() == AEApi.instance() + .storage().getStorageChannel(IFluidStorageChannel.class); + } + + @Nonnull + @Override + public FluidStack getFluid() { + return FluidStack.EMPTY; + } + + @Override + public int getFluidAmount() { + return 0; + } + + @Override + public int getCapacity() { + return canAcceptLiquids() ? FluidAttributes.BUCKET_VOLUME : 0; + } + + @Override + public boolean isFluidValid(FluidStack stack) { + return canAcceptLiquids(); + } + + @Override + public int getTanks() { + return 1; + } + + @Nonnull + @Override + public FluidStack getFluidInTank(int tank) { + return FluidStack.EMPTY; + } + + @Override + public int getTankCapacity(int tank) { + return tank == 0 ? FluidAttributes.BUCKET_VOLUME : 0; + } + + @Override + public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { + return tank == 0; + } + + @Override + public int fill(FluidStack resource, FluidAction action) { + TileChest.this.updateHandler(); + if (canAcceptLiquids()) { + final IAEFluidStack results = Platform.poweredInsert(TileChest.this, TileChest.this.cellHandler, + AEFluidStack.fromFluidStack(resource), TileChest.this.mySrc, + action == FluidAction.EXECUTE ? Actionable.MODULATE : Actionable.SIMULATE); + + if (results == null) { + return resource.getAmount(); + } + return resource.getAmount() - (int) results.getStackSize(); + } + return 0; + } + + @Nonnull + @Override + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } + + @Nonnull + @Override + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; + } + } + + private class InputInventoryFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return false; + } + + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + if (TileChest.this.isPowered()) { + TileChest.this.updateHandler(); + return TileChest.this.cellHandler != null && TileChest.this.cellHandler.getChannel() == AEApi.instance() + .storage().getStorageChannel(IItemStorageChannel.class); + } + return false; + } + } + + private static class CellInventoryFilter implements IAEItemFilter { + + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } + + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return AEApi.instance().registries().cell().getHandler(stack) != null; + } + + } + + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().blocks().chest().maybeStack(1).orElse(ItemStack.EMPTY); + } + + @Override + public ContainerType getContainerType() { + this.updateHandler(); + if (this.cellHandler != null) { + if (this.cellHandler.getChannel() == AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class)) { + return ContainerMEMonitorable.TYPE; + } + if (this.cellHandler.getChannel() == AEApi.instance().storage() + .getStorageChannel(IFluidStorageChannel.class)) { + return ContainerFluidTerminal.TYPE; + } + } + return null; + } } diff --git a/src/main/java/appeng/tile/storage/TileDrive.java b/src/main/java/appeng/tile/storage/TileDrive.java index 97a588788..96eb9cb18 100644 --- a/src/main/java/appeng/tile/storage/TileDrive.java +++ b/src/main/java/appeng/tile/storage/TileDrive.java @@ -18,7 +18,6 @@ package appeng.tile.storage; - import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -27,10 +26,9 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import appeng.block.storage.DriveSlotCellType; -import appeng.block.storage.DriveSlotsState; -import appeng.client.render.model.DriveModelData; -import appeng.container.implementations.ContainerDrive; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -40,6 +38,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.registries.ForgeRegistries; import appeng.api.AEApi; import appeng.api.implementations.tiles.IChestOrDrive; @@ -60,7 +59,10 @@ import appeng.api.storage.data.IAEStack; import appeng.api.util.AECableType; import appeng.api.util.AEPartLocation; import appeng.api.util.DimensionalCoord; - +import appeng.block.storage.DriveSlotCellType; +import appeng.block.storage.DriveSlotsState; +import appeng.client.render.model.DriveModelData; +import appeng.container.implementations.ContainerDrive; import appeng.helpers.IPriorityHost; import appeng.me.GridAccessException; import appeng.me.helpers.MachineSource; @@ -70,437 +72,379 @@ import appeng.tile.inventory.AppEngCellInventory; import appeng.util.Platform; import appeng.util.inv.InvOperation; import appeng.util.inv.filter.IAEItemFilter; -import net.minecraftforge.registries.ForgeRegistries; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - - -public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost -{ - - private static final int BIT_POWER_MASK = 0x80000000; - private static final int BIT_BLINK_MASK = 0x24924924; - private static final int BIT_STATE_MASK = 0xDB6DB6DB; - - private final AppEngCellInventory inv = new AppEngCellInventory( this, 10 ); - private final ICellHandler[] handlersBySlot = new ICellHandler[10]; - private final DriveWatcher[] invBySlot = new DriveWatcher[10]; - private final IActionSource mySrc; - private boolean isCached = false; - private Map>, List> inventoryHandlers; - private int priority = 0; - private boolean wasActive = false; - // This is only used on the client - private final Item[] cellItems = new Item[10]; - - /** - * The state of all cells inside a drive as bitset, using the following format. - * - * Bit 31: power state. 0 = off, 1 = on. - * Bit 30: undefined - * Bit 29-0: 3 bits as state of each cell with the cell in slot 0 located in the 3 least significant bits. - * - * Cell states: - * Bit 2: blink. 0 = off, 1 = on. - * Bit 1-0: cell status - * - * - */ - private int state = 0; - - public TileDrive(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.mySrc = new MachineSource( this ); - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.inv.setFilter( new CellValidInventoryFilter() ); - this.inventoryHandlers = new IdentityHashMap<>(); - } - - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - int newState = 0; - - if( this.getProxy().isActive() ) - { - newState |= BIT_POWER_MASK; - } - for( int x = 0; x < this.getCellCount(); x++ ) { - newState |= (this.getCellStatus(x) << (3 * x)); - } - data.writeInt( newState ); - - writeCellItemIds(data); - } - - private void writeCellItemIds(PacketBuffer data) { - List cellItemIds = new ArrayList<>(getCellCount()); - byte[] bm = new byte[getCellCount()]; - for( int x = 0; x < this.getCellCount(); x++ ) { - Item item = getCellItem(x); - if (item != null && item.getRegistryName() != null) { - ResourceLocation itemId = item.getRegistryName(); - int idx = cellItemIds.indexOf(itemId); - if (idx == -1) { - cellItemIds.add(itemId); - bm[x] = (byte) cellItemIds.size(); // We use 1-based in bm[] - } else { - bm[x] = (byte)(1 + idx); // 1-based indexing!! - } - } - } - - // Write out the list of unique cell item ids - data.writeByte(cellItemIds.size()); - for (ResourceLocation itemId : cellItemIds) { - data.writeResourceLocation(itemId); - } - // Then the lookup table for each slot - for (int i = 0; i < getCellCount(); i++) { - data.writeByte(bm[i]); - } - } - - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - boolean c = super.readFromStream( data ); - final int oldState = this.state; - this.state = data.readInt(); - - c |= this.readCellItemIDs(data); - - return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK ) || c; - } - - private boolean readCellItemIDs(final PacketBuffer data ) { - int uniqueStrCount = data.readByte(); - String[] uniqueStrs = new String[uniqueStrCount]; - for (int i = 0; i < uniqueStrCount; i++) { - uniqueStrs[i] = data.readString(); - } - - boolean changed = false; - for (int i = 0; i < getCellCount(); i++) { - byte idx = data.readByte(); - - // an index of 0 indicates the slot is empty - Item item = null; - if (idx > 0) { - --idx; - String itemId = uniqueStrs[idx]; - item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId)); - } - if (cellItems[i] != item) { - changed = true; - cellItems[i] = item; - } - } - - return changed; - } - - @Override - public int getCellCount() - { - return 10; - } - - @Nullable - @Override - public Item getCellItem(int slot) { - // Client-side we'll need to actually use the synced state - if (world == null || world.isRemote) { - return cellItems[slot]; - } - - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (!stackInSlot.isEmpty()) { - return stackInSlot.getItem(); - } - return null; - } - - @Override - public int getCellStatus( final int slot ) - { - if( Platform.isClient() ) - { - return ( this.state >> ( slot * 3 ) ) & 3; - } - - final DriveWatcher handler = this.invBySlot[slot]; - if( handler == null ) - { - return 0; - } - - return handler.getStatus(); - } - - @Override - public boolean isPowered() - { - if( isRemote() ) - { - return ( this.state & BIT_POWER_MASK ) == BIT_POWER_MASK; - } - - return this.getProxy().isActive(); - } - - @Override - public boolean isCellBlinking( final int slot ) - { - return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01; - } - - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.isCached = false; - this.priority = data.getInt( "priority" ); - } - - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - data.putInt( "priority", this.priority ); - return data; - } - - @MENetworkEventSubscribe - public void powerRender( final MENetworkPowerStatusChange c ) - { - this.recalculateDisplay(); - } - - private void recalculateDisplay() - { - final boolean currentActive = this.getProxy().isActive(); - int newState = 0; - - if( currentActive ) - { - newState |= BIT_POWER_MASK; - } - - if( this.wasActive != currentActive ) - { - this.wasActive = currentActive; - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - for( int x = 0; x < this.getCellCount(); x++ ) - { - newState |= ( this.getCellStatus( x ) << ( 3 * x ) ); - } - - if( newState != this.state ) - { - this.state = newState; - this.markForUpdate(); - } - } - - @MENetworkEventSubscribe - public void channelRender( final MENetworkChannelsChanged c ) - { - this.recalculateDisplay(); - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } - - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } - - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( this.isCached ) - { - this.isCached = false; // recalculate the storage cell. - this.updateState(); - } - - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - - final IStorageGrid gs = this.getProxy().getStorage(); - Platform.postChanges( gs, removed, added, this.mySrc ); - } - catch( final GridAccessException ignored ) - { - } - - this.markForUpdate(); - } - - private void updateState() - { - if( !this.isCached ) - { - final Collection>> storageChannels = AEApi.instance().storage().storageChannels(); - storageChannels.forEach( channel -> this.inventoryHandlers.put( channel, new ArrayList<>( 10 ) ) ); - - double power = 2.0; - - for( int x = 0; x < this.inv.getSlots(); x++ ) - { - final ItemStack is = this.inv.getStackInSlot( x ); - this.invBySlot[x] = null; - this.handlersBySlot[x] = null; - - if( !is.isEmpty() ) - { - this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is ); - - if( this.handlersBySlot[x] != null ) - { - for( IStorageChannel> channel : storageChannels ) - { - - ICellInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, channel ); - - if( cell != null ) - { - this.inv.setHandler( x, cell ); - power += this.handlersBySlot[x].cellIdleDrain( is, cell ); - - final DriveWatcher ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this ); - ih.setPriority( this.priority ); - this.invBySlot[x] = ih; - this.inventoryHandlers.get( channel ).add( ih ); - - break; - } - } - } - } - } - - this.getProxy().setIdlePowerUsage( power ); - - this.isCached = true; - } - } - - @Override - public void onReady() - { - super.onReady(); - this.updateState(); - } - - @Override - public List getCellArray( final IStorageChannel channel ) - { - if( this.getProxy().isActive() ) - { - this.updateState(); - - return this.inventoryHandlers.get( channel ); - } - return Collections.emptyList(); - } - - @Override - public int getPriority() - { - return this.priority; - } - - @Override - public void setPriority( final int newValue ) - { - this.priority = newValue; - this.saveChanges(); - - this.isCached = false; // recalculate the storage cell. - this.updateState(); - - try - { - this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch( final GridAccessException e ) - { - // :P - } - } - - @Override - public void blinkCell( final int slot ) - { - this.state |= 1 << ( slot * 3 + 2 ); - - this.recalculateDisplay(); - } - - @Override - public void saveChanges( final ICellInventory cellInventory ) - { - this.world.markChunkDirty( this.pos, this ); - } - - private class CellValidInventoryFilter implements IAEItemFilter - { - - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return !stack.isEmpty() && AEApi.instance().registries().cell().isCellHandled( stack ); - } - - } - - @Override - public ItemStack getItemStackRepresentation() - { - return AEApi.instance().definitions().blocks().drive().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - } - - @Nonnull - @Override - public IModelData getModelData() { - return new DriveModelData(getUp(), getForward(), DriveSlotsState.fromChestOrDrive( this )); - } - - @Override - public ContainerType getContainerType() - { - return ContainerDrive.TYPE; - } + +public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost { + + private static final int BIT_POWER_MASK = 0x80000000; + private static final int BIT_BLINK_MASK = 0x24924924; + private static final int BIT_STATE_MASK = 0xDB6DB6DB; + + private final AppEngCellInventory inv = new AppEngCellInventory(this, 10); + private final ICellHandler[] handlersBySlot = new ICellHandler[10]; + private final DriveWatcher[] invBySlot = new DriveWatcher[10]; + private final IActionSource mySrc; + private boolean isCached = false; + private Map>, List> inventoryHandlers; + private int priority = 0; + private boolean wasActive = false; + // This is only used on the client + private final Item[] cellItems = new Item[10]; + + /** + * The state of all cells inside a drive as bitset, using the following format. + * + * Bit 31: power state. 0 = off, 1 = on. Bit 30: undefined Bit 29-0: 3 bits as + * state of each cell with the cell in slot 0 located in the 3 least significant + * bits. + * + * Cell states: Bit 2: blink. 0 = off, 1 = on. Bit 1-0: cell status + * + * + */ + private int state = 0; + + public TileDrive(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.mySrc = new MachineSource(this); + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.inv.setFilter(new CellValidInventoryFilter()); + this.inventoryHandlers = new IdentityHashMap<>(); + } + + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + int newState = 0; + + if (this.getProxy().isActive()) { + newState |= BIT_POWER_MASK; + } + for (int x = 0; x < this.getCellCount(); x++) { + newState |= (this.getCellStatus(x) << (3 * x)); + } + data.writeInt(newState); + + writeCellItemIds(data); + } + + private void writeCellItemIds(PacketBuffer data) { + List cellItemIds = new ArrayList<>(getCellCount()); + byte[] bm = new byte[getCellCount()]; + for (int x = 0; x < this.getCellCount(); x++) { + Item item = getCellItem(x); + if (item != null && item.getRegistryName() != null) { + ResourceLocation itemId = item.getRegistryName(); + int idx = cellItemIds.indexOf(itemId); + if (idx == -1) { + cellItemIds.add(itemId); + bm[x] = (byte) cellItemIds.size(); // We use 1-based in bm[] + } else { + bm[x] = (byte) (1 + idx); // 1-based indexing!! + } + } + } + + // Write out the list of unique cell item ids + data.writeByte(cellItemIds.size()); + for (ResourceLocation itemId : cellItemIds) { + data.writeResourceLocation(itemId); + } + // Then the lookup table for each slot + for (int i = 0; i < getCellCount(); i++) { + data.writeByte(bm[i]); + } + } + + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + boolean c = super.readFromStream(data); + final int oldState = this.state; + this.state = data.readInt(); + + c |= this.readCellItemIDs(data); + + return (this.state & BIT_STATE_MASK) != (oldState & BIT_STATE_MASK) || c; + } + + private boolean readCellItemIDs(final PacketBuffer data) { + int uniqueStrCount = data.readByte(); + String[] uniqueStrs = new String[uniqueStrCount]; + for (int i = 0; i < uniqueStrCount; i++) { + uniqueStrs[i] = data.readString(); + } + + boolean changed = false; + for (int i = 0; i < getCellCount(); i++) { + byte idx = data.readByte(); + + // an index of 0 indicates the slot is empty + Item item = null; + if (idx > 0) { + --idx; + String itemId = uniqueStrs[idx]; + item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId)); + } + if (cellItems[i] != item) { + changed = true; + cellItems[i] = item; + } + } + + return changed; + } + + @Override + public int getCellCount() { + return 10; + } + + @Nullable + @Override + public Item getCellItem(int slot) { + // Client-side we'll need to actually use the synced state + if (world == null || world.isRemote) { + return cellItems[slot]; + } + + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (!stackInSlot.isEmpty()) { + return stackInSlot.getItem(); + } + return null; + } + + @Override + public int getCellStatus(final int slot) { + if (Platform.isClient()) { + return (this.state >> (slot * 3)) & 3; + } + + final DriveWatcher handler = this.invBySlot[slot]; + if (handler == null) { + return 0; + } + + return handler.getStatus(); + } + + @Override + public boolean isPowered() { + if (isRemote()) { + return (this.state & BIT_POWER_MASK) == BIT_POWER_MASK; + } + + return this.getProxy().isActive(); + } + + @Override + public boolean isCellBlinking(final int slot) { + return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01; + } + + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.isCached = false; + this.priority = data.getInt("priority"); + } + + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + data.putInt("priority", this.priority); + return data; + } + + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange c) { + this.recalculateDisplay(); + } + + private void recalculateDisplay() { + final boolean currentActive = this.getProxy().isActive(); + int newState = 0; + + if (currentActive) { + newState |= BIT_POWER_MASK; + } + + if (this.wasActive != currentActive) { + this.wasActive = currentActive; + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } + + for (int x = 0; x < this.getCellCount(); x++) { + newState |= (this.getCellStatus(x) << (3 * x)); + } + + if (newState != this.state) { + this.state = newState; + this.markForUpdate(); + } + } + + @MENetworkEventSubscribe + public void channelRender(final MENetworkChannelsChanged c) { + this.recalculateDisplay(); + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } + + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } + + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (this.isCached) { + this.isCached = false; // recalculate the storage cell. + this.updateState(); + } + + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + + final IStorageGrid gs = this.getProxy().getStorage(); + Platform.postChanges(gs, removed, added, this.mySrc); + } catch (final GridAccessException ignored) { + } + + this.markForUpdate(); + } + + private void updateState() { + if (!this.isCached) { + final Collection>> storageChannels = AEApi.instance().storage() + .storageChannels(); + storageChannels.forEach(channel -> this.inventoryHandlers.put(channel, new ArrayList<>(10))); + + double power = 2.0; + + for (int x = 0; x < this.inv.getSlots(); x++) { + final ItemStack is = this.inv.getStackInSlot(x); + this.invBySlot[x] = null; + this.handlersBySlot[x] = null; + + if (!is.isEmpty()) { + this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler(is); + + if (this.handlersBySlot[x] != null) { + for (IStorageChannel> channel : storageChannels) { + + ICellInventoryHandler cell = this.handlersBySlot[x].getCellInventory(is, this, channel); + + if (cell != null) { + this.inv.setHandler(x, cell); + power += this.handlersBySlot[x].cellIdleDrain(is, cell); + + final DriveWatcher ih = new DriveWatcher(cell, is, this.handlersBySlot[x], + this); + ih.setPriority(this.priority); + this.invBySlot[x] = ih; + this.inventoryHandlers.get(channel).add(ih); + + break; + } + } + } + } + } + + this.getProxy().setIdlePowerUsage(power); + + this.isCached = true; + } + } + + @Override + public void onReady() { + super.onReady(); + this.updateState(); + } + + @Override + public List getCellArray(final IStorageChannel channel) { + if (this.getProxy().isActive()) { + this.updateState(); + + return this.inventoryHandlers.get(channel); + } + return Collections.emptyList(); + } + + @Override + public int getPriority() { + return this.priority; + } + + @Override + public void setPriority(final int newValue) { + this.priority = newValue; + this.saveChanges(); + + this.isCached = false; // recalculate the storage cell. + this.updateState(); + + try { + this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); + } catch (final GridAccessException e) { + // :P + } + } + + @Override + public void blinkCell(final int slot) { + this.state |= 1 << (slot * 3 + 2); + + this.recalculateDisplay(); + } + + @Override + public void saveChanges(final ICellInventory cellInventory) { + this.world.markChunkDirty(this.pos, this); + } + + private class CellValidInventoryFilter implements IAEItemFilter { + + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } + + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return !stack.isEmpty() && AEApi.instance().registries().cell().isCellHandled(stack); + } + + } + + @Override + public ItemStack getItemStackRepresentation() { + return AEApi.instance().definitions().blocks().drive().maybeStack(1).orElse(ItemStack.EMPTY); + } + + @Nonnull + @Override + public IModelData getModelData() { + return new DriveModelData(getUp(), getForward(), DriveSlotsState.fromChestOrDrive(this)); + } + + @Override + public ContainerType getContainerType() { + return ContainerDrive.TYPE; + } } - diff --git a/src/main/java/appeng/tile/storage/TileIOPort.java b/src/main/java/appeng/tile/storage/TileIOPort.java index 3892ee333..3d603936d 100644 --- a/src/main/java/appeng/tile/storage/TileIOPort.java +++ b/src/main/java/appeng/tile/storage/TileIOPort.java @@ -18,7 +18,6 @@ package appeng.tile.storage; - import java.util.IdentityHashMap; import java.util.List; import java.util.Map; @@ -75,457 +74,373 @@ import appeng.util.inv.WrapperChainedItemHandler; import appeng.util.inv.WrapperFilteredItemHandler; import appeng.util.inv.filter.AEItemFilters; - -public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable -{ - private static final int NUMBER_OF_CELL_SLOTS = 6; - private static final int NUMBER_OF_UPGRADE_SLOTS = 3; - - private final ConfigManager manager; - - private final AppEngInternalInventory inputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS ); - private final AppEngInternalInventory outputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS ); - private final IItemHandler combinedInventory = new WrapperChainedItemHandler( this.inputCells, this.outputCells ); - - private final IItemHandler inputCellsExt = new WrapperFilteredItemHandler( this.inputCells, AEItemFilters.INSERT_ONLY ); - private final IItemHandler outputCellsExt = new WrapperFilteredItemHandler( this.outputCells, AEItemFilters.EXTRACT_ONLY ); - - private final UpgradeInventory upgrades; - private final IActionSource mySrc; - private YesNo lastRedstoneState; - private ItemStack currentCell; - private Map, IMEInventory> cachedInventories; - - public TileIOPort(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); - this.getProxy().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.mySrc = new MachineSource( this ); - this.lastRedstoneState = YesNo.UNDECIDED; - - final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get(); - this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS ); - } - - @Override - public CompoundNBT write(final CompoundNBT data ) - { - super.write( data ); - this.manager.writeToNBT( data ); - this.upgrades.writeToNBT( data, "upgrades" ); - data.putInt( "lastRedstoneState", this.lastRedstoneState.ordinal() ); - return data; - } - - @Override - public void read(final CompoundNBT data ) - { - super.read( data ); - this.manager.readFromNBT( data ); - this.upgrades.readFromNBT( data, "upgrades" ); - if( data.contains("lastRedstoneState") ) - { - this.lastRedstoneState = YesNo.values()[data.getInt( "lastRedstoneState" )]; - } - } - - @Override - public AECableType getCableConnectionType( final AEPartLocation dir ) - { - return AECableType.SMART; - } - - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } - - private void updateTask() - { - try - { - if( this.hasWork() ) - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); - } - else - { - this.getProxy().getTick().sleepDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { - // :P - } - } - - public void updateRedstoneState() - { - final YesNo currentState = this.world.getRedstonePowerFromNeighbors( this.pos ) != 0 ? YesNo.YES : YesNo.NO; - if( this.lastRedstoneState != currentState ) - { - this.lastRedstoneState = currentState; - this.updateTask(); - } - } - - private boolean getRedstoneState() - { - if( this.lastRedstoneState == YesNo.UNDECIDED ) - { - this.updateRedstoneState(); - } - - return this.lastRedstoneState == YesNo.YES; - } - - private boolean isEnabled() - { - if( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 ) - { - return true; - } - - final RedstoneMode rs = (RedstoneMode) this.manager.getSetting( Settings.REDSTONE_CONTROLLED ); - if( rs == RedstoneMode.HIGH_SIGNAL ) - { - return this.getRedstoneState(); - } - return !this.getRedstoneState(); - } - - @Override - public IConfigManager getConfigManager() - { - return this.manager; - } - - @Override - public IItemHandler getInventoryByName( final String name ) - { - if( name.equals( "upgrades" ) ) - { - return this.upgrades; - } - - if( name.equals( "cells" ) ) - { - return this.combinedInventory; - } - - return null; - } - - @Override - public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue ) - { - this.updateTask(); - } - - private boolean hasWork() - { - if( this.isEnabled() ) - { - return !ItemHandlerUtil.isEmpty( this.inputCells ); - } - - return false; - } - - @Override - public IItemHandler getInternalInventory() - { - return this.combinedInventory; - } - - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { - if( this.inputCells == inv ) - { - this.updateTask(); - } - } - - @Override - protected IItemHandler getItemHandlerForSide( final Direction facing ) - { - if( facing == this.getUp() || facing == this.getUp().getOpposite() ) - { - return this.inputCellsExt; - } - else - { - return this.outputCellsExt; - } - } - - @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { - return new TickingRequest( TickRates.IOPort.getMin(), TickRates.IOPort.getMax(), !this.hasWork(), false ); - } - - @Override - public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall ) - { - if( !this.getProxy().isActive() ) - { - return TickRateModulation.IDLE; - } - - TickRateModulation ret = TickRateModulation.SLEEP; - long itemsToMove = 256; - - switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) - { - case 1: - itemsToMove *= 2; - break; - case 2: - itemsToMove *= 4; - break; - case 3: - itemsToMove *= 8; - break; - } - - try - { - final IEnergySource energy = this.getProxy().getEnergy(); - for( int x = 0; x < NUMBER_OF_CELL_SLOTS; x++ ) - { - final ItemStack is = this.inputCells.getStackInSlot( x ); - if( !is.isEmpty() ) - { - boolean shouldMove = true; - - for( IStorageChannel> c : AEApi.instance().storage().storageChannels() ) - { - if( itemsToMove > 0 ) - { - final IMEMonitor> network = this.getProxy().getStorage().getInventory( c ); - final IMEInventory inv = this.getInv( is, c ); - - if( inv == null ) - { - continue; - } - - if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY ) - { - itemsToMove = this.transferContents( energy, inv, network, itemsToMove, c ); - } - else - { - itemsToMove = this.transferContents( energy, network, inv, itemsToMove, c ); - } - - shouldMove &= this.shouldMove( inv ); - - if( itemsToMove > 0 ) - { - ret = TickRateModulation.IDLE; - } - else - { - ret = TickRateModulation.URGENT; - } - } - } - - if( itemsToMove > 0 && shouldMove && this.moveSlot( x ) ) - { - ret = TickRateModulation.URGENT; - } - else - { - ret = TickRateModulation.URGENT; - } - - } - } - } - catch( final GridAccessException e ) - { - ret = TickRateModulation.IDLE; - } - - return ret; - } - - @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return this.upgrades.getInstalledUpgrades( u ); - } - - private IMEInventory getInv( final ItemStack is, final IStorageChannel chan ) - { - if( this.currentCell != is ) - { - this.currentCell = is; - this.cachedInventories = new IdentityHashMap<>(); - - for( IStorageChannel> c : AEApi.instance().storage().storageChannels() ) - { - this.cachedInventories.put( c, AEApi.instance().registries().cell().getCellInventory( is, null, c ) ); - } - } - - return this.cachedInventories.get( chan ); - } - - private long transferContents( final IEnergySource energy, final IMEInventory src, final IMEInventory destination, long itemsToMove, final IStorageChannel chan ) - { - final IItemList myList; - if( src instanceof IMEMonitor ) - { - myList = ( (IMEMonitor) src ).getStorageList(); - } - else - { - myList = src.getAvailableItems( src.getChannel().createList() ); - } - - itemsToMove *= chan.transferFactor(); - - boolean didStuff; - - do - { - didStuff = false; - - for( final IAEStack s : myList ) - { - final long totalStackSize = s.getStackSize(); - if( totalStackSize > 0 ) - { - final IAEStack stack = destination.injectItems( s, Actionable.SIMULATE, this.mySrc ); - - long possible = 0; - if( stack == null ) - { - possible = totalStackSize; - } - else - { - possible = totalStackSize - stack.getStackSize(); - } - - if( possible > 0 ) - { - possible = Math.min( possible, itemsToMove ); - s.setStackSize( possible ); - - final IAEStack extracted = src.extractItems( s, Actionable.MODULATE, this.mySrc ); - if( extracted != null ) - { - possible = extracted.getStackSize(); - final IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc ); - - if( failed != null ) - { - possible -= failed.getStackSize(); - src.injectItems( failed, Actionable.MODULATE, this.mySrc ); - } - - if( possible > 0 ) - { - itemsToMove -= possible; - didStuff = true; - } - - break; - } - } - } - } - } - while( itemsToMove > 0 && didStuff ); - - return itemsToMove / chan.transferFactor(); - } - - private boolean shouldMove( final IMEInventory inv ) - { - final FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE ); - - if( inv != null ) - { - return this.matches( fm, inv ); - } - - return true; - } - - private boolean moveSlot( final int x ) - { - final InventoryAdaptor ad = new AdaptorItemHandler( this.outputCells ); - if( ad.addItems( this.inputCells.getStackInSlot( x ) ).isEmpty() ) - { - this.inputCells.setStackInSlot( x, ItemStack.EMPTY ); - return true; - } - return false; - } - - private boolean matches( final FullnessMode fm, final IMEInventory src ) - { - if( fm == FullnessMode.HALF ) - { - return true; - } - - final IItemList myList; - - if( src instanceof IMEMonitor ) - { - myList = ( (IMEMonitor) src ).getStorageList(); - } - else - { - myList = src.getAvailableItems( src.getChannel().createList() ); - } - - if( fm == FullnessMode.EMPTY ) - { - return myList.isEmpty(); - } - - final IAEStack test = myList.getFirstItem(); - if( test != null ) - { - test.setStackSize( 1 ); - return src.injectItems( test, Actionable.SIMULATE, this.mySrc ) != null; - } - return false; - } - - /** - * Adds the items in the upgrade slots to the drop list. - * - * @param w world - * @param pos pos of tile entity - * @param drops drops of tile entity - */ - @Override - public void getDrops( final World w, final BlockPos pos, final List drops ) - { - super.getDrops( w, pos, drops ); - - for( int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlots(); upgradeIndex++ ) - { - final ItemStack stackInSlot = this.upgrades.getStackInSlot( upgradeIndex ); - - if( !stackInSlot.isEmpty() ) - { - drops.add( stackInSlot ); - } - } - } +public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable { + private static final int NUMBER_OF_CELL_SLOTS = 6; + private static final int NUMBER_OF_UPGRADE_SLOTS = 3; + + private final ConfigManager manager; + + private final AppEngInternalInventory inputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS); + private final AppEngInternalInventory outputCells = new AppEngInternalInventory(this, NUMBER_OF_CELL_SLOTS); + private final IItemHandler combinedInventory = new WrapperChainedItemHandler(this.inputCells, this.outputCells); + + private final IItemHandler inputCellsExt = new WrapperFilteredItemHandler(this.inputCells, + AEItemFilters.INSERT_ONLY); + private final IItemHandler outputCellsExt = new WrapperFilteredItemHandler(this.outputCells, + AEItemFilters.EXTRACT_ONLY); + + private final UpgradeInventory upgrades; + private final IActionSource mySrc; + private YesNo lastRedstoneState; + private ItemStack currentCell; + private Map, IMEInventory> cachedInventories; + + public TileIOPort(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + this.getProxy().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.mySrc = new MachineSource(this); + this.lastRedstoneState = YesNo.UNDECIDED; + + final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get(); + this.upgrades = new BlockUpgradeInventory(ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS); + } + + @Override + public CompoundNBT write(final CompoundNBT data) { + super.write(data); + this.manager.writeToNBT(data); + this.upgrades.writeToNBT(data, "upgrades"); + data.putInt("lastRedstoneState", this.lastRedstoneState.ordinal()); + return data; + } + + @Override + public void read(final CompoundNBT data) { + super.read(data); + this.manager.readFromNBT(data); + this.upgrades.readFromNBT(data, "upgrades"); + if (data.contains("lastRedstoneState")) { + this.lastRedstoneState = YesNo.values()[data.getInt("lastRedstoneState")]; + } + } + + @Override + public AECableType getCableConnectionType(final AEPartLocation dir) { + return AECableType.SMART; + } + + @Override + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } + + private void updateTask() { + try { + if (this.hasWork()) { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } else { + this.getProxy().getTick().sleepDevice(this.getProxy().getNode()); + } + } catch (final GridAccessException e) { + // :P + } + } + + public void updateRedstoneState() { + final YesNo currentState = this.world.getRedstonePowerFromNeighbors(this.pos) != 0 ? YesNo.YES : YesNo.NO; + if (this.lastRedstoneState != currentState) { + this.lastRedstoneState = currentState; + this.updateTask(); + } + } + + private boolean getRedstoneState() { + if (this.lastRedstoneState == YesNo.UNDECIDED) { + this.updateRedstoneState(); + } + + return this.lastRedstoneState == YesNo.YES; + } + + private boolean isEnabled() { + if (this.getInstalledUpgrades(Upgrades.REDSTONE) == 0) { + return true; + } + + final RedstoneMode rs = (RedstoneMode) this.manager.getSetting(Settings.REDSTONE_CONTROLLED); + if (rs == RedstoneMode.HIGH_SIGNAL) { + return this.getRedstoneState(); + } + return !this.getRedstoneState(); + } + + @Override + public IConfigManager getConfigManager() { + return this.manager; + } + + @Override + public IItemHandler getInventoryByName(final String name) { + if (name.equals("upgrades")) { + return this.upgrades; + } + + if (name.equals("cells")) { + return this.combinedInventory; + } + + return null; + } + + @Override + public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum newValue) { + this.updateTask(); + } + + private boolean hasWork() { + if (this.isEnabled()) { + return !ItemHandlerUtil.isEmpty(this.inputCells); + } + + return false; + } + + @Override + public IItemHandler getInternalInventory() { + return this.combinedInventory; + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { + if (this.inputCells == inv) { + this.updateTask(); + } + } + + @Override + protected IItemHandler getItemHandlerForSide(final Direction facing) { + if (facing == this.getUp() || facing == this.getUp().getOpposite()) { + return this.inputCellsExt; + } else { + return this.outputCellsExt; + } + } + + @Override + public TickingRequest getTickingRequest(final IGridNode node) { + return new TickingRequest(TickRates.IOPort.getMin(), TickRates.IOPort.getMax(), !this.hasWork(), false); + } + + @Override + public TickRateModulation tickingRequest(final IGridNode node, final int ticksSinceLastCall) { + if (!this.getProxy().isActive()) { + return TickRateModulation.IDLE; + } + + TickRateModulation ret = TickRateModulation.SLEEP; + long itemsToMove = 256; + + switch (this.getInstalledUpgrades(Upgrades.SPEED)) { + case 1: + itemsToMove *= 2; + break; + case 2: + itemsToMove *= 4; + break; + case 3: + itemsToMove *= 8; + break; + } + + try { + final IEnergySource energy = this.getProxy().getEnergy(); + for (int x = 0; x < NUMBER_OF_CELL_SLOTS; x++) { + final ItemStack is = this.inputCells.getStackInSlot(x); + if (!is.isEmpty()) { + boolean shouldMove = true; + + for (IStorageChannel> c : AEApi.instance().storage().storageChannels()) { + if (itemsToMove > 0) { + final IMEMonitor> network = this.getProxy().getStorage() + .getInventory(c); + final IMEInventory inv = this.getInv(is, c); + + if (inv == null) { + continue; + } + + if (this.manager.getSetting(Settings.OPERATION_MODE) == OperationMode.EMPTY) { + itemsToMove = this.transferContents(energy, inv, network, itemsToMove, c); + } else { + itemsToMove = this.transferContents(energy, network, inv, itemsToMove, c); + } + + shouldMove &= this.shouldMove(inv); + + if (itemsToMove > 0) { + ret = TickRateModulation.IDLE; + } else { + ret = TickRateModulation.URGENT; + } + } + } + + if (itemsToMove > 0 && shouldMove && this.moveSlot(x)) { + ret = TickRateModulation.URGENT; + } else { + ret = TickRateModulation.URGENT; + } + + } + } + } catch (final GridAccessException e) { + ret = TickRateModulation.IDLE; + } + + return ret; + } + + @Override + public int getInstalledUpgrades(final Upgrades u) { + return this.upgrades.getInstalledUpgrades(u); + } + + private IMEInventory getInv(final ItemStack is, final IStorageChannel chan) { + if (this.currentCell != is) { + this.currentCell = is; + this.cachedInventories = new IdentityHashMap<>(); + + for (IStorageChannel> c : AEApi.instance().storage().storageChannels()) { + this.cachedInventories.put(c, AEApi.instance().registries().cell().getCellInventory(is, null, c)); + } + } + + return this.cachedInventories.get(chan); + } + + private long transferContents(final IEnergySource energy, final IMEInventory src, final IMEInventory destination, + long itemsToMove, final IStorageChannel chan) { + final IItemList myList; + if (src instanceof IMEMonitor) { + myList = ((IMEMonitor) src).getStorageList(); + } else { + myList = src.getAvailableItems(src.getChannel().createList()); + } + + itemsToMove *= chan.transferFactor(); + + boolean didStuff; + + do { + didStuff = false; + + for (final IAEStack s : myList) { + final long totalStackSize = s.getStackSize(); + if (totalStackSize > 0) { + final IAEStack stack = destination.injectItems(s, Actionable.SIMULATE, this.mySrc); + + long possible = 0; + if (stack == null) { + possible = totalStackSize; + } else { + possible = totalStackSize - stack.getStackSize(); + } + + if (possible > 0) { + possible = Math.min(possible, itemsToMove); + s.setStackSize(possible); + + final IAEStack extracted = src.extractItems(s, Actionable.MODULATE, this.mySrc); + if (extracted != null) { + possible = extracted.getStackSize(); + final IAEStack failed = Platform.poweredInsert(energy, destination, extracted, this.mySrc); + + if (failed != null) { + possible -= failed.getStackSize(); + src.injectItems(failed, Actionable.MODULATE, this.mySrc); + } + + if (possible > 0) { + itemsToMove -= possible; + didStuff = true; + } + + break; + } + } + } + } + } while (itemsToMove > 0 && didStuff); + + return itemsToMove / chan.transferFactor(); + } + + private boolean shouldMove(final IMEInventory inv) { + final FullnessMode fm = (FullnessMode) this.manager.getSetting(Settings.FULLNESS_MODE); + + if (inv != null) { + return this.matches(fm, inv); + } + + return true; + } + + private boolean moveSlot(final int x) { + final InventoryAdaptor ad = new AdaptorItemHandler(this.outputCells); + if (ad.addItems(this.inputCells.getStackInSlot(x)).isEmpty()) { + this.inputCells.setStackInSlot(x, ItemStack.EMPTY); + return true; + } + return false; + } + + private boolean matches(final FullnessMode fm, final IMEInventory src) { + if (fm == FullnessMode.HALF) { + return true; + } + + final IItemList myList; + + if (src instanceof IMEMonitor) { + myList = ((IMEMonitor) src).getStorageList(); + } else { + myList = src.getAvailableItems(src.getChannel().createList()); + } + + if (fm == FullnessMode.EMPTY) { + return myList.isEmpty(); + } + + final IAEStack test = myList.getFirstItem(); + if (test != null) { + test.setStackSize(1); + return src.injectItems(test, Actionable.SIMULATE, this.mySrc) != null; + } + return false; + } + + /** + * Adds the items in the upgrade slots to the drop list. + * + * @param w world + * @param pos pos of tile entity + * @param drops drops of tile entity + */ + @Override + public void getDrops(final World w, final BlockPos pos, final List drops) { + super.getDrops(w, pos, drops); + + for (int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlots(); upgradeIndex++) { + final ItemStack stackInSlot = this.upgrades.getStackInSlot(upgradeIndex); + + if (!stackInSlot.isEmpty()) { + drops.add(stackInSlot); + } + } + } } diff --git a/src/main/java/appeng/tile/storage/TileSkyChest.java b/src/main/java/appeng/tile/storage/TileSkyChest.java index 1b6636887..04737f2dc 100644 --- a/src/main/java/appeng/tile/storage/TileSkyChest.java +++ b/src/main/java/appeng/tile/storage/TileSkyChest.java @@ -18,11 +18,8 @@ package appeng.tile.storage; - import java.io.IOException; -import appeng.block.storage.BlockSkyChest; - import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.IContainerProvider; @@ -36,158 +33,137 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.MathHelper; import net.minecraftforge.items.IItemHandler; +import appeng.block.storage.BlockSkyChest; import appeng.tile.AEBaseInvTile; import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.inv.InvOperation; -public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid -{ +public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid { - private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 ); + private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 9 * 4); - // server - private int numPlayersUsing; - // client.. - private long lastEvent; - private float lidAngle; - private float prevLidAngle; + // server + private int numPlayersUsing; + // client.. + private long lastEvent; + private float lidAngle; + private float prevLidAngle; - public TileSkyChest(TileEntityType type) { - super(type); - } + public TileSkyChest(TileEntityType type) { + super(type); + } - @Override - protected void writeToStream( final PacketBuffer data ) throws IOException - { - super.writeToStream( data ); - data.writeBoolean( this.getPlayerOpen() > 0 ); - } + @Override + protected void writeToStream(final PacketBuffer data) throws IOException { + super.writeToStream(data); + data.writeBoolean(this.getPlayerOpen() > 0); + } - @Override - protected boolean readFromStream( final PacketBuffer data ) throws IOException - { - final boolean c = super.readFromStream( data ); - final int wasOpen = this.getPlayerOpen(); - this.setPlayerOpen( data.readBoolean() ? 1 : 0 ); + @Override + protected boolean readFromStream(final PacketBuffer data) throws IOException { + final boolean c = super.readFromStream(data); + final int wasOpen = this.getPlayerOpen(); + this.setPlayerOpen(data.readBoolean() ? 1 : 0); - if( wasOpen != this.getPlayerOpen() ) - { - this.setLastEvent( System.currentTimeMillis() ); - } + if (wasOpen != this.getPlayerOpen()) { + this.setLastEvent(System.currentTimeMillis()); + } - return c; // TESR yo! - } + return c; // TESR yo! + } - @Override - public boolean canRenderBreaking() - { - return true; - } + @Override + public boolean canRenderBreaking() { + return true; + } - @Override - public IItemHandler getInternalInventory() - { - return this.inv; - } + @Override + public IItemHandler getInternalInventory() { + return this.inv; + } - public void openInventory( final PlayerEntity player ) - { - if( !player.isSpectator() ) - { - this.setPlayerOpen( this.getPlayerOpen() + 1 ); - onOpenOrClose(); + public void openInventory(final PlayerEntity player) { + if (!player.isSpectator()) { + this.setPlayerOpen(this.getPlayerOpen() + 1); + onOpenOrClose(); - if( this.getPlayerOpen() == 1 ) - { - this.getWorld() - .playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN, - SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F ); - this.markForUpdate(); - } - } - } + if (this.getPlayerOpen() == 1) { + this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, + this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, + this.getWorld().rand.nextFloat() * 0.1F + 0.9F); + this.markForUpdate(); + } + } + } - public void closeInventory( final PlayerEntity player ) - { - if( !player.isSpectator() ) - { - this.setPlayerOpen( this.getPlayerOpen() - 1 ); - onOpenOrClose(); + public void closeInventory(final PlayerEntity player) { + if (!player.isSpectator()) { + this.setPlayerOpen(this.getPlayerOpen() - 1); + onOpenOrClose(); - if( this.getPlayerOpen() < 0 ) - { - this.setPlayerOpen( 0 ); - } + if (this.getPlayerOpen() < 0) { + this.setPlayerOpen(0); + } - if( this.getPlayerOpen() == 0 ) - { - this.getWorld() - .playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, - SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F ); - this.markForUpdate(); - } - } - } + if (this.getPlayerOpen() == 0) { + this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, + this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, + this.getWorld().rand.nextFloat() * 0.1F + 0.9F); + this.markForUpdate(); + } + } + } - // See ChestTileEntity - private void onOpenOrClose() { - Block block = this.getBlockState().getBlock(); - if (block instanceof BlockSkyChest) { - this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing); - this.world.notifyNeighborsOfStateChange(this.pos, block); - // FIXME: Uhm, we are we doing this? - this.world.notifyNeighborsOfStateChange(this.pos.down(), block); - } - } + // See ChestTileEntity + private void onOpenOrClose() { + Block block = this.getBlockState().getBlock(); + if (block instanceof BlockSkyChest) { + this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing); + this.world.notifyNeighborsOfStateChange(this.pos, block); + // FIXME: Uhm, we are we doing this? + this.world.notifyNeighborsOfStateChange(this.pos.down(), block); + } + } - @Override - public void tick() - { - this.prevLidAngle = this.lidAngle; - if( this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F ) - { - if( this.numPlayersUsing > 0 ) - { - this.lidAngle += 0.1F; - } - else - { - this.lidAngle -= 0.1F; - } + @Override + public void tick() { + this.prevLidAngle = this.lidAngle; + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + if (this.numPlayersUsing > 0) { + this.lidAngle += 0.1F; + } else { + this.lidAngle -= 0.1F; + } - this.lidAngle = MathHelper.clamp(this.lidAngle, 0, 1); - } - } + this.lidAngle = MathHelper.clamp(this.lidAngle, 0, 1); + } + } - @Override - public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added ) - { + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, + final ItemStack removed, final ItemStack added) { - } + } - public int getPlayerOpen() - { - return this.numPlayersUsing; - } + public int getPlayerOpen() { + return this.numPlayersUsing; + } - private void setPlayerOpen( final int playerOpen ) - { - this.numPlayersUsing = playerOpen; - } + private void setPlayerOpen(final int playerOpen) { + this.numPlayersUsing = playerOpen; + } - public long getLastEvent() - { - return this.lastEvent; - } + public long getLastEvent() { + return this.lastEvent; + } - private void setLastEvent( final long lastEvent ) - { - this.lastEvent = lastEvent; - } + private void setLastEvent(final long lastEvent) { + this.lastEvent = lastEvent; + } - @Override - public float getLidAngle(float partialTicks) { - return MathHelper.lerp(partialTicks, this.prevLidAngle, this.lidAngle); - } + @Override + public float getLidAngle(float partialTicks) { + return MathHelper.lerp(partialTicks, this.prevLidAngle, this.lidAngle); + } } diff --git a/src/main/java/appeng/util/BlockUpdate.java b/src/main/java/appeng/util/BlockUpdate.java index 23fc29510..196c47411 100644 --- a/src/main/java/appeng/util/BlockUpdate.java +++ b/src/main/java/appeng/util/BlockUpdate.java @@ -18,28 +18,22 @@ package appeng.util; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +public class BlockUpdate implements IWorldCallable { + private final BlockPos pos; -public class BlockUpdate implements IWorldCallable -{ - private final BlockPos pos; + BlockUpdate(final BlockPos pos) { + this.pos = pos; + } - BlockUpdate( final BlockPos pos ) - { - this.pos = pos; - } + @Override + public Boolean call(final World world) throws Exception { + if (world.isBlockLoaded(this.pos)) { + world.notifyNeighborsOfStateChange(this.pos, Platform.AIR_BLOCK); + } - @Override - public Boolean call( final World world ) throws Exception - { - if( world.isBlockLoaded( this.pos ) ) - { - world.notifyNeighborsOfStateChange( this.pos, Platform.AIR_BLOCK ); - } - - return true; - } + return true; + } } diff --git a/src/main/java/appeng/util/ClassInstantiation.java b/src/main/java/appeng/util/ClassInstantiation.java index 0c5499a3a..822f2761c 100644 --- a/src/main/java/appeng/util/ClassInstantiation.java +++ b/src/main/java/appeng/util/ClassInstantiation.java @@ -18,104 +18,80 @@ package appeng.util; - import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Optional; import appeng.core.AELog; +public class ClassInstantiation { + private final Class template; + private final Object[] args; -public class ClassInstantiation -{ - private final Class template; - private final Object[] args; + public ClassInstantiation(final Class template, final Object... args) { + this.template = template; + this.args = args; + } - public ClassInstantiation( final Class template, final Object... args ) - { - this.template = template; - this.args = args; - } + public Optional get() { + @SuppressWarnings("unchecked") + final Constructor[] constructors = (Constructor[]) this.template.getConstructors(); - public Optional get() - { - @SuppressWarnings( "unchecked" ) - final Constructor[] constructors = (Constructor[]) this.template.getConstructors(); + for (final Constructor constructor : constructors) { + final Class[] paramTypes = constructor.getParameterTypes(); + if (paramTypes.length == this.args.length) { + boolean valid = true; - for( final Constructor constructor : constructors ) - { - final Class[] paramTypes = constructor.getParameterTypes(); - if( paramTypes.length == this.args.length ) - { - boolean valid = true; + for (int idx = 0; idx < paramTypes.length; idx++) { + final Class cz = this.args[idx].getClass(); + if (!this.isClassMatch(paramTypes[idx], cz, this.args[idx])) { + valid = false; + } + } - for( int idx = 0; idx < paramTypes.length; idx++ ) - { - final Class cz = this.args[idx].getClass(); - if( !this.isClassMatch( paramTypes[idx], cz, this.args[idx] ) ) - { - valid = false; - } - } + if (valid) { + try { + return Optional.of(constructor.newInstance(this.args)); + } catch (final InstantiationException e) { + e.printStackTrace(); + } catch (final IllegalAccessException e) { + e.printStackTrace(); + } catch (final InvocationTargetException e) { + e.printStackTrace(); + } + break; + } + } + } - if( valid ) - { - try - { - return Optional.of( constructor.newInstance( this.args ) ); - } - catch( final InstantiationException e ) - { - e.printStackTrace(); - } - catch( final IllegalAccessException e ) - { - e.printStackTrace(); - } - catch( final InvocationTargetException e ) - { - e.printStackTrace(); - } - break; - } - } - } + return Optional.empty(); + } - return Optional.empty(); - } + private boolean isClassMatch(Class expected, Class got, final Object value) { + if (value == null && !expected.isPrimitive()) { + return true; + } - private boolean isClassMatch( Class expected, Class got, final Object value ) - { - if( value == null && !expected.isPrimitive() ) - { - return true; - } + expected = this.condense(expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, + Long.class, Float.class, Double.class); + got = this.condense(got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, + Float.class, Double.class); - expected = this.condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class ); - got = this.condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class ); + return expected == got || expected.isAssignableFrom(got); + } - return expected == got || expected.isAssignableFrom( got ); - } - - private Class condense( final Class expected, final Class... wrappers ) - { - if( expected.isPrimitive() ) - { - for( final Class clz : wrappers ) - { - try - { - if( expected == clz.getField( "TYPE" ).get( null ) ) - { - return clz; - } - } - catch( final Throwable t ) - { - AELog.debug( t ); - } - } - } - return expected; - } + private Class condense(final Class expected, final Class... wrappers) { + if (expected.isPrimitive()) { + for (final Class clz : wrappers) { + try { + if (expected == clz.getField("TYPE").get(null)) { + return clz; + } + } catch (final Throwable t) { + AELog.debug(t); + } + } + } + return expected; + } } diff --git a/src/main/java/appeng/util/ConfigManager.java b/src/main/java/appeng/util/ConfigManager.java index 2b4eeb6d1..39004623f 100644 --- a/src/main/java/appeng/util/ConfigManager.java +++ b/src/main/java/appeng/util/ConfigManager.java @@ -18,7 +18,6 @@ package appeng.util; - import java.util.EnumMap; import java.util.Map; import java.util.Set; @@ -31,102 +30,84 @@ import appeng.api.config.StorageFilter; import appeng.api.util.IConfigManager; import appeng.core.AELog; +public final class ConfigManager implements IConfigManager { + private final Map> settings = new EnumMap<>(Settings.class); + private final IConfigManagerHost target; -public final class ConfigManager implements IConfigManager -{ - private final Map> settings = new EnumMap<>( Settings.class ); - private final IConfigManagerHost target; + public ConfigManager(final IConfigManagerHost tile) { + this.target = tile; + } - public ConfigManager( final IConfigManagerHost tile ) - { - this.target = tile; - } + @Override + public Set getSettings() { + return this.settings.keySet(); + } - @Override - public Set getSettings() - { - return this.settings.keySet(); - } + @Override + public void registerSetting(final Settings settingName, final Enum defaultValue) { + this.settings.put(settingName, defaultValue); + } - @Override - public void registerSetting( final Settings settingName, final Enum defaultValue ) - { - this.settings.put( settingName, defaultValue ); - } + @Override + public Enum getSetting(final Settings settingName) { + final Enum oldValue = this.settings.get(settingName); - @Override - public Enum getSetting( final Settings settingName ) - { - final Enum oldValue = this.settings.get( settingName ); + if (oldValue != null) { + return oldValue; + } - if( oldValue != null ) - { - return oldValue; - } + throw new IllegalStateException("Invalid Config setting. Expected a non-null value for " + settingName); + } - throw new IllegalStateException( "Invalid Config setting. Expected a non-null value for " + settingName ); - } + @Override + public Enum putSetting(final Settings settingName, final Enum newValue) { + final Enum oldValue = this.getSetting(settingName); + this.settings.put(settingName, newValue); + this.target.updateSetting(this, settingName, newValue); + return oldValue; + } - @Override - public Enum putSetting( final Settings settingName, final Enum newValue ) - { - final 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(final CompoundNBT tagCompound) { + for (final Map.Entry> entry : this.settings.entrySet()) { + tagCompound.putString(entry.getKey().name(), this.settings.get(entry.getKey()).toString()); + } + } - /** - * save all settings using config manager. - * - * @param tagCompound to be written to compound - */ - @Override - public void writeToNBT( final CompoundNBT tagCompound ) - { - for( final Map.Entry> entry : this.settings.entrySet() ) - { - tagCompound.putString( entry.getKey().name(), this.settings.get( entry.getKey() ).toString() ); - } - } + /** + * read all settings using config manager. + * + * @param tagCompound to be read from compound + */ + @Override + public void readFromNBT(final CompoundNBT tagCompound) { + for (final Map.Entry> entry : this.settings.entrySet()) { + try { + if (tagCompound.contains(entry.getKey().name())) { + String value = tagCompound.getString(entry.getKey().name()); - /** - * read all settings using config manager. - * - * @param tagCompound to be read from compound - */ - @Override - public void readFromNBT( final CompoundNBT tagCompound ) - { - for( final Map.Entry> entry : this.settings.entrySet() ) - { - try - { - if( tagCompound.contains( entry.getKey().name() ) ) - { - String value = tagCompound.getString( entry.getKey().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(); + } - // 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(); - } + final Enum oldValue = this.settings.get(entry.getKey()); - final Enum oldValue = this.settings.get( entry.getKey() ); + final Enum newValue = Enum.valueOf(oldValue.getClass(), value); - final Enum newValue = Enum.valueOf( oldValue.getClass(), value ); - - this.putSetting( entry.getKey(), newValue ); - } - } - catch( final IllegalArgumentException e ) - { - AELog.debug( e ); - } - } - } + this.putSetting(entry.getKey(), newValue); + } + } catch (final IllegalArgumentException e) { + AELog.debug(e); + } + } + } } diff --git a/src/main/java/appeng/util/EnumCycler.java b/src/main/java/appeng/util/EnumCycler.java index 496a1d9b8..b8d498c2f 100644 --- a/src/main/java/appeng/util/EnumCycler.java +++ b/src/main/java/appeng/util/EnumCycler.java @@ -3,28 +3,22 @@ package appeng.util; import java.util.EnumSet; /** - * Simple utility class to help with select the "next" or "previous" value in a list of options represented - * by an enumeration. + * Simple utility class to help with select the "next" or "previous" value in a + * list of options represented by an enumeration. */ public final class EnumCycler { private EnumCycler() { } - public static > T rotateEnum( T ce, final boolean backwards, final EnumSet validOptions ) - { - do - { - if( backwards ) - { - ce = prevEnum( ce ); + public static > T rotateEnum(T ce, final boolean backwards, final EnumSet validOptions) { + do { + if (backwards) { + ce = prevEnum(ce); + } else { + ce = next(ce); } - else - { - ce = next( ce ); - } - } - while( !validOptions.contains( ce ) ); + } while (!validOptions.contains(ce)); return ce; } @@ -32,18 +26,15 @@ public final class EnumCycler { /* * Simple way to cycle an enum... */ - public static > T prevEnum( final T ce ) - { + public static > T prevEnum(final T ce) { T[] values = ce.getDeclaringClass().getEnumConstants(); int pLoc = ce.ordinal() - 1; - if( pLoc < 0 ) - { + if (pLoc < 0) { pLoc = values.length - 1; } - if( pLoc < 0 || pLoc >= values.length ) - { + if (pLoc < 0 || pLoc >= values.length) { pLoc = 0; } @@ -53,18 +44,15 @@ public final class EnumCycler { /* * Simple way to cycle an enum... */ - public static > T next(final T ce ) - { + public static > T next(final T ce) { T[] values = ce.getDeclaringClass().getEnumConstants(); int pLoc = ce.ordinal() + 1; - if( pLoc >= values.length ) - { + if (pLoc >= values.length) { pLoc = 0; } - if( pLoc < 0 || pLoc >= values.length ) - { + if (pLoc < 0 || pLoc >= values.length) { pLoc = 0; } diff --git a/src/main/java/appeng/util/IConfigManagerHost.java b/src/main/java/appeng/util/IConfigManagerHost.java index 720070949..e504a3d88 100644 --- a/src/main/java/appeng/util/IConfigManagerHost.java +++ b/src/main/java/appeng/util/IConfigManagerHost.java @@ -18,13 +18,10 @@ package appeng.util; - import appeng.api.config.Settings; import appeng.api.util.IConfigManager; +public interface IConfigManagerHost { -public interface IConfigManagerHost -{ - - void updateSetting(IConfigManager manager, Settings settingName, Enum newValue ); + void updateSetting(IConfigManager manager, Settings settingName, Enum newValue); } diff --git a/src/main/java/appeng/util/ISlimReadableNumberConverter.java b/src/main/java/appeng/util/ISlimReadableNumberConverter.java index ea427f4e1..22207c669 100644 --- a/src/main/java/appeng/util/ISlimReadableNumberConverter.java +++ b/src/main/java/appeng/util/ISlimReadableNumberConverter.java @@ -18,32 +18,27 @@ package appeng.util; - import javax.annotation.Nonnegative; - /** - * Limits a number converter to a char width of at max 3 characters. - * This is generally used for players, who activated the large font extension. + * Limits a number converter to a char width of at max 3 characters. This is + * generally used for players, who activated the large font extension. * * @author thatsIch * @version rv2 * @since rv2 */ -public interface ISlimReadableNumberConverter -{ - /** - * Converts a number into a human readable form. It will not round the number, but down it. - * Will try to cut the number down 1 decimal later, but rarely because of the 3 width limitation. - * Can only handle non negative numbers - * - * Example: - * 10000L -> 10K - * 9999L -> 9K, not 9.9K cause 4 width - * - * @param number to be converted number - * - * @return String in SI format cut down as far as possible - */ - String toSlimReadableForm( @Nonnegative long number ); +public interface ISlimReadableNumberConverter { + /** + * Converts a number into a human readable form. It will not round the number, + * but down it. Will try to cut the number down 1 decimal later, but rarely + * because of the 3 width limitation. Can only handle non negative numbers + * + * Example: 10000L -> 10K 9999L -> 9K, not 9.9K cause 4 width + * + * @param number to be converted number + * + * @return String in SI format cut down as far as possible + */ + String toSlimReadableForm(@Nonnegative long number); } diff --git a/src/main/java/appeng/util/IWideReadableNumberConverter.java b/src/main/java/appeng/util/IWideReadableNumberConverter.java index 209e03ea4..5b7b6e884 100644 --- a/src/main/java/appeng/util/IWideReadableNumberConverter.java +++ b/src/main/java/appeng/util/IWideReadableNumberConverter.java @@ -18,10 +18,8 @@ package appeng.util; - import javax.annotation.Nonnegative; - /** * Limits a number converter to a char width of at max 4 characters * @@ -29,20 +27,17 @@ import javax.annotation.Nonnegative; * @version rv2 * @since rv2 */ -public interface IWideReadableNumberConverter -{ - /** - * Converts a number into a human readable form. It will not round the number, but down it. - * Will try to cut the number down 1 decimal later if width can be below 4. - * Can only handle non negative numbers - * - * Example: - * 10000L -> 10K - * 9999L -> 9999 - * - * @param number to be converted number - * - * @return String in SI format cut down as far as possible - */ - String toWideReadableForm( @Nonnegative long number ); +public interface IWideReadableNumberConverter { + /** + * Converts a number into a human readable form. It will not round the number, + * but down it. Will try to cut the number down 1 decimal later if width can be + * below 4. Can only handle non negative numbers + * + * Example: 10000L -> 10K 9999L -> 9999 + * + * @param number to be converted number + * + * @return String in SI format cut down as far as possible + */ + String toWideReadableForm(@Nonnegative long number); } diff --git a/src/main/java/appeng/util/IWorldCallable.java b/src/main/java/appeng/util/IWorldCallable.java index 2e8057913..86ce06f55 100644 --- a/src/main/java/appeng/util/IWorldCallable.java +++ b/src/main/java/appeng/util/IWorldCallable.java @@ -18,35 +18,34 @@ package appeng.util; - import java.util.concurrent.Callable; import javax.annotation.Nullable; import net.minecraft.world.World; - /** - * An interface similar to {@link Callable}, but allowing to pass the {@link World} when calling. + * An interface similar to {@link Callable}, but allowing to pass the + * {@link World} when calling. * * @author yueh * @version rv3 * @see Callable * @since rv3 */ -public interface IWorldCallable -{ - /** - * Similar to {@link Callable#call()} - * - * @param world this param is given to not hold a reference to the world but let the caller handle it. Do not expect - * a world here thus can be null. - * - * @return result of call on the world. Can be null. - * - * @throws Exception if the call fails - * @see Callable#call() - */ - @Nullable - T call( @Nullable World world ) throws Exception; +public interface IWorldCallable { + /** + * Similar to {@link Callable#call()} + * + * @param world this param is given to not hold a reference to the world but let + * the caller handle it. Do not expect a world here thus can be + * null. + * + * @return result of call on the world. Can be null. + * + * @throws Exception if the call fails + * @see Callable#call() + */ + @Nullable + T call(@Nullable World world) throws Exception; } diff --git a/src/main/java/appeng/util/InWorldToolOperationResult.java b/src/main/java/appeng/util/InWorldToolOperationResult.java index 43f2a23fa..721abe15e 100644 --- a/src/main/java/appeng/util/InWorldToolOperationResult.java +++ b/src/main/java/appeng/util/InWorldToolOperationResult.java @@ -18,7 +18,6 @@ package appeng.util; - import java.util.ArrayList; import java.util.List; @@ -27,62 +26,51 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; +public class InWorldToolOperationResult { -public class InWorldToolOperationResult -{ + private final BlockState blockState; + private final List drops; - private final BlockState blockState; - private final List drops; + public InWorldToolOperationResult() { + this.blockState = null; + this.drops = null; + } - public InWorldToolOperationResult() - { - this.blockState = null; - this.drops = null; - } + public InWorldToolOperationResult(final BlockState block, final List drops) { + this.blockState = block; + this.drops = drops; + } - public InWorldToolOperationResult( final BlockState block, final List drops ) - { - this.blockState = block; - this.drops = drops; - } + public InWorldToolOperationResult(final BlockState block) { + this.blockState = block; + this.drops = null; + } - public InWorldToolOperationResult( final BlockState block ) - { - this.blockState = block; - this.drops = null; - } + public static InWorldToolOperationResult getBlockOperationResult(final ItemStack[] items) { + final List temp = new ArrayList<>(); + BlockState b = null; - public static InWorldToolOperationResult getBlockOperationResult( final ItemStack[] items ) - { - final List temp = new ArrayList<>(); - BlockState b = null; + for (final ItemStack l : items) { + if (b == null) { + final Block bl = Block.getBlockFromItem(l.getItem()); - for( final ItemStack l : items ) - { - if( b == null ) - { - final Block bl = Block.getBlockFromItem( l.getItem() ); + if (bl != null && !(bl instanceof AirBlock)) { + b = bl.getDefaultState(); + continue; + } + } - if( bl != null && !( bl instanceof AirBlock ) ) - { - b = bl.getDefaultState(); - continue; - } - } + temp.add(l); + } - temp.add( l ); - } + return new InWorldToolOperationResult(b, temp); + } - return new InWorldToolOperationResult( b, temp ); - } + public BlockState getBlockState() { + return this.blockState; + } - public BlockState getBlockState() - { - return this.blockState; - } - - public List getDrops() - { - return this.drops; - } + public List getDrops() { + return this.drops; + } } diff --git a/src/main/java/appeng/util/InventoryAdaptor.java b/src/main/java/appeng/util/InventoryAdaptor.java index 51b887795..7f7cc9a6a 100644 --- a/src/main/java/appeng/util/InventoryAdaptor.java +++ b/src/main/java/appeng/util/InventoryAdaptor.java @@ -18,7 +18,6 @@ package appeng.util; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -33,55 +32,50 @@ import appeng.util.inv.AdaptorItemHandlerPlayerInv; import appeng.util.inv.IInventoryDestination; import appeng.util.inv.ItemSlot; - /** - * Universal Facade for other inventories. Used to conveniently interact with various types of inventories. This is not - * used for - * actually monitoring an inventory. It is just for insertion and extraction, and is primarily used by import/export - * buses. + * Universal Facade for other inventories. Used to conveniently interact with + * various types of inventories. This is not used for actually monitoring an + * inventory. It is just for insertion and extraction, and is primarily used by + * import/export buses. */ -public abstract class InventoryAdaptor implements Iterable -{ - public static InventoryAdaptor getAdaptor( final TileEntity te, final Direction d ) - { - if( te != null ) - { - LazyOptional cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d); +public abstract class InventoryAdaptor implements Iterable { + public static InventoryAdaptor getAdaptor(final TileEntity te, final Direction d) { + if (te != null) { + LazyOptional cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d); - // Attempt getting an IItemHandler for the given side via caps - if( cap.isPresent() ) - { - return new AdaptorItemHandler( cap.orElseThrow(IllegalStateException::new) ); - } - } - return null; - } + // Attempt getting an IItemHandler for the given side via caps + if (cap.isPresent()) { + return new AdaptorItemHandler(cap.orElseThrow(IllegalStateException::new)); + } + } + return null; + } - public static InventoryAdaptor getAdaptor( final PlayerEntity te ) - { - if( te != null ) - { - return new AdaptorItemHandlerPlayerInv( te ); - } - return null; - } + public static InventoryAdaptor getAdaptor(final PlayerEntity te) { + if (te != null) { + return new AdaptorItemHandlerPlayerInv(te); + } + return null; + } - // return what was extracted. - public abstract ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination ); + // return what was extracted. + public abstract ItemStack removeItems(int amount, ItemStack filter, IInventoryDestination destination); - public abstract ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination ); + public abstract ItemStack simulateRemove(int amount, ItemStack filter, IInventoryDestination destination); - // return what was extracted. - public abstract ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ); + // return what was extracted. + public abstract ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, + IInventoryDestination destination); - public abstract ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ); + public abstract ItemStack simulateSimilarRemove(int amount, ItemStack filter, FuzzyMode fuzzyMode, + IInventoryDestination destination); - // return what isn't used... - public abstract ItemStack addItems( ItemStack toBeAdded ); + // return what isn't used... + public abstract ItemStack addItems(ItemStack toBeAdded); - public abstract ItemStack simulateAdd( ItemStack toBeSimulated ); + public abstract ItemStack simulateAdd(ItemStack toBeSimulated); - public abstract boolean containsItems(); + public abstract boolean containsItems(); - public abstract boolean hasSlots(); + public abstract boolean hasSlots(); } diff --git a/src/main/java/appeng/util/ItemSorters.java b/src/main/java/appeng/util/ItemSorters.java index ecfc031e8..c076101d2 100644 --- a/src/main/java/appeng/util/ItemSorters.java +++ b/src/main/java/appeng/util/ItemSorters.java @@ -18,91 +18,81 @@ package appeng.util; - import java.util.Comparator; import appeng.api.config.SortDir; import appeng.api.storage.data.IAEItemStack; import appeng.util.item.AEItemStack; +public class ItemSorters { -public class ItemSorters -{ + private static SortDir Direction = SortDir.ASCENDING; - private static SortDir Direction = SortDir.ASCENDING; + public static final Comparator CONFIG_BASED_SORT_BY_NAME = (o1, o2) -> { + final int cmp = Platform.getItemDisplayName(o1).getString() + .compareToIgnoreCase(Platform.getItemDisplayName(o2).getString()); + return applyDirection(cmp); + }; - public static final Comparator CONFIG_BASED_SORT_BY_NAME = ( o1, o2 ) -> - { - final int cmp = Platform.getItemDisplayName( o1 ).getString().compareToIgnoreCase( Platform.getItemDisplayName( o2 ).getString() ); - return applyDirection( cmp ); - }; + public static final Comparator CONFIG_BASED_SORT_BY_MOD = (o1, o2) -> { + final AEItemStack op1 = (AEItemStack) o1; + final AEItemStack op2 = (AEItemStack) o2; + int cmp = op1.getModID().compareToIgnoreCase(op2.getModID()); - public static final Comparator CONFIG_BASED_SORT_BY_MOD = ( o1, o2 ) -> - { - final AEItemStack op1 = (AEItemStack) o1; - final AEItemStack op2 = (AEItemStack) o2; - int cmp = op1.getModID().compareToIgnoreCase( op2.getModID() ); + if (cmp == 0) { + cmp = Platform.getItemDisplayName(o1).getString() + .compareToIgnoreCase(Platform.getItemDisplayName(o2).getString()); + } - if( cmp == 0 ) - { - cmp = Platform.getItemDisplayName( o1 ).getString().compareToIgnoreCase( Platform.getItemDisplayName( o2 ).getString() ); - } + return applyDirection(cmp); + }; - return applyDirection( cmp ); - }; + public static final Comparator CONFIG_BASED_SORT_BY_SIZE = (o1, o2) -> { + final int cmp = Long.compare(o2.getStackSize(), o1.getStackSize()); + return applyDirection(cmp); + }; - public static final Comparator CONFIG_BASED_SORT_BY_SIZE = ( o1, o2 ) -> - { - final int cmp = Long.compare( o2.getStackSize(), o1.getStackSize() ); - return applyDirection( cmp ); - }; + // FIXME private static IInvTweaks api; - // FIXME private static IInvTweaks api; + public static final Comparator CONFIG_BASED_SORT_BY_INV_TWEAKS = (o1, o2) -> { + // FIXME if( api == null ) + // FIXME { + return CONFIG_BASED_SORT_BY_NAME.compare(o1, o2); + // FIXME } - public static final Comparator CONFIG_BASED_SORT_BY_INV_TWEAKS = ( o1, o2 ) -> - { - // FIXME if( api == null ) - // FIXME { - return CONFIG_BASED_SORT_BY_NAME.compare( o1, o2 ); - // FIXME } + // FIXME final int cmp = api.compareItems( o1.createItemStack(), + // o2.createItemStack() ); + // FIXME return applyDirection( cmp ); + }; - // FIXME final int cmp = api.compareItems( o1.createItemStack(), o2.createItemStack() ); - // FIXME return applyDirection( cmp ); - }; + public static void init() { + // FIXME if( api != null ) + // FIXME { + // FIXME return; + // FIXME } - public static void init() - { - // FIXME if( api != null ) - // FIXME { - // FIXME return; - // FIXME } + // FIXME if( Integrations.invTweaks().isEnabled() ) + // FIXME { + // FIXME api = Integrations.invTweaks(); + // FIXME } + // FIXME else + // FIXME { + // FIXME api = null; + // FIXME } + } - // FIXME if( Integrations.invTweaks().isEnabled() ) - // FIXME { - // FIXME api = Integrations.invTweaks(); - // FIXME } - // FIXME else - // FIXME { - // FIXME api = null; - // FIXME } - } + private static SortDir getDirection() { + return Direction; + } - private static SortDir getDirection() - { - return Direction; - } + public static void setDirection(final SortDir direction) { + Direction = direction; + } - public static void setDirection( final SortDir direction ) - { - Direction = direction; - } - - private static int applyDirection( int cmp ) - { - if( getDirection() == SortDir.ASCENDING ) - { - return cmp; - } - return -cmp; - } + private static int applyDirection(int cmp) { + if (getDirection() == SortDir.ASCENDING) { + return cmp; + } + return -cmp; + } } diff --git a/src/main/java/appeng/util/Lazy.java b/src/main/java/appeng/util/Lazy.java index 567f5182b..e0904ef29 100644 --- a/src/main/java/appeng/util/Lazy.java +++ b/src/main/java/appeng/util/Lazy.java @@ -18,27 +18,21 @@ package appeng.util; - import java.util.function.Supplier; +public class Lazy implements Supplier { + private final Supplier supplier; + private T instance = null; -public class Lazy implements Supplier -{ - private final Supplier supplier; - private T instance = null; + public Lazy(final Supplier supplier) { + this.supplier = supplier; + } - public Lazy( final Supplier supplier ) - { - this.supplier = supplier; - } - - @Override - public T get() - { - if( this.instance == null ) - { - this.instance = this.supplier.get(); - } - return this.instance; - } + @Override + public T get() { + if (this.instance == null) { + this.instance = this.supplier.get(); + } + return this.instance; + } } diff --git a/src/main/java/appeng/util/LookDirection.java b/src/main/java/appeng/util/LookDirection.java index 9d5507d3c..6818d0412 100644 --- a/src/main/java/appeng/util/LookDirection.java +++ b/src/main/java/appeng/util/LookDirection.java @@ -18,29 +18,23 @@ package appeng.util; - import net.minecraft.util.math.Vec3d; +public class LookDirection { -public class LookDirection -{ + private final Vec3d a; + private final Vec3d b; - private final Vec3d a; - private final Vec3d b; + public LookDirection(final Vec3d a, final Vec3d b) { + this.a = a; + this.b = b; + } - public LookDirection( final Vec3d a, final Vec3d b ) - { - this.a = a; - this.b = b; - } + public Vec3d getA() { + return this.a; + } - public Vec3d getA() - { - return this.a; - } - - public Vec3d getB() - { - return this.b; - } + public Vec3d getB() { + return this.b; + } } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 851f2aae6..6fb6f499a 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -18,6 +18,46 @@ package appeng.util; +import java.text.DecimalFormat; +import java.util.*; +import java.util.stream.Collectors; + +import javax.annotation.Nullable; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.*; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.FakePlayerFactory; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.common.thread.SidedThreadGroups; +import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.registries.ForgeRegistries; import appeng.api.AEApi; import appeng.api.config.*; @@ -57,45 +97,6 @@ import appeng.util.helpers.ItemComparisonHelper; import appeng.util.helpers.P2PHelper; import appeng.util.item.AEItemStack; import appeng.util.prioritylist.IPartitionList; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.client.Minecraft; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.*; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.thread.SidedThreadGroups; -import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.registries.ForgeRegistries; - -import javax.annotation.Nullable; -import java.text.DecimalFormat; -import java.util.*; -import java.util.stream.Collectors; - /** * @author AlgorithmX2 @@ -103,194 +104,180 @@ import java.util.stream.Collectors; * @version rv2 * @since rv0 */ -public class Platform -{ +public class Platform { - // FIXME get rid of this shit, there's CAVE_AIR now !!! - public static final Block AIR_BLOCK = Blocks.AIR; + // FIXME get rid of this shit, there's CAVE_AIR now !!! + public static final Block AIR_BLOCK = Blocks.AIR; - public static final int DEF_OFFSET = 16; + public static final int DEF_OFFSET = 16; - private static final boolean CLIENT_INSTALL = FMLEnvironment.dist.isClient(); + private static final boolean CLIENT_INSTALL = FMLEnvironment.dist.isClient(); - /* - * random source, use it for item drop locations... - */ - private static final Random RANDOM_GENERATOR = new Random(); - private static final WeakHashMap FAKE_PLAYERS = new WeakHashMap<>(); - // private static Method getEntry; + /* + * random source, use it for item drop locations... + */ + private static final Random RANDOM_GENERATOR = new Random(); + private static final WeakHashMap FAKE_PLAYERS = new WeakHashMap<>(); + // private static Method getEntry; + private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper(); - private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper(); + public static ItemComparisonHelper itemComparisons() { + return ITEM_COMPARISON_HELPER; + } - public static ItemComparisonHelper itemComparisons() - { - return ITEM_COMPARISON_HELPER; - } + private static final P2PHelper P2P_HELPER = new P2PHelper(); - private static final P2PHelper P2P_HELPER = new P2PHelper(); + public static P2PHelper p2p() { + return P2P_HELPER; + } - public static P2PHelper p2p() - { - return P2P_HELPER; - } + public static Random getRandom() { + return RANDOM_GENERATOR; + } - public static Random getRandom() - { - return RANDOM_GENERATOR; - } + public static float getRandomFloat() { + return RANDOM_GENERATOR.nextFloat(); + } - public static float getRandomFloat() - { - return RANDOM_GENERATOR.nextFloat(); - } + /** + * This displays the value for encoded longs ( double *100 ) + * + * @param n to be formatted long value + * @param isRate if true it adds a /t to the formatted string + * + * @return formatted long value + */ + public static String formatPowerLong(final long n, final boolean isRate) { + double p = ((double) n) / 100; - /** - * This displays the value for encoded longs ( double *100 ) - * - * @param n to be formatted long value - * @param isRate if true it adds a /t to the formatted string - * - * @return formatted long value - */ - public static String formatPowerLong( final long n, final boolean isRate ) - { - double p = ( (double) n ) / 100; + final PowerUnits displayUnits = AEConfig.instance().selectedPowerUnit(); + p = PowerUnits.AE.convertTo(displayUnits, p); - final PowerUnits displayUnits = AEConfig.instance().selectedPowerUnit(); - p = PowerUnits.AE.convertTo( displayUnits, p ); + final String[] preFixes = { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" }; + String unitName = displayUnits.name(); - final String[] preFixes = { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" }; - String unitName = displayUnits.name(); + String level = ""; + int offset = 0; + while (p > 1000 && offset < preFixes.length) { + p /= 1000; + level = preFixes[offset]; + offset++; + } - String level = ""; - int offset = 0; - while( p > 1000 && offset < preFixes.length ) - { - p /= 1000; - level = preFixes[offset]; - offset++; - } + final DecimalFormat df = new DecimalFormat("#.##"); + return df.format(p) + ' ' + level + unitName + (isRate ? "/t" : ""); + } - final DecimalFormat df = new DecimalFormat( "#.##" ); - return df.format( p ) + ' ' + level + unitName + ( isRate ? "/t" : "" ); - } + public static AEPartLocation crossProduct(final AEPartLocation forward, final AEPartLocation up) { + final int west_x = forward.yOffset * up.zOffset - forward.zOffset * up.yOffset; + final int west_y = forward.zOffset * up.xOffset - forward.xOffset * up.zOffset; + final int west_z = forward.xOffset * up.yOffset - forward.yOffset * up.xOffset; - public static AEPartLocation crossProduct( final AEPartLocation forward, final AEPartLocation up ) - { - final int west_x = forward.yOffset * up.zOffset - forward.zOffset * up.yOffset; - final int west_y = forward.zOffset * up.xOffset - forward.xOffset * up.zOffset; - final int west_z = forward.xOffset * up.yOffset - forward.yOffset * up.xOffset; + switch (west_x + west_y * 2 + west_z * 3) { + case 1: + return AEPartLocation.EAST; + case -1: + return AEPartLocation.WEST; - switch( west_x + west_y * 2 + west_z * 3 ) - { - case 1: - return AEPartLocation.EAST; - case -1: - return AEPartLocation.WEST; + case 2: + return AEPartLocation.UP; + case -2: + return AEPartLocation.DOWN; - case 2: - return AEPartLocation.UP; - case -2: - return AEPartLocation.DOWN; + case 3: + return AEPartLocation.SOUTH; + case -3: + return AEPartLocation.NORTH; + } - case 3: - return AEPartLocation.SOUTH; - case -3: - return AEPartLocation.NORTH; - } + return AEPartLocation.INTERNAL; + } - return AEPartLocation.INTERNAL; - } + public static Direction crossProduct(final Direction forward, final Direction up) { + final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); + final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); + final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); - public static Direction crossProduct(final Direction forward, final Direction up ) - { - final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); - final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); - final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); + switch (west_x + west_y * 2 + west_z * 3) { + case 1: + return Direction.EAST; + case -1: + return Direction.WEST; - switch( west_x + west_y * 2 + west_z * 3 ) - { - case 1: - return Direction.EAST; - case -1: - return Direction.WEST; + case 2: + return Direction.UP; + case -2: + return Direction.DOWN; - case 2: - return Direction.UP; - case -2: - return Direction.DOWN; + case 3: + return Direction.SOUTH; + case -3: + return Direction.NORTH; + } - case 3: - return Direction.SOUTH; - case -3: - return Direction.NORTH; - } + // something is better then nothing? + return Direction.NORTH; + } - // something is better then nothing? - return Direction.NORTH; - } + /** + * @return True if client-side classes (such as Renderers) are available. + */ + public static boolean hasClientClasses() { + return FMLEnvironment.dist.isClient(); + } - /** - * @return True if client-side classes (such as Renderers) are available. - */ - public static boolean hasClientClasses() { - return FMLEnvironment.dist.isClient(); - } + /* + * returns true if the code is on the client. + */ + public static boolean isClient() { + return Thread.currentThread().getThreadGroup() != SidedThreadGroups.SERVER; + } - /* - * returns true if the code is on the client. - */ - public static boolean isClient() - { - return Thread.currentThread().getThreadGroup() != SidedThreadGroups.SERVER; - } + /* + * returns true if client classes are available. + */ + public static boolean isClientInstall() { + return CLIENT_INSTALL; + } - /* - * returns true if client classes are available. - */ - public static boolean isClientInstall() - { - return CLIENT_INSTALL; - } + public static boolean hasPermissions(final DimensionalCoord dc, final PlayerEntity player) { + if (!dc.isInWorld(player.world)) { + return false; + } + return player.world.canMineBlockBody(player, dc.getPos()); + } - public static boolean hasPermissions(final DimensionalCoord dc, final PlayerEntity player ) - { - if (!dc.isInWorld(player.world)) { - return false; - } - return player.world.canMineBlockBody( player, dc.getPos() ); - } + public static boolean checkPermissions(final PlayerEntity player, final Object accessInterface, + SecurityPermissions requiredPermission, boolean notifyPlayer) { + // FIXME: Check permissions... + if (requiredPermission != null && accessInterface instanceof IActionHost) { + final IGridNode gn = ((IActionHost) accessInterface).getActionableNode(); + if (gn != null) { + final IGrid g = gn.getGrid(); + if (g != null) { + final boolean requirePower = false; + if (requirePower) { + final IEnergyGrid eg = g.getCache(IEnergyGrid.class); + if (!eg.isNetworkPowered()) { + // FIXME trace logging? + return false; + } + } - public static boolean checkPermissions(final PlayerEntity player, final Object accessInterface, SecurityPermissions requiredPermission, boolean notifyPlayer) { - // FIXME: Check permissions... - if (requiredPermission != null && accessInterface instanceof IActionHost) { - final IGridNode gn = ((IActionHost) accessInterface).getActionableNode(); - if (gn != null) { - final IGrid g = gn.getGrid(); - if (g != null) { - final boolean requirePower = false; - if (requirePower) { - final IEnergyGrid eg = g.getCache(IEnergyGrid.class); - if (!eg.isNetworkPowered()) { - // FIXME trace logging? - return false; - } - } + final ISecurityGrid sg = g.getCache(ISecurityGrid.class); + if (!sg.hasPermission(player, requiredPermission)) { + player.sendMessage(new TranslationTextComponent("appliedenergistics2.permission_denied") + .applyTextStyle(TextFormatting.RED)); + // FIXME trace logging? + return false; + } + } + } + } - final ISecurityGrid sg = g.getCache(ISecurityGrid.class); - if (!sg.hasPermission(player, requiredPermission)) { - player.sendMessage(new TranslationTextComponent("appliedenergistics2.permission_denied") - .applyTextStyle(TextFormatting.RED)); - // FIXME trace logging? - return false; - } - } - } - } - - return true; - } + return true; + } // // /* @@ -308,22 +295,22 @@ public class Platform // } // } - public static ItemStack[] getBlockDrops(final World w, final BlockPos pos ) - { - // FIXME: Check assumption here and if this could only EVER be called with a server world - if (!(w instanceof ServerWorld)) { - return new ItemStack[0]; - } + public static ItemStack[] getBlockDrops(final World w, final BlockPos pos) { + // FIXME: Check assumption here and if this could only EVER be called with a + // server world + if (!(w instanceof ServerWorld)) { + return new ItemStack[0]; + } - ServerWorld serverWorld = (ServerWorld) w; + ServerWorld serverWorld = (ServerWorld) w; - final BlockState state = w.getBlockState( pos ); - final TileEntity tileEntity = w.getTileEntity(pos); + final BlockState state = w.getBlockState(pos); + final TileEntity tileEntity = w.getTileEntity(pos); - List out = Block.getDrops(state, serverWorld, pos, tileEntity); + List out = Block.getDrops(state, serverWorld, pos, tileEntity); - return out.toArray(new ItemStack[0]); - } + return out.toArray(new ItemStack[0]); + } // public static AEPartLocation cycleOrientations( final AEPartLocation dir, final boolean upAndDown ) // { @@ -371,236 +358,181 @@ public class Platform // return AEPartLocation.INTERNAL; // } - /* - * Generates Item entities in the world similar to how items are generally dropped. - */ - public static void spawnDrops(final World w, final BlockPos pos, final List drops ) - { - if( isServer() ) - { - for( final ItemStack i : drops ) - { - if( !i.isEmpty() ) - { - if( i.getCount() > 0 ) - { - final double offset_x = ( getRandomInt() % 32 - 16 ) / 82; - final double offset_y = ( getRandomInt() % 32 - 16 ) / 82; - final double offset_z = ( getRandomInt() % 32 - 16 ) / 82; - final ItemEntity ei = new ItemEntity( w, 0.5 + offset_x + pos.getX(), 0.5 + offset_y + pos.getY(), 0.2 + offset_z + pos.getZ(), i - .copy() ); - w.addEntity( ei ); - } - } - } - } - } + /* + * Generates Item entities in the world similar to how items are generally + * dropped. + */ + public static void spawnDrops(final World w, final BlockPos pos, final List drops) { + if (isServer()) { + for (final ItemStack i : drops) { + if (!i.isEmpty()) { + if (i.getCount() > 0) { + final double offset_x = (getRandomInt() % 32 - 16) / 82; + final double offset_y = (getRandomInt() % 32 - 16) / 82; + final double offset_z = (getRandomInt() % 32 - 16) / 82; + final ItemEntity ei = new ItemEntity(w, 0.5 + offset_x + pos.getX(), + 0.5 + offset_y + pos.getY(), 0.2 + offset_z + pos.getZ(), i.copy()); + w.addEntity(ei); + } + } + } + } + } - /* - * returns true if the code is on the server. - */ - public static boolean isServer() - { - return Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER; - } + /* + * returns true if the code is on the server. + */ + public static boolean isServer() { + return Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER; + } - public static int getRandomInt() - { - return Math.abs( RANDOM_GENERATOR.nextInt() ); - } + public static int getRandomInt() { + return Math.abs(RANDOM_GENERATOR.nextInt()); + } - @OnlyIn( Dist.CLIENT ) - public static List getTooltip(final Object o ) - { - if( o == null ) - { - return Collections.emptyList(); - } + @OnlyIn(Dist.CLIENT) + public static List getTooltip(final Object o) { + if (o == null) { + return Collections.emptyList(); + } - ItemStack itemStack = ItemStack.EMPTY; - if( o instanceof AEItemStack ) - { - final AEItemStack ais = (AEItemStack) o; - return ais.getToolTip(); - } - else if( o instanceof ItemStack ) - { - itemStack = (ItemStack) o; - } - else - { - return Collections.emptyList(); - } + ItemStack itemStack = ItemStack.EMPTY; + if (o instanceof AEItemStack) { + final AEItemStack ais = (AEItemStack) o; + return ais.getToolTip(); + } else if (o instanceof ItemStack) { + itemStack = (ItemStack) o; + } else { + return Collections.emptyList(); + } - try - { - ITooltipFlag.TooltipFlags tooltipFlag = Minecraft - .getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL; - return itemStack.getTooltip(Minecraft.getInstance().player, tooltipFlag); - } - catch( final Exception errB ) - { - return Collections.emptyList(); - } - } + try { + ITooltipFlag.TooltipFlags tooltipFlag = Minecraft.getInstance().gameSettings.advancedItemTooltips + ? ITooltipFlag.TooltipFlags.ADVANCED + : ITooltipFlag.TooltipFlags.NORMAL; + return itemStack.getTooltip(Minecraft.getInstance().player, tooltipFlag); + } catch (final Exception errB) { + return Collections.emptyList(); + } + } - public static String getModId( final IAEItemStack is ) - { - if( is == null ) - { - return "** Null"; - } + public static String getModId(final IAEItemStack is) { + if (is == null) { + return "** Null"; + } - final String n = ( (AEItemStack) is ).getModID(); - return n == null ? "** Null" : n; - } + final String n = ((AEItemStack) is).getModID(); + return n == null ? "** Null" : n; + } - public static String getModId( final IAEFluidStack fs ) - { - if( fs == null || fs.getFluidStack() == null ) - { - return "** Null"; - } + public static String getModId(final IAEFluidStack fs) { + if (fs == null || fs.getFluidStack() == null) { + return "** Null"; + } - final ResourceLocation n = ForgeRegistries.FLUIDS.getKey( fs.getFluidStack().getFluid() ); - return n == null ? "** Null" : n.getNamespace(); // FIXME: Check if namespace == mod - } + final ResourceLocation n = ForgeRegistries.FLUIDS.getKey(fs.getFluidStack().getFluid()); + return n == null ? "** Null" : n.getNamespace(); // FIXME: Check if namespace == mod + } - public static String getModName( String modId ) { - return "" + TextFormatting.BLUE + TextFormatting.ITALIC + ModList.get() - .getModContainerById( modId ) - .map(mc -> mc.getModInfo().getDisplayName()) - .orElse(null); - } + public static String getModName(String modId) { + return "" + TextFormatting.BLUE + TextFormatting.ITALIC + + ModList.get().getModContainerById(modId).map(mc -> mc.getModInfo().getDisplayName()).orElse(null); + } - public static ITextComponent getItemDisplayName( final Object o ) - { - if( o == null ) - { - return new StringTextComponent( "** Null"); - } + public static ITextComponent getItemDisplayName(final Object o) { + if (o == null) { + return new StringTextComponent("** Null"); + } - ItemStack itemStack = ItemStack.EMPTY; - if( o instanceof AEItemStack ) - { - final ITextComponent n = ( (AEItemStack) o ).getDisplayName(); - return n == null ? new StringTextComponent("** Null") : n; - } - else if( o instanceof ItemStack ) - { - itemStack = (ItemStack) o; - } - else - { - return new StringTextComponent("**Invalid Object"); - } + ItemStack itemStack = ItemStack.EMPTY; + if (o instanceof AEItemStack) { + final ITextComponent n = ((AEItemStack) o).getDisplayName(); + return n == null ? new StringTextComponent("** Null") : n; + } else if (o instanceof ItemStack) { + itemStack = (ItemStack) o; + } else { + return new StringTextComponent("**Invalid Object"); + } - try - { - return itemStack.getDisplayName(); - } - catch( final Exception errA ) - { - try - { - return new TranslationTextComponent(itemStack.getTranslationKey()); - } - catch( final Exception errB ) - { - return new StringTextComponent("** Exception"); - } - } - } + try { + return itemStack.getDisplayName(); + } catch (final Exception errA) { + try { + return new TranslationTextComponent(itemStack.getTranslationKey()); + } catch (final Exception errB) { + return new StringTextComponent("** Exception"); + } + } + } - public static ITextComponent getFluidDisplayName( Object o ) - { - if( o == null ) - { - return new StringTextComponent("** Null"); - } - FluidStack fluidStack = null; - if( o instanceof AEFluidStack) - { - fluidStack = ( (AEFluidStack) o ).getFluidStack(); - } - else if( o instanceof FluidStack ) - { - fluidStack = (FluidStack) o; - } - else - { - return new StringTextComponent("**Invalid Object"); - } - ITextComponent n = fluidStack.getDisplayName(); - if( n == null ) - { - n = new TranslationTextComponent(fluidStack.getTranslationKey()); - } - return n; - } + public static ITextComponent getFluidDisplayName(Object o) { + if (o == null) { + return new StringTextComponent("** Null"); + } + FluidStack fluidStack = null; + if (o instanceof AEFluidStack) { + fluidStack = ((AEFluidStack) o).getFluidStack(); + } else if (o instanceof FluidStack) { + fluidStack = (FluidStack) o; + } else { + return new StringTextComponent("**Invalid Object"); + } + ITextComponent n = fluidStack.getDisplayName(); + if (n == null) { + n = new TranslationTextComponent(fluidStack.getTranslationKey()); + } + return n; + } - public static boolean isWrench(final PlayerEntity player, final ItemStack eq, final BlockPos pos ) - { - if( !eq.isEmpty() ) - { - try - { - // TODO: Build Craft Wrench? - /* - * if( eq.getItem() instanceof IToolWrench ) - * { - * IToolWrench wrench = (IToolWrench) eq.getItem(); - * return wrench.canWrench( player, x, y, z ); - * } - */ + public static boolean isWrench(final PlayerEntity player, final ItemStack eq, final BlockPos pos) { + if (!eq.isEmpty()) { + try { + // TODO: Build Craft Wrench? + /* + * if( eq.getItem() instanceof IToolWrench ) { IToolWrench wrench = + * (IToolWrench) eq.getItem(); return wrench.canWrench( player, x, y, z ); } + */ - // FIXME if( eq.getItem() instanceof cofh.api.item.IToolHammer ) - // FIXME { - // FIXME return ( (cofh.api.item.IToolHammer) eq.getItem() ).isUsable( eq, player, pos ); - // FIXME } - } - catch( final Throwable ignore ) - { // explodes without BC + // FIXME if( eq.getItem() instanceof cofh.api.item.IToolHammer ) + // FIXME { + // FIXME return ( (cofh.api.item.IToolHammer) eq.getItem() ).isUsable( eq, + // player, pos ); + // FIXME } + } catch (final Throwable ignore) { // explodes without BC - } + } - if( eq.getItem() instanceof IAEWrench) - { - final IAEWrench wrench = (IAEWrench) eq.getItem(); - return wrench.canWrench( eq, player, pos ); - } - } - return false; - } + if (eq.getItem() instanceof IAEWrench) { + final IAEWrench wrench = (IAEWrench) eq.getItem(); + return wrench.canWrench(eq, player, pos); + } + } + return false; + } - public static boolean isChargeable( final ItemStack i ) - { - if( i.isEmpty() ) - { - return false; - } - final Item it = i.getItem(); - if( it instanceof IAEItemPowerStorage) - { - return ( (IAEItemPowerStorage) it ).getPowerFlow( i ) != AccessRestriction.READ; - } - return false; - } + public static boolean isChargeable(final ItemStack i) { + if (i.isEmpty()) { + return false; + } + final Item it = i.getItem(); + if (it instanceof IAEItemPowerStorage) { + return ((IAEItemPowerStorage) it).getPowerFlow(i) != AccessRestriction.READ; + } + return false; + } - public static PlayerEntity getPlayer(final ServerWorld w ) - { - Objects.requireNonNull( w ); + public static PlayerEntity getPlayer(final ServerWorld w) { + Objects.requireNonNull(w); - final PlayerEntity wrp = FAKE_PLAYERS.get( w ); - if( wrp != null ) - { - return wrp; - } + final PlayerEntity wrp = FAKE_PLAYERS.get(w); + if (wrp != null) { + return wrp; + } - final PlayerEntity p = FakePlayerFactory.getMinecraft( w ); - FAKE_PLAYERS.put( w, p ); - return p; - } + final PlayerEntity p = FakePlayerFactory.getMinecraft(w); + FAKE_PLAYERS.put(w, p); + return p; + } // // public static int MC2MEColor( final int color ) // { @@ -634,231 +566,212 @@ public class Platform // return -1; // } - /** - * Returns a random element from the given collection. - * - * @return null if the collection is empty - */ - @Nullable - public static T pickRandom( final Collection outs ) - { - if( outs.isEmpty() ) - { - return null; - } + /** + * Returns a random element from the given collection. + * + * @return null if the collection is empty + */ + @Nullable + public static T pickRandom(final Collection outs) { + if (outs.isEmpty()) { + return null; + } - int index = RANDOM_GENERATOR.nextInt( outs.size() ); - return Iterables.get( outs, index, null ); - } + int index = RANDOM_GENERATOR.nextInt(outs.size()); + return Iterables.get(outs, index, null); + } - public static AEPartLocation rotateAround( final AEPartLocation forward, final AEPartLocation axis ) - { - if( axis == AEPartLocation.INTERNAL || forward == AEPartLocation.INTERNAL ) - { - return forward; - } + public static AEPartLocation rotateAround(final AEPartLocation forward, final AEPartLocation axis) { + if (axis == AEPartLocation.INTERNAL || forward == AEPartLocation.INTERNAL) { + return forward; + } - switch( forward ) - { - case DOWN: - switch( axis ) - { - case DOWN: - return forward; - case UP: - return forward; - case NORTH: - return AEPartLocation.EAST; - case SOUTH: - return AEPartLocation.WEST; - case EAST: - return AEPartLocation.NORTH; - case WEST: - return AEPartLocation.SOUTH; - default: - break; - } - break; - case UP: - switch( axis ) - { - case NORTH: - return AEPartLocation.WEST; - case SOUTH: - return AEPartLocation.EAST; - case EAST: - return AEPartLocation.SOUTH; - case WEST: - return AEPartLocation.NORTH; - default: - break; - } - break; - case NORTH: - switch( axis ) - { - case UP: - return AEPartLocation.WEST; - case DOWN: - return AEPartLocation.EAST; - case EAST: - return AEPartLocation.UP; - case WEST: - return AEPartLocation.DOWN; - default: - break; - } - break; - case SOUTH: - switch( axis ) - { - case UP: - return AEPartLocation.EAST; - case DOWN: - return AEPartLocation.WEST; - case EAST: - return AEPartLocation.DOWN; - case WEST: - return AEPartLocation.UP; - default: - break; - } - break; - case EAST: - switch( axis ) - { - case UP: - return AEPartLocation.NORTH; - case DOWN: - return AEPartLocation.SOUTH; - case NORTH: - return AEPartLocation.UP; - case SOUTH: - return AEPartLocation.DOWN; - default: - break; - } - case WEST: - switch( axis ) - { - case UP: - return AEPartLocation.SOUTH; - case DOWN: - return AEPartLocation.NORTH; - case NORTH: - return AEPartLocation.DOWN; - case SOUTH: - return AEPartLocation.UP; - default: - break; - } - default: - break; - } - return forward; - } + switch (forward) { + case DOWN: + switch (axis) { + case DOWN: + return forward; + case UP: + return forward; + case NORTH: + return AEPartLocation.EAST; + case SOUTH: + return AEPartLocation.WEST; + case EAST: + return AEPartLocation.NORTH; + case WEST: + return AEPartLocation.SOUTH; + default: + break; + } + break; + case UP: + switch (axis) { + case NORTH: + return AEPartLocation.WEST; + case SOUTH: + return AEPartLocation.EAST; + case EAST: + return AEPartLocation.SOUTH; + case WEST: + return AEPartLocation.NORTH; + default: + break; + } + break; + case NORTH: + switch (axis) { + case UP: + return AEPartLocation.WEST; + case DOWN: + return AEPartLocation.EAST; + case EAST: + return AEPartLocation.UP; + case WEST: + return AEPartLocation.DOWN; + default: + break; + } + break; + case SOUTH: + switch (axis) { + case UP: + return AEPartLocation.EAST; + case DOWN: + return AEPartLocation.WEST; + case EAST: + return AEPartLocation.DOWN; + case WEST: + return AEPartLocation.UP; + default: + break; + } + break; + case EAST: + switch (axis) { + case UP: + return AEPartLocation.NORTH; + case DOWN: + return AEPartLocation.SOUTH; + case NORTH: + return AEPartLocation.UP; + case SOUTH: + return AEPartLocation.DOWN; + default: + break; + } + case WEST: + switch (axis) { + case UP: + return AEPartLocation.SOUTH; + case DOWN: + return AEPartLocation.NORTH; + case NORTH: + return AEPartLocation.DOWN; + case SOUTH: + return AEPartLocation.UP; + default: + break; + } + default: + break; + } + return forward; + } - public static Direction rotateAround(final Direction forward, final Direction axis ) - { - switch( forward ) - { - case DOWN: - switch( axis ) - { - case DOWN: - return forward; - case UP: - return forward; - case NORTH: - return Direction.EAST; - case SOUTH: - return Direction.WEST; - case EAST: - return Direction.NORTH; - case WEST: - return Direction.SOUTH; - default: - break; - } - break; - case UP: - switch( axis ) - { - case NORTH: - return Direction.WEST; - case SOUTH: - return Direction.EAST; - case EAST: - return Direction.SOUTH; - case WEST: - return Direction.NORTH; - default: - break; - } - break; - case NORTH: - switch( axis ) - { - case UP: - return Direction.WEST; - case DOWN: - return Direction.EAST; - case EAST: - return Direction.UP; - case WEST: - return Direction.DOWN; - default: - break; - } - break; - case SOUTH: - switch( axis ) - { - case UP: - return Direction.EAST; - case DOWN: - return Direction.WEST; - case EAST: - return Direction.DOWN; - case WEST: - return Direction.UP; - default: - break; - } - break; - case EAST: - switch( axis ) - { - case UP: - return Direction.NORTH; - case DOWN: - return Direction.SOUTH; - case NORTH: - return Direction.UP; - case SOUTH: - return Direction.DOWN; - default: - break; - } - case WEST: - switch( axis ) - { - case UP: - return Direction.SOUTH; - case DOWN: - return Direction.NORTH; - case NORTH: - return Direction.DOWN; - case SOUTH: - return Direction.UP; - default: - break; - } - default: - break; - } - return forward; - } + public static Direction rotateAround(final Direction forward, final Direction axis) { + switch (forward) { + case DOWN: + switch (axis) { + case DOWN: + return forward; + case UP: + return forward; + case NORTH: + return Direction.EAST; + case SOUTH: + return Direction.WEST; + case EAST: + return Direction.NORTH; + case WEST: + return Direction.SOUTH; + default: + break; + } + break; + case UP: + switch (axis) { + case NORTH: + return Direction.WEST; + case SOUTH: + return Direction.EAST; + case EAST: + return Direction.SOUTH; + case WEST: + return Direction.NORTH; + default: + break; + } + break; + case NORTH: + switch (axis) { + case UP: + return Direction.WEST; + case DOWN: + return Direction.EAST; + case EAST: + return Direction.UP; + case WEST: + return Direction.DOWN; + default: + break; + } + break; + case SOUTH: + switch (axis) { + case UP: + return Direction.EAST; + case DOWN: + return Direction.WEST; + case EAST: + return Direction.DOWN; + case WEST: + return Direction.UP; + default: + break; + } + break; + case EAST: + switch (axis) { + case UP: + return Direction.NORTH; + case DOWN: + return Direction.SOUTH; + case NORTH: + return Direction.UP; + case SOUTH: + return Direction.DOWN; + default: + break; + } + case WEST: + switch (axis) { + case UP: + return Direction.SOUTH; + case DOWN: + return Direction.NORTH; + case NORTH: + return Direction.DOWN; + case SOUTH: + return Direction.UP; + default: + break; + } + default: + break; + } + return forward; + } // @OnlyIn( Dist.CLIENT ) // public static String gui_localize( final String string ) @@ -866,548 +779,480 @@ public class Platform // return I18n.format( string ); // } - public static LookDirection getPlayerRay(final PlayerEntity playerIn ) - { - final double x = playerIn.prevPosX + ( playerIn.getPosX() - playerIn.prevPosX ); - final double y = playerIn.prevPosY + ( playerIn.getPosY() - playerIn.prevPosY ) + playerIn.getEyeHeight(); - final double z = playerIn.prevPosZ + ( playerIn.getPosZ() - playerIn.prevPosZ ); - - final float playerPitch = playerIn.prevRotationPitch + ( playerIn.rotationPitch - playerIn.prevRotationPitch ); - final float playerYaw = playerIn.prevRotationYaw + ( playerIn.rotationYaw - playerIn.prevRotationYaw ); - - final float yawRayX = MathHelper.sin( -playerYaw * 0.017453292f - (float) Math.PI ); - final float yawRayZ = MathHelper.cos( -playerYaw * 0.017453292f - (float) Math.PI ); - - final float pitchMultiplier = -MathHelper.cos( -playerPitch * 0.017453292F ); - final float eyeRayY = MathHelper.sin( -playerPitch * 0.017453292F ); - final float eyeRayX = yawRayX * pitchMultiplier; - final float eyeRayZ = yawRayZ * pitchMultiplier; - - double reachDistance = playerIn.getAttribute(PlayerEntity.REACH_DISTANCE).getValue(); - - final Vec3d from = new Vec3d( x, y, z ); - final Vec3d to = from.add( eyeRayX * reachDistance, eyeRayY * reachDistance, eyeRayZ * reachDistance ); - - return new LookDirection( from, to ); - } - - public static RayTraceResult rayTrace(final PlayerEntity p, final boolean hitBlocks, final boolean hitEntities ) - { - final World w = p.getEntityWorld(); - - final float f = 1.0F; - float f1 = p.prevRotationPitch + ( p.rotationPitch - p.prevRotationPitch ) * f; - final float f2 = p.prevRotationYaw + ( p.rotationYaw - p.prevRotationYaw ) * f; - final double d0 = p.prevPosX + ( p.getPosX() - p.prevPosX ) * f; - final double d1 = p.prevPosY + ( p.getPosY() - p.prevPosY ) * f + 1.62D - p.getYOffset(); - final double d2 = p.prevPosZ + ( p.getPosZ() - p.prevPosZ ) * f; - final Vec3d vec3 = new Vec3d( d0, d1, d2 ); - final float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI ); - final float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI ); - final float f5 = -MathHelper.cos( -f1 * 0.017453292F ); - final float f6 = MathHelper.sin( -f1 * 0.017453292F ); - final float f7 = f4 * f5; - final float f8 = f3 * f5; - final double d3 = 32.0D; - - final Vec3d vec31 = vec3.add( f7 * d3, f6 * d3, f8 * d3 ); - - final AxisAlignedBB bb = new AxisAlignedBB( Math.min( vec3.x, vec31.x ), Math.min( vec3.y, vec31.y ), Math.min( vec3.z, - vec31.z ), Math.max( vec3.x, vec31.x ), Math.max( vec3.y, vec31.y ), Math.max( vec3.z, vec31.z ) ).grow( - 16, 16, 16 ); - - Entity entity = null; - double closest = 9999999.0D; - if( hitEntities ) - { - final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb ); - - for (final Entity entity1 : list) { - if (entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) { - // prevent killing / flying of mounts. - if (entity1.isRidingOrBeingRiddenBy(p)) { - continue; - } - - f1 = 0.3F; - // FIXME: Three different bounding boxes available, should double-check - final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1); - final Vec3d rtResult = boundingBox.rayTrace(vec3, vec31).orElse(null); - - if (rtResult != null) { - final double nd = vec3.squareDistanceTo(rtResult); - - if (nd < closest) { - entity = entity1; - closest = nd; - } - } - } - } - } - - RayTraceResult pos = null; - Vec3d vec = null; - - if( hitBlocks ) - { - vec = new Vec3d( d0, d1, d2 ); - // FIXME: passing p as entity here might be incorrect - pos = w.rayTraceBlocks( new RayTraceContext(vec3, vec31, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.ANY, p) ); - } - - if( entity != null && pos != null && pos.getHitVec().squareDistanceTo( vec ) > closest ) - { - pos = new EntityRayTraceResult( entity ); - } - else if( entity != null && pos == null ) - { - pos = new EntityRayTraceResult( entity ); - } - - return pos; - } - - public static > T poweredExtraction( final IEnergySource energy, final IMEInventory cell, final T request, final IActionSource src ) - { - return poweredExtraction( energy, cell, request, src, Actionable.MODULATE ); - } - - public static > T poweredExtraction( final IEnergySource energy, final IMEInventory cell, final T request, final IActionSource src, final Actionable mode ) - { - Preconditions.checkNotNull( energy ); - Preconditions.checkNotNull( cell ); - Preconditions.checkNotNull( request ); - Preconditions.checkNotNull( src ); - Preconditions.checkNotNull( mode ); - - final T possible = cell.extractItems( request.copy(), Actionable.SIMULATE, src ); - - long retrieved = 0; - if( possible != null ) - { - retrieved = possible.getStackSize(); - } - - final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() ); - final double availablePower = energy.extractAEPower( retrieved / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG ); - final long itemToExtract = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), retrieved ); - - if( itemToExtract > 0 ) - { - if( mode == Actionable.MODULATE ) - { - energy.extractAEPower( retrieved / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG ); - possible.setStackSize( itemToExtract ); - final T ret = cell.extractItems( possible, Actionable.MODULATE, src ); - - if( ret != null ) - { - src.player().ifPresent( player -> AeStats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) ); - } - return ret; - } - else - { - return possible.setStackSize( itemToExtract ); - } - } - - return null; - } - - public static > T poweredInsert( final IEnergySource energy, final IMEInventory cell, final T input, final IActionSource src ) - { - return poweredInsert( energy, cell, input, src, Actionable.MODULATE ); - } - - public static > T poweredInsert( final IEnergySource energy, final IMEInventory cell, final T input, final IActionSource src, final Actionable mode ) - { - Preconditions.checkNotNull( energy ); - Preconditions.checkNotNull( cell ); - Preconditions.checkNotNull( input ); - Preconditions.checkNotNull( src ); - Preconditions.checkNotNull( mode ); - - final T possible = cell.injectItems( input.copy(), Actionable.SIMULATE, src ); - - long stored = input.getStackSize(); - if( possible != null ) - { - stored -= possible.getStackSize(); - } - - final double energyFactor = Math.max( 1.0, cell.getChannel().transferFactor() ); - final double availablePower = energy.extractAEPower( stored / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG ); - final long itemToAdd = Math.min( (long) ( ( availablePower * energyFactor ) + 0.9 ), stored ); - - if( itemToAdd > 0 ) - { - if( mode == Actionable.MODULATE ) - { - energy.extractAEPower( stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG ); - if( itemToAdd < input.getStackSize() ) - { - final long original = input.getStackSize(); - final T split = input.copy(); - split.decStackSize( itemToAdd ); - input.setStackSize( itemToAdd ); - split.add( cell.injectItems( input, Actionable.MODULATE, src ) ); - - src.player().ifPresent( player -> - { - final long diff = original - split.getStackSize(); - AeStats.ItemsInserted.addToPlayer( player, (int) diff ); - } ); - - return split; - } - - final T ret = cell.injectItems( input, Actionable.MODULATE, src ); - - src.player().ifPresent( player -> - { - final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize(); - AeStats.ItemsInserted.addToPlayer( player, (int) diff ); - } ); - - return ret; - } - else - { - final T ret = input.copy().setStackSize( input.getStackSize() - itemToAdd ); - return ( ret != null && ret.getStackSize() > 0 ) ? ret : null; - } - } - - return input; - } - - @SuppressWarnings( { "rawtypes", "unchecked" } ) - public static void postChanges(final IStorageGrid gs, final ItemStack removed, final ItemStack added, final IActionSource src ) - { - for( final IStorageChannel chan : AEApi.instance().storage().storageChannels() ) - { - final IItemList myChanges = chan.createList(); - - if( !removed.isEmpty() ) - { - final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory( removed, null, chan ); - if( myInv != null ) - { - myInv.getAvailableItems( myChanges ); - for( final IAEStack is : myChanges ) - { - is.setStackSize( -is.getStackSize() ); - } - } - } - if( !added.isEmpty() ) - { - final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory( added, null, chan ); - if( myInv != null ) - { - myInv.getAvailableItems( myChanges ); - } - - } - gs.postAlterationOfStoredItems( chan, myChanges, src ); - } - } - - public static > void postListChanges(final IItemList before, final IItemList after, final IMEMonitorHandlerReceiver meMonitorPassthrough, final IActionSource source ) - { - final List changes = new ArrayList<>(); - - for( final T is : before ) - { - is.setStackSize( -is.getStackSize() ); - } - - for( final T is : after ) - { - before.add( is ); - } - - for( final T is : before ) - { - if( is.getStackSize() != 0 ) - { - changes.add( is ); - } - } - - if( !changes.isEmpty() ) - { - meMonitorPassthrough.postChange( null, changes, source ); - } - } - - public static boolean securityCheck(final GridNode a, final GridNode b ) - { - if( a.getLastSecurityKey() == -1 && b.getLastSecurityKey() == -1 ) - { - return true; - } - else if( a.getLastSecurityKey() == b.getLastSecurityKey() ) - { - return true; - } - - final boolean a_isSecure = isPowered( a.getGrid() ) && a.getLastSecurityKey() != -1; - final boolean b_isSecure = isPowered( b.getGrid() ) && b.getLastSecurityKey() != -1; - - if( AEConfig.instance().isFeatureEnabled( AEFeature.LOG_SECURITY_AUDITS ) ) - { - final String locationA = a.getGridBlock().isWorldAccessible() ? a.getGridBlock().getLocation().toString() : "notInWorld"; - final String locationB = b.getGridBlock().isWorldAccessible() ? b.getGridBlock().getLocation().toString() : "notInWorld"; - - AELog.info( "Audit: Node A [isSecure=%b, key=%d, playerID=%d, location={%s}] vs Node B[isSecure=%b, key=%d, playerID=%d, location={%s}]", - a_isSecure, a.getLastSecurityKey(), a.getPlayerID(), locationA, b_isSecure, b.getLastSecurityKey(), b.getPlayerID(), locationB ); - } - - // can't do that son... - if( a_isSecure && b_isSecure ) - { - return false; - } - - if( !a_isSecure && b_isSecure ) - { - return checkPlayerPermissions( b.getGrid(), a.getPlayerID() ); - } - - if( a_isSecure && !b_isSecure ) - { - return checkPlayerPermissions( a.getGrid(), b.getPlayerID() ); - } - - return true; - } - - private static boolean isPowered( final IGrid grid ) - { - if( grid == null ) - { - return false; - } - - final IEnergyGrid eg = grid.getCache( IEnergyGrid.class ); - return eg.isNetworkPowered(); - } - - private static boolean checkPlayerPermissions(final IGrid grid, final int playerID ) - { - if( grid == null ) - { - return true; - } - - final ISecurityGrid gs = grid.getCache( ISecurityGrid.class ); - - if( gs == null ) - { - return true; - } - - if( !gs.isAvailable() ) - { - return true; - } - - return gs.hasPermission( playerID, SecurityPermissions.BUILD ); - } - - public static void configurePlayer(final PlayerEntity player, final AEPartLocation side, final TileEntity tile ) - { - float pitch = 0.0f; - float yaw = 0.0f; - // player.yOffset = 1.8f; - - switch( side ) - { - case DOWN: - pitch = 90.0f; - // player.getYOffset() = -1.8f; - break; - case EAST: - yaw = -90.0f; - break; - case NORTH: - yaw = 180.0f; - break; - case SOUTH: - yaw = 0.0f; - break; - case INTERNAL: - break; - case UP: - pitch = 90.0f; - break; - case WEST: - yaw = 90.0f; - break; - } - - player.setLocationAndAngles( - tile.getPos().getX() + 0.5, - tile.getPos().getY() + 0.5, - tile.getPos().getZ() + 0.5, - yaw, - pitch - ); - } - - public static boolean canAccess(final AENetworkProxy gridProxy, final IActionSource src ) - { - try - { - if( src.player().isPresent() ) - { - return gridProxy.getSecurity().hasPermission( src.player().get(), SecurityPermissions.BUILD ); - } - else if( src.machine().isPresent() ) - { - final IActionHost te = src.machine().get(); - final IGridNode n = te.getActionableNode(); - if( n == null ) - { - return false; - } - - final int playerID = n.getPlayerID(); - return gridProxy.getSecurity().hasPermission( playerID, SecurityPermissions.BUILD ); - } - else - { - return false; - } - } - catch( final GridAccessException gae ) - { - return false; - } - } - - public static ItemStack extractItemsByRecipe(final IEnergySource energySrc, final IActionSource mySrc, final IMEMonitor src, final World w, final IRecipe r, final ItemStack output, final CraftingInventory ci, final ItemStack providedTemplate, final int slot, final IItemList items, final Actionable realForFake, final IPartitionList filter ) - { - if( energySrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.9 ) - { - if( providedTemplate == null ) - { - return ItemStack.EMPTY; - } - - final AEItemStack ae_req = AEItemStack.fromItemStack( providedTemplate ); - ae_req.setStackSize( 1 ); - - if( filter == null || filter.isListed( ae_req ) ) - { - final IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc ); - if( ae_ext != null ) - { - final ItemStack extracted = ae_ext.createItemStack(); - if( !extracted.isEmpty() ) - { - energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG ); - return extracted; - } - } - } - - final boolean checkFuzzy = /* FIXME ae_req.getOre().isPresent() || FIXME providedTemplate.getDamage() == OreDictionary.WILDCARD_VALUE || */ providedTemplate.hasTag() - || providedTemplate.isDamageable(); - - if( items != null && checkFuzzy ) - { - for( final IAEItemStack x : items ) - { - final ItemStack sh = x.getDefinition(); - if( ( Platform.itemComparisons().isEqualItemType( providedTemplate, sh ) /* FIXME || ae_req.sameOre( x ) */ ) && !ItemStack.areItemsEqual( sh, - output ) ) - { // Platform.isSameItemType( sh, providedTemplate ) - final ItemStack cp = sh.copy(); - cp.setCount( 1 ); - ci.setInventorySlotContents( slot, cp ); - if( r.matches( ci, w ) && ItemStack.areItemsEqual( r.getCraftingResult( ci ), output ) ) - { - final IAEItemStack ax = x.copy(); - ax.setStackSize( 1 ); - if( filter == null || filter.isListed( ax ) ) - { - final IAEItemStack ex = src.extractItems( ax, realForFake, mySrc ); - if( ex != null ) - { - energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG ); - return ex.createItemStack(); - } - } - } - ci.setInventorySlotContents( slot, providedTemplate ); - } - } - } - } - return ItemStack.EMPTY; - } + public static LookDirection getPlayerRay(final PlayerEntity playerIn) { + final double x = playerIn.prevPosX + (playerIn.getPosX() - playerIn.prevPosX); + final double y = playerIn.prevPosY + (playerIn.getPosY() - playerIn.prevPosY) + playerIn.getEyeHeight(); + final double z = playerIn.prevPosZ + (playerIn.getPosZ() - playerIn.prevPosZ); + + final float playerPitch = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch); + final float playerYaw = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw); + + final float yawRayX = MathHelper.sin(-playerYaw * 0.017453292f - (float) Math.PI); + final float yawRayZ = MathHelper.cos(-playerYaw * 0.017453292f - (float) Math.PI); + + final float pitchMultiplier = -MathHelper.cos(-playerPitch * 0.017453292F); + final float eyeRayY = MathHelper.sin(-playerPitch * 0.017453292F); + final float eyeRayX = yawRayX * pitchMultiplier; + final float eyeRayZ = yawRayZ * pitchMultiplier; + + double reachDistance = playerIn.getAttribute(PlayerEntity.REACH_DISTANCE).getValue(); + + final Vec3d from = new Vec3d(x, y, z); + final Vec3d to = from.add(eyeRayX * reachDistance, eyeRayY * reachDistance, eyeRayZ * reachDistance); + + return new LookDirection(from, to); + } + + public static RayTraceResult rayTrace(final PlayerEntity p, final boolean hitBlocks, final boolean hitEntities) { + final World w = p.getEntityWorld(); + + final float f = 1.0F; + float f1 = p.prevRotationPitch + (p.rotationPitch - p.prevRotationPitch) * f; + final float f2 = p.prevRotationYaw + (p.rotationYaw - p.prevRotationYaw) * f; + final double d0 = p.prevPosX + (p.getPosX() - p.prevPosX) * f; + final double d1 = p.prevPosY + (p.getPosY() - p.prevPosY) * f + 1.62D - p.getYOffset(); + final double d2 = p.prevPosZ + (p.getPosZ() - p.prevPosZ) * f; + final Vec3d vec3 = new Vec3d(d0, d1, d2); + final float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + final float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + final float f5 = -MathHelper.cos(-f1 * 0.017453292F); + final float f6 = MathHelper.sin(-f1 * 0.017453292F); + final float f7 = f4 * f5; + final float f8 = f3 * f5; + final double d3 = 32.0D; + + final Vec3d vec31 = vec3.add(f7 * d3, f6 * d3, f8 * d3); + + final AxisAlignedBB bb = new AxisAlignedBB(Math.min(vec3.x, vec31.x), Math.min(vec3.y, vec31.y), + Math.min(vec3.z, vec31.z), Math.max(vec3.x, vec31.x), Math.max(vec3.y, vec31.y), + Math.max(vec3.z, vec31.z)).grow(16, 16, 16); + + Entity entity = null; + double closest = 9999999.0D; + if (hitEntities) { + final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb); + + for (final Entity entity1 : list) { + if (entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) { + // prevent killing / flying of mounts. + if (entity1.isRidingOrBeingRiddenBy(p)) { + continue; + } + + f1 = 0.3F; + // FIXME: Three different bounding boxes available, should double-check + final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1); + final Vec3d rtResult = boundingBox.rayTrace(vec3, vec31).orElse(null); + + if (rtResult != null) { + final double nd = vec3.squareDistanceTo(rtResult); + + if (nd < closest) { + entity = entity1; + closest = nd; + } + } + } + } + } + + RayTraceResult pos = null; + Vec3d vec = null; + + if (hitBlocks) { + vec = new Vec3d(d0, d1, d2); + // FIXME: passing p as entity here might be incorrect + pos = w.rayTraceBlocks(new RayTraceContext(vec3, vec31, RayTraceContext.BlockMode.COLLIDER, + RayTraceContext.FluidMode.ANY, p)); + } + + if (entity != null && pos != null && pos.getHitVec().squareDistanceTo(vec) > closest) { + pos = new EntityRayTraceResult(entity); + } else if (entity != null && pos == null) { + pos = new EntityRayTraceResult(entity); + } + + return pos; + } + + public static > T poweredExtraction(final IEnergySource energy, final IMEInventory cell, + final T request, final IActionSource src) { + return poweredExtraction(energy, cell, request, src, Actionable.MODULATE); + } + + public static > T poweredExtraction(final IEnergySource energy, final IMEInventory cell, + final T request, final IActionSource src, final Actionable mode) { + Preconditions.checkNotNull(energy); + Preconditions.checkNotNull(cell); + Preconditions.checkNotNull(request); + Preconditions.checkNotNull(src); + Preconditions.checkNotNull(mode); + + final T possible = cell.extractItems(request.copy(), Actionable.SIMULATE, src); + + long retrieved = 0; + if (possible != null) { + retrieved = possible.getStackSize(); + } + + final double energyFactor = Math.max(1.0, cell.getChannel().transferFactor()); + final double availablePower = energy.extractAEPower(retrieved / energyFactor, Actionable.SIMULATE, + PowerMultiplier.CONFIG); + final long itemToExtract = Math.min((long) ((availablePower * energyFactor) + 0.9), retrieved); + + if (itemToExtract > 0) { + if (mode == Actionable.MODULATE) { + energy.extractAEPower(retrieved / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG); + possible.setStackSize(itemToExtract); + final T ret = cell.extractItems(possible, Actionable.MODULATE, src); + + if (ret != null) { + src.player() + .ifPresent(player -> AeStats.ItemsExtracted.addToPlayer(player, (int) ret.getStackSize())); + } + return ret; + } else { + return possible.setStackSize(itemToExtract); + } + } + + return null; + } + + public static > T poweredInsert(final IEnergySource energy, final IMEInventory cell, + final T input, final IActionSource src) { + return poweredInsert(energy, cell, input, src, Actionable.MODULATE); + } + + public static > T poweredInsert(final IEnergySource energy, final IMEInventory cell, + final T input, final IActionSource src, final Actionable mode) { + Preconditions.checkNotNull(energy); + Preconditions.checkNotNull(cell); + Preconditions.checkNotNull(input); + Preconditions.checkNotNull(src); + Preconditions.checkNotNull(mode); + + final T possible = cell.injectItems(input.copy(), Actionable.SIMULATE, src); + + long stored = input.getStackSize(); + if (possible != null) { + stored -= possible.getStackSize(); + } + + final double energyFactor = Math.max(1.0, cell.getChannel().transferFactor()); + final double availablePower = energy.extractAEPower(stored / energyFactor, Actionable.SIMULATE, + PowerMultiplier.CONFIG); + final long itemToAdd = Math.min((long) ((availablePower * energyFactor) + 0.9), stored); + + if (itemToAdd > 0) { + if (mode == Actionable.MODULATE) { + energy.extractAEPower(stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG); + if (itemToAdd < input.getStackSize()) { + final long original = input.getStackSize(); + final T split = input.copy(); + split.decStackSize(itemToAdd); + input.setStackSize(itemToAdd); + split.add(cell.injectItems(input, Actionable.MODULATE, src)); + + src.player().ifPresent(player -> { + final long diff = original - split.getStackSize(); + AeStats.ItemsInserted.addToPlayer(player, (int) diff); + }); + + return split; + } + + final T ret = cell.injectItems(input, Actionable.MODULATE, src); + + src.player().ifPresent(player -> { + final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize(); + AeStats.ItemsInserted.addToPlayer(player, (int) diff); + }); + + return ret; + } else { + final T ret = input.copy().setStackSize(input.getStackSize() - itemToAdd); + return (ret != null && ret.getStackSize() > 0) ? ret : null; + } + } + + return input; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static void postChanges(final IStorageGrid gs, final ItemStack removed, final ItemStack added, + final IActionSource src) { + for (final IStorageChannel chan : AEApi.instance().storage().storageChannels()) { + final IItemList myChanges = chan.createList(); + + if (!removed.isEmpty()) { + final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory(removed, null, chan); + if (myInv != null) { + myInv.getAvailableItems(myChanges); + for (final IAEStack is : myChanges) { + is.setStackSize(-is.getStackSize()); + } + } + } + if (!added.isEmpty()) { + final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory(added, null, chan); + if (myInv != null) { + myInv.getAvailableItems(myChanges); + } + + } + gs.postAlterationOfStoredItems(chan, myChanges, src); + } + } + + public static > void postListChanges(final IItemList before, final IItemList after, + final IMEMonitorHandlerReceiver meMonitorPassthrough, final IActionSource source) { + final List changes = new ArrayList<>(); + + for (final T is : before) { + is.setStackSize(-is.getStackSize()); + } + + for (final T is : after) { + before.add(is); + } + + for (final T is : before) { + if (is.getStackSize() != 0) { + changes.add(is); + } + } + + if (!changes.isEmpty()) { + meMonitorPassthrough.postChange(null, changes, source); + } + } + + public static boolean securityCheck(final GridNode a, final GridNode b) { + if (a.getLastSecurityKey() == -1 && b.getLastSecurityKey() == -1) { + return true; + } else if (a.getLastSecurityKey() == b.getLastSecurityKey()) { + return true; + } + + final boolean a_isSecure = isPowered(a.getGrid()) && a.getLastSecurityKey() != -1; + final boolean b_isSecure = isPowered(b.getGrid()) && b.getLastSecurityKey() != -1; + + if (AEConfig.instance().isFeatureEnabled(AEFeature.LOG_SECURITY_AUDITS)) { + final String locationA = a.getGridBlock().isWorldAccessible() ? a.getGridBlock().getLocation().toString() + : "notInWorld"; + final String locationB = b.getGridBlock().isWorldAccessible() ? b.getGridBlock().getLocation().toString() + : "notInWorld"; + + AELog.info( + "Audit: Node A [isSecure=%b, key=%d, playerID=%d, location={%s}] vs Node B[isSecure=%b, key=%d, playerID=%d, location={%s}]", + a_isSecure, a.getLastSecurityKey(), a.getPlayerID(), locationA, b_isSecure, b.getLastSecurityKey(), + b.getPlayerID(), locationB); + } + + // can't do that son... + if (a_isSecure && b_isSecure) { + return false; + } + + if (!a_isSecure && b_isSecure) { + return checkPlayerPermissions(b.getGrid(), a.getPlayerID()); + } + + if (a_isSecure && !b_isSecure) { + return checkPlayerPermissions(a.getGrid(), b.getPlayerID()); + } + + return true; + } + + private static boolean isPowered(final IGrid grid) { + if (grid == null) { + return false; + } + + final IEnergyGrid eg = grid.getCache(IEnergyGrid.class); + return eg.isNetworkPowered(); + } + + private static boolean checkPlayerPermissions(final IGrid grid, final int playerID) { + if (grid == null) { + return true; + } + + final ISecurityGrid gs = grid.getCache(ISecurityGrid.class); + + if (gs == null) { + return true; + } + + if (!gs.isAvailable()) { + return true; + } + + return gs.hasPermission(playerID, SecurityPermissions.BUILD); + } + + public static void configurePlayer(final PlayerEntity player, final AEPartLocation side, final TileEntity tile) { + float pitch = 0.0f; + float yaw = 0.0f; + // player.yOffset = 1.8f; + + switch (side) { + case DOWN: + pitch = 90.0f; + // player.getYOffset() = -1.8f; + break; + case EAST: + yaw = -90.0f; + break; + case NORTH: + yaw = 180.0f; + break; + case SOUTH: + yaw = 0.0f; + break; + case INTERNAL: + break; + case UP: + pitch = 90.0f; + break; + case WEST: + yaw = 90.0f; + break; + } + + player.setLocationAndAngles(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, + yaw, pitch); + } + + public static boolean canAccess(final AENetworkProxy gridProxy, final IActionSource src) { + try { + if (src.player().isPresent()) { + return gridProxy.getSecurity().hasPermission(src.player().get(), SecurityPermissions.BUILD); + } else if (src.machine().isPresent()) { + final IActionHost te = src.machine().get(); + final IGridNode n = te.getActionableNode(); + if (n == null) { + return false; + } + + final int playerID = n.getPlayerID(); + return gridProxy.getSecurity().hasPermission(playerID, SecurityPermissions.BUILD); + } else { + return false; + } + } catch (final GridAccessException gae) { + return false; + } + } + + public static ItemStack extractItemsByRecipe(final IEnergySource energySrc, final IActionSource mySrc, + final IMEMonitor src, final World w, final IRecipe r, + final ItemStack output, final CraftingInventory ci, final ItemStack providedTemplate, final int slot, + final IItemList items, final Actionable realForFake, + final IPartitionList filter) { + if (energySrc.extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.9) { + if (providedTemplate == null) { + return ItemStack.EMPTY; + } + + final AEItemStack ae_req = AEItemStack.fromItemStack(providedTemplate); + ae_req.setStackSize(1); + + if (filter == null || filter.isListed(ae_req)) { + final IAEItemStack ae_ext = src.extractItems(ae_req, realForFake, mySrc); + if (ae_ext != null) { + final ItemStack extracted = ae_ext.createItemStack(); + if (!extracted.isEmpty()) { + energySrc.extractAEPower(1, realForFake, PowerMultiplier.CONFIG); + return extracted; + } + } + } + + final boolean checkFuzzy = /* + * FIXME ae_req.getOre().isPresent() || FIXME providedTemplate.getDamage() == + * OreDictionary.WILDCARD_VALUE || + */ providedTemplate.hasTag() || providedTemplate.isDamageable(); + + if (items != null && checkFuzzy) { + for (final IAEItemStack x : items) { + final ItemStack sh = x.getDefinition(); + if ((Platform.itemComparisons().isEqualItemType(providedTemplate, + sh) /* FIXME || ae_req.sameOre( x ) */ ) && !ItemStack.areItemsEqual(sh, output)) { // Platform.isSameItemType( + // sh, + // providedTemplate + // ) + final ItemStack cp = sh.copy(); + cp.setCount(1); + ci.setInventorySlotContents(slot, cp); + if (r.matches(ci, w) && ItemStack.areItemsEqual(r.getCraftingResult(ci), output)) { + final IAEItemStack ax = x.copy(); + ax.setStackSize(1); + if (filter == null || filter.isListed(ax)) { + final IAEItemStack ex = src.extractItems(ax, realForFake, mySrc); + if (ex != null) { + energySrc.extractAEPower(1, realForFake, PowerMultiplier.CONFIG); + return ex.createItemStack(); + } + } + } + ci.setInventorySlotContents(slot, providedTemplate); + } + } + } + } + return ItemStack.EMPTY; + } // // TODO wtf is this? - public static ItemStack getContainerItem( final ItemStack stackInSlot ) - { - if( stackInSlot == null ) - { - return ItemStack.EMPTY; - } + public static ItemStack getContainerItem(final ItemStack stackInSlot) { + if (stackInSlot == null) { + return ItemStack.EMPTY; + } - final Item i = stackInSlot.getItem(); - if( i == null || !i.hasContainerItem( stackInSlot ) ) - { - if( stackInSlot.getCount() > 1 ) - { - stackInSlot.setCount( stackInSlot.getCount() - 1 ); - return stackInSlot; - } - return ItemStack.EMPTY; - } + final Item i = stackInSlot.getItem(); + if (i == null || !i.hasContainerItem(stackInSlot)) { + if (stackInSlot.getCount() > 1) { + stackInSlot.setCount(stackInSlot.getCount() - 1); + return stackInSlot; + } + return ItemStack.EMPTY; + } - ItemStack ci = i.getContainerItem( stackInSlot.copy() ); - if( !ci.isEmpty() && ci.isDamageable() && ci.getDamage() == ci.getMaxDamage() ) - { - ci = ItemStack.EMPTY; - } + ItemStack ci = i.getContainerItem(stackInSlot.copy()); + if (!ci.isEmpty() && ci.isDamageable() && ci.getDamage() == ci.getMaxDamage()) { + ci = ItemStack.EMPTY; + } - return ci; - } + return ci; + } - public static void notifyBlocksOfNeighbors( final World world, final BlockPos pos ) - { - if( !world.isRemote ) - { - TickHandler.INSTANCE.addCallable( world, new BlockUpdate( pos ) ); - } - } + public static void notifyBlocksOfNeighbors(final World world, final BlockPos pos) { + if (!world.isRemote) { + TickHandler.INSTANCE.addCallable(world, new BlockUpdate(pos)); + } + } - public static boolean canRepair(final AEFeature type, final ItemStack a, final ItemStack b ) - { - if( b.isEmpty() || a.isEmpty() ) - { - return false; - } + public static boolean canRepair(final AEFeature type, final ItemStack a, final ItemStack b) { + if (b.isEmpty() || a.isEmpty()) { + return false; + } - if( type == AEFeature.CERTUS_QUARTZ_TOOLS ) - { - final IItemDefinition certusQuartzCrystal = AEApi.instance().definitions().materials().certusQuartzCrystal(); + if (type == AEFeature.CERTUS_QUARTZ_TOOLS) { + final IItemDefinition certusQuartzCrystal = AEApi.instance().definitions().materials() + .certusQuartzCrystal(); - return certusQuartzCrystal.isSameAs( b ); - } + return certusQuartzCrystal.isSameAs(b); + } - if( type == AEFeature.NETHER_QUARTZ_TOOLS ) - { - return Items.QUARTZ == b.getItem(); - } + if (type == AEFeature.NETHER_QUARTZ_TOOLS) { + return Items.QUARTZ == b.getItem(); + } - return false; - } + return false; + } // public static List findPreferred( final ItemStack[] is ) // { @@ -1439,12 +1284,11 @@ public class Platform // return Lists.newArrayList( is ); // } - public static float getEyeOffset( final PlayerEntity player ) - { - assert player.world.isRemote : "Valid only on client"; - // FIXME: The entire premise of this seems broken - return (float) ( player.getPosY() + player.getEyeHeight() - /* FIXME player.getDefaultEyeHeight()*/ 1.62F ); - } + public static float getEyeOffset(final PlayerEntity player) { + assert player.world.isRemote : "Valid only on client"; + // FIXME: The entire premise of this seems broken + return (float) (player.getPosY() + player.getEyeHeight() - /* FIXME player.getDefaultEyeHeight() */ 1.62F); + } // // // public static void addStat( final int playerID, final Achievement achievement ) // // { @@ -1455,29 +1299,28 @@ public class Platform // // } // // } - public static boolean isRecipePrioritized( final ItemStack what ) - { - final IMaterials materials = AEApi.instance().definitions().materials(); + public static boolean isRecipePrioritized(final ItemStack what) { + final IMaterials materials = AEApi.instance().definitions().materials(); - boolean isPurified = materials.purifiedCertusQuartzCrystal().isSameAs( what ); - isPurified |= materials.purifiedFluixCrystal().isSameAs( what ); - isPurified |= materials.purifiedNetherQuartzCrystal().isSameAs( what ); + boolean isPurified = materials.purifiedCertusQuartzCrystal().isSameAs(what); + isPurified |= materials.purifiedFluixCrystal().isSameAs(what); + isPurified |= materials.purifiedNetherQuartzCrystal().isSameAs(what); - return isPurified; - } + return isPurified; + } - public static boolean isSortOrderAvailable(SortOrder order) { - if (order == SortOrder.INVTWEAKS) { - return false; // FIXME Integrations.invTweaks().isEnabled() - } - return true; - } + public static boolean isSortOrderAvailable(SortOrder order) { + if (order == SortOrder.INVTWEAKS) { + return false; // FIXME Integrations.invTweaks().isEnabled() + } + return true; + } - public static boolean isSearchModeAvailable(SearchBoxMode mode) { - if (mode.isRequiresJei()) { - return JEIFacade.instance().isEnabled(); - } - return true; - } + public static boolean isSearchModeAvailable(SearchBoxMode mode) { + if (mode.isRequiresJei()) { + return JEIFacade.instance().isEnabled(); + } + return true; + } } diff --git a/src/main/java/appeng/util/ReadOnlyCollection.java b/src/main/java/appeng/util/ReadOnlyCollection.java index 9692e889d..a795fc78a 100644 --- a/src/main/java/appeng/util/ReadOnlyCollection.java +++ b/src/main/java/appeng/util/ReadOnlyCollection.java @@ -18,44 +18,36 @@ package appeng.util; - import java.util.Collection; import java.util.Iterator; import appeng.api.util.IReadOnlyCollection; +public class ReadOnlyCollection implements IReadOnlyCollection { -public class ReadOnlyCollection implements IReadOnlyCollection -{ + private final Collection c; - private final Collection c; + public ReadOnlyCollection(final Collection in) { + this.c = in; + } - public ReadOnlyCollection( final Collection in ) - { - this.c = in; - } + @Override + public Iterator iterator() { + return this.c.iterator(); + } - @Override - public Iterator iterator() - { - return this.c.iterator(); - } + @Override + public int size() { + return this.c.size(); + } - @Override - public int size() - { - return this.c.size(); - } + @Override + public boolean isEmpty() { + return this.c.isEmpty(); + } - @Override - public boolean isEmpty() - { - return this.c.isEmpty(); - } - - @Override - public boolean contains( final Object node ) - { - return this.c.contains( node ); - } + @Override + public boolean contains(final Object node) { + return this.c.contains(node); + } } diff --git a/src/main/java/appeng/util/ReadableNumberConverter.java b/src/main/java/appeng/util/ReadableNumberConverter.java index 405910d4f..bf3cdd0ad 100644 --- a/src/main/java/appeng/util/ReadableNumberConverter.java +++ b/src/main/java/appeng/util/ReadableNumberConverter.java @@ -18,13 +18,11 @@ package appeng.util; - import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.Format; - /** * Converter class to convert a large number into a SI system. * @@ -32,93 +30,87 @@ import java.text.Format; * @version rv2 * @since rv2 */ -public enum ReadableNumberConverter implements ISlimReadableNumberConverter, IWideReadableNumberConverter -{ - INSTANCE; +public enum ReadableNumberConverter implements ISlimReadableNumberConverter, IWideReadableNumberConverter { + INSTANCE; - /** - * Defines the base for a division, non-si standard could be 1024 for kilobytes - */ - private static final int DIVISION_BASE = 1000; + /** + * Defines the base for a division, non-si standard could be 1024 for kilobytes + */ + private static final int DIVISION_BASE = 1000; - /** - * String representation of the sorted postfixes - */ - private static final char[] ENCODED_POSTFIXES = "KMGTPE".toCharArray(); + /** + * String representation of the sorted postfixes + */ + private static final char[] ENCODED_POSTFIXES = "KMGTPE".toCharArray(); - private final Format format; + private final Format format; - /** - * Initializes the specific decimal format with special format for negative and positive numbers - */ - ReadableNumberConverter() - { - final DecimalFormatSymbols symbols = new DecimalFormatSymbols(); - symbols.setDecimalSeparator( '.' ); - final DecimalFormat format = new DecimalFormat( ".#;0.#" ); - format.setDecimalFormatSymbols( symbols ); - format.setRoundingMode( RoundingMode.DOWN ); + /** + * Initializes the specific decimal format with special format for negative and + * positive numbers + */ + ReadableNumberConverter() { + final DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + final DecimalFormat format = new DecimalFormat(".#;0.#"); + format.setDecimalFormatSymbols(symbols); + format.setRoundingMode(RoundingMode.DOWN); - this.format = format; - } + this.format = format; + } - @Override - public String toSlimReadableForm( final long number ) - { - return this.toReadableFormRestrictedByWidth( number, 3 ); - } + @Override + public String toSlimReadableForm(final long number) { + return this.toReadableFormRestrictedByWidth(number, 3); + } - /** - * restricts a string representation of a number to a specific width - * - * @param number to be formatted number - * @param width width limitation of the resulting number - * - * @return formatted number restricted by the width limitation - */ - private String toReadableFormRestrictedByWidth( final long number, final int width ) - { - assert number >= 0; + /** + * restricts a string representation of a number to a specific width + * + * @param number to be formatted number + * @param width width limitation of the resulting number + * + * @return formatted number restricted by the width limitation + */ + private String toReadableFormRestrictedByWidth(final long number, final int width) { + assert number >= 0; - // handles low numbers more efficiently since no format is needed - final String numberString = Long.toString( number ); - int numberSize = numberString.length(); - if( numberSize <= width ) - { - return numberString; - } + // handles low numbers more efficiently since no format is needed + final String numberString = Long.toString(number); + int numberSize = numberString.length(); + if (numberSize <= width) { + return numberString; + } - long base = number; - double last = base * 1000; - int exponent = -1; - String postFix = ""; + long base = number; + double last = base * 1000; + int exponent = -1; + String postFix = ""; - while( numberSize > width ) - { - last = base; - base /= DIVISION_BASE; + while (numberSize > width) { + last = base; + base /= DIVISION_BASE; - exponent++; + exponent++; - // adds +1 due to the postfix - numberSize = Long.toString( base ).length() + 1; - postFix = String.valueOf( ENCODED_POSTFIXES[exponent] ); - } + // adds +1 due to the postfix + numberSize = Long.toString(base).length() + 1; + postFix = String.valueOf(ENCODED_POSTFIXES[exponent]); + } - final String withPrecision = this.format.format( last / DIVISION_BASE ) + postFix; - final String withoutPrecision = Long.toString( base ) + postFix; + final String withPrecision = this.format.format(last / DIVISION_BASE) + postFix; + final String withoutPrecision = Long.toString(base) + postFix; - final String slimResult = ( withPrecision.length() <= width ) ? withPrecision : withoutPrecision; + final String slimResult = (withPrecision.length() <= width) ? withPrecision : withoutPrecision; - // post condition - assert slimResult.length() <= width; + // post condition + assert slimResult.length() <= width; - return slimResult; - } + return slimResult; + } - @Override - public String toWideReadableForm( final long number ) - { - return this.toReadableFormRestrictedByWidth( number, 4 ); - } + @Override + public String toWideReadableForm(final long number) { + return this.toReadableFormRestrictedByWidth(number, 4); + } } diff --git a/src/main/java/appeng/util/SettingsFrom.java b/src/main/java/appeng/util/SettingsFrom.java index f187f9948..5efa2d024 100644 --- a/src/main/java/appeng/util/SettingsFrom.java +++ b/src/main/java/appeng/util/SettingsFrom.java @@ -18,12 +18,10 @@ package appeng.util; +public enum SettingsFrom { + // moved the item, and replaced it. + DISMANTLE_ITEM, -public enum SettingsFrom -{ - // moved the item, and replaced it. - DISMANTLE_ITEM, - - // used memory card? - MEMORY_CARD + // used memory card? + MEMORY_CARD } diff --git a/src/main/java/appeng/util/UUIDMatcher.java b/src/main/java/appeng/util/UUIDMatcher.java index 2a6c92353..ebf654efe 100644 --- a/src/main/java/appeng/util/UUIDMatcher.java +++ b/src/main/java/appeng/util/UUIDMatcher.java @@ -18,34 +18,32 @@ package appeng.util; - import java.util.regex.Pattern; - /** * Regex wrapper for {@link java.util.UUID}s to not rely on try catch */ -public final class UUIDMatcher -{ - /** - * String which is the regular expression for {@link java.util.UUID}s - */ - private static final String UUID_REGEX = "[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"; +public final class UUIDMatcher { + /** + * String which is the regular expression for {@link java.util.UUID}s + */ + private static final String UUID_REGEX = "[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"; - /** - * Pattern which pre-compiles the {@link appeng.util.UUIDMatcher#UUID_REGEX} - */ - private static final Pattern PATTERN = Pattern.compile( UUID_REGEX ); + /** + * Pattern which pre-compiles the {@link appeng.util.UUIDMatcher#UUID_REGEX} + */ + private static final Pattern PATTERN = Pattern.compile(UUID_REGEX); - /** - * Checks if a potential {@link java.util.UUID} is an {@link java.util.UUID} by applying a regular expression on it. - * - * @param potential to be checked potential {@link java.util.UUID} - * - * @return true, if the potential {@link java.util.UUID} is indeed an {@link java.util.UUID} - */ - public boolean isUUID( final CharSequence potential ) - { - return PATTERN.matcher( potential ).matches(); - } + /** + * Checks if a potential {@link java.util.UUID} is an {@link java.util.UUID} by + * applying a regular expression on it. + * + * @param potential to be checked potential {@link java.util.UUID} + * + * @return true, if the potential {@link java.util.UUID} is indeed an + * {@link java.util.UUID} + */ + public boolean isUUID(final CharSequence potential) { + return PATTERN.matcher(potential).matches(); + } } diff --git a/src/main/java/appeng/util/helpers/ItemComparisonHelper.java b/src/main/java/appeng/util/helpers/ItemComparisonHelper.java index 6c31f9b2a..d76ddd684 100644 --- a/src/main/java/appeng/util/helpers/ItemComparisonHelper.java +++ b/src/main/java/appeng/util/helpers/ItemComparisonHelper.java @@ -18,7 +18,6 @@ package appeng.util.helpers; - import javax.annotation.Nonnull; import net.minecraft.item.Item; @@ -27,81 +26,70 @@ import net.minecraft.nbt.CompoundNBT; import appeng.api.config.FuzzyMode; - /** * A helper class for comparing {@link Item}, {@link ItemStack} or NBT * */ -public class ItemComparisonHelper -{ +public class ItemComparisonHelper { - /** - * Compare the two {@link ItemStack}s based on the same {@link Item} and damage value. - * - * In case of the item being damageable, only the {@link Item} will be considered. - * If not it will also compare both damage values. - * - * Ignores NBT. - * - * @return true, if both are equal. - */ - public boolean isEqualItemType( @Nonnull final ItemStack that, @Nonnull final ItemStack other ) - { - return !that.isEmpty() && !other.isEmpty() && that.getItem() == other.getItem(); - } + /** + * Compare the two {@link ItemStack}s based on the same {@link Item} and damage + * value. + * + * In case of the item being damageable, only the {@link Item} will be + * considered. If not it will also compare both damage values. + * + * Ignores NBT. + * + * @return true, if both are equal. + */ + public boolean isEqualItemType(@Nonnull final ItemStack that, @Nonnull final ItemStack other) { + return !that.isEmpty() && !other.isEmpty() && that.getItem() == other.getItem(); + } - /** - * Compares two {@link ItemStack} and their NBT tag for equality. - * - * Use this when a precise check is required and the same item is required. - * Not just something with different NBT tags. - * - * @return true, if both are identical. - */ - public boolean isSameItem( @Nonnull final ItemStack is, @Nonnull final ItemStack filter ) - { - return ItemStack.areItemsEqual( is, filter ) && this.isNbtTagEqual( is.getTag(), filter.getTag() ); - } + /** + * Compares two {@link ItemStack} and their NBT tag for equality. + * + * Use this when a precise check is required and the same item is required. Not + * just something with different NBT tags. + * + * @return true, if both are identical. + */ + public boolean isSameItem(@Nonnull final ItemStack is, @Nonnull final ItemStack filter) { + return ItemStack.areItemsEqual(is, filter) && this.isNbtTagEqual(is.getTag(), filter.getTag()); + } - /** - * Similar to {@link ItemComparisonHelper#isEqualItem(ItemStack, ItemStack)}, - * but it can further check, if both match the same {@link FuzzyMode} - * or are considered equal by the {@link OreDictionary} - * - * @param mode how to compare the two {@link ItemStack}s - * @return true, if both are matching the mode or considered equal by the {@link OreDictionary} - */ - public boolean isFuzzyEqualItem( final ItemStack a, final ItemStack b, final FuzzyMode mode ) - { - if( a.isEmpty() && b.isEmpty() ) - { - return true; - } + /** + * Similar to {@link ItemComparisonHelper#isEqualItem(ItemStack, ItemStack)}, + * but it can further check, if both match the same {@link FuzzyMode} or are + * considered equal by the {@link OreDictionary} + * + * @param mode how to compare the two {@link ItemStack}s + * @return true, if both are matching the mode or considered equal by the + * {@link OreDictionary} + */ + public boolean isFuzzyEqualItem(final ItemStack a, final ItemStack b, final FuzzyMode mode) { + if (a.isEmpty() && b.isEmpty()) { + return true; + } - if( a.isEmpty() || b.isEmpty() ) - { - return false; - } + if (a.isEmpty() || b.isEmpty()) { + return false; + } - // test damageable items.. - if( a.getItem() == b.getItem() && a.getItem().isDamageable() ) - { - if( mode == FuzzyMode.IGNORE_ALL ) - { - return true; - } - else if( mode == FuzzyMode.PERCENT_99 ) - { - return ( a.getDamage() > 1 ) == ( b.getDamage() > 1 ); - } - else - { - final float percentDamagedOfA = (float) a.getDamage() / a.getMaxDamage(); - final float percentDamagedOfB = (float) b.getDamage() / b.getMaxDamage(); + // test damageable items.. + if (a.getItem() == b.getItem() && a.getItem().isDamageable()) { + if (mode == FuzzyMode.IGNORE_ALL) { + return true; + } else if (mode == FuzzyMode.PERCENT_99) { + return (a.getDamage() > 1) == (b.getDamage() > 1); + } else { + final float percentDamagedOfA = (float) a.getDamage() / a.getMaxDamage(); + final float percentDamagedOfB = (float) b.getDamage() / b.getMaxDamage(); - return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint ); - } - } + return (percentDamagedOfA > mode.breakPoint) == (percentDamagedOfB > mode.breakPoint); + } + } // FIXME // final OreReference aOR = OreHelper.INSTANCE.getOre( a ).orElse( null ); // final OreReference bOR = OreHelper.INSTANCE.getOre( b ).orElse( null ); @@ -111,39 +99,36 @@ public class ItemComparisonHelper // return true; // } - return a.isItemEqual( b ); - } + return a.isItemEqual(b); + } - /** - * recursive test for NBT Equality, this was faster then trying to compare / generate hashes, its also more reliable - * then the vanilla version which likes to fail when NBT Compound data changes order, it is pretty expensive - * performance wise, so try an use shared tag compounds as long as the system remains in AE. - */ - public boolean isNbtTagEqual( final CompoundNBT left, final CompoundNBT right ) - { - if( left == right ) - { - return true; - } + /** + * recursive test for NBT Equality, this was faster then trying to compare / + * generate hashes, its also more reliable then the vanilla version which likes + * to fail when NBT Compound data changes order, it is pretty expensive + * performance wise, so try an use shared tag compounds as long as the system + * remains in AE. + */ + public boolean isNbtTagEqual(final CompoundNBT left, final CompoundNBT right) { + if (left == right) { + return true; + } - final boolean isLeftEmpty = left == null || left.isEmpty(); - final boolean isRightEmpty = right == null || right.isEmpty(); + final boolean isLeftEmpty = left == null || left.isEmpty(); + final boolean isRightEmpty = right == null || right.isEmpty(); - if( isLeftEmpty && isRightEmpty ) - { - return true; - } + if (isLeftEmpty && isRightEmpty) { + return true; + } - if( isLeftEmpty != isRightEmpty ) - { - return false; - } + if (isLeftEmpty != isRightEmpty) { + return false; + } - if( left != null ) - { - return left.equals( right ); - } + if (left != null) { + return left.equals(right); + } - return false; - } + return false; + } } diff --git a/src/main/java/appeng/util/helpers/ItemHandlerUtil.java b/src/main/java/appeng/util/helpers/ItemHandlerUtil.java index 394302a4b..dc8396972 100644 --- a/src/main/java/appeng/util/helpers/ItemHandlerUtil.java +++ b/src/main/java/appeng/util/helpers/ItemHandlerUtil.java @@ -18,65 +18,48 @@ package appeng.util.helpers; - import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; +public class ItemHandlerUtil { + private ItemHandlerUtil() { + } -public class ItemHandlerUtil -{ - private ItemHandlerUtil() - { - } + public static void setStackInSlot(final IItemHandler inv, final int slot, final ItemStack stack) { + if (inv instanceof IItemHandlerModifiable) { + ((IItemHandlerModifiable) inv).setStackInSlot(slot, stack); + } else { + inv.extractItem(slot, Integer.MAX_VALUE, false); + inv.insertItem(slot, stack, false); + } + } - public static void setStackInSlot( final IItemHandler inv, final int slot, final ItemStack stack ) - { - if( inv instanceof IItemHandlerModifiable ) - { - ( (IItemHandlerModifiable) inv ).setStackInSlot( slot, stack ); - } - else - { - inv.extractItem( slot, Integer.MAX_VALUE, false ); - inv.insertItem( slot, stack, false ); - } - } + public static void clear(final IItemHandler inv) { + for (int x = 0; x < inv.getSlots(); x++) { + setStackInSlot(inv, x, ItemStack.EMPTY); + } + } - public static void clear( final IItemHandler inv ) - { - for( int x = 0; x < inv.getSlots(); x++ ) - { - setStackInSlot( inv, x, ItemStack.EMPTY ); - } - } + public static boolean isEmpty(final IItemHandler inv) { + for (int x = 0; x < inv.getSlots(); x++) { + if (!inv.getStackInSlot(x).isEmpty()) { + return false; + } + } + return true; + } - public static boolean isEmpty( final IItemHandler inv ) - { - for( int x = 0; x < inv.getSlots(); x++ ) - { - if( !inv.getStackInSlot( x ).isEmpty() ) - { - return false; - } - } - return true; - } + public static void copy(final IItemHandler from, final IItemHandler to, boolean deepCopy) { + for (int i = 0; i < Math.min(from.getSlots(), to.getSlots()); ++i) { + setStackInSlot(to, i, deepCopy ? from.getStackInSlot(i).copy() : from.getStackInSlot(i)); + } + } - public static void copy( final IItemHandler from, final IItemHandler to, boolean deepCopy ) - { - for( int i = 0; i < Math.min( from.getSlots(), to.getSlots() ); ++i ) - { - setStackInSlot( to, i, deepCopy ? from.getStackInSlot( i ).copy() : from.getStackInSlot( i ) ); - } - } - - public static void copy( final CraftingInventory from, final IItemHandler to, boolean deepCopy ) - { - for( int i = 0; i < Math.min( from.getSizeInventory(), to.getSlots() ); ++i ) - { - setStackInSlot( to, i, deepCopy ? from.getStackInSlot( i ).copy() : from.getStackInSlot( i ) ); - } - } + public static void copy(final CraftingInventory from, final IItemHandler to, boolean deepCopy) { + for (int i = 0; i < Math.min(from.getSizeInventory(), to.getSlots()); ++i) { + setStackInSlot(to, i, deepCopy ? from.getStackInSlot(i).copy() : from.getStackInSlot(i)); + } + } } diff --git a/src/main/java/appeng/util/helpers/P2PHelper.java b/src/main/java/appeng/util/helpers/P2PHelper.java index f4f2a6dca..53fb55c4f 100644 --- a/src/main/java/appeng/util/helpers/P2PHelper.java +++ b/src/main/java/appeng/util/helpers/P2PHelper.java @@ -18,53 +18,44 @@ package appeng.util.helpers; - import com.google.common.base.Preconditions; import appeng.api.util.AEColor; +public class P2PHelper { -public class P2PHelper -{ + public AEColor[] toColors(short frequency) { + final AEColor[] colors = new AEColor[4]; - public AEColor[] toColors( short frequency ) - { - final AEColor[] colors = new AEColor[4]; + for (int i = 0; i < 4; i++) { + int nibble = (frequency >> 4 * (3 - i)) & 0xF; - for( int i = 0; i < 4; i++ ) - { - int nibble = ( frequency >> 4 * ( 3 - i ) ) & 0xF; + colors[i] = AEColor.values()[nibble]; + } - colors[i] = AEColor.values()[nibble]; - } + return colors; + } - return colors; - } + public short fromColors(AEColor[] colors) { + Preconditions.checkArgument(colors.length == 4); - public short fromColors( AEColor[] colors ) - { - Preconditions.checkArgument( colors.length == 4 ); + int t = 0; - int t = 0; + for (int i = 0; i < 4; i++) { + int code = colors[3 - i].ordinal() << 4 * i; - for( int i = 0; i < 4; i++ ) - { - int code = colors[3 - i].ordinal() << 4 * i; + t |= code; + } - t |= code; - } + return (short) (t & 0xFFFF); + } - return (short) ( t & 0xFFFF ); - } + public String toHexDigit(AEColor color) { + return String.format("%01X", color.ordinal()); + } - public String toHexDigit( AEColor color ) - { - return String.format( "%01X", color.ordinal() ); - } - - public String toHexString( short frequency ) - { - return String.format( "%04X", frequency ); - } + public String toHexString(short frequency) { + return String.format("%04X", frequency); + } } diff --git a/src/main/java/appeng/util/inv/AdaptorItemHandler.java b/src/main/java/appeng/util/inv/AdaptorItemHandler.java index e80859154..56ca52565 100644 --- a/src/main/java/appeng/util/inv/AdaptorItemHandler.java +++ b/src/main/java/appeng/util/inv/AdaptorItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.Iterator; import net.minecraft.item.ItemStack; @@ -28,240 +27,200 @@ import appeng.api.config.FuzzyMode; import appeng.util.InventoryAdaptor; import appeng.util.Platform; +public class AdaptorItemHandler extends InventoryAdaptor { + protected final IItemHandler itemHandler; -public class AdaptorItemHandler extends InventoryAdaptor -{ - protected final IItemHandler itemHandler; + public AdaptorItemHandler(IItemHandler itemHandler) { + this.itemHandler = itemHandler; + } - public AdaptorItemHandler( IItemHandler itemHandler ) - { - this.itemHandler = itemHandler; - } + @Override + public boolean hasSlots() { + return this.itemHandler.getSlots() > 0; + } - @Override - public boolean hasSlots() - { - return this.itemHandler.getSlots() > 0; - } + @Override + public ItemStack removeItems(int amount, ItemStack filter, IInventoryDestination destination) { + int slots = this.itemHandler.getSlots(); + ItemStack rv = ItemStack.EMPTY; - @Override - public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination ) - { - int slots = this.itemHandler.getSlots(); - ItemStack rv = ItemStack.EMPTY; + for (int slot = 0; slot < slots && amount > 0; slot++) { + final ItemStack is = this.itemHandler.getStackInSlot(slot); + if (is.isEmpty() || (!filter.isEmpty() && !Platform.itemComparisons().isSameItem(is, filter))) { + continue; + } - for( int slot = 0; slot < slots && amount > 0; slot++ ) - { - final ItemStack is = this.itemHandler.getStackInSlot( slot ); - if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isSameItem( is, filter ) ) ) - { - continue; - } + if (destination != null) { + ItemStack extracted = this.itemHandler.extractItem(slot, amount, true); + if (extracted.isEmpty()) { + continue; + } - if( destination != null ) - { - ItemStack extracted = this.itemHandler.extractItem( slot, amount, true ); - if( extracted.isEmpty() ) - { - continue; - } + if (!destination.canInsert(extracted)) { + continue; + } + } - if( !destination.canInsert( extracted ) ) - { - continue; - } - } + // Attempt extracting it + ItemStack extracted = this.itemHandler.extractItem(slot, amount, false); - // Attempt extracting it - ItemStack extracted = this.itemHandler.extractItem( slot, amount, false ); + if (extracted.isEmpty()) { + continue; + } - if( extracted.isEmpty() ) - { - continue; - } + if (rv.isEmpty()) { + // Use the first stack as a template for the result + rv = extracted; + filter = extracted; + amount -= extracted.getCount(); + } else { + // Subsequent stacks will just increase the extracted size + rv.grow(extracted.getCount()); + amount -= extracted.getCount(); + } + } - if( rv.isEmpty() ) - { - // Use the first stack as a template for the result - rv = extracted; - filter = extracted; - amount -= extracted.getCount(); - } - else - { - // Subsequent stacks will just increase the extracted size - rv.grow( extracted.getCount() ); - amount -= extracted.getCount(); - } - } + return rv; + } - return rv; - } + @Override + public ItemStack simulateRemove(int amount, ItemStack filter, IInventoryDestination destination) { + int slots = this.itemHandler.getSlots(); + ItemStack rv = ItemStack.EMPTY; - @Override - public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination ) - { - int slots = this.itemHandler.getSlots(); - ItemStack rv = ItemStack.EMPTY; + for (int slot = 0; slot < slots && amount > 0; slot++) { + final ItemStack is = this.itemHandler.getStackInSlot(slot); + if (!is.isEmpty() && (filter.isEmpty() || Platform.itemComparisons().isSameItem(is, filter))) { + ItemStack extracted = this.itemHandler.extractItem(slot, amount, true); - for( int slot = 0; slot < slots && amount > 0; slot++ ) - { - final ItemStack is = this.itemHandler.getStackInSlot( slot ); - if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) - { - ItemStack extracted = this.itemHandler.extractItem( slot, amount, true ); + if (extracted.isEmpty()) { + continue; + } - if( extracted.isEmpty() ) - { - continue; - } + if (destination != null) { + if (!destination.canInsert(extracted)) { + continue; + } + } - if( destination != null ) - { - if( !destination.canInsert( extracted ) ) - { - continue; - } - } + if (rv.isEmpty()) { + // Use the first stack as a template for the result + rv = extracted.copy(); + filter = extracted; + amount -= extracted.getCount(); + } else { + // Subsequent stacks will just increase the extracted size + rv.grow(extracted.getCount()); + amount -= extracted.getCount(); + } + } + } - if( rv.isEmpty() ) - { - // Use the first stack as a template for the result - rv = extracted.copy(); - filter = extracted; - amount -= extracted.getCount(); - } - else - { - // Subsequent stacks will just increase the extracted size - rv.grow( extracted.getCount() ); - amount -= extracted.getCount(); - } - } - } + return rv; + } - return rv; - } + /** + * For fuzzy extract, we will only ever extract one slot, since we're afraid of + * merging two item stacks with different damage values. + */ + @Override + public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, + IInventoryDestination destination) { + int slots = this.itemHandler.getSlots(); + ItemStack extracted = ItemStack.EMPTY; - /** - * For fuzzy extract, we will only ever extract one slot, since we're afraid of merging two item stacks with - * different damage values. - */ - @Override - public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) - { - int slots = this.itemHandler.getSlots(); - ItemStack extracted = ItemStack.EMPTY; + for (int slot = 0; slot < slots && extracted.isEmpty(); slot++) { + final ItemStack is = this.itemHandler.getStackInSlot(slot); + if (is.isEmpty() + || (!filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem(is, filter, fuzzyMode))) { + continue; + } - for( int slot = 0; slot < slots && extracted.isEmpty(); slot++ ) - { - final ItemStack is = this.itemHandler.getStackInSlot( slot ); - if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) - { - continue; - } + if (destination != null) { + ItemStack simulated = this.itemHandler.extractItem(slot, amount, true); + if (simulated.isEmpty()) { + continue; + } - if( destination != null ) - { - ItemStack simulated = this.itemHandler.extractItem( slot, amount, true ); - if( simulated.isEmpty() ) - { - continue; - } + if (!destination.canInsert(simulated)) { + continue; + } + } - if( !destination.canInsert( simulated ) ) - { - continue; - } - } + // Attempt extracting it + extracted = this.itemHandler.extractItem(slot, amount, false); + } - // Attempt extracting it - extracted = this.itemHandler.extractItem( slot, amount, false ); - } + return extracted; + } - return extracted; - } + @Override + public ItemStack simulateSimilarRemove(int amount, ItemStack filter, FuzzyMode fuzzyMode, + IInventoryDestination destination) { + int slots = this.itemHandler.getSlots(); + ItemStack extracted = ItemStack.EMPTY; - @Override - public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) - { - int slots = this.itemHandler.getSlots(); - ItemStack extracted = ItemStack.EMPTY; + for (int slot = 0; slot < slots && extracted.isEmpty(); slot++) { + final ItemStack is = this.itemHandler.getStackInSlot(slot); + if (is.isEmpty() + || (!filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem(is, filter, fuzzyMode))) { + continue; + } - for( int slot = 0; slot < slots && extracted.isEmpty(); slot++ ) - { - final ItemStack is = this.itemHandler.getStackInSlot( slot ); - if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) - { - continue; - } + // Attempt extracting it + extracted = this.itemHandler.extractItem(slot, amount, true); - // Attempt extracting it - extracted = this.itemHandler.extractItem( slot, amount, true ); + if (!extracted.isEmpty() && destination != null) { + if (!destination.canInsert(extracted)) { + extracted = ItemStack.EMPTY; // Keep on looking... + } + } + } - if( !extracted.isEmpty() && destination != null ) - { - if( !destination.canInsert( extracted ) ) - { - extracted = ItemStack.EMPTY; // Keep on looking... - } - } - } + return extracted; + } - return extracted; - } + @Override + public ItemStack addItems(ItemStack toBeAdded) { + return this.addItems(toBeAdded, false); + } - @Override - public ItemStack addItems( ItemStack toBeAdded ) - { - return this.addItems( toBeAdded, false ); - } + @Override + public ItemStack simulateAdd(ItemStack toBeSimulated) { + return this.addItems(toBeSimulated, true); + } - @Override - public ItemStack simulateAdd( ItemStack toBeSimulated ) - { - return this.addItems( toBeSimulated, true ); - } + protected ItemStack addItems(final ItemStack itemsToAdd, final boolean simulate) { + if (itemsToAdd.isEmpty()) { + return ItemStack.EMPTY; + } - protected ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate ) - { - if( itemsToAdd.isEmpty() ) - { - return ItemStack.EMPTY; - } + ItemStack left = itemsToAdd.copy(); - ItemStack left = itemsToAdd.copy(); + for (int slot = 0; slot < this.itemHandler.getSlots(); slot++) { + left = this.itemHandler.insertItem(slot, left, simulate); - for( int slot = 0; slot < this.itemHandler.getSlots(); slot++ ) - { - left = this.itemHandler.insertItem( slot, left, simulate ); + if (left.isEmpty()) { + return ItemStack.EMPTY; + } + } - if( left.isEmpty() ) - { - return ItemStack.EMPTY; - } - } + return left; + } - return left; - } + @Override + public boolean containsItems() { + int slots = this.itemHandler.getSlots(); + for (int slot = 0; slot < slots; slot++) { + if (!this.itemHandler.getStackInSlot(slot).isEmpty()) { + return true; + } + } + return false; + } - @Override - public boolean containsItems() - { - int slots = this.itemHandler.getSlots(); - for( int slot = 0; slot < slots; slot++ ) - { - if( !this.itemHandler.getStackInSlot( slot ).isEmpty() ) - { - return true; - } - } - return false; - } - - @Override - public Iterator iterator() - { - return new ItemHandlerIterator( this.itemHandler ); - } + @Override + public Iterator iterator() { + return new ItemHandlerIterator(this.itemHandler); + } } diff --git a/src/main/java/appeng/util/inv/AdaptorItemHandlerPlayerInv.java b/src/main/java/appeng/util/inv/AdaptorItemHandlerPlayerInv.java index 943fdaa70..79593c371 100644 --- a/src/main/java/appeng/util/inv/AdaptorItemHandlerPlayerInv.java +++ b/src/main/java/appeng/util/inv/AdaptorItemHandlerPlayerInv.java @@ -18,58 +18,47 @@ package appeng.util.inv; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; import appeng.util.Platform; +public class AdaptorItemHandlerPlayerInv extends AdaptorItemHandler { + public AdaptorItemHandlerPlayerInv(final PlayerEntity playerInv) { + super(new PlayerMainInvWrapper(playerInv.inventory)); + } -public class AdaptorItemHandlerPlayerInv extends AdaptorItemHandler -{ - public AdaptorItemHandlerPlayerInv( final PlayerEntity playerInv ) - { - super( new PlayerMainInvWrapper( playerInv.inventory ) ); - } + /** + * Tries to fill existing stacks first + */ + @Override + protected ItemStack addItems(final ItemStack itemsToAdd, final boolean simulate) { + if (itemsToAdd.isEmpty()) { + return ItemStack.EMPTY; + } - /** - * Tries to fill existing stacks first - */ - @Override - protected ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate ) - { - if( itemsToAdd.isEmpty() ) - { - return ItemStack.EMPTY; - } + ItemStack left = itemsToAdd.copy(); - ItemStack left = itemsToAdd.copy(); + for (int slot = 0; slot < this.itemHandler.getSlots(); slot++) { + ItemStack is = this.itemHandler.getStackInSlot(slot); - for( int slot = 0; slot < this.itemHandler.getSlots(); slot++ ) - { - ItemStack is = this.itemHandler.getStackInSlot( slot ); + if (Platform.itemComparisons().isSameItem(is, left)) { + left = this.itemHandler.insertItem(slot, left, simulate); + } + if (left.isEmpty()) { + return ItemStack.EMPTY; + } + } - if( Platform.itemComparisons().isSameItem( is, left ) ) - { - left = this.itemHandler.insertItem( slot, left, simulate ); - } - if( left.isEmpty() ) - { - return ItemStack.EMPTY; - } - } + for (int slot = 0; slot < this.itemHandler.getSlots(); slot++) { + left = this.itemHandler.insertItem(slot, left, simulate); + if (left.isEmpty()) { + return ItemStack.EMPTY; + } + } - for( int slot = 0; slot < this.itemHandler.getSlots(); slot++ ) - { - left = this.itemHandler.insertItem( slot, left, simulate ); - if( left.isEmpty() ) - { - return ItemStack.EMPTY; - } - } - - return left; - } + return left; + } } diff --git a/src/main/java/appeng/util/inv/AdaptorList.java b/src/main/java/appeng/util/inv/AdaptorList.java index c004eb7fd..b38023994 100644 --- a/src/main/java/appeng/util/inv/AdaptorList.java +++ b/src/main/java/appeng/util/inv/AdaptorList.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.Iterator; import java.util.List; @@ -29,200 +28,164 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.iterators.StackToSlotIterator; +public class AdaptorList extends InventoryAdaptor { -public class AdaptorList extends InventoryAdaptor -{ + private final List i; - private final List i; + public AdaptorList(final List s) { + this.i = s; + } - public AdaptorList( final List s ) - { - this.i = s; - } + @Override + public boolean hasSlots() { + return !this.i.isEmpty(); + } - @Override - public boolean hasSlots() - { - return !this.i.isEmpty(); - } + @Override + public ItemStack removeItems(int amount, final ItemStack filter, final IInventoryDestination destination) { + final int s = this.i.size(); + for (int x = 0; x < s; x++) { + final ItemStack is = this.i.get(x); + if (!is.isEmpty() && (filter.isEmpty() || Platform.itemComparisons().isSameItem(is, filter))) { + if (amount > is.getCount()) { + amount = is.getCount(); + } + if (destination != null && !destination.canInsert(is)) { + amount = 0; + } - @Override - public ItemStack removeItems( int amount, final ItemStack filter, final IInventoryDestination destination ) - { - final int s = this.i.size(); - for( int x = 0; x < s; x++ ) - { - final ItemStack is = this.i.get( x ); - if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) - { - if( amount > is.getCount() ) - { - amount = is.getCount(); - } - if( destination != null && !destination.canInsert( is ) ) - { - amount = 0; - } + if (amount > 0) { + final ItemStack rv = is.copy(); + rv.setCount(amount); + is.grow(-amount); - if( amount > 0 ) - { - final ItemStack rv = is.copy(); - rv.setCount( amount ); - is.grow( -amount ); + // remove it.. + if (is.getCount() <= 0) { + this.i.remove(x); + } - // remove it.. - if( is.getCount() <= 0 ) - { - this.i.remove( x ); - } + return rv; + } + } + } + return ItemStack.EMPTY; + } - return rv; - } - } - } - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateRemove(int amount, final ItemStack filter, final IInventoryDestination destination) { + for (final ItemStack is : this.i) { + if (!is.isEmpty() && (filter.isEmpty() || Platform.itemComparisons().isSameItem(is, filter))) { + if (amount > is.getCount()) { + amount = is.getCount(); + } + if (destination != null && !destination.canInsert(is)) { + amount = 0; + } - @Override - public ItemStack simulateRemove( int amount, final ItemStack filter, final IInventoryDestination destination ) - { - for( final ItemStack is : this.i ) - { - if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) - { - if( amount > is.getCount() ) - { - amount = is.getCount(); - } - if( destination != null && !destination.canInsert( is ) ) - { - amount = 0; - } + if (amount > 0) { + final ItemStack rv = is.copy(); + rv.setCount(amount); + return rv; + } + } + } + return ItemStack.EMPTY; + } - if( amount > 0 ) - { - final ItemStack rv = is.copy(); - rv.setCount( amount ); - return rv; - } - } - } - return ItemStack.EMPTY; - } + @Override + public ItemStack removeSimilarItems(int amount, final ItemStack filter, final FuzzyMode fuzzyMode, + final IInventoryDestination destination) { + final int s = this.i.size(); + for (int x = 0; x < s; x++) { + final ItemStack is = this.i.get(x); + if (!is.isEmpty() + && (filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem(is, filter, fuzzyMode))) { + if (amount > is.getCount()) { + amount = is.getCount(); + } + if (destination != null && !destination.canInsert(is)) { + amount = 0; + } - @Override - public ItemStack removeSimilarItems( int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) - { - final int s = this.i.size(); - for( int x = 0; x < s; x++ ) - { - final ItemStack is = this.i.get( x ); - if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) - { - if( amount > is.getCount() ) - { - amount = is.getCount(); - } - if( destination != null && !destination.canInsert( is ) ) - { - amount = 0; - } + if (amount > 0) { + final ItemStack rv = is.copy(); + rv.setCount(amount); + is.grow(-amount); - if( amount > 0 ) - { - final ItemStack rv = is.copy(); - rv.setCount( amount ); - is.grow( -amount ); + // remove it.. + if (is.getCount() <= 0) { + this.i.remove(x); + } - // remove it.. - if( is.getCount() <= 0 ) - { - this.i.remove( x ); - } + return rv; + } + } + } + return ItemStack.EMPTY; + } - return rv; - } - } - } - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateSimilarRemove(int amount, final ItemStack filter, final FuzzyMode fuzzyMode, + final IInventoryDestination destination) { + for (final ItemStack is : this.i) { + if (!is.isEmpty() + && (filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem(is, filter, fuzzyMode))) { + if (amount > is.getCount()) { + amount = is.getCount(); + } + if (destination != null && !destination.canInsert(is)) { + amount = 0; + } - @Override - public ItemStack simulateSimilarRemove( int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) - { - for( final ItemStack is : this.i ) - { - if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) - { - if( amount > is.getCount() ) - { - amount = is.getCount(); - } - if( destination != null && !destination.canInsert( is ) ) - { - amount = 0; - } + if (amount > 0) { + final ItemStack rv = is.copy(); + rv.setCount(amount); + return rv; + } + } + } + return ItemStack.EMPTY; + } - if( amount > 0 ) - { - final ItemStack rv = is.copy(); - rv.setCount( amount ); - return rv; - } - } - } - return ItemStack.EMPTY; - } + @Override + public ItemStack addItems(final ItemStack toBeAdded) { + if (toBeAdded.isEmpty()) { + return ItemStack.EMPTY; + } + if (toBeAdded.getCount() == 0) { + return ItemStack.EMPTY; + } - @Override - public ItemStack addItems( final ItemStack toBeAdded ) - { - if( toBeAdded.isEmpty() ) - { - return ItemStack.EMPTY; - } - if( toBeAdded.getCount() == 0 ) - { - return ItemStack.EMPTY; - } + final ItemStack left = toBeAdded.copy(); - final ItemStack left = toBeAdded.copy(); + for (final ItemStack is : this.i) { + if (ItemStack.areItemsEqual(is, left)) { + is.grow(left.getCount()); + return ItemStack.EMPTY; + } + } - for( final ItemStack is : this.i ) - { - if( ItemStack.areItemsEqual( is, left ) ) - { - is.grow( left.getCount() ); - return ItemStack.EMPTY; - } - } + this.i.add(left); + return ItemStack.EMPTY; + } - this.i.add( left ); - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateAdd(final ItemStack toBeSimulated) { + return ItemStack.EMPTY; + } - @Override - public ItemStack simulateAdd( final ItemStack toBeSimulated ) - { - return ItemStack.EMPTY; - } + @Override + public boolean containsItems() { + for (final ItemStack is : this.i) { + if (!is.isEmpty()) { + return true; + } + } + return false; + } - @Override - public boolean containsItems() - { - for( final ItemStack is : this.i ) - { - if( !is.isEmpty() ) - { - return true; - } - } - return false; - } - - @Override - public Iterator iterator() - { - return new StackToSlotIterator( this.i.iterator() ); - } + @Override + public Iterator iterator() { + return new StackToSlotIterator(this.i.iterator()); + } } diff --git a/src/main/java/appeng/util/inv/IAEAppEngInventory.java b/src/main/java/appeng/util/inv/IAEAppEngInventory.java index a811a980e..d8c6f6300 100644 --- a/src/main/java/appeng/util/inv/IAEAppEngInventory.java +++ b/src/main/java/appeng/util/inv/IAEAppEngInventory.java @@ -18,14 +18,11 @@ package appeng.util.inv; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public interface IAEAppEngInventory { + void saveChanges(); -public interface IAEAppEngInventory -{ - void saveChanges(); - - void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ); + void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack); } diff --git a/src/main/java/appeng/util/inv/IInventoryDestination.java b/src/main/java/appeng/util/inv/IInventoryDestination.java index 61a3cf8b9..9479d0074 100644 --- a/src/main/java/appeng/util/inv/IInventoryDestination.java +++ b/src/main/java/appeng/util/inv/IInventoryDestination.java @@ -18,12 +18,9 @@ package appeng.util.inv; - import net.minecraft.item.ItemStack; +public interface IInventoryDestination { -public interface IInventoryDestination -{ - - boolean canInsert( ItemStack stack ); + boolean canInsert(ItemStack stack); } diff --git a/src/main/java/appeng/util/inv/IMEAdaptor.java b/src/main/java/appeng/util/inv/IMEAdaptor.java index e47875572..e6e4163a2 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptor.java +++ b/src/main/java/appeng/util/inv/IMEAdaptor.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.Iterator; import com.google.common.collect.ImmutableList; @@ -36,171 +35,143 @@ import appeng.api.storage.data.IItemList; import appeng.util.InventoryAdaptor; import appeng.util.item.AEItemStack; +public class IMEAdaptor extends InventoryAdaptor { -public class IMEAdaptor extends InventoryAdaptor -{ + private final IMEInventory target; + private final IActionSource src; + private int maxSlots = 0; - private final IMEInventory target; - private final IActionSource src; - private int maxSlots = 0; + public IMEAdaptor(final IMEInventory input, final IActionSource src) { + this.target = input; + this.src = src; + } - public IMEAdaptor( final IMEInventory input, final IActionSource src ) - { - this.target = input; - this.src = src; - } + @Override + public boolean hasSlots() { + return true; + } - @Override - public boolean hasSlots() - { - return true; - } + @Override + public Iterator iterator() { + return new IMEAdaptorIterator(this, this.getList()); + } - @Override - public Iterator iterator() - { - return new IMEAdaptorIterator( this, this.getList() ); - } + private IItemList getList() { + return this.target.getAvailableItems( + AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); + } - private IItemList getList() - { - return this.target.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ); - } + @Override + public ItemStack removeItems(final int amount, final ItemStack filter, final IInventoryDestination destination) { + return this.doRemoveItems(amount, filter, destination, Actionable.MODULATE); + } - @Override - public ItemStack removeItems( final int amount, final ItemStack filter, final IInventoryDestination destination ) - { - return this.doRemoveItems( amount, filter, destination, Actionable.MODULATE ); - } + private ItemStack doRemoveItems(final int amount, final ItemStack filter, final IInventoryDestination destination, + final Actionable type) { + IAEItemStack req = null; - private ItemStack doRemoveItems( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type ) - { - IAEItemStack req = null; + if (filter.isEmpty()) { + final IItemList list = this.getList(); + if (!list.isEmpty()) { + req = list.getFirstItem(); + } + } else { + req = AEItemStack.fromItemStack(filter); + } - if( filter.isEmpty() ) - { - final IItemList list = this.getList(); - if( !list.isEmpty() ) - { - req = list.getFirstItem(); - } - } - else - { - req = AEItemStack.fromItemStack( filter ); - } + IAEItemStack out = null; - IAEItemStack out = null; + if (req != null) { + req.setStackSize(amount); + out = this.target.extractItems(req, type, this.src); + } - if( req != null ) - { - req.setStackSize( amount ); - out = this.target.extractItems( req, type, this.src ); - } + if (out != null) { + return out.createItemStack(); + } - if( out != null ) - { - return out.createItemStack(); - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateRemove(final int amount, final ItemStack filter, final IInventoryDestination destination) { + return this.doRemoveItems(amount, filter, destination, Actionable.SIMULATE); + } - @Override - public ItemStack simulateRemove( final int amount, final ItemStack filter, final IInventoryDestination destination ) - { - return this.doRemoveItems( amount, filter, destination, Actionable.SIMULATE ); - } + @Override + public ItemStack removeSimilarItems(final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, + final IInventoryDestination destination) { + if (filter.isEmpty()) { + return this.doRemoveItems(amount, null, destination, Actionable.MODULATE); + } + return this.doRemoveItemsFuzzy(amount, filter, destination, Actionable.MODULATE, fuzzyMode); + } - @Override - public ItemStack removeSimilarItems( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) - { - if( filter.isEmpty() ) - { - return this.doRemoveItems( amount, null, destination, Actionable.MODULATE ); - } - return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.MODULATE, fuzzyMode ); - } + private ItemStack doRemoveItemsFuzzy(final int amount, final ItemStack filter, + final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode) { + final IAEItemStack reqFilter = AEItemStack.fromItemStack(filter); + if (reqFilter == null) { + return ItemStack.EMPTY; + } - private ItemStack doRemoveItemsFuzzy( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode ) - { - final IAEItemStack reqFilter = AEItemStack.fromItemStack( filter ); - if( reqFilter == null ) - { - return ItemStack.EMPTY; - } + IAEItemStack out = null; - IAEItemStack out = null; + for (final IAEItemStack req : ImmutableList.copyOf(this.getList().findFuzzy(reqFilter, fuzzyMode))) { + if (req != null) { + req.setStackSize(amount); + out = this.target.extractItems(req, type, this.src); + if (out != null) { + return out.createItemStack(); + } + } + } - for( final IAEItemStack req : ImmutableList.copyOf( this.getList().findFuzzy( reqFilter, fuzzyMode ) ) ) - { - if( req != null ) - { - req.setStackSize( amount ); - out = this.target.extractItems( req, type, this.src ); - if( out != null ) - { - return out.createItemStack(); - } - } - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateSimilarRemove(final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, + final IInventoryDestination destination) { + if (filter.isEmpty()) { + return this.doRemoveItems(amount, ItemStack.EMPTY, destination, Actionable.SIMULATE); + } + return this.doRemoveItemsFuzzy(amount, filter, destination, Actionable.SIMULATE, fuzzyMode); + } - @Override - public ItemStack simulateSimilarRemove( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) - { - if( filter.isEmpty() ) - { - return this.doRemoveItems( amount, ItemStack.EMPTY, destination, Actionable.SIMULATE ); - } - return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.SIMULATE, fuzzyMode ); - } + @Override + public ItemStack addItems(final ItemStack toBeAdded) { + final IAEItemStack in = AEItemStack.fromItemStack(toBeAdded); + if (in != null) { + final IAEItemStack out = this.target.injectItems(in, Actionable.MODULATE, this.src); + if (out != null) { + return out.createItemStack(); + } + } + return ItemStack.EMPTY; + } - @Override - public ItemStack addItems( final ItemStack toBeAdded ) - { - final IAEItemStack in = AEItemStack.fromItemStack( toBeAdded ); - if( in != null ) - { - final IAEItemStack out = this.target.injectItems( in, Actionable.MODULATE, this.src ); - if( out != null ) - { - return out.createItemStack(); - } - } - return ItemStack.EMPTY; - } + @Override + public ItemStack simulateAdd(final ItemStack toBeSimulated) { + final IAEItemStack in = AEItemStack.fromItemStack(toBeSimulated); + if (in != null) { + final IAEItemStack out = this.target.injectItems(in, Actionable.SIMULATE, this.src); + if (out != null) { + return out.createItemStack(); + } + } + return ItemStack.EMPTY; + } - @Override - public ItemStack simulateAdd( final ItemStack toBeSimulated ) - { - final IAEItemStack in = AEItemStack.fromItemStack( toBeSimulated ); - if( in != null ) - { - final IAEItemStack out = this.target.injectItems( in, Actionable.SIMULATE, this.src ); - if( out != null ) - { - return out.createItemStack(); - } - } - return ItemStack.EMPTY; - } + @Override + public boolean containsItems() { + return !this.getList().isEmpty(); + } - @Override - public boolean containsItems() - { - return !this.getList().isEmpty(); - } + int getMaxSlots() { + return this.maxSlots; + } - int getMaxSlots() - { - return this.maxSlots; - } - - void setMaxSlots( final int maxSlots ) - { - this.maxSlots = maxSlots; - } + void setMaxSlots(final int maxSlots) { + this.maxSlots = maxSlots; + } } diff --git a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java index 23664e814..c322e4527 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java +++ b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.Iterator; import net.minecraft.item.ItemStack; @@ -26,57 +25,49 @@ import net.minecraft.item.ItemStack; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +public final class IMEAdaptorIterator implements Iterator { + private final Iterator stack; + private final ItemSlot slot = new ItemSlot(); + private final IMEAdaptor parent; + private final int containerSize; -public final class IMEAdaptorIterator implements Iterator -{ - private final Iterator stack; - private final ItemSlot slot = new ItemSlot(); - private final IMEAdaptor parent; - private final int containerSize; + private int offset = 0; + private boolean hasNext; - private int offset = 0; - private boolean hasNext; + public IMEAdaptorIterator(final IMEAdaptor parent, final IItemList availableItems) { + this.stack = availableItems.iterator(); + this.containerSize = parent.getMaxSlots(); + this.parent = parent; + } - public IMEAdaptorIterator( final IMEAdaptor parent, final IItemList availableItems ) - { - this.stack = availableItems.iterator(); - this.containerSize = parent.getMaxSlots(); - this.parent = parent; - } + @Override + public boolean hasNext() { + this.hasNext = this.stack.hasNext(); + return this.offset < this.containerSize || this.hasNext; + } - @Override - public boolean hasNext() - { - this.hasNext = this.stack.hasNext(); - return this.offset < this.containerSize || this.hasNext; - } + @Override + public ItemSlot next() { + this.slot.setSlot(this.offset); + this.offset++; + this.slot.setExtractable(true); - @Override - public ItemSlot next() - { - this.slot.setSlot( this.offset ); - this.offset++; - this.slot.setExtractable( true ); + if (this.parent.getMaxSlots() < this.offset) { + this.parent.setMaxSlots(this.offset); + } - if( this.parent.getMaxSlots() < this.offset ) - { - this.parent.setMaxSlots( this.offset ); - } + if (this.hasNext) { + final IAEItemStack item = this.stack.next(); + this.slot.setAEItemStack(item); + return this.slot; + } - if( this.hasNext ) - { - final IAEItemStack item = this.stack.next(); - this.slot.setAEItemStack( item ); - return this.slot; - } + this.slot.setItemStack(ItemStack.EMPTY); + return this.slot; + } - this.slot.setItemStack( ItemStack.EMPTY ); - return this.slot; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/inv/IMEInventoryDestination.java b/src/main/java/appeng/util/inv/IMEInventoryDestination.java index 1c07b3f7a..150a0fad4 100644 --- a/src/main/java/appeng/util/inv/IMEInventoryDestination.java +++ b/src/main/java/appeng/util/inv/IMEInventoryDestination.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import net.minecraft.item.ItemStack; import appeng.api.config.Actionable; @@ -26,32 +25,26 @@ import appeng.api.storage.IMEInventory; import appeng.api.storage.data.IAEItemStack; import appeng.util.item.AEItemStack; +public class IMEInventoryDestination implements IInventoryDestination { -public class IMEInventoryDestination implements IInventoryDestination -{ + private final IMEInventory me; - private final IMEInventory me; + public IMEInventoryDestination(final IMEInventory o) { + this.me = o; + } - public IMEInventoryDestination( final IMEInventory o ) - { - this.me = o; - } + @Override + public boolean canInsert(final ItemStack stack) { - @Override - public boolean canInsert( final ItemStack stack ) - { + if (stack.isEmpty()) { + return false; + } - if( stack.isEmpty() ) - { - return false; - } + final IAEItemStack failed = this.me.injectItems(AEItemStack.fromItemStack(stack), Actionable.SIMULATE, null); - final IAEItemStack failed = this.me.injectItems( AEItemStack.fromItemStack( stack ), Actionable.SIMULATE, null ); - - if( failed == null ) - { - return true; - } - return failed.getStackSize() != stack.getCount(); - } + if (failed == null) { + return true; + } + return failed.getStackSize() != stack.getCount(); + } } diff --git a/src/main/java/appeng/util/inv/InvOperation.java b/src/main/java/appeng/util/inv/InvOperation.java index b11390ac5..f737959d6 100644 --- a/src/main/java/appeng/util/inv/InvOperation.java +++ b/src/main/java/appeng/util/inv/InvOperation.java @@ -18,8 +18,6 @@ package appeng.util.inv; - -public enum InvOperation -{ - EXTRACT, INSERT, SET +public enum InvOperation { + EXTRACT, INSERT, SET } diff --git a/src/main/java/appeng/util/inv/ItemHandlerIterator.java b/src/main/java/appeng/util/inv/ItemHandlerIterator.java index 6994cbbb4..2c1df841e 100644 --- a/src/main/java/appeng/util/inv/ItemHandlerIterator.java +++ b/src/main/java/appeng/util/inv/ItemHandlerIterator.java @@ -18,45 +18,38 @@ package appeng.util.inv; - import java.util.Iterator; import java.util.NoSuchElementException; import net.minecraftforge.items.IItemHandler; +class ItemHandlerIterator implements Iterator { -class ItemHandlerIterator implements Iterator -{ + private final IItemHandler itemHandler; - private final IItemHandler itemHandler; + private final ItemSlot itemSlot = new ItemSlot(); - private final ItemSlot itemSlot = new ItemSlot(); + private int slot = 0; - private int slot = 0; + ItemHandlerIterator(IItemHandler itemHandler) { + this.itemHandler = itemHandler; + } - ItemHandlerIterator( IItemHandler itemHandler ) - { - this.itemHandler = itemHandler; - } + @Override + public boolean hasNext() { + return this.slot < this.itemHandler.getSlots(); + } - @Override - public boolean hasNext() - { - return this.slot < this.itemHandler.getSlots(); - } - - @Override - public ItemSlot next() - { - if( this.slot >= this.itemHandler.getSlots() ) - { - throw new NoSuchElementException(); - } - this.itemSlot.setExtractable( !this.itemHandler.extractItem( this.slot, 1, true ).isEmpty() ); - this.itemSlot.setItemStack( this.itemHandler.getStackInSlot( this.slot ) ); - this.itemSlot.setSlot( this.slot ); - this.slot++; - return this.itemSlot; - } + @Override + public ItemSlot next() { + if (this.slot >= this.itemHandler.getSlots()) { + throw new NoSuchElementException(); + } + this.itemSlot.setExtractable(!this.itemHandler.extractItem(this.slot, 1, true).isEmpty()); + this.itemSlot.setItemStack(this.itemHandler.getStackInSlot(this.slot)); + this.itemSlot.setSlot(this.slot); + this.slot++; + return this.itemSlot; + } } diff --git a/src/main/java/appeng/util/inv/ItemListIgnoreCrafting.java b/src/main/java/appeng/util/inv/ItemListIgnoreCrafting.java index 6cf39faff..25c8d3ec1 100644 --- a/src/main/java/appeng/util/inv/ItemListIgnoreCrafting.java +++ b/src/main/java/appeng/util/inv/ItemListIgnoreCrafting.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.Collection; import java.util.Iterator; @@ -26,86 +25,71 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public class ItemListIgnoreCrafting> implements IItemList { -public class ItemListIgnoreCrafting> implements IItemList -{ + private final IItemList target; - private final IItemList target; + public ItemListIgnoreCrafting(final IItemList cla) { + this.target = cla; + } - public ItemListIgnoreCrafting( final IItemList cla ) - { - this.target = cla; - } + @Override + public void add(T option) { + if (option != null && option.isCraftable()) { + option = option.copy(); + option.setCraftable(false); + } - @Override - public void add( T option ) - { - if( option != null && option.isCraftable() ) - { - option = option.copy(); - option.setCraftable( false ); - } + this.target.add(option); + } - this.target.add( option ); - } + @Override + public T findPrecise(final T i) { + return this.target.findPrecise(i); + } - @Override - public T findPrecise( final T i ) - { - return this.target.findPrecise( i ); - } + @Override + public Collection findFuzzy(final T input, final FuzzyMode fuzzy) { + return this.target.findFuzzy(input, fuzzy); + } - @Override - public Collection findFuzzy( final T input, final FuzzyMode fuzzy ) - { - return this.target.findFuzzy( input, fuzzy ); - } + @Override + public boolean isEmpty() { + return this.target.isEmpty(); + } - @Override - public boolean isEmpty() - { - return this.target.isEmpty(); - } + @Override + public void addStorage(final T option) { + this.target.addStorage(option); + } - @Override - public void addStorage( final T option ) - { - this.target.addStorage( option ); - } + @Override + public void addCrafting(final T option) { + // nothing. + } - @Override - public void addCrafting( final T option ) - { - // nothing. - } + @Override + public void addRequestable(final T option) { + this.target.addRequestable(option); + } - @Override - public void addRequestable( final T option ) - { - this.target.addRequestable( option ); - } + @Override + public T getFirstItem() { + return this.target.getFirstItem(); + } - @Override - public T getFirstItem() - { - return this.target.getFirstItem(); - } + @Override + public int size() { + return this.target.size(); + } - @Override - public int size() - { - return this.target.size(); - } + @Override + public Iterator iterator() { + return this.target.iterator(); + } - @Override - public Iterator iterator() - { - return this.target.iterator(); - } - - @Override - public void resetStatus() - { - this.target.resetStatus(); - } + @Override + public void resetStatus() { + this.target.resetStatus(); + } } diff --git a/src/main/java/appeng/util/inv/ItemSlot.java b/src/main/java/appeng/util/inv/ItemSlot.java index 795a6336e..104986838 100644 --- a/src/main/java/appeng/util/inv/ItemSlot.java +++ b/src/main/java/appeng/util/inv/ItemSlot.java @@ -18,63 +18,54 @@ package appeng.util.inv; - import net.minecraft.item.ItemStack; import appeng.api.storage.data.IAEItemStack; import appeng.util.item.AEItemStack; +public class ItemSlot { -public class ItemSlot -{ + private int slot; + private boolean isExtractable; + // one or the other.. + private IAEItemStack aeItemStack; + private ItemStack itemStack; - private int slot; - private boolean isExtractable; - // one or the other.. - private IAEItemStack aeItemStack; - private ItemStack itemStack; + public ItemStack getItemStack() { + return this.itemStack.isEmpty() + ? (this.aeItemStack == null ? ItemStack.EMPTY : (this.itemStack = this.aeItemStack.createItemStack())) + : this.itemStack; + } - public ItemStack getItemStack() - { - return this.itemStack - .isEmpty() ? ( this.aeItemStack == null ? ItemStack.EMPTY : ( this.itemStack = this.aeItemStack.createItemStack() ) ) : this.itemStack; - } + public void setItemStack(final ItemStack is) { + this.aeItemStack = null; + this.itemStack = is; + } - public void setItemStack( final ItemStack is ) - { - this.aeItemStack = null; - this.itemStack = is; - } + public IAEItemStack getAEItemStack() { + return this.aeItemStack == null + ? (this.itemStack.isEmpty() ? null : (this.aeItemStack = AEItemStack.fromItemStack(this.itemStack))) + : this.aeItemStack; + } - public IAEItemStack getAEItemStack() - { - return this.aeItemStack == null ? ( this.itemStack - .isEmpty() ? null : ( this.aeItemStack = AEItemStack.fromItemStack( this.itemStack ) ) ) : this.aeItemStack; - } + void setAEItemStack(final IAEItemStack is) { + this.aeItemStack = is; + this.itemStack = ItemStack.EMPTY; + } - void setAEItemStack( final IAEItemStack is ) - { - this.aeItemStack = is; - this.itemStack = ItemStack.EMPTY; - } + public boolean isExtractable() { + return this.isExtractable; + } - public boolean isExtractable() - { - return this.isExtractable; - } + void setExtractable(final boolean isExtractable) { + this.isExtractable = isExtractable; + } - void setExtractable( final boolean isExtractable ) - { - this.isExtractable = isExtractable; - } + public int getSlot() { + return this.slot; + } - public int getSlot() - { - return this.slot; - } - - public void setSlot( final int slot ) - { - this.slot = slot; - } + public void setSlot(final int slot) { + this.slot = slot; + } } diff --git a/src/main/java/appeng/util/inv/WrapperChainedItemHandler.java b/src/main/java/appeng/util/inv/WrapperChainedItemHandler.java index 84d32ad77..d8be97baf 100644 --- a/src/main/java/appeng/util/inv/WrapperChainedItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperChainedItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.ArrayList; import javax.annotation.Nonnull; @@ -30,141 +29,118 @@ import net.minecraftforge.items.wrapper.EmptyHandler; import appeng.util.helpers.ItemHandlerUtil; +public class WrapperChainedItemHandler implements IItemHandlerModifiable { + private IItemHandler[] itemHandler; // the handlers + private int[] baseIndex; // index-offsets of the different handlers + private int slotCount; // number of total slots -public class WrapperChainedItemHandler implements IItemHandlerModifiable -{ - private IItemHandler[] itemHandler; // the handlers - private int[] baseIndex; // index-offsets of the different handlers - private int slotCount; // number of total slots + public WrapperChainedItemHandler(IItemHandler... itemHandler) { + this.setItemHandlers(itemHandler); + } - public WrapperChainedItemHandler( IItemHandler... itemHandler ) - { - this.setItemHandlers( itemHandler ); - } + private void setItemHandlers(IItemHandler[] handlers) { + this.itemHandler = handlers; + this.baseIndex = new int[this.itemHandler.length]; + int index = 0; + for (int i = 0; i < this.itemHandler.length; i++) { + index += this.itemHandler[i].getSlots(); + this.baseIndex[i] = index; + } + this.slotCount = index; + } - private void setItemHandlers( IItemHandler[] handlers ) - { - this.itemHandler = handlers; - this.baseIndex = new int[this.itemHandler.length]; - int index = 0; - for( int i = 0; i < this.itemHandler.length; i++ ) - { - index += this.itemHandler[i].getSlots(); - this.baseIndex[i] = index; - } - this.slotCount = index; - } + // returns the handler index for the slot + private int getIndexForSlot(int slot) { + if (slot < 0) { + return -1; + } - // returns the handler index for the slot - private int getIndexForSlot( int slot ) - { - if( slot < 0 ) - { - return -1; - } + for (int i = 0; i < this.baseIndex.length; i++) { + if (slot - this.baseIndex[i] < 0) { + return i; + } + } + return -1; + } - for( int i = 0; i < this.baseIndex.length; i++ ) - { - if( slot - this.baseIndex[i] < 0 ) - { - return i; - } - } - return -1; - } + private IItemHandler getHandlerFromIndex(int index) { + if (index < 0 || index >= this.itemHandler.length) { + return EmptyHandler.INSTANCE; + } + return this.itemHandler[index]; + } - private IItemHandler getHandlerFromIndex( int index ) - { - if( index < 0 || index >= this.itemHandler.length ) - { - return EmptyHandler.INSTANCE; - } - return this.itemHandler[index]; - } + private int getSlotFromIndex(int slot, int index) { + if (index <= 0 || index >= this.baseIndex.length) { + return slot; + } + return slot - this.baseIndex[index - 1]; + } - private int getSlotFromIndex( int slot, int index ) - { - if( index <= 0 || index >= this.baseIndex.length ) - { - return slot; - } - return slot - this.baseIndex[index - 1]; - } + public void cycleOrder() { + if (this.itemHandler.length > 1) { + ArrayList newOrder = new ArrayList<>(); + newOrder.add(this.itemHandler[this.itemHandler.length - 1]); + for (int i = 0; i < this.itemHandler.length - 1; ++i) { + newOrder.add(this.itemHandler[i]); + } + this.setItemHandlers(newOrder.toArray(new IItemHandler[this.itemHandler.length])); + } + } - public void cycleOrder() - { - if( this.itemHandler.length > 1 ) - { - ArrayList newOrder = new ArrayList<>(); - newOrder.add( this.itemHandler[this.itemHandler.length - 1] ); - for( int i = 0; i < this.itemHandler.length - 1; ++i ) - { - newOrder.add( this.itemHandler[i] ); - } - this.setItemHandlers( newOrder.toArray( new IItemHandler[this.itemHandler.length] ) ); - } - } + @Override + public int getSlots() { + return this.slotCount; + } - @Override - public int getSlots() - { - return this.slotCount; - } + @Override + @Nonnull + public ItemStack getStackInSlot(final int slot) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int targetSlot = this.getSlotFromIndex(slot, index); + return handler.getStackInSlot(targetSlot); + } - @Override - @Nonnull - public ItemStack getStackInSlot( final int slot ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int targetSlot = this.getSlotFromIndex( slot, index ); - return handler.getStackInSlot( targetSlot ); - } + @Override + @Nonnull + public ItemStack insertItem(final int slot, @Nonnull ItemStack stack, boolean simulate) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int targetSlot = this.getSlotFromIndex(slot, index); + return handler.insertItem(targetSlot, stack, simulate); + } - @Override - @Nonnull - public ItemStack insertItem( final int slot, @Nonnull ItemStack stack, boolean simulate ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int targetSlot = this.getSlotFromIndex( slot, index ); - return handler.insertItem( targetSlot, stack, simulate ); - } + @Override + @Nonnull + public ItemStack extractItem(int slot, int amount, boolean simulate) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int targetSlot = this.getSlotFromIndex(slot, index); + return handler.extractItem(targetSlot, amount, simulate); + } - @Override - @Nonnull - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int targetSlot = this.getSlotFromIndex( slot, index ); - return handler.extractItem( targetSlot, amount, simulate ); - } + @Override + public int getSlotLimit(int slot) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int localSlot = this.getSlotFromIndex(slot, index); + return handler.getSlotLimit(localSlot); + } - @Override - public int getSlotLimit( int slot ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int localSlot = this.getSlotFromIndex( slot, index ); - return handler.getSlotLimit( localSlot ); - } + @Override + public void setStackInSlot(int slot, ItemStack stack) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int targetSlot = this.getSlotFromIndex(slot, index); + ItemHandlerUtil.setStackInSlot(handler, targetSlot, stack); + } - @Override - public void setStackInSlot( int slot, ItemStack stack ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int targetSlot = this.getSlotFromIndex( slot, index ); - ItemHandlerUtil.setStackInSlot( handler, targetSlot, stack ); - } - - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - int index = this.getIndexForSlot( slot ); - IItemHandler handler = this.getHandlerFromIndex( index ); - int targetSlot = this.getSlotFromIndex( slot, index ); - return handler.isItemValid( targetSlot, stack ); - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + int index = this.getIndexForSlot(slot); + IItemHandler handler = this.getHandlerFromIndex(index); + int targetSlot = this.getSlotFromIndex(slot, index); + return handler.isItemValid(targetSlot, stack); + } } diff --git a/src/main/java/appeng/util/inv/WrapperCursorItemHandler.java b/src/main/java/appeng/util/inv/WrapperCursorItemHandler.java index c7f9f733b..7b457c52b 100644 --- a/src/main/java/appeng/util/inv/WrapperCursorItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperCursorItemHandler.java @@ -18,26 +18,21 @@ package appeng.util.inv; - import net.minecraft.entity.player.PlayerInventory; import net.minecraftforge.items.ItemStackHandler; +public class WrapperCursorItemHandler extends ItemStackHandler { + private final PlayerInventory inv; -public class WrapperCursorItemHandler extends ItemStackHandler -{ - private final PlayerInventory inv; + public WrapperCursorItemHandler(PlayerInventory PlayerInventory) { + super(1); - public WrapperCursorItemHandler( PlayerInventory PlayerInventory ) - { - super( 1 ); + this.inv = PlayerInventory; + this.setStackInSlot(0, PlayerInventory.getItemStack()); + } - this.inv = PlayerInventory; - this.setStackInSlot( 0, PlayerInventory.getItemStack() ); - } - - @Override - protected void onContentsChanged( int slot ) - { - this.inv.setItemStack( this.getStackInSlot( slot ) ); - } + @Override + protected void onContentsChanged(int slot) { + this.inv.setItemStack(this.getStackInSlot(slot)); + } } diff --git a/src/main/java/appeng/util/inv/WrapperFilteredItemHandler.java b/src/main/java/appeng/util/inv/WrapperFilteredItemHandler.java index 125da1c26..071b09f20 100644 --- a/src/main/java/appeng/util/inv/WrapperFilteredItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperFilteredItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -28,71 +27,58 @@ import net.minecraftforge.items.IItemHandlerModifiable; import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.filter.IAEItemFilter; +public class WrapperFilteredItemHandler implements IItemHandlerModifiable { + private final IItemHandler handler; + private final IAEItemFilter filter; -public class WrapperFilteredItemHandler implements IItemHandlerModifiable -{ - private final IItemHandler handler; - private final IAEItemFilter filter; + public WrapperFilteredItemHandler(@Nonnull IItemHandler handler, @Nonnull IAEItemFilter filter) { + this.handler = handler; + this.filter = filter; + } - public WrapperFilteredItemHandler( @Nonnull IItemHandler handler, @Nonnull IAEItemFilter filter ) - { - this.handler = handler; - this.filter = filter; - } + @Override + public void setStackInSlot(int slot, ItemStack stack) { + ItemHandlerUtil.setStackInSlot(this.handler, slot, stack); + } - @Override - public void setStackInSlot( int slot, ItemStack stack ) - { - ItemHandlerUtil.setStackInSlot( this.handler, slot, stack ); - } + @Override + public int getSlots() { + return this.handler.getSlots(); + } - @Override - public int getSlots() - { - return this.handler.getSlots(); - } + @Override + public ItemStack getStackInSlot(int slot) { + return this.handler.getStackInSlot(slot); + } - @Override - public ItemStack getStackInSlot( int slot ) - { - return this.handler.getStackInSlot( slot ); - } + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + if (!this.filter.allowInsert(this.handler, slot, stack)) { + return stack; + } - @Override - public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) - { - if( !this.filter.allowInsert( this.handler, slot, stack ) ) - { - return stack; - } + return this.handler.insertItem(slot, stack, simulate); + } - return this.handler.insertItem( slot, stack, simulate ); - } + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (!this.filter.allowExtract(this.handler, slot, amount)) { + return ItemStack.EMPTY; + } - @Override - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - if( !this.filter.allowExtract( this.handler, slot, amount ) ) - { - return ItemStack.EMPTY; - } + return this.handler.extractItem(slot, amount, simulate); + } - return this.handler.extractItem( slot, amount, simulate ); - } + @Override + public int getSlotLimit(int slot) { + return this.handler.getSlotLimit(slot); + } - @Override - public int getSlotLimit( int slot ) - { - return this.handler.getSlotLimit( slot ); - } - - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - if( !this.filter.allowInsert( this.handler, slot, stack ) ) - { - return false; - } - return this.handler.isItemValid( slot, stack ); - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + if (!this.filter.allowInsert(this.handler, slot, stack)) { + return false; + } + return this.handler.isItemValid(slot, stack); + } } diff --git a/src/main/java/appeng/util/inv/WrapperInvItemHandler.java b/src/main/java/appeng/util/inv/WrapperInvItemHandler.java index e5a2bdf9c..d714fd1a2 100644 --- a/src/main/java/appeng/util/inv/WrapperInvItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperInvItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -27,97 +26,80 @@ import net.minecraftforge.items.IItemHandler; import appeng.util.helpers.ItemHandlerUtil; +public class WrapperInvItemHandler implements IInventory { + private final IItemHandler inv; -public class WrapperInvItemHandler implements IInventory -{ - private final IItemHandler inv; + public WrapperInvItemHandler(final IItemHandler inv) { + this.inv = inv; + } - public WrapperInvItemHandler( final IItemHandler inv ) - { - this.inv = inv; - } + @Override + public int getSizeInventory() { + return this.inv.getSlots(); + } - @Override - public int getSizeInventory() - { - return this.inv.getSlots(); - } + @Override + public boolean isEmpty() { + return ItemHandlerUtil.isEmpty(this.inv); + } - @Override - public boolean isEmpty() - { - return ItemHandlerUtil.isEmpty( this.inv ); - } + @Override + public ItemStack getStackInSlot(int index) { + return this.inv.getStackInSlot(index); + } - @Override - public ItemStack getStackInSlot( int index ) - { - return this.inv.getStackInSlot( index ); - } + @Override + public ItemStack decrStackSize(int index, int count) { + return this.inv.extractItem(index, count, false); + } - @Override - public ItemStack decrStackSize( int index, int count ) - { - return this.inv.extractItem( index, count, false ); - } + @Override + public ItemStack removeStackFromSlot(int index) { + return this.inv.extractItem(index, this.inv.getSlotLimit(index), false); + } - @Override - public ItemStack removeStackFromSlot( int index ) - { - return this.inv.extractItem( index, this.inv.getSlotLimit( index ), false ); - } + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + ItemHandlerUtil.setStackInSlot(this.inv, index, stack); + } - @Override - public void setInventorySlotContents( int index, ItemStack stack ) - { - ItemHandlerUtil.setStackInSlot( this.inv, index, stack ); - } + @Override + public int getInventoryStackLimit() { + int max = 0; + for (int i = 0; i < this.inv.getSlots(); ++i) { + max = Math.max(max, this.inv.getSlotLimit(i)); + } + return max; + } - @Override - public int getInventoryStackLimit() - { - int max = 0; - for( int i = 0; i < this.inv.getSlots(); ++i ) - { - max = Math.max( max, this.inv.getSlotLimit( i ) ); - } - return max; - } + @Override + public void markDirty() { + // NOP + } - @Override - public void markDirty() - { - // NOP - } + @Override + public boolean isUsableByPlayer(PlayerEntity player) { + return false; + } - @Override - public boolean isUsableByPlayer( PlayerEntity player ) - { - return false; - } + @Override + public void openInventory(PlayerEntity player) { + // NOP + } - @Override - public void openInventory( PlayerEntity player ) - { - // NOP - } + @Override + public void closeInventory(PlayerEntity player) { + // NOP + } - @Override - public void closeInventory( PlayerEntity player ) - { - // NOP - } + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + return this.inv.isItemValid(index, stack); + } - @Override - public boolean isItemValidForSlot( int index, ItemStack stack ) - { - return this.inv.isItemValid( index, stack ); - } - - @Override - public void clear() - { - ItemHandlerUtil.clear( this.inv ); - } + @Override + public void clear() { + ItemHandlerUtil.clear(this.inv); + } } diff --git a/src/main/java/appeng/util/inv/WrapperRangeItemHandler.java b/src/main/java/appeng/util/inv/WrapperRangeItemHandler.java index 986192967..042b79dd7 100644 --- a/src/main/java/appeng/util/inv/WrapperRangeItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperRangeItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -27,94 +26,77 @@ import net.minecraftforge.items.IItemHandlerModifiable; import appeng.util.helpers.ItemHandlerUtil; +public class WrapperRangeItemHandler implements IItemHandlerModifiable { + private final IItemHandler compose; + private final int minSlot; + private final int maxSlot; -public class WrapperRangeItemHandler implements IItemHandlerModifiable -{ - private final IItemHandler compose; - private final int minSlot; - private final int maxSlot; + public WrapperRangeItemHandler(IItemHandler compose, int minSlot, int maxSlotExclusive) { + this.compose = compose; + this.minSlot = minSlot; + this.maxSlot = maxSlotExclusive; + } - public WrapperRangeItemHandler( IItemHandler compose, int minSlot, int maxSlotExclusive ) - { - this.compose = compose; - this.minSlot = minSlot; - this.maxSlot = maxSlotExclusive; - } + @Override + public int getSlots() { + return this.maxSlot - this.minSlot; + } - @Override - public int getSlots() - { - return this.maxSlot - this.minSlot; - } + @Override + @Nonnull + public ItemStack getStackInSlot(int slot) { + if (this.checkSlot(slot)) { + return this.compose.getStackInSlot(slot + this.minSlot); + } - @Override - @Nonnull - public ItemStack getStackInSlot( int slot ) - { - if( this.checkSlot( slot ) ) - { - return this.compose.getStackInSlot( slot + this.minSlot ); - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + @Nonnull + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if (this.checkSlot(slot)) { + return this.compose.insertItem(slot + this.minSlot, stack, simulate); + } - @Override - @Nonnull - public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate ) - { - if( this.checkSlot( slot ) ) - { - return this.compose.insertItem( slot + this.minSlot, stack, simulate ); - } + return stack; + } - return stack; - } + @Override + @Nonnull + public ItemStack extractItem(int slot, int amount, boolean simulate) { + if (this.checkSlot(slot)) { + return this.compose.extractItem(slot + this.minSlot, amount, simulate); + } - @Override - @Nonnull - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - if( this.checkSlot( slot ) ) - { - return this.compose.extractItem( slot + this.minSlot, amount, simulate ); - } + return ItemStack.EMPTY; + } - return ItemStack.EMPTY; - } + @Override + public void setStackInSlot(int slot, @Nonnull ItemStack stack) { + if (this.checkSlot(slot)) { + ItemHandlerUtil.setStackInSlot(this.compose, slot + this.minSlot, stack); + } + } - @Override - public void setStackInSlot( int slot, @Nonnull ItemStack stack ) - { - if( this.checkSlot( slot ) ) - { - ItemHandlerUtil.setStackInSlot( this.compose, slot + this.minSlot, stack ); - } - } + @Override + public int getSlotLimit(int slot) { + if (this.checkSlot(slot)) { + return this.compose.getSlotLimit(slot + this.minSlot); + } - @Override - public int getSlotLimit( int slot ) - { - if( this.checkSlot( slot ) ) - { - return this.compose.getSlotLimit( slot + this.minSlot ); - } + return 0; + } - return 0; - } + private boolean checkSlot(int localSlot) { + return localSlot + this.minSlot < this.maxSlot; + } - private boolean checkSlot( int localSlot ) - { - return localSlot + this.minSlot < this.maxSlot; - } - - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - if( this.checkSlot( slot ) ) - { - return this.compose.isItemValid( slot + this.minSlot, stack ); - } - return false; - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + if (this.checkSlot(slot)) { + return this.compose.isItemValid(slot + this.minSlot, stack); + } + return false; + } } diff --git a/src/main/java/appeng/util/inv/WrapperSupplierItemHandler.java b/src/main/java/appeng/util/inv/WrapperSupplierItemHandler.java index 7e75b393d..d25f15808 100644 --- a/src/main/java/appeng/util/inv/WrapperSupplierItemHandler.java +++ b/src/main/java/appeng/util/inv/WrapperSupplierItemHandler.java @@ -18,7 +18,6 @@ package appeng.util.inv; - import java.util.function.Supplier; import net.minecraft.item.ItemStack; @@ -27,55 +26,45 @@ import net.minecraftforge.items.IItemHandlerModifiable; import appeng.util.helpers.ItemHandlerUtil; +public class WrapperSupplierItemHandler implements IItemHandlerModifiable { + private final Supplier sourceHandler; -public class WrapperSupplierItemHandler implements IItemHandlerModifiable -{ - private final Supplier sourceHandler; + public WrapperSupplierItemHandler(Supplier source) { + this.sourceHandler = source; + } - public WrapperSupplierItemHandler( Supplier source ) - { - this.sourceHandler = source; - } + @Override + public int getSlots() { + return this.sourceHandler.get().getSlots(); + } - @Override - public int getSlots() - { - return this.sourceHandler.get().getSlots(); - } + @Override + public ItemStack getStackInSlot(int slot) { + return this.sourceHandler.get().getStackInSlot(slot); + } - @Override - public ItemStack getStackInSlot( int slot ) - { - return this.sourceHandler.get().getStackInSlot( slot ); - } + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + return this.sourceHandler.get().insertItem(slot, stack, simulate); + } - @Override - public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) - { - return this.sourceHandler.get().insertItem( slot, stack, simulate ); - } + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + return this.sourceHandler.get().extractItem(slot, amount, simulate); + } - @Override - public ItemStack extractItem( int slot, int amount, boolean simulate ) - { - return this.sourceHandler.get().extractItem( slot, amount, simulate ); - } + @Override + public int getSlotLimit(int slot) { + return this.sourceHandler.get().getSlotLimit(slot); + } - @Override - public int getSlotLimit( int slot ) - { - return this.sourceHandler.get().getSlotLimit( slot ); - } + @Override + public void setStackInSlot(int slot, ItemStack stack) { + ItemHandlerUtil.setStackInSlot(this.sourceHandler.get(), slot, stack); + } - @Override - public void setStackInSlot( int slot, ItemStack stack ) - { - ItemHandlerUtil.setStackInSlot( this.sourceHandler.get(), slot, stack ); - } - - @Override - public boolean isItemValid( int slot, ItemStack stack ) - { - return this.sourceHandler.get().isItemValid( slot, stack ); - } + @Override + public boolean isItemValid(int slot, ItemStack stack) { + return this.sourceHandler.get().isItemValid(slot, stack); + } } diff --git a/src/main/java/appeng/util/inv/filter/AEItemDefinitionFilter.java b/src/main/java/appeng/util/inv/filter/AEItemDefinitionFilter.java index 0606d7253..e29d0daf7 100644 --- a/src/main/java/appeng/util/inv/filter/AEItemDefinitionFilter.java +++ b/src/main/java/appeng/util/inv/filter/AEItemDefinitionFilter.java @@ -18,32 +18,26 @@ package appeng.util.inv.filter; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import appeng.api.definitions.IItemDefinition; +public class AEItemDefinitionFilter implements IAEItemFilter { + private final IItemDefinition definition; -public class AEItemDefinitionFilter implements IAEItemFilter -{ - private final IItemDefinition definition; + public AEItemDefinitionFilter(IItemDefinition definition) { + this.definition = definition; + } - public AEItemDefinitionFilter( IItemDefinition definition ) - { - this.definition = definition; - } + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return this.definition.isSameAs( stack ); - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return this.definition.isSameAs(stack); + } } diff --git a/src/main/java/appeng/util/inv/filter/AEItemFilters.java b/src/main/java/appeng/util/inv/filter/AEItemFilters.java index 9a713d140..cc104208f 100644 --- a/src/main/java/appeng/util/inv/filter/AEItemFilters.java +++ b/src/main/java/appeng/util/inv/filter/AEItemFilters.java @@ -18,47 +18,37 @@ package appeng.util.inv.filter; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public class AEItemFilters { + public static final IAEItemFilter INSERT_ONLY = new InsertOnlyFilter(); + public static final IAEItemFilter EXTRACT_ONLY = new ExtractOnlyFilter(); -public class AEItemFilters -{ - public static final IAEItemFilter INSERT_ONLY = new InsertOnlyFilter(); - public static final IAEItemFilter EXTRACT_ONLY = new ExtractOnlyFilter(); + private AEItemFilters() { + } - private AEItemFilters() - { - } + private static class InsertOnlyFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return false; + } - private static class InsertOnlyFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return false; - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return true; + } + } - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return true; - } - } + private static class ExtractOnlyFilter implements IAEItemFilter { + @Override + public boolean allowExtract(IItemHandler inv, int slot, int amount) { + return true; + } - private static class ExtractOnlyFilter implements IAEItemFilter - { - @Override - public boolean allowExtract( IItemHandler inv, int slot, int amount ) - { - return true; - } - - @Override - public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ) - { - return false; - } - } + @Override + public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { + return false; + } + } } diff --git a/src/main/java/appeng/util/inv/filter/IAEItemFilter.java b/src/main/java/appeng/util/inv/filter/IAEItemFilter.java index 6e9b671c2..1017c5085 100644 --- a/src/main/java/appeng/util/inv/filter/IAEItemFilter.java +++ b/src/main/java/appeng/util/inv/filter/IAEItemFilter.java @@ -18,14 +18,11 @@ package appeng.util.inv.filter; - import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public interface IAEItemFilter { + boolean allowExtract(IItemHandler inv, int slot, int amount); -public interface IAEItemFilter -{ - boolean allowExtract( IItemHandler inv, int slot, int amount ); - - boolean allowInsert( IItemHandler inv, int slot, ItemStack stack ); + boolean allowInsert(IItemHandler inv, int slot, ItemStack stack); } diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index 9ac69083d..1e2cfcbb5 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.List; import java.util.Objects; @@ -41,297 +40,248 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.util.Platform; +public final class AEItemStack extends AEStack implements IAEItemStack { + private static final String NBT_STACKSIZE = "cnt"; + private static final String NBT_REQUESTABLE = "req"; + private static final String NBT_CRAFTABLE = "craft"; + private static final String NBT_ITEMSTACK = "is"; -public final class AEItemStack extends AEStack implements IAEItemStack -{ - private static final String NBT_STACKSIZE = "cnt"; - private static final String NBT_REQUESTABLE = "req"; - private static final String NBT_CRAFTABLE = "craft"; - private static final String NBT_ITEMSTACK = "is"; + private final AESharedItemStack sharedStack; - private final AESharedItemStack sharedStack; + @OnlyIn(Dist.CLIENT) + private ITextComponent displayName; + @OnlyIn(Dist.CLIENT) + private List tooltip; - @OnlyIn( Dist.CLIENT ) - private ITextComponent displayName; - @OnlyIn( Dist.CLIENT ) - private List tooltip; + private AEItemStack(final AEItemStack is) { + this.setStackSize(is.getStackSize()); + this.setCraftable(is.isCraftable()); + this.setCountRequestable(is.getCountRequestable()); + this.sharedStack = is.sharedStack; + } - private AEItemStack( final AEItemStack is ) - { - this.setStackSize( is.getStackSize() ); - this.setCraftable( is.isCraftable() ); - this.setCountRequestable( is.getCountRequestable() ); - this.sharedStack = is.sharedStack; - } + private AEItemStack(final AESharedItemStack is, long size) { + this.sharedStack = is; + this.setStackSize(size); + this.setCraftable(false); + this.setCountRequestable(0); + } - private AEItemStack( final AESharedItemStack is, long size ) - { - this.sharedStack = is; - this.setStackSize( size ); - this.setCraftable( false ); - this.setCountRequestable( 0 ); - } + @Nullable + public static AEItemStack fromItemStack(@Nonnull final ItemStack stack) { + if (stack.isEmpty()) { + return null; + } - @Nullable - public static AEItemStack fromItemStack( @Nonnull final ItemStack stack ) - { - if( stack.isEmpty() ) - { - return null; - } + return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount()); + } - return new AEItemStack( AEItemStackRegistry.getRegisteredStack( stack ), stack.getCount() ); - } + public static IAEItemStack fromNBT(final CompoundNBT i) { + if (i == null) { + return null; + } - public static IAEItemStack fromNBT( final CompoundNBT i ) - { - if( i == null ) - { - return null; - } + final ItemStack itemstack = ItemStack.read(i.getCompound(NBT_ITEMSTACK)); + if (itemstack.isEmpty()) { + return null; + } - final ItemStack itemstack = ItemStack.read( i.getCompound( NBT_ITEMSTACK ) ); - if( itemstack.isEmpty() ) - { - return null; - } + final AEItemStack item = AEItemStack.fromItemStack(itemstack); + item.setStackSize(i.getLong(NBT_STACKSIZE)); + item.setCountRequestable(i.getLong(NBT_REQUESTABLE)); + item.setCraftable(i.getBoolean(NBT_CRAFTABLE)); + return item; + } - final AEItemStack item = AEItemStack.fromItemStack( itemstack ); - item.setStackSize( i.getLong( NBT_STACKSIZE ) ); - item.setCountRequestable( i.getLong( NBT_REQUESTABLE ) ); - item.setCraftable( i.getBoolean( NBT_CRAFTABLE ) ); - return item; - } + @Override + public void writeToNBT(final CompoundNBT i) { + final CompoundNBT itemStack = new CompoundNBT(); + this.getDefinition().write(itemStack); - @Override - public void writeToNBT( final CompoundNBT i ) - { - final CompoundNBT itemStack = new CompoundNBT(); - this.getDefinition().write( itemStack ); + i.put(NBT_ITEMSTACK, itemStack); + i.putLong(NBT_STACKSIZE, this.getStackSize()); + i.putLong(NBT_REQUESTABLE, this.getCountRequestable()); + i.putBoolean(NBT_CRAFTABLE, this.isCraftable()); + } - i.put( NBT_ITEMSTACK, itemStack ); - i.putLong( NBT_STACKSIZE, this.getStackSize() ); - i.putLong( NBT_REQUESTABLE, this.getCountRequestable() ); - i.putBoolean( NBT_CRAFTABLE, this.isCraftable() ); - } + public static AEItemStack fromPacket(final PacketBuffer buffer) { + final boolean isCraftable = buffer.readBoolean(); + final long stackSize = buffer.readVarLong(); + final long countRequestable = buffer.readVarLong(); + final ItemStack itemstack = buffer.readItemStack(); - public static AEItemStack fromPacket( final PacketBuffer buffer ) - { - final boolean isCraftable = buffer.readBoolean(); - final long stackSize = buffer.readVarLong(); - final long countRequestable = buffer.readVarLong(); - final ItemStack itemstack = buffer.readItemStack(); + if (itemstack.isEmpty()) { + return null; + } - if( itemstack.isEmpty() ) - { - return null; - } + final AEItemStack item = new AEItemStack(AEItemStackRegistry.getRegisteredStack(itemstack), stackSize); + item.setCountRequestable(countRequestable); + item.setCraftable(isCraftable); + return item; + } - final AEItemStack item = new AEItemStack( AEItemStackRegistry.getRegisteredStack( itemstack ), stackSize ); - item.setCountRequestable( countRequestable ); - item.setCraftable( isCraftable ); - return item; - } + @Override + public void writeToPacket(final PacketBuffer buffer) { + buffer.writeBoolean(this.isCraftable()); + buffer.writeVarLong(this.getStackSize()); + buffer.writeVarLong(this.getCountRequestable()); + buffer.writeItemStack(getDefinition()); + } - @Override - public void writeToPacket( final PacketBuffer buffer ) - { - buffer.writeBoolean( this.isCraftable() ); - buffer.writeVarLong( this.getStackSize() ); - buffer.writeVarLong( this.getCountRequestable() ); - buffer.writeItemStack( getDefinition() ); - } + @Override + public void add(final IAEItemStack option) { + if (option == null) { + return; + } - @Override - public void add( final IAEItemStack option ) - { - if( option == null ) - { - return; - } + this.incStackSize(option.getStackSize()); + this.setCountRequestable(this.getCountRequestable() + option.getCountRequestable()); + this.setCraftable(this.isCraftable() || option.isCraftable()); + } - this.incStackSize( option.getStackSize() ); - this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() ); - this.setCraftable( this.isCraftable() || option.isCraftable() ); - } + @Override + public boolean fuzzyComparison(final IAEItemStack other, final FuzzyMode mode) { + final ItemStack itemStack = this.getDefinition(); + final ItemStack otherStack = other.getDefinition(); - @Override - public boolean fuzzyComparison( final IAEItemStack other, final FuzzyMode mode ) - { - final ItemStack itemStack = this.getDefinition(); - final ItemStack otherStack = other.getDefinition(); + return this.fuzzyItemStackComparison(itemStack, otherStack, mode); + } - return this.fuzzyItemStackComparison( itemStack, otherStack, mode ); - } + @Override + public IAEItemStack copy() { + return new AEItemStack(this); + } - @Override - public IAEItemStack copy() - { - return new AEItemStack( this ); - } + @Override + public boolean isItem() { + return true; + } - @Override - public boolean isItem() - { - return true; - } + @Override + public boolean isFluid() { + return false; + } - @Override - public boolean isFluid() - { - return false; - } + @Override + public IStorageChannel getChannel() { + return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); + } - @Override - public IStorageChannel getChannel() - { - return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); - } + @Override + public ItemStack createItemStack() { + return ItemHandlerHelper.copyStackWithSize(this.getDefinition(), + (int) Math.min(Integer.MAX_VALUE, this.getStackSize())); + } - @Override - public ItemStack createItemStack() - { - return ItemHandlerHelper.copyStackWithSize( this.getDefinition(), (int) Math.min( Integer.MAX_VALUE, this.getStackSize() ) ); - } + @Override + public Item getItem() { + return this.getDefinition().getItem(); + } - @Override - public Item getItem() - { - return this.getDefinition().getItem(); - } + @Override + public int getItemDamage() { + return this.sharedStack.getItemDamage(); + } - @Override - public int getItemDamage() - { - return this.sharedStack.getItemDamage(); - } + @Override + public boolean isSameType(final IAEItemStack otherStack) { + if (otherStack == null) { + return false; + } - @Override - public boolean isSameType( final IAEItemStack otherStack ) - { - if( otherStack == null ) - { - return false; - } + return Objects.equals(this.sharedStack, ((AEItemStack) otherStack).sharedStack); + } - return Objects.equals( this.sharedStack, ( (AEItemStack) otherStack ).sharedStack ); - } + @Override + public boolean isSameType(final ItemStack otherStack) { + if (otherStack.isEmpty()) { + return false; + } + int oldSize = otherStack.getCount(); - @Override - public boolean isSameType( final ItemStack otherStack ) - { - if( otherStack.isEmpty() ) - { - return false; - } - int oldSize = otherStack.getCount(); + otherStack.setCount(1); + boolean ret = ItemStack.areItemStacksEqual(this.getDefinition(), otherStack); + otherStack.setCount(oldSize); - otherStack.setCount( 1 ); - boolean ret = ItemStack.areItemStacksEqual( this.getDefinition(), otherStack ); - otherStack.setCount( oldSize ); + return ret; + } - return ret; - } + @Override + public int hashCode() { + return this.sharedStack.hashCode(); + } - @Override - public int hashCode() - { - return this.sharedStack.hashCode(); - } + @Override + public boolean equals(final Object ia) { + if (ia instanceof AEItemStack) { + return this.isSameType((AEItemStack) ia); + } else if (ia instanceof ItemStack) { + return this.isSameType((ItemStack) ia); + } + return false; + } - @Override - public boolean equals( final Object ia ) - { - if( ia instanceof AEItemStack ) - { - return this.isSameType( (AEItemStack) ia ); - } - else if( ia instanceof ItemStack ) - { - return this.isSameType( (ItemStack) ia ); - } - return false; - } + @Override + public String toString() { + return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName(); + } - @Override - public String toString() - { - return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName(); - } + @OnlyIn(Dist.CLIENT) + public List getToolTip() { + if (this.tooltip == null) { + this.tooltip = Platform.getTooltip(this.asItemStackRepresentation()); + } + return this.tooltip; + } - @OnlyIn( Dist.CLIENT ) - public List getToolTip() - { - if( this.tooltip == null ) - { - this.tooltip = Platform.getTooltip( this.asItemStackRepresentation() ); - } - return this.tooltip; - } + @OnlyIn(Dist.CLIENT) + public ITextComponent getDisplayName() { + if (this.displayName == null) { + this.displayName = Platform.getItemDisplayName(this.asItemStackRepresentation()); + } + return this.displayName; + } - @OnlyIn( Dist.CLIENT ) - public ITextComponent getDisplayName() - { - if( this.displayName == null ) - { - this.displayName = Platform.getItemDisplayName( this.asItemStackRepresentation() ); - } - return this.displayName; - } + @OnlyIn(Dist.CLIENT) + public String getModID() { + return this.getDefinition().getItem().getRegistryName().getNamespace(); + } - @OnlyIn( Dist.CLIENT ) - public String getModID() - { - return this.getDefinition().getItem().getRegistryName().getNamespace(); - } + @Override + public boolean hasTagCompound() { + return this.getDefinition().hasTag(); + } - @Override - public boolean hasTagCompound() - { - return this.getDefinition().hasTag(); - } + @Override + public ItemStack asItemStackRepresentation() { + return this.getDefinition().copy(); + } - @Override - public ItemStack asItemStackRepresentation() - { - return this.getDefinition().copy(); - } + @Override + public ItemStack getDefinition() { + return this.sharedStack.getDefinition(); + } - @Override - public ItemStack getDefinition() - { - return this.sharedStack.getDefinition(); - } + AESharedItemStack getSharedStack() { + return this.sharedStack; + } - AESharedItemStack getSharedStack() - { - return this.sharedStack; - } + private boolean fuzzyItemStackComparison(ItemStack a, ItemStack b, FuzzyMode mode) { + if (a.getItem() == b.getItem()) { + if (a.getItem().isDamageable()) { + if (mode == FuzzyMode.IGNORE_ALL) { + return true; + } else if (mode == FuzzyMode.PERCENT_99) { + return (a.getDamage() > 1) == (b.getDamage() > 1); + } else { + final float percentDamageOfA = (float) a.getDamage() / a.getMaxDamage(); + final float percentDamageOfB = (float) b.getDamage() / b.getMaxDamage(); - private boolean fuzzyItemStackComparison( ItemStack a, ItemStack b, FuzzyMode mode ) - { - if( a.getItem() == b.getItem() ) - { - if( a.getItem().isDamageable() ) - { - if( mode == FuzzyMode.IGNORE_ALL ) - { - return true; - } - else if( mode == FuzzyMode.PERCENT_99 ) - { - return ( a.getDamage() > 1 ) == ( b.getDamage() > 1 ); - } - else - { - final float percentDamageOfA = (float) a.getDamage() / a.getMaxDamage(); - final float percentDamageOfB = (float) b.getDamage() / b.getMaxDamage(); + return (percentDamageOfA > mode.breakPoint) == (percentDamageOfB > mode.breakPoint); + } + } + } - return ( percentDamageOfA > mode.breakPoint ) == ( percentDamageOfB > mode.breakPoint ); - } - } - } - - return false; - } + return false; + } } diff --git a/src/main/java/appeng/util/item/AEItemStackRegistry.java b/src/main/java/appeng/util/item/AEItemStackRegistry.java index 2bea02b88..011aaa23e 100644 --- a/src/main/java/appeng/util/item/AEItemStackRegistry.java +++ b/src/main/java/appeng/util/item/AEItemStackRegistry.java @@ -23,7 +23,6 @@ package appeng.util.item; - import java.lang.ref.WeakReference; import java.util.WeakHashMap; @@ -33,54 +32,43 @@ import net.minecraft.item.ItemStack; import appeng.util.Platform; +public final class AEItemStackRegistry { + private static final WeakHashMap> SERVER_REGISTRY = new WeakHashMap<>(); + private static final WeakHashMap> CLIENT_REGISTRY = new WeakHashMap<>(); -public final class AEItemStackRegistry -{ - private static final WeakHashMap> SERVER_REGISTRY = new WeakHashMap<>(); - private static final WeakHashMap> CLIENT_REGISTRY = new WeakHashMap<>(); + private AEItemStackRegistry() { + } - private AEItemStackRegistry() - { - } + private static WeakHashMap> registry() { + if (Platform.isClient()) { + return CLIENT_REGISTRY; + } else { + return SERVER_REGISTRY; + } + } - private static WeakHashMap> registry() - { - if( Platform.isClient() ) - { - return CLIENT_REGISTRY; - } - else - { - return SERVER_REGISTRY; - } - } + static synchronized AESharedItemStack getRegisteredStack(final @Nonnull ItemStack itemStack) { + if (itemStack.isEmpty()) { + throw new IllegalArgumentException("stack cannot be empty"); + } - static synchronized AESharedItemStack getRegisteredStack( final @Nonnull ItemStack itemStack ) - { - if( itemStack.isEmpty() ) - { - throw new IllegalArgumentException( "stack cannot be empty" ); - } + int oldStackSize = itemStack.getCount(); + itemStack.setCount(1); - int oldStackSize = itemStack.getCount(); - itemStack.setCount( 1 ); + AESharedItemStack search = new AESharedItemStack(itemStack); + WeakReference weak = registry().get(search); + AESharedItemStack ret = null; - AESharedItemStack search = new AESharedItemStack( itemStack ); - WeakReference weak = registry().get( search ); - AESharedItemStack ret = null; + if (weak != null) { + ret = weak.get(); + } - if( weak != null ) - { - ret = weak.get(); - } + if (ret == null) { + ret = new AESharedItemStack(itemStack.copy()); + registry().put(ret, new WeakReference<>(ret)); + } + itemStack.setCount(oldStackSize); - if( ret == null ) - { - ret = new AESharedItemStack( itemStack.copy() ); - registry().put( ret, new WeakReference<>( ret ) ); - } - itemStack.setCount( oldStackSize ); - - return ret; - } + return ret; + } } diff --git a/src/main/java/appeng/util/item/AESharedItemStack.java b/src/main/java/appeng/util/item/AESharedItemStack.java index 8dcedef92..9e5f2c8ee 100644 --- a/src/main/java/appeng/util/item/AESharedItemStack.java +++ b/src/main/java/appeng/util/item/AESharedItemStack.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Objects; import com.google.common.base.Preconditions; @@ -29,196 +28,159 @@ import net.minecraft.nbt.CompoundNBT; import appeng.api.config.FuzzyMode; +final class AESharedItemStack implements Comparable { + private final ItemStack itemStack; + private final int itemId; + private final int itemDamage; + private final int hashCode; -final class AESharedItemStack implements Comparable -{ - private final ItemStack itemStack; - private final int itemId; - private final int itemDamage; - private final int hashCode; + public AESharedItemStack(final ItemStack itemStack) { + this.itemStack = itemStack; + this.itemId = Item.getIdFromItem(itemStack.getItem()); + this.itemDamage = itemStack.getDamage(); + this.hashCode = this.makeHashCode(); + } - public AESharedItemStack( final ItemStack itemStack ) - { - this.itemStack = itemStack; - this.itemId = Item.getIdFromItem( itemStack.getItem() ); - this.itemDamage = itemStack.getDamage(); - this.hashCode = this.makeHashCode(); - } + Bounds getBounds(final FuzzyMode fuzzy) { + return new Bounds(this.itemStack, fuzzy); + } - Bounds getBounds( final FuzzyMode fuzzy ) - { - return new Bounds( this.itemStack, fuzzy ); - } + ItemStack getDefinition() { + return this.itemStack; + } - ItemStack getDefinition() - { - return this.itemStack; - } + int getItemDamage() { + return this.itemDamage; + } - int getItemDamage() - { - return this.itemDamage; - } + int getItemID() { + return this.itemId; + } - int getItemID() - { - return this.itemId; - } + @Override + public int hashCode() { + return this.hashCode; + } - @Override - public int hashCode() - { - return this.hashCode; - } + @Override + public boolean equals(final Object obj) { + if (obj instanceof AESharedItemStack) { + final AESharedItemStack other = (AESharedItemStack) obj; - @Override - public boolean equals( final Object obj ) - { - if( obj instanceof AESharedItemStack ) - { - final AESharedItemStack other = (AESharedItemStack) obj; + Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1"); + Preconditions.checkArgument(other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1"); - Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" ); - Preconditions.checkArgument( other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" ); + if (this.itemStack == other.itemStack) { + return true; + } + return ItemStack.areItemStacksEqual(this.itemStack, other.itemStack); + } + return false; + } - if( this.itemStack == other.itemStack ) - { - return true; - } - return ItemStack.areItemStacksEqual( this.itemStack, other.itemStack ); - } - return false; - } + @Override + public int compareTo(final AESharedItemStack b) { + Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1"); + Preconditions.checkArgument(b.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1"); - @Override - public int compareTo( final AESharedItemStack b ) - { - Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" ); - Preconditions.checkArgument( b.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" ); + if (this.itemStack == b.getDefinition()) { + return 0; + } - if( this.itemStack == b.getDefinition() ) - { - return 0; - } + final int id = this.itemId - b.itemId; + if (id != 0) { + return id; + } - final int id = this.itemId - b.itemId; - if( id != 0 ) - { - return id; - } + final int damageValue = this.itemDamage - b.itemDamage; + if (damageValue != 0) { + return damageValue; + } - final int damageValue = this.itemDamage - b.itemDamage; - if( damageValue != 0 ) - { - return damageValue; - } + return 0; + } - return 0; - } + private int makeHashCode() { + return Objects.hash(this.itemId, this.itemDamage, this.itemStack.hasTag() ? this.itemStack.getTag() : 0); + } - private int makeHashCode() - { - return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTag() ? this.itemStack.getTag() : 0 ); - } + /** + * Creates the lower and upper bounds for a specific shared itemstack. + */ + public static final class Bounds { + /** + * Bounds enforced by {@link ItemStack#isEmpty()} + */ + private static final int MIN_DAMAGE_VALUE = 0; + private static final int MAX_DAMAGE_VALUE = Short.MAX_VALUE; - /** - * Creates the lower and upper bounds for a specific shared itemstack. - */ - public static final class Bounds - { - /** - * Bounds enforced by {@link ItemStack#isEmpty()} - */ - private static final int MIN_DAMAGE_VALUE = 0; - private static final int MAX_DAMAGE_VALUE = Short.MAX_VALUE; + private final AESharedItemStack lower; + private final AESharedItemStack upper; - private final AESharedItemStack lower; - private final AESharedItemStack upper; + public Bounds(final ItemStack stack, final FuzzyMode fuzzy) { + Preconditions.checkState(!stack.isEmpty(), "ItemStack#isEmpty() has to be false"); + Preconditions.checkState(stack.getCount() == 1, "ItemStack#getCount() has to be 1"); - public Bounds( final ItemStack stack, final FuzzyMode fuzzy ) - { - Preconditions.checkState( !stack.isEmpty(), "ItemStack#isEmpty() has to be false" ); - Preconditions.checkState( stack.getCount() == 1, "ItemStack#getCount() has to be 1" ); + final CompoundNBT tag = stack.hasTag() ? stack.getTag() : null; - final CompoundNBT tag = stack.hasTag() ? stack.getTag() : null; + this.lower = this.makeLowerBound(stack, tag, fuzzy); + this.upper = this.makeUpperBound(stack, tag, fuzzy); + } - this.lower = this.makeLowerBound( stack, tag, fuzzy ); - this.upper = this.makeUpperBound( stack, tag, fuzzy ); - } + public AESharedItemStack lower() { + return this.lower; + } - public AESharedItemStack lower() - { - return this.lower; - } + public AESharedItemStack upper() { + return this.upper; + } - public AESharedItemStack upper() - { - return this.upper; - } + private AESharedItemStack makeLowerBound(final ItemStack itemStack, final CompoundNBT tag, + final FuzzyMode fuzzy) { + final ItemStack newDef = itemStack.copy(); - private AESharedItemStack makeLowerBound( final ItemStack itemStack, final CompoundNBT tag, final FuzzyMode fuzzy ) - { - final ItemStack newDef = itemStack.copy(); + if (newDef.getItem().isDamageable()) { + if (fuzzy == FuzzyMode.IGNORE_ALL) { + newDef.setDamage(MIN_DAMAGE_VALUE); + } else if (fuzzy == FuzzyMode.PERCENT_99) { + if (itemStack.getDamage() == MIN_DAMAGE_VALUE) { + newDef.setDamage(MIN_DAMAGE_VALUE); + } else { + newDef.setDamage(MIN_DAMAGE_VALUE + 1); + } + } else { + final int breakpoint = fuzzy.calculateBreakPoint(itemStack.getMaxDamage()); + final int damage = breakpoint <= itemStack.getDamage() ? breakpoint : 0; + newDef.setDamage(damage); + } + } - if( newDef.getItem().isDamageable() ) - { - if( fuzzy == FuzzyMode.IGNORE_ALL ) - { - newDef.setDamage( MIN_DAMAGE_VALUE ); - } - else if( fuzzy == FuzzyMode.PERCENT_99 ) - { - if( itemStack.getDamage() == MIN_DAMAGE_VALUE ) - { - newDef.setDamage( MIN_DAMAGE_VALUE ); - } - else - { - newDef.setDamage( MIN_DAMAGE_VALUE + 1 ); - } - } - else - { - final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() ); - final int damage = breakpoint <= itemStack.getDamage() ? breakpoint : 0; - newDef.setDamage( damage ); - } - } + return new AESharedItemStack(newDef); + } - return new AESharedItemStack( newDef ); - } + private AESharedItemStack makeUpperBound(final ItemStack itemStack, final CompoundNBT tag, + final FuzzyMode fuzzy) { + final ItemStack newDef = itemStack.copy(); - private AESharedItemStack makeUpperBound( final ItemStack itemStack, final CompoundNBT tag, final FuzzyMode fuzzy ) - { - final ItemStack newDef = itemStack.copy(); + if (newDef.getItem().isDamageable()) { + if (fuzzy == FuzzyMode.IGNORE_ALL) { + newDef.setDamage(itemStack.getMaxDamage() + 1); + } else if (fuzzy == FuzzyMode.PERCENT_99) { + if (itemStack.getDamage() == MIN_DAMAGE_VALUE) { + newDef.setDamage(MIN_DAMAGE_VALUE); + } else { + newDef.setDamage(itemStack.getMaxDamage() + 1); + } + } else { + final int breakpoint = fuzzy.calculateBreakPoint(itemStack.getMaxDamage()); + final int damage = itemStack.getDamage() < breakpoint ? breakpoint - 1 + : itemStack.getMaxDamage() + 1; + newDef.setDamage(damage); + } + } - if( newDef.getItem().isDamageable() ) - { - if( fuzzy == FuzzyMode.IGNORE_ALL ) - { - newDef.setDamage( itemStack.getMaxDamage() + 1 ); - } - else if( fuzzy == FuzzyMode.PERCENT_99 ) - { - if( itemStack.getDamage() == MIN_DAMAGE_VALUE ) - { - newDef.setDamage( MIN_DAMAGE_VALUE ); - } - else - { - newDef.setDamage( itemStack.getMaxDamage() + 1 ); - } - } - else - { - final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() ); - final int damage = itemStack.getDamage() < breakpoint ? breakpoint - 1 : itemStack.getMaxDamage() + 1; - newDef.setDamage( damage ); - } - } + return new AESharedItemStack(newDef); + } - return new AESharedItemStack( newDef ); - } - - } + } } diff --git a/src/main/java/appeng/util/item/AEStack.java b/src/main/java/appeng/util/item/AEStack.java index 0c05bbe16..f7286e0f7 100644 --- a/src/main/java/appeng/util/item/AEStack.java +++ b/src/main/java/appeng/util/item/AEStack.java @@ -18,102 +18,86 @@ package appeng.util.item; - import appeng.api.storage.data.IAEStack; +public abstract class AEStack> implements IAEStack { -public abstract class AEStack> implements IAEStack -{ + private boolean isCraftable; + private long stackSize; + private long countRequestable; - private boolean isCraftable; - private long stackSize; - private long countRequestable; + @Override + public long getStackSize() { + return this.stackSize; + } - @Override - public long getStackSize() - { - return this.stackSize; - } + @Override + public T setStackSize(final long ss) { + this.stackSize = ss; + return (T) this; + } - @Override - public T setStackSize( final long ss ) - { - this.stackSize = ss; - return (T) this; - } + @Override + public long getCountRequestable() { + return this.countRequestable; + } - @Override - public long getCountRequestable() - { - return this.countRequestable; - } + @Override + public T setCountRequestable(final long countRequestable) { + this.countRequestable = countRequestable; + return (T) this; + } - @Override - public T setCountRequestable( final long countRequestable ) - { - this.countRequestable = countRequestable; - return (T) this; - } + @Override + public boolean isCraftable() { + return this.isCraftable; + } - @Override - public boolean isCraftable() - { - return this.isCraftable; - } + @Override + public T setCraftable(final boolean isCraftable) { + this.isCraftable = isCraftable; + return (T) this; + } - @Override - public T setCraftable( final boolean isCraftable ) - { - this.isCraftable = isCraftable; - return (T) this; - } + @Override + public T reset() { + this.stackSize = 0; + this.setCountRequestable(0); + this.setCraftable(false); + return (T) this; + } - @Override - public T reset() - { - this.stackSize = 0; - this.setCountRequestable( 0 ); - this.setCraftable( false ); - return (T) this; - } + @Override + public T empty() { + final T dup = this.copy(); + dup.reset(); + return dup; + } - @Override - public T empty() - { - final T dup = this.copy(); - dup.reset(); - return dup; - } + @Override + public boolean isMeaningful() { + return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable; + } - @Override - public boolean isMeaningful() - { - return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable; - } + @Override + public void incStackSize(final long i) { + this.stackSize += i; + } - @Override - public void incStackSize( final long i ) - { - this.stackSize += i; - } + @Override + public void decStackSize(final long i) { + this.stackSize -= i; + } - @Override - public void decStackSize( final long i ) - { - this.stackSize -= i; - } + @Override + public void incCountRequestable(final long i) { + this.countRequestable += i; + } - @Override - public void incCountRequestable( final long i ) - { - this.countRequestable += i; - } + @Override + public void decCountRequestable(final long i) { + this.countRequestable -= i; + } - @Override - public void decCountRequestable( final long i ) - { - this.countRequestable -= i; - } - - protected abstract boolean hasTagCompound(); + protected abstract boolean hasTagCompound(); } diff --git a/src/main/java/appeng/util/item/AbstractItemList.java b/src/main/java/appeng/util/item/AbstractItemList.java index f3726a6d2..110072618 100644 --- a/src/main/java/appeng/util/item/AbstractItemList.java +++ b/src/main/java/appeng/util/item/AbstractItemList.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -28,173 +27,145 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +abstract class AbstractItemList implements IItemList { -abstract class AbstractItemList implements IItemList -{ + @Override + public void add(final IAEItemStack option) { + if (option == null) { + return; + } - @Override - public void add( final IAEItemStack option ) - { - if( option == null ) - { - return; - } + final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack()); - final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() ); + if (st != null) { + st.add(option); + return; + } - if( st != null ) - { - st.add( option ); - return; - } + final IAEItemStack opt = option.copy(); - final IAEItemStack opt = option.copy(); + this.putItemRecord(opt); + } - this.putItemRecord( opt ); - } + @Override + public IAEItemStack findPrecise(final IAEItemStack itemStack) { + if (itemStack == null) { + return null; + } - @Override - public IAEItemStack findPrecise( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return null; - } + return this.getRecords().get(((AEItemStack) itemStack).getSharedStack()); + } - return this.getRecords().get( ( (AEItemStack) itemStack ).getSharedStack() ); - } + @Override + public Collection findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) { + if (filter == null) { + return Collections.emptyList(); + } - @Override - public Collection findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy ) - { - if( filter == null ) - { - return Collections.emptyList(); - } + return this.getRecords().values(); + } - return this.getRecords().values(); - } + @Override + public boolean isEmpty() { + return !this.iterator().hasNext(); + } - @Override - public boolean isEmpty() - { - return !this.iterator().hasNext(); - } + @Override + public void addStorage(final IAEItemStack option) { + if (option == null) { + return; + } - @Override - public void addStorage( final IAEItemStack option ) - { - if( option == null ) - { - return; - } + final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack()); - final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() ); + if (st != null) { + st.incStackSize(option.getStackSize()); + return; + } - if( st != null ) - { - st.incStackSize( option.getStackSize() ); - return; - } + final IAEItemStack opt = option.copy(); - final IAEItemStack opt = option.copy(); + this.putItemRecord(opt); + } - this.putItemRecord( opt ); - } + @Override + public void addCrafting(final IAEItemStack option) { + if (option == null) { + return; + } - @Override - public void addCrafting( final IAEItemStack option ) - { - if( option == null ) - { - return; - } + final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack()); - final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() ); + if (st != null) { + st.setCraftable(true); + return; + } - if( st != null ) - { - st.setCraftable( true ); - return; - } + final IAEItemStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(true); - final IAEItemStack opt = option.copy(); - opt.setStackSize( 0 ); - opt.setCraftable( true ); + this.putItemRecord(opt); + } - this.putItemRecord( opt ); - } + @Override + public void addRequestable(final IAEItemStack option) { + if (option == null) { + return; + } - @Override - public void addRequestable( final IAEItemStack option ) - { - if( option == null ) - { - return; - } + final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack()); - final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() ); + if (st != null) { + st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable()); + return; + } - if( st != null ) - { - st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() ); - return; - } + final IAEItemStack opt = option.copy(); + opt.setStackSize(0); + opt.setCraftable(false); + opt.setCountRequestable(option.getCountRequestable()); - final IAEItemStack opt = option.copy(); - opt.setStackSize( 0 ); - opt.setCraftable( false ); - opt.setCountRequestable( option.getCountRequestable() ); + this.putItemRecord(opt); + } - this.putItemRecord( opt ); - } + @Override + public IAEItemStack getFirstItem() { + for (final IAEItemStack stackType : this) { + return stackType; + } - @Override - public IAEItemStack getFirstItem() - { - for( final IAEItemStack stackType : this ) - { - return stackType; - } + return null; + } - return null; - } + @Override + public int size() { + int size = 0; + for (IAEItemStack entry : getRecords().values()) { + if (entry.isMeaningful()) { + size++; + } + } - @Override - public int size() - { - int size = 0; - for( IAEItemStack entry : getRecords().values() ) - { - if( entry.isMeaningful() ) - { - size++; - } - } + return size; + } - return size; - } + @Override + public Iterator iterator() { + return new MeaningfulItemIterator<>(this.getRecords().values()); + } - @Override - public Iterator iterator() - { - return new MeaningfulItemIterator<>( this.getRecords().values() ); - } + @Override + public void resetStatus() { + for (final IAEItemStack i : this) { + i.reset(); + } + } - @Override - public void resetStatus() - { - for( final IAEItemStack i : this ) - { - i.reset(); - } - } + abstract Map getRecords(); - abstract Map getRecords(); - - private IAEItemStack putItemRecord( final IAEItemStack itemStack ) - { - return this.getRecords().put( ( (AEItemStack) itemStack ).getSharedStack(), itemStack ); - } + private IAEItemStack putItemRecord(final IAEItemStack itemStack) { + return this.getRecords().put(((AEItemStack) itemStack).getSharedStack(), itemStack); + } } diff --git a/src/main/java/appeng/util/item/FuzzyItemList.java b/src/main/java/appeng/util/item/FuzzyItemList.java index 947631773..ca9e6dc4e 100644 --- a/src/main/java/appeng/util/item/FuzzyItemList.java +++ b/src/main/java/appeng/util/item/FuzzyItemList.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -29,34 +28,28 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; import appeng.util.item.AESharedItemStack.Bounds; +class FuzzyItemList extends AbstractItemList { + private final NavigableMap records = new TreeMap<>(); -class FuzzyItemList extends AbstractItemList -{ - private final NavigableMap records = new TreeMap<>(); + @Override + public Collection findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) { + if (filter == null) { + return Collections.emptyList(); + } - @Override - public Collection findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy ) - { - if( filter == null ) - { - return Collections.emptyList(); - } + return this.findFuzzyDamage(filter, fuzzy); + } - return this.findFuzzyDamage( filter, fuzzy ); - } + @Override + Map getRecords() { + return this.records; + } - @Override - Map getRecords() - { - return this.records; - } + private Collection findFuzzyDamage(final IAEItemStack filter, final FuzzyMode fuzzy) { + final AEItemStack itemStack = (AEItemStack) filter; + final Bounds bounds = itemStack.getSharedStack().getBounds(fuzzy); - private Collection findFuzzyDamage( final IAEItemStack filter, final FuzzyMode fuzzy ) - { - final AEItemStack itemStack = (AEItemStack) filter; - final Bounds bounds = itemStack.getSharedStack().getBounds( fuzzy ); - - return this.records.subMap( bounds.lower(), true, bounds.upper(), true ).descendingMap().values(); - } + return this.records.subMap(bounds.lower(), true, bounds.upper(), true).descendingMap().values(); + } } diff --git a/src/main/java/appeng/util/item/ItemList.java b/src/main/java/appeng/util/item/ItemList.java index 0e0892e01..d5c4f8aa7 100644 --- a/src/main/java/appeng/util/item/ItemList.java +++ b/src/main/java/appeng/util/item/ItemList.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; @@ -32,194 +31,155 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +public final class ItemList implements IItemList { -public final class ItemList implements IItemList -{ + private final static IItemList NULL_ITEMLIST = new NullItemList(); - private final static IItemList NULL_ITEMLIST = new NullItemList(); + private final Map> records = new IdentityHashMap<>(); - private final Map> records = new IdentityHashMap<>(); + @Override + public IAEItemStack findPrecise(final IAEItemStack itemStack) { + if (itemStack == null) { + return null; + } - @Override - public IAEItemStack findPrecise( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return null; - } + return this.getRecord(itemStack.getItem()).findPrecise(itemStack); + } - return this.getRecord( itemStack.getItem() ).findPrecise( itemStack ); - } + @Override + public Collection findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) { + if (filter == null) { + return Collections.emptyList(); + } - @Override - public Collection findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy ) - { - if( filter == null ) - { - return Collections.emptyList(); - } + return this.getRecord(filter.getItem()).findFuzzy(filter, fuzzy); + } - return this.getRecord( filter.getItem() ).findFuzzy( filter, fuzzy ); - } + @Override + public boolean isEmpty() { + return !this.iterator().hasNext(); + } - @Override - public boolean isEmpty() - { - return !this.iterator().hasNext(); - } + @Override + public void add(final IAEItemStack itemStack) { + if (itemStack == null) { + return; + } - @Override - public void add( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return; - } + this.getOrCreateRecord(itemStack.getItem()).add(itemStack); + } - this.getOrCreateRecord( itemStack.getItem() ).add( itemStack ); - } + @Override + public void addStorage(final IAEItemStack itemStack) { + if (itemStack == null) { + return; + } - @Override - public void addStorage( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return; - } + this.getOrCreateRecord(itemStack.getItem()).addStorage(itemStack); + } - this.getOrCreateRecord( itemStack.getItem() ).addStorage( itemStack ); - } + @Override + public void addCrafting(final IAEItemStack itemStack) { + if (itemStack == null) { + return; + } - @Override - public void addCrafting( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return; - } + this.getOrCreateRecord(itemStack.getItem()).addCrafting(itemStack); + } - this.getOrCreateRecord( itemStack.getItem() ).addCrafting( itemStack ); - } + @Override + public void addRequestable(final IAEItemStack itemStack) { + if (itemStack == null) { + return; + } - @Override - public void addRequestable( final IAEItemStack itemStack ) - { - if( itemStack == null ) - { - return; - } + this.getOrCreateRecord(itemStack.getItem()).addRequestable(itemStack); + } - this.getOrCreateRecord( itemStack.getItem() ).addRequestable( itemStack ); - } + @Override + public IAEItemStack getFirstItem() { + for (final IAEItemStack stackType : this) { + return stackType; + } - @Override - public IAEItemStack getFirstItem() - { - for( final IAEItemStack stackType : this ) - { - return stackType; - } + return null; + } - return null; - } + @Override + public int size() { + int size = 0; + for (IItemList entry : records.values()) { + size += entry.size(); + } - @Override - public int size() - { - int size = 0; - for( IItemList entry : records.values() ) - { - size += entry.size(); - } + return size; + } - return size; - } + @Override + public Iterator iterator() { + return new ChainedIterator(this.records.values().iterator()); + } - @Override - public Iterator iterator() - { - return new ChainedIterator( this.records.values().iterator() ); - } + @Override + public void resetStatus() { + for (final IAEItemStack i : this) { + i.reset(); + } + } - @Override - public void resetStatus() - { - for( final IAEItemStack i : this ) - { - i.reset(); - } - } + private IItemList getRecord(Item item) { + return this.records.getOrDefault(item, NULL_ITEMLIST); + } - private IItemList getRecord( Item item ) - { - return this.records.getOrDefault( item, NULL_ITEMLIST ); - } + private IItemList getOrCreateRecord(Item item) { + return this.records.computeIfAbsent(item, this::makeRecordMap); + } - private IItemList getOrCreateRecord( Item item ) - { - return this.records.computeIfAbsent( item, this::makeRecordMap ); - } + private IItemList makeRecordMap(Item item) { + if (item.isDamageable()) { + return new FuzzyItemList(); + } else { + return new StrictItemList(); + } + } - private IItemList makeRecordMap( Item item ) - { - if( item.isDamageable() ) - { - return new FuzzyItemList(); - } - else - { - return new StrictItemList(); - } - } + private class ChainedIterator implements Iterator { - private class ChainedIterator implements Iterator - { + private final Iterator> parent; + private Iterator next; - private final Iterator> parent; - private Iterator next; + public ChainedIterator(Iterator> iterator) { + this.parent = iterator; + if (this.parent.hasNext()) { + this.next = this.parent.next().iterator(); + } + } - public ChainedIterator( Iterator> iterator ) - { - this.parent = iterator; - if( this.parent.hasNext() ) - { - this.next = this.parent.next().iterator(); - } - } + @Override + public boolean hasNext() { + while (this.next != null) { + if (this.next.hasNext()) { + return true; + } - @Override - public boolean hasNext() - { - while( this.next != null ) - { - if( this.next.hasNext() ) - { - return true; - } + if (this.parent.hasNext()) { + this.next = this.parent.next().iterator(); + } else { + this.next = null; + } + } - if( this.parent.hasNext() ) - { - this.next = this.parent.next().iterator(); - } - else - { - this.next = null; - } - } + return false; + } - return false; - } + @Override + public IAEItemStack next() { + if (this.next == null) { + throw new NoSuchElementException(); + } - @Override - public IAEItemStack next() - { - if( this.next == null ) - { - throw new NoSuchElementException(); - } + return this.next.next(); + } - return this.next.next(); - } - - } + } } diff --git a/src/main/java/appeng/util/item/ItemModList.java b/src/main/java/appeng/util/item/ItemModList.java index 60268f679..96d985e02 100644 --- a/src/main/java/appeng/util/item/ItemModList.java +++ b/src/main/java/appeng/util/item/ItemModList.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Collection; import appeng.api.AEApi; @@ -27,61 +26,48 @@ import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemContainer; +public class ItemModList implements IItemContainer { -public class ItemModList implements IItemContainer -{ + private final IItemContainer backingStore; + private final IItemContainer overrides = AEApi.instance().storage() + .getStorageChannel(IItemStorageChannel.class).createList(); - private final IItemContainer backingStore; - private final IItemContainer overrides = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); + public ItemModList(final IItemContainer backend) { + this.backingStore = backend; + } - public ItemModList( final IItemContainer backend ) - { - this.backingStore = backend; - } + @Override + public void add(final IAEItemStack option) { + IAEItemStack over = this.overrides.findPrecise(option); + if (over == null) { + over = this.backingStore.findPrecise(option); + if (over == null) { + this.overrides.add(option); + } else { + option.add(over); + this.overrides.add(option); + } + } else { + this.overrides.add(option); + } + } - @Override - public void add( final IAEItemStack option ) - { - IAEItemStack over = this.overrides.findPrecise( option ); - if( over == null ) - { - over = this.backingStore.findPrecise( option ); - if( over == null ) - { - this.overrides.add( option ); - } - else - { - option.add( over ); - this.overrides.add( option ); - } - } - else - { - this.overrides.add( option ); - } - } + @Override + public IAEItemStack findPrecise(final IAEItemStack i) { + final IAEItemStack over = this.overrides.findPrecise(i); + if (over == null) { + return this.backingStore.findPrecise(i); + } + return over; + } - @Override - public IAEItemStack findPrecise( final IAEItemStack i ) - { - final IAEItemStack over = this.overrides.findPrecise( i ); - if( over == null ) - { - return this.backingStore.findPrecise( i ); - } - return over; - } + @Override + public Collection findFuzzy(final IAEItemStack input, final FuzzyMode fuzzy) { + return this.overrides.findFuzzy(input, fuzzy); + } - @Override - public Collection findFuzzy( final IAEItemStack input, final FuzzyMode fuzzy ) - { - return this.overrides.findFuzzy( input, fuzzy ); - } - - @Override - public boolean isEmpty() - { - return this.overrides.isEmpty() && this.backingStore.isEmpty(); - } + @Override + public boolean isEmpty() { + return this.overrides.isEmpty() && this.backingStore.isEmpty(); + } } diff --git a/src/main/java/appeng/util/item/MeaningfulItemIterator.java b/src/main/java/appeng/util/item/MeaningfulItemIterator.java index e795ef3e8..9738e03e9 100644 --- a/src/main/java/appeng/util/item/MeaningfulItemIterator.java +++ b/src/main/java/appeng/util/item/MeaningfulItemIterator.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -26,61 +25,50 @@ import java.util.NoSuchElementException; import appeng.api.storage.data.IAEItemStack; +public class MeaningfulItemIterator implements Iterator { -public class MeaningfulItemIterator implements Iterator -{ + private final Collection collection; + private final Iterator parent; + private T next; + private final Collection toRemove = new ArrayList<>(); - private final Collection collection; - private final Iterator parent; - private T next; - private final Collection toRemove = new ArrayList<>(); + public MeaningfulItemIterator(final Collection collection) { + this.collection = collection; + this.parent = collection.iterator(); + } - public MeaningfulItemIterator( final Collection collection ) - { - this.collection = collection; - this.parent = collection.iterator(); - } + @Override + public boolean hasNext() { + while (this.parent.hasNext()) { + this.next = this.parent.next(); - @Override - public boolean hasNext() - { - while( this.parent.hasNext() ) - { - this.next = this.parent.next(); + if (this.next.isMeaningful()) { + return true; + } else { + // TODO: Avoid if possible + this.toRemove.add(this.next); + // this.parent.remove(); // self cleaning :3 + } + } - if( this.next.isMeaningful() ) - { - return true; - } - else - { - // TODO: Avoid if possible - this.toRemove.add( this.next ); - // this.parent.remove(); // self cleaning :3 - } - } + // Cleanup afterwards to avoid CMEs + this.toRemove.forEach(entry -> this.collection.remove(entry)); - // Cleanup afterwards to avoid CMEs - this.toRemove.forEach( entry -> this.collection.remove( entry ) ); + this.next = null; + return false; + } - this.next = null; - return false; - } + @Override + public T next() { + if (this.next == null) { + throw new NoSuchElementException(); + } - @Override - public T next() - { - if( this.next == null ) - { - throw new NoSuchElementException(); - } + return this.next; + } - return this.next; - } - - @Override - public void remove() - { - this.parent.remove(); - } + @Override + public void remove() { + this.parent.remove(); + } } diff --git a/src/main/java/appeng/util/item/NullItemList.java b/src/main/java/appeng/util/item/NullItemList.java index 0499f1801..e9bfd2568 100644 --- a/src/main/java/appeng/util/item/NullItemList.java +++ b/src/main/java/appeng/util/item/NullItemList.java @@ -18,7 +18,6 @@ package appeng.util.item; - import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -27,69 +26,56 @@ import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +public class NullItemList implements IItemList { -public class NullItemList implements IItemList -{ + @Override + public void add(IAEItemStack option) { + } - @Override - public void add( IAEItemStack option ) - { - } + @Override + public IAEItemStack findPrecise(IAEItemStack i) { + return null; + } - @Override - public IAEItemStack findPrecise( IAEItemStack i ) - { - return null; - } + @Override + public Collection findFuzzy(IAEItemStack input, FuzzyMode fuzzy) { + return Collections.emptyList(); + } - @Override - public Collection findFuzzy( IAEItemStack input, FuzzyMode fuzzy ) - { - return Collections.emptyList(); - } + @Override + public boolean isEmpty() { + return true; + } - @Override - public boolean isEmpty() - { - return true; - } + @Override + public void addStorage(IAEItemStack option) { + } - @Override - public void addStorage( IAEItemStack option ) - { - } + @Override + public void addCrafting(IAEItemStack option) { + } - @Override - public void addCrafting( IAEItemStack option ) - { - } + @Override + public void addRequestable(IAEItemStack option) { + } - @Override - public void addRequestable( IAEItemStack option ) - { - } + @Override + public IAEItemStack getFirstItem() { + return null; + } - @Override - public IAEItemStack getFirstItem() - { - return null; - } + @Override + public int size() { + return 0; + } - @Override - public int size() - { - return 0; - } + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } - @Override - public Iterator iterator() - { - return Collections.emptyIterator(); - } - - @Override - public void resetStatus() - { - } + @Override + public void resetStatus() { + } } diff --git a/src/main/java/appeng/util/item/StrictItemList.java b/src/main/java/appeng/util/item/StrictItemList.java index 952d7b119..cddec8bcf 100644 --- a/src/main/java/appeng/util/item/StrictItemList.java +++ b/src/main/java/appeng/util/item/StrictItemList.java @@ -18,22 +18,18 @@ package appeng.util.item; - import java.util.IdentityHashMap; import java.util.Map; import appeng.api.storage.data.IAEItemStack; +class StrictItemList extends AbstractItemList { -class StrictItemList extends AbstractItemList -{ + private final Map records = new IdentityHashMap<>(); - private final Map records = new IdentityHashMap<>(); - - @Override - Map getRecords() - { - return this.records; - } + @Override + Map getRecords() { + return this.records; + } } diff --git a/src/main/java/appeng/util/iterators/AEInvIterator.java b/src/main/java/appeng/util/iterators/AEInvIterator.java index 988b27873..dc8a78aa3 100644 --- a/src/main/java/appeng/util/iterators/AEInvIterator.java +++ b/src/main/java/appeng/util/iterators/AEInvIterator.java @@ -18,45 +18,38 @@ package appeng.util.iterators; - import java.util.Iterator; import appeng.api.storage.data.IAEItemStack; import appeng.tile.inventory.AppEngInternalAEInventory; +public final class AEInvIterator implements Iterator { + private final AppEngInternalAEInventory inventory; + private final int size; -public final class AEInvIterator implements Iterator -{ - private final AppEngInternalAEInventory inventory; - private final int size; + private int counter = 0; - private int counter = 0; + public AEInvIterator(final AppEngInternalAEInventory inventory) { + this.inventory = inventory; + this.size = this.inventory.getSlots(); + } - public AEInvIterator( final AppEngInternalAEInventory inventory ) - { - this.inventory = inventory; - this.size = this.inventory.getSlots(); - } + @Override + public boolean hasNext() { + return this.counter < this.size; + } - @Override - public boolean hasNext() - { - return this.counter < this.size; - } + @Override + public IAEItemStack next() { + final IAEItemStack result = this.inventory.getAEStackInSlot(this.counter); - @Override - public IAEItemStack next() - { - final IAEItemStack result = this.inventory.getAEStackInSlot( this.counter ); + this.counter++; - this.counter++; + return result; + } - return result; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/iterators/ChainedIterator.java b/src/main/java/appeng/util/iterators/ChainedIterator.java index 93f3769f7..b2934def3 100644 --- a/src/main/java/appeng/util/iterators/ChainedIterator.java +++ b/src/main/java/appeng/util/iterators/ChainedIterator.java @@ -18,38 +18,31 @@ package appeng.util.iterators; - import java.util.Iterator; +public final class ChainedIterator implements Iterator { + private final T[] list; -public final class ChainedIterator implements Iterator -{ - private final T[] list; + private int offset = 0; - private int offset = 0; + public ChainedIterator(final T... list) { + this.list = list; + } - public ChainedIterator( final T... list ) - { - this.list = list; - } + @Override + public boolean hasNext() { + return this.offset < this.list.length; + } - @Override - public boolean hasNext() - { - return this.offset < this.list.length; - } + @Override + public T next() { + final T result = this.list[this.offset]; + this.offset++; + return result; + } - @Override - public T next() - { - final T result = this.list[this.offset]; - this.offset++; - return result; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/iterators/InvIterator.java b/src/main/java/appeng/util/iterators/InvIterator.java index 942c1c4d5..7ec0b841b 100644 --- a/src/main/java/appeng/util/iterators/InvIterator.java +++ b/src/main/java/appeng/util/iterators/InvIterator.java @@ -18,44 +18,37 @@ package appeng.util.iterators; - import java.util.Iterator; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; +public final class InvIterator implements Iterator { + private final IItemHandler inventory; + private final int size; -public final class InvIterator implements Iterator -{ - private final IItemHandler inventory; - private final int size; + private int counter = 0; - private int counter = 0; + public InvIterator(final IItemHandler inventory) { + this.inventory = inventory; + this.size = this.inventory.getSlots(); + } - public InvIterator( final IItemHandler inventory ) - { - this.inventory = inventory; - this.size = this.inventory.getSlots(); - } + @Override + public boolean hasNext() { + return this.counter < this.size; + } - @Override - public boolean hasNext() - { - return this.counter < this.size; - } + @Override + public ItemStack next() { + final ItemStack result = this.inventory.getStackInSlot(this.counter); + this.counter++; - @Override - public ItemStack next() - { - final ItemStack result = this.inventory.getStackInSlot( this.counter ); - this.counter++; + return result; + } - return result; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/iterators/NullIterator.java b/src/main/java/appeng/util/iterators/NullIterator.java index 3ce3edcc5..61e81c278 100644 --- a/src/main/java/appeng/util/iterators/NullIterator.java +++ b/src/main/java/appeng/util/iterators/NullIterator.java @@ -18,28 +18,22 @@ package appeng.util.iterators; - import java.util.Iterator; +public class NullIterator implements Iterator { -public class NullIterator implements Iterator -{ + @Override + public boolean hasNext() { + return false; + } - @Override - public boolean hasNext() - { - return false; - } + @Override + public T next() { + return null; + } - @Override - public T next() - { - return null; - } + @Override + public void remove() { - @Override - public void remove() - { - - } + } } diff --git a/src/main/java/appeng/util/iterators/ProxyNodeIterator.java b/src/main/java/appeng/util/iterators/ProxyNodeIterator.java index 662c094ab..a9152fc70 100644 --- a/src/main/java/appeng/util/iterators/ProxyNodeIterator.java +++ b/src/main/java/appeng/util/iterators/ProxyNodeIterator.java @@ -18,39 +18,32 @@ package appeng.util.iterators; - import java.util.Iterator; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.util.AEPartLocation; +public final class ProxyNodeIterator implements Iterator { + private final Iterator hosts; -public final class ProxyNodeIterator implements Iterator -{ - private final Iterator hosts; + public ProxyNodeIterator(final Iterator hosts) { + this.hosts = hosts; + } - public ProxyNodeIterator( final Iterator hosts ) - { - this.hosts = hosts; - } + @Override + public boolean hasNext() { + return this.hosts.hasNext(); + } - @Override - public boolean hasNext() - { - return this.hosts.hasNext(); - } + @Override + public IGridNode next() { + final IGridHost host = this.hosts.next(); + return host.getGridNode(AEPartLocation.INTERNAL); + } - @Override - public IGridNode next() - { - final IGridHost host = this.hosts.next(); - return host.getGridNode( AEPartLocation.INTERNAL ); - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/iterators/StackToSlotIterator.java b/src/main/java/appeng/util/iterators/StackToSlotIterator.java index aae4c544c..6ccb51ede 100644 --- a/src/main/java/appeng/util/iterators/StackToSlotIterator.java +++ b/src/main/java/appeng/util/iterators/StackToSlotIterator.java @@ -18,44 +18,37 @@ package appeng.util.iterators; - import java.util.Iterator; import net.minecraft.item.ItemStack; import appeng.util.inv.ItemSlot; +public class StackToSlotIterator implements Iterator { -public class StackToSlotIterator implements Iterator -{ + private final ItemSlot iss = new ItemSlot(); + private final Iterator is; + private int x = 0; - private final ItemSlot iss = new ItemSlot(); - private final Iterator is; - private int x = 0; + public StackToSlotIterator(final Iterator is) { + this.is = is; + } - public StackToSlotIterator( final Iterator is ) - { - this.is = is; - } + @Override + public boolean hasNext() { + return this.is.hasNext(); + } - @Override - public boolean hasNext() - { - return this.is.hasNext(); - } + @Override + public ItemSlot next() { + this.iss.setSlot(this.x); + this.x++; + this.iss.setItemStack(this.is.next()); + return this.iss; + } - @Override - public ItemSlot next() - { - this.iss.setSlot( this.x ); - this.x++; - this.iss.setItemStack( this.is.next() ); - return this.iss; - } - - @Override - public void remove() - { - // uhh no. - } + @Override + public void remove() { + // uhh no. + } } diff --git a/src/main/java/appeng/util/prioritylist/DefaultPriorityList.java b/src/main/java/appeng/util/prioritylist/DefaultPriorityList.java index c8ca99837..b3035a962 100644 --- a/src/main/java/appeng/util/prioritylist/DefaultPriorityList.java +++ b/src/main/java/appeng/util/prioritylist/DefaultPriorityList.java @@ -18,30 +18,24 @@ package appeng.util.prioritylist; - import java.util.Collections; import appeng.api.storage.data.IAEStack; +public class DefaultPriorityList> implements IPartitionList { -public class DefaultPriorityList> implements IPartitionList -{ + @Override + public boolean isListed(final T input) { + return false; + } - @Override - public boolean isListed( final T input ) - { - return false; - } + @Override + public boolean isEmpty() { + return true; + } - @Override - public boolean isEmpty() - { - return true; - } - - @Override - public Iterable getItems() - { - return Collections.emptyList(); - } + @Override + public Iterable getItems() { + return Collections.emptyList(); + } } diff --git a/src/main/java/appeng/util/prioritylist/FuzzyPriorityList.java b/src/main/java/appeng/util/prioritylist/FuzzyPriorityList.java index 39d03e3b4..67c232ccb 100644 --- a/src/main/java/appeng/util/prioritylist/FuzzyPriorityList.java +++ b/src/main/java/appeng/util/prioritylist/FuzzyPriorityList.java @@ -18,42 +18,35 @@ package appeng.util.prioritylist; - import java.util.Collection; import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public class FuzzyPriorityList> implements IPartitionList { -public class FuzzyPriorityList> implements IPartitionList -{ + private final IItemList list; + private final FuzzyMode mode; - private final IItemList list; - private final FuzzyMode mode; + public FuzzyPriorityList(final IItemList in, final FuzzyMode mode) { + this.list = in; + this.mode = mode; + } - public FuzzyPriorityList( final IItemList in, final FuzzyMode mode ) - { - this.list = in; - this.mode = mode; - } + @Override + public boolean isListed(final T input) { + final Collection out = this.list.findFuzzy(input, this.mode); + return out != null && !out.isEmpty(); + } - @Override - public boolean isListed( final T input ) - { - final Collection out = this.list.findFuzzy( input, this.mode ); - return out != null && !out.isEmpty(); - } + @Override + public boolean isEmpty() { + return this.list.isEmpty(); + } - @Override - public boolean isEmpty() - { - return this.list.isEmpty(); - } - - @Override - public Iterable getItems() - { - return this.list; - } + @Override + public Iterable getItems() { + return this.list; + } } diff --git a/src/main/java/appeng/util/prioritylist/IPartitionList.java b/src/main/java/appeng/util/prioritylist/IPartitionList.java index 7daf69df1..3cf3d0ec1 100644 --- a/src/main/java/appeng/util/prioritylist/IPartitionList.java +++ b/src/main/java/appeng/util/prioritylist/IPartitionList.java @@ -18,15 +18,12 @@ package appeng.util.prioritylist; - import appeng.api.storage.data.IAEStack; +public interface IPartitionList> { + boolean isListed(T input); -public interface IPartitionList> -{ - boolean isListed( T input ); + boolean isEmpty(); - boolean isEmpty(); - - Iterable getItems(); + Iterable getItems(); } diff --git a/src/main/java/appeng/util/prioritylist/MergedPriorityList.java b/src/main/java/appeng/util/prioritylist/MergedPriorityList.java index b893ba81e..b43f6a9d4 100644 --- a/src/main/java/appeng/util/prioritylist/MergedPriorityList.java +++ b/src/main/java/appeng/util/prioritylist/MergedPriorityList.java @@ -18,67 +18,52 @@ package appeng.util.prioritylist; - import java.util.ArrayList; import java.util.Collection; import appeng.api.storage.data.IAEStack; +public final class MergedPriorityList> implements IPartitionList { -public final class MergedPriorityList> implements IPartitionList -{ + private final Collection> positive = new ArrayList<>(); + private final Collection> negative = new ArrayList<>(); - private final Collection> positive = new ArrayList<>(); - private final Collection> negative = new ArrayList<>(); + public void addNewList(final IPartitionList list, final boolean isWhitelist) { + if (isWhitelist) { + this.positive.add(list); + } else { + this.negative.add(list); + } + } - public void addNewList( final IPartitionList list, final boolean isWhitelist ) - { - if( isWhitelist ) - { - this.positive.add( list ); - } - else - { - this.negative.add( list ); - } - } + @Override + public boolean isListed(final T input) { + for (final IPartitionList l : this.negative) { + if (l.isListed(input)) { + return false; + } + } - @Override - public boolean isListed( final T input ) - { - for( final IPartitionList l : this.negative ) - { - if( l.isListed( input ) ) - { - return false; - } - } + if (!this.positive.isEmpty()) { + for (final IPartitionList l : this.positive) { + if (l.isListed(input)) { + return true; + } + } - if( !this.positive.isEmpty() ) - { - for( final IPartitionList l : this.positive ) - { - if( l.isListed( input ) ) - { - return true; - } - } + return false; + } - return false; - } + return true; + } - return true; - } + @Override + public boolean isEmpty() { + return this.positive.isEmpty() && this.negative.isEmpty(); + } - @Override - public boolean isEmpty() - { - return this.positive.isEmpty() && this.negative.isEmpty(); - } - - @Override - public Iterable getItems() - { - throw new UnsupportedOperationException(); - } + @Override + public Iterable getItems() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/appeng/util/prioritylist/PrecisePriorityList.java b/src/main/java/appeng/util/prioritylist/PrecisePriorityList.java index 29100901c..862a29763 100644 --- a/src/main/java/appeng/util/prioritylist/PrecisePriorityList.java +++ b/src/main/java/appeng/util/prioritylist/PrecisePriorityList.java @@ -18,36 +18,29 @@ package appeng.util.prioritylist; - import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; +public class PrecisePriorityList> implements IPartitionList { -public class PrecisePriorityList> implements IPartitionList -{ + private final IItemList list; - private final IItemList list; + public PrecisePriorityList(final IItemList in) { + this.list = in; + } - public PrecisePriorityList( final IItemList in ) - { - this.list = in; - } + @Override + public boolean isListed(final T input) { + return this.list.findPrecise(input) != null; + } - @Override - public boolean isListed( final T input ) - { - return this.list.findPrecise( input ) != null; - } + @Override + public boolean isEmpty() { + return this.list.isEmpty(); + } - @Override - public boolean isEmpty() - { - return this.list.isEmpty(); - } - - @Override - public Iterable getItems() - { - return this.list; - } + @Override + public Iterable getItems() { + return this.list; + } } diff --git a/src/main/java/appeng/worldgen/MeteoritePiece.java b/src/main/java/appeng/worldgen/MeteoritePiece.java index 4b18ed8c2..89016abcc 100644 --- a/src/main/java/appeng/worldgen/MeteoritePiece.java +++ b/src/main/java/appeng/worldgen/MeteoritePiece.java @@ -1,5 +1,7 @@ package appeng.worldgen; +import java.util.Random; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MutableBoundingBox; @@ -10,8 +12,6 @@ import net.minecraft.world.gen.feature.structure.ScatteredStructurePiece; import net.minecraft.world.gen.feature.structure.StructurePiece; import net.minecraft.world.gen.feature.template.TemplateManager; -import java.util.Random; - public class MeteoritePiece extends ScatteredStructurePiece { public static IStructurePieceType TYPE = IStructurePieceType.register(MeteoritePiece::new, "AE2M"); @@ -25,7 +25,8 @@ public class MeteoritePiece extends ScatteredStructurePiece { } @Override - public boolean create(IWorld worldIn, ChunkGenerator chunkGeneratorIn, Random randomIn, MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn) { + public boolean create(IWorld worldIn, ChunkGenerator chunkGeneratorIn, Random randomIn, + MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn) { return false; } diff --git a/src/main/java/appeng/worldgen/MeteoritePlacer.java b/src/main/java/appeng/worldgen/MeteoritePlacer.java index b0d1633a8..d113dcf42 100644 --- a/src/main/java/appeng/worldgen/MeteoritePlacer.java +++ b/src/main/java/appeng/worldgen/MeteoritePlacer.java @@ -18,7 +18,6 @@ package appeng.worldgen; - import java.util.*; import net.minecraft.block.Block; @@ -33,13 +32,14 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; 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.api.features.AEFeature; +import appeng.core.AEConfig; import appeng.core.worlddata.WorldData; import appeng.util.InventoryAdaptor; import appeng.util.Platform; @@ -49,375 +49,319 @@ import appeng.worldgen.meteorite.FalloutSand; import appeng.worldgen.meteorite.FalloutSnow; import appeng.worldgen.meteorite.IMeteoriteWorld; import appeng.worldgen.meteorite.MeteoriteBlockPutter; -import net.minecraft.world.IWorld; +public final class MeteoritePlacer { + private static final double PRESSES_SPAWN_CHANCE = 0.7; + private static final int SKYSTONE_SPAWN_LIMIT = 12; + private final IBlockDefinition skyChestDefinition; + private final BlockState skyStone; + private final Item skyStoneItem; + private final MeteoriteBlockPutter putter = new MeteoriteBlockPutter(); + private final IWorld world; + private final Fallout type; + private final BlockPos pos; + private final int x; + private final int y; + private final int z; + private final double meteoriteSize; + private final double realCrater; + private final double squaredMeteoriteSize; + private final double crater; + private final int skyMode; + private final boolean lava; -public final class MeteoritePlacer -{ - private static final double PRESSES_SPAWN_CHANCE = 0.7; - private static final int SKYSTONE_SPAWN_LIMIT = 12; - private final IBlockDefinition skyChestDefinition; - private final BlockState skyStone; - private final Item skyStoneItem; - private final MeteoriteBlockPutter putter = new MeteoriteBlockPutter(); - private final IWorld world; - private final Fallout type; - private final BlockPos pos; - private final int x; - private final int y; - private final int z; - private final double meteoriteSize; - private final double realCrater; - private final double squaredMeteoriteSize; - private final double crater; - private final int skyMode; - private final boolean lava; + public MeteoritePlacer(IWorld world, PlacedMeteoriteSettings settings) { + this.world = world; + this.pos = settings.getPos(); + this.x = settings.getPos().getX(); + this.y = settings.getPos().getY(); + this.z = settings.getPos().getZ(); + this.meteoriteSize = settings.getMeteoriteRadius(); + this.realCrater = settings.getCraterRadius(); + this.skyMode = settings.getSkyMode(); + this.lava = settings.isLava(); + this.squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize; + this.crater = this.realCrater * this.realCrater; - public MeteoritePlacer(IWorld world, PlacedMeteoriteSettings settings) - { - this.world = world; - this.pos = settings.getPos(); - this.x = settings.getPos().getX(); - this.y = settings.getPos().getY(); - this.z = settings.getPos().getZ(); - this.meteoriteSize = settings.getMeteoriteRadius(); - this.realCrater = settings.getCraterRadius(); - this.skyMode = settings.getSkyMode(); - this.lava = settings.isLava(); - this.squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize; - this.crater = this.realCrater * this.realCrater; + final IBlocks blocks = AEApi.instance().definitions().blocks(); - final IBlocks blocks = AEApi.instance().definitions().blocks(); + this.skyChestDefinition = blocks.skyStoneChest(); + this.skyStone = blocks.skyStoneBlock().block().getDefaultState(); + this.skyStoneItem = blocks.skyStoneBlock().item(); - this.skyChestDefinition = blocks.skyStoneChest(); - this.skyStone = blocks.skyStoneBlock().block().getDefaultState(); - this.skyStoneItem = blocks.skyStoneBlock().item(); + this.type = getFalloutFromBaseBlock(world, settings.getPos(), settings.getBlk()); + } - this.type = getFalloutFromBaseBlock(world, settings.getPos(), settings.getBlk()); - } + public void place() { + // creator + if (skyMode > 10) { + this.placeCrater(); + } - public void place() { - // creator - if( skyMode > 10 ) - { - this.placeCrater(); - } + this.placeMeteorite(); - this.placeMeteorite(); + // collapse blocks... + if (skyMode > 3) { + this.decay(); + } + } - // collapse blocks... - if( skyMode > 3 ) - { - this.decay(); - } - } + private int minX(int x) { + return x; + } - private int minX(int x) { - return x; - } - private int minZ(int x) { - return x; - } - private int maxX(int x) { - return x; - } - private int maxZ(int x) { - return x; - } + private int minZ(int x) { + return x; + } - private void placeCrater() - { - final int maxY = 255; - final int minX = minX( x - 200 ); - final int maxX = maxX( x + 200 ); - final int minZ = minZ( z - 200 ); - final int maxZ = maxZ( z + 200 ); + private int maxX(int x) { + return x; + } - BlockPos.Mutable blockPos = new BlockPos.Mutable(); - for( int j = y - 5; j < maxY; j++ ) - { - blockPos.setY(j); - boolean changed = false; + private int maxZ(int x) { + return x; + } - for( int i = minX; i < maxX; i++ ) - { - blockPos.setX(i); - for( int k = minZ; k < maxZ; k++ ) - { - blockPos.setZ(k); - final double dx = i - x; - final double dz = k - z; - final double h = y - this.meteoriteSize + 1 + this.type.adjustCrater(); + private void placeCrater() { + final int maxY = 255; + final int minX = minX(x - 200); + final int maxX = maxX(x + 200); + final int minZ = minZ(z - 200); + final int maxZ = maxZ(z + 200); - final double distanceFrom = dx * dx + dz * dz; + BlockPos.Mutable blockPos = new BlockPos.Mutable(); + for (int j = y - 5; j < maxY; j++) { + blockPos.setY(j); + boolean changed = false; - if( j > h + distanceFrom * 0.02 ) - { - if( lava && j < y && world.getBlockState( blockPos ).getMaterial().isSolid() ) - { - if( j > h + distanceFrom * 0.02 ) - { - this.putter.put(world, blockPos, Blocks.LAVA.getDefaultState() ); - } - } - else - { - changed = this.putter.put(world, blockPos, Platform.AIR_BLOCK.getDefaultState() ) || changed; - } - } - } - } - } + for (int i = minX; i < maxX; i++) { + blockPos.setX(i); + for (int k = minZ; k < maxZ; k++) { + blockPos.setZ(k); + final double dx = i - x; + final double dz = k - z; + final double h = y - this.meteoriteSize + 1 + this.type.adjustCrater(); - for( final Object o : world.getEntitiesWithinAABB( ItemEntity.class, - new AxisAlignedBB( minX( x - 30 ), y - 5, minZ( z - 30 ), maxX( x + 30 ), y + 30, maxZ( z + 30 ) ) ) ) - { - final Entity e = (Entity) o; - e.remove(); - } - } + final double distanceFrom = dx * dx + dz * dz; - private void placeMeteorite() - { - // spawn meteor - this.placeMeteoriteSkyStone(); + if (j > h + distanceFrom * 0.02) { + if (lava && j < y && world.getBlockState(blockPos).getMaterial().isSolid()) { + if (j > h + distanceFrom * 0.02) { + this.putter.put(world, blockPos, Blocks.LAVA.getDefaultState()); + } + } else { + changed = this.putter.put(world, blockPos, Platform.AIR_BLOCK.getDefaultState()) || changed; + } + } + } + } + } - placeChest(); - } + for (final Object o : world.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(minX(x - 30), y - 5, minZ(z - 30), maxX(x + 30), y + 30, maxZ(z + 30)))) { + final Entity e = (Entity) o; + e.remove(); + } + } - private void placeChest() { - if( AEConfig.instance().isFeatureEnabled( AEFeature.SPAWN_PRESSES_IN_METEORITES ) ) - { - this.putter.put(world, pos, this.skyChestDefinition.block().getDefaultState()); + private void placeMeteorite() { + // spawn meteor + this.placeMeteoriteSkyStone(); - final TileEntity te = world.getTileEntity(pos); // FIXME: this is also probably a band-aid for another issue - final InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, Direction.UP ); - if( ap != null && !ap.containsItems() ) // FIXME: band-aid for meteorites being generated multiple times - { - // TODO: loot tables would be better - int primary = Math.max( 1, (int) ( Math.random() * 4 ) ); + placeChest(); + } - if( primary > 3 ) // in case math breaks... - { - primary = 3; - } + private void placeChest() { + if (AEConfig.instance().isFeatureEnabled(AEFeature.SPAWN_PRESSES_IN_METEORITES)) { + this.putter.put(world, pos, this.skyChestDefinition.block().getDefaultState()); - for( int zz = 0; zz < primary; zz++ ) - { - int r; - boolean duplicate; + final TileEntity te = world.getTileEntity(pos); // FIXME: this is also probably a band-aid for another issue + final InventoryAdaptor ap = InventoryAdaptor.getAdaptor(te, Direction.UP); + if (ap != null && !ap.containsItems()) // FIXME: band-aid for meteorites being generated multiple times + { + // TODO: loot tables would be better + int primary = Math.max(1, (int) (Math.random() * 4)); - do - { - duplicate = false; + if (primary > 3) // in case math breaks... + { + primary = 3; + } - if( Math.random() > PRESSES_SPAWN_CHANCE ) - { - r = WorldData.instance().storageData().getNextOrderedValue( "presses", 0 ); - } - else - { - r = (int) ( Math.random() * 1000 ); - } + for (int zz = 0; zz < primary; zz++) { + int r; + boolean duplicate; - ItemStack toAdd = ItemStack.EMPTY; - final IMaterials materials = AEApi.instance().definitions().materials(); + do { + duplicate = false; - switch( r % 4 ) - { - case 0: - toAdd = materials.calcProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - case 1: - toAdd = materials.engProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - case 2: - toAdd = materials.logicProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - case 3: - toAdd = materials.siliconPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); - break; - default: - } + if (Math.random() > PRESSES_SPAWN_CHANCE) { + r = WorldData.instance().storageData().getNextOrderedValue("presses", 0); + } else { + r = (int) (Math.random() * 1000); + } - if( !toAdd.isEmpty() ) - { - if( ap.simulateRemove( 1, toAdd, null ).isEmpty() ) - { - ap.addItems( toAdd ); - } - else - { - duplicate = true; - } - } - } - while( duplicate ); - } + ItemStack toAdd = ItemStack.EMPTY; + final IMaterials materials = AEApi.instance().definitions().materials(); - final 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 ); - ap.addItems(new ItemStack(skyStoneItem, amount)); - break; - case 1: - final List possibles = new ArrayList<>(); - possibles.add( new ItemStack( net.minecraft.item.Items.GOLD_NUGGET ) ); + switch (r % 4) { + case 0: + toAdd = materials.calcProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY); + break; + case 1: + toAdd = materials.engProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY); + break; + case 2: + toAdd = materials.logicProcessorPress().maybeStack(1).orElse(ItemStack.EMPTY); + break; + case 3: + toAdd = materials.siliconPress().maybeStack(1).orElse(ItemStack.EMPTY); + break; + default: + } - ItemStack nugget = Platform.pickRandom( possibles ); - if( nugget != null && !nugget.isEmpty() ) - { - nugget = nugget.copy(); - nugget.setCount( (int) ( Math.random() * 12 ) + 1 ); - ap.addItems( nugget ); - } - break; - } - } - } - } - } + if (!toAdd.isEmpty()) { + if (ap.simulateRemove(1, toAdd, null).isEmpty()) { + ap.addItems(toAdd); + } else { + duplicate = true; + } + } + } while (duplicate); + } - private void placeMeteoriteSkyStone() - { - final int meteorXLength = minX( x - 8 ); - final int meteorXHeight = maxX( x + 8 ); - final int meteorZLength = minZ( z - 8 ); - final int meteorZHeight = maxZ( z + 8 ); + final 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); + ap.addItems(new ItemStack(skyStoneItem, amount)); + break; + case 1: + final List possibles = new ArrayList<>(); + possibles.add(new ItemStack(net.minecraft.item.Items.GOLD_NUGGET)); - BlockPos.Mutable pos = new BlockPos.Mutable(); - for( int i = meteorXLength; i < meteorXHeight; i++ ) - { - pos.setX(i); - for( int j = y - 8; j < y + 8; j++ ) - { - pos.setY(j); - for( int k = meteorZLength; k < meteorZHeight; k++ ) - { - pos.setZ(k); - final double dx = i - x; - final double dy = j - y; - final double dz = k - z; + ItemStack nugget = Platform.pickRandom(possibles); + if (nugget != null && !nugget.isEmpty()) { + nugget = nugget.copy(); + nugget.setCount((int) (Math.random() * 12) + 1); + ap.addItems(nugget); + } + break; + } + } + } + } + } - if( dx * dx * 0.7 + dy * dy * ( j > y ? 1.4 : 0.8 ) + dz * dz * 0.7 < this.squaredMeteoriteSize ) - { - this.putter.put(world, pos, skyStone ); - } - } - } - } - } + private void placeMeteoriteSkyStone() { + final int meteorXLength = minX(x - 8); + final int meteorXHeight = maxX(x + 8); + final int meteorZLength = minZ(z - 8); + final int meteorZHeight = maxZ(z + 8); - private void decay() - { - double randomShit = 0; + BlockPos.Mutable pos = new BlockPos.Mutable(); + for (int i = meteorXLength; i < meteorXHeight; i++) { + pos.setX(i); + for (int j = y - 8; j < y + 8; j++) { + pos.setY(j); + for (int k = meteorZLength; k < meteorZHeight; k++) { + pos.setZ(k); + final double dx = i - x; + final double dy = j - y; + final double dz = k - z; - final int meteorXLength = minX( x - 30 ); - final int meteorXHeight = maxX( x + 30 ); - final int meteorZLength = minZ( z - 30 ); - final int meteorZHeight = maxZ( z + 30 ); + if (dx * dx * 0.7 + dy * dy * (j > y ? 1.4 : 0.8) + dz * dz * 0.7 < this.squaredMeteoriteSize) { + this.putter.put(world, pos, skyStone); + } + } + } + } + } - BlockPos.Mutable blockPos = new BlockPos.Mutable(); - BlockPos.Mutable blockPosUp = new BlockPos.Mutable(); - BlockPos.Mutable blockPosDown = new BlockPos.Mutable(); - for( int i = meteorXLength; i < meteorXHeight; i++ ) - { - blockPos.setX(i); - blockPosUp.setX(i); - blockPosDown.setX(i); - for( int k = meteorZLength; k < meteorZHeight; k++ ) - { - blockPos.setZ(k); - blockPosUp.setZ(k); - blockPosDown.setZ(k); - for( int j = y - 9; j < y + 30; j++ ) - { - blockPos.setY(j); - blockPosUp.setY(j + 1); - blockPosDown.setY(j - 1); - BlockState state = world.getBlockState( blockPos ); - Block blk = world.getBlockState( blockPos ).getBlock(); - if( blk == Blocks.LAVA ) - { - continue; - } + private void decay() { + double randomShit = 0; - // TODO reconsider - if( state.canBeReplacedByLogs( world, new BlockPos( blockPos ) ) ) - { - blk = Platform.AIR_BLOCK; - final Block blk_b = world.getBlockState( blockPosUp ).getBlock(); + final int meteorXLength = minX(x - 30); + final int meteorXHeight = maxX(x + 30); + final int meteorZLength = minZ(z - 30); + final int meteorZHeight = maxZ(z + 30); - if( blk_b != blk ) - { - final BlockState stateUp = world.getBlockState( blockPosUp ); - world.setBlockState( blockPos, stateUp, 3 ); - } - else if( randomShit < 100 * this.crater ) - { - final double dx = i - x; - final double dy = j - y; - final double dz = k - z; - final double dist = dx * dx + dy * dy + dz * dz; + BlockPos.Mutable blockPos = new BlockPos.Mutable(); + BlockPos.Mutable blockPosUp = new BlockPos.Mutable(); + BlockPos.Mutable blockPosDown = new BlockPos.Mutable(); + for (int i = meteorXLength; i < meteorXHeight; i++) { + blockPos.setX(i); + blockPosUp.setX(i); + blockPosDown.setX(i); + for (int k = meteorZLength; k < meteorZHeight; k++) { + blockPos.setZ(k); + blockPosUp.setZ(k); + blockPosDown.setZ(k); + for (int j = y - 9; j < y + 30; j++) { + blockPos.setY(j); + blockPosUp.setY(j + 1); + blockPosDown.setY(j - 1); + BlockState state = world.getBlockState(blockPos); + Block blk = world.getBlockState(blockPos).getBlock(); + if (blk == Blocks.LAVA) { + continue; + } - final BlockState xf = world.getBlockState( blockPosDown ); - if( !xf.canBeReplacedByLogs( world, blockPosDown ) ) - { - final double extraRange = Math.random() * 0.6; - final double height = this.crater * ( extraRange + 0.2 ) - Math.abs( dist - this.crater * 1.7 ); + // TODO reconsider + if (state.canBeReplacedByLogs(world, new BlockPos(blockPos))) { + blk = Platform.AIR_BLOCK; + final Block blk_b = world.getBlockState(blockPosUp).getBlock(); - if( xf.getBlock() != blk && height > 0 && Math.random() > 0.6 ) - { - randomShit++; - this.type.getRandomFall(world, blockPos); - } - } - } - } - else - { - // decay. - if( world.isAirBlock(blockPosUp) ) - { - if( Math.random() > 0.4 ) - { - final double dx = i - x; - final double dy = j - y; - final double dz = k - z; + if (blk_b != blk) { + final BlockState stateUp = world.getBlockState(blockPosUp); + world.setBlockState(blockPos, stateUp, 3); + } else if (randomShit < 100 * this.crater) { + final double dx = i - x; + final double dy = j - y; + final double dz = k - z; + final double dist = dx * dx + dy * dy + dz * dz; - if( dx * dx + dy * dy + dz * dz < this.crater * 1.6 ) - { - this.type.getRandomInset(world, blockPos); - } - } - } - } - } - } - } - } + final BlockState xf = world.getBlockState(blockPosDown); + if (!xf.canBeReplacedByLogs(world, blockPosDown)) { + final double extraRange = Math.random() * 0.6; + final double height = this.crater * (extraRange + 0.2) + - Math.abs(dist - this.crater * 1.7); - private Fallout getFalloutFromBaseBlock(IWorld w, BlockPos pos, ResourceLocation blk) { - if( blk.equals(Blocks.SAND.getRegistryName()) ) - { - return new FalloutSand( w, pos, this.putter, this.skyStone ); - } - else if( blk.equals(Blocks.TERRACOTTA.getRegistryName()) ) - { - return new FalloutCopy( w, pos, this.putter, this.skyStone ); - } - else if( blk.equals(Blocks.ICE.getRegistryName()) || blk.equals(Blocks.SNOW.getRegistryName()) ) - { - return new FalloutSnow( w, pos, this.putter, this.skyStone ); - } - else - { - return new Fallout( this.putter, this.skyStone ); - } - } + if (xf.getBlock() != blk && height > 0 && Math.random() > 0.6) { + randomShit++; + this.type.getRandomFall(world, blockPos); + } + } + } + } else { + // decay. + if (world.isAirBlock(blockPosUp)) { + if (Math.random() > 0.4) { + final double dx = i - x; + final double dy = j - y; + final double dz = k - z; + + if (dx * dx + dy * dy + dz * dz < this.crater * 1.6) { + this.type.getRandomInset(world, blockPos); + } + } + } + } + } + } + } + } + + private Fallout getFalloutFromBaseBlock(IWorld w, BlockPos pos, ResourceLocation blk) { + if (blk.equals(Blocks.SAND.getRegistryName())) { + return new FalloutSand(w, pos, this.putter, this.skyStone); + } else if (blk.equals(Blocks.TERRACOTTA.getRegistryName())) { + return new FalloutCopy(w, pos, this.putter, this.skyStone); + } else if (blk.equals(Blocks.ICE.getRegistryName()) || blk.equals(Blocks.SNOW.getRegistryName())) { + return new FalloutSnow(w, pos, this.putter, this.skyStone); + } else { + return new Fallout(this.putter, this.skyStone); + } + } } diff --git a/src/main/java/appeng/worldgen/MeteoriteSpawnData.java b/src/main/java/appeng/worldgen/MeteoriteSpawnData.java index 15c82cce2..e05e799ed 100644 --- a/src/main/java/appeng/worldgen/MeteoriteSpawnData.java +++ b/src/main/java/appeng/worldgen/MeteoriteSpawnData.java @@ -1,5 +1,10 @@ package appeng.worldgen; +import java.util.ArrayList; +import java.util.Collection; + +import javax.annotation.Nullable; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraft.server.MinecraftServer; @@ -10,10 +15,6 @@ import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.fml.server.ServerLifecycleHooks; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collection; - /** * This is per-world data to track where Meteorites have been spawned. */ @@ -27,7 +28,7 @@ public final class MeteoriteSpawnData { this.data = data; } - public void setGenerated( int chunkX, int chunkZ ) { + public void setGenerated(int chunkX, int chunkZ) { synchronized (data) { // edit. data.generated.putBoolean(chunkX + "," + chunkZ, true); @@ -35,10 +36,9 @@ public final class MeteoriteSpawnData { } } - public boolean hasGenerated( int chunkX, int chunkZ ) { - synchronized( data ) - { - return data.generated.getBoolean( chunkX + "," + chunkZ ); + public boolean hasGenerated(int chunkX, int chunkZ) { + synchronized (data) { + return data.generated.getBoolean(chunkX + "," + chunkZ); } } @@ -61,17 +61,17 @@ public final class MeteoriteSpawnData { } /** - * Checks whether another meteorite has spawned within the given block range of the given position. + * Checks whether another meteorite has spawned within the given block range of + * the given position. */ public boolean isMeteoriteSpawnInRange(BlockPos pos, int rangeSquared) { - synchronized( data ) - { + synchronized (data) { ChunkPos chunkPos = new ChunkPos(pos); CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, false); if (spawnData == null) { return false; } - final int size = spawnData.getInt( "num" ); + final int size = spawnData.getInt("num"); for (int i = 0; i < size; i++) { CompoundNBT existingSettingsNbt = spawnData.getCompound(String.valueOf(i)); BlockPos existingPos = PlacedMeteoriteSettings.read(existingSettingsNbt).getPos(); @@ -86,8 +86,7 @@ public final class MeteoriteSpawnData { } public boolean tryAddSpawnedMeteorite(PlacedMeteoriteSettings settings, int minDistanceSquared) { - synchronized( data ) - { + synchronized (data) { if (isMeteoriteSpawnInRange(settings.getPos(), minDistanceSquared)) { return false; } @@ -98,13 +97,12 @@ public final class MeteoriteSpawnData { } public void addSpawnedMeteorite(PlacedMeteoriteSettings settings) { - synchronized( data ) - { + synchronized (data) { ChunkPos chunkPos = new ChunkPos(settings.getPos()); CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, true); - final int size = spawnData.getInt( "num" ); - spawnData.put( String.valueOf( size ), settings.write(new CompoundNBT()) ); - spawnData.putInt( "num", size + 1 ); + final int size = spawnData.getInt("num"); + spawnData.put(String.valueOf(size), settings.write(new CompoundNBT())); + spawnData.putInt("num", size + 1); data.markDirty(); } } @@ -112,23 +110,18 @@ public final class MeteoriteSpawnData { public Collection getNearByMeteorites(int chunkX, int chunkZ) { final Collection ll = new ArrayList<>(); - synchronized( data ) - { - for( int x = -1; x <= 1; x++ ) - { - for( int z = -1; z <= 1; z++ ) - { - final int cx = x + ( chunkX >> 4 ); - final int cz = z + ( chunkZ >> 4 ); + synchronized (data) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + final int cx = x + (chunkX >> 4); + final int cz = z + (chunkZ >> 4); - final CompoundNBT data = getSpawnData( cx << 4, cz << 4, false ); + final CompoundNBT data = getSpawnData(cx << 4, cz << 4, false); - if( data != null ) - { + if (data != null) { // edit. - final int size = data.getInt( "num" ); - for( int s = 0; s < size; s++ ) - { + final int size = data.getInt("num"); + for (int s = 0; s < size; s++) { CompoundNBT settingsNbt = data.getCompound(String.valueOf(s)); ll.add(PlacedMeteoriteSettings.read(settingsNbt)); } diff --git a/src/main/java/appeng/worldgen/MeteoriteSpawner.java b/src/main/java/appeng/worldgen/MeteoriteSpawner.java index 6bc6063cd..930fcb5ef 100644 --- a/src/main/java/appeng/worldgen/MeteoriteSpawner.java +++ b/src/main/java/appeng/worldgen/MeteoriteSpawner.java @@ -1,18 +1,20 @@ package appeng.worldgen; +import java.util.HashSet; +import java.util.Set; + +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorldReader; + import appeng.api.AEApi; import appeng.api.definitions.IBlocks; import appeng.core.AEConfig; import appeng.worldgen.meteorite.IMeteoriteWorld; import appeng.worldgen.meteorite.StandardWorld; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; - -import javax.annotation.Nullable; -import java.util.HashSet; -import java.util.Set; /** * Makes decisions about spawning meteorites in the world. @@ -22,50 +24,47 @@ public class MeteoriteSpawner { private final Set validSpawn = new HashSet<>(); private final Set invalidSpawn = new HashSet<>(); - public MeteoriteSpawner() - { + public MeteoriteSpawner() { final IBlocks blocks = AEApi.instance().definitions().blocks(); - 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.ICE ); - this.validSpawn.add( Blocks.SNOW ); + 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.ICE); + this.validSpawn.add(Blocks.SNOW); - this.invalidSpawn.add( blocks.skyStoneBlock().block() ); - this.invalidSpawn.add( Blocks.IRON_DOOR ); - this.invalidSpawn.add( Blocks.IRON_BARS ); - this.invalidSpawn.add( Blocks.OAK_DOOR ); - this.invalidSpawn.add( Blocks.ACACIA_DOOR ); - this.invalidSpawn.add( Blocks.BIRCH_DOOR ); - this.invalidSpawn.add( Blocks.DARK_OAK_DOOR ); - this.invalidSpawn.add( Blocks.JUNGLE_DOOR ); - this.invalidSpawn.add( Blocks.SPRUCE_DOOR ); - this.invalidSpawn.add( Blocks.BRICKS ); - this.invalidSpawn.add( Blocks.CLAY ); - this.invalidSpawn.add( Blocks.WATER ); + this.invalidSpawn.add(blocks.skyStoneBlock().block()); + this.invalidSpawn.add(Blocks.IRON_DOOR); + this.invalidSpawn.add(Blocks.IRON_BARS); + this.invalidSpawn.add(Blocks.OAK_DOOR); + this.invalidSpawn.add(Blocks.ACACIA_DOOR); + this.invalidSpawn.add(Blocks.BIRCH_DOOR); + this.invalidSpawn.add(Blocks.DARK_OAK_DOOR); + this.invalidSpawn.add(Blocks.JUNGLE_DOOR); + this.invalidSpawn.add(Blocks.SPRUCE_DOOR); + this.invalidSpawn.add(Blocks.BRICKS); + this.invalidSpawn.add(Blocks.CLAY); + this.invalidSpawn.add(Blocks.WATER); } public PlacedMeteoriteSettings trySpawnMeteoriteAtSuitableHeight(IWorldReader world, int x, int y, int z) { - for( int tries = 0; tries < 20; tries++ ) - { + for (int tries = 0; tries < 20; tries++) { PlacedMeteoriteSettings spawned = trySpawnMeteorite(world, new BlockPos(x, y, z)); if (spawned != null) { return spawned; } y -= 15; - if( y < 40 ) - { + if (y < 40) { return null; } } @@ -74,15 +73,13 @@ public class MeteoriteSpawner { } @Nullable - public PlacedMeteoriteSettings trySpawnMeteorite(IWorldReader world, BlockPos pos ) - { + public PlacedMeteoriteSettings trySpawnMeteorite(IWorldReader world, BlockPos pos) { Block blk = world.getBlockState(pos).getBlock(); - if( !this.validSpawn.contains( blk ) ) - { + if (!this.validSpawn.contains(blk)) { return null; // must spawn on a valid block.. } - double meteoriteSize = ( Math.random() * 6.0 ) + 2; + double meteoriteSize = (Math.random() * 6.0) + 2; double realCrater = meteoriteSize * 2 + 5; boolean lava = Math.random() > 0.9; @@ -95,8 +92,7 @@ public class MeteoriteSpawner { boolean solid = !isAirBelowSpawnPoint(world, pos); - if( !solid ) - { + if (!solid) { skyMode = 0; } @@ -105,11 +101,9 @@ public class MeteoriteSpawner { private static boolean isAirBelowSpawnPoint(IWorldReader w, BlockPos pos) { BlockPos.Mutable testPos = new BlockPos.Mutable(pos); - for( int j = pos.getY() - 15; j < pos.getY() - 1; j++ ) - { + for (int j = pos.getY() - 15; j < pos.getY() - 1; j++) { testPos.setY(j); - if( w.isAirBlock(testPos) ) - { + if (w.isAirBlock(testPos)) { return true; } } @@ -120,17 +114,13 @@ public class MeteoriteSpawner { int skyMode = 0; BlockPos.Mutable testPos = new BlockPos.Mutable(); - for( int i = pos.getX() - 15; i < pos.getX() + 15; i++ ) - { + for (int i = pos.getX() - 15; i < pos.getX() + 15; i++) { testPos.setX(i); - for( int j = pos.getY() - 15; j < pos.getY() + 11; j++ ) - { + for (int j = pos.getY() - 15; j < pos.getY() + 11; j++) { testPos.setY(j); - for( int k = pos.getZ() - 15; k < pos.getZ() + 15; k++ ) - { + for (int k = pos.getZ() - 15; k < pos.getZ() + 15; k++) { testPos.setZ(k); - if( w.canBlockSeeSky( testPos ) ) - { + if (w.canBlockSeeSky(testPos)) { skyMode++; } } @@ -143,18 +133,14 @@ public class MeteoriteSpawner { int realValidBlocks = 0; BlockPos.Mutable testPos = new BlockPos.Mutable(); - for( int i = pos.getX() - 6; i < pos.getX() + 6; i++ ) - { + for (int i = pos.getX() - 6; i < pos.getX() + 6; i++) { testPos.setX(i); - for( int j = pos.getY() - 6; j < pos.getY() + 6; j++ ) - { + for (int j = pos.getY() - 6; j < pos.getY() + 6; j++) { testPos.setY(j); - for( int k = pos.getZ() - 6; k < pos.getZ() + 6; k++ ) - { + for (int k = pos.getZ() - 6; k < pos.getZ() + 6; k++) { testPos.setZ(k); Block testBlk = w.getBlockState(testPos).getBlock(); - if( this.validSpawn.contains( testBlk ) ) - { + if (this.validSpawn.contains(testBlk)) { realValidBlocks++; } } @@ -162,22 +148,17 @@ public class MeteoriteSpawner { } int validBlocks = 0; - for( int i = pos.getX() - 15; i < pos.getX() + 15; i++ ) - { + for (int i = pos.getX() - 15; i < pos.getX() + 15; i++) { testPos.setX(i); - for( int j = pos.getY() - 15; j < pos.getY() + 15; j++ ) - { + for (int j = pos.getY() - 15; j < pos.getY() + 15; j++) { testPos.setY(j); - for( int k = pos.getZ() - 15; k < pos.getZ() + 15; k++ ) - { + for (int k = pos.getZ() - 15; k < pos.getZ() + 15; k++) { testPos.setZ(k); - Block testBlk = w.getBlockState( testPos ).getBlock(); - if( this.invalidSpawn.contains( testBlk ) ) - { + Block testBlk = w.getBlockState(testPos).getBlock(); + if (this.invalidSpawn.contains(testBlk)) { return false; } - if( this.validSpawn.contains( testBlk ) ) - { + if (this.validSpawn.contains(testBlk)) { validBlocks++; } } diff --git a/src/main/java/appeng/worldgen/MeteoriteWorldGen.java b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java index e678ba781..b67a505fc 100644 --- a/src/main/java/appeng/worldgen/MeteoriteWorldGen.java +++ b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java @@ -18,14 +18,10 @@ package appeng.worldgen; +import java.util.Random; + +import javax.annotation.ParametersAreNonnullByDefault; -import appeng.api.features.AEFeature; -import appeng.api.features.IWorldGen.WorldGenType; -import appeng.core.AEConfig; -import appeng.core.AppEng; -import appeng.core.features.registries.WorldGenRegistry; -import appeng.core.worlddata.WorldData; -import appeng.util.Platform; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.IWorld; @@ -35,75 +31,76 @@ import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.NoFeatureConfig; import net.minecraft.world.server.ServerWorld; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Random; +import appeng.api.features.AEFeature; +import appeng.api.features.IWorldGen.WorldGenType; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import appeng.core.features.registries.WorldGenRegistry; +import appeng.core.worlddata.WorldData; +import appeng.util.Platform; +public final class MeteoriteWorldGen extends Feature { -public final class MeteoriteWorldGen extends Feature -{ + public static final MeteoriteWorldGen INSTANCE = new MeteoriteWorldGen(); - public static final MeteoriteWorldGen INSTANCE = new MeteoriteWorldGen(); + private MeteoriteWorldGen() { + super(NoFeatureConfig::deserialize); + setRegistryName(AppEng.MOD_ID, "meteorite"); + } - private MeteoriteWorldGen( ) - { - super( NoFeatureConfig::deserialize ); - setRegistryName( AppEng.MOD_ID, "meteorite" ); - } + private final MeteoriteSpawner spawner = new MeteoriteSpawner(); - private final MeteoriteSpawner spawner = new MeteoriteSpawner(); + @ParametersAreNonnullByDefault + @Override + public boolean place(IWorld w, ChunkGenerator generator, Random r, BlockPos pos, + NoFeatureConfig config) { + if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) { + return false; + } - @ParametersAreNonnullByDefault - @Override - public boolean place( IWorld w, ChunkGenerator generator, Random r, BlockPos pos, NoFeatureConfig config ) - { - if(!AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN )) { - return false; - } + ChunkPos chunkPos = new ChunkPos(pos); + if (!WorldGenRegistry.INSTANCE.isWorldGenEnabled(WorldGenType.METEORITES, w.getWorld())) { + return false; + } - ChunkPos chunkPos = new ChunkPos( pos ); - if (!WorldGenRegistry.INSTANCE.isWorldGenEnabled(WorldGenType.METEORITES, w.getWorld())) { - return false; - } + double minSqDist = Double.MAX_VALUE; - double minSqDist = Double.MAX_VALUE; + MeteoriteSpawnData spawnData = MeteoriteSpawnData.get(w); - MeteoriteSpawnData spawnData = MeteoriteSpawnData.get(w); + // near by meteorites! + for (final PlacedMeteoriteSettings data : spawnData.getNearByMeteorites(chunkPos.x, chunkPos.z)) { + minSqDist = Math.min(minSqDist, getSqDistance(data, pos)); + } - // near by meteorites! - for( final PlacedMeteoriteSettings data : spawnData.getNearByMeteorites(chunkPos.x, chunkPos.z) ) - { - minSqDist = Math.min( minSqDist, getSqDistance( data, pos ) ); - } + final boolean isCluster = (minSqDist < 30 * 30) + && Platform.getRandomFloat() < AEConfig.instance().getMeteoriteClusterChance(); - final boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance().getMeteoriteClusterChance(); + if (minSqDist > AEConfig.instance().getMinMeteoriteDistanceSq() || isCluster) { + final int x = r.nextInt(16) + (chunkPos.x << 4); + final int y = AEConfig.instance().getMeteoriteMaximumSpawnHeight() + r.nextInt(20); + final int z = r.nextInt(16) + (chunkPos.z << 4); - if( minSqDist > AEConfig.instance().getMinMeteoriteDistanceSq() || isCluster ) - { - final int x = r.nextInt( 16 ) + ( chunkPos.x << 4 ); - final int y = AEConfig.instance().getMeteoriteMaximumSpawnHeight() + r.nextInt( 20 ); - final int z = r.nextInt( 16 ) + ( chunkPos.z << 4 ); + PlacedMeteoriteSettings settings = spawner.trySpawnMeteoriteAtSuitableHeight(w, x, y, z); + if (settings != null) { + // Double check that no other chunk generated a meteorite within range while we + // were working + int checkRange = isCluster ? (30 * 30) : AEConfig.instance().getMinMeteoriteDistanceSq(); + if (spawnData.tryAddSpawnedMeteorite(settings, checkRange)) { + MeteoritePlacer placer = new MeteoritePlacer(w, settings); + placer.place(); + WorldData.instance().compassData().service().updateArea(w, chunkPos.x, chunkPos.z); + } + } + } - PlacedMeteoriteSettings settings = spawner.trySpawnMeteoriteAtSuitableHeight(w, x, y, z); - if (settings != null) { - // Double check that no other chunk generated a meteorite within range while we were working - int checkRange = isCluster ? (30*30) : AEConfig.instance().getMinMeteoriteDistanceSq(); - if (spawnData.tryAddSpawnedMeteorite(settings, checkRange)) { - MeteoritePlacer placer = new MeteoritePlacer(w, settings); - placer.place(); - WorldData.instance().compassData().service().updateArea( w, chunkPos.x, chunkPos.z ); - } - } - } + spawnData.setGenerated(chunkPos.x, chunkPos.z); + return true; + } - spawnData.setGenerated( chunkPos.x, chunkPos.z ); - return true; - } - - private static double getSqDistance( PlacedMeteoriteSettings placed, BlockPos pos ) - { - final int chunkX = placed.getPos().getX() - pos.getX(); - final int chunkZ = placed.getPos().getZ() - pos.getZ(); - return chunkX * chunkX + chunkZ * chunkZ; - } + private static double getSqDistance(PlacedMeteoriteSettings placed, BlockPos pos) { + final int chunkX = placed.getPos().getX() - pos.getX(); + final int chunkZ = placed.getPos().getZ() - pos.getZ(); + return chunkX * chunkX + chunkZ * chunkZ; + } } diff --git a/src/main/java/appeng/worldgen/PlacedMeteoriteSettings.java b/src/main/java/appeng/worldgen/PlacedMeteoriteSettings.java index 50b6be51a..aaca370a8 100644 --- a/src/main/java/appeng/worldgen/PlacedMeteoriteSettings.java +++ b/src/main/java/appeng/worldgen/PlacedMeteoriteSettings.java @@ -1,13 +1,13 @@ package appeng.worldgen; +import java.util.Objects; + import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.util.INBTSerializable; -import java.util.Objects; - public final class PlacedMeteoriteSettings { private final BlockPos pos; @@ -17,7 +17,8 @@ public final class PlacedMeteoriteSettings { private final double meteoriteRadius; private final double craterRadius; - public PlacedMeteoriteSettings(BlockPos pos, ResourceLocation blk, boolean lava, int skyMode, double meteoriteRadius, double craterRadius) { + public PlacedMeteoriteSettings(BlockPos pos, ResourceLocation blk, boolean lava, int skyMode, + double meteoriteRadius, double craterRadius) { this.pos = pos; this.blk = blk; this.lava = lava; @@ -54,13 +55,13 @@ public final class PlacedMeteoriteSettings { tag.putInt("x", pos.getX()); tag.putInt("y", pos.getY()); tag.putInt("z", pos.getZ()); - tag.putString( "blk", blk.toString() ); + tag.putString("blk", blk.toString()); - tag.putDouble( "meteoriteRadius", meteoriteRadius ); - tag.putDouble( "craterRadius", craterRadius ); + tag.putDouble("meteoriteRadius", meteoriteRadius); + tag.putDouble("craterRadius", craterRadius); - tag.putBoolean( "lava", lava ); - tag.putInt( "skyMode", skyMode ); + tag.putBoolean("lava", lava); + tag.putInt("skyMode", skyMode); return tag; } diff --git a/src/main/java/appeng/worldgen/QuartzWorldGen.java b/src/main/java/appeng/worldgen/QuartzWorldGen.java index f553ffe12..44745371e 100644 --- a/src/main/java/appeng/worldgen/QuartzWorldGen.java +++ b/src/main/java/appeng/worldgen/QuartzWorldGen.java @@ -18,13 +18,11 @@ package appeng.worldgen; +import java.util.Random; +import java.util.function.Function; -import appeng.api.AEApi; -import appeng.api.definitions.IBlockDefinition; -import appeng.api.definitions.IBlocks; -import appeng.api.features.IWorldGen.WorldGenType; -import appeng.core.features.registries.WorldGenRegistry; import com.mojang.datafixers.Dynamic; + import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.World; @@ -33,83 +31,73 @@ import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.ReplaceBlockConfig; import net.minecraft.world.gen.feature.ReplaceBlockFeature; -import java.util.Random; -import java.util.function.Function; +import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; +import appeng.api.features.IWorldGen.WorldGenType; +import appeng.core.features.registries.WorldGenRegistry; +public final class QuartzWorldGen extends ReplaceBlockFeature { + /* + * private final WorldGenMinable oreNormal; private final WorldGenMinable + * oreCharged; + */ -public final class QuartzWorldGen extends ReplaceBlockFeature -{ - /* - private final WorldGenMinable oreNormal; - private final WorldGenMinable oreCharged; - */ + public QuartzWorldGen(Function, ? extends ReplaceBlockConfig> serializer) { + super(serializer); + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final IBlockDefinition oreDefinition = blocks.quartzOre(); + final IBlockDefinition chargedDefinition = blocks.quartzOreCharged(); - public QuartzWorldGen( Function, ? extends ReplaceBlockConfig> serializer ) - { - super(serializer); - final IBlocks blocks = AEApi.instance().definitions().blocks(); - final IBlockDefinition oreDefinition = blocks.quartzOre(); - final IBlockDefinition chargedDefinition = blocks.quartzOreCharged(); + /* + * this.oreNormal = oreDefinition.maybeBlock() .map( b -> new WorldGenMinable( + * b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) ) + * .orElse( null ); this.oreCharged = chargedDefinition.maybeBlock() .map( b -> + * new WorldGenMinable( b.getDefaultState(), + * AEConfig.instance().getQuartzOresPerCluster() ) ) .orElse( null ); + */ + } - /* - this.oreNormal = oreDefinition.maybeBlock() - .map( b -> new WorldGenMinable( b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) ) - .orElse( null ); - this.oreCharged = chargedDefinition.maybeBlock() - .map( b -> new WorldGenMinable( b.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() ) ) - .orElse( null ); - */ - } + private static boolean shouldGenerate(final boolean isCharged, final World w) { + return WorldGenRegistry.INSTANCE + .isWorldGenEnabled(isCharged ? WorldGenType.CHARGED_CERTUS_QUARTZ : WorldGenType.CERTUS_QUARTZ, w); + } - private static boolean shouldGenerate( final boolean isCharged, final World w ) - { - return WorldGenRegistry.INSTANCE.isWorldGenEnabled( isCharged ? WorldGenType.CHARGED_CERTUS_QUARTZ : WorldGenType.CERTUS_QUARTZ, w ); - } - - @Override public boolean place( IWorld worldIn, ChunkGenerator generator, Random r, BlockPos pos, ReplaceBlockConfig config ) - { - /* - if( this.oreNormal == null && this.oreCharged == null ) - { - return false; - } - - World w = worldIn.getWorld(); - - int seaLevel = w.getSeaLevel(); - - ChunkPos chunkPos = new ChunkPos( pos ); - - if( seaLevel < 20 ) - { - final int x = ( chunkPos.x << 4 ) + 8; - final int z = ( chunkPos.z << 4 ) + 8; - seaLevel = w.getHeight( Heightmap.Type.WORLD_SURFACE, x, z ); - } - - final int oreDepthMultiplier = AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64; - final int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier ); - - for( int cnt = 0; cnt < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++cnt ) - { - boolean isCharged = false; - - if( this.oreCharged != null ) - { - isCharged = r.nextFloat() > AEConfig.instance().getSpawnChargedChance(); - } - - final WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal; - if( whichOre != null && shouldGenerate( isCharged, w ) ) - { - final int cx = chunkPos.x * 16 + r.nextInt( 16 ); - final int cy = r.nextInt( 40 * seaLevel / 64 ) + r.nextInt( 22 * seaLevel / 64 ) + 12 * seaLevel / 64; - final int cz = chunkPos.z * 16 + r.nextInt( 16 ); - whichOre.generate( w, r, new BlockPos( cx, cy, cz ) ); - } - } - */ - return true; - } + @Override + public boolean place(IWorld worldIn, ChunkGenerator generator, Random r, BlockPos pos, + ReplaceBlockConfig config) { + /* + * if( this.oreNormal == null && this.oreCharged == null ) { return false; } + * + * World w = worldIn.getWorld(); + * + * int seaLevel = w.getSeaLevel(); + * + * ChunkPos chunkPos = new ChunkPos( pos ); + * + * if( seaLevel < 20 ) { final int x = ( chunkPos.x << 4 ) + 8; final int z = ( + * chunkPos.z << 4 ) + 8; seaLevel = w.getHeight( Heightmap.Type.WORLD_SURFACE, + * x, z ); } + * + * final int oreDepthMultiplier = + * AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64; final int + * scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + * + oreDepthMultiplier ); + * + * for( int cnt = 0; cnt < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++cnt ) + * { boolean isCharged = false; + * + * if( this.oreCharged != null ) { isCharged = r.nextFloat() > + * AEConfig.instance().getSpawnChargedChance(); } + * + * final WorldGenMinable whichOre = isCharged ? this.oreCharged : + * this.oreNormal; if( whichOre != null && shouldGenerate( isCharged, w ) ) { + * final int cx = chunkPos.x * 16 + r.nextInt( 16 ); final int cy = r.nextInt( + * 40 * seaLevel / 64 ) + r.nextInt( 22 * seaLevel / 64 ) + 12 * seaLevel / 64; + * final int cz = chunkPos.z * 16 + r.nextInt( 16 ); whichOre.generate( w, r, + * new BlockPos( cx, cy, cz ) ); } } + */ + return true; + } } diff --git a/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java index 6fce554a3..7628e9710 100644 --- a/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java +++ b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java @@ -18,56 +18,48 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; - -import appeng.util.Platform; import net.minecraft.world.chunk.IChunk; +import appeng.util.Platform; -public class ChunkOnly extends StandardWorld -{ +public class ChunkOnly extends StandardWorld { - private final IChunk target; - private final int cx; - private final int cz; + private final IChunk target; + private final int cx; + private final int cz; - public ChunkOnly(final IWorld w, final int cx, final int cz ) - { - super( w ); - this.target = w.getChunk( cx, cz ); - this.cx = cx; - this.cz = cz; - } + public ChunkOnly(final IWorld w, final int cx, final int cz) { + super(w); + this.target = w.getChunk(cx, cz); + this.cx = cx; + this.cz = cz; + } - @Override - public int minX( final int in ) - { - return Math.max( in, this.cx << 4 ); - } + @Override + public int minX(final int in) { + return Math.max(in, this.cx << 4); + } - @Override - public int minZ( final int in ) - { - return Math.max( in, this.cz << 4 ); - } + @Override + public int minZ(final int in) { + return Math.max(in, this.cz << 4); + } - @Override - public int maxX( final int in ) - { - return Math.min( in, ( this.cx + 1 ) << 4 ); - } + @Override + public int maxX(final int in) { + return Math.min(in, (this.cx + 1) << 4); + } - @Override - public int maxZ( final int in ) - { - return Math.min( in, ( this.cz + 1 ) << 4 ); - } + @Override + public int maxZ(final int in) { + return Math.min(in, (this.cz + 1) << 4); + } @Override public boolean contains(BlockPos pos) { @@ -75,36 +67,29 @@ public class ChunkOnly extends StandardWorld } @Override - public Block getBlock( BlockPos pos ) - { - if( this.range( pos ) ) - { - return this.target.getBlockState( new BlockPos(pos) ).getBlock(); - } - return Platform.AIR_BLOCK; - } + public Block getBlock(BlockPos pos) { + if (this.range(pos)) { + return this.target.getBlockState(new BlockPos(pos)).getBlock(); + } + return Platform.AIR_BLOCK; + } - @Override - public void setBlock( BlockPos pos, final BlockState blk ) - { - if( this.range( pos ) ) - { - target.setBlockState(new BlockPos( pos ), blk, false); - } - } + @Override + public void setBlock(BlockPos pos, final BlockState blk) { + if (this.range(pos)) { + target.setBlockState(new BlockPos(pos), blk, false); + } + } - @Override - public void setBlock( BlockPos pos, final BlockState state, final int flags ) - { - if( this.range( pos ) ) - { - this.getWorld().setBlockState( new BlockPos( pos ), state, flags & ( ~2 ) ); - } - } + @Override + public void setBlock(BlockPos pos, final BlockState state, final int flags) { + if (this.range(pos)) { + this.getWorld().setBlockState(new BlockPos(pos), state, flags & (~2)); + } + } - @Override - public boolean range( BlockPos pos ) - { - return this.cx == ( pos.getX() >> 4 ) && this.cz == ( pos.getZ() >> 4 ); - } + @Override + public boolean range(BlockPos pos) { + return this.cx == (pos.getX() >> 4) && this.cz == (pos.getZ() >> 4); + } } diff --git a/src/main/java/appeng/worldgen/meteorite/Fallout.java b/src/main/java/appeng/worldgen/meteorite/Fallout.java index aa1062a88..c878b5aad 100644 --- a/src/main/java/appeng/worldgen/meteorite/Fallout.java +++ b/src/main/java/appeng/worldgen/meteorite/Fallout.java @@ -18,78 +18,53 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; - -import appeng.util.Platform; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import appeng.util.Platform; -public class Fallout -{ - private final MeteoriteBlockPutter putter; - private final BlockState skyStone; +public class Fallout { + private final MeteoriteBlockPutter putter; + private final BlockState skyStone; - public Fallout( final MeteoriteBlockPutter putter, final BlockState skyStone ) - { - this.putter = putter; - this.skyStone = skyStone; - } + public Fallout(final MeteoriteBlockPutter putter, final BlockState skyStone) { + this.putter = putter; + this.skyStone = skyStone; + } - public int adjustCrater() - { - return 0; - } + public int adjustCrater() { + return 0; + } - public void getRandomFall(final IWorld w, BlockPos pos ) - { - final double a = Math.random(); - if( a > 0.9 ) - { - this.putter.put( w, pos, Blocks.STONE.getDefaultState() ); - } - else if( a > 0.8 ) - { - this.putter.put( w, pos, Blocks.COBBLESTONE.getDefaultState() ); - } - else if( a > 0.7 ) - { - this.putter.put( w, pos, Blocks.DIRT.getDefaultState() ); - } - else - { - this.putter.put( w, pos, Blocks.GRAVEL.getDefaultState() ); - } - } + public void getRandomFall(final IWorld w, BlockPos pos) { + final double a = Math.random(); + if (a > 0.9) { + this.putter.put(w, pos, Blocks.STONE.getDefaultState()); + } else if (a > 0.8) { + this.putter.put(w, pos, Blocks.COBBLESTONE.getDefaultState()); + } else if (a > 0.7) { + this.putter.put(w, pos, Blocks.DIRT.getDefaultState()); + } else { + this.putter.put(w, pos, Blocks.GRAVEL.getDefaultState()); + } + } - public void getRandomInset( final IWorld w, BlockPos pos ) - { - final double a = Math.random(); - if( a > 0.9 ) - { - this.putter.put( w, pos, Blocks.COBBLESTONE.getDefaultState() ); - } - else if( a > 0.8 ) - { - this.putter.put( w, pos, Blocks.STONE.getDefaultState() ); - } - else if( a > 0.7 ) - { - this.putter.put( w, pos, Blocks.GRASS_BLOCK.getDefaultState() ); - } - else if( a > 0.6 ) - { - this.putter.put( w, pos, this.skyStone ); - } - else if( a > 0.5 ) - { - this.putter.put( w, pos, Blocks.GRAVEL.getDefaultState() ); - } - else - { - this.putter.put( w, pos, Platform.AIR_BLOCK.getDefaultState() ); - } - } + public void getRandomInset(final IWorld w, BlockPos pos) { + final double a = Math.random(); + if (a > 0.9) { + this.putter.put(w, pos, Blocks.COBBLESTONE.getDefaultState()); + } else if (a > 0.8) { + this.putter.put(w, pos, Blocks.STONE.getDefaultState()); + } else if (a > 0.7) { + this.putter.put(w, pos, Blocks.GRASS_BLOCK.getDefaultState()); + } else if (a > 0.6) { + this.putter.put(w, pos, this.skyStone); + } else if (a > 0.5) { + this.putter.put(w, pos, Blocks.GRAVEL.getDefaultState()); + } else { + this.putter.put(w, pos, Platform.AIR_BLOCK.getDefaultState()); + } + } } diff --git a/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java b/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java index 4528896ee..461861187 100644 --- a/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java +++ b/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java @@ -18,67 +18,52 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; - -import appeng.api.definitions.IBlockDefinition; -import appeng.util.Platform; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import appeng.api.definitions.IBlockDefinition; +import appeng.util.Platform; -public class FalloutCopy extends Fallout -{ - private static final double SPECIFIED_BLOCK_THRESHOLD = 0.9; - private static final double AIR_BLOCK_THRESHOLD = 0.8; - private static final double BLOCK_THRESHOLD_STEP = 0.1; +public class FalloutCopy extends Fallout { + private static final double SPECIFIED_BLOCK_THRESHOLD = 0.9; + private static final double AIR_BLOCK_THRESHOLD = 0.8; + private static final double BLOCK_THRESHOLD_STEP = 0.1; - private final BlockState block; - private final MeteoriteBlockPutter putter; + private final BlockState block; + private final MeteoriteBlockPutter putter; - public FalloutCopy(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone ) - { - super( putter, skyStone ); - this.putter = putter; - this.block = w.getBlockState( pos ); - } + public FalloutCopy(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) { + super(putter, skyStone); + this.putter = putter; + this.block = w.getBlockState(pos); + } - @Override - public void getRandomFall( final IWorld w, BlockPos pos ) - { - final double a = Math.random(); - if( a > SPECIFIED_BLOCK_THRESHOLD ) - { - this.putter.put( w, pos, this.block ); - } - else - { - this.getOther( w, pos, a ); - } - } + @Override + public void getRandomFall(final IWorld w, BlockPos pos) { + final double a = Math.random(); + if (a > SPECIFIED_BLOCK_THRESHOLD) { + this.putter.put(w, pos, this.block); + } else { + this.getOther(w, pos, a); + } + } - public void getOther( final IWorld w, BlockPos pos, final double a ) - { + public void getOther(final IWorld w, BlockPos pos, final double a) { - } + } - @Override - public void getRandomInset( final IWorld w, BlockPos pos ) - { - final double a = Math.random(); - if( a > SPECIFIED_BLOCK_THRESHOLD ) - { - this.putter.put( w, pos, this.block ); - } - else if( a > AIR_BLOCK_THRESHOLD ) - { - this.putter.put( w, pos, Blocks.AIR.getDefaultState() ); - } - else - { - this.getOther( w, pos, a - BLOCK_THRESHOLD_STEP ); - } - } + @Override + public void getRandomInset(final IWorld w, BlockPos pos) { + final double a = Math.random(); + if (a > SPECIFIED_BLOCK_THRESHOLD) { + this.putter.put(w, pos, this.block); + } else if (a > AIR_BLOCK_THRESHOLD) { + this.putter.put(w, pos, Blocks.AIR.getDefaultState()); + } else { + this.getOther(w, pos, 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 index 36b62c95a..18f7233a3 100644 --- a/src/main/java/appeng/worldgen/meteorite/FalloutSand.java +++ b/src/main/java/appeng/worldgen/meteorite/FalloutSand.java @@ -18,38 +18,31 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; - -import appeng.api.definitions.IBlockDefinition; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import appeng.api.definitions.IBlockDefinition; -public class FalloutSand extends FalloutCopy -{ - private static final double GLASS_THRESHOLD = 0.66; - private final MeteoriteBlockPutter putter; +public class FalloutSand extends FalloutCopy { + private static final double GLASS_THRESHOLD = 0.66; + private final MeteoriteBlockPutter putter; - public FalloutSand(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone ) - { - super( w, pos, putter, skyStone ); - this.putter = putter; - } + public FalloutSand(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) { + super(w, pos, putter, skyStone); + this.putter = putter; + } - @Override - public int adjustCrater() - { - return 2; - } + @Override + public int adjustCrater() { + return 2; + } - @Override - public void getOther( final IWorld w, BlockPos pos, final double a ) - { - if( a > GLASS_THRESHOLD ) - { - this.putter.put( w, pos, Blocks.GLASS.getDefaultState() ); - } - } + @Override + public void getOther(final IWorld w, BlockPos pos, final double a) { + if (a > GLASS_THRESHOLD) { + this.putter.put(w, pos, Blocks.GLASS.getDefaultState()); + } + } } \ 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 index 7a1b9fda4..6273d67b9 100644 --- a/src/main/java/appeng/worldgen/meteorite/FalloutSnow.java +++ b/src/main/java/appeng/worldgen/meteorite/FalloutSnow.java @@ -18,43 +18,34 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; - -import appeng.api.definitions.IBlockDefinition; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import appeng.api.definitions.IBlockDefinition; -public class FalloutSnow extends FalloutCopy -{ - private static final double SNOW_THRESHOLD = 0.7; - private static final double ICE_THRESHOLD = 0.5; - private final MeteoriteBlockPutter putter; +public class FalloutSnow extends FalloutCopy { + private static final double SNOW_THRESHOLD = 0.7; + private static final double ICE_THRESHOLD = 0.5; + private final MeteoriteBlockPutter putter; - public FalloutSnow(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) - { - super( w, pos, putter, skyStone ); - this.putter = putter; - } + public FalloutSnow(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) { + super(w, pos, putter, skyStone); + this.putter = putter; + } - @Override - public int adjustCrater() - { - return 2; - } + @Override + public int adjustCrater() { + return 2; + } - @Override - public void getOther( final IWorld w, BlockPos pos, final double a ) - { - if( a > SNOW_THRESHOLD ) - { - this.putter.put( w, pos, Blocks.SNOW.getDefaultState() ); - } - else if( a > ICE_THRESHOLD ) - { - this.putter.put( w, pos, Blocks.ICE.getDefaultState() ); - } - } + @Override + public void getOther(final IWorld w, BlockPos pos, final double a) { + if (a > SNOW_THRESHOLD) { + this.putter.put(w, pos, Blocks.SNOW.getDefaultState()); + } else if (a > ICE_THRESHOLD) { + this.putter.put(w, pos, Blocks.ICE.getDefaultState()); + } + } } \ 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 index 29aeaf040..57d12a1df 100644 --- a/src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java +++ b/src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java @@ -18,7 +18,6 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; @@ -26,30 +25,28 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.World; +public interface IMeteoriteWorld { + int minX(int in); -public interface IMeteoriteWorld -{ - int minX( int in ); + int minZ(int in); - int minZ( int in ); + int maxX(int in); - int maxX( int in ); + int maxZ(int in); - int maxZ( int in ); + boolean contains(BlockPos pos); - boolean contains( BlockPos pos ); + Block getBlock(BlockPos pos); - Block getBlock( BlockPos pos ); + boolean canBlockSeeTheSky(BlockPos pos); - boolean canBlockSeeTheSky( BlockPos pos ); + TileEntity getTileEntity(BlockPos pos); - TileEntity getTileEntity( BlockPos pos ); + IWorld getWorld(); - IWorld getWorld(); + void setBlock(BlockPos pos, final BlockState state, final int flags); - void setBlock( BlockPos pos, final BlockState state, final int flags ); + void setBlock(BlockPos pos, BlockState blk); - void setBlock( BlockPos pos, BlockState blk ); - - BlockState getBlockState( BlockPos pos ); + BlockState getBlockState(BlockPos pos); } \ 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 index eb35882a4..e9dfafb2b 100644 --- a/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java +++ b/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java @@ -18,27 +18,22 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +public class MeteoriteBlockPutter { + public boolean put(final IWorld w, BlockPos pos, final BlockState blk) { + final BlockState original = w.getBlockState(pos); -public class MeteoriteBlockPutter -{ - public boolean put(final IWorld w, BlockPos pos, final BlockState blk ) - { - final BlockState original = w.getBlockState( pos ); + if (original.getBlock() == Blocks.BEDROCK || original == blk) { + return false; + } - if( original.getBlock() == Blocks.BEDROCK || original == blk ) - { - return false; - } - - w.setBlockState(pos, blk, 0); - return true; - } + w.setBlockState(pos, blk, 0); + return true; + } } diff --git a/src/main/java/appeng/worldgen/meteorite/StandardWorld.java b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java index f8d49e8ae..fc5862e06 100644 --- a/src/main/java/appeng/worldgen/meteorite/StandardWorld.java +++ b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java @@ -18,7 +18,6 @@ package appeng.worldgen.meteorite; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -29,113 +28,92 @@ import net.minecraft.world.World; import appeng.util.Platform; +public class StandardWorld implements IMeteoriteWorld { -public class StandardWorld implements IMeteoriteWorld -{ + private final IWorld w; - private final IWorld w; + public StandardWorld(final IWorld w) { + this.w = w; + } - public StandardWorld( final IWorld w ) - { - this.w = w; - } + @Override + public int minX(final int in) { + return in; + } - @Override - public int minX( final int in ) - { - return in; - } + @Override + public int minZ(final int in) { + return in; + } - @Override - public int minZ( final int in ) - { - return in; - } + @Override + public int maxX(final int in) { + return in; + } - @Override - public int maxX( final int in ) - { - return in; - } + @Override + public int maxZ(final int in) { + return in; + } - @Override - public int maxZ( final int in ) - { - return in; - } + @Override + public boolean contains(BlockPos pos) { + return true; + } - @Override - public boolean contains(BlockPos pos) { - return true; - } + @Override + public Block getBlock(BlockPos pos) { + if (this.range(pos)) { + return this.getWorld().getBlockState(new BlockPos(pos)).getBlock(); + } + return Platform.AIR_BLOCK; + } - @Override - public Block getBlock( BlockPos pos ) - { - if( this.range( pos ) ) - { - return this.getWorld().getBlockState( new BlockPos( pos ) ).getBlock(); - } - return Platform.AIR_BLOCK; - } + @Override + public boolean canBlockSeeTheSky(BlockPos pos) { + if (this.range(pos)) { + return this.getWorld().canBlockSeeSky(new BlockPos(pos)); + } + return false; + } - @Override - public boolean canBlockSeeTheSky( BlockPos pos ) - { - if( this.range( pos ) ) - { - return this.getWorld().canBlockSeeSky( new BlockPos( pos ) ); - } - return false; - } + @Override + public TileEntity getTileEntity(BlockPos pos) { + if (this.range(pos)) { + return this.getWorld().getTileEntity(new BlockPos(pos)); + } + return null; + } - @Override - public TileEntity getTileEntity( BlockPos pos ) - { - if( this.range( pos ) ) - { - return this.getWorld().getTileEntity( new BlockPos( pos ) ); - } - return null; - } + @Override + public IWorld getWorld() { + return this.w; + } - @Override - public IWorld getWorld() - { - return this.w; - } + @Override + public void setBlock(BlockPos pos, final BlockState blk) { + if (this.range(pos)) { + // FIXME: Attempt at reducing impact of placing meteors by passing 16|32 here + this.getWorld().setBlockState(new BlockPos(pos), blk, 16 | 32); + } + } - @Override - public void setBlock( BlockPos pos, final BlockState blk ) - { - if( this.range( pos ) ) - { - // FIXME: Attempt at reducing impact of placing meteors by passing 16|32 here - this.getWorld().setBlockState( new BlockPos( pos ), blk, 16|32 ); - } - } + public boolean range(BlockPos pos) { + return true; + } - public boolean range( BlockPos pos ) - { - return true; - } + @Override + public void setBlock(BlockPos pos, final BlockState state, final int l) { + if (this.range(pos)) { + this.w.setBlockState(new BlockPos(pos), state, l); + } + } - @Override - public void setBlock( BlockPos pos, final BlockState state, final int l ) - { - if( this.range( pos ) ) - { - this.w.setBlockState( new BlockPos( pos ), state, l ); - } - } - - @Override - public BlockState getBlockState( BlockPos pos ) - { - if( this.range( pos ) ) - { - return this.w.getBlockState( new BlockPos( pos ) ); - } - return Blocks.AIR.getDefaultState(); - } + @Override + public BlockState getBlockState(BlockPos pos) { + if (this.range(pos)) { + return this.w.getBlockState(new BlockPos(pos)); + } + return Blocks.AIR.getDefaultState(); + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/16k_crafting_storage.json b/src/main/resources/assets/appliedenergistics2/blockstates/16k_crafting_storage.json index 062cab614..2a77e5b42 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/16k_crafting_storage.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/16k_crafting_storage.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/16k_storage" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/16k_storage_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/16k_storage" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/16k_storage_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/1k_crafting_storage.json b/src/main/resources/assets/appliedenergistics2/blockstates/1k_crafting_storage.json index 0d6b9a975..ff9177420 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/1k_crafting_storage.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/1k_crafting_storage.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/1k_storage" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/1k_storage_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/1k_storage" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/1k_storage_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/4k_crafting_storage.json b/src/main/resources/assets/appliedenergistics2/blockstates/4k_crafting_storage.json index 59cf6ebc3..45927e96f 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/4k_crafting_storage.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/4k_crafting_storage.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/4k_storage" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/4k_storage_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/4k_storage" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/4k_storage_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/64k_crafting_storage.json b/src/main/resources/assets/appliedenergistics2/blockstates/64k_crafting_storage.json index e6cda46aa..c52490c8a 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/64k_crafting_storage.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/64k_crafting_storage.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/64k_storage" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/64k_storage_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/64k_storage" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/64k_storage_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json b/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json index 9e377efc3..4bfca275e 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/cable_bus" - } + "variants": { + "": { + "model": "appliedenergistics2:block/cable_bus" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/cell_workbench.json b/src/main/resources/assets/appliedenergistics2/blockstates/cell_workbench.json index 9335eb4da..22a6d69a3 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/cell_workbench.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/cell_workbench.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/cell_workbench" - } + "variants": { + "": { + "model": "appliedenergistics2:block/cell_workbench" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/charged_quartz_ore.json b/src/main/resources/assets/appliedenergistics2/blockstates/charged_quartz_ore.json index 02550c327..d185ddf16 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/charged_quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/charged_quartz_ore.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/charged_quartz_ore" - } + "variants": { + "": { + "model": "appliedenergistics2:block/charged_quartz_ore" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/charger.json b/src/main/resources/assets/appliedenergistics2/blockstates/charger.json index 991633f05..9c5d93d5f 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/charger.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/charger.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/charger" - } + "variants": { + "": { + "model": "appliedenergistics2:block/charger" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_block.json b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_block.json index 575a0ebae..aa05e8e7c 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_block.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/chiseled_quartz_block" - } + "variants": { + "": { + "model": "appliedenergistics2:block/chiseled_quartz_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_slab.json index 5673d00aa..4586fca4b 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/chiseled_quartz_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/chiseled_quartz_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/chiseled_quartz_block" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/chiseled_quartz_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/chiseled_quartz_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/chiseled_quartz_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_stairs.json index 75fe4ab79..540246857 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/chiseled_quartz_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/chiseled_quartz", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/chiseled_quartz", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/condenser.json b/src/main/resources/assets/appliedenergistics2/blockstates/condenser.json index f2a4cd84a..f1d52b0a3 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/condenser.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/condenser.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/condenser" - } + "variants": { + "": { + "model": "appliedenergistics2:block/condenser" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/controller.json b/src/main/resources/assets/appliedenergistics2/blockstates/controller.json index cd70227f7..f83c39f14 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/controller.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/controller.json @@ -1,139 +1,139 @@ { - "multipart": [ - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_block_offline" - }, - "when": { - "state": "offline", - "type": "block" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_block_online" - }, - "when": { - "state": "online", - "type": "block" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_block_conflicted" - }, - "when": { - "state": "conflicted", - "type": "block" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_offline", - "x": 90, - "y": 90 - }, - "when": { - "state": "offline", - "type": "column_x" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_offline" - }, - "when": { - "state": "offline", - "type": "column_y" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_offline", - "x": 90 - }, - "when": { - "state": "offline", - "type": "column_z" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_online", - "x": 90, - "y": 90 - }, - "when": { - "state": "online", - "type": "column_x" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_online" - }, - "when": { - "state": "online", - "type": "column_y" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_online", - "x": 90 - }, - "when": { - "state": "online", - "type": "column_z" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_conflicted", - "x": 90, - "y": 90 - }, - "when": { - "state": "conflicted", - "type": "column_x" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_conflicted" - }, - "when": { - "state": "conflicted", - "type": "column_y" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_column_conflicted", - "x": 90 - }, - "when": { - "state": "conflicted", - "type": "column_z" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_inside_a" - }, - "when": { - "state": "offline|online|conflicted", - "type": "inside_a" - } - }, - { - "apply": { - "model": "appliedenergistics2:block/controller/controller_inside_b" - }, - "when": { - "state": "offline|online|conflicted", - "type": "inside_b" - } - } - ] + "multipart": [ + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_block_offline" + }, + "when": { + "state": "offline", + "type": "block" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_block_online" + }, + "when": { + "state": "online", + "type": "block" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_block_conflicted" + }, + "when": { + "state": "conflicted", + "type": "block" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_offline", + "x": 90, + "y": 90 + }, + "when": { + "state": "offline", + "type": "column_x" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_offline" + }, + "when": { + "state": "offline", + "type": "column_y" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_offline", + "x": 90 + }, + "when": { + "state": "offline", + "type": "column_z" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_online", + "x": 90, + "y": 90 + }, + "when": { + "state": "online", + "type": "column_x" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_online" + }, + "when": { + "state": "online", + "type": "column_y" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_online", + "x": 90 + }, + "when": { + "state": "online", + "type": "column_z" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_conflicted", + "x": 90, + "y": 90 + }, + "when": { + "state": "conflicted", + "type": "column_x" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_conflicted" + }, + "when": { + "state": "conflicted", + "type": "column_y" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_column_conflicted", + "x": 90 + }, + "when": { + "state": "conflicted", + "type": "column_z" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_inside_a" + }, + "when": { + "state": "offline|online|conflicted", + "type": "inside_a" + } + }, + { + "apply": { + "model": "appliedenergistics2:block/controller/controller_inside_b" + }, + "when": { + "state": "offline|online|conflicted", + "type": "inside_b" + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_accelerator.json b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_accelerator.json index 4f53f8bf7..6bebafc6d 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_accelerator.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_accelerator.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/accelerator" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/accelerator_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/accelerator" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/accelerator_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_monitor.json b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_monitor.json index e5a30b952..db067212f 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_monitor.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_monitor.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/monitor" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/monitor_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/monitor" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/monitor_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_unit.json b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_unit.json index 393969556..861bc84bf 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/crafting_unit.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/crafting_unit.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/crafting/unit" - }, - "formed=true": { - "model": "appliedenergistics2:block/crafting/unit_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/crafting/unit" + }, + "formed=true": { + "model": "appliedenergistics2:block/crafting/unit_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/crank.json b/src/main/resources/assets/appliedenergistics2/blockstates/crank.json index 5ae8d5fe8..584aafc60 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/crank.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/crank.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/crank" - } + "variants": { + "": { + "model": "appliedenergistics2:block/crank" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/creative_energy_cell.json b/src/main/resources/assets/appliedenergistics2/blockstates/creative_energy_cell.json index fcc2a1c59..6896537f0 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/creative_energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/creative_energy_cell.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/energy_cell/creative_energy_cell" - } + "variants": { + "": { + "model": "appliedenergistics2:block/energy_cell/creative_energy_cell" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/debug_chunk_loader.json b/src/main/resources/assets/appliedenergistics2/blockstates/debug_chunk_loader.json index 5af916247..9f159602b 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/debug_chunk_loader.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/debug_chunk_loader.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/debug/chunk_loader" - } + "variants": { + "": { + "model": "appliedenergistics2:block/debug/chunk_loader" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/debug_cube_gen.json b/src/main/resources/assets/appliedenergistics2/blockstates/debug_cube_gen.json index c7c1cfb0d..ec21eed7c 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/debug_cube_gen.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/debug_cube_gen.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/debug/cube_gen" - } + "variants": { + "": { + "model": "appliedenergistics2:block/debug/cube_gen" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/debug_energy_gen.json b/src/main/resources/assets/appliedenergistics2/blockstates/debug_energy_gen.json index 49a504915..5ecc9080e 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/debug_energy_gen.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/debug_energy_gen.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/debug/energy_gen" - } + "variants": { + "": { + "model": "appliedenergistics2:block/debug/energy_gen" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/debug_item_gen.json b/src/main/resources/assets/appliedenergistics2/blockstates/debug_item_gen.json index b1d78b72b..6559092dc 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/debug_item_gen.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/debug_item_gen.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/debug/item_gen" - } + "variants": { + "": { + "model": "appliedenergistics2:block/debug/item_gen" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/debug_phantom_node.json b/src/main/resources/assets/appliedenergistics2/blockstates/debug_phantom_node.json index 844feb842..8302b4488 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/debug_phantom_node.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/debug_phantom_node.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/debug/phantom_node" - } + "variants": { + "": { + "model": "appliedenergistics2:block/debug/phantom_node" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/dense_energy_cell.json b/src/main/resources/assets/appliedenergistics2/blockstates/dense_energy_cell.json index 7acb4124c..5b35a11a8 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/dense_energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/dense_energy_cell.json @@ -1,28 +1,28 @@ { - "variants": { - "fullness=0": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell0" - }, - "fullness=1": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell1" - }, - "fullness=2": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell2" - }, - "fullness=3": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell3" - }, - "fullness=4": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell4" - }, - "fullness=5": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell5" - }, - "fullness=6": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell6" - }, - "fullness=7": { - "model": "appliedenergistics2:block/energy_cell/dense_energy_cell7" - } + "variants": { + "fullness=0": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell0" + }, + "fullness=1": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell1" + }, + "fullness=2": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell2" + }, + "fullness=3": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell3" + }, + "fullness=4": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell4" + }, + "fullness=5": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell5" + }, + "fullness=6": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell6" + }, + "fullness=7": { + "model": "appliedenergistics2:block/energy_cell/dense_energy_cell7" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/drive.json b/src/main/resources/assets/appliedenergistics2/blockstates/drive.json index 6eefff803..05bceafd6 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/drive.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/drive.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/drive" - } + "variants": { + "": { + "model": "appliedenergistics2:block/drive" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/energy_acceptor.json b/src/main/resources/assets/appliedenergistics2/blockstates/energy_acceptor.json index 99f80651b..b2edaa552 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/energy_acceptor.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/energy_acceptor.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/energy_acceptor" - } + "variants": { + "": { + "model": "appliedenergistics2:block/energy_acceptor" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/energy_cell.json b/src/main/resources/assets/appliedenergistics2/blockstates/energy_cell.json index 923863631..1985548f2 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/energy_cell.json @@ -1,28 +1,28 @@ { - "variants": { - "fullness=0": { - "model": "appliedenergistics2:block/energy_cell/energy_cell0" - }, - "fullness=1": { - "model": "appliedenergistics2:block/energy_cell/energy_cell1" - }, - "fullness=2": { - "model": "appliedenergistics2:block/energy_cell/energy_cell2" - }, - "fullness=3": { - "model": "appliedenergistics2:block/energy_cell/energy_cell3" - }, - "fullness=4": { - "model": "appliedenergistics2:block/energy_cell/energy_cell4" - }, - "fullness=5": { - "model": "appliedenergistics2:block/energy_cell/energy_cell5" - }, - "fullness=6": { - "model": "appliedenergistics2:block/energy_cell/energy_cell6" - }, - "fullness=7": { - "model": "appliedenergistics2:block/energy_cell/energy_cell7" - } + "variants": { + "fullness=0": { + "model": "appliedenergistics2:block/energy_cell/energy_cell0" + }, + "fullness=1": { + "model": "appliedenergistics2:block/energy_cell/energy_cell1" + }, + "fullness=2": { + "model": "appliedenergistics2:block/energy_cell/energy_cell2" + }, + "fullness=3": { + "model": "appliedenergistics2:block/energy_cell/energy_cell3" + }, + "fullness=4": { + "model": "appliedenergistics2:block/energy_cell/energy_cell4" + }, + "fullness=5": { + "model": "appliedenergistics2:block/energy_cell/energy_cell5" + }, + "fullness=6": { + "model": "appliedenergistics2:block/energy_cell/energy_cell6" + }, + "fullness=7": { + "model": "appliedenergistics2:block/energy_cell/energy_cell7" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/fluid_interface.json b/src/main/resources/assets/appliedenergistics2/blockstates/fluid_interface.json index b1e08d239..61156fed1 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/fluid_interface.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/fluid_interface.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/fluid_interface" - } + "variants": { + "": { + "model": "appliedenergistics2:block/fluid_interface" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_block.json b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_block.json index c83bd4036..bd9c23d63 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_block.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_block.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/fluix_block" - } + "variants": { + "": { + "model": "appliedenergistics2:block/fluix_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_slab.json index 790ca1cf9..a9d571520 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/fluix_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/fluix_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/fluix_block" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/fluix_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/fluix_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/fluix_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_stairs.json index 1170744d2..6c8341842 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/fluix_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/fluix_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/fluix_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/fluix_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/fluix", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/fluix_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/fluix_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/fluix", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/grindstone.json b/src/main/resources/assets/appliedenergistics2/blockstates/grindstone.json index 91ae54edd..5b71553cc 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/grindstone.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/grindstone.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/grindstone" - } + "variants": { + "": { + "model": "appliedenergistics2:block/grindstone" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/inscriber.json b/src/main/resources/assets/appliedenergistics2/blockstates/inscriber.json index b01560ac3..0d2a0b31a 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/inscriber.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/inscriber.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/inscriber" - } + "variants": { + "": { + "model": "appliedenergistics2:block/inscriber" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/interface.json b/src/main/resources/assets/appliedenergistics2/blockstates/interface.json index 06c15fb03..6bb628265 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/interface.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/interface.json @@ -1,11 +1,11 @@ { - "variants": { - "omnidirectional=true": { - "model": "appliedenergistics2:block/interface" - }, - "omnidirectional=false": { - "model": "appliedenergistics2:block/interface_oriented", - "x": 90 - } + "variants": { + "omnidirectional=true": { + "model": "appliedenergistics2:block/interface" + }, + "omnidirectional=false": { + "model": "appliedenergistics2:block/interface_oriented", + "x": 90 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/io_port.json b/src/main/resources/assets/appliedenergistics2/blockstates/io_port.json index dc3773ef2..ac0bcd665 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/io_port.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/io_port.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/io_port" - } + "variants": { + "": { + "model": "appliedenergistics2:block/io_port" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/light_detector.json b/src/main/resources/assets/appliedenergistics2/blockstates/light_detector.json index f0b3d7d1b..07e879d0c 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/light_detector.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/light_detector.json @@ -1,48 +1,48 @@ { - "variants": { - "facing=down,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_standing", - "x": 180 - }, - "facing=down,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_standing_odd", - "x": 180 - }, - "facing=east,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 90 - }, - "facing=east,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 90 - }, - "facing=north,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall" - }, - "facing=north,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd" - }, - "facing=south,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 180 - }, - "facing=south,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 180 - }, - "facing=up,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_standing" - }, - "facing=up,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_standing_odd" - }, - "facing=west,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 270 - }, - "facing=west,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 270 - } + "variants": { + "facing=down,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_standing", + "x": 180 + }, + "facing=down,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_standing_odd", + "x": 180 + }, + "facing=east,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 90 + }, + "facing=east,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 90 + }, + "facing=north,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall" + }, + "facing=north,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd" + }, + "facing=south,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 180 + }, + "facing=south,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 180 + }, + "facing=up,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_standing" + }, + "facing=up,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_standing_odd" + }, + "facing=west,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 270 + }, + "facing=west,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 270 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/matrix_frame.json b/src/main/resources/assets/appliedenergistics2/blockstates/matrix_frame.json index 2ff4b529f..fdb0de0fb 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/matrix_frame.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/matrix_frame.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/matrix_frame" - } + "variants": { + "": { + "model": "appliedenergistics2:block/matrix_frame" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/molecular_assembler.json b/src/main/resources/assets/appliedenergistics2/blockstates/molecular_assembler.json index 836042322..63a54e468 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/molecular_assembler.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/molecular_assembler.json @@ -1,17 +1,17 @@ { - "multipart": [ - { - "apply": { - "model":"appliedenergistics2:block/molecular_assembler" - } - }, - { - "when": { - "powered": "true" - }, - "apply": { - "model":"appliedenergistics2:block/molecular_assembler_lights" - } - } - ] -} \ No newline at end of file + "multipart": [ + { + "apply": { + "model": "appliedenergistics2:block/molecular_assembler" + } + }, + { + "when": { + "powered": "true" + }, + "apply": { + "model": "appliedenergistics2:block/molecular_assembler_lights" + } + } + ] +} diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/paint.json b/src/main/resources/assets/appliedenergistics2/blockstates/paint.json index 04148d220..7513a5dfa 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/paint.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/paint.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/paint" - } + "variants": { + "": { + "model": "appliedenergistics2:block/paint" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quantum_link.json b/src/main/resources/assets/appliedenergistics2/blockstates/quantum_link.json index 5a33a4ee0..78af36e32 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quantum_link.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quantum_link.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/qnb/link" - }, - "formed=true": { - "model": "appliedenergistics2:block/qnb/qnb_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/qnb/link" + }, + "formed=true": { + "model": "appliedenergistics2:block/qnb/qnb_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quantum_ring.json b/src/main/resources/assets/appliedenergistics2/blockstates/quantum_ring.json index bc1d9c668..39dfab988 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quantum_ring.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quantum_ring.json @@ -1,10 +1,10 @@ { - "variants": { - "formed=false": { - "model": "appliedenergistics2:block/qnb/ring" - }, - "formed=true": { - "model": "appliedenergistics2:block/qnb/qnb_formed" - } + "variants": { + "formed=false": { + "model": "appliedenergistics2:block/qnb/ring" + }, + "formed=true": { + "model": "appliedenergistics2:block/qnb/qnb_formed" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_block.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_block.json index b8cc07c82..c9941eabc 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_block.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/quartz_block" - } + "variants": { + "": { + "model": "appliedenergistics2:block/quartz_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_fixture.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_fixture.json index f0b3d7d1b..07e879d0c 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_fixture.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_fixture.json @@ -1,48 +1,48 @@ { - "variants": { - "facing=down,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_standing", - "x": 180 - }, - "facing=down,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_standing_odd", - "x": 180 - }, - "facing=east,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 90 - }, - "facing=east,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 90 - }, - "facing=north,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall" - }, - "facing=north,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd" - }, - "facing=south,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 180 - }, - "facing=south,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 180 - }, - "facing=up,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_standing" - }, - "facing=up,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_standing_odd" - }, - "facing=west,odd=false": { - "model": "appliedenergistics2:block/quartz_fixture_wall", - "y": 270 - }, - "facing=west,odd=true": { - "model": "appliedenergistics2:block/quartz_fixture_wall_odd", - "y": 270 - } + "variants": { + "facing=down,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_standing", + "x": 180 + }, + "facing=down,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_standing_odd", + "x": 180 + }, + "facing=east,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 90 + }, + "facing=east,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 90 + }, + "facing=north,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall" + }, + "facing=north,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd" + }, + "facing=south,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 180 + }, + "facing=south,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 180 + }, + "facing=up,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_standing" + }, + "facing=up,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_standing_odd" + }, + "facing=west,odd=false": { + "model": "appliedenergistics2:block/quartz_fixture_wall", + "y": 270 + }, + "facing=west,odd=true": { + "model": "appliedenergistics2:block/quartz_fixture_wall_odd", + "y": 270 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_glass.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_glass.json index 192e6acad..cd40f5b31 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_glass.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_glass.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/quartz_glass" - } + "variants": { + "": { + "model": "appliedenergistics2:block/quartz_glass" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_growth_accelerator.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_growth_accelerator.json index 4eaeb0fe6..ac031dea5 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_growth_accelerator.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_growth_accelerator.json @@ -1,10 +1,10 @@ { - "variants": { - "powered=false": { - "model": "appliedenergistics2:block/quartz_growth_accelerator_off" - }, - "powered=true": { - "model": "appliedenergistics2:block/quartz_growth_accelerator_on" - } + "variants": { + "powered=false": { + "model": "appliedenergistics2:block/quartz_growth_accelerator_off" + }, + "powered=true": { + "model": "appliedenergistics2:block/quartz_growth_accelerator_on" } -} \ No newline at end of file + } +} diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_ore.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_ore.json index bd6616b07..ec64f33da 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_ore.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/quartz_ore" - } + "variants": { + "": { + "model": "appliedenergistics2:block/quartz_ore" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar.json index 32e5afe25..ff4e5a20c 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar.json @@ -1,16 +1,16 @@ { - "variants": { - "axis=x": { - "model": "appliedenergistics2:block/quartz_pillar", - "x": 90, - "y": 90 - }, - "axis=y": { - "model": "appliedenergistics2:block/quartz_pillar" - }, - "axis=z": { - "model": "appliedenergistics2:block/quartz_pillar", - "x": 90 - } + "variants": { + "axis=x": { + "model": "appliedenergistics2:block/quartz_pillar", + "x": 90, + "y": 90 + }, + "axis=y": { + "model": "appliedenergistics2:block/quartz_pillar" + }, + "axis=z": { + "model": "appliedenergistics2:block/quartz_pillar", + "x": 90 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_slab.json index d16cdcf75..6477bd6ee 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/quartz_pillar_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/quartz_pillar_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/quartz_pillar" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/quartz_pillar_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/quartz_pillar_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/quartz_pillar" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_stairs.json index 9d749ae54..155469cce 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_pillar_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz_pillar", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_pillar_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz_pillar", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_slab.json index 513938ac7..79984c802 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/quartz_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/quartz_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/quartz_block" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/quartz_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/quartz_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/quartz_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_stairs.json index df6112e62..f519c5a16 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/quartz_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/quartz_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/quartz", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/quartz_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/quartz_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/quartz", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_vibrant_glass.json b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_vibrant_glass.json index 192e6acad..cd40f5b31 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/quartz_vibrant_glass.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/quartz_vibrant_glass.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/quartz_glass" - } + "variants": { + "": { + "model": "appliedenergistics2:block/quartz_glass" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json b/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json index f30c3434b..5bdbd9407 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json @@ -1,10 +1,10 @@ { - "variants": { - "powered=false": { - "model": "appliedenergistics2:block/security_station_off" - }, - "powered=true": { - "model": "appliedenergistics2:block/security_station_on" - } + "variants": { + "powered=false": { + "model": "appliedenergistics2:block/security_station_off" + }, + "powered=true": { + "model": "appliedenergistics2:block/security_station_on" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_compass.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_compass.json index 17de66dd5..3873f7c9f 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_compass.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_compass.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/sky_compass" - } + "variants": { + "": { + "model": "appliedenergistics2:block/sky_compass" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_block.json index 15bc9cddc..6f8238e6b 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_block.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/sky_stone_block" - } + "variants": { + "": { + "model": "appliedenergistics2:block/sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick.json index 908b32a45..3623cc1ac 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/sky_stone_brick" - } + "variants": { + "": { + "model": "appliedenergistics2:block/sky_stone_brick" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_slab.json index 786e19447..309b215bc 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/sky_stone_brick_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/sky_stone_brick_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/sky_stone_brick" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/sky_stone_brick_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/sky_stone_brick_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/sky_stone_brick" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_stairs.json index e55d3006c..5504bf19d 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_brick_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_brick", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_brick", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_chest.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_chest.json index a5d3a6c14..e245407cd 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_chest.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_chest.json @@ -1,8 +1,8 @@ { - "__comment": "This block is rendered via TESR, so this is only used for the particle texture.", - "variants": { - "": { - "model": "appliedenergistics2:block/sky_stone_block" - } + "__comment": "This block is rendered via TESR, so this is only used for the particle texture.", + "variants": { + "": { + "model": "appliedenergistics2:block/sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_slab.json index e18be9227..dc428d791 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/sky_stone_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/sky_stone_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/sky_stone_block" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/sky_stone_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/sky_stone_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick.json index 1222245a1..b460a84d4 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/sky_stone_small_brick" - } + "variants": { + "": { + "model": "appliedenergistics2:block/sky_stone_small_brick" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_slab.json index db90e6b7a..0bec18eeb 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/sky_stone_small_brick_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/sky_stone_small_brick_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/sky_stone_small_brick" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/sky_stone_small_brick_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/sky_stone_small_brick_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/sky_stone_small_brick" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_stairs.json index a81254511..df798d41a 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_small_brick_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone_small_brick", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_stairs.json index 5e9679d41..6defb848d 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/sky_stone_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/sky_stone", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/sky_stone", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_block.json index e32e20c17..4babd395b 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_block.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/smooth_sky_stone_block" - } + "variants": { + "": { + "model": "appliedenergistics2:block/smooth_sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_chest.json b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_chest.json index fd9121b62..ba39044e5 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_chest.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_chest.json @@ -1,8 +1,8 @@ { - "__comment": "This block is rendered via TESR, so this is only used for the particle texture.", - "variants": { - "": { - "model": "appliedenergistics2:block/smooth_sky_stone_block" - } + "__comment": "This block is rendered via TESR, so this is only used for the particle texture.", + "variants": { + "": { + "model": "appliedenergistics2:block/smooth_sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_slab.json b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_slab.json index a233f90b8..9aefbb9c5 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_slab.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_slab.json @@ -1,13 +1,13 @@ { - "variants": { - "type=bottom": { - "model": "appliedenergistics2:block/slabs/smooth_sky_stone_half" - }, - "type=top": { - "model": "appliedenergistics2:block/slabs/smooth_sky_stone_upper" - }, - "type=double": { - "model": "appliedenergistics2:block/smooth_sky_stone_block" - } + "variants": { + "type=bottom": { + "model": "appliedenergistics2:block/slabs/smooth_sky_stone_half" + }, + "type=top": { + "model": "appliedenergistics2:block/slabs/smooth_sky_stone_upper" + }, + "type=double": { + "model": "appliedenergistics2:block/smooth_sky_stone_block" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_stairs.json b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_stairs.json index ebbab6f09..657137f63 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/smooth_sky_stone_stairs.json @@ -1,209 +1,209 @@ { - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer" - }, - "facing=east,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone" - }, - "facing=east,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "appliedenergistics2:block/stairs/smooth_sky_stone", - "uvlock": true, - "x": 180, - "y": 180 - } + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer" + }, + "facing=east,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone" + }, + "facing=east,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_inner", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone_outer", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "appliedenergistics2:block/stairs/smooth_sky_stone", + "uvlock": true, + "x": 180, + "y": 180 } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/spatial_io_port.json b/src/main/resources/assets/appliedenergistics2/blockstates/spatial_io_port.json index 9ef3ea6f1..f43ce7569 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/spatial_io_port.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/spatial_io_port.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/spatial_io_port" - } + "variants": { + "": { + "model": "appliedenergistics2:block/spatial_io_port" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/spatial_pylon.json b/src/main/resources/assets/appliedenergistics2/blockstates/spatial_pylon.json index 3c4661405..f38c0cf74 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/spatial_pylon.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/spatial_pylon.json @@ -4,4 +4,4 @@ "model": "appliedenergistics2:block/spatial_pylon" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/tiny_tnt.json b/src/main/resources/assets/appliedenergistics2/blockstates/tiny_tnt.json index 636e542e4..3dc4109c9 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/tiny_tnt.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/tiny_tnt.json @@ -1,7 +1,7 @@ { - "variants": { - "": { - "model": "appliedenergistics2:block/tiny_tnt" - } + "variants": { + "": { + "model": "appliedenergistics2:block/tiny_tnt" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/vibration_chamber.json b/src/main/resources/assets/appliedenergistics2/blockstates/vibration_chamber.json index 496f66ad5..3320e9512 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/vibration_chamber.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/vibration_chamber.json @@ -1,10 +1,10 @@ { - "variants": { - "active=false": { - "model": "appliedenergistics2:block/vibration_chamber_off" - }, - "active=true": { - "model": "appliedenergistics2:block/vibration_chamber_on" - } + "variants": { + "active=false": { + "model": "appliedenergistics2:block/vibration_chamber_off" + }, + "active=true": { + "model": "appliedenergistics2:block/vibration_chamber_on" } + } } diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/wireless_access_point.json b/src/main/resources/assets/appliedenergistics2/blockstates/wireless_access_point.json index 75c772c11..98541d4e3 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/wireless_access_point.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/wireless_access_point.json @@ -1,55 +1,55 @@ { - "multipart": [ - { - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_chassis", - "y": 180 - } - }, - { - "when": { - "state": "off" - }, - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_status_off", - "y": 180 - } - }, - { - "when": { - "state": "off|on" - }, - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_off", - "y": 180 - } - }, - { - "when": { - "state": "on" - }, - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_status_on", - "y": 180 - } - }, - { - "when": { - "state": "has_channel" - }, - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_on", - "y": 180 - } - }, - { - "when": { - "state": "has_channel" - }, - "apply": { - "model": "appliedenergistics2:block/wireless_access_point_status_has_channel", - "y": 180 - } - } - ] + "multipart": [ + { + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_chassis", + "y": 180 + } + }, + { + "when": { + "state": "off" + }, + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_status_off", + "y": 180 + } + }, + { + "when": { + "state": "off|on" + }, + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_off", + "y": 180 + } + }, + { + "when": { + "state": "on" + }, + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_status_on", + "y": 180 + } + }, + { + "when": { + "state": "has_channel" + }, + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_on", + "y": 180 + } + }, + { + "when": { + "state": "has_channel" + }, + "apply": { + "model": "appliedenergistics2:block/wireless_access_point_status_has_channel", + "y": 180 + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/lang/cs_cz.json b/src/main/resources/assets/appliedenergistics2/lang/cs_cz.json index a89fb8f21..ec554de8c 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/cs_cz.json +++ b/src/main/resources/assets/appliedenergistics2/lang/cs_cz.json @@ -575,4 +575,4 @@ "waila.appliedenergistics2.Locked": "Zamčeno", "waila.appliedenergistics2.Showing": "Zobrazuje", "waila.appliedenergistics2.Unlocked": "Odemčeno" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/de_de.json b/src/main/resources/assets/appliedenergistics2/lang/de_de.json index faa015061..6342d821e 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/de_de.json +++ b/src/main/resources/assets/appliedenergistics2/lang/de_de.json @@ -614,4 +614,4 @@ "waila.appliedenergistics2.Locked": "Gesperrt", "waila.appliedenergistics2.Showing": "Zeigt", "waila.appliedenergistics2.Unlocked": "Entsperrt" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_gb.json b/src/main/resources/assets/appliedenergistics2/lang/en_gb.json index caef46a8b..9b534cb5e 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_gb.json +++ b/src/main/resources/assets/appliedenergistics2/lang/en_gb.json @@ -7,4 +7,4 @@ "gui.tooltips.appliedenergistics2.TerminalStyle_Small": "Small Centered Terminal", "gui.tooltips.appliedenergistics2.TerminalStyle_Tall": "Tall Centered Terminal", "item.appliedenergistics2.color_applicator": "Colour Applicator" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_us.json b/src/main/resources/assets/appliedenergistics2/lang/en_us.json index 9a46c2e73..f6e759fb3 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_us.json +++ b/src/main/resources/assets/appliedenergistics2/lang/en_us.json @@ -707,4 +707,4 @@ "waila.appliedenergistics2.P2PUnlinked": "Unlinked", "waila.appliedenergistics2.Showing": "Showing", "waila.appliedenergistics2.Unlocked": "Unlocked" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/es_es.json b/src/main/resources/assets/appliedenergistics2/lang/es_es.json index 12682fba6..ad81433ff 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/es_es.json +++ b/src/main/resources/assets/appliedenergistics2/lang/es_es.json @@ -499,4 +499,4 @@ "waila.appliedenergistics2.Locked": "Bloqueado", "waila.appliedenergistics2.Showing": "Mostrando", "waila.appliedenergistics2.Unlocked": "Desbloqueado" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/fr_fr.json b/src/main/resources/assets/appliedenergistics2/lang/fr_fr.json index 1cf524c8d..0d3361e8c 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/fr_fr.json +++ b/src/main/resources/assets/appliedenergistics2/lang/fr_fr.json @@ -611,4 +611,4 @@ "waila.appliedenergistics2.Locked": "Verrouillé", "waila.appliedenergistics2.Showing": "Affichant", "waila.appliedenergistics2.Unlocked": "Déverrouillé" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/hu_hu.json b/src/main/resources/assets/appliedenergistics2/lang/hu_hu.json index 99be99141..2439cb022 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/hu_hu.json +++ b/src/main/resources/assets/appliedenergistics2/lang/hu_hu.json @@ -522,4 +522,4 @@ "waila.appliedenergistics2.Locked": "Zárolva", "waila.appliedenergistics2.Showing": "Mutatott tárgy", "waila.appliedenergistics2.Unlocked": "Feloldva" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/it_it.json b/src/main/resources/assets/appliedenergistics2/lang/it_it.json index 14d237eb4..6c2497a89 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/it_it.json +++ b/src/main/resources/assets/appliedenergistics2/lang/it_it.json @@ -595,4 +595,4 @@ "waila.appliedenergistics2.Locked": "Bloccato", "waila.appliedenergistics2.Showing": "Mostra", "waila.appliedenergistics2.Unlocked": "Sbloccato" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/ko_kr.json b/src/main/resources/assets/appliedenergistics2/lang/ko_kr.json index 79a43042e..1c58c7a8a 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/ko_kr.json +++ b/src/main/resources/assets/appliedenergistics2/lang/ko_kr.json @@ -674,4 +674,4 @@ "waila.appliedenergistics2.P2PUnlinked": "접속 안됨", "waila.appliedenergistics2.Showing": "공개", "waila.appliedenergistics2.Unlocked": "잠겨있지 않음" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/pt_br.json b/src/main/resources/assets/appliedenergistics2/lang/pt_br.json index 3ca2735c9..839e3200d 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/pt_br.json +++ b/src/main/resources/assets/appliedenergistics2/lang/pt_br.json @@ -664,4 +664,4 @@ "waila.appliedenergistics2.P2PUnlinked": "Desconectado", "waila.appliedenergistics2.Showing": "Mostrando", "waila.appliedenergistics2.Unlocked": "Destrancado" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/ro_ro.json b/src/main/resources/assets/appliedenergistics2/lang/ro_ro.json index f68667d56..453632f58 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/ro_ro.json +++ b/src/main/resources/assets/appliedenergistics2/lang/ro_ro.json @@ -388,4 +388,4 @@ "waila.appliedenergistics2.Showing": "Arătând", "waila.appliedenergistics2.Unlocked": "Deschis", "tile.appliedenergistics2.cable_bus.name": "Cabluri AE2 şi/sau Punct" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/ru_ru.json b/src/main/resources/assets/appliedenergistics2/lang/ru_ru.json index e7db18365..9e98943ea 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/ru_ru.json +++ b/src/main/resources/assets/appliedenergistics2/lang/ru_ru.json @@ -663,4 +663,4 @@ "waila.appliedenergistics2.P2PUnlinked": "Не связанный", "waila.appliedenergistics2.Showing": "Показывает", "waila.appliedenergistics2.Unlocked": "Разблокировано" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/zh_cn.json b/src/main/resources/assets/appliedenergistics2/lang/zh_cn.json index fe9815ec2..ce50ff308 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/zh_cn.json +++ b/src/main/resources/assets/appliedenergistics2/lang/zh_cn.json @@ -696,4 +696,4 @@ "waila.appliedenergistics2.P2PUnlinked": "未连接", "waila.appliedenergistics2.Showing": "显示", "waila.appliedenergistics2.Unlocked": "未锁定" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/lang/zh_tw.json b/src/main/resources/assets/appliedenergistics2/lang/zh_tw.json index 9cac71f67..d95271f4f 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/zh_tw.json +++ b/src/main/resources/assets/appliedenergistics2/lang/zh_tw.json @@ -663,4 +663,4 @@ "waila.appliedenergistics2.P2PUnlinked": "未連接", "waila.appliedenergistics2.Showing": "顯示", "waila.appliedenergistics2.Unlocked": "未鎖定" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json b/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json index 74212b3bf..cebc3216b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:cable_bus" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cell_workbench.json b/src/main/resources/assets/appliedenergistics2/models/block/cell_workbench.json index 255ad9496..9ef181048 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cell_workbench.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cell_workbench.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae_bottom_top", - "textures": { - "bottom": "appliedenergistics2:block/cell_workbench_bottom", - "side": "appliedenergistics2:block/cell_workbench_side", - "top": "appliedenergistics2:block/cell_workbench" - } + "parent": "appliedenergistics2:block/cube/cube_ae_bottom_top", + "textures": { + "bottom": "appliedenergistics2:block/cell_workbench_bottom", + "side": "appliedenergistics2:block/cell_workbench_side", + "top": "appliedenergistics2:block/cell_workbench" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/charged_quartz_ore.json b/src/main/resources/assets/appliedenergistics2/models/block/charged_quartz_ore.json index a399edae4..6d593a952 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/charged_quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/charged_quartz_ore.json @@ -1,106 +1,96 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "block": "block/stone", - "quartz": "appliedenergistics2:block/charged_quartz_ore_light", - "particle": "appliedenergistics2:block/charged_quartz_ore" - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#block", "cullface": "down" - }, - "east": { - "texture": "#block", "cullface": "east" - }, - "north": { - "texture": "#block", "cullface": "north" - }, - "south": { - "texture": "#block", "cullface": "south" - }, - "up": { - "texture": "#block", "cullface": "up" - }, - "west": { - "texture": "#block", "cullface": "west" - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "block": "block/stone", + "quartz": "appliedenergistics2:block/charged_quartz_ore_light", + "particle": "appliedenergistics2:block/charged_quartz_ore" + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#block", + "cullface": "down" }, - { - "faces": { - "down": { - "texture": "#quartz", - "cullface": "down", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "east": { - "texture": "#quartz", - "cullface": "east", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "north": { - "texture": "#quartz", - "cullface": "north", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "south": { - "texture": "#quartz", - "cullface": "south", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "up": { - "texture": "#quartz", - "cullface": "up", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "west": { - "texture": "#quartz", - "cullface": "west", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": true, - "to": [ - 16, - 16, - 16 - ] + "east": { + "texture": "#block", + "cullface": "east" + }, + "north": { + "texture": "#block", + "cullface": "north" + }, + "south": { + "texture": "#block", + "cullface": "south" + }, + "up": { + "texture": "#block", + "cullface": "up" + }, + "west": { + "texture": "#block", + "cullface": "west" } - ] + }, + "from": [0, 0, 0], + "to": [16, 16, 16] + }, + { + "faces": { + "down": { + "texture": "#quartz", + "cullface": "down", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "east": { + "texture": "#quartz", + "cullface": "east", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "north": { + "texture": "#quartz", + "cullface": "north", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "south": { + "texture": "#quartz", + "cullface": "south", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "up": { + "texture": "#quartz", + "cullface": "up", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "west": { + "texture": "#quartz", + "cullface": "west", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + }, + "from": [0, 0, 0], + "shade": true, + "to": [16, 16, 16] + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/charger.json b/src/main/resources/assets/appliedenergistics2/models/block/charger.json index 6cafa237b..f7423ec7e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/charger.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/charger.json @@ -1,359 +1,169 @@ { - "parent": "block/orientable", - "textures": { - "particle": "appliedenergistics2:block/charger", - "side": "appliedenergistics2:block/charger_side", - "top": "appliedenergistics2:block/charger", - "inside": "appliedenergistics2:block/charger_inside" - }, - "elements": [ - { - "name": "back", - "from": [ - 6, - 1, - 14 - ], - "to": [ - 10, - 15, - 16 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 6, - 14, - 10, - 16 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 0, - 1, - 2, - 15 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 6, - 1, - 10, - 15 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 6, - 1, - 10, - 15 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 6, - 14, - 10, - 16 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 14, - 1, - 16, - 15 - ] - } - } + "parent": "block/orientable", + "textures": { + "particle": "appliedenergistics2:block/charger", + "side": "appliedenergistics2:block/charger_side", + "top": "appliedenergistics2:block/charger", + "inside": "appliedenergistics2:block/charger_inside" + }, + "elements": [ + { + "name": "back", + "from": [6, 1, 14], + "to": [10, 15, 16], + "faces": { + "down": { + "texture": "#side", + "uv": [6, 14, 10, 16] }, - { - "name": "bottom", - "from": [ - 2, - 0, - 2 - ], - "to": [ - 14, - 3, - 14 - ], - "shade": false, - "faces": { - "down": { - "texture": "#top", - "uv": [ - 2, - 2, - 14, - 14 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 2, - 13, - 14, - 16 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 2, - 13, - 14, - 16 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 2, - 13, - 14, - 16 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 2, - 2, - 14, - 14 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 2, - 13, - 14, - 16 - ] - } - } + "east": { + "texture": "#side", + "uv": [0, 1, 2, 15] }, - { - "name": "top", - "from": [ - 2, - 13, - 2 - ], - "to": [ - 14, - 16, - 14 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 2, - 2, - 14, - 14 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 2, - 0, - 14, - 3 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 2, - 0, - 14, - 3 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 2, - 0, - 14, - 3 - ] - }, - "up": { - "texture": "#top", - "uv": [ - 2, - 2, - 14, - 14 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 2, - 0, - 14, - 3 - ] - } - } + "north": { + "texture": "#side", + "uv": [6, 1, 10, 15] }, - { - "name": "inside-bottom", - "from": [ - 3, - 3, - 3 - ], - "to": [ - 13, - 4, - 13 - ], - "shade": false, - "faces": { - "down": { - "texture": "#inside", - "uv": [ - 3, - 3, - 13, - 13 - ] - }, - "east": { - "texture": "#inside", - "uv": [ - 3, - 15, - 13, - 16 - ] - }, - "north": { - "texture": "#inside", - "uv": [ - 3, - 15, - 13, - 16 - ] - }, - "south": { - "texture": "#inside", - "uv": [ - 3, - 15, - 13, - 16 - ] - }, - "up": { - "texture": "#inside", - "uv": [ - 3, - 3, - 13, - 13 - ] - }, - "west": { - "texture": "#inside", - "uv": [ - 3, - 15, - 13, - 16 - ] - } - } + "south": { + "texture": "#side", + "uv": [6, 1, 10, 15] }, - { - "name": "inside-top", - "from": [ - 3, - 12, - 3 - ], - "to": [ - 13, - 13, - 13 - ], - "shade": false, - "faces": { - "down": { - "texture": "#inside", - "uv": [ - 3, - 3, - 13, - 13 - ] - }, - "east": { - "texture": "#inside", - "uv": [ - 3, - 0, - 13, - 1 - ] - }, - "north": { - "texture": "#inside", - "uv": [ - 3, - 0, - 13, - 1 - ] - }, - "south": { - "texture": "#inside", - "uv": [ - 3, - 0, - 13, - 1 - ] - }, - "up": { - "texture": "#inside", - "uv": [ - 3, - 3, - 13, - 13 - ] - }, - "west": { - "texture": "#inside", - "uv": [ - 3, - 0, - 13, - 1 - ] - } - } + "up": { + "texture": "#side", + "uv": [6, 14, 10, 16] + }, + "west": { + "texture": "#side", + "uv": [14, 1, 16, 15] } - ] + } + }, + { + "name": "bottom", + "from": [2, 0, 2], + "to": [14, 3, 14], + "shade": false, + "faces": { + "down": { + "texture": "#top", + "uv": [2, 2, 14, 14] + }, + "east": { + "texture": "#side", + "uv": [2, 13, 14, 16] + }, + "north": { + "texture": "#side", + "uv": [2, 13, 14, 16] + }, + "south": { + "texture": "#side", + "uv": [2, 13, 14, 16] + }, + "up": { + "texture": "#side", + "uv": [2, 2, 14, 14] + }, + "west": { + "texture": "#side", + "uv": [2, 13, 14, 16] + } + } + }, + { + "name": "top", + "from": [2, 13, 2], + "to": [14, 16, 14], + "faces": { + "down": { + "texture": "#side", + "uv": [2, 2, 14, 14] + }, + "east": { + "texture": "#side", + "uv": [2, 0, 14, 3] + }, + "north": { + "texture": "#side", + "uv": [2, 0, 14, 3] + }, + "south": { + "texture": "#side", + "uv": [2, 0, 14, 3] + }, + "up": { + "texture": "#top", + "uv": [2, 2, 14, 14] + }, + "west": { + "texture": "#side", + "uv": [2, 0, 14, 3] + } + } + }, + { + "name": "inside-bottom", + "from": [3, 3, 3], + "to": [13, 4, 13], + "shade": false, + "faces": { + "down": { + "texture": "#inside", + "uv": [3, 3, 13, 13] + }, + "east": { + "texture": "#inside", + "uv": [3, 15, 13, 16] + }, + "north": { + "texture": "#inside", + "uv": [3, 15, 13, 16] + }, + "south": { + "texture": "#inside", + "uv": [3, 15, 13, 16] + }, + "up": { + "texture": "#inside", + "uv": [3, 3, 13, 13] + }, + "west": { + "texture": "#inside", + "uv": [3, 15, 13, 16] + } + } + }, + { + "name": "inside-top", + "from": [3, 12, 3], + "to": [13, 13, 13], + "shade": false, + "faces": { + "down": { + "texture": "#inside", + "uv": [3, 3, 13, 13] + }, + "east": { + "texture": "#inside", + "uv": [3, 0, 13, 1] + }, + "north": { + "texture": "#inside", + "uv": [3, 0, 13, 1] + }, + "south": { + "texture": "#inside", + "uv": [3, 0, 13, 1] + }, + "up": { + "texture": "#inside", + "uv": [3, 3, 13, 13] + }, + "west": { + "texture": "#inside", + "uv": [3, 0, 13, 1] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json index 49e3723f5..88dc5b2a4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json @@ -1,12 +1,12 @@ { - "parent": "block/cube", - "textures": { - "particle": "appliedenergistics2:block/chest/side", - "up": "appliedenergistics2:block/chest/top", - "down": "appliedenergistics2:block/chest/bottom", - "north": "appliedenergistics2:block/chest/front", - "east": "appliedenergistics2:block/chest/side", - "south": "appliedenergistics2:block/chest/side", - "west": "appliedenergistics2:block/chest/side" - } + "parent": "block/cube", + "textures": { + "particle": "appliedenergistics2:block/chest/side", + "up": "appliedenergistics2:block/chest/top", + "down": "appliedenergistics2:block/chest/bottom", + "north": "appliedenergistics2:block/chest/front", + "east": "appliedenergistics2:block/chest/side", + "south": "appliedenergistics2:block/chest/side", + "west": "appliedenergistics2:block/chest/side" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json index 1485d55a5..72239d88d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json @@ -1,24 +1,16 @@ { - "textures": { - "state": "appliedenergistics2:block/chest/cell_state_empty" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#state" - } - } + "textures": { + "state": "appliedenergistics2:block/chest/cell_state_empty" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#state" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json index 26c41cbe0..a5517ce02 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json @@ -1,47 +1,31 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", - "state": "appliedenergistics2:block/chest/cell_state_full" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#backdrop" - } - } - }, - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#state", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", + "state": "appliedenergistics2:block/chest/cell_state_full" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#backdrop" } - ] + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#state", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json index 2cd3b0655..800895391 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json @@ -1,24 +1,16 @@ { - "textures": { - "state": "appliedenergistics2:block/chest/cell_state_offline" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#state" - } - } + "textures": { + "state": "appliedenergistics2:block/chest/cell_state_offline" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#state" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json index 08d6ac364..5589251f0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json @@ -1,47 +1,31 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", - "state": "appliedenergistics2:block/chest/cell_state_online" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#backdrop" - } - } - }, - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#state", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", + "state": "appliedenergistics2:block/chest/cell_state_online" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#backdrop" } - ] + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#state", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json index 220d1646c..fd0dd2185 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json @@ -1,47 +1,31 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", - "state": "appliedenergistics2:block/chest/cell_state_types_full" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#backdrop" - } - } - }, - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "north": { - "texture": "#state", - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "backdrop": "appliedenergistics2:block/chest/cell_state_backdrop", + "state": "appliedenergistics2:block/chest/cell_state_types_full" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#backdrop" } - ] + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "texture": "#state", + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json index c61f31831..1b4acd7ef 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json @@ -1,25 +1,17 @@ { - "textures": { - "lights": "appliedenergistics2:block/chest/lights_off" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lights", - "tintindex": 3 - } - } + "textures": { + "lights": "appliedenergistics2:block/chest/lights_off" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lights", + "tintindex": 3 } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json index 9421cf08f..121d8258e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lights_bright": "appliedenergistics2:block/chest/lights_on_bright", - "lights_medium": "appliedenergistics2:block/chest/lights_on_medium", - "lights_dark": "appliedenergistics2:block/chest/lights_on_dark" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lights_bright", - "tintindex": 3, - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } - }, - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lights_medium", - "tintindex": 2, - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } - }, - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lights_dark", - "tintindex": 1, - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lights_bright": "appliedenergistics2:block/chest/lights_on_bright", + "lights_medium": "appliedenergistics2:block/chest/lights_on_medium", + "lights_dark": "appliedenergistics2:block/chest/lights_on_dark" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lights_bright", + "tintindex": 3, + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } } - ] + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lights_medium", + "tintindex": 2, + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lights_dark", + "tintindex": 1, + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chiseled_quartz_block.json b/src/main/resources/assets/appliedenergistics2/models/block/chiseled_quartz_block.json index d50b99aba..a229e1c26 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/chiseled_quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/chiseled_quartz_block.json @@ -1,7 +1,7 @@ { - "parent": "block/cube_column", - "textures": { - "end": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side" - } + "parent": "block/cube_column", + "textures": { + "end": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/condenser.json b/src/main/resources/assets/appliedenergistics2/models/block/condenser.json index 505a9a325..433d3fa30 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/condenser.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/condenser.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/condenser" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/condenser" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_conflicted.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_conflicted.json index 02559548c..0038cf7a1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_conflicted.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_conflicted.json @@ -1,172 +1,96 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "block": "appliedenergistics2:block/controller_powered", - "lights": "appliedenergistics2:block/controller_conflict", - "particle": "appliedenergistics2:block/controller" - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "east": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "north": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "south": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "up": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "west": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": false, - "to": [ - 16, - 16, - 16 - ] + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "block": "appliedenergistics2:block/controller_powered", + "lights": "appliedenergistics2:block/controller_conflict", + "particle": "appliedenergistics2:block/controller" + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } }, - { - "faces": { - "down": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "east": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "north": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "south": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "up": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "west": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] + "east": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "north": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "south": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "up": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "west": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } } - ] + }, + "from": [0, 0, 0], + "shade": false, + "to": [16, 16, 16] + }, + { + "faces": { + "down": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "east": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "north": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "south": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "up": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "west": { + "texture": "#block", + "uv": [0, 0, 16, 16] + } + }, + "from": [0, 0, 0], + "to": [16, 16, 16] + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_offline.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_offline.json index 586ca4249..d15526c77 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_offline.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_offline.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/controller" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/controller" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_online.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_online.json index 454db7b48..0ed472fd0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_online.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_block_online.json @@ -1,172 +1,96 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "block": "appliedenergistics2:block/controller_powered", - "lights": "appliedenergistics2:block/controller_lights", - "particle": "appliedenergistics2:block/controller" - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "east": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "north": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "south": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "up": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "west": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": false, - "to": [ - 16, - 16, - 16 - ] + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "block": "appliedenergistics2:block/controller_powered", + "lights": "appliedenergistics2:block/controller_lights", + "particle": "appliedenergistics2:block/controller" + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } }, - { - "faces": { - "down": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "east": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "north": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "south": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "up": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "west": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] + "east": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "north": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "south": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "up": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "west": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } } - ] + }, + "from": [0, 0, 0], + "shade": false, + "to": [16, 16, 16] + }, + { + "faces": { + "down": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "east": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "north": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "south": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "up": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "west": { + "texture": "#block", + "uv": [0, 0, 16, 16] + } + }, + "from": [0, 0, 0], + "to": [16, 16, 16] + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_conflicted.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_conflicted.json index d2a8d0aff..50e506dfd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_conflicted.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_conflicted.json @@ -1,172 +1,96 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "block": "appliedenergistics2:block/controller_column_powered", - "lights": "appliedenergistics2:block/controller_column_conflict", - "particle": "appliedenergistics2:block/controller" - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "east": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "north": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "south": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "up": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "west": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": false, - "to": [ - 16, - 16, - 16 - ] + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "block": "appliedenergistics2:block/controller_column_powered", + "lights": "appliedenergistics2:block/controller_column_conflict", + "particle": "appliedenergistics2:block/controller" + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } }, - { - "faces": { - "down": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "east": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "north": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "south": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "up": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "west": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] + "east": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "north": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "south": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "up": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "west": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } } - ] + }, + "from": [0, 0, 0], + "shade": false, + "to": [16, 16, 16] + }, + { + "faces": { + "down": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "east": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "north": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "south": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "up": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "west": { + "texture": "#block", + "uv": [0, 0, 16, 16] + } + }, + "from": [0, 0, 0], + "to": [16, 16, 16] + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_offline.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_offline.json index 14991305e..0b1bb1acc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_offline.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_offline.json @@ -1,7 +1,7 @@ { - "parent": "block/cube_column", - "textures": { - "side": "appliedenergistics2:block/controller_column", - "end": "appliedenergistics2:block/controller" - } + "parent": "block/cube_column", + "textures": { + "side": "appliedenergistics2:block/controller_column", + "end": "appliedenergistics2:block/controller" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_online.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_online.json index d949fe663..9b7c7527f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_online.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_column_online.json @@ -1,172 +1,96 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "block": "appliedenergistics2:block/controller_column_powered", - "lights": "appliedenergistics2:block/controller_column_lights", - "particle": "appliedenergistics2:block/controller" - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "east": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "north": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "south": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "up": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - }, - "west": { - "texture": "#lights", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "block": 0.007, - "sky": 0.007 - } - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": false, - "to": [ - 16, - 16, - 16 - ] + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "block": "appliedenergistics2:block/controller_column_powered", + "lights": "appliedenergistics2:block/controller_column_lights", + "particle": "appliedenergistics2:block/controller" + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } }, - { - "faces": { - "down": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "east": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "north": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "south": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "up": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "west": { - "texture": "#block", - "uv": [ - 0, - 0, - 16, - 16 - ] - } - }, - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ] + "east": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "north": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "south": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "up": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } + }, + "west": { + "texture": "#lights", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "block": 0.007, + "sky": 0.007 + } } - ] + }, + "from": [0, 0, 0], + "shade": false, + "to": [16, 16, 16] + }, + { + "faces": { + "down": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "east": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "north": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "south": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "up": { + "texture": "#block", + "uv": [0, 0, 16, 16] + }, + "west": { + "texture": "#block", + "uv": [0, 0, 16, 16] + } + }, + "from": [0, 0, 0], + "to": [16, 16, 16] + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_a.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_a.json index d2446afad..430757565 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_a.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_a.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/controller_inside_a" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/controller_inside_a" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_b.json b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_b.json index dc901411f..6b0684c49 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_b.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/controller/controller_inside_b.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/controller_inside_b" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/controller_inside_b" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage.json index 9afc55271..9eedea3f3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/16k_storage" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/16k_storage" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage_formed.json index 107c51c1a..4460f9c0d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/16k_storage_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "storage_16k" + "loader": "appliedenergistics2:crafting_cube", + "type": "storage_16k" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage.json index 84c8eb923..7da0787df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/1k_storage" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/1k_storage" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage_formed.json index 435dc6270..17ed98db2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/1k_storage_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "storage_1k" + "loader": "appliedenergistics2:crafting_cube", + "type": "storage_1k" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage.json index 8ddc0c522..62b34dec9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/4k_storage" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/4k_storage" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage_formed.json index 8dffca4e6..b2961fa9e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/4k_storage_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "storage_4k" + "loader": "appliedenergistics2:crafting_cube", + "type": "storage_4k" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage.json index a1bb094dd..d4b36aaf5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/64k_storage" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/64k_storage" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage_formed.json index c15110143..cebe5752b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/64k_storage_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "storage_64k" + "loader": "appliedenergistics2:crafting_cube", + "type": "storage_64k" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator.json index 15b5cab04..7a0b32c1f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/accelerator" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/accelerator" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator_formed.json index 3f591d981..19a2e23ee 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/accelerator_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "accelerator" + "loader": "appliedenergistics2:crafting_cube", + "type": "accelerator" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor.json index 760b05a04..f6a603730 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor.json @@ -1,12 +1,12 @@ { - "parent": "block/cube", - "textures": { - "particle": "appliedenergistics2:block/crafting/monitor", - "north": "appliedenergistics2:block/crafting/monitor", - "east": "appliedenergistics2:block/crafting/unit", - "west": "appliedenergistics2:block/crafting/unit", - "south": "appliedenergistics2:block/crafting/unit", - "up": "appliedenergistics2:block/crafting/unit", - "down": "appliedenergistics2:block/crafting/unit" - } + "parent": "block/cube", + "textures": { + "particle": "appliedenergistics2:block/crafting/monitor", + "north": "appliedenergistics2:block/crafting/monitor", + "east": "appliedenergistics2:block/crafting/unit", + "west": "appliedenergistics2:block/crafting/unit", + "south": "appliedenergistics2:block/crafting/unit", + "up": "appliedenergistics2:block/crafting/unit", + "down": "appliedenergistics2:block/crafting/unit" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor_formed.json index 85959e653..e8524823f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/monitor_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "monitor" + "loader": "appliedenergistics2:crafting_cube", + "type": "monitor" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit.json index 1ad39870f..d58d4aa18 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/crafting/unit" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/crafting/unit" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit_formed.json index aa5cbe9a4..6d103c9e4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crafting/unit_formed.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:crafting_cube", - "type": "unit" + "loader": "appliedenergistics2:crafting_cube", + "type": "unit" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crank.json b/src/main/resources/assets/appliedenergistics2/models/block/crank.json index 41808deb4..00033b175 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crank.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crank.json @@ -1,75 +1,59 @@ { - "parent": "block/block", - "textures": { - "wood": "appliedenergistics2:block/crank", - "particle": "appliedenergistics2:block/crank" - }, - "elements": [ - { - "name": "Crank Shaft", - "from": [ - 7.2, - 0.0, - 7.2 - ], - "to": [ - 8.8, - 9.6, - 8.8 - ], - "faces": { - "north": { - "texture": "#wood" - }, - "east": { - "texture": "#wood" - }, - "south": { - "texture": "#wood" - }, - "west": { - "texture": "#wood" - }, - "up": { - "texture": "#wood" - }, - "down": { - "texture": "#wood" - } - } + "parent": "block/block", + "textures": { + "wood": "appliedenergistics2:block/crank", + "particle": "appliedenergistics2:block/crank" + }, + "elements": [ + { + "name": "Crank Shaft", + "from": [7.2, 0.0, 7.2], + "to": [8.8, 9.6, 8.8], + "faces": { + "north": { + "texture": "#wood" }, - { - "name": "Crank Handle", - "from": [ - 8.8, - 8.0, - 7.2 - ], - "to": [ - 13.6, - 9.6, - 8.8 - ], - "faces": { - "north": { - "texture": "#wood" - }, - "east": { - "texture": "#wood" - }, - "south": { - "texture": "#wood" - }, - "west": { - "texture": "#wood" - }, - "up": { - "texture": "#wood" - }, - "down": { - "texture": "#wood" - } - } + "east": { + "texture": "#wood" + }, + "south": { + "texture": "#wood" + }, + "west": { + "texture": "#wood" + }, + "up": { + "texture": "#wood" + }, + "down": { + "texture": "#wood" } - ] + } + }, + { + "name": "Crank Handle", + "from": [8.8, 8.0, 7.2], + "to": [13.6, 9.6, 8.8], + "faces": { + "north": { + "texture": "#wood" + }, + "east": { + "texture": "#wood" + }, + "south": { + "texture": "#wood" + }, + "west": { + "texture": "#wood" + }, + "up": { + "texture": "#wood" + }, + "down": { + "texture": "#wood" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/crank_inventory.json b/src/main/resources/assets/appliedenergistics2/models/block/crank_inventory.json index 3550cae04..6883abe38 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/crank_inventory.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/crank_inventory.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crank" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crank" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae.json b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae.json index 5eba84319..ffdfffdcb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae.json @@ -1,58 +1,38 @@ { - "ambientocclusion": false, - "display": { - "firstperson_righthand": { - "rotation": [ - 0, - 135, - 0 - ], - "scale": [ - 0.40, - 0.40, - 0.40 - ], - "translation": [ - 0, - 0, - 0 - ] + "ambientocclusion": false, + "display": { + "firstperson_righthand": { + "rotation": [0, 135, 0], + "scale": [0.4, 0.4, 0.4], + "translation": [0, 0, 0] + } + }, + "elements": [ + { + "faces": { + "down": { + "texture": "#down" + }, + "east": { + "texture": "#east" + }, + "north": { + "texture": "#north" + }, + "south": { + "texture": "#south" + }, + "up": { + "texture": "#up" + }, + "west": { + "texture": "#west" } - }, - "elements": [ - { - "faces": { - "down": { - "texture": "#down" - }, - "east": { - "texture": "#east" - }, - "north": { - "texture": "#north" - }, - "south": { - "texture": "#south" - }, - "up": { - "texture": "#up" - }, - "west": { - "texture": "#west" - } - }, - "from": [ - 0, - 0, - 0 - ], - "shade": false, - "to": [ - 16, - 16, - 16 - ] - } - ], - "parent": "block/block" + }, + "from": [0, 0, 0], + "shade": false, + "to": [16, 16, 16] + } + ], + "parent": "block/block" } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_all.json b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_all.json index b2f2bfdbc..4e4304301 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_all.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_all.json @@ -1,12 +1,12 @@ { - "parent": "appliedenergistics2:block/cube_ae", - "textures": { - "down": "#all", - "east": "#all", - "north": "#all", - "particle": "#all", - "south": "#all", - "up": "#all", - "west": "#all" - } + "parent": "appliedenergistics2:block/cube_ae", + "textures": { + "down": "#all", + "east": "#all", + "north": "#all", + "particle": "#all", + "south": "#all", + "up": "#all", + "west": "#all" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_bottom_top.json b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_bottom_top.json index ab3b40c83..0e1469f84 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_bottom_top.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_bottom_top.json @@ -1,12 +1,12 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae", - "textures": { - "down": "#bottom", - "east": "#side", - "north": "#side", - "particle": "#side", - "south": "#side", - "up": "#top", - "west": "#side" - } + "parent": "appliedenergistics2:block/cube/cube_ae", + "textures": { + "down": "#bottom", + "east": "#side", + "north": "#side", + "particle": "#side", + "south": "#side", + "up": "#top", + "west": "#side" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_machine.json b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_machine.json index 2466e3fa1..3f5549e71 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_machine.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/cube/cube_ae_machine.json @@ -1,12 +1,12 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae", - "textures": { - "down": "#bottom", - "east": "#side", - "north": "#front", - "particle": "#front", - "south": "#side", - "up": "#top", - "west": "#side" - } + "parent": "appliedenergistics2:block/cube/cube_ae", + "textures": { + "down": "#bottom", + "east": "#side", + "north": "#front", + "particle": "#front", + "south": "#side", + "up": "#top", + "west": "#side" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/debug/chunk_loader.json b/src/main/resources/assets/appliedenergistics2/models/block/debug/chunk_loader.json index 2bede5252..e5bf36050 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/debug/chunk_loader.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/debug/chunk_loader.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/debug/chunk_loader" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/debug/chunk_loader" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/debug/cube_gen.json b/src/main/resources/assets/appliedenergistics2/models/block/debug/cube_gen.json index 482d3e4c4..b27019627 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/debug/cube_gen.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/debug/cube_gen.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/debug/cube_gen" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/debug/cube_gen" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/debug/energy_gen.json b/src/main/resources/assets/appliedenergistics2/models/block/debug/energy_gen.json index a1f56d867..065534ce1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/debug/energy_gen.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/debug/energy_gen.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/debug/energy_gen" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/debug/energy_gen" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/debug/item_gen.json b/src/main/resources/assets/appliedenergistics2/models/block/debug/item_gen.json index f3d2b0f47..79f973189 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/debug/item_gen.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/debug/item_gen.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/debug/item_gen" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/debug/item_gen" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/debug/phantom_node.json b/src/main/resources/assets/appliedenergistics2/models/block/debug/phantom_node.json index 0f830298c..71c1d7162 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/debug/phantom_node.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/debug/phantom_node.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/debug/phantom_node" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/debug/phantom_node" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive.json b/src/main/resources/assets/appliedenergistics2/models/block/drive.json index 412184fd7..33651b72b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:drive" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_base.json b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_base.json index 30194d17c..e669c8cd2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_base.json @@ -1,121 +1,245 @@ { - "credit": "Made with Blockbench", - "parent": "block/block", - "textures": { - "4": "appliedenergistics2:block/drive/drive_inside", - "particle": "appliedenergistics2:block/drive/drive_side", - "side": "appliedenergistics2:block/drive/drive_side", - "bottom": "appliedenergistics2:block/drive/drive_bottom", - "top": "appliedenergistics2:block/drive/drive_top", - "front": "appliedenergistics2:block/drive/drive_front" - }, - "elements": [ - { - "name": "Right Side Panel", - "from": [0, 1, 0], - "to": [1.5, 15, 16], - "faces": { - "north": {"uv": [14, 1, 16, 15], "texture": "#front", "cullface": "north"}, - "east": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#4", "cullface": "north"}, - "south": {"uv": [0, 1, 2, 15], "texture": "#side", "cullface": "south"}, - "west": {"uv": [0, 1, 16, 15], "texture": "#side", "cullface": "west"} - } - }, - { - "name": "Left Side Panel", - "from": [14.5, 1, 0], - "to": [16, 15, 16], - "faces": { - "north": {"uv": [0, 1, 2, 15], "texture": "#front", "cullface": "north"}, - "east": {"uv": [0, 1, 16, 15], "texture": "#side", "cullface": "east"}, - "south": {"uv": [14, 1, 16, 15], "texture": "#side", "cullface": "south"}, - "west": {"uv": [0, 0, 16, 16], "texture": "#4", "cullface": "north"} - } - }, - { - "name": "Back Panel", - "from": [1.5, 1, 6], - "to": [14.5, 15, 16], - "faces": { - "north": {"uv": [2, 1, 15, 15], "texture": "#4", "cullface": "north"}, - "south": {"uv": [1.5, 1, 14.5, 15], "texture": "#side", "cullface": "south"} - } - }, - { - "name": "Bottom Panel", - "from": [0, 0, 0], - "to": [16, 1, 16], - "faces": { - "north": {"uv": [0, 15, 16, 16], "texture": "#front", "cullface": "north"}, - "east": {"uv": [0, 15, 16, 16], "texture": "#side", "cullface": "east"}, - "south": {"uv": [0, 15, 16, 16], "texture": "#side", "cullface": "south"}, - "west": {"uv": [0, 15, 16, 16], "texture": "#side", "cullface": "west"}, - "up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#4", "cullface": "north"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#bottom", "cullface": "down"} - } - }, - { - "name": "Top Panel", - "from": [0, 15, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [0, 0, 16, 1], "texture": "#front", "cullface": "north"}, - "east": {"uv": [0, 0, 16, 1], "texture": "#side", "cullface": "east"}, - "south": {"uv": [0, 0, 16, 1], "texture": "#side", "cullface": "south"}, - "west": {"uv": [0, 0, 16, 1], "texture": "#side", "cullface": "west"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#top", "cullface": "up"}, - "down": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#4", "cullface": "north"} - } - }, - { - "name": "Middle Strut", - "from": [7.5, 1, 0], - "to": [8.5, 15, 8], - "faces": { - "north": {"uv": [7, 1, 9, 15], "texture": "#front", "cullface": "north"}, - "east": {"uv": [0, 0, 8, 14], "rotation": 180, "texture": "#4", "cullface": "north"}, - "west": {"uv": [0, 1, 8, 15], "texture": "#4", "cullface": "north"} - } - }, - { - "name": "Separator", - "from": [1.5, 3, 1], - "to": [14.5, 4, 8], - "faces": { - "north": {"uv": [1.5, 12, 14.5, 13], "texture": "#front", "cullface": "north"}, - "up": {"uv": [2.5, 1, 13.5, 8], "texture": "#bottom", "cullface": "north"}, - "down": {"uv": [2.5, 8, 13.5, 15], "texture": "#bottom", "cullface": "north"} - } - }, - { - "name": "Separator", - "from": [1.5, 6, 1], - "to": [14.5, 7, 8], - "faces": { - "north": {"uv": [1.5, 9, 14.5, 10], "texture": "#front", "cullface": "north"}, - "up": {"uv": [2.5, 1, 13.5, 8], "texture": "#bottom", "cullface": "north"}, - "down": {"uv": [2.5, 8, 13.5, 15], "texture": "#bottom", "cullface": "north"} - } - }, - { - "name": "Separator", - "from": [1.5, 9, 1], - "to": [14.5, 10, 8], - "faces": { - "north": {"uv": [1.5, 6, 14.5, 7], "texture": "#front", "cullface": "north"}, - "up": {"uv": [2.5, 1, 13.5, 8], "texture": "#bottom", "cullface": "north"}, - "down": {"uv": [2.5, 8, 13.5, 15], "texture": "#bottom", "cullface": "north"} - } - }, - { - "name": "Separator", - "from": [1.5, 12, 1], - "to": [14.5, 13, 8], - "faces": { - "north": {"uv": [1.5, 3, 14.5, 4], "texture": "#front", "cullface": "north"}, - "up": {"uv": [2.5, 1, 13.5, 8], "texture": "#bottom", "cullface": "north"}, - "down": {"uv": [2.5, 8, 13.5, 15], "texture": "#bottom", "cullface": "north"} - } - } - ] -} \ No newline at end of file + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "4": "appliedenergistics2:block/drive/drive_inside", + "particle": "appliedenergistics2:block/drive/drive_side", + "side": "appliedenergistics2:block/drive/drive_side", + "bottom": "appliedenergistics2:block/drive/drive_bottom", + "top": "appliedenergistics2:block/drive/drive_top", + "front": "appliedenergistics2:block/drive/drive_front" + }, + "elements": [ + { + "name": "Right Side Panel", + "from": [0, 1, 0], + "to": [1.5, 15, 16], + "faces": { + "north": { + "uv": [14, 1, 16, 15], + "texture": "#front", + "cullface": "north" + }, + "east": { + "uv": [0, 0, 16, 16], + "rotation": 180, + "texture": "#4", + "cullface": "north" + }, + "south": { + "uv": [0, 1, 2, 15], + "texture": "#side", + "cullface": "south" + }, + "west": { "uv": [0, 1, 16, 15], "texture": "#side", "cullface": "west" } + } + }, + { + "name": "Left Side Panel", + "from": [14.5, 1, 0], + "to": [16, 15, 16], + "faces": { + "north": { + "uv": [0, 1, 2, 15], + "texture": "#front", + "cullface": "north" + }, + "east": { + "uv": [0, 1, 16, 15], + "texture": "#side", + "cullface": "east" + }, + "south": { + "uv": [14, 1, 16, 15], + "texture": "#side", + "cullface": "south" + }, + "west": { "uv": [0, 0, 16, 16], "texture": "#4", "cullface": "north" } + } + }, + { + "name": "Back Panel", + "from": [1.5, 1, 6], + "to": [14.5, 15, 16], + "faces": { + "north": { "uv": [2, 1, 15, 15], "texture": "#4", "cullface": "north" }, + "south": { + "uv": [1.5, 1, 14.5, 15], + "texture": "#side", + "cullface": "south" + } + } + }, + { + "name": "Bottom Panel", + "from": [0, 0, 0], + "to": [16, 1, 16], + "faces": { + "north": { + "uv": [0, 15, 16, 16], + "texture": "#front", + "cullface": "north" + }, + "east": { + "uv": [0, 15, 16, 16], + "texture": "#side", + "cullface": "east" + }, + "south": { + "uv": [0, 15, 16, 16], + "texture": "#side", + "cullface": "south" + }, + "west": { + "uv": [0, 15, 16, 16], + "texture": "#side", + "cullface": "west" + }, + "up": { + "uv": [0, 0, 16, 16], + "rotation": 90, + "texture": "#4", + "cullface": "north" + }, + "down": { + "uv": [0, 0, 16, 16], + "texture": "#bottom", + "cullface": "down" + } + } + }, + { + "name": "Top Panel", + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "north": { + "uv": [0, 0, 16, 1], + "texture": "#front", + "cullface": "north" + }, + "east": { "uv": [0, 0, 16, 1], "texture": "#side", "cullface": "east" }, + "south": { + "uv": [0, 0, 16, 1], + "texture": "#side", + "cullface": "south" + }, + "west": { "uv": [0, 0, 16, 1], "texture": "#side", "cullface": "west" }, + "up": { "uv": [0, 0, 16, 16], "texture": "#top", "cullface": "up" }, + "down": { + "uv": [0, 0, 16, 16], + "rotation": 270, + "texture": "#4", + "cullface": "north" + } + } + }, + { + "name": "Middle Strut", + "from": [7.5, 1, 0], + "to": [8.5, 15, 8], + "faces": { + "north": { + "uv": [7, 1, 9, 15], + "texture": "#front", + "cullface": "north" + }, + "east": { + "uv": [0, 0, 8, 14], + "rotation": 180, + "texture": "#4", + "cullface": "north" + }, + "west": { "uv": [0, 1, 8, 15], "texture": "#4", "cullface": "north" } + } + }, + { + "name": "Separator", + "from": [1.5, 3, 1], + "to": [14.5, 4, 8], + "faces": { + "north": { + "uv": [1.5, 12, 14.5, 13], + "texture": "#front", + "cullface": "north" + }, + "up": { + "uv": [2.5, 1, 13.5, 8], + "texture": "#bottom", + "cullface": "north" + }, + "down": { + "uv": [2.5, 8, 13.5, 15], + "texture": "#bottom", + "cullface": "north" + } + } + }, + { + "name": "Separator", + "from": [1.5, 6, 1], + "to": [14.5, 7, 8], + "faces": { + "north": { + "uv": [1.5, 9, 14.5, 10], + "texture": "#front", + "cullface": "north" + }, + "up": { + "uv": [2.5, 1, 13.5, 8], + "texture": "#bottom", + "cullface": "north" + }, + "down": { + "uv": [2.5, 8, 13.5, 15], + "texture": "#bottom", + "cullface": "north" + } + } + }, + { + "name": "Separator", + "from": [1.5, 9, 1], + "to": [14.5, 10, 8], + "faces": { + "north": { + "uv": [1.5, 6, 14.5, 7], + "texture": "#front", + "cullface": "north" + }, + "up": { + "uv": [2.5, 1, 13.5, 8], + "texture": "#bottom", + "cullface": "north" + }, + "down": { + "uv": [2.5, 8, 13.5, 15], + "texture": "#bottom", + "cullface": "north" + } + } + }, + { + "name": "Separator", + "from": [1.5, 12, 1], + "to": [14.5, 13, 8], + "faces": { + "north": { + "uv": [1.5, 3, 14.5, 4], + "texture": "#front", + "cullface": "north" + }, + "up": { + "uv": [2.5, 1, 13.5, 8], + "texture": "#bottom", + "cullface": "north" + }, + "down": { + "uv": [2.5, 8, 13.5, 15], + "texture": "#bottom", + "cullface": "north" + } + } + } + ] +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_empty.json b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_empty.json index 358d2da03..6334701b6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_empty.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_empty.json @@ -1,6 +1,4 @@ { - "textures": { - }, - "elements": [ - ] + "textures": {}, + "elements": [] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_fluids.json b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_fluids.json index c59604abd..6c19c9abf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_fluids.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_fluids.json @@ -1,49 +1,26 @@ { - "textures": { - "front": "appliedenergistics2:block/drive/drive_cell_states" - }, - "elements": [ - { - "name": "Cell Backdrop", - "from": [ - 8.5, - 13.0, - 0.5 - ], - "to": [ - 14.5, - 15.0, - 2 - ], - "faces": { - "north": { - "texture": "#front", - "uv": [ - 0, - 12, - 5, - 14 - ] - }, - "up": { - "texture": "#front", - "uv": [ - 0, - 12, - 5, - 14 - ] - }, - "down": { - "texture": "#front", - "uv": [ - 0, - 12, - 5, - 14 - ] - } - } + "textures": { + "front": "appliedenergistics2:block/drive/drive_cell_states" + }, + "elements": [ + { + "name": "Cell Backdrop", + "from": [8.5, 13.0, 0.5], + "to": [14.5, 15.0, 2], + "faces": { + "north": { + "texture": "#front", + "uv": [0, 12, 5, 14] + }, + "up": { + "texture": "#front", + "uv": [0, 12, 5, 14] + }, + "down": { + "texture": "#front", + "uv": [0, 12, 5, 14] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_items.json b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_items.json index 008c52b12..ae2bda54c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_items.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_items.json @@ -1,49 +1,26 @@ { - "textures": { - "front": "appliedenergistics2:block/drive/drive_cell_states" - }, - "elements": [ - { - "name": "Cell Backdrop", - "from": [ - 8.5, - 13.0, - 0.5 - ], - "to": [ - 14.5, - 15.0, - 2 - ], - "faces": { - "north": { - "texture": "#front", - "uv": [ - 0, - 8, - 5, - 10 - ] - }, - "up": { - "texture": "#front", - "uv": [ - 0, - 8, - 5, - 10 - ] - }, - "down": { - "texture": "#front", - "uv": [ - 0, - 8, - 5, - 10 - ] - } - } + "textures": { + "front": "appliedenergistics2:block/drive/drive_cell_states" + }, + "elements": [ + { + "name": "Cell Backdrop", + "from": [8.5, 13.0, 0.5], + "to": [14.5, 15.0, 2], + "faces": { + "north": { + "texture": "#front", + "uv": [0, 8, 5, 10] + }, + "up": { + "texture": "#front", + "uv": [0, 8, 5, 10] + }, + "down": { + "texture": "#front", + "uv": [0, 8, 5, 10] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_led_base.json b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_led_base.json index d0dfe682a..c3efcc340 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_led_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/drive/drive_cell_led_base.json @@ -1,88 +1,55 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "front": "appliedenergistics2:block/drive/drive/cell_state_offline" - }, - "elements": [ - { - "name": "Cell Light", - "from": [ - 9.0, - 13.0, - 0.0 - ], - "to": [ - 14.0, - 15.0, - 1.0 - ], - "faces": { - "north": { - "texture": "#front", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#front", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "down": { - "texture": "#front", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#front", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#front", - "uv": [ - 0, - 0, - 16, - 16 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "front": "appliedenergistics2:block/drive/drive/cell_state_offline" + }, + "elements": [ + { + "name": "Cell Light", + "from": [9.0, 13.0, 0.0], + "to": [14.0, 15.0, 1.0], + "faces": { + "north": { + "texture": "#front", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#front", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "down": { + "texture": "#front", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#front", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#front", + "uv": [0, 0, 16, 16], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_acceptor.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_acceptor.json index 448add971..a9425c5d2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_acceptor.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_acceptor.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_acceptor" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_acceptor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/creative_energy_cell.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/creative_energy_cell.json index 06583c5da..449eaaacd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/creative_energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/creative_energy_cell.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/creative_energy_cell" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/creative_energy_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell0.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell0.json index ab7c751b9..154d12786 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell0.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell0.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell0" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell0" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell1.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell1.json index 53f37a623..1bd02c19d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell1.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell1.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell1" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell1" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell2.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell2.json index 8734bedaf..f31ac6758 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell2.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell2.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell2" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell2" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell3.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell3.json index 2b941946a..14a91bcdd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell3.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell3.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell3" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell3" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell4.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell4.json index 6ef09f814..ed1d7e1e2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell4.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell4.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell4" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell4" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell5.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell5.json index d28fca572..a55d2a509 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell5.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell5.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell5" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell5" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell6.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell6.json index e8fadc772..93dba33cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell6.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell6.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell6" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell6" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell7.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell7.json index 9a9cd9898..66432b1fa 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell7.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/dense_energy_cell7.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/dense_energy_cell7" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/dense_energy_cell7" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell0.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell0.json index 35a4e682c..60faa2ac4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell0.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell0.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell0" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell0" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell1.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell1.json index 5c05d2bf0..a695e5fb4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell1.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell1.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell1" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell1" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell2.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell2.json index 47c1f564e..52911e1d2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell2.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell2.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell2" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell2" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell3.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell3.json index b7c255153..c46c209b8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell3.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell3.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell3" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell3" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell4.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell4.json index df1af20f6..5fe9da98e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell4.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell4.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell4" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell4" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell5.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell5.json index 6691a7dcd..5fd33371d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell5.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell5.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell5" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell5" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell6.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell6.json index 951f841d3..d82de6b8d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell6.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell6.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell6" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell6" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell7.json b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell7.json index 21ce83ad0..866eaa353 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell7.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/energy_cell/energy_cell7.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/energy_cell7" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/energy_cell7" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/fluid_interface.json b/src/main/resources/assets/appliedenergistics2/models/block/fluid_interface.json index a87e58838..f7737573e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/fluid_interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/fluid_interface.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/fluid_interface" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/fluid_interface" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/fluix_block.json b/src/main/resources/assets/appliedenergistics2/models/block/fluix_block.json index f7887da9a..93fc2aa43 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/fluix_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/fluix_block.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/fluix_block" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/grindstone.json b/src/main/resources/assets/appliedenergistics2/models/block/grindstone.json index 2ad10a84f..5bb5e355b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/grindstone.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/grindstone.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae_machine", - "textures": { - "bottom": "appliedenergistics2:block/grindstone_bottom", - "front": "appliedenergistics2:block/grindstone_front", - "side": "appliedenergistics2:block/grindstone_side", - "top": "appliedenergistics2:block/grindstone" - } + "parent": "appliedenergistics2:block/cube/cube_ae_machine", + "textures": { + "bottom": "appliedenergistics2:block/grindstone_bottom", + "front": "appliedenergistics2:block/grindstone_front", + "side": "appliedenergistics2:block/grindstone_side", + "top": "appliedenergistics2:block/grindstone" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/inscriber.json b/src/main/resources/assets/appliedenergistics2/models/block/inscriber.json index d80704b0e..f259995b6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/inscriber.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/inscriber.json @@ -1,385 +1,179 @@ { - "parent": "block/orientable", - "textures": { - "particle": "appliedenergistics2:block/inscriber", - "side": "appliedenergistics2:block/inscriber", - "inside": "appliedenergistics2:block/inscriber_inside" - }, - "elements": [ - { - "name": "bottom", - "from": [ - 1, - 0, - 1 - ], - "to": [ - 15, - 1, - 15 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 1, - 1, - 15, - 15 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 1, - 0, - 15, - 1 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 1, - 15, - 15, - 16 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 1, - 0, - 15, - 1 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 1, - 0, - 15, - 1 - ] - } - } + "parent": "block/orientable", + "textures": { + "particle": "appliedenergistics2:block/inscriber", + "side": "appliedenergistics2:block/inscriber", + "inside": "appliedenergistics2:block/inscriber_inside" + }, + "elements": [ + { + "name": "bottom", + "from": [1, 0, 1], + "to": [15, 1, 15], + "faces": { + "down": { + "texture": "#side", + "uv": [1, 1, 15, 15] }, - { - "name": "top", - "from": [ - 1, - 15, - 1 - ], - "to": [ - 15, - 16, - 15 - ], - "faces": { - "east": { - "texture": "#side", - "uv": [ - 1, - 0, - 15, - 1 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 1, - 15, - 15, - 16 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 1, - 0, - 15, - 1 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 1, - 1, - 15, - 15 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 1, - 15, - 15, - 16 - ] - } - } + "east": { + "texture": "#side", + "uv": [1, 0, 15, 1] }, - { - "name": "left", - "from": [ - 0, - 1, - 0 - ], - "to": [ - 3, - 15, - 16 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 0, - 1, - 3, - 15 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 0, - 1, - 16, - 15 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 13, - 1, - 16, - 15 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 0, - 1, - 3, - 15 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 0, - 0, - 3, - 6 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 0, - 1, - 16, - 15 - ] - } - } + "north": { + "texture": "#side", + "uv": [1, 15, 15, 16] }, - { - "name": "right", - "from": [ - 13, - 1, - 0 - ], - "to": [ - 16, - 15, - 16 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 0, - 1, - 3, - 15 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 0, - 1, - 16, - 15 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 0, - 1, - 3, - 15 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 13, - 1, - 16, - 15 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 13, - 1, - 16, - 15 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 0, - 1, - 16, - 15 - ] - } - } + "south": { + "texture": "#side", + "uv": [1, 0, 15, 1] }, - { - "name": "back", - "from": [ - 3, - 1, - 13 - ], - "to": [ - 13, - 15, - 16 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 3, - 0, - 13, - 3 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 3, - 1, - 13, - 15 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 3, - 1, - 13, - 15 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 3, - 0, - 13, - 3 - ] - } - } - }, - { - "name": "press-bottom", - "from": [ - 3, - 1, - 1 - ], - "to": [ - 13, - 4, - 13 - ], - "faces": { - "north": { - "texture": "#side", - "uv": [ - 3, - 12, - 13, - 15 - ] - }, - "up": { - "texture": "#side", - "uv": [ - 3, - 1, - 13, - 13 - ] - } - } - }, - { - "name": "press-top", - "from": [ - 3, - 12, - 1 - ], - "to": [ - 13, - 15, - 11 - ], - "faces": { - "down": { - "texture": "#side", - "uv": [ - 3, - 1, - 13, - 11 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 3, - 1, - 13, - 4 - ] - } - } + "west": { + "texture": "#side", + "uv": [1, 0, 15, 1] } - ] + } + }, + { + "name": "top", + "from": [1, 15, 1], + "to": [15, 16, 15], + "faces": { + "east": { + "texture": "#side", + "uv": [1, 0, 15, 1] + }, + "north": { + "texture": "#side", + "uv": [1, 15, 15, 16] + }, + "south": { + "texture": "#side", + "uv": [1, 0, 15, 1] + }, + "up": { + "texture": "#side", + "uv": [1, 1, 15, 15] + }, + "west": { + "texture": "#side", + "uv": [1, 15, 15, 16] + } + } + }, + { + "name": "left", + "from": [0, 1, 0], + "to": [3, 15, 16], + "faces": { + "down": { + "texture": "#side", + "uv": [0, 1, 3, 15] + }, + "east": { + "texture": "#side", + "uv": [0, 1, 16, 15] + }, + "north": { + "texture": "#side", + "uv": [13, 1, 16, 15] + }, + "south": { + "texture": "#side", + "uv": [0, 1, 3, 15] + }, + "up": { + "texture": "#side", + "uv": [0, 0, 3, 6] + }, + "west": { + "texture": "#side", + "uv": [0, 1, 16, 15] + } + } + }, + { + "name": "right", + "from": [13, 1, 0], + "to": [16, 15, 16], + "faces": { + "down": { + "texture": "#side", + "uv": [0, 1, 3, 15] + }, + "east": { + "texture": "#side", + "uv": [0, 1, 16, 15] + }, + "north": { + "texture": "#side", + "uv": [0, 1, 3, 15] + }, + "south": { + "texture": "#side", + "uv": [13, 1, 16, 15] + }, + "up": { + "texture": "#side", + "uv": [13, 1, 16, 15] + }, + "west": { + "texture": "#side", + "uv": [0, 1, 16, 15] + } + } + }, + { + "name": "back", + "from": [3, 1, 13], + "to": [13, 15, 16], + "faces": { + "down": { + "texture": "#side", + "uv": [3, 0, 13, 3] + }, + "north": { + "texture": "#side", + "uv": [3, 1, 13, 15] + }, + "south": { + "texture": "#side", + "uv": [3, 1, 13, 15] + }, + "up": { + "texture": "#side", + "uv": [3, 0, 13, 3] + } + } + }, + { + "name": "press-bottom", + "from": [3, 1, 1], + "to": [13, 4, 13], + "faces": { + "north": { + "texture": "#side", + "uv": [3, 12, 13, 15] + }, + "up": { + "texture": "#side", + "uv": [3, 1, 13, 13] + } + } + }, + { + "name": "press-top", + "from": [3, 12, 1], + "to": [13, 15, 11], + "faces": { + "down": { + "texture": "#side", + "uv": [3, 1, 13, 11] + }, + "north": { + "texture": "#side", + "uv": [3, 1, 13, 4] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/interface.json b/src/main/resources/assets/appliedenergistics2/models/block/interface.json index 5bc6ecdff..72812a060 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/interface.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/interface" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/interface" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/interface_oriented.json b/src/main/resources/assets/appliedenergistics2/models/block/interface_oriented.json index 2b5c8404c..f17fba317 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/interface_oriented.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/interface_oriented.json @@ -1,12 +1,12 @@ { - "parent": "block/cube", - "textures": { - "particle": "appliedenergistics2:block/interface", - "down": "appliedenergistics2:block/interface_alternate", - "up": "appliedenergistics2:block/interface", - "north": "appliedenergistics2:block/interface_alternate_arrow", - "south": "appliedenergistics2:block/interface_alternate_arrow", - "east": "appliedenergistics2:block/interface_alternate_arrow", - "west": "appliedenergistics2:block/interface_alternate_arrow" - } + "parent": "block/cube", + "textures": { + "particle": "appliedenergistics2:block/interface", + "down": "appliedenergistics2:block/interface_alternate", + "up": "appliedenergistics2:block/interface", + "north": "appliedenergistics2:block/interface_alternate_arrow", + "south": "appliedenergistics2:block/interface_alternate_arrow", + "east": "appliedenergistics2:block/interface_alternate_arrow", + "west": "appliedenergistics2:block/interface_alternate_arrow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/io_port.json b/src/main/resources/assets/appliedenergistics2/models/block/io_port.json index c5c780a06..3babab27d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/io_port.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/io_port.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae_bottom_top", - "textures": { - "bottom": "appliedenergistics2:block/io_port_bottom", - "side": "appliedenergistics2:block/io_port_side", - "top": "appliedenergistics2:block/io_port" - } + "parent": "appliedenergistics2:block/cube/cube_ae_bottom_top", + "textures": { + "bottom": "appliedenergistics2:block/io_port_bottom", + "side": "appliedenergistics2:block/io_port_side", + "top": "appliedenergistics2:block/io_port" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/matrix_frame.json b/src/main/resources/assets/appliedenergistics2/models/block/matrix_frame.json index 4c0496ba3..55c9a24d9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/matrix_frame.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/matrix_frame.json @@ -1,4 +1,3 @@ { - "elements": [ - ] + "elements": [] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler.json b/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler.json index 4e87b59af..bb30115a5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler.json @@ -1,313 +1,209 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/molecular_assembler", - "outside": "appliedenergistics2:block/molecular_assembler" - }, - "elements": [ - { - "name": "Shell", - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "shade": false, - "faces": { - "down": { - "texture": "#outside", - "cullface": "down" - }, - "up": { - "texture": "#outside", - "cullface": "up" - }, - "north": { - "texture": "#outside", - "cullface": "north" - }, - "south": { - "texture": "#outside", - "cullface": "south" - }, - "west": { - "texture": "#outside", - "cullface": "west" - }, - "east": { - "texture": "#outside", - "cullface": "east" - } - } + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/molecular_assembler", + "outside": "appliedenergistics2:block/molecular_assembler" + }, + "elements": [ + { + "name": "Shell", + "from": [0, 0, 0], + "to": [16, 16, 16], + "shade": false, + "faces": { + "down": { + "texture": "#outside", + "cullface": "down" }, - { - "name": "Beam Bottom North", - "from": [ - 2, - 0, - 0 - ], - "to": [ - 14, - 2, - 2 - ], - "shade": false, - "faces": { - "up": { - "texture": "#outside" - }, - "south": { - "texture": "#outside" - } - } + "up": { + "texture": "#outside", + "cullface": "up" }, - { - "name": "Beam Bottom South", - "from": [ - 2, - 0, - 14 - ], - "to": [ - 14, - 2, - 16 - ], - "shade": false, - "faces": { - "up": { - "texture": "#outside" - }, - "north": { - "texture": "#outside" - } - } + "north": { + "texture": "#outside", + "cullface": "north" }, - { - "name": "Beam Top North", - "from": [ - 2, - 14, - 0 - ], - "to": [ - 14, - 16, - 2 - ], - "shade": false, - "faces": { - "down": { - "texture": "#outside" - }, - "south": { - "texture": "#outside" - } - } + "south": { + "texture": "#outside", + "cullface": "south" }, - { - "name": "Beam Top South", - "from": [ - 2, - 14, - 14 - ], - "to": [ - 14, - 16, - 16 - ], - "shade": false, - "faces": { - "down": { - "texture": "#outside" - }, - "north": { - "texture": "#outside" - } - } + "west": { + "texture": "#outside", + "cullface": "west" }, - { - "name": "Beam Bottom West", - "from": [ - 0, - 0, - 0 - ], - "to": [ - 2, - 2, - 16 - ], - "shade": false, - "faces": { - "up": { - "texture": "#outside" - }, - "east": { - "texture": "#outside" - } - } - }, - { - "name": "Beam Bottom East", - "from": [ - 14, - 0, - 0 - ], - "to": [ - 16, - 2, - 16 - ], - "shade": false, - "faces": { - "up": { - "texture": "#outside" - }, - "west": { - "texture": "#outside" - } - } - }, - { - "name": "Beam Top West", - "from": [ - 0, - 14, - 0 - ], - "to": [ - 2, - 16, - 16 - ], - "shade": false, - "faces": { - "down": { - "texture": "#outside" - }, - "east": { - "texture": "#outside" - } - } - }, - { - "name": "Beam Top East", - "from": [ - 14, - 14, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "shade": false, - "faces": { - "down": { - "texture": "#outside" - }, - "west": { - "texture": "#outside" - } - } - }, - { - "name": "Strut North West", - "from": [ - 0, - 2, - 0 - ], - "to": [ - 2, - 14, - 2 - ], - "shade": false, - "faces": { - "south": { - "texture": "#outside" - }, - "east": { - "texture": "#outside" - } - } - }, - { - "name": "Strut South West", - "from": [ - 0, - 2, - 14 - ], - "to": [ - 2, - 14, - 16 - ], - "shade": false, - "faces": { - "north": { - "texture": "#outside" - }, - "east": { - "texture": "#outside" - } - } - }, - { - "name": "Strut North East", - "from": [ - 14, - 2, - 0 - ], - "to": [ - 16, - 14, - 2 - ], - "shade": false, - "faces": { - "south": { - "texture": "#outside" - }, - "west": { - "texture": "#outside" - } - } - }, - { - "name": "Strut South East", - "from": [ - 14, - 2, - 14 - ], - "to": [ - 16, - 14, - 16 - ], - "shade": false, - "faces": { - "north": { - "texture": "#outside" - }, - "west": { - "texture": "#outside" - } - } + "east": { + "texture": "#outside", + "cullface": "east" } - ] + } + }, + { + "name": "Beam Bottom North", + "from": [2, 0, 0], + "to": [14, 2, 2], + "shade": false, + "faces": { + "up": { + "texture": "#outside" + }, + "south": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Bottom South", + "from": [2, 0, 14], + "to": [14, 2, 16], + "shade": false, + "faces": { + "up": { + "texture": "#outside" + }, + "north": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Top North", + "from": [2, 14, 0], + "to": [14, 16, 2], + "shade": false, + "faces": { + "down": { + "texture": "#outside" + }, + "south": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Top South", + "from": [2, 14, 14], + "to": [14, 16, 16], + "shade": false, + "faces": { + "down": { + "texture": "#outside" + }, + "north": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Bottom West", + "from": [0, 0, 0], + "to": [2, 2, 16], + "shade": false, + "faces": { + "up": { + "texture": "#outside" + }, + "east": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Bottom East", + "from": [14, 0, 0], + "to": [16, 2, 16], + "shade": false, + "faces": { + "up": { + "texture": "#outside" + }, + "west": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Top West", + "from": [0, 14, 0], + "to": [2, 16, 16], + "shade": false, + "faces": { + "down": { + "texture": "#outside" + }, + "east": { + "texture": "#outside" + } + } + }, + { + "name": "Beam Top East", + "from": [14, 14, 0], + "to": [16, 16, 16], + "shade": false, + "faces": { + "down": { + "texture": "#outside" + }, + "west": { + "texture": "#outside" + } + } + }, + { + "name": "Strut North West", + "from": [0, 2, 0], + "to": [2, 14, 2], + "shade": false, + "faces": { + "south": { + "texture": "#outside" + }, + "east": { + "texture": "#outside" + } + } + }, + { + "name": "Strut South West", + "from": [0, 2, 14], + "to": [2, 14, 16], + "shade": false, + "faces": { + "north": { + "texture": "#outside" + }, + "east": { + "texture": "#outside" + } + } + }, + { + "name": "Strut North East", + "from": [14, 2, 0], + "to": [16, 14, 2], + "shade": false, + "faces": { + "south": { + "texture": "#outside" + }, + "west": { + "texture": "#outside" + } + } + }, + { + "name": "Strut South East", + "from": [14, 2, 14], + "to": [16, 14, 16], + "shade": false, + "faces": { + "north": { + "texture": "#outside" + }, + "west": { + "texture": "#outside" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler_lights.json b/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler_lights.json index 1dfd05a1a..d306fd5d2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler_lights.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/molecular_assembler_lights.json @@ -1,83 +1,45 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "all": "appliedenergistics2:block/molecular_assembler_lights" - }, - "elements": [ - { - "from": [ - 2, - 2, - 2 - ], - "to": [ - 14, - 14, - 14 - ], - "faces": { - "down": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "down" - }, - "up": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "up" - }, - "north": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "north" - }, - "south": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "south" - }, - "west": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "west" - }, - "east": { - "texture": "#all", - "uv": [ - 2.6, - 2.6, - 13.4, - 13.4 - ], - "cullface": "east" - } - } + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "all": "appliedenergistics2:block/molecular_assembler_lights" + }, + "elements": [ + { + "from": [2, 2, 2], + "to": [14, 14, 14], + "faces": { + "down": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "down" + }, + "up": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "up" + }, + "north": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "north" + }, + "south": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "south" + }, + "west": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "west" + }, + "east": { + "texture": "#all", + "uv": [2.6, 2.6, 13.4, 13.4], + "cullface": "east" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/paint.json b/src/main/resources/assets/appliedenergistics2/models/block/paint.json index 05d363339..db58c703b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/paint.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/paint.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:paint_splotches" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/qnb/link.json b/src/main/resources/assets/appliedenergistics2/models/block/qnb/link.json index bf6654bd7..1ca8bb137 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/qnb/link.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/qnb/link.json @@ -1,41 +1,33 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/quantum_link", - "sides": "appliedenergistics2:block/quantum_link" - }, - "elements": [ - { - "from": [ - 2, - 2, - 2 - ], - "to": [ - 14, - 14, - 14 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "north": { - "texture": "#sides" - }, - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/quantum_link", + "sides": "appliedenergistics2:block/quantum_link" + }, + "elements": [ + { + "from": [2, 2, 2], + "to": [14, 14, 14], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "north": { + "texture": "#sides" + }, + "east": { + "texture": "#sides" + }, + "south": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/qnb/qnb_formed.json b/src/main/resources/assets/appliedenergistics2/models/block/qnb/qnb_formed.json index 5411616f1..953967cdc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/qnb/qnb_formed.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/qnb/qnb_formed.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:quantum_bridge_formed" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/qnb/ring.json b/src/main/resources/assets/appliedenergistics2/models/block/qnb/ring.json index 0f9130e06..2c753a7c1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/qnb/ring.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/qnb/ring.json @@ -1,41 +1,33 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/quantum_ring", - "sides": "appliedenergistics2:block/quantum_ring" - }, - "elements": [ - { - "from": [ - 2, - 2, - 2 - ], - "to": [ - 14, - 14, - 14 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "north": { - "texture": "#sides" - }, - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/quantum_ring", + "sides": "appliedenergistics2:block/quantum_ring" + }, + "elements": [ + { + "from": [2, 2, 2], + "to": [14, 14, 14], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "north": { + "texture": "#sides" + }, + "east": { + "texture": "#sides" + }, + "south": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_block.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_block.json index 069a6d3d3..64a81a7ee 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_block.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/quartz_block" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing.json index 9f30f43d7..01406f013 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing.json @@ -1,306 +1,234 @@ { - "elements": [ - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 3.0, - 6.0 - ], - "name": "Middle Plate", - "to": [ - 10.0, - 4.0, - 10.0 - ] + "elements": [ + { + "faces": { + "down": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 1.0, - 7.0 - ], - "name": "Lower Quartz Block", - "to": [ - 9.0, - 3.0, - 9.0 - ] + "east": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 0.0, - 7.0 - ], - "name": "Lower Quartz Tip", - "to": [ - 8.0, - 1.0, - 8.0 - ] + "north": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 4.0, - 7.0 - ], - "name": "Upper Quartz Block", - "to": [ - 9.0, - 6.0, - 9.0 - ] + "south": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 8.0, - 6.0, - 8.0 - ], - "name": "Upper Quartz Tip", - "to": [ - 9.0, - 7.0, - 9.0 - ] + "up": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 0.0, - 6.0 - ], - "name": "NW Feet", - "to": [ - 7.0, - 3.0, - 7.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 0.0, - 9.0 - ], - "name": "NE Feet", - "to": [ - 7.0, - 3.0, - 10.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 9.0, - 0.0, - 6.0 - ], - "name": "SW Feet", - "to": [ - 10.0, - 3.0, - 7.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 9.0, - 0.0, - 9.0 - ], - "name": "SE Feet", - "to": [ - 10.0, - 3.0, - 10.0 - ] + "west": { + "texture": "#metal" } - ], - "textures": { - "particle": "appliedenergistics2:block/quartz_fixture", - "metal": "appliedenergistics2:block/quartz_fixture_metal", - "quartz": "appliedenergistics2:block/quartz_fixture" + }, + "from": [6.0, 3.0, 6.0], + "name": "Middle Plate", + "to": [10.0, 4.0, 10.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 1.0, 7.0], + "name": "Lower Quartz Block", + "to": [9.0, 3.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 0.0, 7.0], + "name": "Lower Quartz Tip", + "to": [8.0, 1.0, 8.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 4.0, 7.0], + "name": "Upper Quartz Block", + "to": [9.0, 6.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [8.0, 6.0, 8.0], + "name": "Upper Quartz Tip", + "to": [9.0, 7.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 0.0, 6.0], + "name": "NW Feet", + "to": [7.0, 3.0, 7.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 0.0, 9.0], + "name": "NE Feet", + "to": [7.0, 3.0, 10.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [9.0, 0.0, 6.0], + "name": "SW Feet", + "to": [10.0, 3.0, 7.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [9.0, 0.0, 9.0], + "name": "SE Feet", + "to": [10.0, 3.0, 10.0] } + ], + "textures": { + "particle": "appliedenergistics2:block/quartz_fixture", + "metal": "appliedenergistics2:block/quartz_fixture_metal", + "quartz": "appliedenergistics2:block/quartz_fixture" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing_odd.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing_odd.json index 18990b825..c487d7259 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing_odd.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_standing_odd.json @@ -1,306 +1,234 @@ { - "elements": [ - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 3.0, - 6.0 - ], - "name": "Middle Plate", - "to": [ - 10.0, - 4.0, - 10.0 - ] + "elements": [ + { + "faces": { + "down": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 1.0, - 7.0 - ], - "name": "Lower Quartz Block", - "to": [ - 9.0, - 3.0, - 9.0 - ] + "east": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 8.0, - 0.0, - 8.0 - ], - "name": "Lower Quartz Tip", - "to": [ - 9.0, - 1.0, - 9.0 - ] + "north": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 4.0, - 7.0 - ], - "name": "Upper Quartz Block", - "to": [ - 9.0, - 6.0, - 9.0 - ] + "south": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 6.0, - 7.0 - ], - "name": "Upper Quartz Tip", - "to": [ - 8.0, - 7.0, - 8.0 - ] + "up": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 0.0, - 6.0 - ], - "name": "NW Feet", - "to": [ - 7.0, - 3.0, - 7.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 0.0, - 9.0 - ], - "name": "NE Feet", - "to": [ - 7.0, - 3.0, - 10.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 9.0, - 0.0, - 6.0 - ], - "name": "SW Feet", - "to": [ - 10.0, - 3.0, - 7.0 - ] - }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 9.0, - 0.0, - 9.0 - ], - "name": "SE Feet", - "to": [ - 10.0, - 3.0, - 10.0 - ] + "west": { + "texture": "#metal" } - ], - "textures": { - "particle": "appliedenergistics2:block/quartz_fixture", - "metal": "appliedenergistics2:block/quartz_fixture_metal", - "quartz": "appliedenergistics2:block/quartz_fixture" + }, + "from": [6.0, 3.0, 6.0], + "name": "Middle Plate", + "to": [10.0, 4.0, 10.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 1.0, 7.0], + "name": "Lower Quartz Block", + "to": [9.0, 3.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [8.0, 0.0, 8.0], + "name": "Lower Quartz Tip", + "to": [9.0, 1.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 4.0, 7.0], + "name": "Upper Quartz Block", + "to": [9.0, 6.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 6.0, 7.0], + "name": "Upper Quartz Tip", + "to": [8.0, 7.0, 8.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 0.0, 6.0], + "name": "NW Feet", + "to": [7.0, 3.0, 7.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 0.0, 9.0], + "name": "NE Feet", + "to": [7.0, 3.0, 10.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [9.0, 0.0, 6.0], + "name": "SW Feet", + "to": [10.0, 3.0, 7.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [9.0, 0.0, 9.0], + "name": "SE Feet", + "to": [10.0, 3.0, 10.0] } + ], + "textures": { + "particle": "appliedenergistics2:block/quartz_fixture", + "metal": "appliedenergistics2:block/quartz_fixture_metal", + "quartz": "appliedenergistics2:block/quartz_fixture" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall.json index be3c41eb5..13c0adf66 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall.json @@ -1,208 +1,160 @@ { - "ambientocclusion": false, - "elements": [ - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 7.0, - 7.0, - 14.0 - ], - "name": "Connecting Strut", - "to": [ - 8.0, - 8.0, - 16.0 - ] + "ambientocclusion": false, + "elements": [ + { + "faces": { + "down": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 7.0, - 10.0 - ], - "name": "Middle Plate", - "to": [ - 10.0, - 8.0, - 14.0 - ] + "east": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 5.0, - 11.0 - ], - "name": "Lower Quartz Block", - "to": [ - 9.0, - 7.0, - 13.0 - ] + "north": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 4.0, - 11.0 - ], - "name": "Lower Quartz Tip", - "to": [ - 8.0, - 5.0, - 12.0 - ] + "south": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 8.0, - 11.0 - ], - "name": "Upper Quartz Block", - "to": [ - 9.0, - 10.0, - 13.0 - ] + "up": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 8.0, - 10.0, - 12.0 - ], - "name": "Upper Quartz Tip", - "to": [ - 9.0, - 11.0, - 13.0 - ] + "west": { + "texture": "#metal" } - ], - "textures": { - "particle": "appliedenergistics2:block/quartz_fixture", - "metal": "appliedenergistics2:block/quartz_fixture_metal", - "quartz": "appliedenergistics2:block/quartz_fixture" + }, + "from": [7.0, 7.0, 14.0], + "name": "Connecting Strut", + "to": [8.0, 8.0, 16.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 7.0, 10.0], + "name": "Middle Plate", + "to": [10.0, 8.0, 14.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 5.0, 11.0], + "name": "Lower Quartz Block", + "to": [9.0, 7.0, 13.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 4.0, 11.0], + "name": "Lower Quartz Tip", + "to": [8.0, 5.0, 12.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 8.0, 11.0], + "name": "Upper Quartz Block", + "to": [9.0, 10.0, 13.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [8.0, 10.0, 12.0], + "name": "Upper Quartz Tip", + "to": [9.0, 11.0, 13.0] } + ], + "textures": { + "particle": "appliedenergistics2:block/quartz_fixture", + "metal": "appliedenergistics2:block/quartz_fixture_metal", + "quartz": "appliedenergistics2:block/quartz_fixture" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall_odd.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall_odd.json index 5a655e6f7..f253f4386 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall_odd.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_fixture_wall_odd.json @@ -1,208 +1,160 @@ { - "ambientocclusion": false, - "elements": [ - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 7.0, - 7.0, - 14.0 - ], - "name": "Connecting Strut", - "to": [ - 8.0, - 8.0, - 16.0 - ] + "ambientocclusion": false, + "elements": [ + { + "faces": { + "down": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 7.0, - 10.0 - ], - "name": "Middle Plate", - "to": [ - 10.0, - 8.0, - 14.0 - ] + "east": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 5.0, - 11.0 - ], - "name": "Lower Quartz Block", - "to": [ - 9.0, - 7.0, - 13.0 - ] + "north": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 8.0, - 4.0, - 12.0 - ], - "name": "Lower Quartz Tip", - "to": [ - 9.0, - 5.0, - 13.0 - ] + "south": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 8.0, - 11.0 - ], - "name": "Upper Quartz Block", - "to": [ - 9.0, - 10.0, - 13.0 - ] + "up": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 10.0, - 11.0 - ], - "name": "Upper Quartz Tip", - "to": [ - 8.0, - 11.0, - 12.0 - ] + "west": { + "texture": "#metal" } - ], - "textures": { - "particle": "appliedenergistics2:block/quartz_fixture", - "metal": "appliedenergistics2:block/quartz_fixture_metal", - "quartz": "appliedenergistics2:block/quartz_fixture" + }, + "from": [7.0, 7.0, 14.0], + "name": "Connecting Strut", + "to": [8.0, 8.0, 16.0] + }, + { + "faces": { + "down": { + "texture": "#metal" + }, + "east": { + "texture": "#metal" + }, + "north": { + "texture": "#metal" + }, + "south": { + "texture": "#metal" + }, + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" + } + }, + "from": [6.0, 7.0, 10.0], + "name": "Middle Plate", + "to": [10.0, 8.0, 14.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 5.0, 11.0], + "name": "Lower Quartz Block", + "to": [9.0, 7.0, 13.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [8.0, 4.0, 12.0], + "name": "Lower Quartz Tip", + "to": [9.0, 5.0, 13.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 8.0, 11.0], + "name": "Upper Quartz Block", + "to": [9.0, 10.0, 13.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 10.0, 11.0], + "name": "Upper Quartz Tip", + "to": [8.0, 11.0, 12.0] } + ], + "textures": { + "particle": "appliedenergistics2:block/quartz_fixture", + "metal": "appliedenergistics2:block/quartz_fixture_metal", + "quartz": "appliedenergistics2:block/quartz_fixture" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_glass.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_glass.json index 4810cdf0d..1159d0c33 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_glass.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_glass.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:glass" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_off.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_off.json index d9a89f1fb..a9449877e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_off.json @@ -1,8 +1,8 @@ { - "parent": "block/cube_bottom_top", - "textures": { - "bottom": "appliedenergistics2:block/quartz_growth_accelerator", - "side": "appliedenergistics2:block/quartz_growth_accelerator_side", - "top": "appliedenergistics2:block/quartz_growth_accelerator" - } + "parent": "block/cube_bottom_top", + "textures": { + "bottom": "appliedenergistics2:block/quartz_growth_accelerator", + "side": "appliedenergistics2:block/quartz_growth_accelerator_side", + "top": "appliedenergistics2:block/quartz_growth_accelerator" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_on.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_on.json index 5e7afaddc..0e4202dc3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_growth_accelerator_on.json @@ -1,8 +1,8 @@ { - "parent": "block/cube_bottom_top", - "textures": { - "bottom": "appliedenergistics2:block/quartz_growth_accelerator_on", - "side": "appliedenergistics2:block/quartz_growth_accelerator_side_on", - "top": "appliedenergistics2:block/quartz_growth_accelerator_on" - } + "parent": "block/cube_bottom_top", + "textures": { + "bottom": "appliedenergistics2:block/quartz_growth_accelerator_on", + "side": "appliedenergistics2:block/quartz_growth_accelerator_side_on", + "top": "appliedenergistics2:block/quartz_growth_accelerator_on" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_ore.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_ore.json index 654f29c04..fe14bf0b5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_ore.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/quartz_ore" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/quartz_ore" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/quartz_pillar.json b/src/main/resources/assets/appliedenergistics2/models/block/quartz_pillar.json index 73a921908..16bd5a96e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/quartz_pillar.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/quartz_pillar.json @@ -1,7 +1,7 @@ { - "parent": "block/cube_column", - "textures": { - "end": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side" - } + "parent": "block/cube_column", + "textures": { + "end": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json b/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json index 71148c871..270cd6655 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json @@ -1,100 +1,68 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/security_station_side", - "side": "appliedenergistics2:block/security_station_side", - "bottom": "appliedenergistics2:block/security_station_bottom", - "top": "appliedenergistics2:block/security_station_top", - "lightsBright": "appliedenergistics2:block/security_station_light_bright", - "lightsMedium": "appliedenergistics2:block/security_station_light_medium", - "lightsDark": "appliedenergistics2:block/security_station_light_dark" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "down": { - "texture": "#bottom" - }, - "up": { - "texture": "#top" - }, - "north": { - "texture": "#side" - }, - "south": { - "texture": "#side" - }, - "west": { - "texture": "#side" - }, - "east": { - "texture": "#side" - } - } + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/security_station_side", + "side": "appliedenergistics2:block/security_station_side", + "bottom": "appliedenergistics2:block/security_station_bottom", + "top": "appliedenergistics2:block/security_station_top", + "lightsBright": "appliedenergistics2:block/security_station_light_bright", + "lightsMedium": "appliedenergistics2:block/security_station_light_medium", + "lightsDark": "appliedenergistics2:block/security_station_light_dark" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "down": { + "texture": "#bottom" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsBright", - "tintindex": 3 - } - } + "up": { + "texture": "#top" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsMedium", - "tintindex": 3 - } - } + "north": { + "texture": "#side" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsDark", - "tintindex": 3 - } - } + "south": { + "texture": "#side" + }, + "west": { + "texture": "#side" + }, + "east": { + "texture": "#side" } - ] + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsBright", + "tintindex": 3 + } + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsMedium", + "tintindex": 3 + } + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsDark", + "tintindex": 3 + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json b/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json index c615346ad..b654e4592 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json @@ -1,113 +1,81 @@ { - "loader": "appliedenergistics2:uvlightmap", - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/security_station_side", - "side": "appliedenergistics2:block/security_station_side", - "bottom": "appliedenergistics2:block/security_station_bottom", - "top": "appliedenergistics2:block/security_station_top", - "lightsBright": "appliedenergistics2:block/security_station_light_bright", - "lightsMedium": "appliedenergistics2:block/security_station_light_medium", - "lightsDark": "appliedenergistics2:block/security_station_light_dark" - }, - "elements": [ - { - "from": [ - 0, - 0, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "down": { - "texture": "#bottom" - }, - "up": { - "texture": "#top" - }, - "north": { - "texture": "#side" - }, - "south": { - "texture": "#side" - }, - "west": { - "texture": "#side" - }, - "east": { - "texture": "#side" - } - } + "loader": "appliedenergistics2:uvlightmap", + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/security_station_side", + "side": "appliedenergistics2:block/security_station_side", + "bottom": "appliedenergistics2:block/security_station_bottom", + "top": "appliedenergistics2:block/security_station_top", + "lightsBright": "appliedenergistics2:block/security_station_light_bright", + "lightsMedium": "appliedenergistics2:block/security_station_light_medium", + "lightsDark": "appliedenergistics2:block/security_station_light_dark" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "down": { + "texture": "#bottom" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "up": { + "texture": "#top" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "north": { + "texture": "#side" }, - { - "from": [ - 0, - 15, - 0 - ], - "to": [ - 16, - 16, - 16 - ], - "faces": { - "up": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "south": { + "texture": "#side" + }, + "west": { + "texture": "#side" + }, + "east": { + "texture": "#side" } - ] + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [0, 15, 0], + "to": [16, 16, 16], + "faces": { + "up": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass.json index 487580f14..06213771f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:sky_compass" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_base.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_base.json index edcadc7c3..263f0e923 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_base.json @@ -1,527 +1,227 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/sky_compass", - "0": "appliedenergistics2:block/sky_compass" + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/sky_compass", + "0": "appliedenergistics2:block/sky_compass" + }, + "display": { + "gui": { + "rotation": [30, 225, 0], + "translation": [0, 8, 0], + "scale": [1.5, 1.5, 1.5] }, - "display": { - "gui": { - "rotation": [ - 30, - 225, - 0 - ], - "translation": [ - 0, - 8, - 0 - ], - "scale": [ - 1.5, - 1.5, - 1.5 - ] - }, - "ground": { - "rotation": [ - 0, - 0, - 0 - ], - "translation": [ - 0, - 3, - 0 - ], - "scale": [ - 0.5, - 0.5, - 0.5 - ] - }, - "fixed": { - "rotation": [ - 270, - 0, - 0 - ], - "translation": [ - 0, - 0, - -10.1 - ], - "scale": [ - 1.5, - 1.5, - 1.5 - ] - }, - "thirdperson_righthand": { - "rotation": [ - 75, - 45, - 0 - ], - "translation": [ - 0, - 2.5, - 2 - ], - "scale": [ - 0.375, - 0.375, - 0.375 - ] - }, - "firstperson_righthand": { - "rotation": [ - 10, - 0, - 0 - ], - "translation": [ - 0, - 8, - -12 - ], - "scale": [ - 2, - 2, - 2 - ] - }, - "firstperson_lefthand": { - "rotation": [ - 10, - 0, - 0 - ], - "translation": [ - 0, - 8, - -12 - ], - "scale": [ - 2, - 2, - 2 - ] - } + "ground": { + "rotation": [0, 0, 0], + "translation": [0, 3, 0], + "scale": [0.5, 0.5, 0.5] }, - "elements": [ - { - "name": "Base", - "from": [ - 6.0, - 0.0, - 6.0 - ], - "to": [ - 10.0, - 1.0, - 10.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.0, - 4.0, - 4.0, - 5.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 4.0, - 4.0, - 8.0, - 5.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 8.0, - 4.0, - 12.0, - 5.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 12.0, - 4.0, - 16.0, - 5.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 6.0, - 0.0, - 10.0, - 4.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 6.0, - 0.0, - 10.0, - 4.0 - ] - } - } + "fixed": { + "rotation": [270, 0, 0], + "translation": [0, 0, -10.1], + "scale": [1.5, 1.5, 1.5] + }, + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 2], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [10, 0, 0], + "translation": [0, 8, -12], + "scale": [2, 2, 2] + }, + "firstperson_lefthand": { + "rotation": [10, 0, 0], + "translation": [0, 8, -12], + "scale": [2, 2, 2] + } + }, + "elements": [ + { + "name": "Base", + "from": [6.0, 0.0, 6.0], + "to": [10.0, 1.0, 10.0], + "faces": { + "north": { + "texture": "#0", + "uv": [0.0, 4.0, 4.0, 5.0] }, - { - "name": "Border", - "from": [ - 6.0, - 1.0, - 5.0 - ], - "to": [ - 10.0, - 2.0, - 6.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 1.0, - 0.0, - 5.0, - 1.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 1.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 5.0, - 0.0, - 9.0, - 1.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 4.0, - 0.0, - 5.0, - 1.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 8.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 8.0, - 0.0, - 12.0, - 1.0 - ] - } - } + "east": { + "texture": "#0", + "uv": [4.0, 4.0, 8.0, 5.0] }, - { - "name": "Border", - "from": [ - 6.0, - 1.0, - 10.0 - ], - "to": [ - 10.0, - 2.0, - 11.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 1.0, - 0.0, - 5.0, - 1.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 1.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 5.0, - 0.0, - 9.0, - 1.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 4.0, - 0.0, - 5.0, - 1.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 8.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 8.0, - 0.0, - 12.0, - 1.0 - ] - } - } + "south": { + "texture": "#0", + "uv": [8.0, 4.0, 12.0, 5.0] }, - { - "name": "Border", - "from": [ - 10.0, - 1.0, - 6.0 - ], - "to": [ - 11.0, - 2.0, - 10.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 2.0, - 0.0, - 3.0, - 1.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 4.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 5.0, - 0.0, - 6.0, - 1.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 4.0, - 0.0, - 8.0, - 1.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 11.0, - 0.0, - 12.0, - 4.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 10.0, - 0.0, - 11.0, - 4.0 - ] - } - } + "west": { + "texture": "#0", + "uv": [12.0, 4.0, 16.0, 5.0] }, - { - "name": "Border", - "from": [ - 5.0, - 1.0, - 6.0 - ], - "to": [ - 6.0, - 2.0, - 10.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 2.0, - 0.0, - 3.0, - 1.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 4.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 5.0, - 0.0, - 6.0, - 1.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 4.0, - 0.0, - 8.0, - 1.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 9.0, - 0.0, - 10.0, - 4.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 10.0, - 0.0, - 11.0, - 4.0 - ] - } - } + "up": { + "texture": "#0", + "uv": [6.0, 0.0, 10.0, 4.0] }, - { - "name": "Nibble", - "from": [ - 7.5, - 1.0, - 7.5 - ], - "to": [ - 8.5, - 2.0, - 8.5 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 4.0, - 2.0, - 6.0, - 4.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 6.0, - 2.0, - 8.0, - 4.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 7.0, - 2.0, - 9.0, - 4.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 8.0, - 2.0, - 10.0, - 4.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 10.0, - 2.0, - 12.0, - 4.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 7.0, - 2.0, - 9.0, - 4.0 - ] - } - } + "down": { + "texture": "#0", + "uv": [6.0, 0.0, 10.0, 4.0] } - ] + } + }, + { + "name": "Border", + "from": [6.0, 1.0, 5.0], + "to": [10.0, 2.0, 6.0], + "faces": { + "north": { + "texture": "#0", + "uv": [1.0, 0.0, 5.0, 1.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 1.0, 1.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [5.0, 0.0, 9.0, 1.0] + }, + "west": { + "texture": "#0", + "uv": [4.0, 0.0, 5.0, 1.0] + }, + "up": { + "texture": "#0", + "uv": [8.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "#0", + "uv": [8.0, 0.0, 12.0, 1.0] + } + } + }, + { + "name": "Border", + "from": [6.0, 1.0, 10.0], + "to": [10.0, 2.0, 11.0], + "faces": { + "north": { + "texture": "#0", + "uv": [1.0, 0.0, 5.0, 1.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 1.0, 1.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [5.0, 0.0, 9.0, 1.0] + }, + "west": { + "texture": "#0", + "uv": [4.0, 0.0, 5.0, 1.0] + }, + "up": { + "texture": "#0", + "uv": [8.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "#0", + "uv": [8.0, 0.0, 12.0, 1.0] + } + } + }, + { + "name": "Border", + "from": [10.0, 1.0, 6.0], + "to": [11.0, 2.0, 10.0], + "faces": { + "north": { + "texture": "#0", + "uv": [2.0, 0.0, 3.0, 1.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 1.0, 4.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [5.0, 0.0, 6.0, 1.0] + }, + "west": { + "texture": "#0", + "uv": [4.0, 0.0, 8.0, 1.0] + }, + "up": { + "texture": "#0", + "uv": [11.0, 0.0, 12.0, 4.0] + }, + "down": { + "texture": "#0", + "uv": [10.0, 0.0, 11.0, 4.0] + } + } + }, + { + "name": "Border", + "from": [5.0, 1.0, 6.0], + "to": [6.0, 2.0, 10.0], + "faces": { + "north": { + "texture": "#0", + "uv": [2.0, 0.0, 3.0, 1.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 1.0, 4.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [5.0, 0.0, 6.0, 1.0] + }, + "west": { + "texture": "#0", + "uv": [4.0, 0.0, 8.0, 1.0] + }, + "up": { + "texture": "#0", + "uv": [9.0, 0.0, 10.0, 4.0] + }, + "down": { + "texture": "#0", + "uv": [10.0, 0.0, 11.0, 4.0] + } + } + }, + { + "name": "Nibble", + "from": [7.5, 1.0, 7.5], + "to": [8.5, 2.0, 8.5], + "faces": { + "north": { + "texture": "#0", + "uv": [4.0, 2.0, 6.0, 4.0] + }, + "east": { + "texture": "#0", + "uv": [6.0, 2.0, 8.0, 4.0] + }, + "south": { + "texture": "#0", + "uv": [7.0, 2.0, 9.0, 4.0] + }, + "west": { + "texture": "#0", + "uv": [8.0, 2.0, 10.0, 4.0] + }, + "up": { + "texture": "#0", + "uv": [10.0, 2.0, 12.0, 4.0] + }, + "down": { + "texture": "#0", + "uv": [7.0, 2.0, 9.0, 4.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_pointer.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_pointer.json index 285262f66..c23ac2634 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_pointer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_compass_pointer.json @@ -1,77 +1,39 @@ { - "parent": "block/block", - "textures": { - "0": "appliedenergistics2:block/sky_compass" - }, - "elements": [ - { - "name": "Pointer", - "from": [ - 7.7, - 1.0, - 6 - ], - "to": [ - 8.2, - 1.5, - 8 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16.0, - 8 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16, - 8 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16.0, - 8 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16, - 8 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16.0, - 8 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 0.0, - 5.0, - 16.0, - 8 - ] - } - } + "parent": "block/block", + "textures": { + "0": "appliedenergistics2:block/sky_compass" + }, + "elements": [ + { + "name": "Pointer", + "from": [7.7, 1.0, 6], + "to": [8.2, 1.5, 8], + "faces": { + "north": { + "texture": "#0", + "uv": [0.0, 5.0, 16.0, 8] + }, + "east": { + "texture": "#0", + "uv": [0.0, 5.0, 16, 8] + }, + "south": { + "texture": "#0", + "uv": [0.0, 5.0, 16.0, 8] + }, + "west": { + "texture": "#0", + "uv": [0.0, 5.0, 16, 8] + }, + "up": { + "texture": "#0", + "uv": [0.0, 5.0, 16.0, 8] + }, + "down": { + "texture": "#0", + "uv": [0.0, 5.0, 16.0, 8] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_block.json index 45e393e04..26fa9ff50 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_block.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_brick.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_brick.json index bf03c0bef..b732030ab 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_brick.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_small_brick.json b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_small_brick.json index 6794fd25d..c427d9089 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_small_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/sky_stone_small_brick.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_half.json index b7e3a53ec..3c3313be0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side", - "top": "appliedenergistics2:block/chiseled_quartz_block_top" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side", + "top": "appliedenergistics2:block/chiseled_quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_upper.json index 16e346134..6763f831f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/chiseled_quartz_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side", - "top": "appliedenergistics2:block/chiseled_quartz_block_top" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side", + "top": "appliedenergistics2:block/chiseled_quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_half.json index 96ac741c2..1721b1ce0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/fluix_block", - "side": "appliedenergistics2:block/fluix_block", - "top": "appliedenergistics2:block/fluix_block" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/fluix_block", + "side": "appliedenergistics2:block/fluix_block", + "top": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_upper.json index 5a39d60b7..3337b7d73 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/fluix_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/fluix_block", - "side": "appliedenergistics2:block/fluix_block", - "top": "appliedenergistics2:block/fluix_block" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/fluix_block", + "side": "appliedenergistics2:block/fluix_block", + "top": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_half.json index e08d9093f..2ebe3576b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/quartz_block", - "side": "appliedenergistics2:block/quartz_block", - "top": "appliedenergistics2:block/quartz_block" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/quartz_block", + "side": "appliedenergistics2:block/quartz_block", + "top": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_half.json index b71ce6b46..3b85ffbff 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side", - "top": "appliedenergistics2:block/quartz_pillar_top" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side", + "top": "appliedenergistics2:block/quartz_pillar_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_upper.json index 0e58599ee..78b910bb0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_pillar_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side", - "top": "appliedenergistics2:block/quartz_pillar_top" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side", + "top": "appliedenergistics2:block/quartz_pillar_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_upper.json index f79f38108..4624a6a9f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/quartz_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/quartz_block", - "side": "appliedenergistics2:block/quartz_block", - "top": "appliedenergistics2:block/quartz_block" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/quartz_block", + "side": "appliedenergistics2:block/quartz_block", + "top": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_half.json index 498d55a8b..0630376f2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_brick", - "side": "appliedenergistics2:block/sky_stone_brick", - "top": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_brick", + "side": "appliedenergistics2:block/sky_stone_brick", + "top": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_upper.json index 40bf5a881..835acd2c8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_brick_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_brick", - "side": "appliedenergistics2:block/sky_stone_brick", - "top": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_brick", + "side": "appliedenergistics2:block/sky_stone_brick", + "top": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_half.json index 4f3104633..301c2ac01 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_block", - "side": "appliedenergistics2:block/sky_stone_block", - "top": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_block", + "side": "appliedenergistics2:block/sky_stone_block", + "top": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_half.json index 173d04ebd..51034f4f8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_small_brick", - "side": "appliedenergistics2:block/sky_stone_small_brick", - "top": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_small_brick", + "side": "appliedenergistics2:block/sky_stone_small_brick", + "top": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_upper.json index 39465ecba..10dacd267 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_small_brick_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_small_brick", - "side": "appliedenergistics2:block/sky_stone_small_brick", - "top": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_small_brick", + "side": "appliedenergistics2:block/sky_stone_small_brick", + "top": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_upper.json index 70178f784..ab4190f2b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/sky_stone_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_block", - "side": "appliedenergistics2:block/sky_stone_block", - "top": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_block", + "side": "appliedenergistics2:block/sky_stone_block", + "top": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_half.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_half.json index 03e846e86..af4b3f5c6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_half.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_half.json @@ -1,8 +1,8 @@ { - "parent": "block/slab", - "textures": { - "bottom": "appliedenergistics2:block/smooth_sky_stone_block", - "side": "appliedenergistics2:block/smooth_sky_stone_block", - "top": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/slab", + "textures": { + "bottom": "appliedenergistics2:block/smooth_sky_stone_block", + "side": "appliedenergistics2:block/smooth_sky_stone_block", + "top": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_upper.json b/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_upper.json index 6492ab795..38faa4eaf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_upper.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/slabs/smooth_sky_stone_upper.json @@ -1,8 +1,8 @@ { - "parent": "block/slab_top", - "textures": { - "bottom": "appliedenergistics2:block/smooth_sky_stone_block", - "side": "appliedenergistics2:block/smooth_sky_stone_block", - "top": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/slab_top", + "textures": { + "bottom": "appliedenergistics2:block/smooth_sky_stone_block", + "side": "appliedenergistics2:block/smooth_sky_stone_block", + "top": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/smooth_sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/models/block/smooth_sky_stone_block.json index e5225b999..9d9839bb9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/smooth_sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/smooth_sky_stone_block.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/spatial_io_port.json b/src/main/resources/assets/appliedenergistics2/models/block/spatial_io_port.json index be6f6c34d..2474f390f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/spatial_io_port.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/spatial_io_port.json @@ -1,8 +1,8 @@ { - "parent": "block/cube_bottom_top", - "textures": { - "bottom": "appliedenergistics2:block/spatial_io_port_bottom", - "side": "appliedenergistics2:block/spatial_io_port_side", - "top": "appliedenergistics2:block/spatial_io_port" - } + "parent": "block/cube_bottom_top", + "textures": { + "bottom": "appliedenergistics2:block/spatial_io_port_bottom", + "side": "appliedenergistics2:block/spatial_io_port_side", + "top": "appliedenergistics2:block/spatial_io_port" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/spatial_pylon.json b/src/main/resources/assets/appliedenergistics2/models/block/spatial_pylon.json index 73c19103b..bb881bbfd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/spatial_pylon.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/spatial_pylon.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:spatial_pylon" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz.json index e21a2be34..4d7a9261a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side", - "top": "appliedenergistics2:block/chiseled_quartz_block_top" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side", + "top": "appliedenergistics2:block/chiseled_quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_inner.json index 0c06405a9..eb5042713 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side", - "top": "appliedenergistics2:block/chiseled_quartz_block_top" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side", + "top": "appliedenergistics2:block/chiseled_quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_outer.json index dd4374ac6..3593f3090 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/chiseled_quartz_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", - "side": "appliedenergistics2:block/chiseled_quartz_block_side", - "top": "appliedenergistics2:block/chiseled_quartz_block_top" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/chiseled_quartz_block_top", + "side": "appliedenergistics2:block/chiseled_quartz_block_side", + "top": "appliedenergistics2:block/chiseled_quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix.json index ca8658151..fc41fa96c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/fluix_block", - "side": "appliedenergistics2:block/fluix_block", - "top": "appliedenergistics2:block/fluix_block" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/fluix_block", + "side": "appliedenergistics2:block/fluix_block", + "top": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_inner.json index 4359d1f76..2b1b360d0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/fluix_block", - "side": "appliedenergistics2:block/fluix_block", - "top": "appliedenergistics2:block/fluix_block" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/fluix_block", + "side": "appliedenergistics2:block/fluix_block", + "top": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_outer.json index b1aad6509..8cd41cee6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/fluix_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/fluix_block", - "side": "appliedenergistics2:block/fluix_block", - "top": "appliedenergistics2:block/fluix_block" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/fluix_block", + "side": "appliedenergistics2:block/fluix_block", + "top": "appliedenergistics2:block/fluix_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz.json index 7e943f87c..8b48a62e9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_block", - "side": "appliedenergistics2:block/quartz_block", - "top": "appliedenergistics2:block/quartz_block" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_block", + "side": "appliedenergistics2:block/quartz_block", + "top": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_inner.json index a02a3b05c..639eeea46 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_block", - "side": "appliedenergistics2:block/quartz_block", - "top": "appliedenergistics2:block/quartz_block" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_block", + "side": "appliedenergistics2:block/quartz_block", + "top": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_outer.json index c68646ae7..1071cf617 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_block", - "side": "appliedenergistics2:block/quartz_block", - "top": "appliedenergistics2:block/quartz_block" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_block", + "side": "appliedenergistics2:block/quartz_block", + "top": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar.json index e2a6287fc..947bf8d85 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side", - "top": "appliedenergistics2:block/quartz_pillar_top" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side", + "top": "appliedenergistics2:block/quartz_pillar_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_inner.json index 2991b3ed0..0446539b0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side", - "top": "appliedenergistics2:block/quartz_pillar_top" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side", + "top": "appliedenergistics2:block/quartz_pillar_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_outer.json index 1f226c2ff..7228fcdb7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/quartz_pillar_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/quartz_pillar_top", - "side": "appliedenergistics2:block/quartz_pillar_side", - "top": "appliedenergistics2:block/quartz_pillar_top" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/quartz_pillar_top", + "side": "appliedenergistics2:block/quartz_pillar_side", + "top": "appliedenergistics2:block/quartz_pillar_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone.json index 9725e3f69..357134281 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_block", - "side": "appliedenergistics2:block/sky_stone_block", - "top": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_block", + "side": "appliedenergistics2:block/sky_stone_block", + "top": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick.json index b5bc6f576..af863c090 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_brick", - "side": "appliedenergistics2:block/sky_stone_brick", - "top": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_brick", + "side": "appliedenergistics2:block/sky_stone_brick", + "top": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_inner.json index 27af722c6..3d765c42b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_brick", - "side": "appliedenergistics2:block/sky_stone_brick", - "top": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_brick", + "side": "appliedenergistics2:block/sky_stone_brick", + "top": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_outer.json index f4f678326..a95fc0b55 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_brick_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_brick", - "side": "appliedenergistics2:block/sky_stone_brick", - "top": "appliedenergistics2:block/sky_stone_brick" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_brick", + "side": "appliedenergistics2:block/sky_stone_brick", + "top": "appliedenergistics2:block/sky_stone_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_inner.json index 89b0d1c25..9fc79587c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_block", - "side": "appliedenergistics2:block/sky_stone_block", - "top": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_block", + "side": "appliedenergistics2:block/sky_stone_block", + "top": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_outer.json index aa0222096..9517b149a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_block", - "side": "appliedenergistics2:block/sky_stone_block", - "top": "appliedenergistics2:block/sky_stone_block" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_block", + "side": "appliedenergistics2:block/sky_stone_block", + "top": "appliedenergistics2:block/sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick.json index 41ff9564e..d075280dd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_small_brick", - "side": "appliedenergistics2:block/sky_stone_small_brick", - "top": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_small_brick", + "side": "appliedenergistics2:block/sky_stone_small_brick", + "top": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_inner.json index 7f019e294..b2b58a396 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_small_brick", - "side": "appliedenergistics2:block/sky_stone_small_brick", - "top": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_small_brick", + "side": "appliedenergistics2:block/sky_stone_small_brick", + "top": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_outer.json index fe4420119..eaf272ce5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/sky_stone_small_brick_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/sky_stone_small_brick", - "side": "appliedenergistics2:block/sky_stone_small_brick", - "top": "appliedenergistics2:block/sky_stone_small_brick" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/sky_stone_small_brick", + "side": "appliedenergistics2:block/sky_stone_small_brick", + "top": "appliedenergistics2:block/sky_stone_small_brick" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone.json index a845061e5..98349d82f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone.json @@ -1,8 +1,8 @@ { - "parent": "block/stairs", - "textures": { - "bottom": "appliedenergistics2:block/smooth_sky_stone_block", - "side": "appliedenergistics2:block/smooth_sky_stone_block", - "top": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/stairs", + "textures": { + "bottom": "appliedenergistics2:block/smooth_sky_stone_block", + "side": "appliedenergistics2:block/smooth_sky_stone_block", + "top": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_inner.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_inner.json index fd405a5f8..af49099f5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_inner.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_inner.json @@ -1,8 +1,8 @@ { - "parent": "block/inner_stairs", - "textures": { - "bottom": "appliedenergistics2:block/smooth_sky_stone_block", - "side": "appliedenergistics2:block/smooth_sky_stone_block", - "top": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/inner_stairs", + "textures": { + "bottom": "appliedenergistics2:block/smooth_sky_stone_block", + "side": "appliedenergistics2:block/smooth_sky_stone_block", + "top": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_outer.json b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_outer.json index 832e7b364..98a099224 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_outer.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/stairs/smooth_sky_stone_outer.json @@ -1,8 +1,8 @@ { - "parent": "block/outer_stairs", - "textures": { - "bottom": "appliedenergistics2:block/smooth_sky_stone_block", - "side": "appliedenergistics2:block/smooth_sky_stone_block", - "top": "appliedenergistics2:block/smooth_sky_stone_block" - } + "parent": "block/outer_stairs", + "textures": { + "bottom": "appliedenergistics2:block/smooth_sky_stone_block", + "side": "appliedenergistics2:block/smooth_sky_stone_block", + "top": "appliedenergistics2:block/smooth_sky_stone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/tiny_tnt.json b/src/main/resources/assets/appliedenergistics2/models/block/tiny_tnt.json index 69035134f..63ced931d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/tiny_tnt.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/tiny_tnt.json @@ -1,79 +1,41 @@ { - "parent": "block/block", - "elements": [ - { - "from": [ - 4, - 0, - 4 - ], - "to": [ - 12, - 8, - 12 - ], - "faces": { - "down": { - "texture": "#bottom", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "east": { - "texture": "#side", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "north": { - "texture": "#side", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "south": { - "texture": "#side", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "up": { - "texture": "#top", - "uv": [ - 0, - 0, - 16, - 16 - ] - }, - "west": { - "texture": "#side", - "uv": [ - 0, - 0, - 16, - 16 - ] - } - } + "parent": "block/block", + "elements": [ + { + "from": [4, 0, 4], + "to": [12, 8, 12], + "faces": { + "down": { + "texture": "#bottom", + "uv": [0, 0, 16, 16] + }, + "east": { + "texture": "#side", + "uv": [0, 0, 16, 16] + }, + "north": { + "texture": "#side", + "uv": [0, 0, 16, 16] + }, + "south": { + "texture": "#side", + "uv": [0, 0, 16, 16] + }, + "up": { + "texture": "#top", + "uv": [0, 0, 16, 16] + }, + "west": { + "texture": "#side", + "uv": [0, 0, 16, 16] } - ], - "textures": { - "particle": "block/tnt_side", - "side": "block/tnt_side", - "top": "block/tnt_top", - "bottom": "block/tnt_bottom" + } } + ], + "textures": { + "particle": "block/tnt_side", + "side": "block/tnt_side", + "top": "block/tnt_top", + "bottom": "block/tnt_bottom" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_off.json b/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_off.json index 653a74ee2..25b4faf45 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_off.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:block/cube/cube_ae_machine", - "textures": { - "bottom": "appliedenergistics2:block/vibration_chamber", - "front": "appliedenergistics2:block/vibration_chamber_front", - "side": "appliedenergistics2:block/vibration_chamber", - "top": "appliedenergistics2:block/vibration_chamber" - } + "parent": "appliedenergistics2:block/cube/cube_ae_machine", + "textures": { + "bottom": "appliedenergistics2:block/vibration_chamber", + "front": "appliedenergistics2:block/vibration_chamber_front", + "side": "appliedenergistics2:block/vibration_chamber", + "top": "appliedenergistics2:block/vibration_chamber" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_on.json b/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_on.json index 2e1ea0d44..794dd0354 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/vibration_chamber_on.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:block/vibration_chamber_off", - "textures": { - "front": "appliedenergistics2:block/vibration_chamber_front_on" - } + "parent": "appliedenergistics2:block/vibration_chamber_off", + "textures": { + "front": "appliedenergistics2:block/vibration_chamber_front_on" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_chassis.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_chassis.json index 6d1040ea3..a37ea30df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_chassis.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_chassis.json @@ -1,340 +1,260 @@ { - "parent": "block/block", - "textures": { - "particle": "appliedenergistics2:block/wireless_access_point_inside", - "inside": "appliedenergistics2:block/wireless_access_point_inside", - "1": "appliedenergistics2:block/wireless_access_point", - "sides": "appliedenergistics2:parts/monitor_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status" - }, - "elements": [ - { - "from": [ - 5, - 5, - 0 - ], - "to": [ - 11, - 11, - 1 - ], - "faces": { - "north": { - "texture": "#sides" - }, - "south": { - "texture": "#sides" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "down": { - "texture": "#sidesStatus" - } - } + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:block/wireless_access_point_inside", + "inside": "appliedenergistics2:block/wireless_access_point_inside", + "1": "appliedenergistics2:block/wireless_access_point", + "sides": "appliedenergistics2:parts/monitor_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status" + }, + "elements": [ + { + "from": [5, 5, 0], + "to": [11, 11, 1], + "faces": { + "north": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#sides" }, - { - "name": "Side Antenna I Up", - "from": [ - 6, - 10, - 2 - ], - "to": [ - 10, - 12, - 4 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sidesStatus" }, - { - "name": "Side Antenna I Down", - "from": [ - 6, - 4, - 2 - ], - "to": [ - 10, - 6, - 4 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "west": { + "texture": "#sidesStatus" }, - { - "name": "Side Antenna I West", - "from": [ - 4, - 6, - 2 - ], - "to": [ - 6, - 10, - 4 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "up": { + "texture": "#sidesStatus" }, - { - "name": "Side Antenna I East", - "from": [ - 10, - 6, - 2 - ], - "to": [ - 12, - 10, - 4 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } - }, - { - "name": "Side Antenna II Up", - "from": [ - 7, - 12, - 3 - ], - "to": [ - 9, - 13, - 6 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } - }, - { - "name": "Side Antenna II Down", - "from": [ - 7, - 3, - 3 - ], - "to": [ - 9, - 4, - 6 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } - }, - { - "name": "Side Antenna II West", - "from": [ - 3, - 7, - 3 - ], - "to": [ - 4, - 9, - 6 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } - }, - { - "name": "Side Antenna II East", - "from": [ - 12, - 7, - 3 - ], - "to": [ - 13, - 9, - 6 - ], - "faces": { - "north": { - "texture": "#inside" - }, - "south": { - "texture": "#inside" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "down": { + "texture": "#sidesStatus" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna I Up", + "from": [6, 10, 2], + "to": [10, 12, 4], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna I Down", + "from": [6, 4, 2], + "to": [10, 6, 4], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna I West", + "from": [4, 6, 2], + "to": [6, 10, 4], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna I East", + "from": [10, 6, 2], + "to": [12, 10, 4], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna II Up", + "from": [7, 12, 3], + "to": [9, 13, 6], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna II Down", + "from": [7, 3, 3], + "to": [9, 4, 6], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna II West", + "from": [3, 7, 3], + "to": [4, 9, 6], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "name": "Side Antenna II East", + "from": [12, 7, 3], + "to": [13, 9, 6], + "faces": { + "north": { + "texture": "#inside" + }, + "south": { + "texture": "#inside" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_off.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_off.json index 1aec510a5..fbf476540 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_off.json @@ -1,70 +1,37 @@ { - "textures": { - "torch": "appliedenergistics2:block/wireless_access_point" - }, - "elements": [ - { - "from": [ - 7, - 7, - 1 - ], - "to": [ - 9, - 9, - 9 - ], - "faces": { - "up": { - "texture": "#torch", - "uv": [ - 1, - 7, - 9, - 9 - ], - "rotation": 90 - }, - "down": { - "texture": "#torch", - "uv": [ - 1, - 7, - 9, - 9 - ], - "rotation": 270 - }, - "east": { - "texture": "#torch", - "uv": [ - 1, - 7, - 9, - 9 - ], - "rotation": 180 - }, - "west": { - "texture": "#torch", - "uv": [ - 1, - 7, - 9, - 9 - ] - }, - "south": { - "texture": "#torch", - "uv": [ - 7, - 7, - 9, - 9 - ], - "rotation": 270 - } - } + "textures": { + "torch": "appliedenergistics2:block/wireless_access_point" + }, + "elements": [ + { + "from": [7, 7, 1], + "to": [9, 9, 9], + "faces": { + "up": { + "texture": "#torch", + "uv": [1, 7, 9, 9], + "rotation": 90 + }, + "down": { + "texture": "#torch", + "uv": [1, 7, 9, 9], + "rotation": 270 + }, + "east": { + "texture": "#torch", + "uv": [1, 7, 9, 9], + "rotation": 180 + }, + "west": { + "texture": "#torch", + "uv": [1, 7, 9, 9] + }, + "south": { + "texture": "#torch", + "uv": [7, 7, 9, 9], + "rotation": 270 } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_on.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_on.json index 6b113d042..60be1d40c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_on.json @@ -1,176 +1,99 @@ { - "loader": "appliedenergistics2:uvlightmap", - "ambientocclusion": false, - "textures": { - "torch": "appliedenergistics2:block/wireless_access_point_on" - }, - "elements": [ - { - "from": [ - 7, - 7, - 1 - ], - "to": [ - 9, - 9, - 6 - ], - "faces": { - "up": { - "texture": "#torch", - "uv": [ - 1, - 7, - 6, - 9 - ], - "rotation": 90 - }, - "down": { - "texture": "#torch", - "uv": [ - 1, - 7, - 6, - 9 - ], - "rotation": 270 - }, - "east": { - "texture": "#torch", - "uv": [ - 1, - 7, - 6, - 9 - ], - "rotation": 180 - }, - "west": { - "texture": "#torch", - "uv": [ - 1, - 7, - 6, - 9 - ] - } - } + "loader": "appliedenergistics2:uvlightmap", + "ambientocclusion": false, + "textures": { + "torch": "appliedenergistics2:block/wireless_access_point_on" + }, + "elements": [ + { + "from": [7, 7, 1], + "to": [9, 9, 6], + "faces": { + "up": { + "texture": "#torch", + "uv": [1, 7, 6, 9], + "rotation": 90 }, - { - "from": [ - 7, - 7, - 7 - ], - "to": [ - 9, - 9, - 9 - ], - "shade": false, - "faces": { - "south": { - "texture": "#torch", - "uv": [ - 7, - 7, - 9, - 9 - ], - "rotation": 270, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "down": { + "texture": "#torch", + "uv": [1, 7, 6, 9], + "rotation": 270 }, - { - "from": [ - 6, - 7, - 6 - ], - "to": [ - 10, - 9, - 10 - ], - "shade": false, - "faces": { - "up": { - "texture": "#torch", - "uv": [ - 6, - 6, - 10, - 10 - ], - "rotation": 90, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "down": { - "texture": "#torch", - "uv": [ - 6, - 6, - 10, - 10 - ], - "rotation": 270, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "east": { + "texture": "#torch", + "uv": [1, 7, 6, 9], + "rotation": 180 }, - { - "from": [ - 7, - 6, - 6 - ], - "to": [ - 9, - 10, - 10 - ], - "shade": false, - "faces": { - "west": { - "texture": "#torch", - "uv": [ - 6, - 6, - 10, - 10 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#torch", - "uv": [ - 6, - 6, - 10, - 10 - ], - "rotation": 180, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "west": { + "texture": "#torch", + "uv": [1, 7, 6, 9] } - ] + } + }, + { + "from": [7, 7, 7], + "to": [9, 9, 9], + "shade": false, + "faces": { + "south": { + "texture": "#torch", + "uv": [7, 7, 9, 9], + "rotation": 270, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [6, 7, 6], + "to": [10, 9, 10], + "shade": false, + "faces": { + "up": { + "texture": "#torch", + "uv": [6, 6, 10, 10], + "rotation": 90, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "down": { + "texture": "#torch", + "uv": [6, 6, 10, 10], + "rotation": 270, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [7, 6, 6], + "to": [9, 10, 10], + "shade": false, + "faces": { + "west": { + "texture": "#torch", + "uv": [6, 6, 10, 10], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#torch", + "uv": [6, 6, 10, 10], + "rotation": 180, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_has_channel.json index 6b42310df..d42f0d34e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_has_channel.json @@ -1,53 +1,45 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 0 - ], - "to": [ - 11, - 11, - 1 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 0], + "to": [11, 11, 1], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_off.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_off.json index d8cc0de2c..f599d2021 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 5, - 0 - ], - "to": [ - 11, - 11, - 1 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 5, 0], + "to": [11, 11, 1], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_on.json b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_on.json index a705ba3a3..d1a6fa3f5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/block/wireless_access_point_status_on.json @@ -1,53 +1,45 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 5, - 0 - ], - "to": [ - 11, - 11, - 1 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 5, 0], + "to": [11, 11, 1], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_cell_component.json index 6402461e2..eac5e8e21 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/128_cubed_spatial_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/128_cubed_spatial_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_storage_cell.json index 3b2e636d4..c69707c46 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/128_cubed_spatial_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/128_cubed_spatial_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/128_cubed_spatial_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_cell_component.json index 348dd71ea..c39d36202 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16_cubed_spatial_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16_cubed_spatial_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_storage_cell.json index 28e0d6f71..a78749dd0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16_cubed_spatial_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16_cubed_spatial_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16_cubed_spatial_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16k_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/16k_cell_component.json index 1a49470f6..83161f546 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16k_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16k_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16k_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16k_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_cell_component.json index cab92d91c..721cdde72 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16k_fluid_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16k_fluid_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_storage_cell.json index 214f5bc00..ab6ccafc3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16k_fluid_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16k_fluid_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16k_fluid_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/16k_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/16k_storage_cell.json index 8decff201..54b409af5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/16k_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/16k_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/16k_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/16k_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/1k_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/1k_cell_component.json index 43d99ae1a..5d1dc18da 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/1k_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/1k_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/1k_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/1k_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_cell_component.json index dc6496937..ef1f81beb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/1k_fluid_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/1k_fluid_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_storage_cell.json index cc80de797..c4636a812 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/1k_fluid_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/1k_fluid_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/1k_fluid_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/1k_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/1k_storage_cell.json index d65bb9f3f..a1fc68efc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/1k_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/1k_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/1k_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/1k_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_cell_component.json index 4725ba8f0..c775888df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/2_cubed_spatial_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/2_cubed_spatial_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_storage_cell.json index 86d197644..885472ee2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/2_cubed_spatial_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/2_cubed_spatial_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/2_cubed_spatial_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/4k_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/4k_cell_component.json index ebf118861..b5dc3ef17 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/4k_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/4k_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/4k_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/4k_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_cell_component.json index 280d8a164..570cb0287 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/4k_fluid_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/4k_fluid_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_storage_cell.json index adeae7858..ec7ebf190 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/4k_fluid_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/4k_fluid_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/4k_fluid_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/4k_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/4k_storage_cell.json index 7d388194d..271555b18 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/4k_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/4k_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/4k_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/4k_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/64k_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/64k_cell_component.json index 0db0c8621..97413894a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/64k_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/64k_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/64k_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/64k_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_cell_component.json b/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_cell_component.json index b6afce021..338483b2b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_cell_component.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_cell_component.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/64k_fluid_cell_component" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/64k_fluid_cell_component" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_storage_cell.json index d7ea827dc..ae56fb595 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/64k_fluid_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/64k_fluid_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/64k_fluid_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/64k_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/64k_storage_cell.json index 242b2dd9f..0a8cc3207 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/64k_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/64k_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/64k_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/64k_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/advanced_card.json b/src/main/resources/assets/appliedenergistics2/models/item/advanced_card.json index 2e7769c59..b063c3f6d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/advanced_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/advanced_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/advanced_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/advanced_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/annihilation_core.json b/src/main/resources/assets/appliedenergistics2/models/item/annihilation_core.json index 06b1d5ed9..746471c3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/annihilation_core.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/annihilation_core.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/annihilation_core" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/annihilation_core" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/item/annihilation_plane.json index 328390887..5328a76e8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/annihilation_plane.json @@ -1,72 +1,56 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/plane_sides", - "plane": "appliedenergistics2:item/part/annihilation_plane" - }, - "elements": [ - { - "name": "Front", - "from": [ - 1, - 1, - 8 - ], - "to": [ - 15, - 15, - 9 - ], - "faces": { - "north": { - "texture": "plane" - }, - "south": { - "texture": "sides" - }, - "east": { - "texture": "sides" - }, - "west": { - "texture": "sides" - }, - "up": { - "texture": "sides" - }, - "down": { - "texture": "sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/plane_sides", + "plane": "appliedenergistics2:item/part/annihilation_plane" + }, + "elements": [ + { + "name": "Front", + "from": [1, 1, 8], + "to": [15, 15, 9], + "faces": { + "north": { + "texture": "plane" }, - { - "name": "Back", - "from": [ - 5, - 5, - 9 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "east": { - "texture": "sides" - }, - "south": { - "texture": "sides" - }, - "west": { - "texture": "sides" - }, - "up": { - "texture": "sides" - }, - "down": { - "texture": "sides" - } - } + "south": { + "texture": "sides" + }, + "east": { + "texture": "sides" + }, + "west": { + "texture": "sides" + }, + "up": { + "texture": "sides" + }, + "down": { + "texture": "sides" } - ] + } + }, + { + "name": "Back", + "from": [5, 5, 9], + "to": [11, 11, 10], + "faces": { + "east": { + "texture": "sides" + }, + "south": { + "texture": "sides" + }, + "west": { + "texture": "sides" + }, + "up": { + "texture": "sides" + }, + "down": { + "texture": "sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/basic_card.json b/src/main/resources/assets/appliedenergistics2/models/item/basic_card.json index 70cd9b052..83b78b666 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/basic_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/basic_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/basic_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/basic_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/biometric_card.json b/src/main/resources/assets/appliedenergistics2/models/item/biometric_card.json index 99826cdeb..1f68c9437 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/biometric_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/biometric_card.json @@ -1,3 +1,3 @@ { - "loader": "appliedenergistics2:biometric_card" + "loader": "appliedenergistics2:biometric_card" } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/biometric_card_base.json b/src/main/resources/assets/appliedenergistics2/models/item/biometric_card_base.json index 6fe327d12..a6b86a6e0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/biometric_card_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/biometric_card_base.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/biometric_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/biometric_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/black_covered_cable.json index 03469ea6f..973e0a129 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/black" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/black" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/black_covered_dense_cable.json index 36875cfa5..1b9ec6a27 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/black" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/black" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/black_glass_cable.json index 93dbc2e2c..1d91ffe55 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/black" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/black" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/black_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/black_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/black_smart_cable.json index 34e537574..80b36ab81 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/black" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/black" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/black_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/black_smart_dense_cable.json index c5a7419d4..9432f2771 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/black_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/black_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/black" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/black" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blank_pattern.json b/src/main/resources/assets/appliedenergistics2/models/item/blank_pattern.json index de64140c3..49e0bf7b7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blank_pattern.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blank_pattern.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/blank_pattern" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/blank_pattern" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_cable.json index 8af0cdbad..669edac6c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/blue" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_dense_cable.json index 1eebaff0d..63e43ea1a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/blue" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_glass_cable.json index dec655133..1b41688bc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/blue" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_cable.json index a78e7ac00..092c8803b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/blue" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_dense_cable.json index c622d15ea..a7d946674 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/blue_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/blue" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_cable.json index 8bc786751..e4b2a74bc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/brown" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/brown" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_dense_cable.json index 4354313e1..31342c355 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/brown" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/brown" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_glass_cable.json index b5f874103..435b1263f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/brown" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/brown" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_cable.json index 3cd89f5d5..6deda77d4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/brown" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/brown" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_dense_cable.json index 48ebc06f5..96b8dd812 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/brown_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/brown" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/brown" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cable_anchor.json b/src/main/resources/assets/appliedenergistics2/models/item/cable_anchor.json index 84b1550cc..5afae16cc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cable_anchor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cable_anchor.json @@ -1,41 +1,33 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "all": "appliedenergistics2:parts/cable_anchor", - "particle": "appliedenergistics2:parts/cable_anchor" - }, - "elements": [ - { - "from": [ - 7.0, - 7.0, - 5.0 - ], - "to": [ - 9.0, - 9.0, - 11.0 - ], - "faces": { - "north": { - "texture": "#all" - }, - "east": { - "texture": "#all" - }, - "south": { - "texture": "#all" - }, - "west": { - "texture": "#all" - }, - "up": { - "texture": "#all" - }, - "down": { - "texture": "#all" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "all": "appliedenergistics2:parts/cable_anchor", + "particle": "appliedenergistics2:parts/cable_anchor" + }, + "elements": [ + { + "from": [7.0, 7.0, 5.0], + "to": [9.0, 9.0, 11.0], + "faces": { + "north": { + "texture": "#all" + }, + "east": { + "texture": "#all" + }, + "south": { + "texture": "#all" + }, + "west": { + "texture": "#all" + }, + "up": { + "texture": "#all" + }, + "down": { + "texture": "#all" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json index b3b867fe9..9bdc59011 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/cable_bus" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cable_fluid_interface.json b/src/main/resources/assets/appliedenergistics2/models/item/cable_fluid_interface.json index bd7f7e264..9ea191f84 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cable_fluid_interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cable_fluid_interface.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_interface" - }, - "elements": [ - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_interface" + }, + "elements": [ + { + "from": [2, 2, 7], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 5, - 5, - 10 - ], - "to": [ - 11, - 11, - 11 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 9 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 10], + "to": [11, 11, 11], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 9], + "to": [11, 11, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cable_interface.json b/src/main/resources/assets/appliedenergistics2/models/item/cable_interface.json index e5949bcee..00ed9ec0f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cable_interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cable_interface.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/interface" - }, - "elements": [ - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/interface" + }, + "elements": [ + { + "from": [2, 2, 7], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 5, - 5, - 10 - ], - "to": [ - 11, - 11, - 11 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 9 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 10], + "to": [11, 11, 11], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 9], + "to": [11, 11, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor.json index e7ed243ac..508d7646b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/calculation_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/calculation_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor_press.json b/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor_press.json index 3d113166c..542e60802 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor_press.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/calculation_processor_press.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/calculation_processor_press" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/calculation_processor_press" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/capacity_card.json b/src/main/resources/assets/appliedenergistics2/models/item/capacity_card.json index dc28d0980..d55751142 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/capacity_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/capacity_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_capacity" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_capacity" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cell_workbench.json b/src/main/resources/assets/appliedenergistics2/models/item/cell_workbench.json index 156803961..bf0a612df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cell_workbench.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cell_workbench.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/cell_workbench" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed.json index 0df0eaea9..834ecea11 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed.json @@ -1,20 +1,20 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_certus" + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_certus" + }, + "overrides": [ + { + "predicate": { + "appliedenergistics2:growth": 0.333 + }, + "model": "appliedenergistics2:item/certus_crystal_seed_2" }, - "overrides": [ - { - "predicate": { - "appliedenergistics2:growth": 0.333 - }, - "model": "appliedenergistics2:item/certus_crystal_seed_2" - }, - { - "predicate": { - "appliedenergistics2:growth": 0.666 - }, - "model": "appliedenergistics2:item/certus_crystal_seed_3" - } - ] + { + "predicate": { + "appliedenergistics2:growth": 0.666 + }, + "model": "appliedenergistics2:item/certus_crystal_seed_3" + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_2.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_2.json index 5e19a869f..06ef4291e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_2.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_2.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_certus2" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_certus2" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_3.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_3.json index 15240ebd2..dab7434c5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_3.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_crystal_seed_3.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_certus3" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_certus3" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_axe.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_axe.json index 667321149..9acf4c325 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_axe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_axe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_axe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_axe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_crystal.json index 9aee79908..29af71256 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_crystal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_crystal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_cutting_knife.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_cutting_knife.json index ca662573d..6291caa33 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_cutting_knife.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_cutting_knife.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_cutting_knife" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_cutting_knife" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_dust.json index 36d02e94d..e428cc2c0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_hoe.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_hoe.json index c1dbbc9af..36e39d39b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_hoe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_hoe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_hoe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_hoe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_pickaxe.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_pickaxe.json index fc6389e23..0ccbdccc0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_pickaxe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_pickaxe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_pickaxe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_pickaxe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_shovel.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_shovel.json index ab7e204ad..df0c07132 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_shovel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_shovel.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_shovel" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_shovel" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_sword.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_sword.json index bfb9ccd67..ebcce3bcc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_sword.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_sword.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_sword" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_sword" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_wrench.json b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_wrench.json index 948d05bc7..ea666d01c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_wrench.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/certus_quartz_wrench.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_wrench" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_wrench" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/charged_certus_quartz_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/charged_certus_quartz_crystal.json index a5eea9a21..9e4eb7ac0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/charged_certus_quartz_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/charged_certus_quartz_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/certus_quartz_crystal_charged" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/certus_quartz_crystal_charged" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/charged_quartz_ore.json b/src/main/resources/assets/appliedenergistics2/models/item/charged_quartz_ore.json index 835ad753b..235bebf73 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/charged_quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/charged_quartz_ore.json @@ -3,4 +3,4 @@ "textures": { "all": "appliedenergistics2:block/charged_quartz_ore" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/charged_staff.json b/src/main/resources/assets/appliedenergistics2/models/item/charged_staff.json index ebafab846..3ea6fa90c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/charged_staff.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/charged_staff.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/charged_staff" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/charged_staff" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/charger.json b/src/main/resources/assets/appliedenergistics2/models/item/charger.json index 5a2239a81..eeae632fc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/charger.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/charger.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/charger" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_block.json b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_block.json index 72e279c08..466e542b8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_block.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/chiseled_quartz_block" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_slab.json index 343f73e44..2409988df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/chiseled_quartz_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_stairs.json index ef90892e8..366baa0fe 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/chiseled_quartz_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/chiseled_quartz" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/color_applicator.json b/src/main/resources/assets/appliedenergistics2/models/item/color_applicator.json index 2db583c66..b5609d622 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/color_applicator.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/color_applicator.json @@ -1,15 +1,14 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/color_applicator" - }, - "overrides": [ - { - "predicate": { - "appliedenergistics2:colored": 1 - }, - "model": "appliedenergistics2:item/color_applicator_colored" - } - ] - + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/color_applicator" + }, + "overrides": [ + { + "predicate": { + "appliedenergistics2:colored": 1 + }, + "model": "appliedenergistics2:item/color_applicator_colored" + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/color_applicator_colored.json b/src/main/resources/assets/appliedenergistics2/models/item/color_applicator_colored.json index 658e937af..7ecc8d6d8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/color_applicator_colored.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/color_applicator_colored.json @@ -1,9 +1,9 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/color_applicator", - "layer1": "appliedenergistics2:item/color_applicator_tip_dark", - "layer2": "appliedenergistics2:item/color_applicator_tip_medium", - "layer3": "appliedenergistics2:item/color_applicator_tip_bright" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/color_applicator", + "layer1": "appliedenergistics2:item/color_applicator_tip_dark", + "layer2": "appliedenergistics2:item/color_applicator_tip_medium", + "layer3": "appliedenergistics2:item/color_applicator_tip_bright" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/condenser.json b/src/main/resources/assets/appliedenergistics2/models/item/condenser.json index 6fe0715e2..3320f51bb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/condenser.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/condenser.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/condenser" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/conversion_monitor.json b/src/main/resources/assets/appliedenergistics2/models/item/conversion_monitor.json index 1a5e7d74b..47353aadb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/conversion_monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/conversion_monitor.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/conversion_monitor", - "front_bright": "appliedenergistics2:parts/conversion_monitor_bright", - "front_medium": "appliedenergistics2:parts/conversion_monitor_medium", - "front_dark": "appliedenergistics2:parts/conversion_monitor_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/conversion_monitor", + "front_bright": "appliedenergistics2:parts/conversion_monitor_bright", + "front_medium": "appliedenergistics2:parts/conversion_monitor_medium", + "front_dark": "appliedenergistics2:parts/conversion_monitor_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/covered_cable_base.json b/src/main/resources/assets/appliedenergistics2/models/item/covered_cable_base.json index 32c67cd72..d63b227c9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/covered_cable_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/covered_cable_base.json @@ -1,74 +1,36 @@ { - "parent": "appliedenergistics2:item/part_base", - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 2.0 - ], - "to": [ - 11.0, - 11.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 2.0], + "to": [11.0, 11.0, 14.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/covered_dense_cable_base.json b/src/main/resources/assets/appliedenergistics2/models/item/covered_dense_cable_base.json index fa02e1bbe..3114ff979 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/covered_dense_cable_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/covered_dense_cable_base.json @@ -1,74 +1,36 @@ { - "parent": "appliedenergistics2:item/part_base", - "elements": [ - { - "name": "Base", - "from": [ - 4.0, - 4.0, - 2.0 - ], - "to": [ - 12.0, - 12.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 4.0, - 4.0, - 12.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 4.0, - 4.0, - 12.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 4.0, - 4.0, - 12.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 4.0, - 4.0, - 0.0, - 12.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 4.0, - 0.0, - 12.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 4.0, - 12.0, - 12.0, - 16.0 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "elements": [ + { + "name": "Base", + "from": [4.0, 4.0, 2.0], + "to": [12.0, 12.0, 14.0], + "faces": { + "north": { + "texture": "#base", + "uv": [4.0, 4.0, 12.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [0.0, 4.0, 4.0, 12.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 4.0, 4.0, 12.0] + }, + "west": { + "texture": "#base", + "uv": [4.0, 4.0, 0.0, 12.0] + }, + "up": { + "texture": "#base", + "uv": [4.0, 0.0, 12.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [4.0, 12.0, 12.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/crafting_card.json b/src/main/resources/assets/appliedenergistics2/models/item/crafting_card.json index cd1439b58..73e9c7a20 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/crafting_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/crafting_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_crafting" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_crafting" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/crafting_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/crafting_terminal.json index e735aacf7..3ff073c31 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/crafting_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/crafting_terminal.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/crafting_terminal", - "front_bright": "appliedenergistics2:parts/crafting_terminal_bright", - "front_medium": "appliedenergistics2:parts/crafting_terminal_medium", - "front_dark": "appliedenergistics2:parts/crafting_terminal_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/crafting_terminal", + "front_bright": "appliedenergistics2:parts/crafting_terminal_bright", + "front_medium": "appliedenergistics2:parts/crafting_terminal_medium", + "front_dark": "appliedenergistics2:parts/crafting_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/crank.json b/src/main/resources/assets/appliedenergistics2/models/item/crank.json index b7edb1459..734d4c895 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/crank.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/crank.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/crank" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/creative_energy_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/creative_energy_cell.json index feb6e9877..4472c29c3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/creative_energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/creative_energy_cell.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/energy_cell/creative_energy_cell" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/creative_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/creative_storage_cell.json index 280a1d8bd..53637c03f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/creative_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/creative_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/creative_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/creative_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_cable.json index e0563c39c..8221ffdf1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/cyan" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/cyan" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_dense_cable.json index 3da96d0b9..b91653cdc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/cyan" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/cyan" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_glass_cable.json index ceac2b9e4..e27d40091 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/cyan" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/cyan" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_cable.json index 4b18a5022..ae2af797b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/cyan" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/cyan" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_dense_cable.json index 3fcfed058..cc988f273 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cyan_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/cyan" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/cyan" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/dark_monitor.json b/src/main/resources/assets/appliedenergistics2/models/item/dark_monitor.json index 27302137b..1102fd78a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/dark_monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/dark_monitor.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:parts/monitor_front", - "front_bright": "appliedenergistics2:parts/monitor_colored", - "front_medium": "appliedenergistics2:parts/monitor_bright", - "front_dark": "appliedenergistics2:parts/monitor_colored" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:parts/monitor_front", + "front_bright": "appliedenergistics2:parts/monitor_colored", + "front_medium": "appliedenergistics2:parts/monitor_bright", + "front_dark": "appliedenergistics2:parts/monitor_colored" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/debug_card.json b/src/main/resources/assets/appliedenergistics2/models/item/debug_card.json index 72ad086b1..c700ae8cd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/debug_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/debug_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/debug_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/debug_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/dense_energy_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/dense_energy_cell.json index 78a9f64bb..709f85b90 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/dense_energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/dense_energy_cell.json @@ -44,4 +44,4 @@ "model": "appliedenergistics2:block/energy_cell/dense_energy_cell7" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/display_base.json b/src/main/resources/assets/appliedenergistics2/models/item/display_base.json index bf353dc5e..671d69a7f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/display_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/display_base.json @@ -1,149 +1,101 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front_medium_bright": "appliedenergistics2:parts/monitor_colored" - }, - "elements": [ - { - "name": "Front", - "from": [ - 2, - 2, - 8 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front_medium_bright": "appliedenergistics2:parts/monitor_colored" + }, + "elements": [ + { + "name": "Front", + "from": [2, 2, 8], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front" }, - { - "name": "Front Bright", - "from": [ - 2, - 2, - 8 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front_bright", - "tintindex": 3 - } - } + "south": { + "texture": "#back" }, - { - "name": "Front Medium Bright", - "from": [ - 2, - 2, - 8 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front_medium_bright", - "tintindex": 4 - } - } + "east": { + "texture": "#sides" }, - { - "name": "Front Medium", - "from": [ - 2, - 2, - 8 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front_medium", - "tintindex": 2 - } - } + "west": { + "texture": "#sides" }, - { - "name": "Front Dark", - "from": [ - 2, - 2, - 8 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front_dark", - "tintindex": 1 - } - } + "up": { + "texture": "#sides" }, - { - "name": "Back", - "from": [ - 4, - 4, - 9 - ], - "to": [ - 12, - 12, - 10 - ], - "faces": { - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "down": { + "texture": "#sides" } - ] + } + }, + { + "name": "Front Bright", + "from": [2, 2, 8], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front_bright", + "tintindex": 3 + } + } + }, + { + "name": "Front Medium Bright", + "from": [2, 2, 8], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front_medium_bright", + "tintindex": 4 + } + } + }, + { + "name": "Front Medium", + "from": [2, 2, 8], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front_medium", + "tintindex": 2 + } + } + }, + { + "name": "Front Dark", + "from": [2, 2, 8], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front_dark", + "tintindex": 1 + } + } + }, + { + "name": "Back", + "from": [4, 4, 9], + "to": [12, 12, 10], + "faces": { + "east": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/drive.json b/src/main/resources/assets/appliedenergistics2/models/item/drive.json index dc9c9a20b..46e566986 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/drive.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/drive.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:block/drive/drive_base", - "textures": { - "front": "appliedenergistics2:block/drive/drive_front_flat" - } + "parent": "appliedenergistics2:block/drive/drive_base", + "textures": { + "front": "appliedenergistics2:block/drive/drive_front_flat" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/dummy_fluid_item_base.json b/src/main/resources/assets/appliedenergistics2/models/item/dummy_fluid_item_base.json index b68686041..0ce126fdc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/dummy_fluid_item_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/dummy_fluid_item_base.json @@ -1,5 +1,4 @@ { "parent": "item/generated", - "textures": { - } + "textures": {} } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/empty_storage_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/empty_storage_cell.json index ff43c3cbf..127ecbcfd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/empty_storage_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/empty_storage_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/empty_storage_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/empty_storage_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern.json b/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern.json index 3e4453dd0..5f648927a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern.json @@ -1,4 +1,4 @@ { - "loader": "appliedenergistics2:encoded_pattern", - "baseModel": "appliedenergistics2:item/encoded_pattern_base" -} \ No newline at end of file + "loader": "appliedenergistics2:encoded_pattern", + "baseModel": "appliedenergistics2:item/encoded_pattern_base" +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern_base.json b/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern_base.json index ee3f69165..b0fbf4162 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/encoded_pattern_base.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/encoded_pattern" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/encoded_pattern" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/ender_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/ender_dust.json index f3bc33f0f..f2c58a39b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/ender_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/ender_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/ender_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/ender_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/energy_acceptor.json b/src/main/resources/assets/appliedenergistics2/models/item/energy_acceptor.json index f83e52781..ebedd9741 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/energy_acceptor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/energy_acceptor.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/energy_acceptor" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/energy_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/energy_cell.json index 0bdcc97bf..e8ea4e909 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/energy_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/energy_cell.json @@ -44,4 +44,4 @@ "model": "appliedenergistics2:block/energy_cell/energy_cell7" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor.json index 1db3d9348..7f2854a5a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/engineering_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/engineering_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor_press.json b/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor_press.json index 73d25ee02..60d3ee154 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor_press.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/engineering_processor_press.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/engineering_processor_press" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/engineering_processor_press" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/entropy_manipulator.json b/src/main/resources/assets/appliedenergistics2/models/item/entropy_manipulator.json index 61b3bdd90..1a2d54d7d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/entropy_manipulator.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/entropy_manipulator.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/entropy_manipulator" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/entropy_manipulator" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/export_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/export_bus.json index 0f3dbeff4..da2176f8a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/export_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/export_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/export_bus" - }, - "elements": [ - { - "from": [ - 4, - 4, - 8 - ], - "to": [ - 12, - 12, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/export_bus" + }, + "elements": [ + { + "from": [4, 4, 8], + "to": [12, 12, 10], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 5, - 5, - 7 - ], - "to": [ - 11, - 11, - 8 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 6 - ], - "to": [ - 10, - 10, - 7 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 7], + "to": [11, 11, 8], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 6], + "to": [10, 10, 7], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/facade_base.json b/src/main/resources/assets/appliedenergistics2/models/item/facade_base.json index 1883437ea..8023830c0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/facade_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/facade_base.json @@ -6,15 +6,15 @@ }, "display": { "gui": { - "rotation": [ 30, 225, 0 ], - "translation": [ -4, 2, 0], - "scale":[ 0.7, 0.7, 0.7 ] + "rotation": [30, 225, 0], + "translation": [-4, 2, 0], + "scale": [0.7, 0.7, 0.7] } }, "elements": [ { - "from": [ 7.0, 7.0, 2.0 ], - "to": [ 9.0, 9.0, 10.0 ], + "from": [7.0, 7.0, 2.0], + "to": [9.0, 9.0, 10.0], "faces": { "north": { "texture": "#anchor" }, "east": { "texture": "#anchor" }, diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fe_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/fe_p2p_tunnel.json index 85d2a333a..712069631 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fe_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fe_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/gold_block" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/gold_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/flour.json b/src/main/resources/assets/appliedenergistics2/models/item/flour.json index bdcef9d79..20ed54997 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/flour.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/flour.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/flour" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/flour" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_annihilation_plane.json index b209bbc0c..382b9727a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_annihilation_plane.json @@ -1,72 +1,56 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/plane_sides", - "plane": "appliedenergistics2:item/part/fluid_annihilation_plane" - }, - "elements": [ - { - "name": "Front", - "from": [ - 1, - 1, - 8 - ], - "to": [ - 15, - 15, - 9 - ], - "faces": { - "north": { - "texture": "plane" - }, - "south": { - "texture": "sides" - }, - "east": { - "texture": "sides" - }, - "west": { - "texture": "sides" - }, - "up": { - "texture": "sides" - }, - "down": { - "texture": "sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/plane_sides", + "plane": "appliedenergistics2:item/part/fluid_annihilation_plane" + }, + "elements": [ + { + "name": "Front", + "from": [1, 1, 8], + "to": [15, 15, 9], + "faces": { + "north": { + "texture": "plane" }, - { - "name": "Back", - "from": [ - 5, - 5, - 9 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "east": { - "texture": "sides" - }, - "south": { - "texture": "sides" - }, - "west": { - "texture": "sides" - }, - "up": { - "texture": "sides" - }, - "down": { - "texture": "sides" - } - } + "south": { + "texture": "sides" + }, + "east": { + "texture": "sides" + }, + "west": { + "texture": "sides" + }, + "up": { + "texture": "sides" + }, + "down": { + "texture": "sides" } - ] + } + }, + { + "name": "Back", + "from": [5, 5, 9], + "to": [11, 11, 10], + "faces": { + "east": { + "texture": "sides" + }, + "south": { + "texture": "sides" + }, + "west": { + "texture": "sides" + }, + "up": { + "texture": "sides" + }, + "down": { + "texture": "sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_export_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_export_bus.json index e6f6410c4..ff0d293be 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_export_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_export_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_export_bus" - }, - "elements": [ - { - "from": [ - 4, - 4, - 8 - ], - "to": [ - 12, - 12, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_export_bus" + }, + "elements": [ + { + "from": [4, 4, 8], + "to": [12, 12, 10], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 5, - 5, - 7 - ], - "to": [ - 11, - 11, - 8 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 6 - ], - "to": [ - 10, - 10, - 7 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 7], + "to": [11, 11, 8], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 6], + "to": [10, 10, 7], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_formation_plane.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_formation_plane.json index 33d64d2e1..8dc7a2b68 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_formation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_formation_plane.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/annihilation_plane", - "textures": { - "plane": "appliedenergistics2:item/part/fluid_formation_plane" - } + "parent": "appliedenergistics2:item/annihilation_plane", + "textures": { + "plane": "appliedenergistics2:item/part/fluid_formation_plane" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_import_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_import_bus.json index 8e127bfb3..a38eeb6cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_import_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_import_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/import_bus_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_import_bus" - }, - "elements": [ - { - "from": [ - 3, - 3, - 8 - ], - "to": [ - 13, - 13, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/import_bus_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_import_bus" + }, + "elements": [ + { + "from": [3, 3, 8], + "to": [13, 13, 9], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 4, - 4, - 9 - ], - "to": [ - 12, - 12, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 10 - ], - "to": [ - 11, - 11, - 11 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [4, 4, 9], + "to": [12, 12, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 10], + "to": [11, 11, 11], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_interface.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_interface.json index fba8d2b71..44ed54e6f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_interface.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/fluid_interface" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_level_emitter.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_level_emitter.json index 55b1728f4..5582ee69a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_level_emitter.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_level_emitter.json @@ -1,76 +1,38 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "emitter": "appliedenergistics2:item/part/level_emitter_off" - }, - "elements": [ - { - "from": [ - 7, - 6, - 7 - ], - "to": [ - 9, - 10, - 9 - ], - "faces": { - "north": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "south": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "east": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "west": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "up": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 9 - ] - }, - "down": { - "texture": "#emitter", - "uv": [ - 7, - 9, - 9, - 11 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "emitter": "appliedenergistics2:item/part/level_emitter_off" + }, + "elements": [ + { + "from": [7, 6, 7], + "to": [9, 10, 9], + "faces": { + "north": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "south": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "east": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "west": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "up": { + "texture": "#emitter", + "uv": [7, 7, 9, 9] + }, + "down": { + "texture": "#emitter", + "uv": [7, 9, 9, 11] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_p2p_tunnel.json index b978b1d7c..40cd16864 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/lapis_block" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/lapis_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_storage_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_storage_bus.json index 1c1115095..15fb4dd4b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_storage_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_storage_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/storage_bus_sides", - "back": "appliedenergistics2:parts/storage_bus_back", - "front": "appliedenergistics2:item/part/fluid_storage_bus" - }, - "elements": [ - { - "from": [ - 3, - 3, - 6 - ], - "to": [ - 13, - 13, - 7 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/storage_bus_sides", + "back": "appliedenergistics2:parts/storage_bus_back", + "front": "appliedenergistics2:item/part/fluid_storage_bus" + }, + "elements": [ + { + "from": [3, 3, 6], + "to": [13, 13, 7], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 8 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 8 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [2, 2, 7], + "to": [14, 14, 8], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 8], + "to": [11, 11, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluid_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/fluid_terminal.json index bfa892da0..c07799c13 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluid_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluid_terminal.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/crafting_terminal", - "front_bright": "appliedenergistics2:parts/fluid_terminal/lights_bright", - "front_medium": "appliedenergistics2:parts/fluid_terminal/lights_medium", - "front_dark": "appliedenergistics2:parts/fluid_terminal/lights_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/crafting_terminal", + "front_bright": "appliedenergistics2:parts/fluid_terminal/lights_bright", + "front_medium": "appliedenergistics2:parts/fluid_terminal/lights_medium", + "front_dark": "appliedenergistics2:parts/fluid_terminal/lights_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_block.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_block.json index 41a76fa9e..ecbf622d4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_block.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/fluix_block" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_cable.json index 12ccf81d9..6731bbbca 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/transparent" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/transparent" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_dense_cable.json index 97300841d..013f45a21 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/transparent" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/transparent" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal.json index 5ed8929cd..a70a7dd53 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/fluix_crystal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/fluix_crystal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed.json index 097c2f511..c7bd0c7a0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed.json @@ -1,20 +1,20 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_fluix" + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_fluix" + }, + "overrides": [ + { + "predicate": { + "appliedenergistics2:growth": 0.333 + }, + "model": "appliedenergistics2:item/fluix_crystal_seed_2" }, - "overrides": [ - { - "predicate": { - "appliedenergistics2:growth": 0.333 - }, - "model": "appliedenergistics2:item/fluix_crystal_seed_2" - }, - { - "predicate": { - "appliedenergistics2:growth": 0.666 - }, - "model": "appliedenergistics2:item/fluix_crystal_seed_3" - } - ] + { + "predicate": { + "appliedenergistics2:growth": 0.666 + }, + "model": "appliedenergistics2:item/fluix_crystal_seed_3" + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_2.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_2.json index f4fa27adc..e0a07d3e1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_2.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_2.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_fluix2" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_fluix2" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_3.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_3.json index 98622217f..3097fdb6f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_3.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_crystal_seed_3.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_fluix3" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_fluix3" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_dust.json index e0c37b4fc..eb60afab1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/fluix_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/fluix_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_glass_cable.json index d65ddc4f9..3a98fe454 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/transparent" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/transparent" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_pearl.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_pearl.json index 1bcdf8c47..f60552f13 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_pearl.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_pearl.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/fluix_pearl" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/fluix_pearl" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_slab.json index 28c9b0396..15c9c78e6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/fluix_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_cable.json index a470fe647..374b96dbf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/transparent" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/transparent" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_dense_cable.json index 5e0ef6541..37ad17c3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/transparent" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/transparent" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fluix_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/fluix_stairs.json index d4c6416dd..5196f2d5c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fluix_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fluix_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/fluix" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/formation_core.json b/src/main/resources/assets/appliedenergistics2/models/item/formation_core.json index 2183cd187..88b78d324 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/formation_core.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/formation_core.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/formation_core" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/formation_core" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/formation_plane.json b/src/main/resources/assets/appliedenergistics2/models/item/formation_plane.json index bbad02c5c..7a8d1c57e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/formation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/formation_plane.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/annihilation_plane", - "textures": { - "plane": "appliedenergistics2:item/part/formation_plane" - } + "parent": "appliedenergistics2:item/annihilation_plane", + "textures": { + "plane": "appliedenergistics2:item/part/formation_plane" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/fuzzy_card.json b/src/main/resources/assets/appliedenergistics2/models/item/fuzzy_card.json index 54a7316e8..09bc2896c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/fuzzy_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/fuzzy_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_fuzzy" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_fuzzy" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/glass_cable_base.json b/src/main/resources/assets/appliedenergistics2/models/item/glass_cable_base.json index cc57fd5f4..e97bed034 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/glass_cable_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/glass_cable_base.json @@ -1,37 +1,29 @@ { - "parent": "appliedenergistics2:item/part_base", - "elements": [ - { - "from": [ - 6.0, - 6.0, - 2.0 - ], - "to": [ - 10.0, - 10.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#base" - }, - "east": { - "texture": "#base" - }, - "south": { - "texture": "#base" - }, - "west": { - "texture": "#base" - }, - "up": { - "texture": "#base" - }, - "down": { - "texture": "#base" - } - } + "parent": "appliedenergistics2:item/part_base", + "elements": [ + { + "from": [6.0, 6.0, 2.0], + "to": [10.0, 10.0, 14.0], + "faces": { + "north": { + "texture": "#base" + }, + "east": { + "texture": "#base" + }, + "south": { + "texture": "#base" + }, + "west": { + "texture": "#base" + }, + "up": { + "texture": "#base" + }, + "down": { + "texture": "#base" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gold_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/gold_dust.json index 5cf18d4bc..3566ba3eb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gold_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gold_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/gold_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/gold_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_cable.json index c31e02dd2..fd8b4abd7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/gray" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_dense_cable.json index b7459503b..20e96c5b9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/gray" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_glass_cable.json index f346db944..f84511d1b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/gray" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_cable.json index 4c9a43793..5faad7a95 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/gray" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_dense_cable.json index 6c125ccc9..5089cb3cc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/gray_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/gray" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/green_covered_cable.json index 20da628e1..fc361952c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/green" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/green" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/green_covered_dense_cable.json index 096c51ebb..b232c4b22 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/green" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/green" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/green_glass_cable.json index dfa58b720..90d416858 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/green" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/green" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/green_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/green_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/green_smart_cable.json index 7dc83921d..e0363a7c7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/green" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/green" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/green_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/green_smart_dense_cable.json index aa19cc47d..ac7aa7eb9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/green_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/green_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/green" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/green" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/grindstone.json b/src/main/resources/assets/appliedenergistics2/models/item/grindstone.json index fd74c46df..e4b94f70d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/grindstone.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/grindstone.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/grindstone" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/ic2_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/ic2_p2p_tunnel.json index 102b3ff51..d7e72fa95 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/ic2_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/ic2_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/diamond_block" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/diamond_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/identity_annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/item/identity_annihilation_plane.json index 69243d670..03f4e0f18 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/identity_annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/identity_annihilation_plane.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/annihilation_plane", - "textures": { - "plane": "appliedenergistics2:item/part/identity_annihilation_plane" - } + "parent": "appliedenergistics2:item/annihilation_plane", + "textures": { + "plane": "appliedenergistics2:item/part/identity_annihilation_plane" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/import_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/import_bus.json index c629108ee..d37623ec4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/import_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/import_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/import_bus_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/import_bus" - }, - "elements": [ - { - "from": [ - 3, - 3, - 8 - ], - "to": [ - 13, - 13, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/import_bus_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/import_bus" + }, + "elements": [ + { + "from": [3, 3, 8], + "to": [13, 13, 9], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 4, - 4, - 9 - ], - "to": [ - 12, - 12, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 10 - ], - "to": [ - 11, - 11, - 11 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [4, 4, 9], + "to": [12, 12, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 10], + "to": [11, 11, 11], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/inscriber.json b/src/main/resources/assets/appliedenergistics2/models/item/inscriber.json index 6e21cfb38..cd3fac034 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/inscriber.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/inscriber.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/inscriber" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/interface.json b/src/main/resources/assets/appliedenergistics2/models/item/interface.json index 75cdf1faf..5628a9fdf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/interface.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/interface.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/interface" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/interface_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/interface_terminal.json index bb8425066..2dbf34fac 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/interface_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/interface_terminal.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/interface_terminal", - "front_bright": "appliedenergistics2:parts/interface_terminal_bright", - "front_medium": "appliedenergistics2:parts/interface_terminal_medium", - "front_dark": "appliedenergistics2:parts/interface_terminal_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/interface_terminal", + "front_bright": "appliedenergistics2:parts/interface_terminal_bright", + "front_medium": "appliedenergistics2:parts/interface_terminal_medium", + "front_dark": "appliedenergistics2:parts/interface_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/invalid_type.json b/src/main/resources/assets/appliedenergistics2/models/item/invalid_type.json index 5ab2372b3..c6e05dcc2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/invalid_type.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/invalid_type.json @@ -1,3 +1,3 @@ { - "parent": "block/block" + "parent": "block/block" } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/inverted_toggle_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/inverted_toggle_bus.json index 1b0396fe1..aa967485a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/inverted_toggle_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/inverted_toggle_bus.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/toggle_bus", - "textures": { - "bus": "appliedenergistics2:item/part/inverted_toggle_bus" - } + "parent": "appliedenergistics2:item/toggle_bus", + "textures": { + "bus": "appliedenergistics2:item/part/inverted_toggle_bus" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/inverter_card.json b/src/main/resources/assets/appliedenergistics2/models/item/inverter_card.json index 24eef9d63..9e157b77c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/inverter_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/inverter_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_inverter" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_inverter" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/io_port.json b/src/main/resources/assets/appliedenergistics2/models/item/io_port.json index 54c402e18..f1301c9c0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/io_port.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/io_port.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/io_port" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/iron_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/iron_dust.json index dba1ccbad..625f5eb46 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/iron_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/iron_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/iron_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/iron_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/item_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/item_p2p_tunnel.json index a52275810..894381bf9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/item_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/item_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/hopper_outside" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/hopper_outside" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/level_emitter.json b/src/main/resources/assets/appliedenergistics2/models/item/level_emitter.json index 55b1728f4..5582ee69a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/level_emitter.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/level_emitter.json @@ -1,76 +1,38 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "emitter": "appliedenergistics2:item/part/level_emitter_off" - }, - "elements": [ - { - "from": [ - 7, - 6, - 7 - ], - "to": [ - 9, - 10, - 9 - ], - "faces": { - "north": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "south": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "east": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "west": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 11 - ] - }, - "up": { - "texture": "#emitter", - "uv": [ - 7, - 7, - 9, - 9 - ] - }, - "down": { - "texture": "#emitter", - "uv": [ - 7, - 9, - 9, - 11 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "emitter": "appliedenergistics2:item/part/level_emitter_off" + }, + "elements": [ + { + "from": [7, 6, 7], + "to": [9, 10, 9], + "faces": { + "north": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "south": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "east": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "west": { + "texture": "#emitter", + "uv": [7, 7, 9, 11] + }, + "up": { + "texture": "#emitter", + "uv": [7, 7, 9, 9] + }, + "down": { + "texture": "#emitter", + "uv": [7, 9, 9, 11] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_cable.json index 0642de071..bc18d3549 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/light_blue" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/light_blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_dense_cable.json index 923e9b306..78cfbbea3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/light_blue" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/light_blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_glass_cable.json index f724536b6..58b7f723b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/light_blue" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/light_blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_cable.json index ebb4fd9e8..c5daac955 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/light_blue" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/light_blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_dense_cable.json index 40fece549..d46cc2fd1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_blue_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/light_blue" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/light_blue" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_detector.json b/src/main/resources/assets/appliedenergistics2/models/item/light_detector.json index 08e4d3084..fb2ac6f1b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_detector.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_detector.json @@ -1,3 +1,3 @@ { - "parent": "appliedenergistics2:item/quartz_fixture" + "parent": "appliedenergistics2:item/quartz_fixture" } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_cable.json index bb19a05d8..f881cfe10 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/light_gray" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/light_gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_dense_cable.json index 7f7f4ed8f..39302d96d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/light_gray" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/light_gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_glass_cable.json index 013a082c0..8ba311c3d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/light_gray" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/light_gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_cable.json index f86128aa1..bb66a640d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/light_gray" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/light_gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_dense_cable.json index e6f5c03bf..181898bd7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_gray_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/light_gray" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/light_gray" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/light_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/light_p2p_tunnel.json index a70de37f6..74fa08b05 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/light_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/light_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/quartz_block_top" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_cable.json index b96984fb4..7dfc9da31 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/lime" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/lime" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_dense_cable.json index 9b7331c6c..b9583ee74 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/lime" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/lime" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_glass_cable.json index b644cb060..c40012f01 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/lime" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/lime" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_cable.json index 058ecebe0..1bd5973f0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/lime" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/lime" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_dense_cable.json index b8389fde6..6d746f9d7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/lime_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/lime" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/lime" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/logic_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/logic_processor.json index 88378b5b6..7f9fbed6c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/logic_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/logic_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/logic_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/logic_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/logic_processor_press.json b/src/main/resources/assets/appliedenergistics2/models/item/logic_processor_press.json index ca4535465..41fc78144 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/logic_processor_press.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/logic_processor_press.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/logic_processor_press" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/logic_processor_press" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_cable.json index ddb3436dd..b58b59583 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/magenta" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/magenta" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_dense_cable.json index 76215a10e..826c59f4a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/magenta" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/magenta" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_glass_cable.json index 73820df5a..5bf8f37f3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/magenta" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/magenta" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_cable.json index f43d3e191..281e48ef9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/magenta" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/magenta" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_dense_cable.json index b628bd4c4..d72d894e5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/magenta_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/magenta" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/magenta" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/matrix_frame.json b/src/main/resources/assets/appliedenergistics2/models/item/matrix_frame.json index 7efbb5ff3..dda24d544 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/matrix_frame.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/matrix_frame.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/matrix_frame" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/matter_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/matter_ball.json index eb77b592b..5bddb40c3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/matter_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/matter_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/matter_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/matter_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/matter_cannon.json b/src/main/resources/assets/appliedenergistics2/models/item/matter_cannon.json index 931319c0e..38105d00b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/matter_cannon.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/matter_cannon.json @@ -1,22 +1,14 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/matter_cannon" + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/matter_cannon" + }, + "display": { + "thirdperson_righthand": { + "rotation": [0, -90, 0] }, - "display": { - "thirdperson_righthand": { - "rotation": [ - 0, - -90, - 0 - ] - }, - "thirdperson_lefthand": { - "rotation": [ - 0, - 90, - 0 - ] - } + "thirdperson_lefthand": { + "rotation": [0, 90, 0] } + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/me_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/me_p2p_tunnel.json index 6cbded902..08a4ceed5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/me_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/me_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "appliedenergistics2:block/quartz_block" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/memory_card.json b/src/main/resources/assets/appliedenergistics2/models/item/memory_card.json index 105ca4473..6b90f12ed 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/memory_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/memory_card.json @@ -1,3 +1,3 @@ { - "loader": "appliedenergistics2:memory_card" + "loader": "appliedenergistics2:memory_card" } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/memory_card_base.json b/src/main/resources/assets/appliedenergistics2/models/item/memory_card_base.json index d7f2c6f00..0886f9a1e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/memory_card_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/memory_card_base.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/memory_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/memory_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/molecular_assembler.json b/src/main/resources/assets/appliedenergistics2/models/item/molecular_assembler.json index 3886ded20..909f261df 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/molecular_assembler.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/molecular_assembler.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/molecular_assembler" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/monitor.json b/src/main/resources/assets/appliedenergistics2/models/item/monitor.json index 7ae1662f1..a5ce7c9d8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/monitor.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/crafting_terminal", - "front_bright": "appliedenergistics2:parts/monitor_bright", - "front_medium": "appliedenergistics2:parts/monitor_colored", - "front_dark": "appliedenergistics2:parts/monitor_colored" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/crafting_terminal", + "front_bright": "appliedenergistics2:parts/monitor_bright", + "front_medium": "appliedenergistics2:parts/monitor_colored", + "front_dark": "appliedenergistics2:parts/monitor_colored" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/name_press.json b/src/main/resources/assets/appliedenergistics2/models/item/name_press.json index 308a8f04e..925e9eb4c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/name_press.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/name_press.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/name_press" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/name_press" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_axe.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_axe.json index 0a334eeea..3ff393fb3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_axe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_axe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_axe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_axe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_cutting_knife.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_cutting_knife.json index 41e290940..e9c15ca25 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_cutting_knife.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_cutting_knife.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_cutting_knife" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_cutting_knife" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_dust.json index 0279d33d5..972b59a2c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_hoe.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_hoe.json index 9f6c96ed4..aef7f4c36 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_hoe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_hoe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_hoe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_hoe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_pickaxe.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_pickaxe.json index ff96c56d5..86e197570 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_pickaxe.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_pickaxe.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_pickaxe" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_pickaxe" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed.json index d6e6bfc69..44b943f8a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed.json @@ -1,20 +1,20 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_nether" + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_nether" + }, + "overrides": [ + { + "predicate": { + "appliedenergistics2:growth": 0.333 + }, + "model": "appliedenergistics2:item/nether_quartz_seed_2" }, - "overrides": [ - { - "predicate": { - "appliedenergistics2:growth": 0.333 - }, - "model": "appliedenergistics2:item/nether_quartz_seed_2" - }, - { - "predicate": { - "appliedenergistics2:growth": 0.666 - }, - "model": "appliedenergistics2:item/nether_quartz_seed_3" - } - ] + { + "predicate": { + "appliedenergistics2:growth": 0.666 + }, + "model": "appliedenergistics2:item/nether_quartz_seed_3" + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_2.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_2.json index 04117a9e7..540eb0198 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_2.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_2.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_nether2" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_nether2" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_3.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_3.json index 718864d01..9100c4b79 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_3.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_seed_3.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/crystal_seed_nether3" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/crystal_seed_nether3" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_shovel.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_shovel.json index 61a7dce67..7dc976ab3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_shovel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_shovel.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_shovel" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_shovel" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_sword.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_sword.json index 048367cfe..f9b7257c7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_sword.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_sword.json @@ -1,6 +1,6 @@ { - "parent": "item/handheld", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_sword" - } + "parent": "item/handheld", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_sword" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_wrench.json b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_wrench.json index 8bd39aa85..cdbfbdc83 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_wrench.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/nether_quartz_wrench.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/nether_quartz_wrench" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/nether_quartz_wrench" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/network_tool.json b/src/main/resources/assets/appliedenergistics2/models/item/network_tool.json index c4ba64687..6b6c9b69c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/network_tool.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/network_tool.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/network_tool" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/network_tool" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_cable.json index 4892cb596..c4bfb88be 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/orange" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/orange" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_dense_cable.json index 3dc73acce..efe24a7d7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/orange" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/orange" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_glass_cable.json index 3e3943d75..85665fe3a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/orange" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/orange" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_cable.json index e76e232f1..08b5208b6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/orange" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/orange" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_dense_cable.json index c579e4254..4a5653322 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/orange_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/orange" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/orange" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/p2p_tunnel_base.json b/src/main/resources/assets/appliedenergistics2/models/item/p2p_tunnel_base.json index 1d3dd5389..3d7b5e630 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/p2p_tunnel_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/p2p_tunnel_base.json @@ -1,60 +1,44 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/p2p_tunnel_sides", - "back": "appliedenergistics2:item/part/p2p_tunnel_back", - "front": "appliedenergistics2:item/part/p2p_tunnel_front", - "type": "appliedenergistics2:block/quartz_block" - }, - "elements": [ - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#type" - } - } - }, - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 9 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/p2p_tunnel_sides", + "back": "appliedenergistics2:item/part/p2p_tunnel_back", + "front": "appliedenergistics2:item/part/p2p_tunnel_front", + "type": "appliedenergistics2:block/quartz_block" + }, + "elements": [ + { + "from": [2, 2, 7], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#type" } - ] + } + }, + { + "from": [2, 2, 7], + "to": [14, 14, 9], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/paint.json b/src/main/resources/assets/appliedenergistics2/models/item/paint.json index a4cf52069..a00845cb1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/paint.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/paint.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/paint" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/part_base.json b/src/main/resources/assets/appliedenergistics2/models/item/part_base.json index f0115f10f..4c633b047 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/part_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/part_base.json @@ -1,106 +1,34 @@ { - "display": { - "gui": { - "rotation": [ - 30, - 225, - 0 - ], - "translation": [ - 0, - 0, - 0 - ], - "scale": [ - 0.8, - 0.8, - 0.8 - ] - }, - "ground": { - "rotation": [ - 0, - 0, - 0 - ], - "translation": [ - 0, - 3, - 0 - ], - "scale": [ - 0.25, - 0.25, - 0.25 - ] - }, - "fixed": { - "rotation": [ - 0, - 0, - 0 - ], - "translation": [ - 0, - 0, - 0 - ], - "scale": [ - 0.5, - 0.5, - 0.5 - ] - }, - "thirdperson_righthand": { - "rotation": [ - 75, - 45, - 0 - ], - "translation": [ - 0, - 2.5, - 0 - ], - "scale": [ - 0.375, - 0.375, - 0.375 - ] - }, - "firstperson_righthand": { - "rotation": [ - 0, - 45, - 0 - ], - "translation": [ - 0, - 0, - 0 - ], - "scale": [ - 0.40, - 0.40, - 0.40 - ] - }, - "firstperson_lefthand": { - "rotation": [ - 0, - 225, - 0 - ], - "translation": [ - 0, - 0, - 0 - ], - "scale": [ - 0.40, - 0.40, - 0.40 - ] - } + "display": { + "gui": { + "rotation": [30, 225, 0], + "translation": [0, 0, 0], + "scale": [0.8, 0.8, 0.8] + }, + "ground": { + "rotation": [0, 0, 0], + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "fixed": { + "rotation": [0, 0, 0], + "translation": [0, 0, 0], + "scale": [0.5, 0.5, 0.5] + }, + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "translation": [0, 0, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "translation": [0, 0, 0], + "scale": [0.4, 0.4, 0.4] } + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pattern_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/pattern_terminal.json index 0a7065f0c..befadb8e2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pattern_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pattern_terminal.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/pattern_terminal", - "front_bright": "appliedenergistics2:parts/pattern_terminal_bright", - "front_medium": "appliedenergistics2:parts/pattern_terminal_medium", - "front_dark": "appliedenergistics2:parts/pattern_terminal_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/pattern_terminal", + "front_bright": "appliedenergistics2:parts/pattern_terminal_bright", + "front_medium": "appliedenergistics2:parts/pattern_terminal_medium", + "front_dark": "appliedenergistics2:parts/pattern_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_cable.json index 50e023c12..5f0175a32 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/pink" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/pink" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_dense_cable.json index a860c8d19..77992d29f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/pink" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/pink" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_glass_cable.json index 3f42fb6d9..29e81c3a4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/pink" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/pink" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_cable.json index a37f064ea..dcc4c0bab 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/pink" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/pink" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_dense_cable.json index f213f5788..4c731e4e2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/pink_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/pink" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/pink" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/portable_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/portable_cell.json index c8e8b6bae..de08d9ce3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/portable_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/portable_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/portable_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/portable_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/printed_calculation_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/printed_calculation_processor.json index aec96fbb4..96109b4bd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/printed_calculation_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/printed_calculation_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/printed_calculation_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/printed_calculation_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/printed_engineering_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/printed_engineering_processor.json index f1bf7c195..c15ecc884 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/printed_engineering_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/printed_engineering_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/printed_engineering_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/printed_engineering_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/printed_logic_processor.json b/src/main/resources/assets/appliedenergistics2/models/item/printed_logic_processor.json index ddece3fcc..67018e168 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/printed_logic_processor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/printed_logic_processor.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/printed_logic_processor" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/printed_logic_processor" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/printed_silicon.json b/src/main/resources/assets/appliedenergistics2/models/item/printed_silicon.json index 6c0dc83bf..156138d3b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/printed_silicon.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/printed_silicon.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/printed_silicon" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/printed_silicon" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purified_certus_quartz_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/purified_certus_quartz_crystal.json index a970f9993..ddb0312a3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purified_certus_quartz_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purified_certus_quartz_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/purified_certus_quartz_crystal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/purified_certus_quartz_crystal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purified_fluix_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/purified_fluix_crystal.json index 882e8aa61..13c3aee1e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purified_fluix_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purified_fluix_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/purified_fluix_crystal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/purified_fluix_crystal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purified_nether_quartz_crystal.json b/src/main/resources/assets/appliedenergistics2/models/item/purified_nether_quartz_crystal.json index 01b6a9533..241ac4040 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purified_nether_quartz_crystal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purified_nether_quartz_crystal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/purified_nether_quartz_crystal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/purified_nether_quartz_crystal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_cable.json index aa68cecc0..2adec2465 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/purple" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/purple" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_dense_cable.json index a8118bf29..a4de5ea57 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/purple" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/purple" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_glass_cable.json index 5959fdf1d..540462b22 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/purple" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/purple" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_cable.json index 88a66170d..ace644f98 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/purple" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/purple" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_dense_cable.json index 531b67a63..ba9b8d783 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/purple_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/purple" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/purple" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quantum_entangled_singularity.json b/src/main/resources/assets/appliedenergistics2/models/item/quantum_entangled_singularity.json index f9268af91..7c8015a0f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quantum_entangled_singularity.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quantum_entangled_singularity.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/quantum_entangled_singularity" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/quantum_entangled_singularity" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quantum_link.json b/src/main/resources/assets/appliedenergistics2/models/item/quantum_link.json index 624f8d400..2defe7878 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quantum_link.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quantum_link.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/qnb/link" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quantum_ring.json b/src/main/resources/assets/appliedenergistics2/models/item/quantum_ring.json index 15520b719..284062ead 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quantum_ring.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quantum_ring.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/qnb/ring" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_block.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_block.json index f368c0199..838fdeae6 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_block.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/quartz_block" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_fiber.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_fiber.json index 8b2c0edea..efd30161a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_fiber.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_fiber.json @@ -1,40 +1,32 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "cable": "appliedenergistics2:item/part/quartz_fiber" - }, - "elements": [ - { - "from": [ - 6, - 6, - 5 - ], - "to": [ - 10, - 10, - 11 - ], - "faces": { - "north": { - "texture": "#cable" - }, - "south": { - "texture": "#cable" - }, - "east": { - "texture": "#cable" - }, - "west": { - "texture": "#cable" - }, - "up": { - "texture": "#cable" - }, - "down": { - "texture": "#cable" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "cable": "appliedenergistics2:item/part/quartz_fiber" + }, + "elements": [ + { + "from": [6, 6, 5], + "to": [10, 10, 11], + "faces": { + "north": { + "texture": "#cable" + }, + "south": { + "texture": "#cable" + }, + "east": { + "texture": "#cable" + }, + "west": { + "texture": "#cable" + }, + "up": { + "texture": "#cable" + }, + "down": { + "texture": "#cable" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_fixture.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_fixture.json index c67981b04..dc79defc9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_fixture.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_fixture.json @@ -1,174 +1,134 @@ { - "elements": [ - { - "faces": { - "down": { - "texture": "#metal" - }, - "east": { - "texture": "#metal" - }, - "north": { - "texture": "#metal" - }, - "south": { - "texture": "#metal" - }, - "up": { - "texture": "#metal" - }, - "west": { - "texture": "#metal" - } - }, - "from": [ - 6.0, - 8.0, - 6.0 - ], - "name": "Middle Plate", - "to": [ - 10.0, - 9.0, - 10.0 - ] + "elements": [ + { + "faces": { + "down": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 6.0, - 7.0 - ], - "name": "Lower Quartz Block", - "to": [ - 9.0, - 8.0, - 9.0 - ] + "east": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 8.0, - 5.0, - 7.0 - ], - "name": "Lower Quartz Tip", - "to": [ - 9.0, - 6.0, - 8.0 - ] + "north": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 9.0, - 7.0 - ], - "name": "Upper Quartz Block", - "to": [ - 9.0, - 11.0, - 9.0 - ] + "south": { + "texture": "#metal" }, - { - "faces": { - "down": { - "texture": "#quartz" - }, - "east": { - "texture": "#quartz" - }, - "north": { - "texture": "#quartz" - }, - "south": { - "texture": "#quartz" - }, - "up": { - "texture": "#quartz" - }, - "west": { - "texture": "#quartz" - } - }, - "from": [ - 7.0, - 11.0, - 8.0 - ], - "name": "Upper Quartz Tip", - "to": [ - 8.0, - 12.0, - 9.0 - ] + "up": { + "texture": "#metal" + }, + "west": { + "texture": "#metal" } - ], - "parent": "block/block", - "textures": { - "metal": "appliedenergistics2:block/quartz_fixture_metal", - "quartz": "appliedenergistics2:block/quartz_fixture" + }, + "from": [6.0, 8.0, 6.0], + "name": "Middle Plate", + "to": [10.0, 9.0, 10.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 6.0, 7.0], + "name": "Lower Quartz Block", + "to": [9.0, 8.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [8.0, 5.0, 7.0], + "name": "Lower Quartz Tip", + "to": [9.0, 6.0, 8.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 9.0, 7.0], + "name": "Upper Quartz Block", + "to": [9.0, 11.0, 9.0] + }, + { + "faces": { + "down": { + "texture": "#quartz" + }, + "east": { + "texture": "#quartz" + }, + "north": { + "texture": "#quartz" + }, + "south": { + "texture": "#quartz" + }, + "up": { + "texture": "#quartz" + }, + "west": { + "texture": "#quartz" + } + }, + "from": [7.0, 11.0, 8.0], + "name": "Upper Quartz Tip", + "to": [8.0, 12.0, 9.0] } + ], + "parent": "block/block", + "textures": { + "metal": "appliedenergistics2:block/quartz_fixture_metal", + "quartz": "appliedenergistics2:block/quartz_fixture" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_glass.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_glass.json index 967d8d5b8..b2747ac61 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_glass.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_glass.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:item/quartz_glass" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:item/quartz_glass" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_growth_accelerator.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_growth_accelerator.json index 24f638a96..27b7410e7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_growth_accelerator.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_growth_accelerator.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/quartz_growth_accelerator_off" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_ore.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_ore.json index 0d1fae780..6369af854 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_ore.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_ore.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/quartz_ore" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar.json index 80e039345..3a538f15d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/quartz_pillar" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_slab.json index e273d5841..74c3d1d00 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/quartz_pillar_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_stairs.json index b946cf632..40be25b25 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_pillar_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/quartz_pillar" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_slab.json index 67c5770bd..68c07b62d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/quartz_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_stairs.json index 7078d6cbd..a595feefa 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/quartz" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/quartz_vibrant_glass.json b/src/main/resources/assets/appliedenergistics2/models/item/quartz_vibrant_glass.json index 967d8d5b8..b2747ac61 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/quartz_vibrant_glass.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/quartz_vibrant_glass.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:item/quartz_glass" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:item/quartz_glass" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/red_covered_cable.json index 9e8fc6ff5..eeb2c24bf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/red" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/red" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/red_covered_dense_cable.json index b904144ef..0a6b7a2dd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/red" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/red" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/red_glass_cable.json index def5aa638..782ca948d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/red" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/red" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/red_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/red_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/red_smart_cable.json index aa2490cc8..5b4698f91 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/red" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/red" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/red_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/red_smart_dense_cable.json index 177a7687f..f631ab7c7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/red_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/red_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/red" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/red" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/redstone_card.json b/src/main/resources/assets/appliedenergistics2/models/item/redstone_card.json index 11534bfb2..5a5514609 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/redstone_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/redstone_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_redstone" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_redstone" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/redstone_p2p_tunnel.json b/src/main/resources/assets/appliedenergistics2/models/item/redstone_p2p_tunnel.json index e19827a23..4ac40ec38 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/redstone_p2p_tunnel.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/redstone_p2p_tunnel.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/p2p_tunnel_base", - "textures": { - "type": "block/redstone_block" - } + "parent": "appliedenergistics2:item/p2p_tunnel_base", + "textures": { + "type": "block/redstone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/replicator_card.json b/src/main/resources/assets/appliedenergistics2/models/item/replicator_card.json index 8a32f2323..da568a7ec 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/replicator_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/replicator_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/replicator_card" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/replicator_card" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/security_station.json b/src/main/resources/assets/appliedenergistics2/models/item/security_station.json index 0432a822a..82458306f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/security_station.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/security_station.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/security_station_off" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/semi_dark_monitor.json b/src/main/resources/assets/appliedenergistics2/models/item/semi_dark_monitor.json index 3593f12c5..fc0c8d24b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/semi_dark_monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/semi_dark_monitor.json @@ -1,10 +1,10 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:parts/monitor_front", - "front_bright": "appliedenergistics2:parts/monitor_colored", - "front_medium_bright": "appliedenergistics2:parts/monitor_bright", - "front_medium": "appliedenergistics2:parts/monitor_colored", - "front_dark": "appliedenergistics2:parts/monitor_colored" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:parts/monitor_front", + "front_bright": "appliedenergistics2:parts/monitor_colored", + "front_medium_bright": "appliedenergistics2:parts/monitor_bright", + "front_medium": "appliedenergistics2:parts/monitor_colored", + "front_dark": "appliedenergistics2:parts/monitor_colored" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/silicon.json b/src/main/resources/assets/appliedenergistics2/models/item/silicon.json index f47979bfc..159845e84 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/silicon.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/silicon.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/silicon" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/silicon" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/silicon_press.json b/src/main/resources/assets/appliedenergistics2/models/item/silicon_press.json index 45bb213ec..474938a6e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/silicon_press.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/silicon_press.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/silicon_press" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/silicon_press" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/singularity.json b/src/main/resources/assets/appliedenergistics2/models/item/singularity.json index 3cff64514..199ac4d1b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/singularity.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/singularity.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/singularity" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/singularity" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_compass.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_compass.json index 5043084d1..0e35ca77b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_compass.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_compass.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/sky_compass" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_dust.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_dust.json index ddf7f0786..65ff5f24a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_dust.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_dust.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/sky_dust" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/sky_dust" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_block.json index 3597f7b49..6b02d0735 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_block.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/sky_stone_block" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick.json index debbf5be2..e231d012a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/sky_stone_brick" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_slab.json index 9a35ec5ef..45e741fad 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/sky_stone_brick_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_stairs.json index 51f641970..b1f8a9a8c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_brick_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/sky_stone_brick" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json index 04ed8e5ad..119e44f92 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json @@ -1,210 +1,101 @@ { - "parent": "block/orientable", - "textures": { - "particle": "appliedenergistics2:models/skychest", - "0": "appliedenergistics2:models/skychest" - }, - "elements": [ - { - "name": "Base", - "from": [ - 1.0, - 0.0, - 1.0 - ], - "to": [ - 15.0, - 10.0, - 15.0 - ], - "shade": false, - "faces": { - "north": { - "texture": "#0", - "uv": [ - 3.5, - 8.25, - 7, - 10.75 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 8.25, - 3.5, - 10.75 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 10.5, - 8.25, - 14, - 10.75 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 7, - 8.25, - 10.5, - 10.75 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 3.5, - 0.0, - 7, - 3.5 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 7, - 0.0, - 10.5, - 3.5 - ] - } - } + "parent": "block/orientable", + "textures": { + "particle": "appliedenergistics2:models/skychest", + "0": "appliedenergistics2:models/skychest" + }, + "elements": [ + { + "name": "Base", + "from": [1.0, 0.0, 1.0], + "to": [15.0, 10.0, 15.0], + "shade": false, + "faces": { + "north": { + "texture": "#0", + "uv": [3.5, 8.25, 7, 10.75] }, - { - "name": "Lid", - "from": [ - 1.0, - 10.0, - 1.0 - ], - "to": [ - 15.0, - 15.0, - 15.0 - ], - "shade": false, - "faces": { - "north": { - "texture": "#0", - "uv": [ - 3.5, - 3.5, - 7, - 4.75 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 3.5, - 3.5, - 4.75 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 10.5, - 3.5, - 14, - 4.75 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 7, - 3.5, - 10.5, - 4.75 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 3.5, - 0.0, - 7, - 3.5 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 7, - 0.0, - 10.5, - 3.5 - ] - } - } + "east": { + "texture": "#0", + "uv": [0.0, 8.25, 3.5, 10.75] }, - { - "name": "Knob", - "from": [ - 7.0, - 7.0, - 0.0 - ], - "to": [ - 9.0, - 11.0, - 1.0 - ], - "shade": false, - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.25, - 0.25, - 0.75, - 1.25 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0, - 0.25, - 0.25, - 1.25 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 0.75, - 0.25, - 1.5, - 1.25 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 0.25, - 0.0, - 0.75, - 0.25 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 0.75, - 0.0, - 1.5, - 0.25 - ] - } - } + "south": { + "texture": "#0", + "uv": [10.5, 8.25, 14, 10.75] + }, + "west": { + "texture": "#0", + "uv": [7, 8.25, 10.5, 10.75] + }, + "up": { + "texture": "#0", + "uv": [3.5, 0.0, 7, 3.5] + }, + "down": { + "texture": "#0", + "uv": [7, 0.0, 10.5, 3.5] } - ] + } + }, + { + "name": "Lid", + "from": [1.0, 10.0, 1.0], + "to": [15.0, 15.0, 15.0], + "shade": false, + "faces": { + "north": { + "texture": "#0", + "uv": [3.5, 3.5, 7, 4.75] + }, + "east": { + "texture": "#0", + "uv": [0.0, 3.5, 3.5, 4.75] + }, + "south": { + "texture": "#0", + "uv": [10.5, 3.5, 14, 4.75] + }, + "west": { + "texture": "#0", + "uv": [7, 3.5, 10.5, 4.75] + }, + "up": { + "texture": "#0", + "uv": [3.5, 0.0, 7, 3.5] + }, + "down": { + "texture": "#0", + "uv": [7, 0.0, 10.5, 3.5] + } + } + }, + { + "name": "Knob", + "from": [7.0, 7.0, 0.0], + "to": [9.0, 11.0, 1.0], + "shade": false, + "faces": { + "north": { + "texture": "#0", + "uv": [0.25, 0.25, 0.75, 1.25] + }, + "east": { + "texture": "#0", + "uv": [0, 0.25, 0.25, 1.25] + }, + "west": { + "texture": "#0", + "uv": [0.75, 0.25, 1.5, 1.25] + }, + "up": { + "texture": "#0", + "uv": [0.25, 0.0, 0.75, 0.25] + }, + "down": { + "texture": "#0", + "uv": [0.75, 0.0, 1.5, 0.25] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_slab.json index a610a0416..b0d9d6597 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/sky_stone_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick.json index 7b8c93d97..1088af0a5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/sky_stone_small_brick" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_slab.json index 7eec93e15..cd37c40e0 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/sky_stone_small_brick_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_stairs.json index e8b45e5dc..eff6e5890 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_small_brick_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/sky_stone_small_brick" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_stairs.json index b06ece7f8..6dd61120f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/sky_stone" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smart_cable_base.json b/src/main/resources/assets/appliedenergistics2/models/item/smart_cable_base.json index d657e6530..9739dc219 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smart_cable_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smart_cable_base.json @@ -1,216 +1,102 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "channelsOdd": "appliedenergistics2:parts/cable/smart/channels_00", - "channelsEven": "appliedenergistics2:parts/cable/smart/channels_10" - }, - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 2.0 - ], - "to": [ - 11.0, - 11.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "channelsOdd": "appliedenergistics2:parts/cable/smart/channels_00", + "channelsEven": "appliedenergistics2:parts/cable/smart/channels_10" + }, + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 2.0], + "to": [11.0, 11.0, 14.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] }, - { - "name": "Channels Odd", - "from": [ - 5.0, - 5.0, - 2.0 - ], - "to": [ - 11.0, - 11.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#channelsOdd", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#channelsOdd", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#channelsOdd", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#channelsOdd", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#channelsOdd", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#channelsOdd", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] }, - { - "name": "Channels Even", - "from": [ - 5.0, - 5.0, - 2.0 - ], - "to": [ - 11.0, - 11.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#channelsEven", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#channelsEven", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#channelsEven", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#channelsEven", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#channelsEven", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#channelsEven", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + }, + { + "name": "Channels Odd", + "from": [5.0, 5.0, 2.0], + "to": [11.0, 11.0, 14.0], + "faces": { + "north": { + "texture": "#channelsOdd", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#channelsOdd", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#channelsOdd", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#channelsOdd", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#channelsOdd", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#channelsOdd", + "uv": [5.0, 11.0, 11.0, 16.0] + } + } + }, + { + "name": "Channels Even", + "from": [5.0, 5.0, 2.0], + "to": [11.0, 11.0, 14.0], + "faces": { + "north": { + "texture": "#channelsEven", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#channelsEven", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#channelsEven", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#channelsEven", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#channelsEven", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#channelsEven", + "uv": [5.0, 11.0, 11.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smart_dense_cable_base.json b/src/main/resources/assets/appliedenergistics2/models/item/smart_dense_cable_base.json index 792820f09..5b2843320 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smart_dense_cable_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smart_dense_cable_base.json @@ -1,146 +1,70 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "channels": "appliedenergistics2:parts/cable/dense_smart/0" - }, - "elements": [ - { - "name": "Base", - "from": [ - 4.0, - 4.0, - 2.0 - ], - "to": [ - 12.0, - 12.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 4.0, - 4.0, - 12.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 4.0, - 4.0, - 12.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 4.0, - 4.0, - 12.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 4.0, - 4.0, - 0.0, - 12.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 4.0, - 0.0, - 12.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 4.0, - 12.0, - 12.0, - 16.0 - ] - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "channels": "appliedenergistics2:parts/cable/dense_smart/0" + }, + "elements": [ + { + "name": "Base", + "from": [4.0, 4.0, 2.0], + "to": [12.0, 12.0, 14.0], + "faces": { + "north": { + "texture": "#base", + "uv": [4.0, 4.0, 12.0, 11.0] }, - { - "name": "Channels", - "from": [ - 4.0, - 4.0, - 2.0 - ], - "to": [ - 12.0, - 12.0, - 14.0 - ], - "faces": { - "north": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#channels", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#channels", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#channels", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#channels", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [0.0, 4.0, 4.0, 12.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 4.0, 4.0, 12.0] + }, + "west": { + "texture": "#base", + "uv": [4.0, 4.0, 0.0, 12.0] + }, + "up": { + "texture": "#base", + "uv": [4.0, 0.0, 12.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [4.0, 12.0, 12.0, 16.0] } - ] + } + }, + { + "name": "Channels", + "from": [4.0, 4.0, 2.0], + "to": [12.0, 12.0, 14.0], + "faces": { + "north": { + "texture": "#channels", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#channels", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#channels", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#channels", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#channels", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#channels", + "uv": [5.0, 11.0, 11.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_block.json b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_block.json index a9884433b..be00bb0d8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_block.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_block.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/smooth_sky_stone_block" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_chest.json b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_chest.json index 959f53a16..79fc66f40 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_chest.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_chest.json @@ -1,7 +1,7 @@ { - "parent": "appliedenergistics2:item/sky_stone_chest", - "textures": { - "particle": "appliedenergistics2:models/skyblockchest", - "0": "appliedenergistics2:models/skyblockchest" - } + "parent": "appliedenergistics2:item/sky_stone_chest", + "textures": { + "particle": "appliedenergistics2:models/skyblockchest", + "0": "appliedenergistics2:models/skyblockchest" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_slab.json b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_slab.json index a2db9e4cf..4ac07ffbc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_slab.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_slab.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/slabs/smooth_sky_stone_half" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_stairs.json b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_stairs.json index 843cfabd1..28fcde2ed 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_stairs.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/smooth_sky_stone_stairs.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/stairs/smooth_sky_stone" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/spatial_io_port.json b/src/main/resources/assets/appliedenergistics2/models/item/spatial_io_port.json index fdc64b3e6..c5f1925b2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/spatial_io_port.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/spatial_io_port.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/spatial_io_port" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/spatial_pylon.json b/src/main/resources/assets/appliedenergistics2/models/item/spatial_pylon.json index a77811df4..bc97e9b7a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/spatial_pylon.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/spatial_pylon.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", - "textures": { - "all": "appliedenergistics2:item/spatial_pylon" - } + "parent": "block/cube_all", + "textures": { + "all": "appliedenergistics2:item/spatial_pylon" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/speed_card.json b/src/main/resources/assets/appliedenergistics2/models/item/speed_card.json index f3e2ebdc3..a2ff521a9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/speed_card.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/speed_card.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/card_speed" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/card_speed" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/storage_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/storage_bus.json index 9de2552a6..006c3d771 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/storage_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/storage_bus.json @@ -1,106 +1,82 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "sides": "appliedenergistics2:parts/storage_bus_sides", - "back": "appliedenergistics2:parts/storage_bus_back", - "front": "appliedenergistics2:item/part/storage_bus" - }, - "elements": [ - { - "from": [ - 3, - 3, - 6 - ], - "to": [ - 13, - 13, - 7 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "sides": "appliedenergistics2:parts/storage_bus_sides", + "back": "appliedenergistics2:parts/storage_bus_back", + "front": "appliedenergistics2:item/part/storage_bus" + }, + "elements": [ + { + "from": [3, 3, 6], + "to": [13, 13, 7], + "faces": { + "north": { + "texture": "#front" }, - { - "from": [ - 2, - 2, - 7 - ], - "to": [ - 14, - 14, - 8 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 8 - ], - "to": [ - 11, - 11, - 10 - ], - "faces": { - "north": { - "texture": "#front" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [2, 2, 7], + "to": [14, 14, 8], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 8], + "to": [11, 11, 10], + "faces": { + "north": { + "texture": "#front" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/storage_monitor.json b/src/main/resources/assets/appliedenergistics2/models/item/storage_monitor.json index 36ed082a5..aa701b0c3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/storage_monitor.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/storage_monitor.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/storage_monitor", - "front_bright": "appliedenergistics2:parts/storage_monitor_bright", - "front_medium": "appliedenergistics2:parts/storage_monitor_medium", - "front_dark": "appliedenergistics2:parts/storage_monitor_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/storage_monitor", + "front_bright": "appliedenergistics2:parts/storage_monitor_bright", + "front_medium": "appliedenergistics2:parts/storage_monitor_medium", + "front_dark": "appliedenergistics2:parts/storage_monitor_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/terminal.json index 6f450fe09..1734597fe 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/terminal.json @@ -1,9 +1,9 @@ { - "parent": "appliedenergistics2:item/display_base", - "textures": { - "front": "appliedenergistics2:item/part/terminal", - "front_bright": "appliedenergistics2:parts/terminal_bright", - "front_medium": "appliedenergistics2:parts/terminal_medium", - "front_dark": "appliedenergistics2:parts/terminal_dark" - } + "parent": "appliedenergistics2:item/display_base", + "textures": { + "front": "appliedenergistics2:item/part/terminal", + "front_bright": "appliedenergistics2:parts/terminal_bright", + "front_medium": "appliedenergistics2:parts/terminal_medium", + "front_dark": "appliedenergistics2:parts/terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/tiny_tnt.json b/src/main/resources/assets/appliedenergistics2/models/item/tiny_tnt.json index f6c62cf39..5eacf45ca 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/tiny_tnt.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/tiny_tnt.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/tiny_tnt" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/toggle_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/toggle_bus.json index b57e1b7db..b2cd4c2fc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/toggle_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/toggle_bus.json @@ -1,138 +1,106 @@ { - "parent": "appliedenergistics2:item/part_base", - "textures": { - "bus": "appliedenergistics2:item/part/toggle_bus", - "status": "appliedenergistics2:parts/monitor_sides_status", - "lights": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 10 - ], - "to": [ - 10, - 10, - 12 - ], - "faces": { - "north": { - "texture": "#bus" - }, - "south": { - "texture": "#bus" - }, - "east": { - "texture": "#bus" - }, - "west": { - "texture": "#bus" - }, - "up": { - "texture": "#bus" - }, - "down": { - "texture": "#bus" - } - } + "parent": "appliedenergistics2:item/part_base", + "textures": { + "bus": "appliedenergistics2:item/part/toggle_bus", + "status": "appliedenergistics2:parts/monitor_sides_status", + "lights": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 10], + "to": [10, 10, 12], + "faces": { + "north": { + "texture": "#bus" }, - { - "from": [ - 6, - 6, - 7 - ], - "to": [ - 10, - 10, - 9 - ], - "faces": { - "north": { - "texture": "#bus" - }, - "south": { - "texture": "#bus" - }, - "east": { - "texture": "#bus" - }, - "west": { - "texture": "#bus" - }, - "up": { - "texture": "#bus" - }, - "down": { - "texture": "#bus" - } - } + "south": { + "texture": "#bus" }, - { - "from": [ - 6, - 6, - 9 - ], - "to": [ - 10, - 10, - 10 - ], - "faces": { - "north": { - "texture": "#status" - }, - "south": { - "texture": "#status" - }, - "east": { - "texture": "#status" - }, - "west": { - "texture": "#status" - }, - "up": { - "texture": "#status" - }, - "down": { - "texture": "#status" - } - } + "east": { + "texture": "#bus" }, - { - "from": [ - 6, - 6, - 9 - ], - "to": [ - 10, - 10, - 10 - ], - "faces": { - "north": { - "texture": "#lights" - }, - "south": { - "texture": "#lights" - }, - "east": { - "texture": "#lights" - }, - "west": { - "texture": "#lights" - }, - "up": { - "texture": "#lights" - }, - "down": { - "texture": "#lights" - } - } + "west": { + "texture": "#bus" + }, + "up": { + "texture": "#bus" + }, + "down": { + "texture": "#bus" } - ] + } + }, + { + "from": [6, 6, 7], + "to": [10, 10, 9], + "faces": { + "north": { + "texture": "#bus" + }, + "south": { + "texture": "#bus" + }, + "east": { + "texture": "#bus" + }, + "west": { + "texture": "#bus" + }, + "up": { + "texture": "#bus" + }, + "down": { + "texture": "#bus" + } + } + }, + { + "from": [6, 6, 9], + "to": [10, 10, 10], + "faces": { + "north": { + "texture": "#status" + }, + "south": { + "texture": "#status" + }, + "east": { + "texture": "#status" + }, + "west": { + "texture": "#status" + }, + "up": { + "texture": "#status" + }, + "down": { + "texture": "#status" + } + } + }, + { + "from": [6, 6, 9], + "to": [10, 10, 10], + "faces": { + "north": { + "texture": "#lights" + }, + "south": { + "texture": "#lights" + }, + "east": { + "texture": "#lights" + }, + "west": { + "texture": "#lights" + }, + "up": { + "texture": "#lights" + }, + "down": { + "texture": "#lights" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/vibration_chamber.json b/src/main/resources/assets/appliedenergistics2/models/item/vibration_chamber.json index 49eff78d5..3de72ba1a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/vibration_chamber.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/vibration_chamber.json @@ -1,3 +1,3 @@ { "parent": "appliedenergistics2:block/vibration_chamber_off" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/view_cell.json b/src/main/resources/assets/appliedenergistics2/models/item/view_cell.json index 35077d912..ccd7e9805 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/view_cell.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/view_cell.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/view_cell" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/view_cell" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/white_covered_cable.json index ac24f1a79..598993e4c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/white" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/white" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/white_covered_dense_cable.json index ee9c1c691..b6763b3f8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/white" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/white" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/white_glass_cable.json index f9f0fd6b7..3c0067c04 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/white" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/white" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/white_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/white_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/white_smart_cable.json index a8acc2c8a..fa600d0ab 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/white" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/white" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/white_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/white_smart_dense_cable.json index 2a3f87669..43d85d346 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/white_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/white_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/white" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/white" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wireless_access_point.json b/src/main/resources/assets/appliedenergistics2/models/item/wireless_access_point.json index fb5f2bafe..810cf5dc8 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wireless_access_point.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wireless_access_point.json @@ -12,165 +12,181 @@ { "from": [4.875, 5, 5], "to": [5.875, 11, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [12, 5, 13, 11], "texture": "#sidesStatus"}, - "east": {"uv": [5, 5, 11, 11], "texture": "#sides"}, - "south": {"uv": [3, 5, 4, 11], "texture": "#sidesStatus"}, - "west": {"uv": [5, 5, 11, 11], "texture": "#sides"}, - "up": {"uv": [12, 5, 13, 11], "rotation": 270, "texture": "#sidesStatus"}, - "down": {"uv": [12, 5, 13, 11], "rotation": 90, "texture": "#sidesStatus"} + "north": { "uv": [12, 5, 13, 11], "texture": "#sidesStatus" }, + "east": { "uv": [5, 5, 11, 11], "texture": "#sides" }, + "south": { "uv": [3, 5, 4, 11], "texture": "#sidesStatus" }, + "west": { "uv": [5, 5, 11, 11], "texture": "#sides" }, + "up": { + "uv": [12, 5, 13, 11], + "rotation": 270, + "texture": "#sidesStatus" + }, + "down": { + "uv": [12, 5, 13, 11], + "rotation": 90, + "texture": "#sidesStatus" + } } }, { "from": [5.875, 5, 5], "to": [6.875, 11, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [11, 5, 12, 11], "texture": "#sides"}, - "east": {"uv": [5, 5, 11, 11], "texture": "#inside"}, - "south": {"uv": [4, 5, 5, 11], "texture": "#sides"}, - "west": {"uv": [5, 5, 11, 11], "texture": "#inside"}, - "up": {"uv": [11, 5, 12, 11], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [11, 5, 12, 11], "rotation": 90, "texture": "#sides"} + "north": { "uv": [11, 5, 12, 11], "texture": "#sides" }, + "east": { "uv": [5, 5, 11, 11], "texture": "#inside" }, + "south": { "uv": [4, 5, 5, 11], "texture": "#sides" }, + "west": { "uv": [5, 5, 11, 11], "texture": "#inside" }, + "up": { "uv": [11, 5, 12, 11], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [11, 5, 12, 11], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna I Up", "from": [6.875, 10, 6], "to": [8.875, 12, 10], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [9, 4, 11, 6], "texture": "#sides"}, - "east": {"uv": [6, 4, 10, 6], "texture": "#inside"}, - "south": {"uv": [5, 4, 7, 6], "texture": "#sides"}, - "west": {"uv": [6, 4, 10, 6], "texture": "#inside"}, - "up": {"uv": [9, 6, 11, 10], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [9, 6, 11, 10], "rotation": 90, "texture": "#sides"} + "north": { "uv": [9, 4, 11, 6], "texture": "#sides" }, + "east": { "uv": [6, 4, 10, 6], "texture": "#inside" }, + "south": { "uv": [5, 4, 7, 6], "texture": "#sides" }, + "west": { "uv": [6, 4, 10, 6], "texture": "#inside" }, + "up": { "uv": [9, 6, 11, 10], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [9, 6, 11, 10], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna I Down", "from": [6.875, 4, 6], "to": [8.875, 6, 10], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [9, 10, 11, 12], "texture": "#sides"}, - "east": {"uv": [6, 10, 10, 12], "texture": "#inside"}, - "south": {"uv": [5, 10, 7, 12], "texture": "#sides"}, - "west": {"uv": [6, 10, 10, 12], "texture": "#inside"}, - "up": {"uv": [9, 6, 11, 10], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [9, 6, 11, 10], "rotation": 90, "texture": "#sides"} + "north": { "uv": [9, 10, 11, 12], "texture": "#sides" }, + "east": { "uv": [6, 10, 10, 12], "texture": "#inside" }, + "south": { "uv": [5, 10, 7, 12], "texture": "#sides" }, + "west": { "uv": [6, 10, 10, 12], "texture": "#inside" }, + "up": { "uv": [9, 6, 11, 10], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [9, 6, 11, 10], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna I West", "from": [6.875, 6, 10], "to": [8.875, 10, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [9, 6, 11, 10], "texture": "#sides"}, - "east": {"uv": [4, 6, 6, 10], "texture": "#inside"}, - "south": {"uv": [5, 6, 7, 10], "texture": "#sides"}, - "west": {"uv": [10, 6, 12, 10], "texture": "#inside"}, - "up": {"uv": [9, 4, 11, 6], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [9, 10, 11, 12], "rotation": 90, "texture": "#sides"} + "north": { "uv": [9, 6, 11, 10], "texture": "#sides" }, + "east": { "uv": [4, 6, 6, 10], "texture": "#inside" }, + "south": { "uv": [5, 6, 7, 10], "texture": "#sides" }, + "west": { "uv": [10, 6, 12, 10], "texture": "#inside" }, + "up": { "uv": [9, 4, 11, 6], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [9, 10, 11, 12], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna I East", "from": [6.875, 6, 4], "to": [8.875, 10, 6], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [9, 6, 11, 10], "texture": "#sides"}, - "east": {"uv": [10, 6, 12, 10], "texture": "#inside"}, - "south": {"uv": [5, 6, 7, 10], "texture": "#sides"}, - "west": {"uv": [4, 6, 6, 10], "texture": "#inside"}, - "up": {"uv": [9, 10, 11, 12], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [9, 4, 11, 6], "rotation": 90, "texture": "#sides"} + "north": { "uv": [9, 6, 11, 10], "texture": "#sides" }, + "east": { "uv": [10, 6, 12, 10], "texture": "#inside" }, + "south": { "uv": [5, 6, 7, 10], "texture": "#sides" }, + "west": { "uv": [4, 6, 6, 10], "texture": "#inside" }, + "up": { "uv": [9, 10, 11, 12], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [9, 4, 11, 6], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna II Up", "from": [7.875, 12, 7], "to": [10.875, 13, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [7, 3, 10, 4], "texture": "#sides"}, - "east": {"uv": [7, 3, 9, 4], "texture": "#inside"}, - "south": {"uv": [6, 3, 9, 4], "texture": "#sides"}, - "west": {"uv": [7, 3, 9, 4], "texture": "#inside"}, - "up": {"uv": [7, 7, 10, 9], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [7, 7, 10, 9], "rotation": 90, "texture": "#sides"} + "north": { "uv": [7, 3, 10, 4], "texture": "#sides" }, + "east": { "uv": [7, 3, 9, 4], "texture": "#inside" }, + "south": { "uv": [6, 3, 9, 4], "texture": "#sides" }, + "west": { "uv": [7, 3, 9, 4], "texture": "#inside" }, + "up": { "uv": [7, 7, 10, 9], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [7, 7, 10, 9], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna II Down", "from": [7.875, 3, 7], "to": [10.875, 4, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [7, 12, 10, 13], "texture": "#sides"}, - "east": {"uv": [7, 12, 9, 13], "texture": "#inside"}, - "south": {"uv": [6, 12, 9, 13], "texture": "#sides"}, - "west": {"uv": [7, 12, 9, 13], "texture": "#inside"}, - "up": {"uv": [7, 7, 10, 9], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [7, 7, 10, 9], "rotation": 90, "texture": "#sides"} + "north": { "uv": [7, 12, 10, 13], "texture": "#sides" }, + "east": { "uv": [7, 12, 9, 13], "texture": "#inside" }, + "south": { "uv": [6, 12, 9, 13], "texture": "#sides" }, + "west": { "uv": [7, 12, 9, 13], "texture": "#inside" }, + "up": { "uv": [7, 7, 10, 9], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [7, 7, 10, 9], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna II West", "from": [7.875, 7, 12], "to": [10.875, 9, 13], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [7, 7, 10, 9], "texture": "#sides"}, - "east": {"uv": [3, 7, 4, 9], "texture": "#inside"}, - "south": {"uv": [6, 7, 9, 9], "texture": "#sides"}, - "west": {"uv": [12, 7, 13, 9], "texture": "#inside"}, - "up": {"uv": [7, 3, 10, 4], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [7, 12, 10, 13], "rotation": 90, "texture": "#sides"} + "north": { "uv": [7, 7, 10, 9], "texture": "#sides" }, + "east": { "uv": [3, 7, 4, 9], "texture": "#inside" }, + "south": { "uv": [6, 7, 9, 9], "texture": "#sides" }, + "west": { "uv": [12, 7, 13, 9], "texture": "#inside" }, + "up": { "uv": [7, 3, 10, 4], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [7, 12, 10, 13], "rotation": 90, "texture": "#sides" } } }, { "name": "Side Antenna II East", "from": [7.875, 7, 3], "to": [10.875, 9, 4], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [7, 7, 10, 9], "texture": "#sides"}, - "east": {"uv": [12, 7, 13, 9], "texture": "#inside"}, - "south": {"uv": [6, 7, 9, 9], "texture": "#sides"}, - "west": {"uv": [3, 7, 4, 9], "texture": "#inside"}, - "up": {"uv": [7, 12, 10, 13], "rotation": 270, "texture": "#sides"}, - "down": {"uv": [7, 3, 10, 4], "rotation": 90, "texture": "#sides"} + "north": { "uv": [7, 7, 10, 9], "texture": "#sides" }, + "east": { "uv": [12, 7, 13, 9], "texture": "#inside" }, + "south": { "uv": [6, 7, 9, 9], "texture": "#sides" }, + "west": { "uv": [3, 7, 4, 9], "texture": "#inside" }, + "up": { "uv": [7, 12, 10, 13], "rotation": 270, "texture": "#sides" }, + "down": { "uv": [7, 3, 10, 4], "rotation": 90, "texture": "#sides" } } }, { "name": "Antenna Off", "from": [5.875, 7, 7], "to": [13.875, 9, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [1, 7, 9, 9], "rotation": 180, "texture": "#torch"}, - "east": {"uv": [7, 7, 9, 9], "rotation": 270, "texture": "#torch"}, - "south": {"uv": [1, 7, 9, 9], "texture": "#torch"}, - "up": {"uv": [1, 7, 9, 9], "texture": "#torch"}, - "down": {"uv": [1, 7, 9, 9], "texture": "#torch"} + "north": { "uv": [1, 7, 9, 9], "rotation": 180, "texture": "#torch" }, + "east": { "uv": [7, 7, 9, 9], "rotation": 270, "texture": "#torch" }, + "south": { "uv": [1, 7, 9, 9], "texture": "#torch" }, + "up": { "uv": [1, 7, 9, 9], "texture": "#torch" }, + "down": { "uv": [1, 7, 9, 9], "texture": "#torch" } } }, { "name": "Status Off", "from": [4.875, 5, 5], "to": [5.875, 11, 11], - "rotation": {"angle": 0, "axis": "y", "origin": [12.875, 8, 8]}, + "rotation": { "angle": 0, "axis": "y", "origin": [12.875, 8, 8] }, "faces": { - "north": {"uv": [12, 5, 13, 11], "texture": "#indicator"}, - "south": {"uv": [3, 5, 4, 11], "texture": "#indicator"}, - "up": {"uv": [12, 5, 13, 11], "rotation": 270, "texture": "#indicator"}, - "down": {"uv": [12, 5, 13, 11], "rotation": 90, "texture": "#indicator"} + "north": { "uv": [12, 5, 13, 11], "texture": "#indicator" }, + "south": { "uv": [3, 5, 4, 11], "texture": "#indicator" }, + "up": { + "uv": [12, 5, 13, 11], + "rotation": 270, + "texture": "#indicator" + }, + "down": { + "uv": [12, 5, 13, 11], + "rotation": 90, + "texture": "#indicator" + } } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wireless_booster.json b/src/main/resources/assets/appliedenergistics2/models/item/wireless_booster.json index eee7f3127..fdd62684d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wireless_booster.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wireless_booster.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/wireless_booster" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/wireless_booster" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wireless_receiver.json b/src/main/resources/assets/appliedenergistics2/models/item/wireless_receiver.json index f03927ccd..c34a0f982 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wireless_receiver.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wireless_receiver.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/wireless_receiver" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/wireless_receiver" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wireless_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/wireless_terminal.json index 9a469d44e..74ac7ceb4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wireless_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wireless_terminal.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/wireless_terminal" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/wireless_terminal" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wooden_crank.json b/src/main/resources/assets/appliedenergistics2/models/item/wooden_crank.json index 741b9b9ed..d802af31e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wooden_crank.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wooden_crank.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/wooden_crank" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/wooden_crank" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/wooden_gear.json b/src/main/resources/assets/appliedenergistics2/models/item/wooden_gear.json index 260bef1b4..462e3033d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/wooden_gear.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/wooden_gear.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/wooden_gear" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/wooden_gear" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_cable.json index f567a1b08..ecfebb488 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/covered/yellow" - } + "parent": "appliedenergistics2:item/covered_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/covered/yellow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_dense_cable.json index 79aad452f..ee10a60f4 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_covered_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/covered_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/yellow" - } + "parent": "appliedenergistics2:item/covered_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/yellow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_glass_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_glass_cable.json index 95f9cf8d2..b30df2413 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_glass_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_glass_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/glass_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/glass/yellow" - } + "parent": "appliedenergistics2:item/glass_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/glass/yellow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_lumen_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_lumen_paint_ball.json index c10dc7d77..a78a23e3f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_lumen_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_lumen_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball_shimmer" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball_shimmer" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_paint_ball.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_paint_ball.json index 7bd8f39f5..c87053094 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_paint_ball.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_paint_ball.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "appliedenergistics2:item/paint_ball" - } + "parent": "item/generated", + "textures": { + "layer0": "appliedenergistics2:item/paint_ball" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_cable.json index 44bc4a8f4..eca2c84c2 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/smart/yellow" - } + "parent": "appliedenergistics2:item/smart_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/smart/yellow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_dense_cable.json b/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_dense_cable.json index 584c7f1f6..fd4d25e90 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_dense_cable.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/yellow_smart_dense_cable.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:item/smart_dense_cable_base", - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/yellow" - } + "parent": "appliedenergistics2:item/smart_dense_cable_base", + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/yellow" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane.json index 9236ced97..088ba1d22 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:item/part/annihilation_plane", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane_on.json index 60ee29674..ae4365576 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/annihilation_plane_on.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:parts/annihilation_plane_on", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/center.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/center.json index 7e3c8c9dd..0b21e11ea 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/center.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/center.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 5.0 - ], - "to": [ - 11.0, - 11.0, - 11.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 5.0], + "to": [11.0, 11.0, 11.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/connection.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/connection.json index b7767a5af..4de548bb1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/connection.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/connection.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 0.0 - ], - "to": [ - 10.0, - 10.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 11.0, - 6.0, - 16.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 6.0, - 11.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 0.0, - 10.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 11.0, - 10.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [6.0, 6.0, 0.0], + "to": [10.0, 10.0, 8.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "east": { + "texture": "#base", + "uv": [11.0, 6.0, 16.0, 10.0] + }, + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [16.0, 6.0, 11.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 0.0, 10.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 11.0, 10.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/straight.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/straight.json index 98746eb45..ec449e51a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/straight.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/covered/straight.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 0.0 - ], - "to": [ - 11.0, - 11.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 0.0], + "to": [11.0, 11.0, 16.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/center.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/center.json index 8522b7da6..c2de0b52c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/center.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/center.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 3.0, - 3.0, - 3.0 - ], - "to": [ - 13.0, - 13.0, - 13.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.5, - 5.5, - 5.5, - 10.5 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 10.5, - 5.5, - 5.5, - 10.5 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [3.0, 3.0, 3.0], + "to": [13.0, 13.0, 13.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "east": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "south": { + "texture": "#base", + "uv": [10.5, 5.5, 5.5, 10.5] + }, + "west": { + "texture": "#base", + "uv": [10.5, 5.5, 5.5, 10.5] + }, + "up": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "down": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/connection.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/connection.json index 664768076..3cee47219 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/connection.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/connection.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 4.0, - 4.0, - 0.0 - ], - "to": [ - 12.0, - 12.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 11.0, - 5.5, - 16.0, - 10.5 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.5, - 10.5, - 5.5, - 5.5 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 5.5, - 11.0, - 10.5 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.5, - 0.0, - 10.5, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.5, - 11.0, - 10.5, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [4.0, 4.0, 0.0], + "to": [12.0, 12.0, 8.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "east": { + "texture": "#base", + "uv": [11.0, 5.5, 16.0, 10.5] + }, + "south": { + "texture": "#base", + "uv": [10.5, 10.5, 5.5, 5.5] + }, + "west": { + "texture": "#base", + "uv": [16.0, 5.5, 11.0, 10.5] + }, + "up": { + "texture": "#base", + "uv": [5.5, 0.0, 10.5, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.5, 11.0, 10.5, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/straight.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/straight.json index 7124067e8..270576f0b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/straight.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_covered/straight.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_covered/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 3.0, - 3.0, - 0.0 - ], - "to": [ - 13.0, - 13.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_covered/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [3.0, 3.0, 0.0], + "to": [13.0, 13.0, 16.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/center.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/center.json index 68023e2b1..8cea214ad 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/center.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/center.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/${color}" - }, - "elements": [ - { - "name": "Base", - "from": [ - 3.0, - 3.0, - 3.0 - ], - "to": [ - 13.0, - 13.0, - 13.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.5, - 5.5, - 5.5, - 10.5 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 10.5, - 5.5, - 5.5, - 10.5 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/${color}" + }, + "elements": [ + { + "name": "Base", + "from": [3.0, 3.0, 3.0], + "to": [13.0, 13.0, 13.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "east": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "south": { + "texture": "#base", + "uv": [10.5, 5.5, 5.5, 10.5] + }, + "west": { + "texture": "#base", + "uv": [10.5, 5.5, 5.5, 10.5] + }, + "up": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "down": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/connection.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/connection.json index c8b882898..b774bfb28 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/connection.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/connection.json @@ -1,146 +1,70 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/${color}", - "channels": "appliedenergistics2:parts/cable/dense_smart/${channels}" - }, - "elements": [ - { - "name": "Base", - "from": [ - 4.0, - 4.0, - 0.0 - ], - "to": [ - 12.0, - 12.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 11.0, - 5.5, - 16.0, - 10.5 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.5, - 10.5, - 5.5, - 5.5 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 5.5, - 11.0, - 10.5 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.5, - 0.0, - 10.5, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.5, - 11.0, - 10.5, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/${color}", + "channels": "appliedenergistics2:parts/cable/dense_smart/${channels}" + }, + "elements": [ + { + "name": "Base", + "from": [4.0, 4.0, 0.0], + "to": [12.0, 12.0, 8.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.5, 5.5, 10.5, 10.5] }, - { - "name": "Channels", - "from": [ - 4.0, - 4.0, - 0.0 - ], - "to": [ - 12.0, - 12.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#channels", - "uv": [ - 5.5, - 5.5, - 10.5, - 10.5 - ] - }, - "east": { - "texture": "#channels", - "uv": [ - 11.0, - 5.5, - 16.0, - 10.5 - ] - }, - "south": { - "texture": "#channels", - "uv": [ - 10.5, - 10.5, - 5.5, - 5.5 - ] - }, - "west": { - "texture": "#channels", - "uv": [ - 16.0, - 5.5, - 11.0, - 10.5 - ] - }, - "up": { - "texture": "#channels", - "uv": [ - 5.5, - 0.0, - 10.5, - 5.0 - ] - }, - "down": { - "texture": "#channels", - "uv": [ - 5.5, - 11.0, - 10.5, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [11.0, 5.5, 16.0, 10.5] + }, + "south": { + "texture": "#base", + "uv": [10.5, 10.5, 5.5, 5.5] + }, + "west": { + "texture": "#base", + "uv": [16.0, 5.5, 11.0, 10.5] + }, + "up": { + "texture": "#base", + "uv": [5.5, 0.0, 10.5, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.5, 11.0, 10.5, 16.0] } - ] + } + }, + { + "name": "Channels", + "from": [4.0, 4.0, 0.0], + "to": [12.0, 12.0, 8.0], + "faces": { + "north": { + "texture": "#channels", + "uv": [5.5, 5.5, 10.5, 10.5] + }, + "east": { + "texture": "#channels", + "uv": [11.0, 5.5, 16.0, 10.5] + }, + "south": { + "texture": "#channels", + "uv": [10.5, 10.5, 5.5, 5.5] + }, + "west": { + "texture": "#channels", + "uv": [16.0, 5.5, 11.0, 10.5] + }, + "up": { + "texture": "#channels", + "uv": [5.5, 0.0, 10.5, 5.0] + }, + "down": { + "texture": "#channels", + "uv": [5.5, 11.0, 10.5, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/straight.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/straight.json index 4269f669d..ba21522e7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/straight.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/dense_smart/straight.json @@ -1,146 +1,70 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/dense_smart/${color}", - "channels": "appliedenergistics2:parts/cable/dense_smart/${channels}" - }, - "elements": [ - { - "name": "Base", - "from": [ - 3.0, - 3.0, - 0.0 - ], - "to": [ - 13.0, - 13.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/dense_smart/${color}", + "channels": "appliedenergistics2:parts/cable/dense_smart/${channels}" + }, + "elements": [ + { + "name": "Base", + "from": [3.0, 3.0, 0.0], + "to": [13.0, 13.0, 16.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] }, - { - "name": "Channels", - "from": [ - 3.0, - 3.0, - 0.0 - ], - "to": [ - 13.0, - 13.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#channels", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#channels", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#channels", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#channels", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + }, + { + "name": "Channels", + "from": [3.0, 3.0, 0.0], + "to": [13.0, 13.0, 16.0], + "faces": { + "north": { + "texture": "#channels", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#channels", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#channels", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#channels", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#channels", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#channels", + "uv": [5.0, 11.0, 11.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/center.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/center.json index 1f0172027..721b72118 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/center.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/center.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/glass/transparent" - }, - "elements": [ - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 6.0 - ], - "to": [ - 10.0, - 10.0, - 10.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/glass/transparent" + }, + "elements": [ + { + "name": "Element", + "from": [6.0, 6.0, 6.0], + "to": [10.0, 10.0, 10.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "east": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/connection.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/connection.json index 198666f6b..4b0bc5b73 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/connection.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/connection.json @@ -1,58 +1,30 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/glass/transparent" - }, - "elements": [ - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 0.0 - ], - "to": [ - 10.0, - 10.0, - 6.0 - ], - "faces": { - "east": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 16.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 6.0, - 10.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 0.0, - 10.0, - 6.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 10.0, - 10.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/glass/transparent" + }, + "elements": [ + { + "name": "Element", + "from": [6.0, 6.0, 0.0], + "to": [10.0, 10.0, 6.0], + "faces": { + "east": { + "texture": "#base", + "uv": [10.0, 6.0, 16.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [16.0, 6.0, 10.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 0.0, 10.0, 6.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 10.0, 10.0, 16.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/straight.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/straight.json index b5b3cc126..2f1a3be13 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/straight.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/glass/straight.json @@ -1,214 +1,100 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/glass/transparent" - }, - "elements": [ - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 6.0 - ], - "to": [ - 10.0, - 10.0, - 10.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/glass/transparent" + }, + "elements": [ + { + "name": "Element", + "from": [6.0, 6.0, 6.0], + "to": [10.0, 10.0, 10.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] }, - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 0.0 - ], - "to": [ - 10.0, - 10.0, - 6.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 16.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 6.0, - 10.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 0.0, - 10.0, - 6.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 10.0, - 10.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] }, - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 10.0 - ], - "to": [ - 10.0, - 10.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 6.0, - 6.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 0.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 10.0, - 10.0, - 16.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 0.0, - 10.0, - 6.0 - ] - } - } + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] } - ] + } + }, + { + "name": "Element", + "from": [6.0, 6.0, 0.0], + "to": [10.0, 10.0, 6.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "east": { + "texture": "#base", + "uv": [10.0, 6.0, 16.0, 10.0] + }, + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [16.0, 6.0, 10.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 0.0, 10.0, 6.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 10.0, 10.0, 16.0] + } + } + }, + { + "name": "Element", + "from": [6.0, 6.0, 10.0], + "to": [10.0, 10.0, 16.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "east": { + "texture": "#base", + "uv": [0.0, 6.0, 6.0, 10.0] + }, + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [6.0, 6.0, 0.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 10.0, 10.0, 16.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 0.0, 10.0, 6.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/center.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/center.json index e9b0cdfd3..0175823f9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/center.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/center.json @@ -1,76 +1,38 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/smart/${color}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 5.0 - ], - "to": [ - 11.0, - 11.0, - 11.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/smart/${color}" + }, + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 5.0], + "to": [11.0, 11.0, 11.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/connection.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/connection.json index 40309b74d..f56b8ce45 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/connection.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/connection.json @@ -1,146 +1,70 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/smart/${color}", - "channels": "appliedenergistics2:parts/cable/smart/${channels}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 6.0, - 6.0, - 0.0 - ], - "to": [ - 10.0, - 10.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 11.0, - 6.0, - 16.0, - 10.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 16.0, - 6.0, - 11.0, - 10.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 6.0, - 0.0, - 10.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 6.0, - 11.0, - 10.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/smart/${color}", + "channels": "appliedenergistics2:parts/cable/smart/${channels}" + }, + "elements": [ + { + "name": "Element", + "from": [6.0, 6.0, 0.0], + "to": [10.0, 10.0, 8.0], + "faces": { + "north": { + "texture": "#base", + "uv": [6.0, 6.0, 10.0, 10.0] }, - { - "name": "Channels", - "from": [ - 6.0, - 6.0, - 0.0 - ], - "to": [ - 10.0, - 10.0, - 8.0 - ], - "faces": { - "north": { - "texture": "#channels", - "uv": [ - 6.0, - 6.0, - 10.0, - 10.0 - ] - }, - "east": { - "texture": "#channels", - "uv": [ - 11.0, - 6.0, - 16.0, - 10.0 - ] - }, - "south": { - "texture": "#channels", - "uv": [ - 10.0, - 6.0, - 6.0, - 10.0 - ] - }, - "west": { - "texture": "#channels", - "uv": [ - 16.0, - 6.0, - 11.0, - 10.0 - ] - }, - "up": { - "texture": "#channels", - "uv": [ - 6.0, - 0.0, - 10.0, - 5.0 - ] - }, - "down": { - "texture": "#channels", - "uv": [ - 6.0, - 11.0, - 10.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [11.0, 6.0, 16.0, 10.0] + }, + "south": { + "texture": "#base", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#base", + "uv": [16.0, 6.0, 11.0, 10.0] + }, + "up": { + "texture": "#base", + "uv": [6.0, 0.0, 10.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [6.0, 11.0, 10.0, 16.0] } - ] + } + }, + { + "name": "Channels", + "from": [6.0, 6.0, 0.0], + "to": [10.0, 10.0, 8.0], + "faces": { + "north": { + "texture": "#channels", + "uv": [6.0, 6.0, 10.0, 10.0] + }, + "east": { + "texture": "#channels", + "uv": [11.0, 6.0, 16.0, 10.0] + }, + "south": { + "texture": "#channels", + "uv": [10.0, 6.0, 6.0, 10.0] + }, + "west": { + "texture": "#channels", + "uv": [16.0, 6.0, 11.0, 10.0] + }, + "up": { + "texture": "#channels", + "uv": [6.0, 0.0, 10.0, 5.0] + }, + "down": { + "texture": "#channels", + "uv": [6.0, 11.0, 10.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/straight.json b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/straight.json index 747b99328..bfb8ad55c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/straight.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable/smart/straight.json @@ -1,146 +1,70 @@ { - "textures": { - "base": "appliedenergistics2:parts/cable/smart/${color}", - "channels": "appliedenergistics2:parts/cable/smart/${channels}" - }, - "elements": [ - { - "name": "Element", - "from": [ - 5.0, - 5.0, - 0.0 - ], - "to": [ - 11.0, - 11.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#base", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#base", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#base", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#base", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#base", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "textures": { + "base": "appliedenergistics2:parts/cable/smart/${color}", + "channels": "appliedenergistics2:parts/cable/smart/${channels}" + }, + "elements": [ + { + "name": "Element", + "from": [5.0, 5.0, 0.0], + "to": [11.0, 11.0, 16.0], + "faces": { + "north": { + "texture": "#base", + "uv": [5.0, 5.0, 11.0, 11.0] }, - { - "name": "Channels", - "from": [ - 5.0, - 5.0, - 0.0 - ], - "to": [ - 11.0, - 11.0, - 16.0 - ], - "faces": { - "north": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 11.0, - 11.0 - ] - }, - "east": { - "texture": "#channels", - "uv": [ - 0.0, - 5.0, - 5.0, - 11.0 - ] - }, - "south": { - "texture": "#channels", - "uv": [ - 11.0, - 5.0, - 5.0, - 11.0 - ] - }, - "west": { - "texture": "#channels", - "uv": [ - 5.0, - 5.0, - 0.0, - 11.0 - ] - }, - "up": { - "texture": "#channels", - "uv": [ - 5.0, - 0.0, - 11.0, - 5.0 - ] - }, - "down": { - "texture": "#channels", - "uv": [ - 5.0, - 11.0, - 11.0, - 16.0 - ] - } - } + "east": { + "texture": "#base", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#base", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#base", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#base", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#base", + "uv": [5.0, 11.0, 11.0, 16.0] } - ] + } + }, + { + "name": "Channels", + "from": [5.0, 5.0, 0.0], + "to": [11.0, 11.0, 16.0], + "faces": { + "north": { + "texture": "#channels", + "uv": [5.0, 5.0, 11.0, 11.0] + }, + "east": { + "texture": "#channels", + "uv": [0.0, 5.0, 5.0, 11.0] + }, + "south": { + "texture": "#channels", + "uv": [11.0, 5.0, 5.0, 11.0] + }, + "west": { + "texture": "#channels", + "uv": [5.0, 5.0, 0.0, 11.0] + }, + "up": { + "texture": "#channels", + "uv": [5.0, 0.0, 11.0, 5.0] + }, + "down": { + "texture": "#channels", + "uv": [5.0, 11.0, 11.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor.json b/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor.json index b58d9c9a3..8fa002a46 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor.json @@ -1,77 +1,39 @@ { - "textures": { - "0": "appliedenergistics2:parts/cable_anchor", - "particle": "appliedenergistics2:parts/cable_anchor" - }, - "elements": [ - { - "name": "Element", - "from": [ - 7.0, - 7.0, - 0.0 - ], - "to": [ - 9.0, - 9.0, - 6 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 6.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 6.0, - 2.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 6.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 6.0 - ] - } - } + "textures": { + "0": "appliedenergistics2:parts/cable_anchor", + "particle": "appliedenergistics2:parts/cable_anchor" + }, + "elements": [ + { + "name": "Element", + "from": [7.0, 7.0, 0.0], + "to": [9.0, 9.0, 6], + "faces": { + "north": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 0.0, 6.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "west": { + "texture": "#0", + "uv": [0.0, 0.0, 6.0, 2.0] + }, + "up": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 6.0] + }, + "down": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 6.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor_short.json b/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor_short.json index 7c8468818..4b9f989dd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor_short.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable_anchor_short.json @@ -1,77 +1,39 @@ { - "textures": { - "0": "appliedenergistics2:parts/cable_anchor", - "particle": "appliedenergistics2:parts/cable_anchor" - }, - "elements": [ - { - "name": "Element", - "from": [ - 7.0, - 7.0, - 1.0 - ], - "to": [ - 9.0, - 9.0, - 6 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 1.0, - 0.0, - 6.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 1.0, - 0.0, - 6.0, - 2.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 2.0, - 6.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 0.0, - 1.0, - 2.0, - 6.0 - ] - } - } + "textures": { + "0": "appliedenergistics2:parts/cable_anchor", + "particle": "appliedenergistics2:parts/cable_anchor" + }, + "elements": [ + { + "name": "Element", + "from": [7.0, 7.0, 1.0], + "to": [9.0, 9.0, 6], + "faces": { + "north": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "east": { + "texture": "#0", + "uv": [1.0, 0.0, 6.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "west": { + "texture": "#0", + "uv": [1.0, 0.0, 6.0, 2.0] + }, + "up": { + "texture": "#0", + "uv": [0.0, 1.0, 2.0, 6.0] + }, + "down": { + "texture": "#0", + "uv": [0.0, 1.0, 2.0, 6.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/cable_facade.json b/src/main/resources/assets/appliedenergistics2/models/part/cable_facade.json index 7ba7bf689..e5ac44882 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/cable_facade.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/cable_facade.json @@ -1,77 +1,39 @@ { - "textures": { - "0": "appliedenergistics2:parts/cable_anchor", - "particle": "appliedenergistics2:parts/cable_anchor" - }, - "elements": [ - { - "name": "Element", - "from": [ - 7.0, - 7.0, - 1.0 - ], - "to": [ - 9.0, - 9.0, - 6.0 - ], - "faces": { - "north": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "east": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 5.0, - 2.0 - ] - }, - "south": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 2.0 - ] - }, - "west": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 5.0, - 2.0 - ] - }, - "up": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 5.0 - ] - }, - "down": { - "texture": "#0", - "uv": [ - 0.0, - 0.0, - 2.0, - 5.0 - ] - } - } + "textures": { + "0": "appliedenergistics2:parts/cable_anchor", + "particle": "appliedenergistics2:parts/cable_anchor" + }, + "elements": [ + { + "name": "Element", + "from": [7.0, 7.0, 1.0], + "to": [9.0, 9.0, 6.0], + "faces": { + "north": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "east": { + "texture": "#0", + "uv": [0.0, 0.0, 5.0, 2.0] + }, + "south": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 2.0] + }, + "west": { + "texture": "#0", + "uv": [0.0, 0.0, 5.0, 2.0] + }, + "up": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 5.0] + }, + "down": { + "texture": "#0", + "uv": [0.0, 0.0, 2.0, 5.0] } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_off.json b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_off.json index d17e535ee..e0166fa7c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium_locked", - "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium_locked", + "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_on.json b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_on.json index 41a322617..3c91d21a7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_locked_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium_locked", - "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium_locked", + "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_off.json b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_off.json index 022ba3151..00cb8cb26 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium", - "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium", + "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_on.json b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_on.json index 31ecd1871..bc3035772 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/conversion_monitor_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium", - "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/conversion_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/conversion_monitor_medium", + "lightsDark": "appliedenergistics2:parts/conversion_monitor_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal.json b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal.json index da5917646..ce80ad08e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal.json @@ -1,283 +1,140 @@ { - "textures": { - "frame": "appliedenergistics2:parts/crafting_terminal/frame", - "sides": "appliedenergistics2:parts/crafting_terminal/sides", - "back": "appliedenergistics2:parts/crafting_terminal/back", - "l0": "appliedenergistics2:parts/crafting_terminal/l0", - "l1": "appliedenergistics2:parts/crafting_terminal/l1", - "l2": "appliedenergistics2:parts/crafting_terminal/l2", - "SidesStatus": "appliedenergistics2:parts/crafting_terminal/sidesstatus", - "Backlights": "appliedenergistics2:parts/crafting_terminal/backlights", - "particle": "appliedenergistics2:parts/crafting_terminal/back" - }, - "elements": [ - { - "name": "Base", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "frame", - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - }, - "east": { - "texture": "sides", - "uv": [ - 0.0, - 2.0, - 1.0, - 14.0 - ] - }, - "south": { - "texture": "back", - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - }, - "west": { - "texture": "sides", - "uv": [ - 15.0, - 2.0, - 16.0, - 14.0 - ] - }, - "up": { - "texture": "sides", - "uv": [ - 2.0, - 0.0, - 14.0, - 1.0 - ] - }, - "down": { - "texture": "sides", - "uv": [ - 2.0, - 15.0, - 14.0, - 16.0 - ] - } - } + "textures": { + "frame": "appliedenergistics2:parts/crafting_terminal/frame", + "sides": "appliedenergistics2:parts/crafting_terminal/sides", + "back": "appliedenergistics2:parts/crafting_terminal/back", + "l0": "appliedenergistics2:parts/crafting_terminal/l0", + "l1": "appliedenergistics2:parts/crafting_terminal/l1", + "l2": "appliedenergistics2:parts/crafting_terminal/l2", + "SidesStatus": "appliedenergistics2:parts/crafting_terminal/sidesstatus", + "Backlights": "appliedenergistics2:parts/crafting_terminal/backlights", + "particle": "appliedenergistics2:parts/crafting_terminal/back" + }, + "elements": [ + { + "name": "Base", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "frame", + "uv": [2.0, 2.0, 14.0, 14.0] }, - { - "name": "l0", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "l0", - "tintindex": 1, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "east": { + "texture": "sides", + "uv": [0.0, 2.0, 1.0, 14.0] }, - { - "name": "l1", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "l1", - "tintindex": 2, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "south": { + "texture": "back", + "uv": [2.0, 2.0, 14.0, 14.0] }, - { - "name": "l2", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "l2", - "tintindex": 3, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "west": { + "texture": "sides", + "uv": [15.0, 2.0, 16.0, 14.0] }, - { - "name": "Back", - "from": [ - 4.0, - 4.0, - 1.0 - ], - "to": [ - 12.0, - 12.0, - 2.0 - ], - "faces": { - "north": { - "texture": "back", - "uv": [ - 4.0, - 4.0, - 12.0, - 12.0 - ] - }, - "east": { - "texture": "SidesStatus", - "uv": [ - 0.0, - 4.0, - 1.0, - 12.0 - ] - }, - "south": { - "texture": "back", - "uv": [ - 4.0, - 4.0, - 12.0, - 12.0 - ] - }, - "west": { - "texture": "SidesStatus", - "uv": [ - 15.0, - 4.0, - 16.0, - 12.0 - ] - }, - "up": { - "texture": "SidesStatus", - "uv": [ - 4.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "SidesStatus", - "uv": [ - 4.0, - 15.0, - 12.0, - 16.0 - ] - } - } + "up": { + "texture": "sides", + "uv": [2.0, 0.0, 14.0, 1.0] }, - { - "name": "Backlights", - "from": [ - 4.0, - 4.0, - 1.0 - ], - "to": [ - 12.0, - 12.0, - 2.0 - ], - "faces": { - "east": { - "texture": "Backlights", - "tintindex": 0, - "uv": [ - 0.0, - 4.0, - 1.0, - 12.0 - ] - }, - "west": { - "texture": "Backlights", - "tintindex": 0, - "uv": [ - 15.0, - 4.0, - 16.0, - 12.0 - ] - }, - "up": { - "texture": "Backlights", - "tintindex": 0, - "uv": [ - 4.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "Backlights", - "tintindex": 0, - "uv": [ - 4.0, - 15.0, - 12.0, - 16.0 - ] - } - } + "down": { + "texture": "sides", + "uv": [2.0, 15.0, 14.0, 16.0] } - ] + } + }, + { + "name": "l0", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "l0", + "tintindex": 1, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "l1", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "l1", + "tintindex": 2, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "l2", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "l2", + "tintindex": 3, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "Back", + "from": [4.0, 4.0, 1.0], + "to": [12.0, 12.0, 2.0], + "faces": { + "north": { + "texture": "back", + "uv": [4.0, 4.0, 12.0, 12.0] + }, + "east": { + "texture": "SidesStatus", + "uv": [0.0, 4.0, 1.0, 12.0] + }, + "south": { + "texture": "back", + "uv": [4.0, 4.0, 12.0, 12.0] + }, + "west": { + "texture": "SidesStatus", + "uv": [15.0, 4.0, 16.0, 12.0] + }, + "up": { + "texture": "SidesStatus", + "uv": [4.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "SidesStatus", + "uv": [4.0, 15.0, 12.0, 16.0] + } + } + }, + { + "name": "Backlights", + "from": [4.0, 4.0, 1.0], + "to": [12.0, 12.0, 2.0], + "faces": { + "east": { + "texture": "Backlights", + "tintindex": 0, + "uv": [0.0, 4.0, 1.0, 12.0] + }, + "west": { + "texture": "Backlights", + "tintindex": 0, + "uv": [15.0, 4.0, 16.0, 12.0] + }, + "up": { + "texture": "Backlights", + "tintindex": 0, + "uv": [4.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "Backlights", + "tintindex": 0, + "uv": [4.0, 15.0, 12.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_off.json index c0a7b0ea7..a2633d0a1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/crafting_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/crafting_terminal_medium", - "lightsDark": "appliedenergistics2:parts/crafting_terminal_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/crafting_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/crafting_terminal_medium", + "lightsDark": "appliedenergistics2:parts/crafting_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_on.json index 367447150..cf0aba25e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/crafting_terminal_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/crafting_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/crafting_terminal_medium", - "lightsDark": "appliedenergistics2:parts/crafting_terminal_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/crafting_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/crafting_terminal_medium", + "lightsDark": "appliedenergistics2:parts/crafting_terminal_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/display_base.json b/src/main/resources/assets/appliedenergistics2/models/part/display_base.json index 930a48200..890d13172 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/display_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/display_base.json @@ -1,72 +1,56 @@ { - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:parts/monitor_front", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:parts/monitor_front", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 3 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [4, 4, 2], + "to": [12, 12, 3], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/display_off.json b/src/main/resources/assets/appliedenergistics2/models/part/display_off.json index 123edaf82..560d1a014 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/display_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/display_off.json @@ -1,63 +1,39 @@ { - "textures": { - "lightsBright": "appliedenergistics2:parts/terminal_bright", - "lightsMedium": "appliedenergistics2:parts/terminal_medium", - "lightsDark": "appliedenergistics2:parts/terminal_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3 - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2 - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1 - } - } + "textures": { + "lightsBright": "appliedenergistics2:parts/terminal_bright", + "lightsMedium": "appliedenergistics2:parts/terminal_medium", + "lightsDark": "appliedenergistics2:parts/terminal_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3 } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2 + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1 + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/display_status_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/display_status_has_channel.json index 93d4fcded..02e6ea241 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/display_status_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/display_status_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [4, 4, 2], + "to": [12, 12, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/display_status_off.json b/src/main/resources/assets/appliedenergistics2/models/part/display_status_off.json index 4db170344..f646c8639 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/display_status_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/display_status_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [4, 4, 2], + "to": [12, 12, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/display_status_on.json b/src/main/resources/assets/appliedenergistics2/models/part/display_status_on.json index f5707fb65..b88a57dfa 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/display_status_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/display_status_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [4, 4, 2], + "to": [12, 12, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_base.json index 4ca74e0b2..8bfcab093 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_base.json @@ -1,136 +1,104 @@ { - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/export_bus", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/export_bus", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [4, 4, 2], + "to": [12, 12, 4], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 6, - 6, - 0 - ], - "to": [ - 10, - 10, - 1 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 0], + "to": [10, 10, 1], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_has_channel.json index 5371d54c1..a4a4940cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_off.json index 7ab36af58..3d5d7755e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_on.json index 37fdae783..9bcf52c70 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/export_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/export_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane.json index 556e10f95..0e3bfde89 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:item/part/fluid_annihilation_plane", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane_on.json index 7d03bc75d..60f244818 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_annihilation_plane_on.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:parts/fluid_annihilation_plane_on", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_base.json index 759c9068d..72f31828b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_base.json @@ -1,136 +1,104 @@ { - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_export_bus", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_export_bus", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [4, 4, 2], + "to": [12, 12, 4], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 6, - 6, - 0 - ], - "to": [ - 10, - 10, - 1 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 0], + "to": [10, 10, 1], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_has_channel.json index 5371d54c1..a4a4940cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_off.json index 7ab36af58..3d5d7755e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_on.json index 37fdae783..9bcf52c70 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_export_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane.json index df09bada0..75b1ff4a3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:item/part/fluid_formation_plane", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane_on.json index c604f759a..73c1e511a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_formation_plane_on.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:parts/fluid_formation_plane_on", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_base.json index bc90ac2f9..d268ecb5d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_base.json @@ -1,136 +1,104 @@ { - "textures": { - "sides": "appliedenergistics2:parts/import_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_import_bus", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 4, - 4, - 0 - ], - "to": [ - 12, - 12, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/import_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_import_bus", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [4, 4, 0], + "to": [12, 12, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 6, - 6, - 3 - ], - "to": [ - 10, - 10, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 3], + "to": [10, 10, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_has_channel.json index 5371d54c1..a4a4940cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_off.json index 7ab36af58..3d5d7755e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_on.json index 37fdae783..9bcf52c70 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_import_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_base.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_base.json index b18e0f2c4..1355e83b1 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_base.json @@ -1,104 +1,80 @@ { - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/fluid_interface", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/fluid_interface", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 3 - ], - "to": [ - 11, - 11, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 3], + "to": [11, 11, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_has_channel.json index a9cdf5044..e675a71e5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_off.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_off.json index 3ab8507fa..2707327cb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_on.json index fddbe6753..f78e58241 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_interface_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_base.json index 15d7415d9..273f4226f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_base.json @@ -1,130 +1,98 @@ { - "textures": { - "sides": "appliedenergistics2:parts/storage_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/storage_bus_back", - "front": "appliedenergistics2:item/part/fluid_storage_bus", - "particle": "appliedenergistics2:parts/storage_bus_back" - }, - "elements": [ - { - "from": [ - 3, - 3, - 0 - ], - "to": [ - 13, - 13, - 1 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/storage_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/storage_bus_back", + "front": "appliedenergistics2:item/part/fluid_storage_bus", + "particle": "appliedenergistics2:parts/storage_bus_back" + }, + "elements": [ + { + "from": [3, 3, 0], + "to": [13, 13, 1], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 2, - 2, - 1 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 3 - ], - "to": [ - 11, - 11, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [2, 2, 1], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 3], + "to": [11, 11, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_has_channel.json index a9cdf5044..e675a71e5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_off.json index 3ab8507fa..2707327cb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_on.json index fddbe6753..f78e58241 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_storage_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal.json index b0a836c66..4f7e4a926 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal.json @@ -1,283 +1,140 @@ { - "textures": { - "frame": "appliedenergistics2:parts/fluid_terminal/frame", - "sides": "appliedenergistics2:parts/fluid_terminal/sides", - "back": "appliedenergistics2:parts/fluid_terminal/back", - "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", - "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", - "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark", - "status": "appliedenergistics2:parts/fluid_terminal/status", - "backlights": "appliedenergistics2:parts/fluid_terminal/backlights", - "particle": "appliedenergistics2:parts/fluid_terminal/back" - }, - "elements": [ - { - "name": "Base", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "frame", - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - }, - "east": { - "texture": "sides", - "uv": [ - 0.0, - 2.0, - 1.0, - 14.0 - ] - }, - "south": { - "texture": "back", - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - }, - "west": { - "texture": "sides", - "uv": [ - 15.0, - 2.0, - 16.0, - 14.0 - ] - }, - "up": { - "texture": "sides", - "uv": [ - 2.0, - 0.0, - 14.0, - 1.0 - ] - }, - "down": { - "texture": "sides", - "uv": [ - 2.0, - 15.0, - 14.0, - 16.0 - ] - } - } + "textures": { + "frame": "appliedenergistics2:parts/fluid_terminal/frame", + "sides": "appliedenergistics2:parts/fluid_terminal/sides", + "back": "appliedenergistics2:parts/fluid_terminal/back", + "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", + "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", + "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark", + "status": "appliedenergistics2:parts/fluid_terminal/status", + "backlights": "appliedenergistics2:parts/fluid_terminal/backlights", + "particle": "appliedenergistics2:parts/fluid_terminal/back" + }, + "elements": [ + { + "name": "Base", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "frame", + "uv": [2.0, 2.0, 14.0, 14.0] }, - { - "name": "lightsBright", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "lightsBright", - "tintindex": 1, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "east": { + "texture": "sides", + "uv": [0.0, 2.0, 1.0, 14.0] }, - { - "name": "lightsDark", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "lightsDark", - "tintindex": 2, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "south": { + "texture": "back", + "uv": [2.0, 2.0, 14.0, 14.0] }, - { - "name": "lightsMedium", - "from": [ - 2.0, - 2.0, - 0.0 - ], - "to": [ - 14.0, - 14.0, - 1.0 - ], - "faces": { - "north": { - "texture": "lightsMedium", - "tintindex": 3, - "uv": [ - 2.0, - 2.0, - 14.0, - 14.0 - ] - } - } + "west": { + "texture": "sides", + "uv": [15.0, 2.0, 16.0, 14.0] }, - { - "name": "Back", - "from": [ - 4.0, - 4.0, - 1.0 - ], - "to": [ - 12.0, - 12.0, - 2.0 - ], - "faces": { - "north": { - "texture": "back", - "uv": [ - 4.0, - 4.0, - 12.0, - 12.0 - ] - }, - "east": { - "texture": "status", - "uv": [ - 0.0, - 4.0, - 1.0, - 12.0 - ] - }, - "south": { - "texture": "back", - "uv": [ - 4.0, - 4.0, - 12.0, - 12.0 - ] - }, - "west": { - "texture": "status", - "uv": [ - 15.0, - 4.0, - 16.0, - 12.0 - ] - }, - "up": { - "texture": "status", - "uv": [ - 4.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "status", - "uv": [ - 4.0, - 15.0, - 12.0, - 16.0 - ] - } - } + "up": { + "texture": "sides", + "uv": [2.0, 0.0, 14.0, 1.0] }, - { - "name": "backlights", - "from": [ - 4.0, - 4.0, - 1.0 - ], - "to": [ - 12.0, - 12.0, - 2.0 - ], - "faces": { - "east": { - "texture": "backlights", - "tintindex": 0, - "uv": [ - 0.0, - 4.0, - 1.0, - 12.0 - ] - }, - "west": { - "texture": "backlights", - "tintindex": 0, - "uv": [ - 15.0, - 4.0, - 16.0, - 12.0 - ] - }, - "up": { - "texture": "backlights", - "tintindex": 0, - "uv": [ - 4.0, - 0.0, - 12.0, - 1.0 - ] - }, - "down": { - "texture": "backlights", - "tintindex": 0, - "uv": [ - 4.0, - 15.0, - 12.0, - 16.0 - ] - } - } + "down": { + "texture": "sides", + "uv": [2.0, 15.0, 14.0, 16.0] } - ] + } + }, + { + "name": "lightsBright", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "lightsBright", + "tintindex": 1, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "lightsDark", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "lightsDark", + "tintindex": 2, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "lightsMedium", + "from": [2.0, 2.0, 0.0], + "to": [14.0, 14.0, 1.0], + "faces": { + "north": { + "texture": "lightsMedium", + "tintindex": 3, + "uv": [2.0, 2.0, 14.0, 14.0] + } + } + }, + { + "name": "Back", + "from": [4.0, 4.0, 1.0], + "to": [12.0, 12.0, 2.0], + "faces": { + "north": { + "texture": "back", + "uv": [4.0, 4.0, 12.0, 12.0] + }, + "east": { + "texture": "status", + "uv": [0.0, 4.0, 1.0, 12.0] + }, + "south": { + "texture": "back", + "uv": [4.0, 4.0, 12.0, 12.0] + }, + "west": { + "texture": "status", + "uv": [15.0, 4.0, 16.0, 12.0] + }, + "up": { + "texture": "status", + "uv": [4.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "status", + "uv": [4.0, 15.0, 12.0, 16.0] + } + } + }, + { + "name": "backlights", + "from": [4.0, 4.0, 1.0], + "to": [12.0, 12.0, 2.0], + "faces": { + "east": { + "texture": "backlights", + "tintindex": 0, + "uv": [0.0, 4.0, 1.0, 12.0] + }, + "west": { + "texture": "backlights", + "tintindex": 0, + "uv": [15.0, 4.0, 16.0, 12.0] + }, + "up": { + "texture": "backlights", + "tintindex": 0, + "uv": [4.0, 0.0, 12.0, 1.0] + }, + "down": { + "texture": "backlights", + "tintindex": 0, + "uv": [4.0, 15.0, 12.0, 16.0] + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_off.json index d7f3c27d7..533eb164f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", - "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", - "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", + "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", + "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_on.json index 37f167164..e0f80b175 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/fluid_terminal_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", - "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", - "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/fluid_terminal/lights_bright", + "lightsMedium": "appliedenergistics2:parts/fluid_terminal/lights_medium", + "lightsDark": "appliedenergistics2:parts/fluid_terminal/lights_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/formation_plane.json b/src/main/resources/assets/appliedenergistics2/models/part/formation_plane.json index 6054449d0..a58c99bad 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/formation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/formation_plane.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:item/part/formation_plane", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/formation_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/formation_plane_on.json index 7d2821745..374473a3c 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/formation_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/formation_plane_on.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:parts/formation_plane_on", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane.json b/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane.json index f18fb6138..5695c1a26 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:item/part/identity_annihilation_plane", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane_on.json index e3a07b689..b5e12b76a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/identity_annihilation_plane_on.json @@ -3,4 +3,4 @@ "front": "appliedenergistics2:parts/identity_annihilation_plane_on", "sides": "appliedenergistics2:parts/plane_sides", "back": "appliedenergistics2:parts/transition_plane_back" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_base.json index 0b8054694..4233fae26 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_base.json @@ -1,136 +1,104 @@ { - "textures": { - "sides": "appliedenergistics2:parts/import_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/import_bus", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 4, - 4, - 0 - ], - "to": [ - 12, - 12, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/import_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/import_bus", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [4, 4, 0], + "to": [12, 12, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 6, - 6, - 3 - ], - "to": [ - 10, - 10, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 3], + "to": [10, 10, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_has_channel.json index 5371d54c1..a4a4940cf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_off.json index 7ab36af58..3d5d7755e 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_on.json index 37fdae783..9bcf52c70 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/import_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/import_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 4 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 4], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_base.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_base.json index 27ea445cf..6d1d78633 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_base.json @@ -1,104 +1,80 @@ { - "textures": { - "sides": "appliedenergistics2:parts/export_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:item/part/interface", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/export_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:item/part/interface", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 3 - ], - "to": [ - 11, - 11, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sidesStatus" - }, - "up": { - "texture": "#sidesStatus" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sidesStatus" - }, - "west": { - "texture": "#sidesStatus" - } - } + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 3], + "to": [11, 11, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sidesStatus" + }, + "up": { + "texture": "#sidesStatus" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sidesStatus" + }, + "west": { + "texture": "#sidesStatus" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_has_channel.json index a9cdf5044..e675a71e5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_off.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_off.json index 3ab8507fa..2707327cb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_on.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_on.json index fddbe6753..f78e58241 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_off.json index 6802d0b8a..6d2759c95 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/interface_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/interface_terminal_medium", - "lightsDark": "appliedenergistics2:parts/interface_terminal_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/interface_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/interface_terminal_medium", + "lightsDark": "appliedenergistics2:parts/interface_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_on.json index 7d0344a67..2fc010e8f 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/interface_terminal_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/interface_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/interface_terminal_medium", - "lightsDark": "appliedenergistics2:parts/interface_terminal_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/interface_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/interface_terminal_medium", + "lightsDark": "appliedenergistics2:parts/interface_terminal_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/inverted_toggle_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/inverted_toggle_bus_base.json index a9a7e4acf..544964f3b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/inverted_toggle_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/inverted_toggle_bus_base.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/toggle_bus_base", - "textures": { - "bus": "appliedenergistics2:item/part/inverted_toggle_bus" - } + "parent": "appliedenergistics2:part/toggle_bus_base", + "textures": { + "bus": "appliedenergistics2:item/part/inverted_toggle_bus" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_off.json b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_off.json index bc7f65249..44a520360 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_off.json @@ -1,88 +1,47 @@ { - "textures": { - "emitter": "appliedenergistics2:parts/level_emitter_off", - "sides": "appliedenergistics2:parts/monitor_sides", - "particle": "appliedenergistics2:parts/level_emitter_off" - }, - "elements": [ - { - "from": [ - 7, - 7, - 0 - ], - "to": [ - 9, - 9, - 4 - ], - "faces": { - "up": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 10, - 9 - ], - "rotation": 90 - }, - "down": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 10, - 9 - ], - "rotation": 270 - }, - "east": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 10, - 9 - ], - "rotation": 180 - }, - "north": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 8, - 9 - ] - }, - "west": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 10, - 9 - ] - } - } + "textures": { + "emitter": "appliedenergistics2:parts/level_emitter_off", + "sides": "appliedenergistics2:parts/monitor_sides", + "particle": "appliedenergistics2:parts/level_emitter_off" + }, + "elements": [ + { + "from": [7, 7, 0], + "to": [9, 9, 4], + "faces": { + "up": { + "texture": "#emitter", + "uv": [6, 7, 10, 9], + "rotation": 90 }, - { - "from": [ - 7, - 7, - 4 - ], - "to": [ - 9, - 9, - 5 - ], - "faces": { - "south": { - "texture": "#sides" - } - } + "down": { + "texture": "#emitter", + "uv": [6, 7, 10, 9], + "rotation": 270 + }, + "east": { + "texture": "#emitter", + "uv": [6, 7, 10, 9], + "rotation": 180 + }, + "north": { + "texture": "#emitter", + "uv": [6, 7, 8, 9] + }, + "west": { + "texture": "#emitter", + "uv": [6, 7, 10, 9] } - ] + } + }, + { + "from": [7, 7, 4], + "to": [9, 9, 5], + "faces": { + "south": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_on.json b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_on.json index 16979c4a0..ffc981aef 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_base_on.json @@ -1,177 +1,100 @@ { - "loader": "appliedenergistics2:uvlightmap", - "ambientocclusion": false, - "textures": { - "emitter": "appliedenergistics2:parts/level_emitter_on", - "particle": "appliedenergistics2:parts/level_emitter_on" - }, - "elements": [ - { - "from": [ - 7, - 7, - 3 - ], - "to": [ - 9, - 9, - 4 - ], - "faces": { - "up": { - "texture": "#emitter", - "uv": [ - 9, - 7, - 10, - 9 - ], - "rotation": 90 - }, - "down": { - "texture": "#emitter", - "uv": [ - 9, - 7, - 10, - 9 - ], - "rotation": 270 - }, - "east": { - "texture": "#emitter", - "uv": [ - 9, - 7, - 10, - 9 - ], - "rotation": 180 - }, - "west": { - "texture": "#emitter", - "uv": [ - 9, - 7, - 10, - 9 - ] - } - } + "loader": "appliedenergistics2:uvlightmap", + "ambientocclusion": false, + "textures": { + "emitter": "appliedenergistics2:parts/level_emitter_on", + "particle": "appliedenergistics2:parts/level_emitter_on" + }, + "elements": [ + { + "from": [7, 7, 3], + "to": [9, 9, 4], + "faces": { + "up": { + "texture": "#emitter", + "uv": [9, 7, 10, 9], + "rotation": 90 }, - { - "from": [ - 7, - 7, - 0 - ], - "to": [ - 9, - 9, - 3 - ], - "shade": false, - "faces": { - "north": { - "texture": "#emitter", - "uv": [ - 6, - 7, - 8, - 9 - ], - "rotation": 270, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "down": { + "texture": "#emitter", + "uv": [9, 7, 10, 9], + "rotation": 270 }, - { - "from": [ - 6, - 7, - -1 - ], - "to": [ - 10, - 9, - 3 - ], - "shade": false, - "faces": { - "up": { - "texture": "#emitter", - "uv": [ - 5, - 6, - 9, - 10 - ], - "rotation": 90, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "down": { - "texture": "#emitter", - "uv": [ - 5, - 6, - 9, - 10 - ], - "rotation": 270, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "east": { + "texture": "#emitter", + "uv": [9, 7, 10, 9], + "rotation": 180 }, - { - "from": [ - 7, - 6, - -1 - ], - "to": [ - 9, - 10, - 3 - ], - "shade": false, - "faces": { - "west": { - "texture": "#emitter", - "uv": [ - 5, - 6, - 9, - 10 - ], - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#emitter", - "uv": [ - 5, - 6, - 9, - 10 - ], - "rotation": 180, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "west": { + "texture": "#emitter", + "uv": [9, 7, 10, 9] } - ] + } + }, + { + "from": [7, 7, 0], + "to": [9, 9, 3], + "shade": false, + "faces": { + "north": { + "texture": "#emitter", + "uv": [6, 7, 8, 9], + "rotation": 270, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [6, 7, -1], + "to": [10, 9, 3], + "shade": false, + "faces": { + "up": { + "texture": "#emitter", + "uv": [5, 6, 9, 10], + "rotation": 90, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "down": { + "texture": "#emitter", + "uv": [5, 6, 9, 10], + "rotation": 270, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [7, 6, -1], + "to": [9, 10, 3], + "shade": false, + "faces": { + "west": { + "texture": "#emitter", + "uv": [5, 6, 9, 10], + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#emitter", + "uv": [5, 6, 9, 10], + "rotation": 180, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_has_channel.json index e6687bb8a..3ae5fcbde 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 7, - 7, - 4 - ], - "to": [ - 9, - 9, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [7, 7, 4], + "to": [9, 9, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_off.json b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_off.json index 4cfcf6719..8dbef85bf 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 7, - 7, - 4 - ], - "to": [ - 9, - 9, - 5 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [7, 7, 4], + "to": [9, 9, 5], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_on.json b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_on.json index 2cde4bd75..a11f5e9ba 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/level_emitter_status_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 7, - 7, - 4 - ], - "to": [ - 9, - 9, - 5 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [7, 7, 4], + "to": [9, 9, 5], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_base.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_base.json index fcd36fd3b..00332badd 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_base.json @@ -1,72 +1,56 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides", - "back": "appliedenergistics2:parts/monitor_back", - "front": "appliedenergistics2:parts/monitor_front", - "particle": "appliedenergistics2:parts/monitor_back" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides", + "back": "appliedenergistics2:parts/monitor_back", + "front": "appliedenergistics2:parts/monitor_front", + "particle": "appliedenergistics2:parts/monitor_back" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 4, - 4, - 2 - ], - "to": [ - 12, - 12, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [4, 4, 2], + "to": [12, 12, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_off.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_off.json index a44a45032..5c6150adc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_off.json @@ -1,25 +1,17 @@ { - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 3 - } - } + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 3 } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_on.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_on.json index fdfb131c0..e4a60712d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_bright_on.json @@ -1,32 +1,24 @@ { - "loader": "appliedenergistics2:uvlightmap", - "ambientocclusion": false, - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "shade": false, - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "ambientocclusion": false, + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "shade": false, + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_off.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_off.json index a1bfdebb6..efba08753 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_off.json @@ -1,25 +1,17 @@ { - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 2 - } - } + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 2 } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_on.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_on.json index e779d1355..9b13ae35b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_dark_on.json @@ -1,30 +1,22 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_off.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_off.json index b9705317a..ee0dbc764 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_off.json @@ -1,25 +1,17 @@ { - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 4 - } - } + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 4 } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_on.json b/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_on.json index 94bc71425..9299113bc 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/monitor_medium_on.json @@ -1,30 +1,22 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lights": "appliedenergistics2:parts/monitor_light" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lights", - "tintindex": 4, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lights": "appliedenergistics2:parts/monitor_light" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lights", + "tintindex": 4, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_base.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_base.json index bfe141b9a..e261e54c9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_base.json @@ -1,964 +1,431 @@ { - "textures": { - "front": "appliedenergistics2:item/part/p2p_tunnel_front", - "sides": "appliedenergistics2:parts/p2p_tunnel_sides", - "back": "appliedenergistics2:item/part/p2p_tunnel_back", - "particle": "appliedenergistics2:item/part/p2p_tunnel_back", - "back2": "appliedenergistics2:item/part/p2p_tunnel_back2" - }, - "elements": [ - { - "from": [ - 4, - 4, - 0 - ], - "to": [ - 12, - 12, - 2 - ], - "faces": { - "north": { - "uv": [ - 4, - 4, - 12, - 12 - ], - "texture": "#type" - } - } - }, - { - "from": [ - 6, - 5, - 3 - ], - "to": [ - 10, - 11, - 4 - ], - "faces": { - "east": { - "uv": [ - 12, - 5, - 13, - 11 - ], - "texture": "#back2" - }, - "south": { - "uv": [ - 6, - 5, - 10, - 11 - ], - "texture": "#back2" - }, - "west": { - "uv": [ - 3, - 5, - 4, - 11 - ], - "texture": "#back2" - }, - "up": { - "uv": [ - 6, - 3, - 10, - 4 - ], - "texture": "#back2" - }, - "down": { - "uv": [ - 6, - 12, - 10, - 13 - ], - "texture": "#back2" - } - } - }, - { - "from": [ - 5, - 6, - 3 - ], - "to": [ - 6, - 10, - 4 - ], - "faces": { - "east": { - "uv": [ - 12, - 6, - 13, - 10 - ], - "texture": "#back2" - }, - "south": { - "uv": [ - 5, - 6, - 6, - 10 - ], - "texture": "#back2" - }, - "west": { - "uv": [ - 3, - 6, - 4, - 10 - ], - "texture": "#back2" - }, - "up": { - "uv": [ - 5, - 3, - 6, - 4 - ], - "texture": "#back2" - }, - "down": { - "uv": [ - 5, - 12, - 6, - 13 - ], - "texture": "#back2" - } - } - }, - { - "from": [ - 10, - 6, - 3 - ], - "to": [ - 11, - 10, - 4 - ], - "faces": { - "east": { - "uv": [ - 12, - 6, - 13, - 10 - ], - "texture": "#back2" - }, - "south": { - "uv": [ - 10, - 6, - 11, - 10 - ], - "texture": "#back2" - }, - "west": { - "uv": [ - 3, - 6, - 4, - 10 - ], - "texture": "#back2" - }, - "up": { - "uv": [ - 10, - 3, - 11, - 4 - ], - "texture": "#back2" - }, - "down": { - "uv": [ - 10, - 12, - 11, - 13 - ], - "texture": "#back2" - } - } - }, - { - "from": [ - 6, - 4, - 2 - ], - "to": [ - 10, - 6, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 10, - 14, - 12 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 6, - 10, - 10, - 12 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 10, - 3, - 12 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 6, - 2, - 10, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 6, - 13, - 10, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 4, - 6, - 2 - ], - "to": [ - 12, - 10, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 6, - 14, - 10 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 4, - 6, - 12, - 10 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 6, - 3, - 10 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 4, - 2, - 12, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 4, - 13, - 12, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 6, - 10, - 2 - ], - "to": [ - 10, - 12, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 4, - 14, - 6 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 6, - 4, - 10, - 6 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 4, - 3, - 6 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 6, - 2, - 10, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 6, - 13, - 10, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 3, - 12, - 2 - ], - "to": [ - 13, - 13, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 3, - 14, - 4 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 3, - 3, - 13, - 4 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 3, - 3, - 4 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 3, - 2, - 13, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 3, - 13, - 13, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 12, - 4, - 2 - ], - "to": [ - 13, - 12, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 4, - 14, - 12 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 12, - 4, - 13, - 12 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 4, - 3, - 12 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 12, - 2, - 13, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 12, - 13, - 13, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 3, - 4, - 2 - ], - "to": [ - 4, - 12, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 4, - 14, - 12 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 3, - 4, - 4, - 12 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 4, - 3, - 12 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 3, - 2, - 4, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 3, - 13, - 4, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 3, - 3, - 2 - ], - "to": [ - 13, - 4, - 3 - ], - "faces": { - "east": { - "uv": [ - 13, - 12, - 14, - 13 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 3, - 12, - 13, - 13 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 2, - 12, - 3, - 13 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 3, - 2, - 13, - 3 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 3, - 13, - 13, - 14 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 2, - 2, - 1 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "uv": [ - 2, - 2, - 14, - 14 - ], - "texture": "#front" - }, - "east": { - "uv": [ - 14, - 2, - 15, - 14 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 2, - 2, - 14, - 14 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 1, - 2, - 2, - 14 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 2, - 1, - 14, - 2 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 2, - 14, - 14, - 15 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 2, - 12, - 0 - ], - "to": [ - 14, - 14, - 1 - ], - "faces": { - "north": { - "uv": [ - 2, - 2, - 14, - 4 - ], - "texture": "#front" - }, - "east": { - "uv": [ - 15, - 2, - 16, - 4 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 2, - 2, - 14, - 4 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 0, - 2, - 1, - 4 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 2, - 0, - 14, - 1 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 2, - 15, - 14, - 16 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 4, - 1 - ], - "faces": { - "north": { - "uv": [ - 2, - 12, - 14, - 14 - ], - "texture": "#front" - }, - "east": { - "uv": [ - 15, - 12, - 16, - 14 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 2, - 12, - 14, - 14 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 0, - 12, - 1, - 14 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 2, - 0, - 14, - 1 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 2, - 15, - 14, - 16 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 12, - 4, - 0 - ], - "to": [ - 14, - 12, - 1 - ], - "faces": { - "north": { - "uv": [ - 2, - 4, - 4, - 12 - ], - "texture": "#front" - }, - "east": { - "uv": [ - 15, - 4, - 16, - 12 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 12, - 4, - 14, - 12 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 0, - 4, - 1, - 12 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 12, - 0, - 14, - 1 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 12, - 15, - 14, - 16 - ], - "texture": "#sides" - } - } - }, - { - "from": [ - 2, - 4, - 0 - ], - "to": [ - 4, - 12, - 1 - ], - "faces": { - "north": { - "uv": [ - 12, - 4, - 14, - 12 - ], - "texture": "#front" - }, - "east": { - "uv": [ - 15, - 4, - 16, - 12 - ], - "texture": "#sides" - }, - "south": { - "uv": [ - 2, - 4, - 4, - 12 - ], - "texture": "#back" - }, - "west": { - "uv": [ - 0, - 4, - 1, - 12 - ], - "texture": "#sides" - }, - "up": { - "uv": [ - 2, - 0, - 4, - 1 - ], - "texture": "#sides" - }, - "down": { - "uv": [ - 2, - 15, - 4, - 16 - ], - "texture": "#sides" - } - } + "textures": { + "front": "appliedenergistics2:item/part/p2p_tunnel_front", + "sides": "appliedenergistics2:parts/p2p_tunnel_sides", + "back": "appliedenergistics2:item/part/p2p_tunnel_back", + "particle": "appliedenergistics2:item/part/p2p_tunnel_back", + "back2": "appliedenergistics2:item/part/p2p_tunnel_back2" + }, + "elements": [ + { + "from": [4, 4, 0], + "to": [12, 12, 2], + "faces": { + "north": { + "uv": [4, 4, 12, 12], + "texture": "#type" } - ] -} \ No newline at end of file + } + }, + { + "from": [6, 5, 3], + "to": [10, 11, 4], + "faces": { + "east": { + "uv": [12, 5, 13, 11], + "texture": "#back2" + }, + "south": { + "uv": [6, 5, 10, 11], + "texture": "#back2" + }, + "west": { + "uv": [3, 5, 4, 11], + "texture": "#back2" + }, + "up": { + "uv": [6, 3, 10, 4], + "texture": "#back2" + }, + "down": { + "uv": [6, 12, 10, 13], + "texture": "#back2" + } + } + }, + { + "from": [5, 6, 3], + "to": [6, 10, 4], + "faces": { + "east": { + "uv": [12, 6, 13, 10], + "texture": "#back2" + }, + "south": { + "uv": [5, 6, 6, 10], + "texture": "#back2" + }, + "west": { + "uv": [3, 6, 4, 10], + "texture": "#back2" + }, + "up": { + "uv": [5, 3, 6, 4], + "texture": "#back2" + }, + "down": { + "uv": [5, 12, 6, 13], + "texture": "#back2" + } + } + }, + { + "from": [10, 6, 3], + "to": [11, 10, 4], + "faces": { + "east": { + "uv": [12, 6, 13, 10], + "texture": "#back2" + }, + "south": { + "uv": [10, 6, 11, 10], + "texture": "#back2" + }, + "west": { + "uv": [3, 6, 4, 10], + "texture": "#back2" + }, + "up": { + "uv": [10, 3, 11, 4], + "texture": "#back2" + }, + "down": { + "uv": [10, 12, 11, 13], + "texture": "#back2" + } + } + }, + { + "from": [6, 4, 2], + "to": [10, 6, 3], + "faces": { + "east": { + "uv": [13, 10, 14, 12], + "texture": "#sides" + }, + "south": { + "uv": [6, 10, 10, 12], + "texture": "#back" + }, + "west": { + "uv": [2, 10, 3, 12], + "texture": "#sides" + }, + "up": { + "uv": [6, 2, 10, 3], + "texture": "#sides" + }, + "down": { + "uv": [6, 13, 10, 14], + "texture": "#sides" + } + } + }, + { + "from": [4, 6, 2], + "to": [12, 10, 3], + "faces": { + "east": { + "uv": [13, 6, 14, 10], + "texture": "#sides" + }, + "south": { + "uv": [4, 6, 12, 10], + "texture": "#back" + }, + "west": { + "uv": [2, 6, 3, 10], + "texture": "#sides" + }, + "up": { + "uv": [4, 2, 12, 3], + "texture": "#sides" + }, + "down": { + "uv": [4, 13, 12, 14], + "texture": "#sides" + } + } + }, + { + "from": [6, 10, 2], + "to": [10, 12, 3], + "faces": { + "east": { + "uv": [13, 4, 14, 6], + "texture": "#sides" + }, + "south": { + "uv": [6, 4, 10, 6], + "texture": "#back" + }, + "west": { + "uv": [2, 4, 3, 6], + "texture": "#sides" + }, + "up": { + "uv": [6, 2, 10, 3], + "texture": "#sides" + }, + "down": { + "uv": [6, 13, 10, 14], + "texture": "#sides" + } + } + }, + { + "from": [3, 12, 2], + "to": [13, 13, 3], + "faces": { + "east": { + "uv": [13, 3, 14, 4], + "texture": "#sides" + }, + "south": { + "uv": [3, 3, 13, 4], + "texture": "#back" + }, + "west": { + "uv": [2, 3, 3, 4], + "texture": "#sides" + }, + "up": { + "uv": [3, 2, 13, 3], + "texture": "#sides" + }, + "down": { + "uv": [3, 13, 13, 14], + "texture": "#sides" + } + } + }, + { + "from": [12, 4, 2], + "to": [13, 12, 3], + "faces": { + "east": { + "uv": [13, 4, 14, 12], + "texture": "#sides" + }, + "south": { + "uv": [12, 4, 13, 12], + "texture": "#back" + }, + "west": { + "uv": [2, 4, 3, 12], + "texture": "#sides" + }, + "up": { + "uv": [12, 2, 13, 3], + "texture": "#sides" + }, + "down": { + "uv": [12, 13, 13, 14], + "texture": "#sides" + } + } + }, + { + "from": [3, 4, 2], + "to": [4, 12, 3], + "faces": { + "east": { + "uv": [13, 4, 14, 12], + "texture": "#sides" + }, + "south": { + "uv": [3, 4, 4, 12], + "texture": "#back" + }, + "west": { + "uv": [2, 4, 3, 12], + "texture": "#sides" + }, + "up": { + "uv": [3, 2, 4, 3], + "texture": "#sides" + }, + "down": { + "uv": [3, 13, 4, 14], + "texture": "#sides" + } + } + }, + { + "from": [3, 3, 2], + "to": [13, 4, 3], + "faces": { + "east": { + "uv": [13, 12, 14, 13], + "texture": "#sides" + }, + "south": { + "uv": [3, 12, 13, 13], + "texture": "#back" + }, + "west": { + "uv": [2, 12, 3, 13], + "texture": "#sides" + }, + "up": { + "uv": [3, 2, 13, 3], + "texture": "#sides" + }, + "down": { + "uv": [3, 13, 13, 14], + "texture": "#sides" + } + } + }, + { + "from": [2, 2, 1], + "to": [14, 14, 2], + "faces": { + "north": { + "uv": [2, 2, 14, 14], + "texture": "#front" + }, + "east": { + "uv": [14, 2, 15, 14], + "texture": "#sides" + }, + "south": { + "uv": [2, 2, 14, 14], + "texture": "#back" + }, + "west": { + "uv": [1, 2, 2, 14], + "texture": "#sides" + }, + "up": { + "uv": [2, 1, 14, 2], + "texture": "#sides" + }, + "down": { + "uv": [2, 14, 14, 15], + "texture": "#sides" + } + } + }, + { + "from": [2, 12, 0], + "to": [14, 14, 1], + "faces": { + "north": { + "uv": [2, 2, 14, 4], + "texture": "#front" + }, + "east": { + "uv": [15, 2, 16, 4], + "texture": "#sides" + }, + "south": { + "uv": [2, 2, 14, 4], + "texture": "#back" + }, + "west": { + "uv": [0, 2, 1, 4], + "texture": "#sides" + }, + "up": { + "uv": [2, 0, 14, 1], + "texture": "#sides" + }, + "down": { + "uv": [2, 15, 14, 16], + "texture": "#sides" + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 4, 1], + "faces": { + "north": { + "uv": [2, 12, 14, 14], + "texture": "#front" + }, + "east": { + "uv": [15, 12, 16, 14], + "texture": "#sides" + }, + "south": { + "uv": [2, 12, 14, 14], + "texture": "#back" + }, + "west": { + "uv": [0, 12, 1, 14], + "texture": "#sides" + }, + "up": { + "uv": [2, 0, 14, 1], + "texture": "#sides" + }, + "down": { + "uv": [2, 15, 14, 16], + "texture": "#sides" + } + } + }, + { + "from": [12, 4, 0], + "to": [14, 12, 1], + "faces": { + "north": { + "uv": [2, 4, 4, 12], + "texture": "#front" + }, + "east": { + "uv": [15, 4, 16, 12], + "texture": "#sides" + }, + "south": { + "uv": [12, 4, 14, 12], + "texture": "#back" + }, + "west": { + "uv": [0, 4, 1, 12], + "texture": "#sides" + }, + "up": { + "uv": [12, 0, 14, 1], + "texture": "#sides" + }, + "down": { + "uv": [12, 15, 14, 16], + "texture": "#sides" + } + } + }, + { + "from": [2, 4, 0], + "to": [4, 12, 1], + "faces": { + "north": { + "uv": [12, 4, 14, 12], + "texture": "#front" + }, + "east": { + "uv": [15, 4, 16, 12], + "texture": "#sides" + }, + "south": { + "uv": [2, 4, 4, 12], + "texture": "#back" + }, + "west": { + "uv": [0, 4, 1, 12], + "texture": "#sides" + }, + "up": { + "uv": [2, 0, 4, 1], + "texture": "#sides" + }, + "down": { + "uv": [2, 15, 4, 16], + "texture": "#sides" + } + } + } + ] +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fe.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fe.json index bfcfe8af7..2841530d3 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fe.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fe.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "block/gold_block" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "block/gold_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fluids.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fluids.json index f13d0e563..893ed0e1a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fluids.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_fluids.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "block/lapis_block" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "block/lapis_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_frequency.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_frequency.json index 8dd0de3aa..bee9bcd3b 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_frequency.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_frequency.json @@ -1,3 +1,3 @@ { "loader": "appliedenergistics2:p2p_tunnel_frequency" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_ic2.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_ic2.json index 56df8c132..0af9aabef 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_ic2.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_ic2.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "minecraft:block/diamond_block" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "minecraft:block/diamond_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_items.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_items.json index 9018c143e..3caf28842 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_items.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_items.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "block/hopper_outside" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "block/hopper_outside" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_light.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_light.json index 8c94fc815..b91fcf507 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_light.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_light.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "block/quartz_block_top" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "block/quartz_block_top" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_me.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_me.json index 041e852db..dff9e4997 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_me.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_me.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "appliedenergistics2:block/quartz_block" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "appliedenergistics2:block/quartz_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_redstone.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_redstone.json index 58d03613d..81f1e82ff 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_redstone.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_redstone.json @@ -1,6 +1,6 @@ { - "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", - "textures": { - "type": "block/redstone_block" - } + "parent": "appliedenergistics2:part/p2p/p2p_tunnel_base", + "textures": { + "type": "block/redstone_block" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_has_channel.json index 843ebb8ca..c574b96ec 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 6, - 3 - ], - "to": [ - 11, - 10, - 4 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 6, 3], + "to": [11, 10, 4], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_off.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_off.json index 3213fd16b..fd2ec71ce 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 6, - 3 - ], - "to": [ - 11, - 10, - 4 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 6, 3], + "to": [11, 10, 4], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_on.json b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_on.json index f34d38cb5..9edb3c078 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/p2p/p2p_tunnel_status_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 6, - 3 - ], - "to": [ - 11, - 10, - 4 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 6, 3], + "to": [11, 10, 4], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_off.json index 4790909f8..da163ab14 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/pattern_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/pattern_terminal_medium", - "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/pattern_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/pattern_terminal_medium", + "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_on.json index 471805e59..24d4cb34d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/pattern_terminal_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/pattern_terminal_bright", - "lightsMedium": "appliedenergistics2:parts/pattern_terminal_medium", - "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/pattern_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/pattern_terminal_medium", + "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/quartz_fiber.json b/src/main/resources/assets/appliedenergistics2/models/part/quartz_fiber.json index 44774984f..9c6f53c12 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/quartz_fiber.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/quartz_fiber.json @@ -1,40 +1,32 @@ { - "textures": { - "fiber": "appliedenergistics2:item/part/quartz_fiber", - "particle": "appliedenergistics2:item/part/quartz_fiber" - }, - "elements": [ - { - "from": [ - 6, - 6, - 0 - ], - "to": [ - 10, - 10, - 6 - ], - "faces": { - "down": { - "texture": "#fiber" - }, - "up": { - "texture": "#fiber" - }, - "south": { - "texture": "#fiber" - }, - "east": { - "texture": "#fiber" - }, - "north": { - "texture": "#fiber" - }, - "west": { - "texture": "#fiber" - } - } + "textures": { + "fiber": "appliedenergistics2:item/part/quartz_fiber", + "particle": "appliedenergistics2:item/part/quartz_fiber" + }, + "elements": [ + { + "from": [6, 6, 0], + "to": [10, 10, 6], + "faces": { + "down": { + "texture": "#fiber" + }, + "up": { + "texture": "#fiber" + }, + "south": { + "texture": "#fiber" + }, + "east": { + "texture": "#fiber" + }, + "north": { + "texture": "#fiber" + }, + "west": { + "texture": "#fiber" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_base.json index ebc6e0809..e9b909551 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_base.json @@ -1,130 +1,98 @@ { - "textures": { - "sides": "appliedenergistics2:parts/storage_bus_sides", - "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/storage_bus_back", - "front": "appliedenergistics2:item/part/storage_bus", - "particle": "appliedenergistics2:parts/storage_bus_back" - }, - "elements": [ - { - "from": [ - 3, - 3, - 0 - ], - "to": [ - 13, - 13, - 1 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/storage_bus_sides", + "sidesStatus": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/storage_bus_back", + "front": "appliedenergistics2:item/part/storage_bus", + "particle": "appliedenergistics2:parts/storage_bus_back" + }, + "elements": [ + { + "from": [3, 3, 0], + "to": [13, 13, 1], + "faces": { + "down": { + "texture": "#sides" }, - { - "from": [ - 2, - 2, - 1 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "north": { - "texture": "#front" - }, - "west": { - "texture": "#sides" - } - } + "up": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 3 - ], - "to": [ - 11, - 11, - 4 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "south": { + "texture": "#back" }, - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" } - ] + } + }, + { + "from": [2, 2, 1], + "to": [14, 14, 2], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "north": { + "texture": "#front" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 3], + "to": [11, 11, 4], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "south": { + "texture": "#back" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + }, + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_has_channel.json index a9cdf5044..e675a71e5 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_off.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_off.json index 3ab8507fa..2707327cb 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_on.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_on.json index fddbe6753..f78e58241 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_bus_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 5, - 5, - 2 - ], - "to": [ - 11, - 11, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [5, 5, 2], + "to": [11, 11, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_off.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_off.json index beb240917..1f3d86f35 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", - "lightsDark": "appliedenergistics2:parts/storage_monitor_dark_locked" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", + "lightsDark": "appliedenergistics2:parts/storage_monitor_dark_locked" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_on.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_on.json index 33b9156b8..a67875163 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_locked_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", - "lightsDark": "appliedenergistics2:parts/storage_monitor_dark_locked" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", + "lightsDark": "appliedenergistics2:parts/storage_monitor_dark_locked" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_off.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_off.json index 128fa2001..7d0943896 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", - "lightsDark": "appliedenergistics2:parts/storage_monitor_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", + "lightsDark": "appliedenergistics2:parts/storage_monitor_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_on.json b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_on.json index 4d34b44b1..59106c724 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/storage_monitor_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", - "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", - "lightsDark": "appliedenergistics2:parts/storage_monitor_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/storage_monitor_bright", + "lightsMedium": "appliedenergistics2:parts/storage_monitor_medium", + "lightsDark": "appliedenergistics2:parts/storage_monitor_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/terminal_off.json index eba1d49a3..1ef4fa66d 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/terminal_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/terminal_off.json @@ -1,8 +1,8 @@ { - "parent": "appliedenergistics2:part/display_off", - "textures": { - "lightsBright": "appliedenergistics2:parts/terminal_bright", - "lightsMedium": "appliedenergistics2:parts/terminal_medium", - "lightsDark": "appliedenergistics2:parts/terminal_dark" - } + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/terminal_bright", + "lightsMedium": "appliedenergistics2:parts/terminal_medium", + "lightsDark": "appliedenergistics2:parts/terminal_dark" + } } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/terminal_on.json index 2bc6f135c..a532eba26 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/terminal_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/terminal_on.json @@ -1,76 +1,52 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "lightsBright": "appliedenergistics2:parts/terminal_bright", - "lightsMedium": "appliedenergistics2:parts/terminal_medium", - "lightsDark": "appliedenergistics2:parts/terminal_dark" - }, - "elements": [ - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsBright", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsMedium", - "tintindex": 2, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } - }, - { - "from": [ - 2, - 2, - 0 - ], - "to": [ - 14, - 14, - 2 - ], - "faces": { - "north": { - "texture": "#lightsDark", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "lightsBright": "appliedenergistics2:parts/terminal_bright", + "lightsMedium": "appliedenergistics2:parts/terminal_medium", + "lightsDark": "appliedenergistics2:parts/terminal_dark" + }, + "elements": [ + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [2, 2, 0], + "to": [14, 14, 2], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_base.json b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_base.json index 25eed1def..4d6be7780 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_base.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_base.json @@ -1,93 +1,69 @@ { - "textures": { - "bus": "appliedenergistics2:item/part/toggle_bus", - "sides": "appliedenergistics2:parts/monitor_sides_status", - "particle": "appliedenergistics2:item/part/toggle_bus" - }, - "elements": [ - { - "from": [ - 6, - 6, - 0 - ], - "to": [ - 10, - 10, - 2 - ], - "faces": { - "down": { - "texture": "#bus" - }, - "up": { - "texture": "#bus" - }, - "east": { - "texture": "#bus" - }, - "north": { - "texture": "#bus" - }, - "west": { - "texture": "#bus" - } - } + "textures": { + "bus": "appliedenergistics2:item/part/toggle_bus", + "sides": "appliedenergistics2:parts/monitor_sides_status", + "particle": "appliedenergistics2:item/part/toggle_bus" + }, + "elements": [ + { + "from": [6, 6, 0], + "to": [10, 10, 2], + "faces": { + "down": { + "texture": "#bus" }, - { - "from": [ - 6, - 6, - 3 - ], - "to": [ - 10, - 10, - 5 - ], - "faces": { - "down": { - "texture": "#bus" - }, - "up": { - "texture": "#bus" - }, - "south": { - "texture": "#bus" - }, - "east": { - "texture": "#bus" - }, - "west": { - "texture": "#bus" - } - } + "up": { + "texture": "#bus" }, - { - "from": [ - 6, - 6, - 2 - ], - "to": [ - 10, - 10, - 3 - ], - "faces": { - "down": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "east": { - "texture": "#sides" - }, - "west": { - "texture": "#sides" - } - } + "east": { + "texture": "#bus" + }, + "north": { + "texture": "#bus" + }, + "west": { + "texture": "#bus" } - ] + } + }, + { + "from": [6, 6, 3], + "to": [10, 10, 5], + "faces": { + "down": { + "texture": "#bus" + }, + "up": { + "texture": "#bus" + }, + "south": { + "texture": "#bus" + }, + "east": { + "texture": "#bus" + }, + "west": { + "texture": "#bus" + } + } + }, + { + "from": [6, 6, 2], + "to": [10, 10, 3], + "faces": { + "down": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "east": { + "texture": "#sides" + }, + "west": { + "texture": "#sides" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_has_channel.json index bbff56e65..6cf383ca7 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_has_channel.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 2 - ], - "to": [ - 10, - 10, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 2], + "to": [10, 10, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_off.json b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_off.json index 2c708d689..9ca804fef 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_off.json @@ -1,33 +1,25 @@ { - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_off" - }, - "elements": [ - { - "from": [ - 6, - 6, - 2 - ], - "to": [ - 10, - 10, - 3 - ], - "faces": { - "down": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - } - } + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_off" + }, + "elements": [ + { + "from": [6, 6, 2], + "to": [10, 10, 3], + "faces": { + "down": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_on.json b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_on.json index 537cadbb1..f8ebdacfe 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/toggle_bus_status_on.json @@ -1,54 +1,46 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "indicator": "appliedenergistics2:parts/monitor_sides_status_on" - }, - "elements": [ - { - "from": [ - 6, - 6, - 2 - ], - "to": [ - 10, - 10, - 3 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "indicator": "appliedenergistics2:parts/monitor_sides_status_on" + }, + "elements": [ + { + "from": [6, 6, 2], + "to": [10, 10, 3], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } } - ] + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_has_channel.json b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_has_channel.json index d4c7f7b20..7453fa56a 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_has_channel.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_has_channel.json @@ -1,85 +1,69 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/transition_plane_back", - "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" - }, - "elements": [ - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/transition_plane_back", + "indicator": "appliedenergistics2:parts/monitor_sides_status_has_channel" + }, + "elements": [ + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "east": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 1, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "south": { + "texture": "#back" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_off.json b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_off.json index 9be5470f4..e577e56ef 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_off.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_off.json @@ -1,65 +1,49 @@ { - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/transition_plane_back", - "indicator": "appliedenergistics2:parts/monitor_sides_status_off", - "particle": "appliedenergistics2:parts/transition_plane_back" - }, - "elements": [ - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/transition_plane_back", + "indicator": "appliedenergistics2:parts/monitor_sides_status_off", + "particle": "appliedenergistics2:parts/transition_plane_back" + }, + "elements": [ + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "east": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "east": { - "texture": "#indicator" - }, - "west": { - "texture": "#indicator" - }, - "up": { - "texture": "#indicator" - }, - "down": { - "texture": "#indicator" - } - } + "south": { + "texture": "#back" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "east": { + "texture": "#indicator" + }, + "west": { + "texture": "#indicator" + }, + "up": { + "texture": "#indicator" + }, + "down": { + "texture": "#indicator" + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_on.json b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_on.json index 660998ec0..83a63f305 100644 --- a/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_on.json +++ b/src/main/resources/assets/appliedenergistics2/models/part/transition_plane_on.json @@ -1,86 +1,70 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "sides": "appliedenergistics2:parts/monitor_sides_status", - "back": "appliedenergistics2:parts/transition_plane_back", - "indicator": "appliedenergistics2:parts/monitor_sides_status_on", - "particle": "appliedenergistics2:parts/transition_plane_back" - }, - "elements": [ - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "east": { - "texture": "#sides" - }, - "south": { - "texture": "#back" - }, - "west": { - "texture": "#sides" - }, - "up": { - "texture": "#sides" - }, - "down": { - "texture": "#sides" - } - } + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "sides": "appliedenergistics2:parts/monitor_sides_status", + "back": "appliedenergistics2:parts/transition_plane_back", + "indicator": "appliedenergistics2:parts/monitor_sides_status_on", + "particle": "appliedenergistics2:parts/transition_plane_back" + }, + "elements": [ + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "east": { + "texture": "#sides" }, - { - "from": [ - 5, - 5, - 1 - ], - "to": [ - 11, - 11, - 2 - ], - "faces": { - "down": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "up": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "east": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - }, - "west": { - "texture": "#indicator", - "tintindex": 3, - "uvlightmap": { - "sky": 0.007, - "block": 0.007 - } - } - } + "south": { + "texture": "#back" + }, + "west": { + "texture": "#sides" + }, + "up": { + "texture": "#sides" + }, + "down": { + "texture": "#sides" } - ] + } + }, + { + "from": [5, 5, 1], + "to": [11, 11, 2], + "faces": { + "down": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "up": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "east": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + }, + "west": { + "texture": "#indicator", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] } diff --git a/src/main/resources/assets/appliedenergistics2/particles/assembler_fx.json b/src/main/resources/assets/appliedenergistics2/particles/assembler_fx.json index 7a73a41bf..0967ef424 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/assembler_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/assembler_fx.json @@ -1,2 +1 @@ -{ -} \ No newline at end of file +{} diff --git a/src/main/resources/assets/appliedenergistics2/particles/charged_ore_fx.json b/src/main/resources/assets/appliedenergistics2/particles/charged_ore_fx.json index 271261099..e0996e04f 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/charged_ore_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/charged_ore_fx.json @@ -9,4 +9,4 @@ "minecraft:generic_1", "minecraft:generic_0" ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/appliedenergistics2/particles/crafting_fx.json b/src/main/resources/assets/appliedenergistics2/particles/crafting_fx.json index ad2e7618c..26dbb39df 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/crafting_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/crafting_fx.json @@ -1,5 +1,3 @@ { - "textures": [ - "appliedenergistics2:particles/energy" - ] -} \ No newline at end of file + "textures": ["appliedenergistics2:particles/energy"] +} diff --git a/src/main/resources/assets/appliedenergistics2/particles/lightning_arc_fx.json b/src/main/resources/assets/appliedenergistics2/particles/lightning_arc_fx.json index ca698ca44..7d0f2ce24 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/lightning_arc_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/lightning_arc_fx.json @@ -1,5 +1,3 @@ { - "textures": [ - "minecraft:generic_0" - ] -} \ No newline at end of file + "textures": ["minecraft:generic_0"] +} diff --git a/src/main/resources/assets/appliedenergistics2/particles/lightning_fx.json b/src/main/resources/assets/appliedenergistics2/particles/lightning_fx.json index ca698ca44..7d0f2ce24 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/lightning_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/lightning_fx.json @@ -1,5 +1,3 @@ { - "textures": [ - "minecraft:generic_0" - ] -} \ No newline at end of file + "textures": ["minecraft:generic_0"] +} diff --git a/src/main/resources/assets/appliedenergistics2/particles/matter_cannon_fx.json b/src/main/resources/assets/appliedenergistics2/particles/matter_cannon_fx.json index 338b997f9..f0a4e5277 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/matter_cannon_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/matter_cannon_fx.json @@ -1,5 +1,3 @@ { - "textures": [ - "appliedenergistics2:particles/matter_cannon" - ] -} \ No newline at end of file + "textures": ["appliedenergistics2:particles/matter_cannon"] +} diff --git a/src/main/resources/assets/appliedenergistics2/particles/vibrant_fx.json b/src/main/resources/assets/appliedenergistics2/particles/vibrant_fx.json index ca698ca44..7d0f2ce24 100644 --- a/src/main/resources/assets/appliedenergistics2/particles/vibrant_fx.json +++ b/src/main/resources/assets/appliedenergistics2/particles/vibrant_fx.json @@ -1,5 +1,3 @@ { - "textures": [ - "minecraft:generic_0" - ] -} \ No newline at end of file + "textures": ["minecraft:generic_0"] +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/charged_quartz.json b/src/main/resources/data/appliedenergistics2/advancements/main/charged_quartz.json index 879061635..c278cbddc 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/charged_quartz.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/charged_quartz.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/charger.json b/src/main/resources/data/appliedenergistics2/advancements/main/charger.json index 3cc527a64..604bbbd40 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/charger.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/charger.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/compass.json b/src/main/resources/data/appliedenergistics2/advancements/main/compass.json index e4c133113..72712abb2 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/compass.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/compass.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/controller.json b/src/main/resources/data/appliedenergistics2/advancements/main/controller.json index a956f3f7c..b03137d38 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/controller.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/controller.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/crafting_cpu.json b/src/main/resources/data/appliedenergistics2/advancements/main/crafting_cpu.json index 68508a299..f3f10e1f5 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/crafting_cpu.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/crafting_cpu.json @@ -53,12 +53,5 @@ } } }, - "requirements": [ - [ - "c1k", - "c4k", - "c16k", - "c64k" - ] - ] -} \ No newline at end of file + "requirements": [["c1k", "c4k", "c16k", "c64k"]] +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/crafting_terminal.json b/src/main/resources/data/appliedenergistics2/advancements/main/crafting_terminal.json index 686547fae..1cd1f7d7c 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/crafting_terminal.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/crafting_terminal.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/facade.json b/src/main/resources/data/appliedenergistics2/advancements/main/facade.json index 96e625c9f..d47b45694 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/facade.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/facade.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/fluix.json b/src/main/resources/data/appliedenergistics2/advancements/main/fluix.json index b6e02cdc5..5380cd9de 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/fluix.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/fluix.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/glass_cable.json b/src/main/resources/data/appliedenergistics2/advancements/main/glass_cable.json index da8bd9ccf..a9893b39c 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/glass_cable.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/glass_cable.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/growth_accelerator.json b/src/main/resources/data/appliedenergistics2/advancements/main/growth_accelerator.json index af3680ba9..3a1380b6e 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/growth_accelerator.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/growth_accelerator.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/interface.json b/src/main/resources/data/appliedenergistics2/advancements/main/interface.json index a267e3623..0981681d2 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/interface.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/interface.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/ioport.json b/src/main/resources/data/appliedenergistics2/advancements/main/ioport.json index 9e82d2cc7..ed8a71d79 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/ioport.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/ioport.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/network1.json b/src/main/resources/data/appliedenergistics2/advancements/main/network1.json index 6c4fe13b0..d57a39ef4 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/network1.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/network1.json @@ -16,4 +16,4 @@ "trigger": "appliedenergistics2:network_apprentice" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/network2.json b/src/main/resources/data/appliedenergistics2/advancements/main/network2.json index 0ac5564ca..85c394b27 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/network2.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/network2.json @@ -16,4 +16,4 @@ "trigger": "appliedenergistics2:network_engineer" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/network3.json b/src/main/resources/data/appliedenergistics2/advancements/main/network3.json index 62c9721b8..eae211921 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/network3.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/network3.json @@ -16,4 +16,4 @@ "trigger": "appliedenergistics2:network_admin" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/network_tool.json b/src/main/resources/data/appliedenergistics2/advancements/main/network_tool.json index 83927d874..7063429bb 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/network_tool.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/network_tool.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/p2p.json b/src/main/resources/data/appliedenergistics2/advancements/main/p2p.json index 55df1d070..7415e9f9e 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/p2p.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/p2p.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/pattern_terminal.json b/src/main/resources/data/appliedenergistics2/advancements/main/pattern_terminal.json index 159f5adee..f1d1d9de3 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/pattern_terminal.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/pattern_terminal.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/portable_cell.json b/src/main/resources/data/appliedenergistics2/advancements/main/portable_cell.json index da5943df0..27e3f4729 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/portable_cell.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/portable_cell.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/presses.json b/src/main/resources/data/appliedenergistics2/advancements/main/presses.json index a0c6bec51..41118d1b8 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/presses.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/presses.json @@ -53,12 +53,5 @@ } } }, - "requirements": [ - [ - "calc", - "eng", - "logic", - "silicon" - ] - ] -} \ No newline at end of file + "requirements": [["calc", "eng", "logic", "silicon"]] +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/qnb.json b/src/main/resources/data/appliedenergistics2/advancements/main/qnb.json index 0ae0e5493..8419b8920 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/qnb.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/qnb.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/root.json b/src/main/resources/data/appliedenergistics2/advancements/main/root.json index dfe366e89..d9da62b75 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/root.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/root.json @@ -25,4 +25,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/spatial_explorer.json b/src/main/resources/data/appliedenergistics2/advancements/main/spatial_explorer.json index b7dbeea90..2d9e0f27c 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/spatial_explorer.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/spatial_explorer.json @@ -16,4 +16,4 @@ "trigger": "appliedenergistics2:spatial_explorer" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/spatial_ioport.json b/src/main/resources/data/appliedenergistics2/advancements/main/spatial_ioport.json index 02f474d91..4efa118e5 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/spatial_ioport.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/spatial_ioport.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/storage_bus.json b/src/main/resources/data/appliedenergistics2/advancements/main/storage_bus.json index b114ce407..36bfe0ae0 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/storage_bus.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/storage_bus.json @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/advancements/main/storage_cell.json b/src/main/resources/data/appliedenergistics2/advancements/main/storage_cell.json index 12159526b..efab236b8 100644 --- a/src/main/resources/data/appliedenergistics2/advancements/main/storage_cell.json +++ b/src/main/resources/data/appliedenergistics2/advancements/main/storage_cell.json @@ -53,12 +53,5 @@ } } }, - "requirements": [ - [ - "c1k", - "c4k", - "c16k", - "c64k" - ] - ] -} \ No newline at end of file + "requirements": [["c1k", "c4k", "c16k", "c64k"]] +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/_factories.json b/src/main/resources/data/appliedenergistics2/recipes/_factories.json index 5f8190ca8..aad0aafa6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/_factories.json +++ b/src/main/resources/data/appliedenergistics2/recipes/_factories.json @@ -1,13 +1,13 @@ { - "conditions": { - "material_exists": "appeng.recipes.factories.conditions.MaterialExists", - "features": "appeng.recipes.factories.conditions.Features" - }, - "ingredients": { - "part": "appeng.recipes.factories.ingredients.PartIngredientFactory" - }, - "recipes": { - "part_shaped": "appeng.recipes.factories.recipes.PartRecipeFactory", - "part_shapeless": "appeng.recipes.factories.recipes.PartRecipeFactory" - } + "conditions": { + "material_exists": "appeng.recipes.factories.conditions.MaterialExists", + "features": "appeng.recipes.factories.conditions.Features" + }, + "ingredients": { + "part": "appeng.recipes.factories.ingredients.PartIngredientFactory" + }, + "recipes": { + "part_shaped": "appeng.recipes.factories.recipes.PartRecipeFactory", + "part_shapeless": "appeng.recipes.factories.recipes.PartRecipeFactory" + } } diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block.json index 3b384bdc5..c3f0096a2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block.json @@ -3,13 +3,10 @@ "item": "appliedenergistics2:quartz_block" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - "aa" - ], + "pattern": ["aa", "aa"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block_pure.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block_pure.json index 2f0fbd8dc..484bcc5a9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block_pure.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_block_pure.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:quartz_block" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "a a", - "aaa" - ], + "pattern": ["aaa", "a a", "aaa"], "key": { "a": { "item": "appliedenergistics2:purified_certus_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_pillar.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_pillar.json index fdc7d40d3..f55c55322 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_pillar.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/certus_quartz_pillar.json @@ -4,13 +4,10 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "a" - ], + "pattern": ["a", "a"], "key": { "a": { "item": "appliedenergistics2:quartz_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/chiseled_quartz_block.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/chiseled_quartz_block.json index 2a8db58ca..ae3655d3f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/chiseled_quartz_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/chiseled_quartz_block.json @@ -4,12 +4,10 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa" - ], + "pattern": ["aa"], "key": { "a": { "item": "appliedenergistics2:quartz_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block.json index c31c13ac3..31973df9b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block.json @@ -3,13 +3,10 @@ "item": "appliedenergistics2:fluix_block" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - "aa" - ], + "pattern": ["aa", "aa"], "key": { "a": { "item": "appliedenergistics2:fluix_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block_pure.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block_pure.json index 4d273aae1..99ad30270 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block_pure.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/fluix_block_pure.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:fluix_block" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "a a", - "aaa" - ], + "pattern": ["aaa", "a a", "aaa"], "key": { "a": { "item": "appliedenergistics2:purified_fluix_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/light_detector.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/light_detector.json index 47ee522c6..b0046caa2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/light_detector.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/light_detector.json @@ -3,9 +3,7 @@ "item": "appliedenergistics2:light_detector" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab" - ], + "pattern": ["ab"], "key": { "a": { "tag": "appliedenergistics2:crystals/nether" @@ -14,4 +12,4 @@ "item": "minecraft:iron_ingot" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_block_pure.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_block_pure.json index f7ac3902e..b40e8633e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_block_pure.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_block_pure.json @@ -3,14 +3,10 @@ "item": "minecraft:quartz_block" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "a a", - "aaa" - ], + "pattern": ["aaa", "a a", "aaa"], "key": { "a": { "item": "appliedenergistics2:purified_nether_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_fixture.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_fixture.json index d968d5cb3..e5e4e71f5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_fixture.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_fixture.json @@ -4,9 +4,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab" - ], + "pattern": ["ab"], "key": { "b": { "item": "minecraft:iron_ingot" @@ -15,4 +13,4 @@ "item": "appliedenergistics2:charged_certus_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_glass.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_glass.json index e541597ae..72eda82cb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_glass.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_glass.json @@ -4,11 +4,7 @@ "count": 4 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bab", - "aba" - ], + "pattern": ["aba", "bab", "aba"], "key": { "b": { "tag": "appliedenergistics2:glass" @@ -17,4 +13,4 @@ "tag": "appliedenergistics2:dusts/quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_vibrant_glass.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_vibrant_glass.json index 3de5344e0..d7f4248bf 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_vibrant_glass.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/quartz_vibrant_glass.json @@ -3,9 +3,7 @@ "item": "appliedenergistics2:quartz_vibrant_glass" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba" - ], + "pattern": ["aba"], "key": { "a": { "item": "minecraft:glowstone_dust" @@ -14,4 +12,4 @@ "item": "appliedenergistics2:quartz_glass" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_brick.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_brick.json index 25383fc75..2d2a74596 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_brick.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_brick.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:smooth_sky_stone_block" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_small_brick.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_small_brick.json index 8d49a024e..4b36c7fcb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_small_brick.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_small_brick.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:sky_stone_brick" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_smooth.json b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_smooth.json index 53d564062..0b8bfa049 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_smooth.json +++ b/src/main/resources/data/appliedenergistics2/recipes/decorative/sky_stone_smooth.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:sky_stone_small_brick" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/bonemeal.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/bonemeal.json index ff89b55ef..dc01e3d62 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/bonemeal.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/bonemeal.json @@ -10,4 +10,4 @@ } }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust.json index 571e8b518..9e6448094 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust_ore.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust_ore.json index 5dd55962b..a47482c86 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust_ore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/certus_quartz_dust_ore.json @@ -14,4 +14,4 @@ ] }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/ender_dust.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/ender_dust.json index 459980352..1bf6bc360 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/ender_dust.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/ender_dust.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/flint.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/flint.json index 7da54fd4e..5e3c4c7c1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/flint.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/flint.json @@ -9,4 +9,4 @@ } }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/flour.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/flour.json index d31d7a788..7eacb45c4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/flour.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/flour.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/fluix_dust.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/fluix_dust.json index 507db0e2a..ff6e3f270 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/fluix_dust.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/fluix_dust.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ingot.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ingot.json index 063b82d84..57ff905d8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ingot.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ingot.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ore.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ore.json index ed8d310fc..0623dcbb0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/gold_dust_ore.json @@ -14,4 +14,4 @@ ] }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ingot.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ingot.json index bcaea7f11..272a731e3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ingot.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ingot.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ore.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ore.json index b1f911d71..21887a0d5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/iron_dust_ore.json @@ -14,4 +14,4 @@ ] }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust.json index ad2e9196c..752893d23 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust.json @@ -9,4 +9,4 @@ } }, "turns": 4 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust_ore.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust_ore.json index 583ca4054..2a94dafb4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust_ore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/nether_quartz_dust_ore.json @@ -14,4 +14,4 @@ ] }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/grinder/sky_dust.json b/src/main/resources/data/appliedenergistics2/recipes/grinder/sky_dust.json index 7581da816..adeebf431 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/grinder/sky_dust.json +++ b/src/main/resources/data/appliedenergistics2/recipes/grinder/sky_dust.json @@ -9,4 +9,4 @@ } }, "turns": 8 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor.json index d568a8c72..57948108a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor.json @@ -15,4 +15,4 @@ "item": "appliedenergistics2:printed_silicon" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_press.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_press.json index 2d67494fe..868466996 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_press.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_press.json @@ -12,4 +12,4 @@ "tag": "forge:storage_blocks/iron" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_print.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_print.json index 5f7282e90..3da2e378c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_print.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/calculation_processor_print.json @@ -12,4 +12,4 @@ "item": "appliedenergistics2:purified_certus_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor.json index cdb70c05c..ef8ac8193 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor.json @@ -15,4 +15,4 @@ "item": "appliedenergistics2:printed_silicon" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_press.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_press.json index 759e3b73a..a819407d4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_press.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_press.json @@ -12,4 +12,4 @@ "tag": "forge:storage_blocks/iron" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_print.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_print.json index 6696392e0..0457a09b8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_print.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/engineering_processor_print.json @@ -12,4 +12,4 @@ "tag": "forge:gems/diamond" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor.json index 70e165eaa..ca18e96a8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor.json @@ -15,4 +15,4 @@ "item": "appliedenergistics2:printed_silicon" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_press.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_press.json index b82af1b90..0c37907cb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_press.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_press.json @@ -12,4 +12,4 @@ "tag": "forge:storage_blocks/iron" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_print.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_print.json index 8f504f7af..7f891cb38 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_print.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/logic_processor_print.json @@ -12,4 +12,4 @@ "tag": "forge:ingots/gold" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_press.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_press.json index b00268f41..c3714f4e0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_press.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_press.json @@ -12,4 +12,4 @@ "tag": "forge:storage_blocks/iron" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_print.json b/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_print.json index 0166ffcf5..4b3a2ee0a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_print.json +++ b/src/main/resources/data/appliedenergistics2/recipes/inscriber/silicon_print.json @@ -12,4 +12,4 @@ "tag": "appliedenergistics2:silicon" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json b/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json index 87f9869a5..b0a66311a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/advancedcard.json @@ -10,11 +10,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab ", - "cdb", - "ab " - ], + "pattern": ["ab ", "cdb", "ab "], "key": { "b": { "tag": "forge:ingots/iron" @@ -29,4 +25,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json b/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json index a63a9f72e..314768657 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/annihilationcore.json @@ -10,9 +10,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abc" - ], + "pattern": ["abc"], "key": { "b": { "tag": "appliedenergistics2:dusts/fluix" @@ -24,4 +22,4 @@ "item": "appliedenergistics2:logic_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json b/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json index be636003a..841bb3984 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/basiccard.json @@ -10,11 +10,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab ", - "cdb", - "ab " - ], + "pattern": ["ab ", "cdb", "ab "], "key": { "b": { "tag": "forge:ingots/iron" @@ -29,4 +25,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json index 87e5099b9..b1c4ff79d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcapacity.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:basic_card" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json index 5da23984a..54e20cc56 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardcrafting.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:basic_card" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json index f8b0e9119..6de77e54b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardfuzzy.json @@ -17,4 +17,4 @@ "tag": "appliedenergistics2:wool" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json index 9147305f2..a4d7e1f80 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardinverter.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:advanced_card" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json index ceef2da0f..7833e5ee0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardredstone.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:basic_card" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json b/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json index f3bbd660f..260ea93bf 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/cardspeed.json @@ -17,4 +17,4 @@ "tag": "appliedenergistics2:crystals/fluix" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json b/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json index d1a9caf90..81c738f36 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json +++ b/src/main/resources/data/appliedenergistics2/recipes/materials/formationcore.json @@ -10,9 +10,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abc" - ], + "pattern": ["abc"], "key": { "b": { "tag": "appliedenergistics2:dusts/fluix" @@ -24,4 +22,4 @@ "item": "appliedenergistics2:logic_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/chests_sky_stone.json b/src/main/resources/data/appliedenergistics2/recipes/misc/chests_sky_stone.json index c03817ea0..fb0b878d0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/chests_sky_stone.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/chests_sky_stone.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:sky_stone_chest" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "a a", - "aaa" - ], + "pattern": ["aaa", "a a", "aaa"], "key": { "a": { "item": "appliedenergistics2:sky_stone_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/chests_smooth_sky_stone.json b/src/main/resources/data/appliedenergistics2/recipes/misc/chests_smooth_sky_stone.json index fc9dda804..337682e37 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/chests_smooth_sky_stone.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/chests_smooth_sky_stone.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:smooth_sky_stone_chest" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "a a", - "aaa" - ], + "pattern": ["aaa", "a a", "aaa"], "key": { "a": { "item": "appliedenergistics2:smooth_sky_stone_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_chiseled_quartz.json b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_chiseled_quartz.json index 04f196255..289536de4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_chiseled_quartz.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_chiseled_quartz.json @@ -9,4 +9,4 @@ "item": "appliedenergistics2:chiseled_quartz_block" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_block.json b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_block.json index cb33c59ff..2b649ac3b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_block.json @@ -9,4 +9,4 @@ "item": "appliedenergistics2:quartz_block" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_pillar.json b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_pillar.json index abe9f1b3e..3d87d221a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_pillar.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_certus_quartz_pillar.json @@ -9,4 +9,4 @@ "item": "appliedenergistics2:quartz_pillar" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_fluix_block.json b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_fluix_block.json index 14f9556c2..ad5304e68 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_fluix_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/deconstruction_fluix_block.json @@ -9,4 +9,4 @@ "item": "appliedenergistics2:fluix_block" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/fluixpearl.json b/src/main/resources/data/appliedenergistics2/recipes/misc/fluixpearl.json index 3ce72a30f..03908b6a7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/fluixpearl.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/fluixpearl.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluix_pearl" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "minecraft:ender_pearl" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone.json b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone.json index 4c05d488f..0e710a846 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:grindstone" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cac", - "dcd" - ], + "pattern": ["aba", "cac", "dcd"], "key": { "c": { "tag": "appliedenergistics2:crystals/quartz" @@ -22,4 +18,4 @@ "tag": "appliedenergistics2:gears/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_crank.json b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_crank.json index fdc335338..8d01495a6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_crank.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_crank.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:crank" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - " a", - " a" - ], + "pattern": ["aaa", " a", " a"], "key": { "a": { "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json index 86948516a..e68d46d5a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/grindstone_woodengear.json @@ -9,14 +9,10 @@ "item": "appliedenergistics2:wooden_gear" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "a a", - " a " - ], + "pattern": [" a ", "a a", " a "], "key": { "a": { "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/meteors_sky_compass.json b/src/main/resources/data/appliedenergistics2/recipes/misc/meteors_sky_compass.json index ce7b0d73d..5559a8808 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/meteors_sky_compass.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/meteors_sky_compass.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:sky_compass" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "aba", - " a " - ], + "pattern": [" a ", "aba", " a "], "key": { "a": { "tag": "forge:ingots/iron" @@ -16,4 +12,4 @@ "item": "appliedenergistics2:charged_certus_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_certus.json b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_certus.json index aed21e889..7bde98b53 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_certus.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_certus.json @@ -12,4 +12,4 @@ "tag": "appliedenergistics2:dusts/certus_quartz" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_fluix.json index 102b00f9f..bf043715f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_fluix.json @@ -12,4 +12,4 @@ "tag": "appliedenergistics2:dusts/fluix" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_nether.json b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_nether.json index 899af58c4..537fad5f4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_nether.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/seeds_nether.json @@ -12,4 +12,4 @@ "tag": "appliedenergistics2:dusts/nether_quartz" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/tiny_tnt.json b/src/main/resources/data/appliedenergistics2/recipes/misc/tiny_tnt.json index 2342b1484..6593d8355 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/tiny_tnt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/tiny_tnt.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:tiny_tnt" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab", - "ba" - ], + "pattern": ["ab", "ba"], "key": { "b": { "item": "minecraft:gunpowder" @@ -15,4 +12,4 @@ "tag": "appliedenergistics2:dusts/quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_comparator.json b/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_comparator.json index 820a56e01..664556012 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_comparator.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_comparator.json @@ -3,11 +3,7 @@ "item": "minecraft:comparator" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "aba", - "ccc" - ], + "pattern": [" a ", "aba", "ccc"], "key": { "b": { "tag": "appliedenergistics2:crystals/nether" @@ -19,4 +15,4 @@ "tag": "forge:stone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_daylight_detector.json b/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_daylight_detector.json index a65804a9d..e565d406e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_daylight_detector.json +++ b/src/main/resources/data/appliedenergistics2/recipes/misc/vanilla_daylight_detector.json @@ -3,11 +3,7 @@ "item": "minecraft:daylight_detector" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bbb", - "ccc" - ], + "pattern": ["aaa", "bbb", "ccc"], "key": { "a": { "tag": "appliedenergistics2:glass" @@ -19,4 +15,4 @@ "tag": "minecraft:wooden_slabs" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/cell_workbench.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/cell_workbench.json index a58c54a3e..bfa474e9a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/cell_workbench.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/cell_workbench.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:cell_workbench" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "ccc" - ], + "pattern": ["aba", "cdc", "ccc"], "key": { "c": { "tag": "forge:ingots/iron" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/controller.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/controller.json index e5ac428e7..b66603b52 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/controller.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/controller.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:controller" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:smooth_sky_stone_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_charger.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_charger.json index 922897958..8fe23d97a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_charger.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_charger.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:charger" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "a ", - "aba" - ], + "pattern": ["aba", "a ", "aba"], "key": { "a": { "tag": "forge:ingots/iron" @@ -16,4 +12,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_quartz_growth_accelerator.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_quartz_growth_accelerator.json index 2b97f2a72..618ea68b1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_quartz_growth_accelerator.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/crystal_processing_quartz_growth_accelerator.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:quartz_growth_accelerator" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aba" - ], + "pattern": ["aba", "cdc", "aba"], "key": { "c": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:fluix_block" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_dense_energy_cell.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_dense_energy_cell.json index 9294b78f4..a45664c37 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_dense_energy_cell.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_dense_energy_cell.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:dense_energy_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:energy_cell" @@ -16,4 +12,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_acceptor.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_acceptor.json index 31b63b6b3..8b71ae411 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_acceptor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_acceptor.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:energy_acceptor" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "b": { "item": "appliedenergistics2:quartz_glass" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_cell.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_cell.json index 40046791e..665f0b856 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_cell.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_energy_cell.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:energy_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "appliedenergistics2:quartz_glass" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:dusts/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_vibration_chamber.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_vibration_chamber.json index ce36b546d..63b6e5822 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_vibration_chamber.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/energy_vibration_chamber.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:vibration_chamber" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aca" - ], + "pattern": ["aaa", "aba", "aca"], "key": { "a": { "tag": "forge:ingots/iron" @@ -19,4 +15,4 @@ "item": "minecraft:furnace" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface.json index 74b9b993e..ce6d8d9a1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluid_interface" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "c d", - "aba" - ], + "pattern": ["aba", "c d", "aba"], "key": { "d": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_alt.json index 06386c0ab..cb2eaf402 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_alt.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:cable_fluid_interface" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_part.json index e30539002..7b1645cd8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/fluid_interfaces_interface_part.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:fluid_interface" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/inscribers.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/inscribers.json index 17a854913..d54227a63 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/inscribers.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/inscribers.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:inscriber" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "c a", - "aba" - ], + "pattern": ["aba", "c a", "aba"], "key": { "b": { "item": "minecraft:sticky_piston" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface.json index 34db614ce..1a97b54a3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:interface" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "c d", - "aba" - ], + "pattern": ["aba", "c d", "aba"], "key": { "d": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_alt.json index 21575b01d..0911b422f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_alt.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:cable_interface" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_part.json index a575f6026..6a6fc859c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/interfaces_interface_part.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:interface" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_condenser.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_condenser.json index c9bc7f2c1..034ee7d7d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_condenser.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_condenser.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:condenser" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "b": { "tag": "appliedenergistics2:glass" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:dusts/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_port.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_port.json index 2d44fde9c..fb685ec1f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_port.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/io_port.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:io_port" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bcb", - "ded" - ], + "pattern": ["aaa", "bcb", "ded"], "key": { "a": { "tag": "appliedenergistics2:glass" @@ -25,4 +21,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_link.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_link.json index bd6aca1f4..d44438bde 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_link.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_link.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:quantum_link" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "b b", - "aba" - ], + "pattern": ["aba", "b b", "aba"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -16,4 +12,4 @@ "item": "appliedenergistics2:fluix_pearl" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_ring.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_ring.json index 5883cb258..82cb847b2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_ring.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/quantum_ring.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:quantum_ring" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cde", - "aba" - ], + "pattern": ["aba", "cde", "aba"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -25,4 +21,4 @@ "item": "appliedenergistics2:logic_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/security_station.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/security_station.json index 69218affb..ff5b5084d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/security_station.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/security_station.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:security_station" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aea" - ], + "pattern": ["aba", "cdc", "aea"], "key": { "d": { "item": "appliedenergistics2:16k_cell_component" @@ -25,4 +21,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_port.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_port.json index af5d87644..8f9d815ac 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_port.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_port.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:spatial_io_port" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bcb", - "ded" - ], + "pattern": ["aaa", "bcb", "ded"], "key": { "a": { "tag": "appliedenergistics2:glass" @@ -25,4 +21,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_pylon.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_pylon.json index 261d23b61..365470ce7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_pylon.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/spatial_io_pylon.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:spatial_pylon" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aba" - ], + "pattern": ["aba", "cdc", "aba"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_chest.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_chest.json index 5170bbea3..1294f2794 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_chest.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_chest.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:chest" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "c c", - "ded" - ], + "pattern": ["aba", "c c", "ded"], "key": { "a": { "tag": "appliedenergistics2:glass" @@ -25,4 +21,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_drive.json b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_drive.json index 8522ab87c..de0f1886b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_drive.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/blocks/storage_drive.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:drive" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "c c", - "aba" - ], + "pattern": ["aba", "c c", "aba"], "key": { "b": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_black.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_black.json index 769d1993c..3947aeb1d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/black" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_blue.json index 3c8a69f8b..4178a90f6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_brown.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_brown.json index 07f4d2cca..621d47eda 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_cyan.json index fafa52100..23d4f4a32 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/cyan" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix.json index 925642ad2..fef0c6747 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix_clean.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix_clean.json index 1765671b3..33102a109 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix_clean.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_fluix_clean.json @@ -11,4 +11,4 @@ "item": "minecraft:water_bucket" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_gray.json index 2285417d2..c0d9db7f4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/gray" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_green.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_green.json index 763e022b2..fe5702b6a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_blue.json index 148881282..65a4f1747 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_gray.json index 903a50a1f..ac1533f9c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_lime.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_lime.json index 41813ea78..b7c709f8b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_magenta.json index 49035423e..337d8b0ac 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/magenta" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_orange.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_orange.json index 304401f89..52c7cac4a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/orange" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_pink.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_pink.json index 1d24353bc..9b84dd258 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/pink" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_purple.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_purple.json index 522aa8c08..d398510cc 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_red.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_red.json index 11948cd89..045c80ba7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_white.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_white.json index 47faff4cd..16d2f67ef 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/white" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_yellow.json index 9a06d5cdf..9441cb0f1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/covered_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/yellow" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_black.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_black.json index 63da1e203..e9e6a5eef 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/black" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_blue.json index 6e065218a..14b4ba8df 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_brown.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_brown.json index 67548a599..14ec16d66 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_cyan.json index 73e4bfc2d..5350a25c5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/cyan" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix.json index 617fe49d7..e513104e5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:fluix_covered_cable" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix_clean.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix_clean.json index 41f9dc024..3723ed4d9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix_clean.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_fluix_clean.json @@ -11,4 +11,4 @@ "item": "minecraft:water_bucket" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_gray.json index d445f9be2..c6d1a5889 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_green.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_green.json index 578ebabf0..aee399fa2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_blue.json index aae0c0674..ea78f6751 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_gray.json index 906d602f4..21e77e2fd 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_lime.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_lime.json index ce58d6783..b6b3fe4d2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_magenta.json index 385c62e3c..19419ac79 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/magenta" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_orange.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_orange.json index dc9ab7078..0e1a8566d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/orange" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_pink.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_pink.json index ad5a7b395..3094faba6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/pink" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_purple.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_purple.json index af979fe9a..2fa029363 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_red.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_red.json index 511be6671..afea4ce7c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_white.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_white.json index ff729b6c7..2a75e5f0f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_covered_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/white" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_yellow.json index 3b2398090..1222327ef 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_covered_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/yellow" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_covered_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_black.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_black.json index aa2097340..17726d719 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/black" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_blue.json index f3bd77632..c99bf657c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_brown.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_brown.json index 68d40e1bd..250321479 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_cyan.json index 36c8e77a4..a013c4945 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/cyan" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix.json index de0011ecb..a352d3f2b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix.json @@ -14,4 +14,4 @@ "tag": "forge:dusts/glowstone" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix_clean.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix_clean.json index 290b50488..413dec0dd 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix_clean.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_fluix_clean.json @@ -11,4 +11,4 @@ "item": "minecraft:water_bucket" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_gray.json index 2e2af7580..ebeed17a3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_green.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_green.json index 610467b90..28ef47baf 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_blue.json index c01571205..bf2d7c6d3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_gray.json index dde4cca0f..c66974b11 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_lime.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_lime.json index e79453438..b43d62981 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_magenta.json index 12b34ac57..45964e4f5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/magenta" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_orange.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_orange.json index 36c45d1bd..e5fcc6519 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/orange" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_pink.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_pink.json index 791b3f1c7..1f270fee7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/pink" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_purple.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_purple.json index c5e9db867..c192df3c3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_red.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_red.json index bd33b08aa..de75cacdb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_white.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_white.json index b553be209..3c37cb89a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_dense_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/white" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_yellow.json index 8dd47dc55..8293bfd7c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/dense_smart_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/yellow" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_dense_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_black.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_black.json index 440f5bb9b..02c6a307c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/black" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_blue.json index 7595a33bd..93ae9ebef 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_brown.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_brown.json index 3ba2baa6f..0f30fa2cf 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_cyan.json index f9ded4159..d9b206ad2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/cyan" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix.json index 8f2f31548..4d9860101 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix.json @@ -15,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix_clean.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix_clean.json index 38db66c30..b1b52793a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix_clean.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_fluix_clean.json @@ -11,4 +11,4 @@ "item": "minecraft:water_bucket" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_gray.json index 34e441e8f..b52da35b6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_green.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_green.json index c44c58620..d0d3cdadb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_blue.json index d1ad552ed..fdb768fc9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_gray.json index 7748e616c..f512acda7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/light_gray" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_lime.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_lime.json index d4b8a2d97..0deede1b2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_magenta.json index 110d50a05..69b7ee4fd 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/magenta" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_orange.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_orange.json index 8a4f54686..b11f3e5e9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/orange" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_pink.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_pink.json index 3ef7c3cda..c94ba82e3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/pink" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_purple.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_purple.json index 04b5a3466..034447db2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_red.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_red.json index d0b6d8fd0..0a9e24cb1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_white.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_white.json index 43041ed5d..fe3797c94 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/white" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_yellow.json index 0db861c11..4302c9cec 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/glass_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_glass_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/yellow" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_black.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_black.json index d70f2c245..dd60e17e5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/black" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_blue.json index f4d91966c..0772d5118 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_brown.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_brown.json index d2e298a67..435186fed 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_cyan.json index 2881dc524..40e341787 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/cyan" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix.json index c759de7ec..ca563c5a7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix.json @@ -14,4 +14,4 @@ "tag": "forge:dusts/glowstone" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix_clean.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix_clean.json index 986fc3dd6..075578e8a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix_clean.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_fluix_clean.json @@ -11,4 +11,4 @@ "item": "minecraft:water_bucket" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_gray.json index f12236149..30b9bdbea 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/gray" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_green.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_green.json index 8a3243329..eabdc382d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_blue.json index ebaf511ad..5ca17df44 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/light_blue" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_gray.json index fa0467a98..c4ba80dad 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/light_gray" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_lime.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_lime.json index a9e545ea2..6e4b58126 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_magenta.json index fc9e3a556..dd2e65ff0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/magenta" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_orange.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_orange.json index 68aa1e436..b8a81c005 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/orange" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_pink.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_pink.json index 667cc380f..9e34926a9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/pink" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_purple.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_purple.json index 061ff547c..ba51a45d9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_red.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_red.json index 44161a345..3eb6dcdff 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:fluix_smart_cable" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_white.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_white.json index f768a5166..38783300e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/white" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_yellow.json index 4998ad26a..3a1d1ec43 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cables/smart_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/yellow" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:fluix_smart_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/empty_storage_cell.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/empty_storage_cell.json index 809ff59a1..685c8bea6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/empty_storage_cell.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/empty_storage_cell.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:empty_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "b b", - "ccc" - ], + "pattern": ["aba", "b b", "ccc"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -19,4 +15,4 @@ "tag": "forge:dusts/redstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k.json index 8effeb33a..2e8723cdb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16k_fluid_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:16k_fluid_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k_storage.json index ff81bc8b6..b1b00a9c2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_16k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:16k_fluid_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k.json index 60ef5f061..03b08574f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:1k_fluid_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:1k_fluid_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k_storage.json index c802fc24c..1b682f506 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_1k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:1k_fluid_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k.json index 30ca3747a..022cbab0e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:4k_fluid_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:4k_fluid_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k_storage.json index 88468f0b8..b5c7c2273 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_4k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:4k_fluid_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k.json index 09b2a0e58..a7456a237 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:64k_fluid_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:64k_fluid_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k_storage.json index 1de226f62..30abf0d11 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_cell_64k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:64k_fluid_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_16k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_16k_part.json index e43a6bdf0..f12e1c6a8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_16k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_16k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16k_fluid_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "d": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_1k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_1k_part.json index c639bc152..6ea56cf58 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_1k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_1k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:1k_fluid_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "a": { "item": "minecraft:lapis_lazuli" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:logic_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_4k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_4k_part.json index 55547bc84..06ce0eff7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_4k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_4k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:4k_fluid_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "d": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_64k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_64k_part.json index f803e9322..58cb098b9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_64k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/fluid_storage_components_cell_64k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:64k_fluid_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "d": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components.json index 18a4404b9..eb620d943 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:2_cubed_spatial_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:fluix_pearl" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_0.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_0.json index 5e9db0eec..2025cdb60 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_0.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_0.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16_cubed_spatial_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_1.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_1.json index a4722504a..cc79e1a1b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_1.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_components_1.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:128_cubed_spatial_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed.json index 753028f71..89e7d4a9d 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:128_cubed_spatial_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:128_cubed_spatial_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed_storage.json index a98988612..b20c62b12 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_128_cubed_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:128_cubed_spatial_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed.json index 4c827aed3..7407dfc23 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16_cubed_spatial_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "tag": "forge:dusts/redstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed_storage.json index 6a7811104..94e65e9ca 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_16_cubed_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:16_cubed_spatial_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed.json index fa62bbd8e..d1aaa1b31 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:2_cubed_spatial_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:2_cubed_spatial_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed_storage.json index e765d16aa..d92b1110c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/spatial_storage_cell_2_cubed_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:2_cubed_spatial_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k.json index 47f51d47e..7ede54282 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16k_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "tag": "forge:dusts/redstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k_storage.json index d94a1f382..9b32287a5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_16k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:empty_storage_cell" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k.json index c93485271..394a0c8c1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:1k_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:1k_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k_storage.json index a1f9810f6..0830fb942 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_1k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:1k_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k.json index 6cd610eda..d4fed6bf4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:4k_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:4k_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k_storage.json index dbaee29bb..5fd069279 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_4k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:4k_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k.json index c2828649f..2bef37720 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:64k_storage_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:64k_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k_storage.json index 0e07409e2..04cadcc1f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_cell_64k_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:64k_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_16k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_16k_part.json index 49b6b74b8..1a841a6b7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_16k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_16k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:16k_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "b": { "item": "appliedenergistics2:calculation_processor" @@ -22,4 +18,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_1k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_1k_part.json index 477fead20..f94ddf111 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_1k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_1k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:1k_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "aba" - ], + "pattern": ["aba", "bcb", "aba"], "key": { "a": { "tag": "forge:dusts/redstone" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:logic_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_4k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_4k_part.json index a16a11b51..a54ce6aff 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_4k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_4k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:4k_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "d": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_64k_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_64k_part.json index 92f2dcc40..f94dc4936 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_64k_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/storage_components_cell_64k_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:64k_cell_component" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aca" - ], + "pattern": ["aba", "cdc", "aca"], "key": { "b": { "item": "appliedenergistics2:calculation_processor" @@ -22,4 +18,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell.json index 67725efa3..1ad6f3728 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:view_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "tag": "appliedenergistics2:crystals/certus" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell_storage.json index 3125fe4ff..4ecdf3bdd 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/cells/view_cell_storage.json @@ -11,4 +11,4 @@ "tag": "appliedenergistics2:crystals/certus" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/16k_cpu_crafting_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/16k_cpu_crafting_storage.json index e30aeeea5..8da0e90bb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/16k_cpu_crafting_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/16k_cpu_crafting_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:crafting_unit" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/1k_cpu_crafting_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/1k_cpu_crafting_storage.json index e2520db83..3b8b7d1e0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/1k_cpu_crafting_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/1k_cpu_crafting_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:1k_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/4k_cpu_crafting_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/4k_cpu_crafting_storage.json index 9f43ed5b1..543eddf2e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/4k_cpu_crafting_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/4k_cpu_crafting_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:crafting_unit" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/64k_cpu_crafting_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/64k_cpu_crafting_storage.json index 5541ee728..e554573eb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/64k_cpu_crafting_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/64k_cpu_crafting_storage.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:64k_cell_component" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_accelerator.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_accelerator.json index 409499a07..e68bc8fe6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_accelerator.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_accelerator.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:crafting_unit" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_monitor.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_monitor.json index d8cabf287..e745fa6b6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_monitor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_monitor.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:crafting_unit" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_unit.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_unit.json index 16f700b45..abe5ba7b3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_unit.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/cpu_crafting_unit.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:crafting_unit" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cdc", - "aba" - ], + "pattern": ["aba", "cdc", "aba"], "key": { "a": { "tag": "forge:ingots/iron" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/molecular_assembler.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/molecular_assembler.json index d7c65f44a..9eed81f56 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/molecular_assembler.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/molecular_assembler.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:molecular_assembler" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "cde", - "aba" - ], + "pattern": ["aba", "cde", "aba"], "key": { "e": { "item": "appliedenergistics2:formation_core" @@ -25,4 +21,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/patterns_blank.json b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/patterns_blank.json index ec6eaeb75..eadeb3cff 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/crafting/patterns_blank.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/crafting/patterns_blank.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:blank_pattern" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "bcb", - "ddd" - ], + "pattern": ["aba", "bcb", "ddd"], "key": { "a": { "item": "appliedenergistics2:quartz_glass" @@ -22,4 +18,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json index f4661fe7d..15d0510d9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json @@ -12,4 +12,4 @@ "tag": "appliedenergistics2:knife" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus.json index ae80b3d42..6ca89df11 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:export_bus" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - " c " - ], + "pattern": ["aba", " c "], "key": { "b": { "item": "appliedenergistics2:formation_core" @@ -18,4 +15,4 @@ "item": "minecraft:piston" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus_fluid.json index 7a8aa4100..e75658b3c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/export_bus_fluid.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:fluid_export_bus" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aba", - "lcl" - ], + "pattern": ["aba", "lcl"], "key": { "b": { "item": "appliedenergistics2:formation_core" @@ -21,4 +18,4 @@ "item": "minecraft:lapis_lazuli" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/fluid_level_emitter.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/fluid_level_emitter.json index d8cfeda03..3d9b15d16 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/fluid_level_emitter.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/fluid_level_emitter.json @@ -14,4 +14,4 @@ "item": "appliedenergistics2:calculation_processor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus.json index 41ee5d111..03f8868bf 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:import_bus" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "bcb" - ], + "pattern": [" a ", "bcb"], "key": { "c": { "item": "minecraft:sticky_piston" @@ -18,4 +15,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus_fluid.json index 1283fb68f..f2bb4b61c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/import_bus_fluid.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:fluid_import_bus" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "lal", - "bcb" - ], + "pattern": ["lal", "bcb"], "key": { "c": { "item": "minecraft:sticky_piston" @@ -21,4 +18,4 @@ "item": "minecraft:lapis_lazuli" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/level_emitter.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/level_emitter.json index f119de30d..f135e18f0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/level_emitter.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/level_emitter.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:calculation_processor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_conversion.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_conversion.json index 512219a83..85ed24cc9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_conversion.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_conversion.json @@ -14,4 +14,4 @@ "item": "appliedenergistics2:annihilation_core" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_storage.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_storage.json index c543214ea..948ea788b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_storage.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/monitors_storage.json @@ -11,4 +11,4 @@ "tag": "appliedenergistics2:illuminated_panel" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_dark_monitor.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_dark_monitor.json index c4c625dff..eb75a62e1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_dark_monitor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_dark_monitor.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:monitor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_monitor.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_monitor.json index 68cfc6e4e..e9c59f367 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_monitor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_monitor.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:semi_dark_monitor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor.json index 51e1eb350..d77102a0e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor.json @@ -4,11 +4,7 @@ "count": 3 }, "type": "minecraft:crafting_shaped", - "pattern": [ - " ab", - "cdb", - " ab" - ], + "pattern": [" ab", "cdb", " ab"], "key": { "b": { "item": "appliedenergistics2:quartz_glass" @@ -23,4 +19,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor_alt.json index 57c50e506..2fe6d506a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/panels_semi_dark_monitor_alt.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:dark_monitor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt.json index c644da01c..945ee261a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:annihilation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bcb" - ], + "pattern": ["aaa", "bcb"], "key": { "b": { "tag": "forge:ingots/iron" @@ -18,4 +15,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt2.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt2.json index 4d564658a..5dee66904 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt2.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_alt2.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:annihilation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab", - "cb", - "ab" - ], + "pattern": ["ab", "cb", "ab"], "key": { "a": { "tag": "forge:ingots/iron" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:annihilation_core" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid.json index 85827af0c..851620a60 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluid_annihilation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "ddd", - "bcb" - ], + "pattern": ["aaa", "ddd", "bcb"], "key": { "b": { "tag": "forge:ingots/iron" @@ -22,4 +18,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid_alt.json index 3a6be5d68..9ba1fbd60 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilation_fluid_alt.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluid_annihilation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "adb", - "cdb", - "adb" - ], + "pattern": ["adb", "cdb", "adb"], "key": { "a": { "tag": "forge:ingots/iron" @@ -22,4 +18,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilatition_identity.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilatition_identity.json index 0908b01e9..09336a5bc 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilatition_identity.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_annihilatition_identity.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:fluix_pearl" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation.json index edc85cd98..7c5c10fc0 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:formation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bcb" - ], + "pattern": ["aaa", "bcb"], "key": { "c": { "item": "appliedenergistics2:formation_core" @@ -18,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_alt.json index ef4b21807..ea0a51b97 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_alt.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:formation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab", - "cb", - "ab" - ], + "pattern": ["ab", "cb", "ab"], "key": { "c": { "item": "appliedenergistics2:formation_core" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid.json index 1beeab6c1..17fdad5b5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluid_formation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "adb", - "cdb", - "adb" - ], + "pattern": ["adb", "cdb", "adb"], "key": { "c": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid_alt.json index a75c9f2a5..3ac3ef09e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/planes_formation_fluid_alt.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:fluid_formation_plane" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "ddd", - "bcb" - ], + "pattern": ["aaa", "ddd", "bcb"], "key": { "c": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/quartz_fiber_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/quartz_fiber_part.json index 547b37ed4..544c9ce1a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/quartz_fiber_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/quartz_fiber_part.json @@ -4,11 +4,7 @@ "count": 3 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "bbb", - "aaa" - ], + "pattern": ["aaa", "bbb", "aaa"], "key": { "a": { "tag": "appliedenergistics2:glass" @@ -17,4 +13,4 @@ "tag": "appliedenergistics2:dusts/quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus.json index 303d5566d..e102e5baa 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus.json @@ -14,4 +14,4 @@ "item": "minecraft:piston" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus_fluid.json index 39412d938..f2cefd753 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/storage_bus_fluid.json @@ -17,4 +17,4 @@ "item": "minecraft:lapis_lazuli" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals.json index 450742b10..5fad5fa29 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:annihilation_core" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_crafting.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_crafting.json index 75892a991..2b7412435 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_crafting.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_crafting.json @@ -14,4 +14,4 @@ "item": "appliedenergistics2:calculation_processor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_fluid.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_fluid.json index f565fd463..9391c7206 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_fluid.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_fluid.json @@ -14,4 +14,4 @@ "item": "appliedenergistics2:logic_processor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_interface.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_interface.json index 78cf8384d..0d6dba370 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_interface.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_interface.json @@ -14,4 +14,4 @@ "tag": "appliedenergistics2:interface" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_pattern.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_pattern.json index a3c6a86fd..d9eaca353 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_pattern.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/terminals_pattern.json @@ -11,4 +11,4 @@ "item": "appliedenergistics2:crafting_terminal" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus.json index 311b57a6b..35ad2f5de 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:toggle_bus" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "bcb", - " a " - ], + "pattern": [" a ", "bcb", " a "], "key": { "c": { "item": "minecraft:lever" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:fluix_glass_cable" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_alt.json index d2d7f9b6b..2427554c4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_alt.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:inverted_toggle_bus" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_inverted_alt.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_inverted_alt.json index 7a5bf9824..25b1ba4b5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_inverted_alt.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/toggle_bus_inverted_alt.json @@ -8,4 +8,4 @@ "item": "appliedenergistics2:toggle_bus" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/parts/tunnels_me.json b/src/main/resources/data/appliedenergistics2/recipes/network/parts/tunnels_me.json index c2eb9875f..1a4d817d6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/parts/tunnels_me.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/parts/tunnels_me.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:me_p2p_tunnel" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "aba", - "ccc" - ], + "pattern": [" a ", "aba", "ccc"], "key": { "b": { "item": "appliedenergistics2:engineering_processor" @@ -19,4 +15,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_access_point.json b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_access_point.json index f8bd31ea2..4b6ce7aca 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_access_point.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_access_point.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:wireless_access_point" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "b", - "c" - ], + "pattern": ["a", "b", "c"], "key": { "a": { "item": "appliedenergistics2:wireless_receiver" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_booster.json b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_booster.json index 7b218d6da..0864339a8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_booster.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_booster.json @@ -4,10 +4,7 @@ "count": 2 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abc", - "ddd" - ], + "pattern": ["abc", "ddd"], "key": { "d": { "tag": "forge:ingots/iron" @@ -22,4 +19,4 @@ "tag": "appliedenergistics2:dusts/ender" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_part.json b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_part.json index 90e685285..d907608db 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_part.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_part.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:wireless_receiver" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "bcb", - " b " - ], + "pattern": [" a ", "bcb", " b "], "key": { "b": { "tag": "forge:ingots/iron" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:fluix_pearl" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_terminal.json b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_terminal.json index d57cff732..5e534b16f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/network/wireless_terminal.json +++ b/src/main/resources/data/appliedenergistics2/recipes/network/wireless_terminal.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:wireless_terminal" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "b", - "c" - ], + "pattern": ["a", "b", "c"], "key": { "b": { "item": "appliedenergistics2:terminal" @@ -19,4 +15,4 @@ "item": "appliedenergistics2:wireless_receiver" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/smelting/bread.json b/src/main/resources/data/appliedenergistics2/recipes/smelting/bread.json index b993fbd6a..a19d9585e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/smelting/bread.json +++ b/src/main/resources/data/appliedenergistics2/recipes/smelting/bread.json @@ -7,4 +7,4 @@ "item": "appliedenergistics2:flour" }, "experience": 0.0 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/smelting/gold_ingot.json b/src/main/resources/data/appliedenergistics2/recipes/smelting/gold_ingot.json index c508e385b..cc7ecf42a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/smelting/gold_ingot.json +++ b/src/main/resources/data/appliedenergistics2/recipes/smelting/gold_ingot.json @@ -7,4 +7,4 @@ "tag": "forge:dusts/gold" }, "experience": 0.0 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/smelting/iron_ingot.json b/src/main/resources/data/appliedenergistics2/recipes/smelting/iron_ingot.json index 164bd47e1..756188cfb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/smelting/iron_ingot.json +++ b/src/main/resources/data/appliedenergistics2/recipes/smelting/iron_ingot.json @@ -7,4 +7,4 @@ "tag": "forge:dusts/iron" }, "experience": 0.0 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/smelting/silicon.json b/src/main/resources/data/appliedenergistics2/recipes/smelting/silicon.json index 4956bc506..4c9f6e3be 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/smelting/silicon.json +++ b/src/main/resources/data/appliedenergistics2/recipes/smelting/silicon.json @@ -12,4 +12,4 @@ } ], "experience": 0.0 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/smelting/smooth_sky_stone_block.json b/src/main/resources/data/appliedenergistics2/recipes/smelting/smooth_sky_stone_block.json index 2e5aadc1a..d8c9098c4 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/smelting/smooth_sky_stone_block.json +++ b/src/main/resources/data/appliedenergistics2/recipes/smelting/smooth_sky_stone_block.json @@ -7,4 +7,4 @@ "item": "appliedenergistics2:sky_stone_block" }, "experience": 0.0 -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_axe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_axe.json index 809720b00..a82124b8f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_axe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_axe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_axe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - "ab", - " b" - ], + "pattern": ["aa", "ab", " b"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_cutting_knife.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_cutting_knife.json index f0830a3b3..69babca7c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_cutting_knife.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_cutting_knife.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_cutting_knife" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a", - "ba ", - "cc " - ], + "pattern": [" a", "ba ", "cc "], "key": { "b": { "tag": "forge:ingots/iron" @@ -19,4 +15,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_hoe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_hoe.json index 684fbfd9a..433cfc3c8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_hoe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_hoe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_hoe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - " b", - " b" - ], + "pattern": ["aa", " b", " b"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_pickaxe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_pickaxe.json index 7bf55a893..e7bd191a8 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_pickaxe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_pickaxe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_pickaxe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - " b ", - " b " - ], + "pattern": ["aaa", " b ", " b "], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_spade.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_spade.json index 43e306207..c8c325479 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_spade.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_spade.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_shovel" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "b", - "b" - ], + "pattern": ["a", "b", "b"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_sword.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_sword.json index 71bc16c7c..a691588f9 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_sword.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_sword.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:certus_quartz_sword" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "a", - "b" - ], + "pattern": ["a", "a", "b"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_wrench.json b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_wrench.json index 37c1d456a..2b94f5d6e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_wrench.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/certus_quartz_wrench.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:certus_quartz_wrench" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a a", - " a ", - "a a" - ], + "pattern": ["a a", " a ", "a a"], "key": { "a": { "tag": "appliedenergistics2:crystals/certus_quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/matter_cannon.json b/src/main/resources/data/appliedenergistics2/recipes/tools/matter_cannon.json index 357acfc9c..26e053d7c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/matter_cannon.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/matter_cannon.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:matter_cannon" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aab", - "cd ", - "a " - ], + "pattern": ["aab", "cd ", "a "], "key": { "b": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:energy_cell" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_charged_staff.json b/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_charged_staff.json index 38a413e5c..06e24dd30 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_charged_staff.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_charged_staff.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:charged_staff" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a ", - " b ", - " b" - ], + "pattern": ["a ", " b ", " b"], "key": { "b": { "tag": "forge:ingots/iron" @@ -16,4 +12,4 @@ "item": "appliedenergistics2:charged_certus_quartz_crystal" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_entropy_manipulator.json b/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_entropy_manipulator.json index 0a8d2ee0e..9b4be79b7 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_entropy_manipulator.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/misctools_entropy_manipulator.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:entropy_manipulator" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab ", - "cd ", - " d" - ], + "pattern": ["ab ", "cd ", " d"], "key": { "c": { "item": "appliedenergistics2:engineering_processor" @@ -22,4 +18,4 @@ "tag": "appliedenergistics2:crystals/fluix" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_axe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_axe.json index fd9411df6..f1cfec619 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_axe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_axe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_axe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - "ab", - " b" - ], + "pattern": ["aa", "ab", " b"], "key": { "a": { "tag": "forge:gems/quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_cutting_knife.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_cutting_knife.json index 0bfa2cf9e..f73c8caeb 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_cutting_knife.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_cutting_knife.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_cutting_knife" }, "type": "minecraft:crafting_shaped", - "pattern": [ - " a", - "ba ", - "cc " - ], + "pattern": [" a", "ba ", "cc "], "key": { "b": { "tag": "forge:ingots/iron" @@ -19,4 +15,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_hoe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_hoe.json index 1fb24bff3..5c3e88dac 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_hoe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_hoe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_hoe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aa", - " b", - " b" - ], + "pattern": ["aa", " b", " b"], "key": { "a": { "tag": "forge:gems/quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_pickaxe.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_pickaxe.json index b18b7dfbe..6e3bab149 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_pickaxe.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_pickaxe.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_pickaxe" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - " b ", - " b " - ], + "pattern": ["aaa", " b ", " b "], "key": { "a": { "tag": "forge:gems/quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_spade.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_spade.json index 2742fe038..481e674c6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_spade.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_spade.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_shovel" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "b", - "b" - ], + "pattern": ["a", "b", "b"], "key": { "a": { "tag": "forge:gems/quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_sword.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_sword.json index 89779412d..bb5970afd 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_sword.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_sword.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:nether_quartz_sword" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a", - "a", - "b" - ], + "pattern": ["a", "a", "b"], "key": { "a": { "tag": "forge:gems/quartz" @@ -16,4 +12,4 @@ "tag": "forge:rods/wooden" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_wrench.json b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_wrench.json index 148ca2bbf..21c7cf1e3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_wrench.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/nether_quartz_wrench.json @@ -3,14 +3,10 @@ "item": "appliedenergistics2:nether_quartz_wrench" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "a a", - " a ", - "a a" - ], + "pattern": ["a a", " a ", "a a"], "key": { "a": { "tag": "forge:gems/quartz" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/network_biometric_card.json b/src/main/resources/data/appliedenergistics2/recipes/tools/network_biometric_card.json index 033e49d08..9075fc659 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/network_biometric_card.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/network_biometric_card.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:biometric_card" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abb", - "cdc" - ], + "pattern": ["abb", "cdc"], "key": { "a": { "item": "appliedenergistics2:engineering_processor" @@ -21,4 +18,4 @@ "tag": "forge:ingots/gold" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/network_color_applicator.json b/src/main/resources/data/appliedenergistics2/recipes/tools/network_color_applicator.json index f9de1f42c..c5c7b4390 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/network_color_applicator.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/network_color_applicator.json @@ -3,11 +3,7 @@ "item": "appliedenergistics2:color_applicator" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "ab ", - "bc ", - " d" - ], + "pattern": ["ab ", "bc ", " d"], "key": { "a": { "item": "appliedenergistics2:formation_core" @@ -22,4 +18,4 @@ "item": "appliedenergistics2:energy_cell" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/network_memory_card.json b/src/main/resources/data/appliedenergistics2/recipes/tools/network_memory_card.json index 0b43c82b5..58650982c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/network_memory_card.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/network_memory_card.json @@ -3,10 +3,7 @@ "item": "appliedenergistics2:memory_card" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abb", - "cdc" - ], + "pattern": ["abb", "cdc"], "key": { "b": { "tag": "forge:ingots/iron" @@ -21,4 +18,4 @@ "item": "appliedenergistics2:calculation_processor" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/network_portable_cell.json b/src/main/resources/data/appliedenergistics2/recipes/tools/network_portable_cell.json index d99ee50c4..79afbb765 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/network_portable_cell.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/network_portable_cell.json @@ -3,9 +3,7 @@ "item": "appliedenergistics2:portable_cell" }, "type": "minecraft:crafting_shaped", - "pattern": [ - "abc" - ], + "pattern": ["abc"], "key": { "a": { "item": "appliedenergistics2:chest" @@ -17,4 +15,4 @@ "item": "appliedenergistics2:1k_cell_component" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/network_tool.json b/src/main/resources/data/appliedenergistics2/recipes/tools/network_tool.json index 0c897803b..364393565 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/network_tool.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/network_tool.json @@ -17,4 +17,4 @@ "item": "appliedenergistics2:calculation_processor" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_black.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_black.json index 6e91baeff..0746435ff 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/black" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_blue.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_blue.json index 0883562b0..819be064a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:matter_ball" @@ -17,4 +13,4 @@ "tag": "forge:dyes/blue" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_brown.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_brown.json index 8b471f9e7..9eb6ad8d2 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/brown" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_cyan.json index 94087d3a7..ee60ec588 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/cyan" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_gray.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_gray.json index 6e7c9b8f7..6d8444b4e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/gray" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_green.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_green.json index de8ea5499..47e625fd6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/green" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_blue.json index e558ec593..2ec6370a3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/light_blue" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_gray.json index 55d676410..6cc52e4ac 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/light_gray" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lime.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lime.json index 7398cc951..8f32df391 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:matter_ball" @@ -17,4 +13,4 @@ "tag": "forge:dyes/lime" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_black.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_black.json index 5bd38ce94..4ad5d2987 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_black.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_black.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:black_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_blue.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_blue.json index de4e3f62d..758915f79 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:blue_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_brown.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_brown.json index 3487b0206..8ad4fdb8f 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_brown.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_brown.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:brown_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_cyan.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_cyan.json index 1047dd766..1bb7aa7a3 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_cyan.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_cyan.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:cyan_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_gray.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_gray.json index c96648be5..46036a2ea 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:gray_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_green.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_green.json index d721681ce..285075f9e 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_green.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_green.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:green_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_blue.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_blue.json index d87503dc7..6b606df2c 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_blue.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_blue.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:light_blue_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_gray.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_gray.json index 17cd0e978..3d2dfef69 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_gray.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_light_gray.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:light_gray_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_lime.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_lime.json index 11cbf451b..c54c0061a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_lime.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_lime.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:lime_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_magenta.json index 32eae4e27..7b3971cb5 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:magenta_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_orange.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_orange.json index 70c1eaa18..cf7b38e1a 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dusts/glowstone" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:orange_paint_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_pink.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_pink.json index 790601ecc..64d3f3de1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:pink_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_purple.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_purple.json index d0bb94e3f..15b3273e1 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:purple_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_red.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_red.json index 3027bd490..ec0fa0dfe 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:red_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_white.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_white.json index d8e277418..403bf926b 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:white_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_yellow.json index e349431eb..f11a61051 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_lumen_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:yellow_paint_ball" @@ -17,4 +13,4 @@ "tag": "forge:dusts/glowstone" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_magenta.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_magenta.json index 38d123789..c5f3302c6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_magenta.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_magenta.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/magenta" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_orange.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_orange.json index 18fcb6fc2..6075a57c6 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_orange.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_orange.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/orange" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_pink.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_pink.json index 287a23212..52433d2da 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_pink.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_pink.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/pink" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_purple.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_purple.json index a2887b8d7..78c098b69 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_purple.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_purple.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/purple" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_red.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_red.json index 6d9c86e14..7f5ea0ead 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_red.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_red.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "a": { "item": "appliedenergistics2:matter_ball" @@ -17,4 +13,4 @@ "tag": "forge:dyes/red" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_white.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_white.json index 7b71401ba..65c010343 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_white.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_white.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/white" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_yellow.json b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_yellow.json index bc71e273a..83c890057 100644 --- a/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_yellow.json +++ b/src/main/resources/data/appliedenergistics2/recipes/tools/paintballs_yellow.json @@ -4,11 +4,7 @@ "count": 8 }, "type": "minecraft:crafting_shaped", - "pattern": [ - "aaa", - "aba", - "aaa" - ], + "pattern": ["aaa", "aba", "aaa"], "key": { "b": { "tag": "forge:dyes/yellow" @@ -17,4 +13,4 @@ "item": "appliedenergistics2:matter_ball" } } -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/covered_cable.json b/src/main/resources/data/appliedenergistics2/tags/items/covered_cable.json index 8c239b4b9..e77b1fc11 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/covered_cable.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/covered_cable.json @@ -18,4 +18,4 @@ "appliedenergistics2:black_covered_cable", "appliedenergistics2:fluix_covered_cable" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/covered_dense_cable.json b/src/main/resources/data/appliedenergistics2/tags/items/covered_dense_cable.json index e9f042255..f2e26544a 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/covered_dense_cable.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/covered_dense_cable.json @@ -18,4 +18,4 @@ "appliedenergistics2:black_covered_dense_cable", "appliedenergistics2:fluix_covered_dense_cable" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus.json b/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus.json index 0956d772c..7b11e7885 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus.json @@ -4,4 +4,4 @@ "appliedenergistics2:charged_certus_quartz_crystal", "appliedenergistics2:purified_certus_quartz_crystal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus_quartz.json b/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus_quartz.json index de228338f..4422564cb 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus_quartz.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/crystals/certus_quartz.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:certus_quartz_crystal" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:certus_quartz_crystal"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/crystals/fluix.json b/src/main/resources/data/appliedenergistics2/tags/items/crystals/fluix.json index e3305851d..b56b77065 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/crystals/fluix.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/crystals/fluix.json @@ -3,4 +3,4 @@ "appliedenergistics2:fluix_crystal", "appliedenergistics2:purified_fluix_crystal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/crystals/nether.json b/src/main/resources/data/appliedenergistics2/tags/items/crystals/nether.json index 1e70b5360..dfeaf33a2 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/crystals/nether.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/crystals/nether.json @@ -3,4 +3,4 @@ "#forge:gems/quartz", "appliedenergistics2:purified_nether_quartz_crystal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/crystals/quartz.json b/src/main/resources/data/appliedenergistics2/tags/items/crystals/quartz.json index b914e9d4f..88ec4bab7 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/crystals/quartz.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/crystals/quartz.json @@ -4,4 +4,4 @@ "#appliedenergistics2:crystals/certus_quartz", "appliedenergistics2:charged_certus_quartz_crystal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/dusts/certus_quartz.json b/src/main/resources/data/appliedenergistics2/tags/items/dusts/certus_quartz.json index 55b0aa974..ed59def4e 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/dusts/certus_quartz.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/dusts/certus_quartz.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:certus_quartz_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:certus_quartz_dust"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/dusts/ender.json b/src/main/resources/data/appliedenergistics2/tags/items/dusts/ender.json index f22431a8e..444bd0222 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/dusts/ender.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/dusts/ender.json @@ -1,3 +1,3 @@ { "values": ["appliedenergistics2:ender_dust"] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/dusts/fluix.json b/src/main/resources/data/appliedenergistics2/tags/items/dusts/fluix.json index 511ff0e77..08ef53ef7 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/dusts/fluix.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/dusts/fluix.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:fluix_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:fluix_dust"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/dusts/nether_quartz.json b/src/main/resources/data/appliedenergistics2/tags/items/dusts/nether_quartz.json index a353be234..a26eca269 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/dusts/nether_quartz.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/dusts/nether_quartz.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:nether_quartz_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:nether_quartz_dust"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/dusts/quartz.json b/src/main/resources/data/appliedenergistics2/tags/items/dusts/quartz.json index 11d12c8f7..1bace7a98 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/dusts/quartz.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/dusts/quartz.json @@ -3,4 +3,4 @@ "#appliedenergistics2:dusts/certus_quartz", "#appliedenergistics2:dusts/nether_quartz" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/fluid_interface.json b/src/main/resources/data/appliedenergistics2/tags/items/fluid_interface.json index ce7158041..abfba4844 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/fluid_interface.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/fluid_interface.json @@ -3,4 +3,4 @@ "appliedenergistics2:fluid_interface", "appliedenergistics2:cable_fluid_interface" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/gears/wooden.json b/src/main/resources/data/appliedenergistics2/tags/items/gears/wooden.json index d53541e6b..0df618dff 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/gears/wooden.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/gears/wooden.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:wooden_gear" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:wooden_gear"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/glass.json b/src/main/resources/data/appliedenergistics2/tags/items/glass.json index 31e49d020..5309f6f80 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/glass.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/glass.json @@ -1,6 +1,3 @@ { - "values": [ - "minecraft:glass", - "#forge:glass" - ] -} \ No newline at end of file + "values": ["minecraft:glass", "#forge:glass"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/glass_cable.json b/src/main/resources/data/appliedenergistics2/tags/items/glass_cable.json index 22bc8d549..478d5dcb4 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/glass_cable.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/glass_cable.json @@ -18,4 +18,4 @@ "appliedenergistics2:black_glass_cable", "appliedenergistics2:fluix_glass_cable" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/illuminated_panel.json b/src/main/resources/data/appliedenergistics2/tags/items/illuminated_panel.json index 411061cfb..6f995234f 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/illuminated_panel.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/illuminated_panel.json @@ -4,4 +4,4 @@ "appliedenergistics2:semi_dark_monitor", "appliedenergistics2:dark_monitor" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/interface.json b/src/main/resources/data/appliedenergistics2/tags/items/interface.json index df9a466ff..309cde456 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/interface.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/interface.json @@ -3,4 +3,4 @@ "appliedenergistics2:interface", "appliedenergistics2:cable_interface" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/knife.json b/src/main/resources/data/appliedenergistics2/tags/items/knife.json index b11b036b0..caffcb661 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/knife.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/knife.json @@ -3,4 +3,4 @@ "appliedenergistics2:certus_quartz_cutting_knife", "appliedenergistics2:nether_quartz_cutting_knife" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json b/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json index 81f6e053a..cd352b2e1 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json @@ -1,6 +1,3 @@ { - "values": [ - "#forge:ingots/gold", - "#forge:ingots/iron" - ] -} \ No newline at end of file + "values": ["#forge:ingots/gold", "#forge:ingots/iron"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/nether_quartz_dust.json b/src/main/resources/data/appliedenergistics2/tags/items/nether_quartz_dust.json index a353be234..a26eca269 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/nether_quartz_dust.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/nether_quartz_dust.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:nether_quartz_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:nether_quartz_dust"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/quartz_wrench.json b/src/main/resources/data/appliedenergistics2/tags/items/quartz_wrench.json index 35ff272ad..111998186 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/quartz_wrench.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/quartz_wrench.json @@ -3,4 +3,4 @@ "appliedenergistics2:nether_quartz_wrench", "appliedenergistics2:certus_quartz_wrench" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/silicon.json b/src/main/resources/data/appliedenergistics2/tags/items/silicon.json index 500504096..65a77c2e8 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/silicon.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/silicon.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:silicon" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:silicon"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/smart_cable.json b/src/main/resources/data/appliedenergistics2/tags/items/smart_cable.json index f1e86f2a1..92b7d0e28 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/smart_cable.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/smart_cable.json @@ -18,4 +18,4 @@ "appliedenergistics2:black_smart_cable", "appliedenergistics2:fluix_smart_cable" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/smart_dense_cable.json b/src/main/resources/data/appliedenergistics2/tags/items/smart_dense_cable.json index 10789f0fa..d512f80c7 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/smart_dense_cable.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/smart_dense_cable.json @@ -18,4 +18,4 @@ "appliedenergistics2:black_smart_dense_cable", "appliedenergistics2:fluix_smart_dense_cable" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/wool.json b/src/main/resources/data/appliedenergistics2/tags/items/wool.json index 495a1df46..e8a3c8aa6 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/wool.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/wool.json @@ -1,5 +1,3 @@ { - "values": [ - "#minecraft:wool" - ] -} \ No newline at end of file + "values": ["#minecraft:wool"] +} diff --git a/src/main/resources/data/appliedenergistics2/tags/items/workbench.json b/src/main/resources/data/appliedenergistics2/tags/items/workbench.json index 3be1c8e22..24d0d25eb 100644 --- a/src/main/resources/data/appliedenergistics2/tags/items/workbench.json +++ b/src/main/resources/data/appliedenergistics2/tags/items/workbench.json @@ -1,5 +1,3 @@ { - "values": [ - "minecraft:crafting_table" - ] -} \ No newline at end of file + "values": ["minecraft:crafting_table"] +} diff --git a/src/main/resources/data/forge/tags/items/dusts/gold.json b/src/main/resources/data/forge/tags/items/dusts/gold.json index a059d79b5..1ac425070 100644 --- a/src/main/resources/data/forge/tags/items/dusts/gold.json +++ b/src/main/resources/data/forge/tags/items/dusts/gold.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:gold_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:gold_dust"] +} diff --git a/src/main/resources/data/forge/tags/items/dusts/iron.json b/src/main/resources/data/forge/tags/items/dusts/iron.json index 6ea444823..9f4a29198 100644 --- a/src/main/resources/data/forge/tags/items/dusts/iron.json +++ b/src/main/resources/data/forge/tags/items/dusts/iron.json @@ -1,5 +1,3 @@ { - "values": [ - "appliedenergistics2:iron_dust" - ] -} \ No newline at end of file + "values": ["appliedenergistics2:iron_dust"] +} diff --git a/src/main/resources/data/forge/tags/items/gems/certus_quartz.json b/src/main/resources/data/forge/tags/items/gems/certus_quartz.json index d306de422..d8941663a 100644 --- a/src/main/resources/data/forge/tags/items/gems/certus_quartz.json +++ b/src/main/resources/data/forge/tags/items/gems/certus_quartz.json @@ -3,4 +3,4 @@ "appliedenergistics2:certus_quartz_crystal", "appliedenergistics2:charged_certus_quartz_crystal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/forge/tags/items/ores/certus_quartz.json b/src/main/resources/data/forge/tags/items/ores/certus_quartz.json index ce24520a5..05fecd1c9 100644 --- a/src/main/resources/data/forge/tags/items/ores/certus_quartz.json +++ b/src/main/resources/data/forge/tags/items/ores/certus_quartz.json @@ -3,4 +3,4 @@ "appliedenergistics2:quartz_ore", "appliedenergistics2:charged_quartz_ore" ] -} \ No newline at end of file +} diff --git a/src/test/java/appeng/core/worlddata/MeteorDataNameEncoderTest.java b/src/test/java/appeng/core/worlddata/MeteorDataNameEncoderTest.java index bbe6f44e4..ee935c0de 100644 --- a/src/test/java/appeng/core/worlddata/MeteorDataNameEncoderTest.java +++ b/src/test/java/appeng/core/worlddata/MeteorDataNameEncoderTest.java @@ -18,11 +18,9 @@ package appeng.core.worlddata; - import org.junit.Assert; import org.junit.Test; - /** * Tests for {@link MeteorDataNameEncoder} * @@ -30,34 +28,31 @@ import org.junit.Test; * @version rv3 - 06.06.2015 * @since rv3 06.06.2015 */ -public class MeteorDataNameEncoderTest -{ - private static final int WITHOUT_CHUNK_X = 0; - private static final int WITHOUT_CHUNK_Z = 13; - private static final String WITHOUT_EXPECTED = "-5_0_13.dat"; +public class MeteorDataNameEncoderTest { + private static final int WITHOUT_CHUNK_X = 0; + private static final int WITHOUT_CHUNK_Z = 13; + private static final String WITHOUT_EXPECTED = "-5_0_13.dat"; - private static final int WITH_CHUNK_X = 32; - private static final int WITH_CHUNK_Z = -64; - private static final String WITH_EXPECTED = "3_2_-4.dat"; + private static final int WITH_CHUNK_X = 32; + private static final int WITH_CHUNK_Z = -64; + private static final String WITH_EXPECTED = "3_2_-4.dat"; - private final MeteorDataNameEncoder encoderWithZeroShifting = new MeteorDataNameEncoder( 0 ); - private final MeteorDataNameEncoder encoderWithFourShifting = new MeteorDataNameEncoder( 4 ); + private final MeteorDataNameEncoder encoderWithZeroShifting = new MeteorDataNameEncoder(0); + private final MeteorDataNameEncoder encoderWithFourShifting = new MeteorDataNameEncoder(4); - @Test - public void testEncoderWithoutShifting() - { - final String expected = WITHOUT_EXPECTED; - final String actual = this.encoderWithZeroShifting.encode( WITHOUT_CHUNK_X, WITHOUT_CHUNK_Z ); + @Test + public void testEncoderWithoutShifting() { + final String expected = WITHOUT_EXPECTED; + final String actual = this.encoderWithZeroShifting.encode(WITHOUT_CHUNK_X, WITHOUT_CHUNK_Z); - Assert.assertEquals( expected, actual ); - } + Assert.assertEquals(expected, actual); + } - @Test - public void testEncoderWithShifting() - { - final String expected = WITH_EXPECTED; - final String actual = this.encoderWithFourShifting.encode( WITH_CHUNK_X, WITH_CHUNK_Z ); + @Test + public void testEncoderWithShifting() { + final String expected = WITH_EXPECTED; + final String actual = this.encoderWithFourShifting.encode(WITH_CHUNK_X, WITH_CHUNK_Z); - Assert.assertEquals( expected, actual ); - } + Assert.assertEquals(expected, actual); + } } diff --git a/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java b/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java index 5427438ea..fe2e32241 100644 --- a/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java +++ b/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java @@ -1,12 +1,15 @@ package appeng.core.worlddata; -import appeng.spatial.SpatialDimensionExtraData; -import io.netty.buffer.Unpooled; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import static org.junit.Assert.*; + import org.junit.Test; -import static org.junit.Assert.*; +import io.netty.buffer.Unpooled; + +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; + +import appeng.spatial.SpatialDimensionExtraData; public class SpatialDimensionExtraDataTest { diff --git a/src/test/java/appeng/util/SlimReadableNumberConverterTest.java b/src/test/java/appeng/util/SlimReadableNumberConverterTest.java index 1a2b032ca..ef48ca8c3 100644 --- a/src/test/java/appeng/util/SlimReadableNumberConverterTest.java +++ b/src/test/java/appeng/util/SlimReadableNumberConverterTest.java @@ -1,12 +1,10 @@ package appeng.util; - import static org.junit.Assert.assertEquals; import org.junit.Test; - /* * This file is part of Applied Energistics 2. * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. @@ -32,115 +30,102 @@ import org.junit.Test; * @version rv2 * @since rv2 */ -public final class SlimReadableNumberConverterTest -{ - private static final long NUMBER_NEG_999999 = -999999L; - private static final String RESULT_NEG_999999 = "-0M"; +public final class SlimReadableNumberConverterTest { + private static final long NUMBER_NEG_999999 = -999999L; + private static final String RESULT_NEG_999999 = "-0M"; - private static final long NUMBER_NEG_9999 = -9999L; - private static final String RESULT_NEG_9999 = "-9K"; + private static final long NUMBER_NEG_9999 = -9999L; + private static final String RESULT_NEG_9999 = "-9K"; - private static final long NUMBER_NEG_999 = -999L; - private static final String RESULT_NEG_999 = "-0K"; + private static final long NUMBER_NEG_999 = -999L; + private static final String RESULT_NEG_999 = "-0K"; - private static final long NUMBER_0 = 0L; - private static final String RESULT_0 = "0"; + private static final long NUMBER_0 = 0L; + private static final String RESULT_0 = "0"; - private static final long NUMBER_999 = 999L; - private static final String RESULT_999 = "999"; + private static final long NUMBER_999 = 999L; + private static final String RESULT_999 = "999"; - private static final long NUMBER_9999 = 9999L; - private static final String RESULT_9999 = "9K"; + private static final long NUMBER_9999 = 9999L; + private static final String RESULT_9999 = "9K"; - private static final long NUMBER_10000 = 10000L; - private static final String RESULT_10000 = "10K"; + private static final long NUMBER_10000 = 10000L; + private static final String RESULT_10000 = "10K"; - private static final long NUMBER_10500 = 10500L; - private static final String RESULT_10500 = "10K"; + private static final long NUMBER_10500 = 10500L; + private static final String RESULT_10500 = "10K"; - private static final long NUMBER_155555 = 155555L; - private static final String RESULT_155555 = ".1M"; + private static final long NUMBER_155555 = 155555L; + private static final String RESULT_155555 = ".1M"; - private static final long NUMBER_9999999 = 9999999L; - private static final String RESULT_9999999 = "9M"; + private static final long NUMBER_9999999 = 9999999L; + private static final String RESULT_9999999 = "9M"; - private static final long NUMBER_10000000 = 10000000L; - private static final String RESULT_10000000 = "10M"; + private static final long NUMBER_10000000 = 10000000L; + private static final String RESULT_10000000 = "10M"; - private static final long NUMBER_155555555 = 155555555L; - private static final String RESULT_155555555 = ".1G"; + private static final long NUMBER_155555555 = 155555555L; + private static final String RESULT_155555555 = ".1G"; - private final ISlimReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; + private final ISlimReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; - @Test( expected = AssertionError.class ) - public void testConvertNeg999999() - { - assertEquals( RESULT_NEG_999999, this.converter.toSlimReadableForm( NUMBER_NEG_999999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg999999() { + assertEquals(RESULT_NEG_999999, this.converter.toSlimReadableForm(NUMBER_NEG_999999)); + } - @Test( expected = AssertionError.class ) - public void testConvertNeg9999() - { - assertEquals( RESULT_NEG_9999, this.converter.toSlimReadableForm( NUMBER_NEG_9999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg9999() { + assertEquals(RESULT_NEG_9999, this.converter.toSlimReadableForm(NUMBER_NEG_9999)); + } - @Test( expected = AssertionError.class ) - public void testConvertNeg999() - { - assertEquals( RESULT_NEG_999, this.converter.toSlimReadableForm( NUMBER_NEG_999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg999() { + assertEquals(RESULT_NEG_999, this.converter.toSlimReadableForm(NUMBER_NEG_999)); + } - @Test - public void testConvert0() - { - assertEquals( RESULT_0, this.converter.toSlimReadableForm( NUMBER_0 ) ); - } + @Test + public void testConvert0() { + assertEquals(RESULT_0, this.converter.toSlimReadableForm(NUMBER_0)); + } - @Test - public void testConvert999() - { - assertEquals( RESULT_999, this.converter.toSlimReadableForm( NUMBER_999 ) ); - } + @Test + public void testConvert999() { + assertEquals(RESULT_999, this.converter.toSlimReadableForm(NUMBER_999)); + } - @Test - public void testConvert9999() - { - assertEquals( RESULT_9999, this.converter.toSlimReadableForm( NUMBER_9999 ) ); - } + @Test + public void testConvert9999() { + assertEquals(RESULT_9999, this.converter.toSlimReadableForm(NUMBER_9999)); + } - @Test - public void testConvert10000() - { - assertEquals( RESULT_10000, this.converter.toSlimReadableForm( NUMBER_10000 ) ); - } + @Test + public void testConvert10000() { + assertEquals(RESULT_10000, this.converter.toSlimReadableForm(NUMBER_10000)); + } - @Test - public void testConvert10500() - { - assertEquals( RESULT_10500, this.converter.toSlimReadableForm( NUMBER_10500 ) ); - } + @Test + public void testConvert10500() { + assertEquals(RESULT_10500, this.converter.toSlimReadableForm(NUMBER_10500)); + } - @Test - public void testConvert155555() - { - assertEquals( RESULT_155555, this.converter.toSlimReadableForm( NUMBER_155555 ) ); - } + @Test + public void testConvert155555() { + assertEquals(RESULT_155555, this.converter.toSlimReadableForm(NUMBER_155555)); + } - @Test - public void testConvert9999999() - { - assertEquals( RESULT_9999999, this.converter.toSlimReadableForm( NUMBER_9999999 ) ); - } + @Test + public void testConvert9999999() { + assertEquals(RESULT_9999999, this.converter.toSlimReadableForm(NUMBER_9999999)); + } - @Test - public void testConvert10000000() - { - assertEquals( RESULT_10000000, this.converter.toSlimReadableForm( NUMBER_10000000 ) ); - } + @Test + public void testConvert10000000() { + assertEquals(RESULT_10000000, this.converter.toSlimReadableForm(NUMBER_10000000)); + } - @Test - public void testConvert155555555() - { - assertEquals( RESULT_155555555, this.converter.toSlimReadableForm( NUMBER_155555555 ) ); - } + @Test + public void testConvert155555555() { + assertEquals(RESULT_155555555, this.converter.toSlimReadableForm(NUMBER_155555555)); + } } diff --git a/src/test/java/appeng/util/UUIDMatcherTest.java b/src/test/java/appeng/util/UUIDMatcherTest.java index 69e3c6d13..16cc1da5b 100644 --- a/src/test/java/appeng/util/UUIDMatcherTest.java +++ b/src/test/java/appeng/util/UUIDMatcherTest.java @@ -18,44 +18,37 @@ package appeng.util; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; - /** * Tests for {@link UUIDMatcher} */ -public final class UUIDMatcherTest -{ - private static final String IS_UUID = "03ba29a1-d6bd-32ba-90b2-375e4d65abc9"; - private static final String NO_UUID = "no"; - private static final String INVALID_UUID = "g3ba29a1-d6bd-32ba-90b2-375e4d65abc9"; +public final class UUIDMatcherTest { + private static final String IS_UUID = "03ba29a1-d6bd-32ba-90b2-375e4d65abc9"; + private static final String NO_UUID = "no"; + private static final String INVALID_UUID = "g3ba29a1-d6bd-32ba-90b2-375e4d65abc9"; - private final UUIDMatcher matcher; + private final UUIDMatcher matcher; - public UUIDMatcherTest() - { - this.matcher = new UUIDMatcher(); - } + public UUIDMatcherTest() { + this.matcher = new UUIDMatcher(); + } - @Test - public void testUUID_shouldPass() - { - assertTrue( this.matcher.isUUID( IS_UUID ) ); - } + @Test + public void testUUID_shouldPass() { + assertTrue(this.matcher.isUUID(IS_UUID)); + } - @Test - public void testNoUUD_shouldPass() - { - assertFalse( this.matcher.isUUID( NO_UUID ) ); - } + @Test + public void testNoUUD_shouldPass() { + assertFalse(this.matcher.isUUID(NO_UUID)); + } - @Test - public void testInvalidUUID_shouldPass() - { - assertFalse( this.matcher.isUUID( INVALID_UUID ) ); - } + @Test + public void testInvalidUUID_shouldPass() { + assertFalse(this.matcher.isUUID(INVALID_UUID)); + } } diff --git a/src/test/java/appeng/util/WideReadableNumberConverterTest.java b/src/test/java/appeng/util/WideReadableNumberConverterTest.java index eb57ea6eb..a3f0b5b1a 100644 --- a/src/test/java/appeng/util/WideReadableNumberConverterTest.java +++ b/src/test/java/appeng/util/WideReadableNumberConverterTest.java @@ -18,12 +18,10 @@ package appeng.util; - import static org.junit.Assert.assertEquals; import org.junit.Test; - /** * Test for {@link IWideReadableNumberConverter} * @@ -31,115 +29,102 @@ import org.junit.Test; * @version rv2 * @since rv2 */ -public final class WideReadableNumberConverterTest -{ - private static final long NUMBER_NEG_999999 = -999999L; - private static final String RESULT_NEG_999999 = "-0M"; +public final class WideReadableNumberConverterTest { + private static final long NUMBER_NEG_999999 = -999999L; + private static final String RESULT_NEG_999999 = "-0M"; - private static final long NUMBER_NEG_9999 = -9999L; - private static final String RESULT_NEG_9999 = "-9K"; + private static final long NUMBER_NEG_9999 = -9999L; + private static final String RESULT_NEG_9999 = "-9K"; - private static final long NUMBER_NEG_999 = -999L; - private static final String RESULT_NEG_999 = "-999"; + private static final long NUMBER_NEG_999 = -999L; + private static final String RESULT_NEG_999 = "-999"; - private static final long NUMBER_0 = 0L; - private static final String RESULT_0 = "0"; + private static final long NUMBER_0 = 0L; + private static final String RESULT_0 = "0"; - private static final long NUMBER_999 = 999L; - private static final String RESULT_999 = "999"; + private static final long NUMBER_999 = 999L; + private static final String RESULT_999 = "999"; - private static final long NUMBER_9999 = 9999L; - private static final String RESULT_9999 = "9999"; + private static final long NUMBER_9999 = 9999L; + private static final String RESULT_9999 = "9999"; - private static final long NUMBER_10000 = 10000L; - private static final String RESULT_10000 = "10K"; + private static final long NUMBER_10000 = 10000L; + private static final String RESULT_10000 = "10K"; - private static final long NUMBER_10500 = 10500L; - private static final String RESULT_10500 = "10K"; + private static final long NUMBER_10500 = 10500L; + private static final String RESULT_10500 = "10K"; - private static final long NUMBER_155555 = 155555L; - private static final String RESULT_155555 = "155K"; + private static final long NUMBER_155555 = 155555L; + private static final String RESULT_155555 = "155K"; - private static final long NUMBER_9999999 = 9999999L; - private static final String RESULT_9999999 = "9.9M"; + private static final long NUMBER_9999999 = 9999999L; + private static final String RESULT_9999999 = "9.9M"; - private static final long NUMBER_10000000 = 10000000L; - private static final String RESULT_10000000 = "10M"; + private static final long NUMBER_10000000 = 10000000L; + private static final String RESULT_10000000 = "10M"; - private static final long NUMBER_155555555 = 155555555L; - private static final String RESULT_155555555 = "155M"; + private static final long NUMBER_155555555 = 155555555L; + private static final String RESULT_155555555 = "155M"; - private final IWideReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; + private final IWideReadableNumberConverter converter = ReadableNumberConverter.INSTANCE; - @Test( expected = AssertionError.class ) - public void testConvertNeg999999() - { - assertEquals( RESULT_NEG_999999, this.converter.toWideReadableForm( NUMBER_NEG_999999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg999999() { + assertEquals(RESULT_NEG_999999, this.converter.toWideReadableForm(NUMBER_NEG_999999)); + } - @Test( expected = AssertionError.class ) - public void testConvertNeg9999() - { - assertEquals( RESULT_NEG_9999, this.converter.toWideReadableForm( NUMBER_NEG_9999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg9999() { + assertEquals(RESULT_NEG_9999, this.converter.toWideReadableForm(NUMBER_NEG_9999)); + } - @Test( expected = AssertionError.class ) - public void testConvertNeg999() - { - assertEquals( RESULT_NEG_999, this.converter.toWideReadableForm( NUMBER_NEG_999 ) ); - } + @Test(expected = AssertionError.class) + public void testConvertNeg999() { + assertEquals(RESULT_NEG_999, this.converter.toWideReadableForm(NUMBER_NEG_999)); + } - @Test - public void testConvert0() - { - assertEquals( RESULT_0, this.converter.toWideReadableForm( NUMBER_0 ) ); - } + @Test + public void testConvert0() { + assertEquals(RESULT_0, this.converter.toWideReadableForm(NUMBER_0)); + } - @Test - public void testConvert999() - { - assertEquals( RESULT_999, this.converter.toWideReadableForm( NUMBER_999 ) ); - } + @Test + public void testConvert999() { + assertEquals(RESULT_999, this.converter.toWideReadableForm(NUMBER_999)); + } - @Test - public void testConvert9999() - { - assertEquals( RESULT_9999, this.converter.toWideReadableForm( NUMBER_9999 ) ); - } + @Test + public void testConvert9999() { + assertEquals(RESULT_9999, this.converter.toWideReadableForm(NUMBER_9999)); + } - @Test - public void testConvert10000() - { - assertEquals( RESULT_10000, this.converter.toWideReadableForm( NUMBER_10000 ) ); - } + @Test + public void testConvert10000() { + assertEquals(RESULT_10000, this.converter.toWideReadableForm(NUMBER_10000)); + } - @Test - public void testConvert10500() - { - assertEquals( RESULT_10500, this.converter.toWideReadableForm( NUMBER_10500 ) ); - } + @Test + public void testConvert10500() { + assertEquals(RESULT_10500, this.converter.toWideReadableForm(NUMBER_10500)); + } - @Test - public void testConvert155555() - { - assertEquals( RESULT_155555, this.converter.toWideReadableForm( NUMBER_155555 ) ); - } + @Test + public void testConvert155555() { + assertEquals(RESULT_155555, this.converter.toWideReadableForm(NUMBER_155555)); + } - @Test - public void testConvert9999999() - { - assertEquals( RESULT_9999999, this.converter.toWideReadableForm( NUMBER_9999999 ) ); - } + @Test + public void testConvert9999999() { + assertEquals(RESULT_9999999, this.converter.toWideReadableForm(NUMBER_9999999)); + } - @Test - public void testConvert10000000() - { - assertEquals( RESULT_10000000, this.converter.toWideReadableForm( NUMBER_10000000 ) ); - } + @Test + public void testConvert10000000() { + assertEquals(RESULT_10000000, this.converter.toWideReadableForm(NUMBER_10000000)); + } - @Test - public void testConvert155555555() - { - assertEquals( RESULT_155555555, this.converter.toWideReadableForm( NUMBER_155555555 ) ); - } + @Test + public void testConvert155555555() { + assertEquals(RESULT_155555555, this.converter.toWideReadableForm(NUMBER_155555555)); + } } diff --git a/src/test/java/appeng/util/helpers/P2PHelperTest.java b/src/test/java/appeng/util/helpers/P2PHelperTest.java index e18c35828..637fae605 100644 --- a/src/test/java/appeng/util/helpers/P2PHelperTest.java +++ b/src/test/java/appeng/util/helpers/P2PHelperTest.java @@ -18,7 +18,6 @@ package appeng.util.helpers; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -26,82 +25,77 @@ import org.junit.Test; import appeng.api.util.AEColor; +public class P2PHelperTest { -public class P2PHelperTest -{ + private P2PHelper unitUnderTest = new P2PHelper(); - private P2PHelper unitUnderTest = new P2PHelper(); + private static final short WHITE_FREQUENCY = 0; + private static final AEColor[] WHITE_COLORS = new AEColor[] { AEColor.WHITE, AEColor.WHITE, AEColor.WHITE, + AEColor.WHITE }; - private static final short WHITE_FREQUENCY = 0; - private static final AEColor[] WHITE_COLORS = new AEColor[] { AEColor.WHITE, AEColor.WHITE, AEColor.WHITE, AEColor.WHITE }; + private static final short BLACK_FREQUENCY = (short) 0xFFFF; + private static final AEColor[] BLACK_COLORS = new AEColor[] { AEColor.BLACK, AEColor.BLACK, AEColor.BLACK, + AEColor.BLACK }; - private static final short BLACK_FREQUENCY = (short) 0xFFFF; - private static final AEColor[] BLACK_COLORS = new AEColor[] { AEColor.BLACK, AEColor.BLACK, AEColor.BLACK, AEColor.BLACK }; + private static final short MULTI_FREQUENCY = (short) 0xE8D1; + private static final AEColor[] MULTI_COLORS = new AEColor[] { AEColor.RED, AEColor.LIGHT_GRAY, AEColor.GREEN, + AEColor.ORANGE }; - private static final short MULTI_FREQUENCY = (short) 0xE8D1; - private static final AEColor[] MULTI_COLORS = new AEColor[] { AEColor.RED, AEColor.LIGHT_GRAY, AEColor.GREEN, AEColor.ORANGE }; + private static final String HEX_WHITE_FREQUENCY = "0000"; + private static final String HEX_BLACK_FREQUENCY = "FFFF"; + private static final String HEX_MULTI_FREQUENCY = "E8D1"; + private static final String HEX_MIN_FREQUENCY = "8000"; + private static final String HEX_MAX_FREQUENCY = "7FFF"; - private static final String HEX_WHITE_FREQUENCY = "0000"; - private static final String HEX_BLACK_FREQUENCY = "FFFF"; - private static final String HEX_MULTI_FREQUENCY = "E8D1"; - private static final String HEX_MIN_FREQUENCY = "8000"; - private static final String HEX_MAX_FREQUENCY = "7FFF"; + @Test + public void testToColors() { + assertArrayEquals(WHITE_COLORS, this.unitUnderTest.toColors(WHITE_FREQUENCY)); + assertArrayEquals(BLACK_COLORS, this.unitUnderTest.toColors(BLACK_FREQUENCY)); + assertArrayEquals(MULTI_COLORS, this.unitUnderTest.toColors(MULTI_FREQUENCY)); + } - @Test - public void testToColors() - { - assertArrayEquals( WHITE_COLORS, this.unitUnderTest.toColors( WHITE_FREQUENCY ) ); - assertArrayEquals( BLACK_COLORS, this.unitUnderTest.toColors( BLACK_FREQUENCY ) ); - assertArrayEquals( MULTI_COLORS, this.unitUnderTest.toColors( MULTI_FREQUENCY ) ); - } + @Test + public void testFromColors() { + assertEquals(WHITE_FREQUENCY, this.unitUnderTest.fromColors(WHITE_COLORS)); + assertEquals(BLACK_FREQUENCY, this.unitUnderTest.fromColors(BLACK_COLORS)); + assertEquals(MULTI_FREQUENCY, this.unitUnderTest.fromColors(MULTI_COLORS)); + } - @Test - public void testFromColors() - { - assertEquals( WHITE_FREQUENCY, this.unitUnderTest.fromColors( WHITE_COLORS ) ); - assertEquals( BLACK_FREQUENCY, this.unitUnderTest.fromColors( BLACK_COLORS ) ); - assertEquals( MULTI_FREQUENCY, this.unitUnderTest.fromColors( MULTI_COLORS ) ); - } + @Test + public void testToAndFromColors() { + for (short i = Short.MIN_VALUE; i < Short.MAX_VALUE; i++) { + assertEquals(i, this.unitUnderTest.fromColors(this.unitUnderTest.toColors(i))); + } + } - @Test - public void testToAndFromColors() - { - for( short i = Short.MIN_VALUE; i < Short.MAX_VALUE; i++ ) - { - assertEquals( i, this.unitUnderTest.fromColors( this.unitUnderTest.toColors( i ) ) ); - } - } + @Test + public void testToHexDigit() { + assertEquals("0", this.unitUnderTest.toHexDigit(AEColor.WHITE)); + assertEquals("1", this.unitUnderTest.toHexDigit(AEColor.ORANGE)); + assertEquals("2", this.unitUnderTest.toHexDigit(AEColor.MAGENTA)); + assertEquals("3", this.unitUnderTest.toHexDigit(AEColor.LIGHT_BLUE)); + assertEquals("4", this.unitUnderTest.toHexDigit(AEColor.YELLOW)); + assertEquals("5", this.unitUnderTest.toHexDigit(AEColor.LIME)); + assertEquals("6", this.unitUnderTest.toHexDigit(AEColor.PINK)); + assertEquals("7", this.unitUnderTest.toHexDigit(AEColor.GRAY)); + assertEquals("8", this.unitUnderTest.toHexDigit(AEColor.LIGHT_GRAY)); + assertEquals("9", this.unitUnderTest.toHexDigit(AEColor.CYAN)); + assertEquals("A", this.unitUnderTest.toHexDigit(AEColor.PURPLE)); + assertEquals("B", this.unitUnderTest.toHexDigit(AEColor.BLUE)); + assertEquals("C", this.unitUnderTest.toHexDigit(AEColor.BROWN)); + assertEquals("D", this.unitUnderTest.toHexDigit(AEColor.GREEN)); + assertEquals("E", this.unitUnderTest.toHexDigit(AEColor.RED)); + assertEquals("F", this.unitUnderTest.toHexDigit(AEColor.BLACK)); + } - @Test - public void testToHexDigit() - { - assertEquals( "0", this.unitUnderTest.toHexDigit( AEColor.WHITE ) ); - assertEquals( "1", this.unitUnderTest.toHexDigit( AEColor.ORANGE ) ); - assertEquals( "2", this.unitUnderTest.toHexDigit( AEColor.MAGENTA ) ); - assertEquals( "3", this.unitUnderTest.toHexDigit( AEColor.LIGHT_BLUE ) ); - assertEquals( "4", this.unitUnderTest.toHexDigit( AEColor.YELLOW ) ); - assertEquals( "5", this.unitUnderTest.toHexDigit( AEColor.LIME ) ); - assertEquals( "6", this.unitUnderTest.toHexDigit( AEColor.PINK ) ); - assertEquals( "7", this.unitUnderTest.toHexDigit( AEColor.GRAY ) ); - assertEquals( "8", this.unitUnderTest.toHexDigit( AEColor.LIGHT_GRAY ) ); - assertEquals( "9", this.unitUnderTest.toHexDigit( AEColor.CYAN ) ); - assertEquals( "A", this.unitUnderTest.toHexDigit( AEColor.PURPLE ) ); - assertEquals( "B", this.unitUnderTest.toHexDigit( AEColor.BLUE ) ); - assertEquals( "C", this.unitUnderTest.toHexDigit( AEColor.BROWN ) ); - assertEquals( "D", this.unitUnderTest.toHexDigit( AEColor.GREEN ) ); - assertEquals( "E", this.unitUnderTest.toHexDigit( AEColor.RED ) ); - assertEquals( "F", this.unitUnderTest.toHexDigit( AEColor.BLACK ) ); - } + @Test + public void testToHexString() { + assertEquals(HEX_WHITE_FREQUENCY, this.unitUnderTest.toHexString(WHITE_FREQUENCY)); + assertEquals(HEX_BLACK_FREQUENCY, this.unitUnderTest.toHexString(BLACK_FREQUENCY)); + assertEquals(HEX_MULTI_FREQUENCY, this.unitUnderTest.toHexString(MULTI_FREQUENCY)); - @Test - public void testToHexString() - { - assertEquals( HEX_WHITE_FREQUENCY, this.unitUnderTest.toHexString( WHITE_FREQUENCY ) ); - assertEquals( HEX_BLACK_FREQUENCY, this.unitUnderTest.toHexString( BLACK_FREQUENCY ) ); - assertEquals( HEX_MULTI_FREQUENCY, this.unitUnderTest.toHexString( MULTI_FREQUENCY ) ); - - assertEquals( HEX_MIN_FREQUENCY, this.unitUnderTest.toHexString( Short.MIN_VALUE ) ); - assertEquals( HEX_MAX_FREQUENCY, this.unitUnderTest.toHexString( Short.MAX_VALUE ) ); - } + assertEquals(HEX_MIN_FREQUENCY, this.unitUnderTest.toHexString(Short.MIN_VALUE)); + assertEquals(HEX_MAX_FREQUENCY, this.unitUnderTest.toHexString(Short.MAX_VALUE)); + } } diff --git a/src/test/resources/appeng/services/version/releases.json b/src/test/resources/appeng/services/version/releases.json index ee473838d..8f8e00ef7 100644 --- a/src/test/resources/appeng/services/version/releases.json +++ b/src/test/resources/appeng/services/version/releases.json @@ -31,9 +31,7 @@ "prerelease": true, "created_at": "2015-03-15T17:38:03Z", "published_at": "2015-03-16T06:32:39Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.12", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.12", "body": "Fixes #1024 Added zinc to the grindstone - thatsIch\r\n\r\nUpdate zh_CN.lang - bakaxyf" @@ -70,9 +68,7 @@ "prerelease": true, "created_at": "2015-03-13T22:49:12Z", "published_at": "2015-03-14T23:53:49Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.11", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.11", "body": "Fixes #1015 Pattern terminal destroying a single item when not able to satisfy a NEI recipe - yueh\r\n\r\nFixes #1011 skip null values returned by the oredictionary - yueh\r\n\r\nUpdate zh_CN.lang - bakaxyf" @@ -109,9 +105,7 @@ "prerelease": true, "created_at": "2015-03-11T15:40:32Z", "published_at": "2015-03-11T15:53:37Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.10", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.10", "body": "Fixes #861 Wireless Terminal notifies player, if it is unlinked - thatsIch\r\n\r\nFixes #920 Increased GUI close distance to match Vanilla MC distance - thatsIch\r\n\r\nFixes #743 Crash with BC plugs\r\n\r\nFixes #942 BC builder can build AE networks again\r\n\r\nUpdate #319 Now compiled against BC 6.4.2, with that MJ is gone" @@ -148,9 +142,7 @@ "prerelease": true, "created_at": "2015-03-09T14:05:21Z", "published_at": "2015-03-10T09:42:09Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.9", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.9", "body": "Enhancement #817 Crafting CPU GUI now shows a green background on items being crafted, and a yellow background on scheduled items - Eearslya\r\n\r\nEnhancement Added an option to disable the colored crafting status - yueh\r\n\r\nEnhancement Added more information to the security audit - yueh\r\n\r\nEnhancement Improved performance - yueh\r\n\r\nFixes #972 Level Emitter tool-tip now corresponds to the actual behavior - thatsIch\r\n\r\nFixes #982 Auto-crafting lag reduced - yueh\r\n\r\nFixes #910 Dense cables render correctly with FMP now - yueh\r\n\r\nFixes #943 Reduced lag when breaking multiple blocks at once using Annihilation Plane - yueh\r\n\r\nFixes cable render crash and covered cables render as smart - yueh\r\n\r\nUpdate fr_FR.lang - Mazdallier\r\n\r\nUpdate zh_CN.lang - bakaxyf\r\n\r\nUpdated Texture / Model License to be more specific - AlgorithmX2\r\n\r\nUpdated Forge to recommended 10.13.2.1291 and other dependencies - yueh" @@ -187,9 +179,7 @@ "prerelease": true, "created_at": "2015-01-22T16:05:23Z", "published_at": "2015-01-24T16:46:55Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.8", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.8", "body": "Update pt_BR.lang - al-myr\r\n\r\nImproved the logged warning for FailledConnection Now displays to coordinates of the affected tunnels. - yueh\r\n\r\nFix #701 - Changed harvest tool to axe - TheJulianJES\r\n\r\nFormation plane can now drop blocks as items - yueh\r\n\r\nDisable level emitter on offline networks Turns off level emitters if the goes offline because it runs out of power, channels or similar. - yueh\r\n\r\nFixes #304 WAILA Integration updated and fixed WAILA offers a new interface to sync the server data to the client. - thatsIch\r\n\r\nRemoved buffer from annihilation plane - yueh\r\n\r\nEffects should not collide with anything - yueh\r\n\r\nImprove code quality - thatsIch" @@ -226,9 +216,7 @@ "prerelease": true, "created_at": "2015-01-01T14:35:57Z", "published_at": "2015-01-01T17:56:50Z", - "assets": [ - - ], + "assets": [], "tarball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/tarball/rv2.beta.7", "zipball_url": "https://api.github.com/repos/AppliedEnergistics/Applied-Energistics-2/zipball/rv2.beta.7", "body": "Fixes #666 vanishing microblocks with Immibis-Microblocks - yueh" diff --git a/src/test/resources/assets/uvlightmapjsontest/blockstates/uvlblock.json b/src/test/resources/assets/uvlightmapjsontest/blockstates/uvlblock.json index 0e07367bf..c3ea0bc0c 100644 --- a/src/test/resources/assets/uvlightmapjsontest/blockstates/uvlblock.json +++ b/src/test/resources/assets/uvlightmapjsontest/blockstates/uvlblock.json @@ -1,5 +1,5 @@ { - "variants": { - "normal": { "model": "uvlightmapjsontest:uvlblock_vanilla" } - } + "variants": { + "normal": { "model": "uvlightmapjsontest:uvlblock_vanilla" } + } } diff --git a/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock.json b/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock.json index 94093ca02..8ae4133ed 100644 --- a/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock.json +++ b/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock.json @@ -1,87 +1,159 @@ { - "loader": "appliedenergistics2:uvlightmap", - "textures": { - "0": "block/obsidian", - "1": "uvlightmapjsontest:blocks/BlockControllerLights" + "loader": "appliedenergistics2:uvlightmap", + "textures": { + "0": "block/obsidian", + "1": "uvlightmapjsontest:blocks/BlockControllerLights" + }, + "elements": [ + { + "name": "LL", + "from": [4.0, 0.0, 7.0], + "to": [6.0, 16.0, 9.0], + "faces": { + "north": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "east": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "south": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "west": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "up": { "texture": "#0", "uv": [0.0, 0.0, 2.0, 2.0] }, + "down": { "texture": "#0", "uv": [0.0, 0.0, 2.0, 2.0] } + } }, - "elements": [ - { - "name": "LL", - "from": [ 4.0, 0.0, 7.0 ], - "to": [ 6.0, 16.0, 9.0 ], - "faces": { - "north": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "east": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "south": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0] }, - "west": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "up": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }, - "down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] } - } + { + "name": "RL", + "from": [10.0, 0.0, 7.0], + "to": [12.0, 16.0, 9.0], + "faces": { + "north": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "east": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "south": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "west": { "texture": "#0", "uv": [1.0, 0.0, 15.0, 16.0] }, + "up": { "texture": "#0", "uv": [0.0, 0.0, 2.0, 2.0] }, + "down": { "texture": "#0", "uv": [0.0, 0.0, 2.0, 2.0] } + } + }, + { + "name": "B", + "from": [6.0, 7.0, 7.0], + "to": [10.0, 9.0, 9.0], + "faces": { + "north": { "texture": "#0", "uv": [0.0, 1.0, 16.0, 3.0] }, + "east": { "texture": "#0", "uv": [1.0, 1.0, 3.0, 3.0] }, + "south": { "texture": "#0", "uv": [0.0, 1.0, 16.0, 3.0] }, + "west": { "texture": "#0", "uv": [1.0, 1.0, 3.0, 3.0] }, + "up": { "texture": "#0", "uv": [0.0, 1.0, 16.0, 3.0] }, + "down": { "texture": "#0", "uv": [0.0, 1.0, 16.0, 3.0] } + } + }, + { + "name": "LLO", + "from": [4.0, 0.0, 7.0], + "to": [6.0, 16.0, 9.0], + "faces": { + "north": { + "texture": "#1", + "uv": [2.0, 0.0, 4.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - { - "name": "RL", - "from": [ 10.0, 0.0, 7.0 ], - "to": [ 12.0, 16.0, 9.0 ], - "faces": { - "north": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "east": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "south": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "west": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, - "up": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }, - "down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] } - } + "east": { + "texture": "#1", + "uv": [5.0, 0.0, 7.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - { - "name": "B", - "from": [ 6.0, 7.0, 7.0 ], - "to": [ 10.0, 9.0, 9.0 ], - "faces": { - "north": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 3.0 ] }, - "east": { "texture": "#0", "uv": [ 1.0, 1.0, 3.0, 3.0 ] }, - "south": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 3.0 ] }, - "west": { "texture": "#0", "uv": [ 1.0, 1.0, 3.0, 3.0 ] }, - "up": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 3.0 ] }, - "down": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 3.0 ] } - } + "south": { + "texture": "#1", + "uv": [8.0, 0.0, 10.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - { - "name": "LLO", - "from": [ 4.0, 0.0, 7.0 ], - "to": [ 6.0, 16.0, 9.0 ], - "faces": { - "north": { "texture": "#1", "uv": [ 2.0, 0.0, 4.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "east": { "texture": "#1", "uv": [ 5.0, 0.0, 7.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "south": { "texture": "#1", "uv": [ 8.0, 0.0, 10.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "west": { "texture": "#1", "uv": [ 11.0, 0.0, 13.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "up": { "texture": "#1", "uv": [ 6.0, 6.0, 8.0, 8.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "down": { "texture": "#1", "uv": [ 8.0, 8.0, 10.0, 10.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } } - } + "west": { + "texture": "#1", + "uv": [11.0, 0.0, 13.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - { - "name": "RLO", - "from": [ 10.0, 0.0, 7.0 ], - "to": [ 12.0, 16.0, 9.0 ], - "faces": { - "north": { "texture": "#1", "uv": [ 3.0, 0.0, 5.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "east": { "texture": "#1", "uv": [ 5.0, 0.0, 7.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "south": { "texture": "#1", "uv": [ 7.0, 0.0, 9.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "west": { "texture": "#1", "uv": [ 10.0, 0.0, 12.0, 16.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "up": { "texture": "#1", "uv": [ 6.0, 6.0, 8.0, 8.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "down": { "texture": "#1", "uv": [ 7.0, 8.0, 9.0, 10.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } } - } + "up": { + "texture": "#1", + "uv": [6.0, 6.0, 8.0, 8.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - { - "name": "BO", - "from": [ 6.0, 7.0, 7.0 ], - "to": [ 10.0, 9.0, 9.0 ], - "faces": { - "north": { "texture": "#1", "uv": [ 5.0, 6.0, 9.0, 8.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "east": { "texture": "#1", "uv": [ 0.0, 0.0, 2.0, 2.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "south": { "texture": "#1", "uv": [ 5.0, 7.0, 9.0, 9.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "west": { "texture": "#1", "uv": [ 5.0, 3.0, 7.0, 5.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "up": { "texture": "#1", "uv": [ 4.0, 10.0, 8.0, 12.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } }, - "down": { "texture": "#1", "uv": [ 8.0, 8.0, 12.0, 10.0 ], "uvlightmap": { "sky": 0.007, "block": 0.007 } } - } + "down": { + "texture": "#1", + "uv": [8.0, 8.0, 10.0, 10.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } } - ] + } + }, + { + "name": "RLO", + "from": [10.0, 0.0, 7.0], + "to": [12.0, 16.0, 9.0], + "faces": { + "north": { + "texture": "#1", + "uv": [3.0, 0.0, 5.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "east": { + "texture": "#1", + "uv": [5.0, 0.0, 7.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "south": { + "texture": "#1", + "uv": [7.0, 0.0, 9.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "west": { + "texture": "#1", + "uv": [10.0, 0.0, 12.0, 16.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "up": { + "texture": "#1", + "uv": [6.0, 6.0, 8.0, 8.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "down": { + "texture": "#1", + "uv": [7.0, 8.0, 9.0, 10.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + } + } + }, + { + "name": "BO", + "from": [6.0, 7.0, 7.0], + "to": [10.0, 9.0, 9.0], + "faces": { + "north": { + "texture": "#1", + "uv": [5.0, 6.0, 9.0, 8.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "east": { + "texture": "#1", + "uv": [0.0, 0.0, 2.0, 2.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "south": { + "texture": "#1", + "uv": [5.0, 7.0, 9.0, 9.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "west": { + "texture": "#1", + "uv": [5.0, 3.0, 7.0, 5.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "up": { + "texture": "#1", + "uv": [4.0, 10.0, 8.0, 12.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + }, + "down": { + "texture": "#1", + "uv": [8.0, 8.0, 12.0, 10.0], + "uvlightmap": { "sky": 0.007, "block": 0.007 } + } + } + } + ] } diff --git a/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock_vanilla.json b/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock_vanilla.json index d721b7e9f..69f151821 100644 --- a/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock_vanilla.json +++ b/src/test/resources/assets/uvlightmapjsontest/models/block/uvlblock_vanilla.json @@ -1,6 +1,6 @@ { - "parent": "uvlightmapjsontest:block/uvlblock", - "textures": { - "0": "block/diamond_block" - } + "parent": "uvlightmapjsontest:block/uvlblock", + "textures": { + "0": "block/diamond_block" + } } diff --git a/src/test/resources/assets/uvlightmapjsontest/models/item/uvlblock.json b/src/test/resources/assets/uvlightmapjsontest/models/item/uvlblock.json index c435bbbba..4b1ab065f 100644 --- a/src/test/resources/assets/uvlightmapjsontest/models/item/uvlblock.json +++ b/src/test/resources/assets/uvlightmapjsontest/models/item/uvlblock.json @@ -1,3 +1,3 @@ { - "parent": "uvlightmapjsontest:block/uvlblock" + "parent": "uvlightmapjsontest:block/uvlblock" }