diff --git a/AntimatterAPI b/AntimatterAPI index b764d718..2e7bc7fe 160000 --- a/AntimatterAPI +++ b/AntimatterAPI @@ -1 +1 @@ -Subproject commit b764d71881e3690f35e6fc7dac4b0ca260a9563d +Subproject commit 2e7bc7fe174cee6e482e9e77e41531151cb87d78 diff --git a/common/src/main/java/trinsdar/gt4r/blockentity/multi/BlockEntityUpgradeableBasicMultiblock.java b/common/src/main/java/trinsdar/gt4r/blockentity/multi/BlockEntityUpgradeableBasicMultiblock.java index 51ae64e0..9bed459c 100644 --- a/common/src/main/java/trinsdar/gt4r/blockentity/multi/BlockEntityUpgradeableBasicMultiblock.java +++ b/common/src/main/java/trinsdar/gt4r/blockentity/multi/BlockEntityUpgradeableBasicMultiblock.java @@ -96,11 +96,17 @@ public InteractionResult onInteractBoth(BlockState state, Level world, BlockPos if (foundUpgrade == CustomTags.TRANSFORMER_UPGRADES || foundUpgrade == CustomTags.HV_TRANSFORMER_UPGRADES) { energyHandler.ifPresent(e -> e.setInputVoltage(e.getInputVoltage() * 4)); } + if (foundUpgrade == CustomTags.STEAM_UPGRADES){ + energyHandler.ifPresent(e -> { + e.setInputVoltage(0); + //e.extractEu(e.getEnergy(), false); //TODO way to drain only the internal buffer of the machine, not batteries in it + }); + } + if (foundUpgrade == CustomTags.MUFFLER_UPGRADES) { + this.setMuffled(true); + } world.playSound(null, pos, SoundEvents.UI_BUTTON_CLICK, SoundSource.BLOCKS, 1.0f, 1.0f); } - if (foundUpgrade == CustomTags.MUFFLER_UPGRADES) { - this.setMuffled(true); - } return InteractionResult.sidedSuccess(isClientSide()); } diff --git a/common/src/main/java/trinsdar/gt4r/machine/UpgradeableFluidHandler.java b/common/src/main/java/trinsdar/gt4r/machine/UpgradeableFluidHandler.java index 898e451f..fd68d25d 100644 --- a/common/src/main/java/trinsdar/gt4r/machine/UpgradeableFluidHandler.java +++ b/common/src/main/java/trinsdar/gt4r/machine/UpgradeableFluidHandler.java @@ -1,60 +1,35 @@ package trinsdar.gt4r.machine; import muramasa.antimatter.blockentity.BlockEntityMachine; +import muramasa.antimatter.capability.fluid.FluidTanks; import muramasa.antimatter.capability.machine.MachineFluidHandler; +import muramasa.antimatter.gui.SlotType; +import muramasa.antimatter.util.TagUtils; +import trinsdar.gt4r.data.CustomTags; -public class UpgradeableFluidHandler & IUpgradeProvider> extends MachineFluidHandler { +import static muramasa.antimatter.machine.MachineFlag.GUI; - public UpgradeableFluidHandler(T tile) { - super(tile); +public class UpgradeableFluidHandler & IUpgradeProvider> extends MachineFluidHandler { + public UpgradeableFluidHandler(T tile, int capacity, int pressure) { + this(tile, capacity, pressure, tile.has(GUI) ? tile.getMachineType().getSlots(SlotType.FL_IN, tile.getMachineTier()).size() : 0, + tile.has(GUI) ? tile.getMachineType().getSlots(SlotType.FL_OUT, tile.getMachineTier()).size() : 0); } - /*@Override - public long fillDroplets(FluidStack stack, FluidAction action) { - if (stack.getFluid().is(BlockEntitySteamMachine.STEAM)){ - if (tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES)){ - if (stack.getRealAmount() % TesseractGraphWrappers.dropletMultiplier == 0 && stack.getAmount() % 2 == 0){ - long[] toDrain = new long[1]; - toDrain[0] = 0; - tile.energyHandler.ifPresent(e -> { - long euToInject = Math.min(stack.getAmount() / 2, e.getCapacity() - e.getEnergy()); - if (euToInject > 0){ - if (action.execute()){ - Utils.addEnergy(e, euToInject); - } - toDrain[0] = euToInject * 2; - } - }); - if (toDrain[0] > 0){ - return toDrain[0]; - } - + public UpgradeableFluidHandler(T tile, int capacity, int pressure, int inputCount, int outputCount) { + super(tile, capacity, pressure, inputCount + 1, outputCount); + tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> { + for (int i = 0; i < inputCount + 1; i++) { + if (i == inputCount){ + b.tank(f -> f.getFluid().is(TagUtils.getForgelikeFluidTag("steam")) && tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES), capacity); + } else { + b.tank(f -> !f.getFluid().is(TagUtils.getForgelikeFluidTag("steam")) || !tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES), capacity); } } - } - return super.fillDroplets(stack, action); + return b; + })); } - @Override - public boolean canInput(Direction facing) { - if (tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES)) { - return tile.getFacing().get3DDataValue() != facing.get3DDataValue() || tile.getMachineType().allowsFrontCovers(); - } - return super.canInput(facing); - } - - @Override - public boolean canInput(FluidHolder fluid, Direction direction) { - if (fluid.getFluid().is(BlockEntitySteamMachine.STEAM) && tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES)) { - return true; - } - return super.canInput(direction); + public UpgradeableFluidHandler(T tile) { + this(tile, 32000, 1000 * (250 + tile.getMachineTier().getIntegerId())); } - - @Override - public int getSize() { - int tanks = super.getSize(); - if (tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES) && tanks == 0) tanks = 1; - return tanks; - }*/ } diff --git a/common/src/main/java/trinsdar/gt4r/machine/UpgradeableMachineRecipeHandler.java b/common/src/main/java/trinsdar/gt4r/machine/UpgradeableMachineRecipeHandler.java index 170f2910..7bf0364d 100644 --- a/common/src/main/java/trinsdar/gt4r/machine/UpgradeableMachineRecipeHandler.java +++ b/common/src/main/java/trinsdar/gt4r/machine/UpgradeableMachineRecipeHandler.java @@ -2,13 +2,31 @@ import muramasa.antimatter.capability.machine.MachineRecipeHandler; import muramasa.antimatter.blockentity.BlockEntityMachine; +import tesseract.FluidPlatformUtils; +import tesseract.TesseractGraphWrappers; import trinsdar.gt4r.data.CustomTags; +import static trinsdar.gt4r.data.Materials.Steam; + public class UpgradeableMachineRecipeHandler & IUpgradeProvider> extends MachineRecipeHandler { public UpgradeableMachineRecipeHandler(T tile) { super(tile); } + @Override + public boolean consumeResourceForRecipe(boolean simulate) { + if (tile.getUpgrades().containsKey(CustomTags.STEAM_UPGRADES) && !generator){ + if (activeRecipe.getPower() > 0) { + if (tile.fluidHandler.isPresent()) { + return tile.fluidHandler.map(f -> f.drainInput(Steam.getLiquid(getPower() * 2 * TesseractGraphWrappers.dropletMultiplier), simulate).getFluidAmount() == getPower() * 2 * TesseractGraphWrappers.dropletMultiplier).orElse(false); + } else { + return false; + } + } + } + return super.consumeResourceForRecipe(simulate); + } + @Override public int getOverclock() { if (activeRecipe == null) return 0;