Skip to content

Commit

Permalink
Add three new pigment based machines (and corresponding recipe types)…
Browse files Browse the repository at this point in the history
…, a base dye item, a pigment corresponding to each EnumColor we have (18 in total), and add balloons, plastic blocks, and glow panels for the two EnumColors that don't have corresponding dyes (aqua, and Dark red). This adds up to a total of 36 new blocks/items.

- Improve a bit of class hierarchy to reduce duplicate code between some existing recipe types and our new ones
- Refactored how we keep track of blocks/items in Mekanism Additions to require less copy pasted code for definitions by storing them in maps
- Move various simple models for Mekanism Additions blocks/items to data generation
- Fix glow plastic slabs and transparent plastic slabs having incorrect loot tables for double slabs
- Slightly reduce memory impact of colored blocks/items color handlers by properly ensuring that they only create the color handler once for all ones using the same type instead of creating a new one for each block/item
- Don't allow recoloring recipes to be made with the same type as the output (no orange plastic + orange dye -> orange plastic)
- Made a couple minor breaking changes to the recipe class hierarchy:
  - Renamed intermediate class ItemStackChemicalToItemStackCachedRecipe to ItemStackConstantChemicalToItemStackCachedRecipe
  - Made MetallurgicInfuserRecipe extend ItemStackChemicalToItemStackRecipe, the methods in the class are deprecated and bounce to the proper ItemStackChemicalToItemStackRecipe methods, MetallurgicInfuserRecipe is now implementing BiPredicate<ItemStack, InfusionStack> instead of BiPredicate<InfusionStack, ItemStack>
  - Deprecated ChemicalInfuserRecipeBuilder in favor of a more generified ChemicalChemicalToChemicalRecipeBuilder
  - Deprecated ItemStackGasToItemStackRecipeBuilder and MetallurgicInfuserRecipeBuilder in favor of a more generified ItemStackChemicalToItemStackRecipeBuilder.
  • Loading branch information
pupnewfster committed Mar 21, 2021
1 parent 99743c6 commit 0771076
Show file tree
Hide file tree
Showing 1,836 changed files with 45,187 additions and 4,256 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ repositories {
}

