Skip to content

Commit

Permalink
Add Gas Collectors (GregTechCEu#68)
Browse files Browse the repository at this point in the history
* add dimension-specific gas collectors
  • Loading branch information
TechLord22 authored Aug 9, 2021
1 parent 17d8f74 commit 98a6ca6
Show file tree
Hide file tree
Showing 25 changed files with 250 additions and 147 deletions.
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/gui/GuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class GuiTextures {
public static final TextureArea PROGRESS_BAR_EXTRACT = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_extract.png");
public static final TextureArea PROGRESS_BAR_EXTRUDER = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_extruder.png");
public static final TextureArea PROGRESS_BAR_FUSION = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_fusion.png");
public static final TextureArea PROGRESS_BAR_GAS_COLLECTOR = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_gas_collector.png");
public static final TextureArea PROGRESS_BAR_HAMMER = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_hammer.png");
public static final TextureArea PROGRESS_BAR_HAMMER_BASE = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_hammer_base.png");
public static final TextureArea PROGRESS_BAR_LATHE = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_lathe.png");
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gregtech/api/recipes/RecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ public class RecipeMaps {
.setSlotOverlay(false, false, true, GuiTextures.SCANNER_OVERLAY)
.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, MoveType.HORIZONTAL);

@ZenProperty
public static final RecipeMap<GasCollectorRecipeBuilder> GAS_COLLECTOR_RECIPES = new RecipeMap<>("gas_collector", 1, 1, 0, 0, 0, 0, 1, 1, new GasCollectorRecipeBuilder(), false)
.setSlotOverlay(false, false, GuiTextures.INT_CIRCUIT_OVERLAY)
.setSlotOverlay(true, true, GuiTextures.CENTRIFUGE_OVERLAY)
.setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, MoveType.HORIZONTAL);

@ZenProperty
public static final FuelRecipeMap COMBUSTION_GENERATOR_FUELS = new FuelRecipeMap("combustion_generator");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package gregtech.api.recipes.builders;

import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.recipeproperties.GasCollectorDimensionProperty;
import gregtech.api.util.EnumValidationResult;
import gregtech.api.util.ValidationResult;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.ArrayList;
import java.util.List;

public class GasCollectorRecipeBuilder extends RecipeBuilder<GasCollectorRecipeBuilder> {

private List<Integer> dimensionIDs;

public GasCollectorRecipeBuilder() {
}

public GasCollectorRecipeBuilder(Recipe recipe, RecipeMap<GasCollectorRecipeBuilder> recipeMap) {
super(recipe, recipeMap);
this.dimensionIDs = recipe.getProperty(GasCollectorDimensionProperty.getInstance(), new ArrayList<Integer>());
}

public GasCollectorRecipeBuilder(RecipeBuilder<GasCollectorRecipeBuilder> recipeBuilder) {
super(recipeBuilder);
}

@Override
public GasCollectorRecipeBuilder copy() {
return new GasCollectorRecipeBuilder(this);
}

@Override
public boolean applyProperty(String key, Object value) {
if (key.equals(GasCollectorDimensionProperty.KEY)) {
this.dimension(((Number) value).intValue());
return true;
}
return true;
}

public GasCollectorRecipeBuilder dimension(int dimensionID) {
if (this.dimensionIDs == null)
this.dimensionIDs = new ArrayList<>();
this.dimensionIDs.add(dimensionID);
return this;
}

public ValidationResult<Recipe> build() {
Recipe recipe = new Recipe(inputs, outputs, chancedOutputs, fluidInputs, fluidOutputs,
duration, EUt, hidden);
if (!recipe.setProperty(GasCollectorDimensionProperty.getInstance(), dimensionIDs)) {
return ValidationResult.newResult(EnumValidationResult.INVALID, recipe);
}

return ValidationResult.newResult(finalizeAndValidate(), recipe);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.appendSuper(super.toString())
.append(GasCollectorDimensionProperty.getInstance().getKey(), dimensionIDs.toString())
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gregtech.api.recipes.recipeproperties;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;

import java.util.List;

public class GasCollectorDimensionProperty extends RecipeProperty<List> {
public static final String KEY = "dimension";

private static GasCollectorDimensionProperty INSTANCE;

private GasCollectorDimensionProperty() {
super(KEY, List.class);
}

public static GasCollectorDimensionProperty getInstance() {
if (INSTANCE == null)
INSTANCE = new GasCollectorDimensionProperty();
return INSTANCE;
}

@Override
public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) {
minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.dimensions",
value, getDimensionsForRecipe(castValue(value))), x, y, color);
}

private String getDimensionsForRecipe(List<Integer> value) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < value.size(); i++) {
builder.append(value.get(i));
if (i != value.size() - 1)
builder.append(", ");
}
String str = builder.toString();

