Skip to content

Commit

Permalink
Merge pull request #67 from GrowthcraftCE/development
Browse files Browse the repository at this point in the history
Release for Growthcraft 9.1.2
  • Loading branch information
Alatyami authored Nov 6, 2023
2 parents c3658ca + 54954fd commit a44e5a1
Show file tree
Hide file tree
Showing 39 changed files with 374 additions and 111 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Growthcraft 9 for Minecraft 1.20.1 (Forge)

[![Growthcraft Version](https://img.shields.io/badge/Growthcraft-9.1.1-orange.svg)](https://github.com/GrowthcraftCE/Growthcraft-1.20)
[![Growthcraft Version](https://img.shields.io/badge/Growthcraft-9.1.2-orange.svg)](https://github.com/GrowthcraftCE/Growthcraft-1.20)
[![](http://cf.way2muchnoise.eu/versions/growthcraft-community-edition_latest.svg)](https://minecraft.curseforge.com/projects/growthcraft-community-edition/)
[![](http://cf.way2muchnoise.eu/short_growthcraft-community-edition.svg)](https://minecraft.curseforge.com/projects/growthcraft-community-edition/)
[![Forge Version](https://img.shields.io/badge/Minecraft%20Forge-47.2.0-yellow.svg)](http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.20.1.html)
Expand All @@ -23,7 +23,7 @@ to our GitHub wiki documentation. As of version 9 we have included an in-game ma

End of Support: TBD
Latest Version: 9.0.7
Stable Version: 9.1.1
Stable Version: 9.1.2

### Growthcraft 8 (Minecraft 1.19.4)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ dependencies {
runtimeOnly fg.deobf("curse.maven:patchouli-${curseforge_patchouli}")
runtimeOnly fg.deobf("curse.maven:appleskin-${curseforge_appleskin}")
runtimeOnly fg.deobf("curse.maven:mekanism-${curseforge_mekanism}")

runtimeOnly fg.deobf("curse.maven:mekanism-${curseforge_farmers_delight}")
}

// This block of code expands all declared replace properties in the specified resource targets.
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod_id=growthcraft
mod_archive_base=growthcraft
mod_name=Growthcraft
mod_license=GNU General Public License v3.0
mod_version=9.1.1
mod_version=9.1.2
mod_group_id=growthcraft
mod_authors=Alatyami
mod_description=Growthcraft is a realistic and immersive Forge mod that adds various new elements to the game of Minecraft.
Expand All @@ -48,4 +48,6 @@ curseforge_appleskin=248787:4770828
# Mekansim, for testing pipes
curseforge_mekanism=268560:4807067
# ------------------------------------------------

# Farmer's Delight, for testing rice tags
curseforge_farmers_delight=398521:4679319
# ------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public void tick(Level level, BlockPos blockPos, BlockState blockState, BrewKett
} else {
this.resetTickClock();
}
} else {
this.resetTickClock();
}
} else {
// Do nothing on the client side.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

public class BrewKettleRecipeCategory implements IRecipeCategory<BrewKettleRecipe> {

Expand Down Expand Up @@ -85,9 +86,11 @@ public void setRecipe(IRecipeLayoutBuilder builder, BrewKettleRecipe recipe, IFo
.addItemStack(new ItemStack(GrowthcraftCellarItems.BREW_KETTLE_LID.get()));
}

// Input Item
builder.addSlot(RecipeIngredientRole.INPUT, 70, 25)
.addItemStack(recipe.getInputItemStack());
// Input Item with Tag Support
for (Ingredient ingredient : recipe.getIngredients()) {
builder.addSlot(RecipeIngredientRole.INPUT, 70, 25)
.addIngredients(ingredient);
}

// TODO: Input Fluid
builder.addSlot(RecipeIngredientRole.INPUT, 36, 7)
Expand Down
53 changes: 40 additions & 13 deletions src/main/java/growthcraft/cellar/recipe/BrewKettleRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import growthcraft.cellar.GrowthcraftCellar;
import growthcraft.cellar.shared.Reference;
import growthcraft.lib.utils.CraftingUtils;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
Expand All @@ -19,23 +21,25 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;

public class BrewKettleRecipe implements Recipe<SimpleContainer> {

private final ResourceLocation recipeId;
private final FluidStack inputFluidStack;
private final ItemStack inputItemStack;
private final NonNullList<Ingredient> inputIngredients;

private final FluidStack outputFluidStack;
private final ItemStack byProduct;
private final boolean requiresLid;
private final boolean requiresHeat;
private final int byProductChance;
private final int processingTime;


public BrewKettleRecipe(ResourceLocation recipeId, FluidStack inputFluidStack, ItemStack inputItem, FluidStack outputFluidStack, ItemStack byProduct, int byProductChance, int processingTime, boolean requiresHeat, boolean requiresLid) {
public BrewKettleRecipe(ResourceLocation recipeId, FluidStack inputFluidStack, NonNullList<Ingredient> inputIngredients, FluidStack outputFluidStack, ItemStack byProduct, int byProductChance, int processingTime, boolean requiresHeat, boolean requiresLid) {
this.recipeId = recipeId;
this.inputFluidStack = inputFluidStack;
this.inputItemStack = inputItem;
this.inputIngredients = inputIngredients;
this.outputFluidStack = outputFluidStack;
this.byProduct = byProduct;
this.processingTime = processingTime;
Expand All @@ -51,14 +55,18 @@ public boolean matches(SimpleContainer container, Level level) {

public boolean matches(ItemStack itemStack, FluidStack fluidStack, boolean needsLid, boolean needsHeat) {

boolean inputItemTypeMatches = this.inputItemStack.getItem() == itemStack.getItem();
boolean inputItemCountLessThan = this.inputItemStack.getCount() <= itemStack.getCount();
boolean inputItemTypeMatches = Arrays.stream(
this.inputIngredients.get(0).getItems()).anyMatch(
ingredientItem -> ingredientItem.is(itemStack.getItem()) && ingredientItem.getCount() <= itemStack.getCount()
);

//boolean inputItemCountLessThan = this.inputIngredients.get(0).getItems()[0].getCount() <= itemStack.getCount();
boolean inputFluidTypeMatches = this.inputFluidStack.getFluid() == fluidStack.getFluid();
boolean inputFluidAmountLessThan = this.inputFluidStack.getAmount() <= fluidStack.getAmount();
boolean hasRequiredLid = this.requiresLid == needsLid && this.requiresHeat == needsHeat;

return inputItemTypeMatches
&& inputItemCountLessThan
//&& inputItemCountLessThan
&& inputFluidTypeMatches
&& inputFluidAmountLessThan
&& hasRequiredLid;
Expand Down Expand Up @@ -93,7 +101,12 @@ public FluidStack getOutputFluidStack() {
}

public ItemStack getInputItemStack() {
return inputItemStack;
return inputIngredients.get(0).getItems()[0];
}

@Override
public @NotNull NonNullList<Ingredient> getIngredients() {
return this.inputIngredients;
}

public ItemStack getByProduct() {
Expand Down Expand Up @@ -144,7 +157,8 @@ public static class Serializer implements RecipeSerializer<BrewKettleRecipe> {
@Override
public @NotNull BrewKettleRecipe fromJson(ResourceLocation recipeId, JsonObject json) {

ItemStack inputItemStack = CraftingHelper.getItemStack(GsonHelper.getAsJsonObject(json, "input_item"), false);
NonNullList<Ingredient> inputIngredient = CraftingUtils.readIngredient(GsonHelper.getAsJsonObject(json, "input_item"));

ItemStack byProductItemStack = CraftingHelper.getItemStack(GsonHelper.getAsJsonObject(json, "by_product"), false);

FluidStack inputFluid = CraftingUtils.getFluidStack(GsonHelper.getAsJsonObject(json, "input_fluid"));
Expand All @@ -156,15 +170,23 @@ public static class Serializer implements RecipeSerializer<BrewKettleRecipe> {
int processingTime = GsonHelper.getAsInt(json, "processing_time", 600);
int byProductChance = GsonHelper.getAsInt(json, "by_product_chance", 10);

return new BrewKettleRecipe(recipeId, inputFluid, inputItemStack,
return new BrewKettleRecipe(recipeId, inputFluid, inputIngredient,
outputFluid, byProductItemStack, byProductChance, processingTime,
requiresHeat, requiresLid);
}

@Override
public @Nullable BrewKettleRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
try {
ItemStack inputItemStack = buffer.readItem();

int i = buffer.readVarInt();
NonNullList<Ingredient> inputIngredients = NonNullList.withSize(i, Ingredient.EMPTY);

for (int j = 0; j < inputIngredients.size(); ++j) {
inputIngredients.set(j, Ingredient.fromNetwork(buffer));

}

ItemStack byProductItemStack = buffer.readItem();
FluidStack inputFluidStack = buffer.readFluidStack();
FluidStack outputFluidStack = buffer.readFluidStack();
Expand All @@ -173,7 +195,7 @@ public static class Serializer implements RecipeSerializer<BrewKettleRecipe> {
int processingTime = buffer.readVarInt();
int byProductChance = buffer.readVarInt();

return new BrewKettleRecipe(recipeId, inputFluidStack, inputItemStack,
return new BrewKettleRecipe(recipeId, inputFluidStack, inputIngredients,
outputFluidStack, byProductItemStack, byProductChance, processingTime,
requiresHeat, requiresLid);
} catch (Exception ex) {
Expand All @@ -185,7 +207,12 @@ public static class Serializer implements RecipeSerializer<BrewKettleRecipe> {

@Override
public void toNetwork(FriendlyByteBuf buffer, BrewKettleRecipe recipe) {
buffer.writeItemStack(recipe.getInputItemStack(), false);
buffer.writeVarInt(recipe.inputIngredients.size());

for (Ingredient ingredient : recipe.getIngredients()) {
ingredient.toNetwork(buffer);
}

buffer.writeItemStack(recipe.getByProduct(), false);
buffer.writeFluidStack(recipe.getInputFluidStack());
buffer.writeFluidStack(recipe.getOutputFluidStack());
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/growthcraft/core/init/GrowthcraftBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ public class GrowthcraftBlocks {
Reference.UnlocalizedName.SALT_ORE,
() -> new GrowthcraftBlock(BlockBehaviour.Properties.copy(Blocks.IRON_ORE))
);

public static final RegistryObject<Block> SALT_ORE_DEEPSLATE = registerBlock(
Reference.UnlocalizedName.SALT_ORE + "_deepslate",
() -> new GrowthcraftBlock(BlockBehaviour.Properties.copy(Blocks.DEEPSLATE_IRON_ORE))
);

public static final RegistryObject<Block> SALT_ORE_NETHER = registerBlock(
Reference.UnlocalizedName.SALT_ORE + "_nether",
() -> new GrowthcraftBlock(BlockBehaviour.Properties.copy(Blocks.NETHER_GOLD_ORE))
);

public static final RegistryObject<Block> SALT_ORE_END = registerBlock(
Reference.UnlocalizedName.SALT_ORE + "_end",
() -> new GrowthcraftBlock(BlockBehaviour.Properties.copy(Blocks.IRON_ORE))
);

private static RegistryObject<Block> registerBlock(String name, Supplier<Block> block) {
return registerBlock(name, block, false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/growthcraft/core/shared/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Reference {
public static final String MODID = "growthcraft";
public static final String NAME = "Growthcraft";
public static final String NAME_SHORT = "core";
public static final String VERSION = "9.1.1";
public static final String VERSION = "9.1.2";

private Reference() { /* Prevent default public constructor */ }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
List<OreConfiguration.TargetBlockState> overworldSaltOres = List.of(
OreConfiguration.target(stoneReplaceable, GrowthcraftBlocks.SALT_ORE.get().defaultBlockState()),
// TODO: Create a deepslate version of SALT_ORE
OreConfiguration.target(deepslateReplaceable, GrowthcraftBlocks.SALT_ORE.get().defaultBlockState())
OreConfiguration.target(deepslateReplaceable, GrowthcraftBlocks.SALT_ORE_DEEPSLATE.get().defaultBlockState())
);

register(context, OVERWORLD_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(
overworldSaltOres, SALT_ORE_GEN_VEIN_SIZE));
register(context, END_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(endstoneReplaceable,
GrowthcraftBlocks.SALT_ORE.get().defaultBlockState(), 9));
GrowthcraftBlocks.SALT_ORE_END.get().defaultBlockState(), 9));
register(context, NETHER_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(netherrackReplaceable,
GrowthcraftBlocks.SALT_ORE.get().defaultBlockState(), 9));
GrowthcraftBlocks.SALT_ORE_NETHER.get().defaultBlockState(), 9));
}

private static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/growthcraft/lib/utils/CraftingUtils.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package growthcraft.lib.utils;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
Expand All @@ -23,5 +26,24 @@ public static FluidStack getFluidStack(JsonObject json) {
return new FluidStack(fluid, fluidAmount);
}

public static NonNullList<Ingredient> readIngredient(JsonObject ingredientObject) {
NonNullList<Ingredient> nonnulllist = NonNullList.create();
nonnulllist.add(Ingredient.fromJson(ingredientObject));
return nonnulllist;
}

public static NonNullList<Ingredient> readIngredients(JsonArray ingredientArray) {
NonNullList<Ingredient> nonnulllist = NonNullList.create();

for (int i = 0; i < ingredientArray.size(); ++i) {
Ingredient ingredient = Ingredient.fromJson(ingredientArray.get(i));
if (!ingredient.isEmpty()) {
nonnulllist.add(ingredient);
}
}

return nonnulllist;
}

private CraftingUtils() { /* Prevent automatic public constructor */ }
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
package growthcraft.milk.datagen;

import growthcraft.milk.datagen.loot.GrowthcraftMilkLootTables;
import growthcraft.milk.datagen.providers.GrowthcraftMilkBlockStateProvider;
import growthcraft.milk.datagen.providers.GrowthcraftMilkLootTableProvider;
import growthcraft.milk.init.GrowthcraftMilkItems;
import growthcraft.milk.shared.Reference;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

public class DataGeneration {
public static void generate(GatherDataEvent event) {
@Mod.EventBusSubscriber(modid = Reference.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class GrowthcraftMilkDataGenerators {

@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
PackOutput output = generator.getPackOutput();
ExistingFileHelper helper = event.getExistingFileHelper();

generator.addProvider(
event.includeServer(),
new GrowthcraftMilkLootTables(output)
new GrowthcraftMilkLootTableProvider(output)
);


generator.addProvider(event.includeClient(), new GrowthcraftMilkBlockStates(output, helper));
generator.addProvider(event.includeClient(), new GrowthcraftMilkBlockStateProvider(output, helper));

}

//@SubscribeEvent
public static void modelBake(ModelEvent.ModifyBakingResult event) {
GrowthcraftMilkItems.addItemModelProperties();
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package growthcraft.milk.datagen;
package growthcraft.milk.datagen.providers;

import growthcraft.milk.init.GrowthcraftMilkBlocks;
import growthcraft.milk.shared.Reference;
Expand All @@ -18,11 +18,11 @@
import static growthcraft.milk.block.BaseCheeseWheel.SLICE_COUNT_BOTTOM;
import static growthcraft.milk.block.BaseCheeseWheel.SLICE_COUNT_TOP;

public class GrowthcraftMilkBlockStates extends BlockStateProvider {
public class GrowthcraftMilkBlockStateProvider extends BlockStateProvider {

private final ModelFile empty_model = models().getExistingFile(new ResourceLocation("growthcraft", "block/empty"));

public GrowthcraftMilkBlockStates(PackOutput output, ExistingFileHelper exFileHelper) {
public GrowthcraftMilkBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper) {
super(output, Reference.MODID, exFileHelper);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package growthcraft.milk.datagen.loot;
package growthcraft.milk.datagen.providers;

import growthcraft.milk.datagen.providers.loot.CheeseWheelLootTable;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;

import java.util.Collections;
import java.util.List;

public class GrowthcraftMilkLootTables extends LootTableProvider {
public GrowthcraftMilkLootTables(PackOutput output) {
public class GrowthcraftMilkLootTableProvider extends LootTableProvider {
public GrowthcraftMilkLootTableProvider(PackOutput output) {
super(output, Collections.emptySet(), List.of(
new LootTableProvider.SubProviderEntry(CheeseWheelLoot::new, LootContextParamSets.BLOCK)
new LootTableProvider.SubProviderEntry(CheeseWheelLootTable::new, LootContextParamSets.BLOCK)
));
}
}
Loading

0 comments on commit a44e5a1

Please sign in to comment.