forked from GregTechCEu/GregTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
250 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/gregtech/api/recipes/builders/GasCollectorRecipeBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/gregtech/api/recipes/recipeproperties/GasCollectorDimensionProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 0 additions & 116 deletions
116
src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAirCollector.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.