From 7503eba7267f425e1c3f8ab42b5271e0d50911ed Mon Sep 17 00:00:00 2001 From: Sara Freimer Date: Sun, 25 Aug 2024 17:15:58 -0500 Subject: [PATCH] Re-use direction and config suppliers throughout the various capability helpers, and use singleton instances for can input and can output checks --- .../generators/common/tile/TileEntityBioGenerator.java | 4 ++-- .../generators/common/tile/TileEntityGasGenerator.java | 4 ++-- .../generators/common/tile/TileEntityGenerator.java | 2 +- .../common/tile/TileEntityHeatGenerator.java | 6 +++--- .../common/tile/TileEntitySolarGenerator.java | 2 +- .../common/tile/TileEntityWindGenerator.java | 2 +- .../common/capabilities/holder/ConfigHolder.java | 10 +++++++--- .../holder/QuantumEntangloporterConfigHolder.java | 2 +- .../common/capabilities/proxy/ProxyFluidHandler.java | 4 ++++ src/main/java/mekanism/common/tile/TileEntityBin.java | 2 +- .../java/mekanism/common/tile/TileEntityChargepad.java | 2 +- .../mekanism/common/tile/TileEntityChemicalTank.java | 4 ++-- .../mekanism/common/tile/TileEntityEnergyCube.java | 4 ++-- .../java/mekanism/common/tile/TileEntityFluidTank.java | 4 ++-- .../common/tile/TileEntityLogisticalSorter.java | 2 +- .../common/tile/TileEntityModificationStation.java | 4 ++-- .../common/tile/TileEntityPersonalStorage.java | 2 +- .../common/tile/TileEntityRadioactiveWasteBarrel.java | 2 +- .../mekanism/common/tile/TileEntitySecurityDesk.java | 2 +- .../mekanism/common/tile/TileEntityTeleporter.java | 4 ++-- .../mekanism/common/tile/base/TileEntityMekanism.java | 3 +++ .../common/tile/component/TileComponentEjector.java | 6 ++---- .../common/tile/factory/TileEntityFactory.java | 4 ++-- .../TileEntityItemStackChemicalToItemStackFactory.java | 2 +- .../common/tile/laser/TileEntityBasicLaser.java | 2 +- .../common/tile/laser/TileEntityLaserTractorBeam.java | 2 +- .../TileEntityAntiprotonicNucleosynthesizer.java | 6 +++--- .../tile/machine/TileEntityChemicalCrystallizer.java | 6 +++--- .../machine/TileEntityChemicalDissolutionChamber.java | 6 +++--- .../common/tile/machine/TileEntityChemicalInfuser.java | 6 +++--- .../tile/machine/TileEntityChemicalOxidizer.java | 6 +++--- .../common/tile/machine/TileEntityChemicalWasher.java | 8 ++++---- .../common/tile/machine/TileEntityCombiner.java | 4 ++-- .../common/tile/machine/TileEntityDigitalMiner.java | 4 ++-- .../tile/machine/TileEntityDimensionalStabilizer.java | 4 ++-- .../common/tile/machine/TileEntityElectricPump.java | 6 +++--- .../tile/machine/TileEntityElectrolyticSeparator.java | 8 ++++---- .../tile/machine/TileEntityFluidicPlenisher.java | 6 +++--- .../tile/machine/TileEntityFormulaicAssemblicator.java | 4 ++-- .../common/tile/machine/TileEntityFuelwoodHeater.java | 4 ++-- .../tile/machine/TileEntityIsotopicCentrifuge.java | 6 +++--- .../tile/machine/TileEntityMetallurgicInfuser.java | 6 +++--- .../tile/machine/TileEntityNutritionalLiquifier.java | 6 +++--- .../tile/machine/TileEntityOredictionificator.java | 2 +- .../common/tile/machine/TileEntityPaintingMachine.java | 6 +++--- .../tile/machine/TileEntityPigmentExtractor.java | 6 +++--- .../common/tile/machine/TileEntityPigmentMixer.java | 6 +++--- .../tile/machine/TileEntityPrecisionSawmill.java | 4 ++-- .../machine/TileEntityPressurizedReactionChamber.java | 8 ++++---- .../common/tile/machine/TileEntityResistiveHeater.java | 6 +++--- .../tile/machine/TileEntityRotaryCondensentrator.java | 8 ++++---- .../common/tile/machine/TileEntitySeismicVibrator.java | 4 ++-- .../tile/machine/TileEntitySolarNeutronActivator.java | 4 ++-- .../tile/multiblock/TileEntityInductionCell.java | 2 +- .../common/tile/multiblock/TileEntitySPSPort.java | 2 +- .../tile/prefab/TileEntityAdvancedElectricMachine.java | 6 +++--- .../tile/prefab/TileEntityConfigurableMachine.java | 2 ++ .../common/tile/prefab/TileEntityElectricMachine.java | 4 ++-- .../common/tile/qio/TileEntityQIODriveArray.java | 2 +- .../common/tile/qio/TileEntityQIOExporter.java | 2 +- 60 files changed, 134 insertions(+), 123 deletions(-) diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index f8d9c270f5c..eeb0e1a9032 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -48,7 +48,7 @@ public TileEntityBioGenerator(BlockPos pos, BlockState state) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { - FluidTankHelper builder = FluidTankHelper.forSide(this::getDirection); + FluidTankHelper builder = FluidTankHelper.forSide(facingSupplier); builder.addTank(bioFuelTank = VariableCapacityFluidTank.input(MekanismGeneratorsConfig.generators.bioTankCapacity, fluidStack -> fluidStack.is(GeneratorTags.Fluids.BIOETHANOL), listener), RelativeSide.LEFT, RelativeSide.RIGHT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM); @@ -58,7 +58,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(fuelSlot = FluidFuelInventorySlot.forFuel(bioFuelTank, stack -> stack.is(MekanismTags.Items.FUELS_BIO) ? 200 : stack.is(MekanismTags.Items.FUELS_BLOCK_BIO) ? 200 * 9 : 0, GeneratorsFluids.BIOETHANOL::getFluidStack, listener, 17, 35), RelativeSide.FRONT, RelativeSide.LEFT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM); diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index 1431aa94768..eefa2f56386 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -59,7 +59,7 @@ public TileEntityGasGenerator(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSide(this::getDirection); + ChemicalTankHelper builder = ChemicalTankHelper.forSide(facingSupplier); builder.addTank(fuelTank = new FuelTank(listener), RelativeSide.LEFT, RelativeSide.RIGHT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM); return builder.build(); } @@ -67,7 +67,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(fuelSlot = ChemicalInventorySlot.fill(fuelTank, listener, 17, 35), RelativeSide.FRONT, RelativeSide.LEFT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM); builder.addSlot(energySlot = EnergyInventorySlot.drain(getEnergyContainer(), listener, 143, 35), RelativeSide.RIGHT); diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntityGenerator.java index 9d1b9fbb70b..1530b1f5c57 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -51,7 +51,7 @@ protected RelativeSide[] getEnergySides() { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = BasicEnergyContainer.output(MachineEnergyContainer.validateBlock(this).getStorage(), listener), getEnergySides()); return builder.build(); } diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 50b6de118d6..ebe0f6dcff0 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -82,7 +82,7 @@ public TileEntityHeatGenerator(BlockPos pos, BlockState state) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { - FluidTankHelper builder = FluidTankHelper.forSide(this::getDirection); + FluidTankHelper builder = FluidTankHelper.forSide(facingSupplier); builder.addTank(lavaTank = VariableCapacityFluidTank.input(MekanismGeneratorsConfig.generators.heatTankCapacity, fluidStack -> fluidStack.is(FluidTags.LAVA), listener), RelativeSide.LEFT, RelativeSide.RIGHT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM); @@ -92,7 +92,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); //Divide the burn time by 20 as that is the ratio of how much a bucket of lava would burn for //TODO: Eventually we may want to grab the 20 dynamically in case some mod is changing the burn time of a lava bucket builder.addSlot(fuelSlot = FluidFuelInventorySlot.forFuel(lavaTank, stack -> stack.getBurnTime(null) / 20, size -> new FluidStack(Fluids.LAVA, size), @@ -104,7 +104,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { @NotNull @Override protected IHeatCapacitorHolder getInitialHeatCapacitors(IContentsListener listener, CachedAmbientTemperature ambientTemperature) { - HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(this::getDirection); + HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(facingSupplier); builder.addCapacitor(heatCapacitor = BasicHeatCapacitor.create(HEAT_CAPACITY, INVERSE_CONDUCTION_COEFFICIENT, INVERSE_INSULATION_COEFFICIENT, ambientTemperature, listener)); return builder.build(); } diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 8bffd9e7a52..1a3c714b262 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -48,7 +48,7 @@ protected TileEntitySolarGenerator(IBlockProvider blockProvider, BlockPos pos, B @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.drain(getEnergyContainer(), listener, 143, 35)); return builder.build(); } diff --git a/src/generators/java/mekanism/generators/common/tile/TileEntityWindGenerator.java b/src/generators/java/mekanism/generators/common/tile/TileEntityWindGenerator.java index 34b391abecf..c8ec19e48ea 100644 --- a/src/generators/java/mekanism/generators/common/tile/TileEntityWindGenerator.java +++ b/src/generators/java/mekanism/generators/common/tile/TileEntityWindGenerator.java @@ -43,7 +43,7 @@ public TileEntityWindGenerator(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.drain(getEnergyContainer(), listener, 143, 35)); return builder.build(); } diff --git a/src/main/java/mekanism/common/capabilities/holder/ConfigHolder.java b/src/main/java/mekanism/common/capabilities/holder/ConfigHolder.java index 4c865ee8863..98e6f5bace9 100644 --- a/src/main/java/mekanism/common/capabilities/holder/ConfigHolder.java +++ b/src/main/java/mekanism/common/capabilities/holder/ConfigHolder.java @@ -19,6 +19,9 @@ public abstract class ConfigHolder implements IHolder { + private static final Predicate CAN_INPUT = ISlotInfo::canInput; + private static final Predicate CAN_OUTPUT = ISlotInfo::canOutput; + /** * Dummy ISlotInfo used for representing we have no config */ @@ -71,12 +74,12 @@ protected ConfigHolder(Supplier facingSupplier, Supplier interactPredicate) { @@ -114,7 +117,8 @@ private ISlotInfo getSlotInfo(Direction side) { //Invalid entire cache and update what direction we had as last if our last direction doesn't match the one we currently are facing cachedSlotInfo.clear(); lastDirection = direction; - } else if (cachedSlotInfo.containsKey(side)) { + } + if (cachedSlotInfo.containsKey(side)) { return cachedSlotInfo.get(side); } ISlotInfo slotInfo; diff --git a/src/main/java/mekanism/common/capabilities/holder/QuantumEntangloporterConfigHolder.java b/src/main/java/mekanism/common/capabilities/holder/QuantumEntangloporterConfigHolder.java index b94563b0b22..14793c82b4f 100644 --- a/src/main/java/mekanism/common/capabilities/holder/QuantumEntangloporterConfigHolder.java +++ b/src/main/java/mekanism/common/capabilities/holder/QuantumEntangloporterConfigHolder.java @@ -7,7 +7,7 @@ public abstract class QuantumEntangloporterConfigHolder extends ConfigHold protected final TileEntityQuantumEntangloporter entangloporter; protected QuantumEntangloporterConfigHolder(TileEntityQuantumEntangloporter entangloporter) { - super(entangloporter::getDirection, entangloporter::getConfig); + super(entangloporter.facingSupplier, entangloporter.configSupplier); this.entangloporter = entangloporter; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/capabilities/proxy/ProxyFluidHandler.java b/src/main/java/mekanism/common/capabilities/proxy/ProxyFluidHandler.java index b22d523ec51..3c791598784 100644 --- a/src/main/java/mekanism/common/capabilities/proxy/ProxyFluidHandler.java +++ b/src/main/java/mekanism/common/capabilities/proxy/ProxyFluidHandler.java @@ -19,6 +19,10 @@ public ProxyFluidHandler(ISidedFluidHandler fluidHandler, @Nullable Direction si this.fluidHandler = fluidHandler; } + public ISidedFluidHandler getInternalHandler() { + return fluidHandler; + } + @Override public int getTanks() { return fluidHandler.getTanks(side); diff --git a/src/main/java/mekanism/common/tile/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index af96cadfe3c..6b506ba8dc5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -72,7 +72,7 @@ protected void presetVariables() { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(binSlot = BinInventorySlot.create(listener, tier)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index e2c6bb888f7..d4fe3c626f4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -44,7 +44,7 @@ public TileEntityChargepad(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener), RelativeSide.BACK, RelativeSide.BOTTOM); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalTank.java b/src/main/java/mekanism/common/tile/TileEntityChemicalTank.java index 3d7067a9028..c28e46f2a07 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalTank.java @@ -90,7 +90,7 @@ protected void presetVariables() { @Override public @Nullable IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(chemicalTank = ChemicalTankChemicalTank.create(tier, listener)); return builder.build(); } @@ -98,7 +98,7 @@ protected void presetVariables() { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(drainSlot = ChemicalInventorySlot.drain(chemicalTank, listener, 16, 16)); builder.addSlot(fillSlot = ChemicalInventorySlot.fill(chemicalTank, listener, 16, 48)); drainSlot.setSlotType(ContainerSlotType.OUTPUT); diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index b51c43c2085..fb332c210b0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -72,7 +72,7 @@ protected void presetVariables() { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = EnergyCubeEnergyContainer.create(tier, listener)); return builder.build(); } @@ -80,7 +80,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(dischargeSlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 17, 35)); builder.addSlot(chargeSlot = EnergyInventorySlot.drain(energyContainer, listener, 143, 35)); dischargeSlot.setSlotOverlay(SlotOverlay.MINUS); diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index 8ec3cdb129a..766ffa852b7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -96,7 +96,7 @@ protected void presetVariables() { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { - FluidTankHelper builder = FluidTankHelper.forSide(this::getDirection); + FluidTankHelper builder = FluidTankHelper.forSide(facingSupplier); builder.addTank(fluidTank = FluidTankFluidTank.create(this, listener)); return builder.build(); } @@ -104,7 +104,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(inputSlot = FluidInventorySlot.input(fluidTank, listener, 146, 19)); builder.addSlot(outputSlot = OutputInventorySlot.at(listener, 146, 51)); inputSlot.setSlotOverlay(SlotOverlay.INPUT); diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index d9b26e61b98..1d7b0e37fae 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -92,7 +92,7 @@ public TileEntityLogisticalSorter(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); //TODO - 1.20.4: Re-evaluate the internal inventory slot and why do we even have a slot on the sorter builder.addSlot(InternalInventorySlot.create(listener), RelativeSide.FRONT); return builder.build(); diff --git a/src/main/java/mekanism/common/tile/TileEntityModificationStation.java b/src/main/java/mekanism/common/tile/TileEntityModificationStation.java index 6262d7df67f..ef82c468ef5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityModificationStation.java +++ b/src/main/java/mekanism/common/tile/TileEntityModificationStation.java @@ -58,7 +58,7 @@ public TileEntityModificationStation(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener), RelativeSide.BACK); return builder.build(); } @@ -70,7 +70,7 @@ public MachineEnergyContainer getEnergyContainer( @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(moduleSlot = InputInventorySlot.at(stack -> stack.getItem() instanceof IModuleItem, listener, 35, 118)); builder.addSlot(containerSlot = InputInventorySlot.at(IModuleHelper.INSTANCE::isModuleContainer, listener, 125, 118)); moduleSlot.setSlotType(ContainerSlotType.NORMAL); diff --git a/src/main/java/mekanism/common/tile/TileEntityPersonalStorage.java b/src/main/java/mekanism/common/tile/TileEntityPersonalStorage.java index e7b5f019c0d..9b8772856aa 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPersonalStorage.java +++ b/src/main/java/mekanism/common/tile/TileEntityPersonalStorage.java @@ -61,7 +61,7 @@ protected TileEntityPersonalStorage(IBlockProvider blockProvider, BlockPos pos, @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); //Note: We always allow manual interaction (even for insertion), as if a player has the GUI open we treat that as they are allowed to interact with it // and if the security mode changes we then boot any players who can't interact with it anymore out of the GUI //Note: We can just directly pass ourselves as a security object as we know we are present and that we aren't just an owner item diff --git a/src/main/java/mekanism/common/tile/TileEntityRadioactiveWasteBarrel.java b/src/main/java/mekanism/common/tile/TileEntityRadioactiveWasteBarrel.java index a557c0a4e80..cbb31509989 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRadioactiveWasteBarrel.java +++ b/src/main/java/mekanism/common/tile/TileEntityRadioactiveWasteBarrel.java @@ -54,7 +54,7 @@ public TileEntityRadioactiveWasteBarrel(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSide(this::getDirection); + ChemicalTankHelper builder = ChemicalTankHelper.forSide(facingSupplier); builder.addTank(chemicalTank = StackedWasteBarrel.create(this, listener), RelativeSide.TOP, RelativeSide.BOTTOM); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java index 9a4353030bc..aca794d4b18 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java +++ b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java @@ -38,7 +38,7 @@ public TileEntitySecurityDesk(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(unlockSlot = SecurityInventorySlot.unlock(this::getOwnerUUID, listener, 146, 18)); builder.addSlot(lockSlot = SecurityInventorySlot.lock(listener, 146, 97)); return builder.build(); diff --git a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index 4c28ecb6ee6..c8131d79c0e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -125,7 +125,7 @@ public TileEntityTeleporter(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener)); return builder.build(); } @@ -133,7 +133,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 153, 7)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java b/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java index 080aed557c9..9db06594ea4 100644 --- a/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java +++ b/src/main/java/mekanism/common/tile/base/TileEntityMekanism.java @@ -186,6 +186,9 @@ public abstract class TileEntityMekanism extends CapabilityTileEntity implements //Methods for implementing ITileDirectional @Nullable private Direction cachedDirection; + + //TODO: Re-evaluate if we should have this be null when we are not a directional tile? + public final Supplier facingSupplier = this::getDirection; //End variables ITileRedstone //Variables for handling ITileRedstone diff --git a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java index 4c3a878c387..257218187a0 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java @@ -62,7 +62,6 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.block.entity.BlockEntity; import net.neoforged.neoforge.capabilities.BlockCapabilityCache; -import net.neoforged.neoforge.common.util.Lazy; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.items.IItemHandler; import org.jetbrains.annotations.NotNull; @@ -140,19 +139,18 @@ public boolean isEjecting(ConfigInfo info, TransmissionType type) { } public void tickServer() { - Lazy facing = Lazy.of(tile::getDirection); for (Map.Entry entry : configInfo.entrySet()) { TransmissionType type = entry.getKey(); ConfigInfo info = entry.getValue(); if (isEjecting(info, type)) { if (type == TransmissionType.ITEM) { if (tickDelay == 0) { - outputItems(facing.get(), info); + outputItems(tile.facingSupplier.get(), info); } else { tickDelay--; } } else if (type != TransmissionType.HEAT) { - eject(type, facing.get(), info); + eject(type, tile.facingSupplier.get(), info); } } } diff --git a/src/main/java/mekanism/common/tile/factory/TileEntityFactory.java b/src/main/java/mekanism/common/tile/factory/TileEntityFactory.java index 914a5052781..7909657c427 100644 --- a/src/main/java/mekanism/common/tile/factory/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/factory/TileEntityFactory.java @@ -177,7 +177,7 @@ protected void presetVariables() { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, () -> { listener.onContentsChanged(); for (FactoryRecipeCacheLookupMonitor cacheLookupMonitor : recipeCacheLookupMonitors) { @@ -190,7 +190,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); addSlots(builder, listener, () -> { listener.onContentsChanged(); //Mark sorting as being needed again diff --git a/src/main/java/mekanism/common/tile/factory/TileEntityItemStackChemicalToItemStackFactory.java b/src/main/java/mekanism/common/tile/factory/TileEntityItemStackChemicalToItemStackFactory.java index 479c7a76983..8d80be385d2 100644 --- a/src/main/java/mekanism/common/tile/factory/TileEntityItemStackChemicalToItemStackFactory.java +++ b/src/main/java/mekanism/common/tile/factory/TileEntityItemStackChemicalToItemStackFactory.java @@ -112,7 +112,7 @@ public TileEntityItemStackChemicalToItemStackFactory(IBlockProvider blockProvide @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); //If the tank's contents change make sure to call our extended content listener that also marks sorting as being needed // as maybe the valid recipes have changed, and we need to sort again and have all recipes know they may need to be rechecked // if they are not still valid diff --git a/src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java b/src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java index 0626e75813d..5bf1cbb725b 100644 --- a/src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java +++ b/src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java @@ -77,7 +77,7 @@ public TileEntityBasicLaser(IBlockProvider blockProvider, BlockPos pos, BlockSta @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); addInitialEnergyContainers(builder, listener); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/laser/TileEntityLaserTractorBeam.java b/src/main/java/mekanism/common/tile/laser/TileEntityLaserTractorBeam.java index a4b0c0d403b..38709add277 100644 --- a/src/main/java/mekanism/common/tile/laser/TileEntityLaserTractorBeam.java +++ b/src/main/java/mekanism/common/tile/laser/TileEntityLaserTractorBeam.java @@ -42,7 +42,7 @@ protected void addInitialEnergyContainers(EnergyContainerHelper builder, IConten @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); for (int slotX = 0; slotX < 9; slotX++) { for (int slotY = 0; slotY < 3; slotY++) { OutputInventorySlot slot = OutputInventorySlot.at(listener, 8 + slotX * 18, 16 + slotY * 18); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityAntiprotonicNucleosynthesizer.java b/src/main/java/mekanism/common/tile/machine/TileEntityAntiprotonicNucleosynthesizer.java index 1e840ef222a..bf1ac5a6c9b 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityAntiprotonicNucleosynthesizer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityAntiprotonicNucleosynthesizer.java @@ -119,7 +119,7 @@ protected RecipeCacheLookupMonitor createNewCacheMonit @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(gasTank = BasicChemicalTank.input(MAX_GAS, gas -> containsRecipeBA(inputSlot.getStack(), gas), this::containsRecipeB, recipeCacheListener)); return builder.build(); } @@ -127,7 +127,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -135,7 +135,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(gasInputSlot = ChemicalInventorySlot.fillOrConvert(gasTank, this::getLevel, listener, 6, 69)); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, gasTank.getStack()), this::containsRecipeA, recipeCacheListener, 26, 40)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java index a8dbbe3564b..6e7fe9d371c 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalCrystallizer.java @@ -90,7 +90,7 @@ public TileEntityChemicalCrystallizer(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(inputTank = BasicChemicalTank.input(MAX_CHEMICAL, this::containsRecipe, recipeCacheListener)); return builder.build(); } @@ -98,7 +98,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -106,7 +106,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = ChemicalInventorySlot.fill(inputTank, listener, 8, 65)); builder.addSlot(outputSlot = OutputInventorySlot.at(recipeCacheUnpauseListener, 129, 57)) .tracksWarnings(slot -> slot.warning(WarningType.NO_SPACE_IN_OUTPUT, getWarningCheck(RecipeError.NOT_ENOUGH_OUTPUT_SPACE))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalDissolutionChamber.java index 386f27aca59..a866d364405 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalDissolutionChamber.java @@ -119,7 +119,7 @@ public TileEntityChemicalDissolutionChamber(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(injectTank = BasicChemicalTank.input(MAX_CHEMICAL, gas -> containsRecipeBA(inputSlot.getStack(), gas), this::containsRecipeB, recipeCacheListener)); builder.addTank(outputTank = BasicChemicalTank.output(MAX_CHEMICAL, recipeCacheUnpauseListener)); return builder.build(); @@ -128,7 +128,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -136,7 +136,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(gasInputSlot = ChemicalInventorySlot.fillOrConvert(injectTank, this::getLevel, listener, 8, 65)); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, injectTank.getStack()), this::containsRecipeA, recipeCacheListener, 28, 36)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalInfuser.java index b79b47f7367..28bfe031f53 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalInfuser.java @@ -127,7 +127,7 @@ public TileEntityChemicalInfuser(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(leftTank = BasicChemicalTank.input(MAX_GAS, gas -> containsRecipe(gas, rightTank.getStack()), this::containsRecipe, recipeCacheListener)); builder.addTank(rightTank = BasicChemicalTank.input(MAX_GAS, gas -> containsRecipe(gas, leftTank.getStack()), this::containsRecipe, recipeCacheListener)); builder.addTank(centerTank = BasicChemicalTank.output(MAX_GAS, recipeCacheUnpauseListener)); @@ -137,7 +137,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -145,7 +145,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(leftInputSlot = ChemicalInventorySlot.fill(leftTank, listener, 6, 56)); builder.addSlot(rightInputSlot = ChemicalInventorySlot.fill(rightTank, listener, 154, 56)); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(centerTank, listener, 80, 65)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalOxidizer.java index 2af166aafa2..36f854024e2 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalOxidizer.java @@ -92,7 +92,7 @@ public TileEntityChemicalOxidizer(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(gasTank = BasicChemicalTank.output(MAX_GAS, recipeCacheUnpauseListener)); return builder.build(); } @@ -100,7 +100,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -108,7 +108,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(this::containsRecipe, recipeCacheListener, 26, 36)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(gasTank, listener, 152, 55)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalWasher.java index f4a755263a4..d2bd7ff2a7d 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityChemicalWasher.java @@ -120,7 +120,7 @@ public TileEntityChemicalWasher(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(inputTank = BasicChemicalTank.input(MAX_SLURRY, slurry -> containsRecipeBA(fluidTank.getFluid(), slurry), this::containsRecipeB, recipeCacheListener)); builder.addTank(outputTank = BasicChemicalTank.output(MAX_SLURRY, recipeCacheUnpauseListener)); @@ -130,7 +130,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - FluidTankHelper builder = FluidTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + FluidTankHelper builder = FluidTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(fluidTank = BasicFluidTank.input(MAX_FLUID, fluid -> containsRecipeAB(fluid, inputTank.getStack()), this::containsRecipeA, recipeCacheListener)); return builder.build(); } @@ -138,7 +138,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, ICon @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -146,7 +146,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(fluidSlot = FluidInventorySlot.fill(fluidTank, listener, 180, 71)); //Output slot for the fluid container that was used as an input builder.addSlot(fluidOutputSlot = OutputInventorySlot.at(listener, 180, 102)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityCombiner.java b/src/main/java/mekanism/common/tile/machine/TileEntityCombiner.java index 4fab21b1b46..e86a1365b68 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityCombiner.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityCombiner.java @@ -87,7 +87,7 @@ public TileEntityCombiner(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -95,7 +95,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(mainInputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, extraInputSlot.getStack()), this::containsRecipeA, recipeCacheListener, 64, 17) ).tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java index 5d9f68caa54..064a3df51cd 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java @@ -171,7 +171,7 @@ public TileEntityDigitalMiner(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MinerEnergyContainer.input(this, listener), RelativeSide.LEFT, RelativeSide.RIGHT, RelativeSide.BOTTOM); return builder.build(); } @@ -185,7 +185,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { //Ensure we recheck if our overflow can fit anywhere recheckOverflow = true; }; - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection, side -> side == RelativeSide.TOP, side -> side == RelativeSide.BACK); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier, side -> side == RelativeSide.TOP, side -> side == RelativeSide.BACK); //Allow insertion manually or internally, or if it is a replace stack BiPredicate<@NotNull ItemStack, @NotNull AutomationType> canInsert = (stack, automationType) -> automationType != AutomationType.EXTERNAL || isReplaceTarget(stack.getItem()); //Allow extraction if it is manual or for internal usage, or if it is not a replace stack diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityDimensionalStabilizer.java b/src/main/java/mekanism/common/tile/machine/TileEntityDimensionalStabilizer.java index fcb975076a9..953ad5bd5cd 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityDimensionalStabilizer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityDimensionalStabilizer.java @@ -70,7 +70,7 @@ public TileEntityDimensionalStabilizer(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = FixedUsageEnergyContainer.input(this, BASE_ENERGY_CALCULATOR, listener)); return builder.build(); } @@ -78,7 +78,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 143, 35), RelativeSide.BACK); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityElectricPump.java b/src/main/java/mekanism/common/tile/machine/TileEntityElectricPump.java index d16632be8c9..8c7ab34d806 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityElectricPump.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityElectricPump.java @@ -120,7 +120,7 @@ public TileEntityElectricPump(BlockPos pos, BlockState state) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { - FluidTankHelper builder = FluidTankHelper.forSide(this::getDirection); + FluidTankHelper builder = FluidTankHelper.forSide(facingSupplier); builder.addTank(fluidTank = BasicFluidTank.output(MAX_FLUID, listener), RelativeSide.TOP); return builder.build(); } @@ -128,7 +128,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener), RelativeSide.BACK); return builder.build(); } @@ -136,7 +136,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(inputSlot = FluidInventorySlot.drain(fluidTank, listener, 28, 20), RelativeSide.TOP); builder.addSlot(outputSlot = OutputInventorySlot.at(listener, 28, 51), RelativeSide.BOTTOM); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 143, 35), RelativeSide.BACK); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/machine/TileEntityElectrolyticSeparator.java index 3393a334e56..a1a053243c5 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityElectrolyticSeparator.java @@ -175,7 +175,7 @@ public TileEntityElectrolyticSeparator(BlockPos pos, BlockState state) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - FluidTankHelper builder = FluidTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + FluidTankHelper builder = FluidTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(fluidTank = BasicFluidTank.input(MAX_FLUID, this::containsRecipe, recipeCacheListener)); return builder.build(); } @@ -183,7 +183,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, ICon @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(leftTank = BasicChemicalTank.output(MAX_GAS, recipeCacheUnpauseListener)); builder.addTank(rightTank = BasicChemicalTank.output(MAX_GAS, recipeCacheUnpauseListener)); return builder.build(); @@ -192,7 +192,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = FixedUsageEnergyContainer.input(this, BASE_ENERGY_CALCULATOR, recipeCacheUnpauseListener)); return builder.build(); } @@ -200,7 +200,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(fluidSlot = FluidInventorySlot.fill(fluidTank, listener, 26, 35)); builder.addSlot(leftOutputSlot = ChemicalInventorySlot.drain(leftTank, listener, 59, 52)); builder.addSlot(rightOutputSlot = ChemicalInventorySlot.drain(rightTank, listener, 101, 52)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityFluidicPlenisher.java b/src/main/java/mekanism/common/tile/machine/TileEntityFluidicPlenisher.java index 1540d7d703d..6bb7caff0f4 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityFluidicPlenisher.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityFluidicPlenisher.java @@ -93,7 +93,7 @@ public TileEntityFluidicPlenisher(BlockPos pos, BlockState state) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { - FluidTankHelper builder = FluidTankHelper.forSide(this::getDirection); + FluidTankHelper builder = FluidTankHelper.forSide(facingSupplier); builder.addTank(fluidTank = BasicFluidTank.input(MAX_FLUID, this::isValidFluid, listener), RelativeSide.TOP); return builder.build(); } @@ -101,7 +101,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener), RelativeSide.BACK); return builder.build(); } @@ -109,7 +109,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(inputSlot = FluidInventorySlot.fill(fluidTank, listener, 28, 20), RelativeSide.TOP); builder.addSlot(outputSlot = OutputInventorySlot.at(listener, 28, 51), RelativeSide.BOTTOM); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 143, 35), RelativeSide.BACK); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityFormulaicAssemblicator.java b/src/main/java/mekanism/common/tile/machine/TileEntityFormulaicAssemblicator.java index f7c43aff686..895d523763c 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityFormulaicAssemblicator.java @@ -125,7 +125,7 @@ public TileEntityFormulaicAssemblicator(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener)); return builder.build(); } @@ -148,7 +148,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { recalculateRecipe(); }; - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); //If the formula slot changes we want to make sure to recheck the recipe builder.addSlot(formulaSlot = BasicInventorySlot.at(FORMULA_SLOT_VALIDATOR, listenAndRecheckRecipe, 6, 26, 1)) .setSlotOverlay(SlotOverlay.FORMULA); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityFuelwoodHeater.java b/src/main/java/mekanism/common/tile/machine/TileEntityFuelwoodHeater.java index 55b41a88684..c0d0300985e 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityFuelwoodHeater.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityFuelwoodHeater.java @@ -50,7 +50,7 @@ public TileEntityFuelwoodHeater(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(fuelSlot = FuelInventorySlot.forFuel(stack -> stack.getBurnTime(null), listener, 15, 29)); return builder.build(); } @@ -58,7 +58,7 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { @NotNull @Override protected IHeatCapacitorHolder getInitialHeatCapacitors(IContentsListener listener, CachedAmbientTemperature ambientTemperature) { - HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(this::getDirection); + HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(facingSupplier); builder.addCapacitor(heatCapacitor = BasicHeatCapacitor.create(HEAT_CAPACITY, INVERSE_CONDUCTION_COEFFICIENT, INVERSE_INSULATION_COEFFICIENT, ambientTemperature, listener)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityIsotopicCentrifuge.java b/src/main/java/mekanism/common/tile/machine/TileEntityIsotopicCentrifuge.java index f0830790cd0..a8bdff0258b 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityIsotopicCentrifuge.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityIsotopicCentrifuge.java @@ -104,7 +104,7 @@ public TileEntityIsotopicCentrifuge(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); //Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive builder.addTank(inputTank = BasicChemicalTank.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputTank), BasicChemicalTank.alwaysTrueBi, this::containsRecipe, ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener)); @@ -115,7 +115,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -123,7 +123,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = ChemicalInventorySlot.fill(inputTank, listener, 5, 56)); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(outputTank, listener, 155, 56)); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 155, 14)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/machine/TileEntityMetallurgicInfuser.java index b8aa0eb1df8..1936b140f53 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityMetallurgicInfuser.java @@ -113,7 +113,7 @@ public TileEntityMetallurgicInfuser(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(infusionTank = BasicChemicalTank.create(MAX_INFUSE, BasicChemicalTank.alwaysTrueBi, (infuseType, automationType) -> containsRecipeBA(inputSlot.getStack(), infuseType), this::containsRecipeB, recipeCacheListener)); return builder.build(); @@ -122,7 +122,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -130,7 +130,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(infusionSlot = ChemicalInventorySlot.fillOrConvert(infusionTank, this::getLevel, listener, 17, 35)); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, infusionTank.getStack()), this::containsRecipeA, recipeCacheListener, 51, 43)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityNutritionalLiquifier.java b/src/main/java/mekanism/common/tile/machine/TileEntityNutritionalLiquifier.java index 4530251db41..fd18ef06cb1 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityNutritionalLiquifier.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityNutritionalLiquifier.java @@ -111,7 +111,7 @@ public TileEntityNutritionalLiquifier(BlockPos pos, BlockState state) { @NotNull @Override public IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - FluidTankHelper builder = FluidTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + FluidTankHelper builder = FluidTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(fluidTank = BasicFluidTank.output(MAX_FLUID, recipeCacheUnpauseListener)); return builder.build(); } @@ -119,7 +119,7 @@ public IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IConten @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -127,7 +127,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(TileEntityNutritionalLiquifier::isValidInput, recipeCacheListener, 26, 36) ).tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(outputSlot = OutputInventorySlot.at(listener, 110, 36)) diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityOredictionificator.java b/src/main/java/mekanism/common/tile/machine/TileEntityOredictionificator.java index 8e62437cdf4..2f2433c1fee 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityOredictionificator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityOredictionificator.java @@ -63,7 +63,7 @@ public TileEntityOredictionificator(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); //Only allow inserting items with tags that match filters, but mark all items that have any filterable tags as valid builder.addSlot(inputSlot = InputInventorySlot.at(item -> hasResult(filterManager.getEnabledFilters(), item), this::hasFilterableTags, listener, 56, 115)); builder.addSlot(outputSlot = OutputInventorySlot.at(listener, 164, 115)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPaintingMachine.java b/src/main/java/mekanism/common/tile/machine/TileEntityPaintingMachine.java index 073e4a859cd..5cffdc413e8 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPaintingMachine.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPaintingMachine.java @@ -109,7 +109,7 @@ public TileEntityPaintingMachine(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(pigmentTank = BasicChemicalTank.input(MAX_PIGMENT, pigment -> containsRecipeBA(inputSlot.getStack(), pigment), this::containsRecipeB, recipeCacheListener)); return builder.build(); @@ -118,7 +118,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -126,7 +126,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(pigmentInputSlot = ChemicalInventorySlot.fill(pigmentTank, listener, 6, 56)); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, pigmentTank.getStack()), this::containsRecipeA, recipeCacheListener, 45, 35)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPigmentExtractor.java b/src/main/java/mekanism/common/tile/machine/TileEntityPigmentExtractor.java index 0995c7b8240..0f4dbfd12f5 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPigmentExtractor.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPigmentExtractor.java @@ -94,7 +94,7 @@ public TileEntityPigmentExtractor(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(pigmentTank = BasicChemicalTank.output(MAX_PIGMENT, recipeCacheUnpauseListener)); return builder.build(); } @@ -102,7 +102,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -110,7 +110,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(this::containsRecipe, recipeCacheListener, 26, 36)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(pigmentTank, listener, 152, 55)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPigmentMixer.java b/src/main/java/mekanism/common/tile/machine/TileEntityPigmentMixer.java index 7e5da4a3581..be20b10f4a3 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPigmentMixer.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPigmentMixer.java @@ -132,7 +132,7 @@ public TileEntityPigmentMixer(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(leftInputTank = BasicChemicalTank.input(MAX_INPUT_PIGMENT, pigment -> containsRecipe(pigment, rightInputTank.getStack()), this::containsRecipe, recipeCacheListener)); builder.addTank(rightInputTank = BasicChemicalTank.input(MAX_INPUT_PIGMENT, pigment -> containsRecipe(pigment, leftInputTank.getStack()), @@ -144,7 +144,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -152,7 +152,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(leftInputSlot = ChemicalInventorySlot.fill(leftInputTank, listener, 6, 56)); builder.addSlot(rightInputSlot = ChemicalInventorySlot.fill(rightInputTank, listener, 154, 56)); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(outputTank, listener, 80, 65)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPrecisionSawmill.java b/src/main/java/mekanism/common/tile/machine/TileEntityPrecisionSawmill.java index 62808f0d501..d3df6853f58 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPrecisionSawmill.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPrecisionSawmill.java @@ -87,7 +87,7 @@ public TileEntityPrecisionSawmill(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -95,7 +95,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(this::containsRecipe, recipeCacheListener, 56, 17)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(outputSlot = OutputInventorySlot.at(recipeCacheUnpauseListener, 116, 35)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java b/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java index a239528e811..fe6e51ec187 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityPressurizedReactionChamber.java @@ -122,7 +122,7 @@ public TileEntityPressurizedReactionChamber(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); //Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive builder.addTank(inputGasTank = BasicChemicalTank.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputGasTank), (gas, automationType) -> containsRecipeCAB(inputSlot.getStack(), inputFluidTank.getFluid(), gas), this::containsRecipeC, @@ -134,7 +134,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - FluidTankHelper builder = FluidTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + FluidTankHelper builder = FluidTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(inputFluidTank = BasicFluidTank.input(MAX_FLUID, fluid -> containsRecipeBAC(inputSlot.getStack(), fluid, inputGasTank.getStack()), this::containsRecipeB, recipeCacheListener)); return builder.build(); @@ -143,7 +143,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, ICon @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = PRCEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -151,7 +151,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeABC(item, inputFluidTank.getFluid(), inputGasTank.getStack()), this::containsRecipeA, recipeCacheListener, 54, 35)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(NOT_ENOUGH_ITEM_INPUT_ERROR))); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/machine/TileEntityResistiveHeater.java index 1e362934d62..631c259492e 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityResistiveHeater.java @@ -67,7 +67,7 @@ public TileEntityResistiveHeater(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = ResistiveHeaterEnergyContainer.input(this, listener), RelativeSide.LEFT, RelativeSide.RIGHT); return builder.build(); } @@ -75,7 +75,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IHeatCapacitorHolder getInitialHeatCapacitors(IContentsListener listener, CachedAmbientTemperature ambientTemperature) { - HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(this::getDirection); + HeatCapacitorHelper builder = HeatCapacitorHelper.forSide(facingSupplier); builder.addCapacitor(heatCapacitor = BasicHeatCapacitor.create(HEAT_CAPACITY, INVERSE_CONDUCTION_COEFFICIENT, INVERSE_INSULATION_COEFFICIENT, ambientTemperature, listener)); return builder.build(); } @@ -83,7 +83,7 @@ protected IHeatCapacitorHolder getInitialHeatCapacitors(IContentsListener listen @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 15, 35)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/machine/TileEntityRotaryCondensentrator.java index 0434d965547..17bd7a3f9e5 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityRotaryCondensentrator.java @@ -147,7 +147,7 @@ public TileEntityRotaryCondensentrator(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); //Only allow extraction builder.addTank(gasTank = BasicChemicalTank.create(CAPACITY, (gas, automationType) -> automationType == AutomationType.MANUAL || mode, (gas, automationType) -> automationType == AutomationType.INTERNAL || !mode, this::isValidGas, ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener)); @@ -161,7 +161,7 @@ private boolean isValidGas(@NotNull Chemical gas) { @NotNull @Override protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - FluidTankHelper builder = FluidTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + FluidTankHelper builder = FluidTankHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addTank(fluidTank = BasicFluidTank.create(CAPACITY, (fluid, automationType) -> automationType == AutomationType.MANUAL || !mode, (fluid, automationType) -> automationType == AutomationType.INTERNAL || mode, this::isValidFluid, recipeCacheListener)); return builder.build(); @@ -174,7 +174,7 @@ private boolean isValidFluid(@NotNull FluidStack fluidStack) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -182,7 +182,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); BooleanSupplier modeSupplier = this::getMode; builder.addSlot(gasInputSlot = ChemicalInventorySlot.rotaryDrain(gasTank, modeSupplier, listener, 5, 25)); builder.addSlot(gasOutputSlot = ChemicalInventorySlot.rotaryFill(gasTank, modeSupplier, listener, 5, 56)); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/machine/TileEntitySeismicVibrator.java index db5b9da1861..1d6dacb4699 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntitySeismicVibrator.java @@ -44,7 +44,7 @@ public TileEntitySeismicVibrator(BlockPos pos, BlockState state) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener), RelativeSide.BACK); return builder.build(); } @@ -52,7 +52,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getLevel, listener, 143, 35)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/machine/TileEntitySolarNeutronActivator.java b/src/main/java/mekanism/common/tile/machine/TileEntitySolarNeutronActivator.java index 79748213a5b..7aaec93873f 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntitySolarNeutronActivator.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntitySolarNeutronActivator.java @@ -100,7 +100,7 @@ public TileEntitySolarNeutronActivator(BlockPos pos, BlockState state) { @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); //Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive builder.addTank(inputTank = BasicChemicalTank.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputTank), BasicChemicalTank.alwaysTrueBi, this::containsRecipe, ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener)); @@ -111,7 +111,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = ChemicalInventorySlot.fill(inputTank, listener, 5, 56)); builder.addSlot(outputSlot = ChemicalInventorySlot.drain(outputTank, listener, 155, 56)); inputSlot.setSlotType(ContainerSlotType.INPUT); diff --git a/src/main/java/mekanism/common/tile/multiblock/TileEntityInductionCell.java b/src/main/java/mekanism/common/tile/multiblock/TileEntityInductionCell.java index 5e4b2a063e9..c0aa219bffc 100644 --- a/src/main/java/mekanism/common/tile/multiblock/TileEntityInductionCell.java +++ b/src/main/java/mekanism/common/tile/multiblock/TileEntityInductionCell.java @@ -24,7 +24,7 @@ public TileEntityInductionCell(IBlockProvider blockProvider, BlockPos pos, Block @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.internal(this, listener)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/multiblock/TileEntitySPSPort.java b/src/main/java/mekanism/common/tile/multiblock/TileEntitySPSPort.java index caebb05ad71..03a30525d71 100644 --- a/src/main/java/mekanism/common/tile/multiblock/TileEntitySPSPort.java +++ b/src/main/java/mekanism/common/tile/multiblock/TileEntitySPSPort.java @@ -54,7 +54,7 @@ protected boolean onUpdateServer(SPSMultiblockData multiblock) { @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection); + EnergyContainerHelper builder = EnergyContainerHelper.forSide(facingSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, listener)); return builder.build(); } diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java index 648a6017962..cf33a21a200 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java @@ -124,7 +124,7 @@ public TileEntityAdvancedElectricMachine(IBlockProvider blockProvider, BlockPos @NotNull @Override public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(this::getDirection, this::getConfig); + ChemicalTankHelper builder = ChemicalTankHelper.forSideWithConfig(facingSupplier, configSupplier); BiPredicate<@NotNull Chemical, @NotNull AutomationType> canExtract = allowExtractingChemical() ? BasicChemicalTank.alwaysTrueBi : BasicChemicalTank.notExternal; builder.addTank(chemicalTank = BasicChemicalTank.create(MAX_GAS, canExtract, (gas, automationType) -> containsRecipeBA(inputSlot.getStack(), gas), this::containsRecipeB, recipeCacheListener)); @@ -134,7 +134,7 @@ public IChemicalTankHolder getInitialChemicalTanks(IContentsListener listener, I @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -142,7 +142,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(item -> containsRecipeAB(item, chemicalTank.getStack()), this::containsRecipeA, recipeCacheListener, 64, 17)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(secondarySlot = ChemicalInventorySlot.fillOrConvert(chemicalTank, this::getLevel, listener, 64, 53)); diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityConfigurableMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityConfigurableMachine.java index 8b48fe826a5..b879bf87a4c 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityConfigurableMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityConfigurableMachine.java @@ -1,5 +1,6 @@ package mekanism.common.tile.prefab; +import java.util.function.Supplier; import mekanism.api.providers.IBlockProvider; import mekanism.common.block.attribute.Attribute; import mekanism.common.block.attribute.AttributeSideConfig; @@ -17,6 +18,7 @@ public abstract class TileEntityConfigurableMachine extends TileEntityMekanism i public TileComponentEjector ejectorComponent; public final TileComponentConfig configComponent;//does not tick! + public final Supplier configSupplier = this::getConfig; public TileEntityConfigurableMachine(IBlockProvider blockProvider, BlockPos pos, BlockState state) { super(blockProvider, pos, state); diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java index dc6c266c885..c338725f63a 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricMachine.java @@ -74,7 +74,7 @@ public TileEntityElectricMachine(IBlockProvider blockProvider, BlockPos pos, Blo @NotNull @Override protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(this::getDirection, this::getConfig); + EnergyContainerHelper builder = EnergyContainerHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addContainer(energyContainer = MachineEnergyContainer.input(this, recipeCacheUnpauseListener)); return builder.build(); } @@ -82,7 +82,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers(IContentsListener li @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener, IContentsListener recipeCacheListener, IContentsListener recipeCacheUnpauseListener) { - InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(this::getDirection, this::getConfig); + InventorySlotHelper builder = InventorySlotHelper.forSideWithConfig(facingSupplier, configSupplier); builder.addSlot(inputSlot = InputInventorySlot.at(this::containsRecipe, recipeCacheListener, 64, 17)) .tracksWarnings(slot -> slot.warning(WarningType.NO_MATCHING_RECIPE, getWarningCheck(RecipeError.NOT_ENOUGH_INPUT))); builder.addSlot(outputSlot = OutputInventorySlot.at(recipeCacheUnpauseListener, 116, 35)) diff --git a/src/main/java/mekanism/common/tile/qio/TileEntityQIODriveArray.java b/src/main/java/mekanism/common/tile/qio/TileEntityQIODriveArray.java index 63dddb4e129..c7beabd4164 100644 --- a/src/main/java/mekanism/common/tile/qio/TileEntityQIODriveArray.java +++ b/src/main/java/mekanism/common/tile/qio/TileEntityQIODriveArray.java @@ -48,7 +48,7 @@ public TileEntityQIODriveArray(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); final int xSize = 176; driveSlots = new ArrayList<>(); for (int y = 0; y < 2; y++) { diff --git a/src/main/java/mekanism/common/tile/qio/TileEntityQIOExporter.java b/src/main/java/mekanism/common/tile/qio/TileEntityQIOExporter.java index ec696ef5e9e..2f95882ef84 100644 --- a/src/main/java/mekanism/common/tile/qio/TileEntityQIOExporter.java +++ b/src/main/java/mekanism/common/tile/qio/TileEntityQIOExporter.java @@ -86,7 +86,7 @@ public TileEntityQIOExporter(BlockPos pos, BlockState state) { @NotNull @Override protected IInventorySlotHolder getInitialInventory(IContentsListener listener) { - InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection); + InventorySlotHelper builder = InventorySlotHelper.forSide(facingSupplier); //TODO - 1.20.4: Re-evaluate the internal inventory slot and why do we even have a slot on the exporter // I think it is so that transporters can connect, but it seems a bit silly builder.addSlot(InternalInventorySlot.create(listener), RelativeSide.BACK);