Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vacuum distillation tower #335

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package supersymmetry.api.metatileentity.multiblock;

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 net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.NotNull;
import supersymmetry.common.recipes.DistillationTowerRecipeLogic;

import java.util.function.Function;

import static gregtech.api.util.RelativeDirection.UP;

public class MetaTileEntityOrderedDT extends RecipeMapMultiblockController implements IDistillationTower {
protected DistillationTowerLogicHandler handler;

public MetaTileEntityOrderedDT(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap) {
super(metaTileEntityId, recipeMap);
this.handler = new DistillationTowerLogicHandler(this);
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;
}

@Override
public boolean allowSameFluidFillForOutputs() {
return false;
}

public DistillationTowerLogicHandler getHandler() {
return handler;
}


/**
* Used if MultiblockPart Abilities need to be sorted a certain way, like
* Distillation Tower and Assembly Line. <br>
* <br>
* There will be <i>consequences</i> if this is changed. Make sure to set the logic handler to one with
* a properly overriden {@link DistillationTowerLogicHandler#determineOrderedFluidOutputs()}
*/
@Override
protected Function<BlockPos, Integer> multiblockPartSorter() {
return UP.getSorter(getFrontFacing(), getUpwardsFacing(), isFlipped());
}

@Override
protected void formStructure(PatternMatchContext context) {
super.formStructure(context);
if (this.handler == null || this.structurePattern == null) return;
handler.determineLayerCount(this.structurePattern);
handler.determineOrderedFluidOutputs();
}


@Override
public void invalidateStructure() {
super.invalidateStructure();
if (this.handler != null) handler.invalidate();
}


@Override
public int getFluidOutputLimit() {
if (this.handler != null) return this.handler.getLayerCount();
else return super.getFluidOutputLimit();
}

@Override
public boolean allowsExtendedFacing() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiFluidHatch;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT;
import supersymmetry.api.recipes.SuSyRecipeMaps;
import supersymmetry.client.renderer.textures.SusyTextures;
import supersymmetry.common.blocks.BlockSuSyMultiblockCasing;
Expand All @@ -24,10 +25,9 @@

import static gregtech.api.util.RelativeDirection.*;

public class MetaTileEntityHighPressureCryogenicDistillationPlant extends RecipeMapMultiblockController {
public class MetaTileEntityHighPressureCryogenicDistillationPlant extends MetaTileEntityOrderedDT {
public MetaTileEntityHighPressureCryogenicDistillationPlant(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SuSyRecipeMaps.HIGH_PRESSURE_CRYOGENIC_DISTILLATION);
this.recipeMapWorkable = new MultiblockRecipeLogic(this, false);
}

public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT;
import supersymmetry.api.recipes.SuSyRecipeMaps;
import supersymmetry.client.renderer.textures.SusyTextures;
import supersymmetry.common.blocks.BlockSuSyMultiblockCasing;
Expand All @@ -22,7 +23,7 @@

import static gregtech.api.util.RelativeDirection.*;

public class MetaTileEntityHighTemperatureDistillationTower extends RecipeMapMultiblockController {
public class MetaTileEntityHighTemperatureDistillationTower extends MetaTileEntityOrderedDT {

public MetaTileEntityHighTemperatureDistillationTower(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SuSyRecipeMaps.HIGH_TEMPERATURE_DISTILLATION);
Expand Down Expand Up @@ -60,11 +61,6 @@ protected BlockPattern createStructurePattern() {
.build();
}

@Override
protected boolean allowSameFluidFillForOutputs() {
return false;
}

@Override
public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) {
return SusyTextures.SILICON_CARBIDE_CASING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jetbrains.annotations.NotNull;
import supersymmetry.api.metatileentity.multiblock.ICryogenicProvider;
import supersymmetry.api.metatileentity.multiblock.ICryogenicReceiver;
import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT;
import supersymmetry.api.recipes.SuSyRecipeMaps;
import supersymmetry.client.renderer.textures.SusyTextures;
import supersymmetry.common.blocks.BlockSuSyMultiblockCasing;
Expand All @@ -28,13 +29,12 @@

import static gregtech.api.util.RelativeDirection.*;

public class MetaTileEntityLowPressureCryogenicDistillationPlant extends RecipeMapMultiblockController implements ICryogenicProvider {
public class MetaTileEntityLowPressureCryogenicDistillationPlant extends MetaTileEntityOrderedDT implements ICryogenicProvider {

private @Nullable ICryogenicReceiver receiver;

public MetaTileEntityLowPressureCryogenicDistillationPlant(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SuSyRecipeMaps.LOW_PRESSURE_CRYOGENIC_DISTILLATION);
this.recipeMapWorkable = new MultiblockRecipeLogic(this, false);
}

public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,29 @@
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 RecipeMapMultiblockController implements IDistillationTower {
public class MetaTileEntitySieveDistillationTower extends MetaTileEntityOrderedDT implements IDistillationTower {
protected DistillationTowerLogicHandler handler;

public MetaTileEntitySieveDistillationTower(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SIEVE_DISTILLATION_RECIPES);
this.recipeMapWorkable = new SieveDistillationTowerRecipeLogic(this);
this.handler = new DistillationTowerLogicHandler(this);
}

public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
return new MetaTileEntitySieveDistillationTower(this.metaTileEntityId);
}

/**
* Used if MultiblockPart Abilities need to be sorted a certain way, like
* Distillation Tower and Assembly Line. <br>
* <br>
* There will be <i>consequences</i> if this is changed. Make sure to set the logic handler to one with
* a properly overriden {@link DistillationTowerLogicHandler#determineOrderedFluidOutputs()}
*/
@Override
protected Function<BlockPos, Integer> multiblockPartSorter() {
return UP.getSorter(getFrontFacing(), getUpwardsFacing(), isFlipped());
}

/**
* Whether this multi can be rotated or face upwards. <br>
* <br>
* There will be <i>consequences</i> if this returns true. Make sure to set the logic handler to one with
* a properly overriden {@link DistillationTowerLogicHandler#determineOrderedFluidOutputs()}
*/
@Override
public boolean allowsExtendedFacing() {
return false;
}

@Override
protected void addDisplayText(List<ITextComponent> textList) {
if (isStructureFormed()) {
Expand All @@ -93,19 +71,6 @@ protected void addDisplayText(List<ITextComponent> textList) {
super.addDisplayText(textList);
}

@Override
protected void formStructure(PatternMatchContext context) {
super.formStructure(context);
if (this.handler == null || this.structurePattern == null) return;
handler.determineLayerCount(this.structurePattern);
handler.determineOrderedFluidOutputs();
}

@Override
public void invalidateStructure() {
super.invalidateStructure();
if (this.handler != null) handler.invalidate();
}

@Override
protected @NotNull BlockPattern createStructurePattern() {
Expand All @@ -125,11 +90,6 @@ public void invalidateStructure() {
.build();
}

@Override
public boolean allowSameFluidFillForOutputs() {
return false;
}

@SideOnly(Side.CLIENT)
@Override
public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) {
Expand All @@ -156,64 +116,4 @@ protected ICubeRenderer getFrontOverlay() {
return Textures.DISTILLATION_TOWER_OVERLAY;
}

@Override
public int getFluidOutputLimit() {
if (this.handler != null) return this.handler.getLayerCount();
else return super.getFluidOutputLimit();
}

protected class SieveDistillationTowerRecipeLogic extends MultiblockRecipeLogic {

public SieveDistillationTowerRecipeLogic(MetaTileEntitySieveDistillationTower tileEntity) {
super(tileEntity);
}

@Override
protected void outputRecipeOutputs() {
GTTransferUtils.addItemsToItemHandler(getOutputInventory(), false, itemOutputs);
handler.applyFluidToOutputs(fluidOutputs, true);
}

@Override
protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
@NotNull IItemHandlerModifiable importInventory,
@NotNull IMultipleTankHandler importFluids) {
this.overclockResults = calculateOverclock(recipe);

modifyOverclockPost(overclockResults, recipe.getRecipePropertyStorage());

if (!hasEnoughPower(overclockResults)) {
return false;
}

IItemHandlerModifiable exportInventory = getOutputInventory();

// We have already trimmed outputs and chanced outputs at this time
// Attempt to merge all outputs + chanced outputs into the output bus, to prevent voiding chanced outputs
if (!metaTileEntity.canVoidRecipeItemOutputs() &&
!GTTransferUtils.addItemsToItemHandler(exportInventory, true, recipe.getAllItemOutputs())) {
this.isOutputsFull = true;
return false;
}

// We have already trimmed fluid outputs at this time
if (!metaTileEntity.canVoidRecipeFluidOutputs() &&
!handler.applyFluidToOutputs(recipe.getAllFluidOutputs(), false)) {
this.isOutputsFull = true;
return false;
}

this.isOutputsFull = false;
if (recipe.matches(true, importInventory, importFluids)) {
this.metaTileEntity.addNotifiedInput(importInventory);
return true;
}
return false;
}

@Override
protected IMultipleTankHandler getOutputTank() {
return handler.getFluidTanks();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jetbrains.annotations.NotNull;
import supersymmetry.api.metatileentity.multiblock.ICryogenicProvider;
import supersymmetry.api.metatileentity.multiblock.ICryogenicReceiver;
import supersymmetry.api.metatileentity.multiblock.MetaTileEntityOrderedDT;
import supersymmetry.api.recipes.SuSyRecipeMaps;
import supersymmetry.common.blocks.BlockSuSyMultiblockCasing;
import supersymmetry.common.blocks.SuSyBlocks;
Expand All @@ -27,13 +28,12 @@

import static gregtech.api.util.RelativeDirection.*;

public class MetaTileEntitySingleColumnCryogenicDistillationPlant extends RecipeMapMultiblockController implements ICryogenicProvider {
public class MetaTileEntitySingleColumnCryogenicDistillationPlant extends MetaTileEntityOrderedDT implements ICryogenicProvider {

private @Nullable ICryogenicReceiver receiver;

public MetaTileEntitySingleColumnCryogenicDistillationPlant(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SuSyRecipeMaps.SINGLE_COLUMN_CRYOGENIC_DISTILLATION);
this.recipeMapWorkable = new MultiblockRecipeLogic(this, false);
}

public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
Expand Down
Loading