Skip to content

Commit

Permalink
Multi fluid hatch additions and recipe changes (GregTechCEu#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Oct 15, 2023
1 parent affcc87 commit dc3c19d
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public class MetaTileEntities {
public static final MetaTileEntityItemBus[] ITEM_EXPORT_BUS = new MetaTileEntityItemBus[GTValues.UHV + 1];
public static final MetaTileEntityFluidHatch[] FLUID_IMPORT_HATCH = new MetaTileEntityFluidHatch[GTValues.UHV + 1];
public static final MetaTileEntityFluidHatch[] FLUID_EXPORT_HATCH = new MetaTileEntityFluidHatch[GTValues.UHV + 1];
public static final MetaTileEntityMultiFluidHatch[] MULTI_FLUID_IMPORT_HATCH = new MetaTileEntityMultiFluidHatch[2];
public static final MetaTileEntityMultiFluidHatch[] MULTI_FLUID_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[2];
public static final MetaTileEntityMultiFluidHatch[] QUADRUPLE_IMPORT_HATCH = new MetaTileEntityMultiFluidHatch[6]; // EV-UHV
public static final MetaTileEntityMultiFluidHatch[] NONUPLE_IMPORT_HATCH = new MetaTileEntityMultiFluidHatch[6]; // EV-UHV
public static final MetaTileEntityMultiFluidHatch[] QUADRUPLE_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[6]; // EV-UHV
public static final MetaTileEntityMultiFluidHatch[] NONUPLE_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[6]; // EV-UHV
public static final MetaTileEntityEnergyHatch[] ENERGY_INPUT_HATCH = new MetaTileEntityEnergyHatch[GTValues.V.length];
public static final MetaTileEntityEnergyHatch[] ENERGY_INPUT_HATCH_4A = new MetaTileEntityEnergyHatch[6]; // EV, IV, LuV, ZPM, UV, UHV
public static final MetaTileEntityEnergyHatch[] ENERGY_INPUT_HATCH_16A = new MetaTileEntityEnergyHatch[5]; // IV, LuV, ZPM, UV, UHV
Expand Down Expand Up @@ -561,11 +563,7 @@ public static void init() {
registerMetaTileEntity(1195 + i, FLUID_EXPORT_HATCH[i]);
}

// Multi-Fluid Hatches
MULTI_FLUID_IMPORT_HATCH[0] = registerMetaTileEntity(1190, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_4x"), 2, false));
MULTI_FLUID_IMPORT_HATCH[1] = registerMetaTileEntity(1191, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_9x"), 3, false));
MULTI_FLUID_EXPORT_HATCH[0] = registerMetaTileEntity(1205, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_4x"), 2, true));
MULTI_FLUID_EXPORT_HATCH[1] = registerMetaTileEntity(1206, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_9x"), 3, true));
// IDs 1190, 1191, 1205, and 1206 reserved for multi-fluid hatches

// Energy Input/Output Hatches, IDs 1210-1269
endPos = GregTechAPI.isHighTier() ? ENERGY_INPUT_HATCH.length - 1 : Math.min(ENERGY_INPUT_HATCH.length - 1, GTValues.UV + 2);
Expand Down Expand Up @@ -822,6 +820,22 @@ public static void init() {
LONG_DIST_ITEM_ENDPOINT = registerMetaTileEntity(1749, new MetaTileEntityLDItemEndpoint(gregtechId("ld_item_endpoint")));
LONG_DIST_FLUID_ENDPOINT = registerMetaTileEntity(1750, new MetaTileEntityLDFluidEndpoint(gregtechId("ld_fluid_endpoint")));


// Multi-Fluid Hatches, IDs 1190, 1191, 1205, 1206, 1780-1799
// EV hatches separate because of old names/IDs
QUADRUPLE_IMPORT_HATCH[0] = registerMetaTileEntity(1190, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_4x"), GTValues.EV, 4, false));
NONUPLE_IMPORT_HATCH[0] = registerMetaTileEntity(1191, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_9x"), GTValues.EV, 9, false));
QUADRUPLE_EXPORT_HATCH[0] = registerMetaTileEntity(1205, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_4x"), GTValues.EV, 4, true));
NONUPLE_EXPORT_HATCH[0] = registerMetaTileEntity(1206, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_9x"), GTValues.EV, 9, true));
for (int i = GTValues.IV; i <= GTValues.UHV; i++) {
int index = i - GTValues.IV;
String tierName = GTValues.VN[i].toLowerCase();
QUADRUPLE_IMPORT_HATCH[index + 1] = registerMetaTileEntity(1780 + index, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_4x." + tierName), i, 4, false));
NONUPLE_IMPORT_HATCH[index + 1] = registerMetaTileEntity(1785 + index, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.import_9x." + tierName), i, 9, false));
QUADRUPLE_EXPORT_HATCH[index + 1] = registerMetaTileEntity(1790 + index, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_4x." + tierName), i, 4, true));
NONUPLE_EXPORT_HATCH[index + 1] = registerMetaTileEntity(1795 + index, new MetaTileEntityMultiFluidHatch(gregtechId("fluid_hatch.export_9x." + tierName), i, 9, true));
}

/*
* FOR ADDON DEVELOPERS:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import gregtech.api.GTValues;
import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.capability.GregtechTileCapabilities;
import gregtech.api.capability.IControllable;
Expand All @@ -15,8 +16,6 @@
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
import gregtech.client.renderer.ICubeRenderer;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
import net.minecraft.client.resources.I18n;
Expand All @@ -36,26 +35,33 @@

public class MetaTileEntityMultiFluidHatch extends MetaTileEntityMultiblockNotifiablePart implements IMultiblockAbilityPart<IFluidTank>, IControllable {

private static final int TANK_SIZE = 16000;
private static final int BASE_TANK_SIZE = 8000;

private final int numSlots;
private final int tankSize;

// only holding this for convenience
private final FluidTankList fluidTankList;
private boolean workingEnabled;

public MetaTileEntityMultiFluidHatch(ResourceLocation metaTileEntityId, int tier, boolean isExportHatch) {
public MetaTileEntityMultiFluidHatch(ResourceLocation metaTileEntityId, int tier, int numSlots, boolean isExportHatch) {
super(metaTileEntityId, tier, isExportHatch);
this.workingEnabled = true;
FluidTank[] fluidsHandlers = new FluidTank[getTier() * getTier()];
this.numSlots = numSlots;
// Quadruple: 1/4th the capacity of a fluid hatch of this tier
// Nonuple: 1/8th the capacity of a fluid hatch of this tier
this.tankSize = (BASE_TANK_SIZE * (1 << Math.min(GTValues.UHV, tier))) / (numSlots == 4 ? 4 : 8);
FluidTank[] fluidsHandlers = new FluidTank[numSlots];
for (int i = 0; i < fluidsHandlers.length; i++) {
fluidsHandlers[i] = new NotifiableFluidTank(TANK_SIZE, this, isExportHatch);
fluidsHandlers[i] = new NotifiableFluidTank(tankSize, this, isExportHatch);
}
this.fluidTankList = new FluidTankList(false, fluidsHandlers);
initializeInventory();
}

@Override
public MetaTileEntity createMetaTileEntity(IGregTechTileEntity metaTileEntityHolder) {
return new MetaTileEntityMultiFluidHatch(metaTileEntityId, this.getTier(), this.isExportHatch);
return new MetaTileEntityMultiFluidHatch(metaTileEntityId, this.getTier(), numSlots, this.isExportHatch);
}

@Override
Expand Down Expand Up @@ -131,30 +137,15 @@ public void readFromNBT(NBTTagCompound data) {
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
super.renderMetaTileEntity(renderState, translation, pipeline);
if (shouldRenderOverlay()) {
SimpleOverlayRenderer renderer = getTier() == 2 ? Textures.PIPE_4X_OVERLAY : Textures.PIPE_9X_OVERLAY;
SimpleOverlayRenderer renderer = numSlots == 4 ? Textures.PIPE_4X_OVERLAY : Textures.PIPE_9X_OVERLAY;
renderer.renderSided(getFrontFacing(), renderState, translation, pipeline);
}
}

@Override
public ICubeRenderer getBaseTexture() {
MultiblockControllerBase controller = getController();
if (controller != null) {
return this.hatchTexture = controller.getBaseTexture(this);
} else if (this.hatchTexture != null) {
if (hatchTexture != Textures.getInactiveTexture(hatchTexture)) {
return this.hatchTexture = Textures.getInactiveTexture(hatchTexture);
}
return this.hatchTexture;
} else {
return Textures.VOLTAGE_CASINGS[getTier() == 2 ? 3 : 5];
}
}

@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
tooltip.add(I18n.format(isExportHatch ? "gregtech.machine.fluid_hatch.export.tooltip" : "gregtech.machine.fluid_hatch.import.tooltip"));
tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_storage_capacity_mult", (int) Math.pow(this.getTier(), 2), TANK_SIZE));
tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_storage_capacity_mult", numSlots, tankSize));
tooltip.add(I18n.format("gregtech.universal.enabled"));
}

Expand Down Expand Up @@ -187,7 +178,7 @@ public void registerAbilities(List<IFluidTank> abilityList) {

@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
int rowSize = getTier();
int rowSize = (int) Math.sqrt(numSlots);
ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176,
18 + 18 * rowSize + 94)
.label(10, 5, getMetaFullName());
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1079,13 +1079,21 @@ private static void ConvertHatchToHatch() {
}
}

for (int i = 0; i < MULTI_FLUID_IMPORT_HATCH.length; i++) {
if (MULTI_FLUID_IMPORT_HATCH[i] != null && MULTI_FLUID_EXPORT_HATCH[i] != null) {
for (int i = 0; i < QUADRUPLE_IMPORT_HATCH.length; i++) {
if (QUADRUPLE_IMPORT_HATCH[i] != null && QUADRUPLE_EXPORT_HATCH[i] != null) {
ModHandler.addShapedRecipe("quadruple_fluid_hatch_output_to_input_" + QUADRUPLE_IMPORT_HATCH[i].getTier(), QUADRUPLE_IMPORT_HATCH[i].getStackForm(),
"d", "B", 'B', QUADRUPLE_EXPORT_HATCH[i].getStackForm());
ModHandler.addShapedRecipe("quadruple_fluid_hatch_input_to_output_" + QUADRUPLE_EXPORT_HATCH[i].getTier(), QUADRUPLE_EXPORT_HATCH[i].getStackForm(),
"d", "B", 'B', QUADRUPLE_IMPORT_HATCH[i].getStackForm());
}
}

ModHandler.addShapedRecipe("multi_fluid_hatch_output_to_input_" + MULTI_FLUID_IMPORT_HATCH[i].getTier(), MULTI_FLUID_IMPORT_HATCH[i].getStackForm(),
"d", "B", 'B', MULTI_FLUID_EXPORT_HATCH[i].getStackForm());
ModHandler.addShapedRecipe("multi_fluid_hatch_input_to_output_" + MULTI_FLUID_EXPORT_HATCH[i].getTier(), MULTI_FLUID_EXPORT_HATCH[i].getStackForm(),
"d", "B", 'B', MULTI_FLUID_IMPORT_HATCH[i].getStackForm());
for (int i = 0; i < NONUPLE_IMPORT_HATCH.length; i++) {
if (NONUPLE_IMPORT_HATCH[i] != null && NONUPLE_EXPORT_HATCH[i] != null) {
ModHandler.addShapedRecipe("nonuple_fluid_hatch_output_to_input_" + NONUPLE_IMPORT_HATCH[i].getTier(), NONUPLE_IMPORT_HATCH[i].getStackForm(),
"d", "B", 'B', NONUPLE_EXPORT_HATCH[i].getStackForm());
ModHandler.addShapedRecipe("nonuple_fluid_hatch_input_to_output_" + NONUPLE_EXPORT_HATCH[i].getTier(), NONUPLE_EXPORT_HATCH[i].getStackForm(),
"d", "B", 'B', NONUPLE_IMPORT_HATCH[i].getStackForm());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ public static void init() {
ModHandler.addShapelessRecipe("frost_hazard_to_steel_solid_casing", MetaBlocks.METAL_CASING.getItemVariant(STEEL_SOLID), MetaBlocks.WARNING_SIGN.getItemVariant(FROST_HAZARD));
ModHandler.addShapelessRecipe("noise_hazard_to_steel_solid_casing", MetaBlocks.METAL_CASING.getItemVariant(STEEL_SOLID), MetaBlocks.WARNING_SIGN.getItemVariant(NOISE_HAZARD));

ModHandler.addShapedRecipe(true, "fluid_import_hatch_4x", MetaTileEntities.MULTI_FLUID_IMPORT_HATCH[0].getStackForm(), "P", "M", 'M', MetaTileEntities.HULL[GTValues.HV].getStackForm(), 'P', new UnificationEntry(OrePrefix.pipeQuadrupleFluid, Materials.Titanium));
ModHandler.addShapedRecipe(true, "fluid_import_hatch_9x", MetaTileEntities.MULTI_FLUID_IMPORT_HATCH[1].getStackForm(), "P", "M", 'M', MetaTileEntities.HULL[GTValues.IV].getStackForm(), 'P', new UnificationEntry(OrePrefix.pipeNonupleFluid, Materials.TungstenSteel));

ModHandler.addShapedRecipe(true, "fluid_export_hatch_4x", MetaTileEntities.MULTI_FLUID_EXPORT_HATCH[0].getStackForm(), "M", "P", 'M', MetaTileEntities.HULL[GTValues.HV].getStackForm(), 'P', new UnificationEntry(OrePrefix.pipeQuadrupleFluid, Materials.Titanium));
ModHandler.addShapedRecipe(true, "fluid_export_hatch_9x", MetaTileEntities.MULTI_FLUID_EXPORT_HATCH[1].getStackForm(), "M", "P", 'M', MetaTileEntities.HULL[GTValues.IV].getStackForm(), 'P', new UnificationEntry(OrePrefix.pipeNonupleFluid, Materials.TungstenSteel));

ModHandler.addShapedRecipe(true, "rotor_holder_hv", MetaTileEntities.ROTOR_HOLDER[0].getStackForm(), "SGS", "GHG", "SGS", 'H', MetaTileEntities.HULL[GTValues.HV].getStackForm(), 'G', new UnificationEntry(OrePrefix.gear, Materials.BlackSteel), 'S', new UnificationEntry(OrePrefix.gearSmall, Materials.StainlessSteel));
ModHandler.addShapedRecipe(true, "rotor_holder_ev", MetaTileEntities.ROTOR_HOLDER[1].getStackForm(), "SGS", "GHG", "SGS", 'H', MetaTileEntities.HULL[GTValues.EV].getStackForm(), 'G', new UnificationEntry(OrePrefix.gear, Materials.Ultimet), 'S', new UnificationEntry(OrePrefix.gearSmall, Materials.Titanium));
ModHandler.addShapedRecipe(true, "rotor_holder_iv", MetaTileEntities.ROTOR_HOLDER[2].getStackForm(), "SGS", "GHG", "SGS", 'H', MetaTileEntities.HULL[GTValues.IV].getStackForm(), 'G', new UnificationEntry(OrePrefix.gear, Materials.HSSG), 'S', new UnificationEntry(OrePrefix.gearSmall, Materials.TungstenSteel));
Expand Down
Loading

0 comments on commit dc3c19d

Please sign in to comment.