Skip to content

Commit

Permalink
fixed muffler upgrade, made steam upgrade actually add an additional …
Browse files Browse the repository at this point in the history
…tank
  • Loading branch information
Trinsdar committed Mar 2, 2024
1 parent fb3154c commit ea62e41
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion AntimatterAPI
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends BlockEntityMachine<T> & IUpgradeProvider> extends MachineFluidHandler<T> {
import static muramasa.antimatter.machine.MachineFlag.GUI;

public UpgradeableFluidHandler(T tile) {
super(tile);
public class UpgradeableFluidHandler<T extends BlockEntityMachine<T> & IUpgradeProvider> extends MachineFluidHandler<T> {
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;
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends BlockEntityMachine<T> & IUpgradeProvider> extends MachineRecipeHandler<T> {
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;
Expand Down

0 comments on commit ea62e41

Please sign in to comment.