if (str.length() >= 13) {
str = str.substring(0, 10) + "..";
}
return str;
}

}
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/render/Textures.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public class Textures {
public static final OrientedOverlayRenderer FLUID_SOLIDIFIER_OVERLAY = new OrientedOverlayRenderer("machines/fluid_solidifier", FRONT);
public static final OrientedOverlayRenderer FORGE_HAMMER_OVERLAY = new OrientedOverlayRenderer("machines/forge_hammer", FRONT);
public static final OrientedOverlayRenderer FORMING_PRESS_OVERLAY = new OrientedOverlayRenderer("machines/press", FRONT, SIDE, TOP);
public static final OrientedOverlayRenderer GAS_COLLECTOR_OVERLAY = new OrientedOverlayRenderer("machines/gas_collector", FRONT, SIDE, TOP, BOTTOM, BACK);
public static final OrientedOverlayRenderer LATHE_OVERLAY = new OrientedOverlayRenderer("machines/lathe", FRONT);
public static final OrientedOverlayRenderer MIXER_OVERLAY = new OrientedOverlayRenderer("machines/mixer", FRONT, SIDE, TOP);
public static final OrientedOverlayRenderer ORE_WASHER_OVERLAY = new OrientedOverlayRenderer("machines/ore_washer", FRONT, SIDE);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/gregtech/common/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ public class ConfigHolder {
@Config.RequiresMcRestart
public static int gasTurbineBonusOutput = 6144;

@Config.Comment("Array of blacklisted dimension IDs in which Air Collector does not work. Default: none")
public static int[] airCollectorDimensionBlacklist = new int[]{};

public static class VanillaRecipes {

@Config.Comment("Whether to make glass related recipes harder. Default: true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@
import gregtech.api.render.Textures;
import gregtech.api.unification.material.Materials;
import gregtech.api.util.GTLog;
import gregtech.common.ConfigHolder;
import gregtech.common.metatileentities.electric.*;
import gregtech.common.metatileentities.electric.multiblockpart.*;
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityEnergyHatch;
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityFluidHatch;
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityItemBus;
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityRotorHolder;
import gregtech.common.metatileentities.multi.*;
import gregtech.common.metatileentities.multi.MetaTileEntityLargeBoiler.BoilerType;
import gregtech.common.metatileentities.multi.electric.*;
import gregtech.common.metatileentities.multi.electric.generator.*;
import gregtech.common.metatileentities.multi.electric.generator.MetaTileEntityLargeCombustionEngine;
import gregtech.common.metatileentities.multi.electric.generator.MetaTileEntityLargeTurbine;
import gregtech.common.metatileentities.multi.electric.generator.MetaTileEntityLargeTurbine.TurbineType;
import gregtech.common.metatileentities.multi.steam.*;
import gregtech.common.metatileentities.multi.steam.MetaTileEntitySteamGrinder;
import gregtech.common.metatileentities.multi.steam.MetaTileEntitySteamOven;
import gregtech.common.metatileentities.steam.*;
import gregtech.common.metatileentities.steam.boiler.*;
import gregtech.common.metatileentities.steam.multiblockpart.*;
import gregtech.common.metatileentities.steam.boiler.SteamCoalBoiler;
import gregtech.common.metatileentities.steam.boiler.SteamLavaBoiler;
import gregtech.common.metatileentities.steam.boiler.SteamSolarBoiler;
import gregtech.common.metatileentities.steam.multiblockpart.MetaTileEntitySteamHatch;
import gregtech.common.metatileentities.steam.multiblockpart.MetaTileEntitySteamItemBus;
import gregtech.common.metatileentities.storage.*;
import net.minecraft.util.ResourceLocation;

Expand Down Expand Up @@ -97,6 +104,7 @@ public class MetaTileEntities {
public static final SimpleMachineMetaTileEntity[] MASS_FABRICATOR = new SimpleMachineMetaTileEntity[GTValues.V.length - 1];
public static final SimpleMachineMetaTileEntity[] REPLICATOR = new SimpleMachineMetaTileEntity[GTValues.V.length - 1];
public static final SimpleMachineMetaTileEntity[] SCANNER = new SimpleMachineMetaTileEntity[GTValues.V.length - 1];
public static final SimpleMachineMetaTileEntity[] GAS_COLLECTOR = new SimpleMachineMetaTileEntity[GTValues.V.length - 1];

//GENERATORS SECTION
public static final SimpleGeneratorMetaTileEntity[] COMBUSTION_GENERATOR = new SimpleGeneratorMetaTileEntity[4];
Expand Down Expand Up @@ -180,7 +188,6 @@ public class MetaTileEntities {
public static MetaTileEntityWorkbench WORKBENCH;
public static final MetaTileEntityPump[] PUMP = new MetaTileEntityPump[8];
public static final MetaTileEntityBlockBreaker[] BLOCK_BREAKER = new MetaTileEntityBlockBreaker[4];
public static final MetaTileEntityAirCollector[] AIR_COLLECTOR = new MetaTileEntityAirCollector[6];
public static final MetaTileEntityItemCollector[] ITEM_COLLECTOR = new MetaTileEntityItemCollector[4];
public static final MetaTileEntityFisher[] FISHER = new MetaTileEntityFisher[4];

Expand Down Expand Up @@ -329,7 +336,8 @@ public static void init() {
// Unpacker, IDs 530-544
registerSimpleMetaTileEntity(UNPACKER, 530, "unpacker", RecipeMaps.UNPACKER_RECIPES, Textures.UNPACKER_OVERLAY);

// Free Range, IDs 545-559
// Gas Collectors, IDs 545-559
registerSimpleMetaTileEntity(GAS_COLLECTOR, 545, "gas_collector", RecipeMaps.GAS_COLLECTOR_RECIPES, Textures.GAS_COLLECTOR_OVERLAY, false);

// Polarizer, IDs 560-574
registerSimpleMetaTileEntity(POLARIZER, 560, "polarizer", RecipeMaps.POLARIZER_RECIPES, Textures.POLARIZER_OVERLAY);
Expand Down Expand Up @@ -526,14 +534,6 @@ public static void init() {
PUMP[2] = GregTechAPI.registerMetaTileEntity(1532, new MetaTileEntityPump(gregtechId("pump.hv"), 3));
PUMP[3] = GregTechAPI.registerMetaTileEntity(1533, new MetaTileEntityPump(gregtechId("pump.ev"), 4));

// Air Collectors, IDs 1545-1559
AIR_COLLECTOR[0] = GregTechAPI.registerMetaTileEntity(1545, new MetaTileEntityAirCollector(gregtechId("air_collector.lv"), 1));
AIR_COLLECTOR[1] = GregTechAPI.registerMetaTileEntity(1546, new MetaTileEntityAirCollector(gregtechId("air_collector.mv"), 2));
AIR_COLLECTOR[2] = GregTechAPI.registerMetaTileEntity(1547, new MetaTileEntityAirCollector(gregtechId("air_collector.hv"), 3));
AIR_COLLECTOR[3] = GregTechAPI.registerMetaTileEntity(1548, new MetaTileEntityAirCollector(gregtechId("air_collector.ev"), 4));
AIR_COLLECTOR[4] = GregTechAPI.registerMetaTileEntity(1549, new MetaTileEntityAirCollector(gregtechId("air_collector.iv"), 5));
AIR_COLLECTOR[5] = GregTechAPI.registerMetaTileEntity(1550, new MetaTileEntityAirCollector(gregtechId("air_collector.luv"), 6));

// Super / Quantum Chests, IDs 1560-1574
for (int i = 0; i < 5; i++) {
String voltageName = GTValues.VN[i + 1].toLowerCase();
Expand Down

This file was deleted.

Loading

0 comments on commit 98a6ca6

Please sign in to comment.