From daefcc4dbfa7957245e92388eae89ec6f540aae2 Mon Sep 17 00:00:00 2001 From: Aleksey Date: Sun, 27 Jun 2021 17:30:15 +0300 Subject: [PATCH 1/4] Fix #216 and #217 --- build.gradle | 6 +++++- gradle.properties | 2 +- src/main/java/ru/betterend/blocks/EndStoneSmelter.java | 4 ++-- .../blocks/entities/EndStoneSmelterBlockEntity.java | 6 +++--- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 83414897..4411ad02 100644 --- a/build.gradle +++ b/build.gradle @@ -70,12 +70,16 @@ def useApi(String dep) { processResources { inputs.property "version", project.version - duplicatesStrategy = 'WARN' + duplicatesStrategy = 'EXCLUDE' from(sourceSets.main.resources.srcDirs) { include "fabric.mod.json" expand "version": project.version } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } } // ensure that the encoding is set to UTF-8, no matter what the system default is diff --git a/gradle.properties b/gradle.properties index 7c15972e..5f798ac2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,5 +17,5 @@ archives_base_name = better-end patchouli_version = 50-FABRIC fabric_version = 0.32.9+1.16 canvas_version = 1.0.+ -bclib_version = 0.1.42 +bclib_version = 0.1.44 rei_version = 5.8.10 \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/EndStoneSmelter.java b/src/main/java/ru/betterend/blocks/EndStoneSmelter.java index 46e17878..2cf18798 100644 --- a/src/main/java/ru/betterend/blocks/EndStoneSmelter.java +++ b/src/main/java/ru/betterend/blocks/EndStoneSmelter.java @@ -52,7 +52,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity { .resistance(100F) .requiresCorrectToolForDrops() .sound(SoundType.STONE)); - this.registerDefaultState(this.stateDefinition.any() + registerDefaultState(this.stateDefinition.any() .setValue(FACING, Direction.NORTH) .setValue(LIT, false)); } @@ -75,7 +75,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity { @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { - return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); + return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); } @Override diff --git a/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java index 49516b35..27c54ef4 100644 --- a/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java @@ -246,7 +246,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme if (recipe == null) { recipe = level.getRecipeManager().getRecipeFor(RecipeType.BLASTING, this, level).orElse(null); } - boolean accepted = this.canAcceptRecipeOutput(recipe); + boolean accepted = canAcceptRecipeOutput(recipe); if (!burning && accepted) { burnTime = getFuelTime(fuel); fuelTime = burnTime; @@ -265,7 +265,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme } if (burning && accepted) { - this.smeltTime++; + smeltTime++; if (smeltTime == smeltTimeTotal) { smeltTime = 0; smeltTimeTotal = getSmeltTime(); @@ -276,7 +276,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme smeltTime = 0; } } - + burning = isBurning(); if (initialBurning != burning) { level.setBlock(worldPosition, level.getBlockState(worldPosition).setValue(EndStoneSmelter.LIT, burning), 3); setChanged(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 90a89ea6..6e5c72a4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -46,7 +46,7 @@ "fabricloader": ">=0.11.0", "fabric": ">=0.32.0", "minecraft": ">=1.16.4", - "bclib": ">=0.1.42" + "bclib": ">=0.1.44" }, "suggests": { "byg": ">=1.1.3", From 13e169c4588d0d1bc57fb05d2865ed16204e0a63 Mon Sep 17 00:00:00 2001 From: Aleksey Date: Tue, 29 Jun 2021 21:14:28 +0300 Subject: [PATCH 2/4] Possible avoid #214 --- build.gradle | 3 +++ .../ru/betterend/mixin/common/LivingEntityMixin.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4411ad02..ce8b3995 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,7 @@ def useOptional(String dep) { exclude group: "net.fabricmc.fabric-api" exclude group: "net.fabricmc" if (!dep.contains("me.shedaniel")) { + exclude group: "me.shedaniel.cloth" exclude group: "me.shedaniel" } } @@ -53,6 +54,7 @@ def useOptional(String dep) { exclude group: "net.fabricmc.fabric-api" exclude group: "net.fabricmc" if (!dep.contains("me.shedaniel")) { + exclude group: "me.shedaniel.cloth" exclude group: "me.shedaniel" } } @@ -63,6 +65,7 @@ def useApi(String dep) { exclude group: "net.fabricmc.fabric-api" exclude group: "net.fabricmc" if (!dep.contains("me.shedaniel")) { + exclude group: "me.shedaniel.cloth" exclude group: "me.shedaniel" } } diff --git a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java index b4e430d6..93c28174 100644 --- a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java @@ -32,6 +32,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import ru.betterend.BetterEnd; import ru.betterend.interfaces.FallFlyingItem; import ru.betterend.interfaces.MobEffectApplier; import ru.betterend.item.CrystaliteArmor; @@ -89,8 +90,12 @@ public abstract class LivingEntityMixin extends Entity { @Inject(method = "canBeAffected", at = @At("HEAD"), cancellable = true) public void be_canBeAffected(MobEffectInstance mobEffectInstance, CallbackInfoReturnable info) { - if (mobEffectInstance.getEffect() == MobEffects.BLINDNESS && getAttributes().getValue(EndAttributes.BLINDNESS_RESISTANCE) > 0.0) { - info.setReturnValue(false); + try { + if (mobEffectInstance.getEffect() == MobEffects.BLINDNESS && getAttributes().getValue(EndAttributes.BLINDNESS_RESISTANCE) > 0.0) { + info.setReturnValue(false); + } + } catch (Exception ex) { + BetterEnd.LOGGER.warning("Blindness resistance attribute haven't registered."); } } From 3f225c59a172447f327245fa80e591c59342c5a9 Mon Sep 17 00:00:00 2001 From: Aleksey Date: Wed, 30 Jun 2021 16:20:16 +0300 Subject: [PATCH 3/4] Possibility to add NBT data for Infusion recipes output (#215) --- build.gradle | 26 +++++++++---------- gradle.properties | 8 +++--- .../mixin/common/LivingEntityMixin.java | 2 +- .../particle/InfusionParticleType.java | 13 +++++----- .../recipe/builders/InfusionRecipe.java | 14 ++++++++++ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index ce8b3995..9a618e8b 100644 --- a/build.gradle +++ b/build.gradle @@ -43,30 +43,30 @@ dependencies { def useOptional(String dep) { dependencies.modRuntime (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel.cloth" - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } dependencies.modCompileOnly (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel.cloth" - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } } def useApi(String dep) { dependencies.modApi (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel.cloth" - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } } @@ -162,4 +162,4 @@ task release(dependsOn: [remapJar, sourcesJar, javadocJar]) { // // uncomment to publish to the local maven // // mavenLocal() // } -//} +//} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 5f798ac2..a0581cf9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,8 +14,8 @@ archives_base_name = better-end # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -patchouli_version = 50-FABRIC -fabric_version = 0.32.9+1.16 -canvas_version = 1.0.+ +patchouli_version = 53-FABRIC +fabric_version = 0.36.0+1.16 bclib_version = 0.1.44 -rei_version = 5.8.10 \ No newline at end of file +rei_version = 5.12.248 +canvas_version = 1.0.+ \ No newline at end of file diff --git a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java index 93c28174..565976a8 100644 --- a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java @@ -95,7 +95,7 @@ public abstract class LivingEntityMixin extends Entity { info.setReturnValue(false); } } catch (Exception ex) { - BetterEnd.LOGGER.warning("Blindness resistance attribute haven't registered."); + BetterEnd.LOGGER.warning("Blindness resistance attribute haven't been registered."); } } diff --git a/src/main/java/ru/betterend/particle/InfusionParticleType.java b/src/main/java/ru/betterend/particle/InfusionParticleType.java index 672f3ab9..bda8fe13 100644 --- a/src/main/java/ru/betterend/particle/InfusionParticleType.java +++ b/src/main/java/ru/betterend/particle/InfusionParticleType.java @@ -17,11 +17,10 @@ import ru.bclib.util.ColorUtil; import ru.betterend.registry.EndParticles; public class InfusionParticleType extends ParticleType implements ParticleOptions { - public static final Codec CODEC = ItemStack.CODEC.xmap(itemStack -> { - return new InfusionParticleType(EndParticles.INFUSION, itemStack); - }, infusionParticleType -> { - return infusionParticleType.itemStack; - }); + public static final Codec CODEC = ItemStack.CODEC.xmap( + itemStack -> new InfusionParticleType(EndParticles.INFUSION, itemStack), + infusionParticleType -> infusionParticleType.itemStack); + public static final ParticleOptions.Deserializer PARAMETERS_FACTORY = new ParticleOptions.Deserializer() { public InfusionParticleType fromCommand(ParticleType particleType, StringReader stringReader) throws CommandSyntaxException { stringReader.expect(' '); @@ -35,8 +34,8 @@ public class InfusionParticleType extends ParticleType imp } }; - private ParticleType type; - private ItemStack itemStack; + private final ParticleType type; + private final ItemStack itemStack; public InfusionParticleType(ParticleType particleType, ItemStack stack) { super(true, PARAMETERS_FACTORY); diff --git a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java index b05b2f37..f1186d59 100644 --- a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java @@ -4,11 +4,15 @@ import java.util.Arrays; import com.google.gson.JsonObject; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.core.NonNullList; +import net.minecraft.nbt.*; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagLoader; import net.minecraft.util.GsonHelper; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; @@ -17,6 +21,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; +import net.minecraft.world.level.storage.loot.GsonAdapterFactory; import ru.bclib.recipes.BCLRecipeManager; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; @@ -209,6 +214,15 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { if (recipe.output == null) { throw new IllegalStateException("Output item does not exists!"); } + if (result.has("nbt")) { + try { + String nbtData = GsonHelper.getAsString(result, "nbt"); + CompoundTag nbt = TagParser.parseTag(nbtData); + recipe.output.setTag(nbt); + } catch (CommandSyntaxException ex) { + BetterEnd.LOGGER.warning("Error parse nbt data for output.", ex); + } + } recipe.group = GsonHelper.getAsString(json, "group", GROUP); recipe.time = GsonHelper.getAsInt(json, "time", 1); From e28dcf1ee4032fcc58b1ec03ba5c14e66a269825 Mon Sep 17 00:00:00 2001 From: Aleksey Date: Wed, 30 Jun 2021 16:23:32 +0300 Subject: [PATCH 4/4] Possibility to add NBT data for Anvil recipes output --- .../ru/betterend/recipe/builders/AnvilRecipe.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java b/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java index 2a9ed475..0bee9b39 100644 --- a/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java @@ -4,9 +4,12 @@ import java.util.Objects; import com.google.gson.JsonObject; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.TagParser; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.Tag; @@ -276,6 +279,15 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { if (output == null) { throw new IllegalStateException("Output item does not exists!"); } + if (result.has("nbt")) { + try { + String nbtData = GsonHelper.getAsString(result, "nbt"); + CompoundTag nbt = TagParser.parseTag(nbtData); + output.setTag(nbt); + } catch (CommandSyntaxException ex) { + BetterEnd.LOGGER.warning("Error parse nbt data for output.", ex); + } + } int inputCount = GsonHelper.getAsInt(json, "inputCount", 1); int toolLevel = GsonHelper.getAsInt(json, "toolLevel", 1); int anvilLevel = GsonHelper.getAsInt(json, "anvilLevel", 1);