whenObjectAdded {//ForgeGradle adds these in an afterEvaluate, so we need to catch them as they're added and exclude mod artifacts/groups
if (it instanceof MavenArtifactRepository){
if (it.url.toString() == 'https://files.minecraftforge.net/maven/' || it.url.toString() == 'https://libraries.minecraft.net/' || it.url.toString() == 'https://repo.maven.apache.org/maven2/') {
if (it instanceof MavenArtifactRepository) {
if (it.url.toString() == 'https://files.minecraftforge.net/maven/' || it.url.toString() == 'https://libraries.minecraft.net/' ||
it.url.toString() == 'https://repo.maven.apache.org/maven2/') {
try {
it.content {
excludeGroup 'curse.maven'
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -410,40 +410,6 @@ public void setLocationFromBoundingbox() {

@Override
public ItemStack getPickedResult(RayTraceResult target) {
switch (color) {
case BLACK:
return AdditionsItems.BLACK_BALLOON.getItemStack();
case DARK_BLUE:
return AdditionsItems.BLUE_BALLOON.getItemStack();
case DARK_GREEN:
return AdditionsItems.GREEN_BALLOON.getItemStack();
case DARK_AQUA:
return AdditionsItems.CYAN_BALLOON.getItemStack();
case PURPLE:
return AdditionsItems.PURPLE_BALLOON.getItemStack();
case ORANGE:
return AdditionsItems.ORANGE_BALLOON.getItemStack();
case GRAY:
return AdditionsItems.LIGHT_GRAY_BALLOON.getItemStack();
case DARK_GRAY:
return AdditionsItems.GRAY_BALLOON.getItemStack();
case INDIGO:
return AdditionsItems.LIGHT_BLUE_BALLOON.getItemStack();
case BRIGHT_GREEN:
return AdditionsItems.LIME_BALLOON.getItemStack();
case RED:
return AdditionsItems.RED_BALLOON.getItemStack();
case PINK:
return AdditionsItems.MAGENTA_BALLOON.getItemStack();
case YELLOW:
return AdditionsItems.YELLOW_BALLOON.getItemStack();
case WHITE:
return AdditionsItems.WHITE_BALLOON.getItemStack();
case BROWN:
return AdditionsItems.BROWN_BALLOON.getItemStack();
case BRIGHT_PINK:
return AdditionsItems.PINK_BALLOON.getItemStack();
}
return super.getPickedResult(target);
return AdditionsItems.BALLOONS.get(color).getItemStack();
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mekanism.additions.common.registries;

import java.util.EnumMap;
import java.util.Map;
import mekanism.additions.common.MekanismAdditions;
import mekanism.additions.common.item.AdditionsSpawnEggItem;
import mekanism.additions.common.item.ItemBalloon;
Expand All @@ -8,6 +10,7 @@
import mekanism.common.registration.impl.EntityTypeRegistryObject;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.registration.impl.ItemRegistryObject;
import mekanism.common.util.EnumUtils;
import net.minecraft.entity.Entity;

public class AdditionsItems {
Expand All @@ -24,25 +27,12 @@ private AdditionsItems() {
public static final ItemRegistryObject<AdditionsSpawnEggItem> BABY_WITHER_SKELETON_SPAWN_EGG = registerSpawnEgg(AdditionsEntityTypes.BABY_WITHER_SKELETON, 0x303030, 0x525454);
public static final ItemRegistryObject<ItemWalkieTalkie> WALKIE_TALKIE = ITEMS.register("walkie_talkie", ItemWalkieTalkie::new);

public static final ItemRegistryObject<ItemBalloon> BLACK_BALLOON = registerBalloon(EnumColor.BLACK);
public static final ItemRegistryObject<ItemBalloon> RED_BALLOON = registerBalloon(EnumColor.RED);
public static final ItemRegistryObject<ItemBalloon> GREEN_BALLOON = registerBalloon(EnumColor.DARK_GREEN);
public static final ItemRegistryObject<ItemBalloon> BROWN_BALLOON = registerBalloon(EnumColor.BROWN);
public static final ItemRegistryObject<ItemBalloon> BLUE_BALLOON = registerBalloon(EnumColor.DARK_BLUE);
public static final ItemRegistryObject<ItemBalloon> PURPLE_BALLOON = registerBalloon(EnumColor.PURPLE);
public static final ItemRegistryObject<ItemBalloon> CYAN_BALLOON = registerBalloon(EnumColor.DARK_AQUA);
public static final ItemRegistryObject<ItemBalloon> LIGHT_GRAY_BALLOON = registerBalloon(EnumColor.GRAY);
public static final ItemRegistryObject<ItemBalloon> GRAY_BALLOON = registerBalloon(EnumColor.DARK_GRAY);
public static final ItemRegistryObject<ItemBalloon> PINK_BALLOON = registerBalloon(EnumColor.BRIGHT_PINK);
public static final ItemRegistryObject<ItemBalloon> LIME_BALLOON = registerBalloon(EnumColor.BRIGHT_GREEN);
public static final ItemRegistryObject<ItemBalloon> YELLOW_BALLOON = registerBalloon(EnumColor.YELLOW);
public static final ItemRegistryObject<ItemBalloon> LIGHT_BLUE_BALLOON = registerBalloon(EnumColor.INDIGO);
public static final ItemRegistryObject<ItemBalloon> MAGENTA_BALLOON = registerBalloon(EnumColor.PINK);
public static final ItemRegistryObject<ItemBalloon> ORANGE_BALLOON = registerBalloon(EnumColor.ORANGE);
public static final ItemRegistryObject<ItemBalloon> WHITE_BALLOON = registerBalloon(EnumColor.WHITE);

private static ItemRegistryObject<ItemBalloon> registerBalloon(EnumColor color) {
return ITEMS.register(color.getRegistryPrefix() + "_balloon", () -> new ItemBalloon(color));
public static final Map<EnumColor, ItemRegistryObject<ItemBalloon>> BALLOONS = new EnumMap<>(EnumColor.class);

static {
for (EnumColor color : EnumUtils.COLORS) {
BALLOONS.put(color, ITEMS.register(color.getRegistryPrefix() + "_balloon", () -> new ItemBalloon(color)));
}
}

private static <ENTITY extends Entity> ItemRegistryObject<AdditionsSpawnEggItem> registerSpawnEgg(EntityTypeRegistryObject<ENTITY> entityTypeProvider,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "mekanismadditions:block/glow_panel",
"gui_light": "front",
"display": {
"thirdperson_righthand": {
"rotation": [100, 45, 0],
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions src/api/java/mekanism/api/JsonConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private JsonConstants() {
public static final String MAIN_INPUT = "mainInput";
public static final String EXTRA_INPUT = "extraInput";
public static final String ITEM_INPUT = "itemInput";
public static final String CHEMICAL_INPUT = "chemicalInput";
public static final String INFUSION_INPUT = "infusionInput";
public static final String GAS_INPUT = "gasInput";
public static final String SLURRY_INPUT = "slurryInput";
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/mekanism/api/MekanismAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private MekanismAPI() {
/**
* The version of the api classes - may not always match the mod's version
*/
public static final String API_VERSION = "10.0.21";
public static final String API_VERSION = "10.1.0";
public static final String MEKANISM_MODID = "mekanism";
/**
* Mekanism debug mode
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package mekanism.api.datagen.recipe.builder;

import com.google.gson.JsonObject;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
import mekanism.api.JsonConstants;
import mekanism.api.annotations.FieldsAreNonnullByDefault;
import mekanism.api.chemical.Chemical;
import mekanism.api.chemical.ChemicalStack;
import mekanism.api.chemical.gas.Gas;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.chemical.pigment.Pigment;
import mekanism.api.chemical.pigment.PigmentStack;
import mekanism.api.datagen.recipe.MekanismRecipeBuilder;
import mekanism.api.recipes.inputs.chemical.ChemicalIngredientDeserializer;
import mekanism.api.recipes.inputs.chemical.GasStackIngredient;
import mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient;
import mekanism.api.recipes.inputs.chemical.PigmentStackIngredient;
import net.minecraft.util.ResourceLocation;

@FieldsAreNonnullByDefault
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ChemicalChemicalToChemicalRecipeBuilder<CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMICAL>,
INGREDIENT extends IChemicalStackIngredient<CHEMICAL, STACK>> extends MekanismRecipeBuilder<ChemicalChemicalToChemicalRecipeBuilder<CHEMICAL, STACK, INGREDIENT>> {

private final ChemicalIngredientDeserializer<CHEMICAL, STACK, ?> outputSerializer;
private final INGREDIENT leftInput;
private final INGREDIENT rightInput;
private final STACK output;

protected ChemicalChemicalToChemicalRecipeBuilder(ResourceLocation serializerName, INGREDIENT leftInput, INGREDIENT rightInput, STACK output,
ChemicalIngredientDeserializer<CHEMICAL, STACK, ?> outputSerializer) {
super(serializerName);
this.leftInput = leftInput;
this.rightInput = rightInput;
this.output = output;
this.outputSerializer = outputSerializer;
}

public static ChemicalChemicalToChemicalRecipeBuilder<Gas, GasStack, GasStackIngredient> chemicalInfusing(GasStackIngredient leftInput, GasStackIngredient rightInput,
GasStack output) {
if (output.isEmpty()) {
throw new IllegalArgumentException("This chemical infusing recipe requires a non empty gas output.");
}
return new ChemicalChemicalToChemicalRecipeBuilder<>(mekSerializer("chemical_infusing"), leftInput, rightInput, output, ChemicalIngredientDeserializer.GAS);
}

public static ChemicalChemicalToChemicalRecipeBuilder<Pigment, PigmentStack, PigmentStackIngredient> pigmentMixing(PigmentStackIngredient leftInput,
PigmentStackIngredient rightInput, PigmentStack output) {
if (output.isEmpty()) {
throw new IllegalArgumentException("This pigment mixing recipe requires a non empty gas output.");
}
return new ChemicalChemicalToChemicalRecipeBuilder<>(mekSerializer("pigment_mixing"), leftInput, rightInput, output, ChemicalIngredientDeserializer.PIGMENT);
}

@Override
protected ChemicalChemicalToChemicalRecipeResult getResult(ResourceLocation id) {
return new ChemicalChemicalToChemicalRecipeResult(id);
}

public class ChemicalChemicalToChemicalRecipeResult extends RecipeResult {

protected ChemicalChemicalToChemicalRecipeResult(ResourceLocation id) {
super(id);
}

@Override
public void serializeRecipeData(@Nonnull JsonObject json) {
json.add(JsonConstants.LEFT_INPUT, leftInput.serialize());
json.add(JsonConstants.RIGHT_INPUT, rightInput.serialize());
json.add(JsonConstants.OUTPUT, outputSerializer.serializeStack(output));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
package mekanism.api.datagen.recipe.builder;

import com.google.gson.JsonObject;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
import mekanism.api.JsonConstants;
import mekanism.api.SerializerHelper;
import mekanism.api.annotations.FieldsAreNonnullByDefault;
import mekanism.api.chemical.gas.Gas;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.datagen.recipe.MekanismRecipeBuilder;
import mekanism.api.recipes.inputs.chemical.ChemicalIngredientDeserializer;
import mekanism.api.recipes.inputs.chemical.GasStackIngredient;
import net.minecraft.util.ResourceLocation;

@FieldsAreNonnullByDefault
//TODO - 1.17: Get rid of this class and move the helpers to ChemicalChemicalToChemicalRecipeBuilder
@Deprecated
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ChemicalInfuserRecipeBuilder extends MekanismRecipeBuilder<ChemicalInfuserRecipeBuilder> {

private final GasStackIngredient leftInput;
private final GasStackIngredient rightInput;
private final GasStack output;
public class ChemicalInfuserRecipeBuilder extends ChemicalChemicalToChemicalRecipeBuilder<Gas, GasStack, GasStackIngredient> {

protected ChemicalInfuserRecipeBuilder(GasStackIngredient leftInput, GasStackIngredient rightInput, GasStack output) {
super(mekSerializer("chemical_infusing"));
this.leftInput = leftInput;
this.rightInput = rightInput;
this.output = output;
super(mekSerializer("chemical_infusing"), leftInput, rightInput, output, ChemicalIngredientDeserializer.GAS);
}

/**
* @deprecated Use {@link ChemicalChemicalToChemicalRecipeBuilder#chemicalInfusing(GasStackIngredient, GasStackIngredient, GasStack)} instead.
*/
@Deprecated
public static ChemicalInfuserRecipeBuilder chemicalInfusing(GasStackIngredient leftInput, GasStackIngredient rightInput, GasStack output) {
if (output.isEmpty()) {
throw new IllegalArgumentException("This chemical infusing recipe requires a non empty gas output.");
Expand All @@ -40,17 +34,10 @@ protected ChemicalInfuserRecipeResult getResult(ResourceLocation id) {
return new ChemicalInfuserRecipeResult(id);
}

public class ChemicalInfuserRecipeResult extends RecipeResult {
public class ChemicalInfuserRecipeResult extends ChemicalChemicalToChemicalRecipeResult {

protected ChemicalInfuserRecipeResult(ResourceLocation id) {
super(id);
}

@Override
public void serializeRecipeData(@Nonnull JsonObject json) {
json.add(JsonConstants.LEFT_INPUT, leftInput.serialize());
json.add(JsonConstants.RIGHT_INPUT, rightInput.serialize());
json.add(JsonConstants.OUTPUT, SerializerHelper.serializeGasStack(output));
}
}
}
Loading

0 comments on commit 0771076

Please sign in to comment.