diff --git a/build.gradle b/build.gradle index 209c8e59..cef7fc7b 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ //file:noinspection GroovyAccessibility //file:noinspection GradlePackageVersionRange plugins { - id "fabric-loom" version "1.4.+" + id "fabric-loom" version "1.5.+" id "maven-publish" id "me.modmuss50.mod-publish-plugin" version "0.3.5" } diff --git a/changelog/1.2.11.md b/changelog/1.2.11.md index 74938084..02f2e166 100644 --- a/changelog/1.2.11.md +++ b/changelog/1.2.11.md @@ -1,4 +1,4 @@ -## Create: Enchantment Industry 1.2.10 +## Create: Enchantment Industry 1.2.11 ### Update - Fix items in the right most slot being dropped when clicked inside the Printing Guide menu diff --git a/changelog/1.2.12.md b/changelog/1.2.12.md new file mode 100644 index 00000000..ee3df45c --- /dev/null +++ b/changelog/1.2.12.md @@ -0,0 +1,4 @@ +## Create: Enchantment Industry 1.2.12 + +### Update +- Fix NPE with jade diff --git a/gradle.properties b/gradle.properties index 9fc1bfc0..25c2198e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G # Mod Info maven_group = plus.dragons.createenchantmentindustry archives_base_name = create_enchantment_industry -mod_version = 1.2.11 +mod_version = 1.2.12 minecraft_version = 1.20.1 diff --git a/src/main/java/plus/dragons/createenchantmentindustry/foundation/mixin/AbstractFurnaceBlockEntityMixin.java b/src/main/java/plus/dragons/createenchantmentindustry/foundation/mixin/AbstractFurnaceBlockEntityMixin.java index d41775fb..6cefc200 100644 --- a/src/main/java/plus/dragons/createenchantmentindustry/foundation/mixin/AbstractFurnaceBlockEntityMixin.java +++ b/src/main/java/plus/dragons/createenchantmentindustry/foundation/mixin/AbstractFurnaceBlockEntityMixin.java @@ -45,33 +45,29 @@ import javax.annotation.Nullable; @Mixin(AbstractFurnaceBlockEntity.class) -abstract public class AbstractFurnaceBlockEntityMixin extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder, StackedContentsCompatible, SidedStorageBlockEntity { +abstract public class AbstractFurnaceBlockEntityMixin extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder, StackedContentsCompatible, SidedStorageBlockEntity { protected AbstractFurnaceBlockEntityMixin(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); } - @Shadow - private Object2IntOpenHashMap recipesUsed; + @Shadow @Final private Object2IntOpenHashMap recipesUsed; @Unique protected long calculateExperienceStored() { double total = 0.0; for (var entry : recipesUsed.object2IntEntrySet()) { - total += getLevel().getRecipeManager().byKey(entry.getKey()).map(recipe -> { - return (double)((AbstractCookingRecipe) recipe).getExperience() * entry.getIntValue(); - }).orElse(0.0); + total += getLevel().getRecipeManager().byKey(entry.getKey()).map(recipe -> (double)((AbstractCookingRecipe) recipe).getExperience() * entry.getIntValue()).orElse(0.0); } total *= UNIT_PER_MB; - EnchantmentIndustry.LOGGER.debug("Furnace XP amount: {}", total); return (long)total; } - @Inject(method = "setRecipeUsed", at = @At("TAIL"), cancellable = true) + @Inject(method = "setRecipeUsed", at = @At("TAIL")) private void injectSetRecipeUsed(@Nullable Recipe recipe, CallbackInfo ci) { if (recipe != null) { long amount = internalTank.getFluidAmount(); amount += (amount == 0) ? calculateExperienceStored() : - Math.floor(((AbstractCookingRecipe) recipe).getExperience() * UNIT_PER_MB); + (long) Math.floor(((AbstractCookingRecipe) recipe).getExperience() * UNIT_PER_MB); internalTank.setFluid(new FluidStack(FluidVariant.of(CeiFluids.EXPERIENCE.getSource()), amount)); } } @@ -87,19 +83,16 @@ protected void onContentsChanged() { return; } - EnchantmentIndustry.LOGGER.debug("Furnace XP removing recipes for a total of {} out of {}", diff, total); - if (diff >= total) { - EnchantmentIndustry.LOGGER.debug("Furnace XP removing all recipes"); recipesUsed.clear(); return; } var recipeManager = getLevel().getRecipeManager(); var it = recipesUsed.object2IntEntrySet(); - var entriesUsed = StreamSupport.stream(it.spliterator(), false) + var entriesUsed = it.stream() .filter(e -> recipeManager.byKey(e.getKey()).isPresent()) - .collect(Collectors.toList()); + .toList(); for (var entry : entriesUsed) { var usedRecipe = (AbstractCookingRecipe)recipeManager.byKey(entry.getKey()).get(); long experience = (long)(usedRecipe.getExperience() * UNIT_PER_MB); @@ -107,7 +100,6 @@ protected void onContentsChanged() { if (count > 0) { diff -= experience; recipesUsed.addTo(usedRecipe.getId(), -count); - EnchantmentIndustry.LOGGER.debug("Furnace XP removed {} recipe {} times", entry.getKey(), count); } } } @@ -118,9 +110,8 @@ protected void onContentsChanged() { @Override public @Nullable Storage getFluidStorage(Direction side) { - if (side.getAxis().isHorizontal()) { - return exposedExperienceTank; - } - return null; + if (side != null && side.getAxis().isHorizontal()) + return exposedExperienceTank; + return null; } }