diff --git a/src/main/java/supersymmetry/api/capability/impl/ExtendedDTLogicHandler.java b/src/main/java/supersymmetry/api/capability/impl/ExtendedDTLogicHandler.java new file mode 100644 index 000000000..556659699 --- /dev/null +++ b/src/main/java/supersymmetry/api/capability/impl/ExtendedDTLogicHandler.java @@ -0,0 +1,88 @@ +package supersymmetry.api.capability.impl; + +import gregtech.api.capability.IDistillationTower; +import gregtech.api.capability.impl.DistillationTowerLogicHandler; +import gregtech.api.capability.impl.FluidTankList; +import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart; +import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.pattern.BlockPattern; +import gregtech.api.util.GTLog; +import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.fluids.capability.IFluidHandler; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + + +public class ExtendedDTLogicHandler extends DistillationTowerLogicHandler { + + // This have to be an anonymous class. Just blame ceu. + protected static final FakeTank BLACK_HOLE = new FakeTank() { + }; + + // Y offset from the controller to the first layer that output hatch can be placed on + // As a function since monsters like LP Cryo DT exist + protected final Function offsetCounter; + // The index of the extendable aisle repetition + protected final int outputLayerIndex; + + public ExtendedDTLogicHandler(IDistillationTower tower, int outputLayerIndex, Function offsetCounter) { + super(tower); + this.outputLayerIndex = outputLayerIndex; + this.offsetCounter = offsetCounter; + } + + @Override + public void determineLayerCount(@NotNull BlockPattern structurePattern) { + this.setLayerCount(structurePattern.formedRepetitionCount[outputLayerIndex]); + } + + @Override + public void determineOrderedFluidOutputs() { + // noinspection SimplifyStreamApiCallChains + List fluidExportParts = tower.getMultiblockParts().stream() + .filter(iMultiblockPart -> iMultiblockPart instanceof IMultiblockAbilityPart abilityPart && + abilityPart.getAbility() == MultiblockAbility.EXPORT_FLUIDS && + abilityPart instanceof MetaTileEntityMultiblockPart) + .map(iMultiblockPart -> (MetaTileEntityMultiblockPart) iMultiblockPart) + .collect(Collectors.toList()); + // the fluidExportParts should come sorted in smallest Y first, largest Y last. + List orderedHandlerList = new ObjectArrayList<>(); + List tankList = new ObjectArrayList<>(); + + int firstY = tower.getPos().getY() + offsetCounter.apply(getLayerCount()); + int exportIndex = 0; + for (int y = firstY; y < firstY + this.getLayerCount(); y++) { + if (fluidExportParts.size() <= exportIndex) { + orderedHandlerList.add(BLACK_HOLE); + tankList.add(BLACK_HOLE); + continue; + } + MetaTileEntityMultiblockPart part = fluidExportParts.get(exportIndex); + if (part.getPos().getY() == y) { + List hatchTanks = new ObjectArrayList<>(); + // noinspection unchecked + ((IMultiblockAbilityPart) part).registerAbilities(hatchTanks); + orderedHandlerList.add(new FluidTankList(false, hatchTanks)); + tankList.addAll(hatchTanks); + exportIndex++; + } else if (part.getPos().getY() > y) { + orderedHandlerList.add(BLACK_HOLE); + tankList.add(BLACK_HOLE); + } else { + GTLog.logger.error( + "The Distillation Tower at {} had a fluid export hatch with an unexpected Y position.", + tower.getPos()); + tower.invalidateStructure(); + this.setOrderedFluidOutputs(new ObjectArrayList<>()); + this.setFluidTanks(new FluidTankList(false)); + } + } + this.setOrderedFluidOutputs(orderedHandlerList); + this.setFluidTanks(new FluidTankList(tower.allowSameFluidFillForOutputs(), tankList)); + } +} diff --git a/src/main/java/supersymmetry/api/capability/impl/LPDistillationTowerLogic.java b/src/main/java/supersymmetry/api/capability/impl/LPDistillationTowerLogic.java deleted file mode 100644 index cdaf8b01a..000000000 --- a/src/main/java/supersymmetry/api/capability/impl/LPDistillationTowerLogic.java +++ /dev/null @@ -1,116 +0,0 @@ -package supersymmetry.api.capability.impl; - -import gregtech.api.capability.IDistillationTower; -import gregtech.api.capability.impl.DistillationTowerLogicHandler; -import gregtech.api.capability.impl.FluidTankList; -import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart; -import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.util.GTLog; -import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.fluids.capability.FluidTankProperties; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.IFluidTankProperties; - -import java.util.List; -import java.util.stream.Collectors; - -public class LPDistillationTowerLogic extends DistillationTowerLogicHandler { - public LPDistillationTowerLogic(IDistillationTower tower, int yOffset) { - super(tower); - } - - - public void determineOrderedFluidOutputs() { - List fluidExportParts = this.tower.getMultiblockParts().stream().filter((iMultiblockPart) -> { - if (iMultiblockPart instanceof IMultiblockAbilityPart) { - IMultiblockAbilityPart abilityPart = (IMultiblockAbilityPart)iMultiblockPart; - if (abilityPart.getAbility() == MultiblockAbility.EXPORT_FLUIDS && abilityPart instanceof MetaTileEntityMultiblockPart) { - return true; - } - } - - return false; - }).map((iMultiblockPart) -> (MetaTileEntityMultiblockPart)iMultiblockPart).collect(Collectors.toList()); - List orderedHandlerList = new ObjectArrayList(); - List tankList = new ObjectArrayList(); - int firstY = this.tower.getPos().getY() - this.getLayerCount(); - int exportIndex = 0; - - for(int y = firstY; y < firstY + this.getLayerCount(); ++y) { - if (fluidExportParts.size() <= exportIndex) { - orderedHandlerList.add(FakeTank.INSTANCE); - tankList.add(FakeTank.INSTANCE); - } else { - MetaTileEntityMultiblockPart part = fluidExportParts.get(exportIndex); - if (part.getPos().getY() == y) { - List hatchTanks = new ObjectArrayList(); - ((IMultiblockAbilityPart)part).registerAbilities(hatchTanks); - orderedHandlerList.add(new FluidTankList(false, hatchTanks)); - tankList.addAll(hatchTanks); - ++exportIndex; - } else if (part.getPos().getY() > y) { - orderedHandlerList.add(FakeTank.INSTANCE); - tankList.add(FakeTank.INSTANCE); - } else { - GTLog.logger.error("The Distillation Tower at {} had a fluid export hatch with an unexpected Y position.", this.tower.getPos()); - this.tower.invalidateStructure(); - this.setOrderedFluidOutputs(new ObjectArrayList()); - this.setFluidTanks(new FluidTankList(false)); - } - } - } - - this.setOrderedFluidOutputs(orderedHandlerList); - this.setFluidTanks(new FluidTankList(this.tower.allowSameFluidFillForOutputs(), tankList)); - } - - protected static class FakeTank implements IFluidHandler, IFluidTank { - protected static final FakeTank INSTANCE = new FakeTank(); - public static final FluidTankInfo FAKE_TANK_INFO = new FluidTankInfo((FluidStack)null, Integer.MAX_VALUE); - public static final IFluidTankProperties FAKE_TANK_PROPERTIES = new FluidTankProperties((FluidStack)null, Integer.MAX_VALUE, true, false); - public static final IFluidTankProperties[] FAKE_TANK_PROPERTIES_ARRAY; - - protected FakeTank() { - } - - public IFluidTankProperties[] getTankProperties() { - return FAKE_TANK_PROPERTIES_ARRAY; - } - - public FluidStack getFluid() { - return null; - } - - public int getFluidAmount() { - return 0; - } - - public int getCapacity() { - return Integer.MAX_VALUE; - } - - public FluidTankInfo getInfo() { - return FAKE_TANK_INFO; - } - - public int fill(FluidStack resource, boolean doFill) { - return resource.amount; - } - - public FluidStack drain(FluidStack resource, boolean doDrain) { - return null; - } - - public FluidStack drain(int maxDrain, boolean doDrain) { - return null; - } - - static { - FAKE_TANK_PROPERTIES_ARRAY = new IFluidTankProperties[]{FAKE_TANK_PROPERTIES}; - } - } -} diff --git a/src/main/java/supersymmetry/api/metatileentity/multiblock/MetaTileEntityOrderedDT.java b/src/main/java/supersymmetry/api/metatileentity/multiblock/MetaTileEntityOrderedDT.java index 33e402735..56056ac01 100644 --- a/src/main/java/supersymmetry/api/metatileentity/multiblock/MetaTileEntityOrderedDT.java +++ b/src/main/java/supersymmetry/api/metatileentity/multiblock/MetaTileEntityOrderedDT.java @@ -2,45 +2,37 @@ import gregtech.api.capability.IDistillationTower; import gregtech.api.capability.impl.DistillationTowerLogicHandler; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; -import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.PatternMatchContext; import gregtech.api.recipes.RecipeMap; -import gregtech.client.renderer.ICubeRenderer; +import gregtech.client.utils.TooltipHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import supersymmetry.common.recipes.DistillationTowerRecipeLogic; +import java.util.List; import java.util.function.Function; import static gregtech.api.util.RelativeDirection.UP; -public class MetaTileEntityOrderedDT extends RecipeMapMultiblockController implements IDistillationTower { +public abstract class MetaTileEntityOrderedDT extends RecipeMapMultiblockController implements IDistillationTower { + protected DistillationTowerLogicHandler handler; public MetaTileEntityOrderedDT(ResourceLocation metaTileEntityId, RecipeMap recipeMap) { super(metaTileEntityId, recipeMap); - this.handler = new DistillationTowerLogicHandler(this); + this.handler = createHandler(); this.recipeMapWorkable = new DistillationTowerRecipeLogic(this); } - @Override - protected @NotNull BlockPattern createStructurePattern() { - return null; - } - - @Override - public ICubeRenderer getBaseTexture(IMultiblockPart iMultiblockPart) { - return null; - } - - @Override - public MetaTileEntity createMetaTileEntity(IGregTechTileEntity iGregTechTileEntity) { - return null; + @NotNull + public DistillationTowerLogicHandler createHandler() { + return new DistillationTowerLogicHandler(this); } @Override @@ -52,7 +44,6 @@ public DistillationTowerLogicHandler getHandler() { return handler; } - /** * Used if MultiblockPart Abilities need to be sorted a certain way, like * Distillation Tower and Assembly Line.
@@ -91,4 +82,11 @@ public int getFluidOutputLimit() { public boolean allowsExtendedFacing() { return false; } + + @Override + public void addInformation(ItemStack stack, @Nullable World world, @NotNull List tooltip, boolean advanced) { + super.addInformation(stack, world, tooltip, advanced); + tooltip.add(I18n.format("gregtech.machine.ordered_dt.tooltip.1")); + tooltip.add(I18n.format("gregtech.machine.ordered_dt.tooltip.2")); + } } diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighPressureCryogenicDistillationPlant.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighPressureCryogenicDistillationPlant.java index 610c6664e..bc446734c 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighPressureCryogenicDistillationPlant.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighPressureCryogenicDistillationPlant.java @@ -1,5 +1,6 @@ package supersymmetry.common.metatileentities.multi.electric; +import gregtech.api.capability.impl.DistillationTowerLogicHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; @@ -13,6 +14,8 @@ import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiFluidHatch; import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import supersymmetry.api.capability.impl.ExtendedDTLogicHandler; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.client.renderer.textures.SusyTextures; @@ -28,44 +31,55 @@ public MetaTileEntityHighPressureCryogenicDistillationPlant(ResourceLocation met super(metaTileEntityId, SuSyRecipeMaps.HIGH_PRESSURE_CRYOGENIC_DISTILLATION); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityHighPressureCryogenicDistillationPlant(this.metaTileEntityId); } + @Override + @NotNull protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle("CCC", "CCC", "CCC") .aisle("CSC", "CFC", "CCC") - .aisle("XXX", "XFX", "XXX").setRepeatable(1,16) + .aisle("XXX", "XFX", "XXX").setRepeatable(1, 16) .aisle("DDD", "DDD", "DDD") .where('S', this.selfPredicate()) - .where('C', states(this.getCasingState()) + .where('C', states(getCasingState()) .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1)) .or(autoAbilities(false, true, false, false, false, false, false).setExactLimit(1))) .where('F', states(SuSyBlocks.MULTIBLOCK_CASING.getState(BlockSuSyMultiblockCasing.CasingType.SIEVE_TRAY))) .where('X', states(getCasingState()) .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.EXPORT_FLUIDS).stream() - .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) .setMaxLayerLimited(1)) .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.IMPORT_FLUIDS).stream() - .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) - .setMaxLayerLimited(1))) - .where('D', states(this.getCasingState())) + .setMaxLayerLimited(4))) + .where('D', states(getCasingState())) .where('#', air()) .build(); } - public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { - return Textures.FROST_PROOF_CASING; + @Override + @NotNull + public DistillationTowerLogicHandler createHandler() { + return new ExtendedDTLogicHandler(this, 2, ignored -> 1); } + protected static IBlockState getCasingState() { return MetaBlocks.METAL_CASING.getState(MetalCasingType.ALUMINIUM_FROSTPROOF); } + @Override + public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { + return Textures.FROST_PROOF_CASING; + } + @Nonnull @Override protected ICubeRenderer getFrontOverlay() { diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighTemperatureDistillationTower.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighTemperatureDistillationTower.java index c26c72081..a1f4df16f 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighTemperatureDistillationTower.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityHighTemperatureDistillationTower.java @@ -4,14 +4,13 @@ import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; import gregtech.client.renderer.ICubeRenderer; import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiFluidHatch; import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.NotNull; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.client.renderer.textures.SusyTextures; @@ -19,7 +18,6 @@ import supersymmetry.common.blocks.SuSyBlocks; import javax.annotation.Nonnull; -import java.util.function.Function; import static gregtech.api.util.RelativeDirection.*; @@ -35,11 +33,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { } @Override - protected Function multiblockPartSorter() { - return BlockPos::getY; - } - - @Override + @NotNull protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle("YSY", "YYY", "YYY") @@ -80,9 +74,4 @@ protected ICubeRenderer getFrontOverlay() { public int getFluidOutputLimit() { return getOutputFluidInventory().getTanks(); } - - @Override - public boolean allowsExtendedFacing() { - return false; - } } diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLowPressureCryogenicDistillationPlant.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLowPressureCryogenicDistillationPlant.java index c70cd1b26..5bf3c1be1 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLowPressureCryogenicDistillationPlant.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLowPressureCryogenicDistillationPlant.java @@ -1,5 +1,6 @@ package supersymmetry.common.metatileentities.multi.electric; +import gregtech.api.capability.impl.DistillationTowerLogicHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; @@ -14,7 +15,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.NotNull; -import supersymmetry.api.capability.impl.LPDistillationTowerLogic; +import supersymmetry.api.capability.impl.ExtendedDTLogicHandler; import supersymmetry.api.metatileentity.multiblock.ICryogenicProvider; import supersymmetry.api.metatileentity.multiblock.ICryogenicReceiver; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; @@ -30,25 +31,28 @@ public class MetaTileEntityLowPressureCryogenicDistillationPlant extends MetaTileEntityOrderedDT implements ICryogenicProvider { - private @Nullable ICryogenicReceiver receiver; + @Nullable + private ICryogenicReceiver receiver; public MetaTileEntityLowPressureCryogenicDistillationPlant(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SuSyRecipeMaps.LOW_PRESSURE_CRYOGENIC_DISTILLATION); - this.handler = new LPDistillationTowerLogic(this, -1); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityLowPressureCryogenicDistillationPlant(this.metaTileEntityId); } - protected @NotNull BlockPattern createStructurePattern() { + @Override + @NotNull + protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle("CCC", "CCC", "CCC") .aisle("XXX", "XFX", "XXX").setRepeatable(1,16) .aisle("CSC", "E E", "CEC") .aisle("DDD", "DDD", "DDD") .where('S', this.selfPredicate()) - .where('C', states(this.getCasingState()) + .where('C', states(getCasingState()) .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1)) .or(autoAbilities(false, true, false, false, false, false, false).setExactLimit(1))) @@ -61,15 +65,21 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.IMPORT_FLUIDS).stream() .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) - .setMaxLayerLimited(1))) - .where('D', states(this.getCasingState())) - .where('E', states(this.getCasingState()) + .setMaxLayerLimited(4))) + .where('D', states(getCasingState())) + .where('E', states(getCasingState()) .or(abilities(MultiblockAbility.PASSTHROUGH_HATCH))) .where('#', air()) .where(' ', cryogenicRecieverPredicate()) .build(); } + @Override + @NotNull + public DistillationTowerLogicHandler createHandler() { + return new ExtendedDTLogicHandler(this, 1, i -> -i); + } + @Override public void invalidateStructure() { super.invalidateStructure(); @@ -79,14 +89,15 @@ public void invalidateStructure() { } } - public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { - return Textures.FROST_PROOF_CASING; - } - protected static IBlockState getCasingState() { return MetaBlocks.METAL_CASING.getState(MetalCasingType.ALUMINIUM_FROSTPROOF); } + @Override + public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { + return Textures.FROST_PROOF_CASING; + } + @Nonnull @Override protected ICubeRenderer getFrontOverlay() { @@ -97,9 +108,4 @@ protected ICubeRenderer getFrontOverlay() { public void setReceiver(@NotNull ICryogenicReceiver receiver) { this.receiver = receiver; } - - @Override - public boolean allowsExtendedFacing() { - return false; - } } diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySieveDistillationTower.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySieveDistillationTower.java index 0d645377f..1e287d4e3 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySieveDistillationTower.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySieveDistillationTower.java @@ -1,57 +1,45 @@ package supersymmetry.common.metatileentities.multi.electric; -import gregtech.api.capability.IDistillationTower; -import gregtech.api.capability.IMultipleTankHandler; -import gregtech.api.capability.impl.DistillationTowerLogicHandler; -import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; -import gregtech.api.pattern.PatternMatchContext; -import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; -import gregtech.api.util.GTTransferUtils; import gregtech.api.util.GTUtility; import gregtech.api.util.TextComponentUtil; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; import gregtech.common.blocks.BlockMetalCasing; import gregtech.common.blocks.MetaBlocks; +import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiFluidHatch; import gregtech.core.sound.GTSoundEvents; import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandlerModifiable; import org.jetbrains.annotations.NotNull; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; import supersymmetry.common.blocks.BlockSuSyMultiblockCasing; import supersymmetry.common.blocks.SuSyBlocks; -import supersymmetry.common.recipes.DistillationTowerRecipeLogic; import java.util.List; -import java.util.function.Function; import static gregtech.api.util.RelativeDirection.*; import static supersymmetry.api.recipes.SuSyRecipeMaps.SIEVE_DISTILLATION_RECIPES; -public class MetaTileEntitySieveDistillationTower extends MetaTileEntityOrderedDT implements IDistillationTower { - protected DistillationTowerLogicHandler handler; +public class MetaTileEntitySieveDistillationTower extends MetaTileEntityOrderedDT { public MetaTileEntitySieveDistillationTower(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SIEVE_DISTILLATION_RECIPES); - this.handler = new DistillationTowerLogicHandler(this); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntitySieveDistillationTower(this.metaTileEntityId); } @@ -72,9 +60,9 @@ protected void addDisplayText(List textList) { super.addDisplayText(textList); } - @Override - protected @NotNull BlockPattern createStructurePattern() { + @NotNull + protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle("YSY", "YYY", "YYY") .aisle("FXF", "X#X", "FXF").setRepeatable(1, 11) @@ -85,7 +73,10 @@ protected void addDisplayText(List textList) { .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) .or(abilities(MultiblockAbility.IMPORT_FLUIDS).setMinGlobalLimited(1).setMaxGlobalLimited(2))) .where('X', states(getCasingState()) - .or(abilities(MultiblockAbility.EXPORT_FLUIDS).setMaxLayerLimited(1, 1)) + .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.EXPORT_FLUIDS).stream() + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) + .toArray(MetaTileEntity[]::new)) + .setMaxLayerLimited(1)) .or(autoAbilities(true, false))) .where('#', states(getSieveState())) .where('F', frames(Materials.StainlessSteel)) @@ -98,11 +89,11 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { return Textures.CLEAN_STAINLESS_STEEL_CASING; } - protected IBlockState getSieveState() { + protected static IBlockState getSieveState() { return SuSyBlocks.MULTIBLOCK_CASING.getState(BlockSuSyMultiblockCasing.CasingType.SIEVE_TRAY); } - protected IBlockState getCasingState() { + protected static IBlockState getCasingState() { return MetaBlocks.METAL_CASING.getState(BlockMetalCasing.MetalCasingType.STAINLESS_CLEAN); } diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySingleColumnCryogenicDistillationPlant.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySingleColumnCryogenicDistillationPlant.java index e10077e79..ddc311863 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySingleColumnCryogenicDistillationPlant.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntitySingleColumnCryogenicDistillationPlant.java @@ -1,11 +1,10 @@ package supersymmetry.common.metatileentities.multi.electric; -import gregtech.api.capability.impl.MultiblockRecipeLogic; +import gregtech.api.capability.impl.DistillationTowerLogicHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; import gregtech.client.renderer.ICubeRenderer; @@ -16,6 +15,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.NotNull; +import supersymmetry.api.capability.impl.ExtendedDTLogicHandler; import supersymmetry.api.metatileentity.multiblock.ICryogenicProvider; import supersymmetry.api.metatileentity.multiblock.ICryogenicReceiver; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; @@ -23,7 +23,6 @@ import supersymmetry.common.blocks.BlockSuSyMultiblockCasing; import supersymmetry.common.blocks.SuSyBlocks; -import javax.annotation.Nonnull; import javax.annotation.Nullable; import static gregtech.api.util.RelativeDirection.*; @@ -36,41 +35,54 @@ public MetaTileEntitySingleColumnCryogenicDistillationPlant(ResourceLocation met super(metaTileEntityId, SuSyRecipeMaps.SINGLE_COLUMN_CRYOGENIC_DISTILLATION); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntitySingleColumnCryogenicDistillationPlant(this.metaTileEntityId); } - protected @NotNull BlockPattern createStructurePattern() { + @Override + @NotNull + protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle("CCC", "CCC", "CCC") .aisle("CSC", "CFC", "CCC") - .aisle("XXX", "XFX", "XXX").setRepeatable(1,16) + .aisle("XXX", "XFX", "XXX").setRepeatable(1, 16) .aisle("CCC", "CCC", "CCC") .aisle("CEC", "E E", "CEC") .aisle("DDD", "DED", "DDD") .where('S', this.selfPredicate()) - .where('C', states(this.getCasingState()) + .where('C', states(getCasingState()) .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1)) .or(autoAbilities(false, true, false, false, false, false, false).setExactLimit(1))) .where('F', states(SuSyBlocks.MULTIBLOCK_CASING.getState(BlockSuSyMultiblockCasing.CasingType.STRUCTURAL_PACKING))) .where('X', states(getCasingState()) .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.EXPORT_FLUIDS).stream() - .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) .setMaxLayerLimited(1)) .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.IMPORT_FLUIDS).stream() - .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) - .setMaxLayerLimited(1))) - .where('D', states(this.getCasingState())) - .where('E', states(this.getCasingState()) + .setMaxLayerLimited(4))) + .where('D', states(getCasingState())) + .where('E', states(getCasingState()) .or(abilities(MultiblockAbility.PASSTHROUGH_HATCH))) .where('#', air()) .where(' ', cryogenicRecieverPredicate()) .build(); } + @Override + @NotNull + public DistillationTowerLogicHandler createHandler() { + return new ExtendedDTLogicHandler(this, 2, ignored -> 1); + } + + protected static IBlockState getCasingState() { + return MetaBlocks.METAL_CASING.getState(MetalCasingType.ALUMINIUM_FROSTPROOF); + } + @Override public void invalidateStructure() { super.invalidateStructure(); @@ -84,11 +96,8 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { return Textures.FROST_PROOF_CASING; } - protected static IBlockState getCasingState() { - return MetaBlocks.METAL_CASING.getState(MetalCasingType.ALUMINIUM_FROSTPROOF); - } - - @Nonnull + @Override + @NotNull protected ICubeRenderer getFrontOverlay() { return Textures.BLAST_FURNACE_OVERLAY; } @@ -98,8 +107,4 @@ public void setReceiver(@NotNull ICryogenicReceiver receiver) { this.receiver = receiver; } - @Override - public boolean allowsExtendedFacing() { - return false; - } } diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityVacuumDistillationTower.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityVacuumDistillationTower.java index ff0b936fa..1d4d79a4e 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityVacuumDistillationTower.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityVacuumDistillationTower.java @@ -1,13 +1,10 @@ package supersymmetry.common.metatileentities.multi.electric; -import gregtech.api.capability.IDistillationTower; import gregtech.api.capability.impl.DistillationTowerLogicHandler; -import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.unification.material.Materials; @@ -24,6 +21,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; +import supersymmetry.api.capability.impl.ExtendedDTLogicHandler; import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.client.renderer.textures.SusyTextures; @@ -40,10 +39,19 @@ public MetaTileEntityVacuumDistillationTower(ResourceLocation metaTileEntityId) super(metaTileEntityId, SuSyRecipeMaps.VACUUM_DISTILLATION_RECIPES); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityVacuumDistillationTower(this.metaTileEntityId); } + @Override + @NotNull + public DistillationTowerLogicHandler createHandler() { + return new ExtendedDTLogicHandler(this, 3, ignored -> 3); + } + + @Override + @NotNull protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) .aisle(" CSC ", "CCCCCC", "CCCCCC", "CCCCCC", " CCC ") @@ -51,30 +59,26 @@ protected BlockPattern createStructurePattern() { .aisle(" CCC ", "C#F#CC", "CFFFCC", "C#F#CC", " CCC ") .aisle(" XXX ", "X#F#D ", "XFFFD ", "X#F#D ", " XXX ").setRepeatable(1, 12) .aisle(" DDD ", "DDDDD ", "DDDDD ", "DDDDD ", " DDD ") - .where('S', this.selfPredicate()) - .where('G', states(this.getGlassState())) - .where('P', states(this.getPipeCasingState())) + .where('S', selfPredicate()) + .where('G', states(getGlassState())) + .where('P', states(getPipeCasingState())) .where('F', frames(Materials.Steel)) - .where('C', states(this.getCasingState()) + .where('C', states(getCasingState()) .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) .or(abilities(MultiblockAbility.IMPORT_FLUIDS).setMaxGlobalLimited(2)) .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1))) .where('I', abilities(MultiblockAbility.EXPORT_ITEMS).setMaxGlobalLimited(1)) - .where('D', states(this.getCasingState())) + .where('D', states(getCasingState())) .where('X', states(getCasingState()) .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.EXPORT_FLUIDS).stream() - .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) - .toArray(MetaTileEntity[]::new)) - .setMaxLayerLimited(1)) + .filter(mte -> !(mte instanceof MetaTileEntityMultiFluidHatch)) + .toArray(MetaTileEntity[]::new)) + .setMaxLayerLimited(1)) .or(autoAbilities(true, false))) .where('#', air()) .build(); } - public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { - return Textures.SOLID_STEEL_CASING; - } - protected static IBlockState getGlassState() { return MetaBlocks.TRANSPARENT_CASING.getState(BlockGlassCasing.CasingType.TEMPERED_GLASS); } @@ -87,7 +91,13 @@ protected static IBlockState getPipeCasingState() { return MetaBlocks.BOILER_CASING.getState(BoilerCasingType.STEEL_PIPE); } - public void addInformation(ItemStack stack, @Nullable World player, List tooltip, boolean advanced) { + @Override + public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { + return Textures.SOLID_STEEL_CASING; + } + + @Override + public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { super.addInformation(stack, player, tooltip, advanced); tooltip.add(TooltipHelper.RAINBOW_SLOW + I18n.format("gregtech.machine.perfect_oc", new Object[0])); } diff --git a/src/main/java/supersymmetry/common/recipes/DistillationTowerRecipeLogic.java b/src/main/java/supersymmetry/common/recipes/DistillationTowerRecipeLogic.java index 433e2a806..a503d8572 100644 --- a/src/main/java/supersymmetry/common/recipes/DistillationTowerRecipeLogic.java +++ b/src/main/java/supersymmetry/common/recipes/DistillationTowerRecipeLogic.java @@ -10,6 +10,7 @@ import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT; public class DistillationTowerRecipeLogic extends MultiblockRecipeLogic { + public DistillationTowerRecipeLogic(RecipeMapMultiblockController tileEntity) { super(tileEntity); } diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index a54598ef5..df7361e3d 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -759,6 +759,10 @@ gregtech.machine.fluid_hatch.export_9x.hv.name=HV Nonuple Output Hatch gregtech.machine.dumping_hatch=Dumping Hatch gregtech.machine.dumping_hatch.lv.name=Dumping Hatch +# Distillation tower explanations +gregtech.machine.ordered_dt.tooltip.1=Fluid input and output hatches are on the same layers +gregtech.machine.ordered_dt.tooltip.2=§cNot putting a fluid output in the Nth layer from the bottom voids the Nth output§7 + # Logistics gregtech.machine.delegator.tooltip.non_recursion=§6Cannot be attached to other Delegators! gregtech.top.delegator.delegating_face=Delegating: %s