Skip to content

Commit

Permalink
Prevent crash when more than 256 compostables have been for the Compo…
Browse files Browse the repository at this point in the history
…ster, Closes #95
  • Loading branch information
GirafiStudios committed Mar 13, 2020
1 parent 05b4308 commit 9ae6255
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
minecraft_version=1.15.2
forge_version=31.1.16
mappings=20200127-1.15.1
mod_version=2.0.10
mod_version=2.0.11
jei_version=6.0.0.2

org.gradle.jvmargs=-Xmx4G
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public WormFarmBlock() {
}

public static void addCompostables() {
CHANCES.put(AquaItems.ALGAE.asItem(), 0.3F);
registerCompostable(AquaItems.ALGAE.asItem(), 0.3F);
if (AquaConfig.BASIC_OPTIONS.compostableFish.get()) {
for (Item fish : AquacultureAPI.FISH_DATA.getFish()) {
double weight = AquacultureAPI.FISH_DATA.getMinWeight(fish);
Expand All @@ -43,13 +43,17 @@ public static void addCompostables() {
weight = fishStack.getTag().getDouble("fishWeight");
}
float chance = MathHelper.clamp((FishWeightHandler.getFilletAmountFromWeight(weight) * 0.25F), 0.05F, 0.65F);
if (!CHANCES.containsKey(fish)) {
CHANCES.put(fish, chance);
}
registerCompostable(fish, chance);
}
}
}

public static void registerCompostable(Item item, float chance) {
if (!CHANCES.containsKey(item) && CHANCES.size() < 256) {
CHANCES.put(item, chance);
}
}

@Override
@Nonnull
public ActionResultType onBlockActivated(BlockState state, @Nonnull World world, @Nonnull BlockPos pos, PlayerEntity player, @Nonnull Hand hand, BlockRayTraceResult raytrace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static List<ShapelessRecipe> createFilletKnifeRecipes() {

for (Item fish : AquacultureAPI.FISH_DATA.getFish()) {
Tag<Item> filletKnifeTag = AquacultureAPI.Tags.FILLET_KNIFE;
Ingredient filletKnifes = Ingredient.fromItems(AquaItems.WOODEN_FILLET_KNIFE, AquaItems.STONE_FILLET_KNIFE, AquaItems.IRON_FILLET_KNIFE, AquaItems.GOLD_FILLET_KNIFE, AquaItems.DIAMOND_FILLET_KNIFE);
Ingredient filletKnifes = Ingredient.fromItems(AquaItems.WOODEN_FILLET_KNIFE, AquaItems.STONE_FILLET_KNIFE, AquaItems.IRON_FILLET_KNIFE, AquaItems.GOLD_FILLET_KNIFE, AquaItems.DIAMOND_FILLET_KNIFE, AquaItems.NEPTINIUM_FILLET_KNIFE);
NonNullList<Ingredient> input = NonNullList.from(Ingredient.EMPTY, filletKnifeTag.getAllElements().isEmpty() ? filletKnifes : Ingredient.fromTag(filletKnifeTag), Ingredient.fromItems(fish));
if (AquacultureAPI.FISH_DATA.hasFilletAmount(fish)) {
ItemStack output = new ItemStack(AquaItems.FISH_FILLET, AquacultureAPI.FISH_DATA.getFilletAmount(fish));
Expand Down

0 comments on commit 9ae6255

Please sign in to comment.