From 78295027103a7a69b04c17642c03723d79c36e31 Mon Sep 17 00:00:00 2001 From: UltrusBot <13109003+UltrusBot@users.noreply.github.com> Date: Tue, 28 May 2024 21:25:08 -0400 Subject: [PATCH 1/4] Add Seismic Sense --- .../enchantment/seismic_sense.json | 41 +++++++ .../tags/block/seismic_sense_blacklist.json | 8 ++ .../tags/enchantment/category/secondary.json | 3 +- .../enchantment/exclusive_set/mining.json | 3 +- .../enchiridion/Enchiridion.java | 1 + .../client/GlowingBlocksClientHolder.java | 100 ++++++++++++++++++ .../command/BlockHighlightCommand.java | 77 ++++++++++++++ .../enchiridion/data/GlowingBlocks.java | 14 +++ .../enchantment/effects/BlockMinedEffect.java | 16 +++ .../effects/HighlightMinedBlocksEffect.java | 85 +++++++++++++++ .../mixin/client/LevelRendererMixin.java | 29 +++++ .../SetOutlinedBlocksClientboundPacket.java | 43 ++++++++ ...nchiridionEnchantmentEffectComponents.java | 4 + .../registry/EnchiridionEnchantments.java | 14 +-- ...EnchiridionLocationEnchantmentEffects.java | 14 +++ .../assets/enchiridion/textures/dummy.png | Bin 0 -> 4734 bytes .../main/resources/enchiridion.mixins.json | 1 + .../enchiridion/EnchiridionFabric.java | 60 +++++++++-- .../client/EnchiridionFabricClient.java | 9 ++ .../datagen/EnchiridionDatagen.java | 11 +- 20 files changed, 516 insertions(+), 17 deletions(-) create mode 100644 common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json create mode 100644 common/src/generated/resources/data/enchiridion/tags/block/seismic_sense_blacklist.json create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/client/GlowingBlocksClientHolder.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/command/BlockHighlightCommand.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/data/GlowingBlocks.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/BlockMinedEffect.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/HighlightMinedBlocksEffect.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/mixin/client/LevelRendererMixin.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/network/clientbound/SetOutlinedBlocksClientboundPacket.java create mode 100644 common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionLocationEnchantmentEffects.java create mode 100644 common/src/main/resources/assets/enchiridion/textures/dummy.png diff --git a/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json new file mode 100644 index 0000000..43da844 --- /dev/null +++ b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json @@ -0,0 +1,41 @@ +{ + "anvil_cost": 1, + "description": { + "translate": "enchantment.enchiridion.seismic_sense" + }, + "effects": { + "enchiridion:block_broken": [ + { + "effect": { + "type": "enchiridion:highlight_blocks", + "blacklist": "minecraft:base_stone_overworld", + "duration": { + "type": "minecraft:linear", + "base": 40.0, + "per_level_above_first": 20.0 + }, + "invert_list": false, + "range": { + "type": "minecraft:linear", + "base": 3.0, + "per_level_above_first": 2.0 + } + } + } + ] + }, + "max_cost": { + "base": 35, + "per_level_above_first": 0 + }, + "max_level": 1, + "min_cost": { + "base": 12, + "per_level_above_first": 4 + }, + "slots": [ + "mainhand" + ], + "supported_items": "#minecraft:enchantable/mining", + "weight": 1 +} \ No newline at end of file diff --git a/common/src/generated/resources/data/enchiridion/tags/block/seismic_sense_blacklist.json b/common/src/generated/resources/data/enchiridion/tags/block/seismic_sense_blacklist.json new file mode 100644 index 0000000..3780184 --- /dev/null +++ b/common/src/generated/resources/data/enchiridion/tags/block/seismic_sense_blacklist.json @@ -0,0 +1,8 @@ +{ + "values": [ + "minecraft:stone", + "minecraft:deepslate", + "minecraft:netherrack", + "minecraft:end_stone" + ] +} \ No newline at end of file diff --git a/common/src/generated/resources/data/enchiridion/tags/enchantment/category/secondary.json b/common/src/generated/resources/data/enchiridion/tags/enchantment/category/secondary.json index 9d44f5c..687f531 100644 --- a/common/src/generated/resources/data/enchiridion/tags/enchantment/category/secondary.json +++ b/common/src/generated/resources/data/enchiridion/tags/enchantment/category/secondary.json @@ -12,6 +12,7 @@ "minecraft:swift_sneak", "enchiridion:exhilarating", "enchiridion:ice_strike", - "enchiridion:reach" + "enchiridion:reach", + "enchiridion:seismic_sense" ] } \ No newline at end of file diff --git a/common/src/generated/resources/data/minecraft/tags/enchantment/exclusive_set/mining.json b/common/src/generated/resources/data/minecraft/tags/enchantment/exclusive_set/mining.json index e6be2f9..2ba07a8 100644 --- a/common/src/generated/resources/data/minecraft/tags/enchantment/exclusive_set/mining.json +++ b/common/src/generated/resources/data/minecraft/tags/enchantment/exclusive_set/mining.json @@ -1,5 +1,6 @@ { "values": [ - "enchiridion:crumble" + "enchiridion:crumble", + "enchiridion:seismic_sense" ] } \ No newline at end of file diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/Enchiridion.java b/common/src/main/java/dev/greenhouseteam/enchiridion/Enchiridion.java index e3c97bc..a7d0c3d 100644 --- a/common/src/main/java/dev/greenhouseteam/enchiridion/Enchiridion.java +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/Enchiridion.java @@ -33,6 +33,7 @@ public static EnchiridionPlatformHelper getHelper() { public static class BlockTags { public static final TagKey BASE_STONE = TagKey.create(Registries.BLOCK, asResource("base_stone")); public static final TagKey HARDER_STONE = TagKey.create(Registries.BLOCK, asResource("harder_stone")); + public static final TagKey SEISMIC_SENSE_BLACKLIST = TagKey.create(Registries.BLOCK, asResource("seismic_sense_blacklist")); } public static class EnchantmentTags { diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/client/GlowingBlocksClientHolder.java b/common/src/main/java/dev/greenhouseteam/enchiridion/client/GlowingBlocksClientHolder.java new file mode 100644 index 0000000..9fba143 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/client/GlowingBlocksClientHolder.java @@ -0,0 +1,100 @@ +package dev.greenhouseteam.enchiridion.client; + +import com.mojang.blaze3d.vertex.*; +import dev.greenhouseteam.enchiridion.Enchiridion; +import net.minecraft.client.Camera; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.FastColor; +import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; + +import java.util.EnumSet; +import java.util.List; + +public class GlowingBlocksClientHolder { + + public static List outlinedBlocks; + public static int color; + public static int duration; + public static int red; + public static int green; + public static int blue; + + private static EntityRenderDispatcher entityRenderer; + private static final ModelPart.Cube BLOCK = new ModelPart.Cube( + 0, 0, + 0, 0, 0, + 16, 16, 16, + 0, 0, 0, + false, + 0, 0, EnumSet.allOf(Direction.class)); + private static final RenderType GLOWING = RenderType.outline(Enchiridion.asResource("textures/dummy.png")); + + public static boolean isGlowing() { + return outlinedBlocks != null && !outlinedBlocks.isEmpty(); + } + + + public static void clearGlowingBlocks() { + outlinedBlocks = List.of(); + } + + public static void setGlowingBlocks(List outlinedBlocks, int color, int duration) { + + for (BlockPos pos : outlinedBlocks) { + Enchiridion.LOGGER.info("Block pos: {}", pos); + } + GlowingBlocksClientHolder.outlinedBlocks = outlinedBlocks; + GlowingBlocksClientHolder.color = color; + GlowingBlocksClientHolder.red = FastColor.ARGB32.red(color); + GlowingBlocksClientHolder.green = FastColor.ARGB32.green(color); + GlowingBlocksClientHolder.blue = FastColor.ARGB32.blue(color); + GlowingBlocksClientHolder.duration = duration; + } + + public static void tick(ClientLevel clientLevel) { + if (duration > 0) { + duration--; + } + if (duration == 0) { + outlinedBlocks = List.of(); + } + } + + public static void render(GameRenderer gameRenderer, Camera camera, @Nullable PoseStack poseStack, Matrix4f matrix4f, Matrix4f f, @Nullable MultiBufferSource consumers) { + if (entityRenderer == null) { + entityRenderer = gameRenderer.getMinecraft().getEntityRenderDispatcher(); + } + if (poseStack == null && consumers == null) { + return; + } + + if (outlinedBlocks != null && !outlinedBlocks.isEmpty()) { + OutlineBufferSource bufferSource = gameRenderer.getMinecraft().renderBuffers().outlineBufferSource(); + poseStack.pushPose(); + poseStack.translate(-camera.getPosition().x(), -camera.getPosition().y(), -camera.getPosition().z()); + bufferSource.setColor(red, green, blue, 255); + var buffer = bufferSource.getBuffer(GLOWING); + for (BlockPos pos : outlinedBlocks) { + poseStack.pushPose(); + poseStack.translate(pos.getX(), pos.getY(), pos.getZ()); + BLOCK.compile( + poseStack.last(), + buffer, + 0, + OverlayTexture.NO_OVERLAY, + 0, 0, 0, 0 + ); + poseStack.popPose(); + } + poseStack.popPose(); + } + + } +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/command/BlockHighlightCommand.java b/common/src/main/java/dev/greenhouseteam/enchiridion/command/BlockHighlightCommand.java new file mode 100644 index 0000000..e8ba491 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/command/BlockHighlightCommand.java @@ -0,0 +1,77 @@ +package dev.greenhouseteam.enchiridion.command; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import dev.greenhouseteam.enchiridion.Enchiridion; +import dev.greenhouseteam.enchiridion.network.clientbound.SetOutlinedBlocksClientboundPacket; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.blocks.BlockStateArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MapColor; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class BlockHighlightCommand { + + private static int executeCommand(CommandContext context) throws CommandSyntaxException { + CommandSourceStack source = context.getSource(); + if (!source.isPlayer()) { + return 0; + } + ServerPlayer player = source.getPlayerOrException(); + Block block = BlockStateArgument.getBlock(context, "block").getState().getBlock(); + var range = IntegerArgumentType.getInteger(context, "range"); + var color = block.defaultMapColor().calculateRGBColor(MapColor.Brightness.HIGH); + int duration = IntegerArgumentType.getInteger(context, "duration"); + Iterator blocks = BlockPos.withinManhattan( + player.blockPosition(), + range, + range, + range + ).iterator(); + List blocksList = new ArrayList<>(); + while (blocks.hasNext()) { + BlockPos pos = blocks.next(); + BlockState state = player.level().getBlockState(pos); + if (state.getBlock().equals(block)) { + blocksList.add(new BlockPos(pos)); // To deal with mutable BlockPos + } + } + + Enchiridion.getHelper().sendClientbound(player, new SetOutlinedBlocksClientboundPacket( + blocksList, + color, + duration + + )); + + + return 1; + } + + public static void register(CommandDispatcher commandDispatcher, CommandBuildContext commandBuildContext) { + commandDispatcher.register( + Commands.literal("blockhighlight") + .then( + Commands.argument("block", BlockStateArgument.block(commandBuildContext)) + .then( + Commands.argument("range", IntegerArgumentType.integer(1)) + .then( + Commands.argument("duration", IntegerArgumentType.integer(1)) + .executes(BlockHighlightCommand::executeCommand) + ) + ) + ) + ); + + } +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/data/GlowingBlocks.java b/common/src/main/java/dev/greenhouseteam/enchiridion/data/GlowingBlocks.java new file mode 100644 index 0000000..2e738c9 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/data/GlowingBlocks.java @@ -0,0 +1,14 @@ +package dev.greenhouseteam.enchiridion.data; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.BlockPos; + +import java.util.List; + +public record GlowingBlocks(List glowingBlocks, int highlightColor) { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + BlockPos.CODEC.listOf().fieldOf("glowingBlocks").forGetter(GlowingBlocks::glowingBlocks), + Codec.INT.fieldOf("highlightColor").forGetter(GlowingBlocks::highlightColor) + ).apply(instance, GlowingBlocks::new)); +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/BlockMinedEffect.java b/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/BlockMinedEffect.java new file mode 100644 index 0000000..ec0bd40 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/BlockMinedEffect.java @@ -0,0 +1,16 @@ +package dev.greenhouseteam.enchiridion.enchantment.effects; + +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.enchantment.EnchantedItemInUse; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; + + +/** + * Represents an enchantment effect that is triggered when a block is mined by a player. + */ +public interface BlockMinedEffect { + + void onBlockMined(ServerLevel serverLevel, int i, EnchantedItemInUse enchantedItemInUse, Entity entity, Vec3 vec3, BlockState block); +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/HighlightMinedBlocksEffect.java b/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/HighlightMinedBlocksEffect.java new file mode 100644 index 0000000..2cac088 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/enchantment/effects/HighlightMinedBlocksEffect.java @@ -0,0 +1,85 @@ +package dev.greenhouseteam.enchiridion.enchantment.effects; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.greenhouseteam.enchiridion.Enchiridion; +import dev.greenhouseteam.enchiridion.network.clientbound.SetOutlinedBlocksClientboundPacket; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.DiggerItem; +import net.minecraft.world.item.enchantment.EnchantedItemInUse; +import net.minecraft.world.item.enchantment.LevelBasedValue; +import net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.phys.Vec3; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public record HighlightMinedBlocksEffect(LevelBasedValue duration, LevelBasedValue range, TagKey blacklist, boolean invertList) implements BlockMinedEffect, EnchantmentLocationBasedEffect { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> inst.group( + LevelBasedValue.CODEC.fieldOf("duration").forGetter(HighlightMinedBlocksEffect::duration), + LevelBasedValue.CODEC.fieldOf("range").forGetter(HighlightMinedBlocksEffect::range), + TagKey.codec(Registries.BLOCK).fieldOf("blacklist").forGetter(HighlightMinedBlocksEffect::blacklist), + Codec.BOOL.fieldOf("invert_list").forGetter(HighlightMinedBlocksEffect::invertList) + ).apply(inst, HighlightMinedBlocksEffect::new)); + + + @Override + public void onChangedBlock(ServerLevel var1, int var2, EnchantedItemInUse var3, Entity var4, Vec3 var5, boolean var6) { + // No-op + } + + @Override + public MapCodec codec() { + return CODEC; + } + + + @Override + public void onBlockMined(ServerLevel serverLevel, int i, EnchantedItemInUse enchantedItemInUse, Entity entity, Vec3 vec3, BlockState block) { + LivingEntity livingEntity = enchantedItemInUse.owner(); + + if (block.is(blacklist) != invertList) return; + if (enchantedItemInUse.itemStack().getItem() instanceof DiggerItem diggerItem && !diggerItem.isCorrectToolForDrops(enchantedItemInUse.itemStack(), block)) return; + if (livingEntity instanceof ServerPlayer player) { + int range = (int) this.range.calculate(i); + int duration = (int) this.duration.calculate(i); + int color = block.getBlock().defaultMapColor().calculateRGBColor(MapColor.Brightness.HIGH); + // Highlight the mined block + Iterator blocks = BlockPos.withinManhattan( + player.blockPosition(), + range, + range, + range + ).iterator(); + List blocksList = new ArrayList<>(); + while (blocks.hasNext()) { + BlockPos pos = blocks.next(); + BlockState state = player.level().getBlockState(pos); + if (state.getBlock().equals(block.getBlock())) { + blocksList.add(new BlockPos(pos)); // To deal with mutable BlockPos + } + } + + Enchiridion.getHelper().sendClientbound(player, new SetOutlinedBlocksClientboundPacket( + blocksList, + color, + duration + + )); + + } + + } + +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/mixin/client/LevelRendererMixin.java b/common/src/main/java/dev/greenhouseteam/enchiridion/mixin/client/LevelRendererMixin.java new file mode 100644 index 0000000..815fe73 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/mixin/client/LevelRendererMixin.java @@ -0,0 +1,29 @@ +package dev.greenhouseteam.enchiridion.mixin.client; + +import dev.greenhouseteam.enchiridion.client.GlowingBlocksClientHolder; +import net.minecraft.client.renderer.LevelRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + + +@Mixin(LevelRenderer.class) +public class LevelRendererMixin { + + + // This is probably pretty fragile, but it works:tm: + // Thank fabric WorldRenderer mixin for having a similar injection point that lead me to this + @ModifyVariable(method = "renderLevel", + at = @At(value = "CONSTANT", + args="stringValue=blockentities", + ordinal = 0), + ordinal=3 + ) + private boolean modify(boolean value) { + // Changes the flag that makes the glowing render source actually work. + // Normally the flag is only true if there are glowing entities. + return value || GlowingBlocksClientHolder.isGlowing(); + } + + +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/network/clientbound/SetOutlinedBlocksClientboundPacket.java b/common/src/main/java/dev/greenhouseteam/enchiridion/network/clientbound/SetOutlinedBlocksClientboundPacket.java new file mode 100644 index 0000000..09eded6 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/network/clientbound/SetOutlinedBlocksClientboundPacket.java @@ -0,0 +1,43 @@ +package dev.greenhouseteam.enchiridion.network.clientbound; + +import dev.greenhouseteam.enchiridion.Enchiridion; +import dev.greenhouseteam.enchiridion.client.GlowingBlocksClientHolder; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; + +public record SetOutlinedBlocksClientboundPacket(List outlinedBlocks, int color, int duration) implements CustomPacketPayload { + public static final ResourceLocation ID = Enchiridion.asResource("set_outlined_blocks"); + public static final Type TYPE = new Type<>(ID); + + public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec( + SetOutlinedBlocksClientboundPacket::write, SetOutlinedBlocksClientboundPacket::new + ); + + public SetOutlinedBlocksClientboundPacket(FriendlyByteBuf buf) { + this(buf.readCollection(ArrayList::new, BlockPos.STREAM_CODEC), buf.readInt(), buf.readInt()); + } + + @Override + public Type type() { + return TYPE; + } + + public void write(FriendlyByteBuf buf) { + buf.writeCollection(outlinedBlocks, BlockPos.STREAM_CODEC); + buf.writeInt(color); + buf.writeInt(duration); + } + + public void handle() { + Minecraft.getInstance().execute(() -> { + GlowingBlocksClientHolder.setGlowingBlocks(outlinedBlocks, color, duration); + }); + } +} diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantmentEffectComponents.java b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantmentEffectComponents.java index 2009940..440730e 100644 --- a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantmentEffectComponents.java +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantmentEffectComponents.java @@ -47,6 +47,9 @@ public class EnchiridionEnchantmentEffectComponents { public static final DataComponentType>> VEHICLE_DAMAGE_PROTECTION = DataComponentType.>>builder() .persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, EnchiridionLootContextParamSets.VEHICLE_ENCHANTED_DAMAGE).listOf()) .build(); + public static final DataComponentType>> BLOCK_BROKEN = DataComponentType.>>builder() + .persistent(ConditionalEffect.codec(EnchantmentLocationBasedEffect.CODEC, EnchiridionLootContextParamSets.ENCHANTED_BLOCK).listOf()) + .build(); public static void registerAll(RegistrationCallback> callback) { callback.register(BuiltInRegistries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Enchiridion.asResource("allow_firing_without_projectile"), ALLOW_FIRING_WITHOUT_PROJECTILE); @@ -57,5 +60,6 @@ public static void registerAll(RegistrationCallback> callba callback.register(BuiltInRegistries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Enchiridion.asResource("target_block_changed"), TARGET_BLOCK_CHANGED); callback.register(BuiltInRegistries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Enchiridion.asResource("vehicle_changed"), VEHICLE_CHANGED); callback.register(BuiltInRegistries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Enchiridion.asResource("vehicle_damage_protection"), VEHICLE_DAMAGE_PROTECTION); + callback.register(BuiltInRegistries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Enchiridion.asResource("block_broken"), BLOCK_BROKEN); } } diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java index 014c7c9..5911339 100644 --- a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java @@ -1,12 +1,7 @@ package dev.greenhouseteam.enchiridion.registry; import dev.greenhouseteam.enchiridion.Enchiridion; -import dev.greenhouseteam.enchiridion.enchantment.effects.ExtinguishEffect; -import dev.greenhouseteam.enchiridion.enchantment.effects.FreezeEffect; -import dev.greenhouseteam.enchiridion.enchantment.effects.PreventHungerConsumptionEffect; -import dev.greenhouseteam.enchiridion.enchantment.effects.RidingConditionalEffect; -import dev.greenhouseteam.enchiridion.enchantment.effects.RidingEntityEffect; -import dev.greenhouseteam.enchiridion.enchantment.effects.RidingTarget; +import dev.greenhouseteam.enchiridion.enchantment.effects.*; import net.minecraft.advancements.critereon.BlockPredicate; import net.minecraft.advancements.critereon.DamageSourcePredicate; import net.minecraft.advancements.critereon.EntityPredicate; @@ -22,6 +17,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.BlockTags; import net.minecraft.tags.DamageTypeTags; import net.minecraft.tags.EnchantmentTags; import net.minecraft.tags.ItemTags; @@ -63,6 +59,7 @@ public class EnchiridionEnchantments { public static final ResourceKey ICE_STRIKE = ResourceKey.create(Registries.ENCHANTMENT, Enchiridion.asResource("ice_strike")); public static final ResourceKey JOUSTING = ResourceKey.create(Registries.ENCHANTMENT, Enchiridion.asResource("jousting")); public static final ResourceKey REACH = ResourceKey.create(Registries.ENCHANTMENT, Enchiridion.asResource("reach")); + public static final ResourceKey SEISMIC_SENSE = ResourceKey.create(Registries.ENCHANTMENT, Enchiridion.asResource("seismic_sense")); public static final ResourceKey ASHES_CURSE = ResourceKey.create(Registries.ENCHANTMENT, Enchiridion.asResource("ashes_curse")); @@ -182,6 +179,10 @@ public static void bootstrap(BootstrapContext context) { Enchantment.definition(miningEnchantable, 1, 2, Enchantment.dynamicCost(12, 7), Enchantment.constantCost(50), 2, EquipmentSlotGroup.MAINHAND) ).withEffect(EnchantmentEffectComponents.ATTRIBUTES, new EnchantmentAttributeEffect("enchantment.enchiridion.reach", Attributes.BLOCK_INTERACTION_RANGE, LevelBasedValue.perLevel(0.5F, 0.5F), AttributeModifier.Operation.ADD_VALUE, UUID.fromString("164c937c-f04c-4730-b8e9-d299a3a187fa"))) .build(REACH.location()); + Enchantment seismicSense = Enchantment.enchantment( + Enchantment.definition(miningEnchantable, 1, 1, Enchantment.dynamicCost(12, 4), Enchantment.constantCost(35), 1, EquipmentSlotGroup.MAINHAND) + ).withEffect(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN, new HighlightMinedBlocksEffect(LevelBasedValue.perLevel(40.0f, 20.0f), LevelBasedValue.perLevel(3.0f, 2.0f), BlockTags.BASE_STONE_OVERWORLD, false)) + .build(SEISMIC_SENSE.location()); context.register(ASHES_CURSE, ashesCurse); context.register(BARDING, barding); @@ -190,5 +191,6 @@ public static void bootstrap(BootstrapContext context) { context.register(ICE_STRIKE, iceStrike); context.register(JOUSTING, jousting); context.register(REACH, reach); + context.register(SEISMIC_SENSE, seismicSense); } } diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionLocationEnchantmentEffects.java b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionLocationEnchantmentEffects.java new file mode 100644 index 0000000..0f7c511 --- /dev/null +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionLocationEnchantmentEffects.java @@ -0,0 +1,14 @@ +package dev.greenhouseteam.enchiridion.registry; + +import com.mojang.serialization.MapCodec; +import dev.greenhouseteam.enchiridion.Enchiridion; +import dev.greenhouseteam.enchiridion.enchantment.effects.HighlightMinedBlocksEffect; +import dev.greenhouseteam.enchiridion.registry.internal.RegistrationCallback; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect; + +public class EnchiridionLocationEnchantmentEffects { + public static void registerAll(RegistrationCallback> callback) { + callback.register(BuiltInRegistries.ENCHANTMENT_LOCATION_BASED_EFFECT_TYPE, Enchiridion.asResource("highlight_blocks"), HighlightMinedBlocksEffect.CODEC); + } +} diff --git a/common/src/main/resources/assets/enchiridion/textures/dummy.png b/common/src/main/resources/assets/enchiridion/textures/dummy.png new file mode 100644 index 0000000000000000000000000000000000000000..97806db56e271cffe0aa83d692421a4d738461e5 GIT binary patch literal 4734 zcmeHLdvFuS89!>*5QAeH2oJ}=`Ai-RobFD#lkTn(u91wTBm&u1Vuv&x-(w|TtQWeI zCA;C}j1wGBoSMd@&7^^LVl#At+fbS@VLCu+niQLuq|K8A2$LbCV=%84(gf(<$I$22hYv0tk}&=;^YDTQdu$eSKy2k25nLi{*dSK9Fs=Hxz_31c`W{=yP8}hvyKCzke|fe2 z#RmsF%Gn+HEw3-FSn}b_%DeER>i3%$EVb=~fxAJ-wslqSXL^m&}l zVZWibFRW{Gxc~Trc~6|^+&X6`TjlR5a3*%QJjLF7drS2%_uRfFLGHbr`#imPiK(@* z_Ta&7hkpHd%kR2w?P^4?W}F&0`O+Ee&h^jDUel9`C36SY4fcML+<5e5^Sc8-&+s2H zzti0Pv)mL~G3P?o zg}%-X_4wVbzuo=P%x$w)&(n%em3H--_OCT@%g*<0Zu9ofD&2gjd~WX}eTSd8*Y3@K z!2k5crWbm%KgZvC^!IOlbmcQ*#@s#aGu~HPu}ya_Zfl%2KjHT^HO)Jlx8$yOw1rpB zKf_+1y;qJuaNx~XHs<-=t&6_SU4P}hWvjfec|K)lrd~Pw425=2-;?+1wRNFmyJj7@ zG2@5If(^TF>07_$_?eow3%75$qr3ZD&BcYWy%{r#zSvU0ZQ0i8TlSs7;AL-p^~pJB z9#Ow~Z}}TvWc;M#NB9Y3>XQdj&AZ=s9AEIabI0~GXRlvF9&U^O;%EuJ6hU%n1q!js zdp|El!zMwFiolc#$Dl$H#9ow&2~sW4P!R-`hyxqkw;w|l*@0CuUeX(Lf*Qr$5C;_v ztNcF`G!9VOM4L#w zB&F1uvE|vQJuV0Ma@Wcs2>9l}YBVjz6GSqZG$k#jXgo+z9LEu)nJ}AiXo0Ks5lu+p z5w%c0g15+94Cllpga*(6Cx7Op&+JHWd@3a zwy-45S_3rBh-R7*WtJpuf&nE<{K{xNEWmIoVIc^JSR`mP=!EmdK92)4o5;}`Ur5jb zumj8iB_cS&W+34;nv(D|fnl$EA9%1W{fZMNA)jUEJX6>3pOrAU*-YP9Hq;h{T_ zT0vJT1TgBMH@q_r1T7l(N24JJrcVmhdyX`FVM57*Cb$F*Kv2?5^CZKY&3=m03k-*o zux5;XR8|7@|IJ!YAJm=>x?54<`1M9rI;SeY+VorcHKZ8HgrY`T@Pd?fK^5viI$RJd z-6YirksyHU$By>X1gT%;zfCX4_vxNmXZ38sUaaIziYypmB12%z@B!h(!bTt~# zl0qC52O*D;D=1KdEA*bBP%Rm6pR56T93W*l$>2I=EYDbYip7YV?;gvLG)GBR9EgGh z1xj(aAOQhqXn|s^0UIS+{*Ao<-94xX3vc26FYd{5K;(3%XpV!c0bB?~k%1u;B@1T> zkRmIlHTf+@54va7r9KorJE5=l!&2Jm~H!y|xJ+ zlC#A7N?pcr8Trz=Zv!md5_3PKB8aI_zow)*is1hq$W+baEtz`eyL0AdAw6PeF07ib zl~ifYXjnf{A;xDukkO=~)u8%ke&wcH=R%_e9#^rS?Um%}>gvFDgrt1aR_4rOs{gw2 apok!4G*W0elHCgp5l_h~SJ#T_#(x1^(}J=9 literal 0 HcmV?d00001 diff --git a/common/src/main/resources/enchiridion.mixins.json b/common/src/main/resources/enchiridion.mixins.json index e933eaa..ba51423 100644 --- a/common/src/main/resources/enchiridion.mixins.json +++ b/common/src/main/resources/enchiridion.mixins.json @@ -26,6 +26,7 @@ "client.ContainerEventHandlerMixin", "client.EnchantmentScreenMixin", "client.ItemRendererMixin", + "client.LevelRendererMixin", "client.LivingEntityMixin", "client.ModelManagerAccessor" ], diff --git a/fabric/src/main/java/dev/greenhouseteam/enchiridion/EnchiridionFabric.java b/fabric/src/main/java/dev/greenhouseteam/enchiridion/EnchiridionFabric.java index 708079a..e1563c2 100644 --- a/fabric/src/main/java/dev/greenhouseteam/enchiridion/EnchiridionFabric.java +++ b/fabric/src/main/java/dev/greenhouseteam/enchiridion/EnchiridionFabric.java @@ -1,29 +1,28 @@ package dev.greenhouseteam.enchiridion; import com.google.common.collect.ImmutableList; +import dev.greenhouseteam.enchiridion.command.BlockHighlightCommand; import dev.greenhouseteam.enchiridion.enchantment.category.EnchantmentCategory; import dev.greenhouseteam.enchiridion.enchantment.category.ItemEnchantmentCategories; +import dev.greenhouseteam.enchiridion.enchantment.effects.BlockMinedEffect; import dev.greenhouseteam.enchiridion.mixin.CreativeModeTabsAccessor; import dev.greenhouseteam.enchiridion.mixin.fabric.LootPoolAccessor; import dev.greenhouseteam.enchiridion.mixin.fabric.LootTableBuilderAccessor; +import dev.greenhouseteam.enchiridion.network.clientbound.SetOutlinedBlocksClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantScrollIndexClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantedFrozenStateClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantmentLevelUpSeedsPacket; import dev.greenhouseteam.enchiridion.network.serverbound.SyncEnchantScrollIndexServerboundPacket; import dev.greenhouseteam.enchiridion.platform.EnchiridionPlatformHelperFabric; -import dev.greenhouseteam.enchiridion.registry.EnchiridionDataComponents; -import dev.greenhouseteam.enchiridion.registry.EnchiridionEnchantmentEffectComponents; -import dev.greenhouseteam.enchiridion.registry.EnchiridionEnchantments; -import dev.greenhouseteam.enchiridion.registry.EnchiridionEntityEnchantmentEffects; -import dev.greenhouseteam.enchiridion.registry.EnchiridionRegistries; +import dev.greenhouseteam.enchiridion.registry.*; import dev.greenhouseteam.enchiridion.util.ClientRegistryAccessReference; import dev.greenhouseteam.enchiridion.util.CreativeTabUtil; import dev.greenhouseteam.enchiridion.util.EnchiridionUtil; import dev.greenhouseteam.enchiridion.util.TagUtil; -import dev.greenhouseteam.enchiridion.util.TargetUtil; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; +import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.event.registry.DynamicRegistries; import net.fabricmc.fabric.api.item.v1.EnchantmentEvents; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; @@ -49,17 +48,27 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; +import net.minecraft.world.item.enchantment.ConditionalEffect; +import net.minecraft.world.item.enchantment.EnchantedItemInUse; import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraft.world.level.storage.loot.predicates.MatchTool; +import org.apache.commons.lang3.tuple.Triple; import java.util.ArrayList; import java.util.List; @@ -148,6 +157,41 @@ public void onInitialize() { ResourceManagerHelper.registerBuiltinResourcePack(Enchiridion.asResource("default_enchanted_books"), modContainer, Component.translatable("resourcePack.enchiridion.default_enchanted_books.name"), ResourcePackActivationType.NORMAL); ResourceManagerHelper.registerBuiltinResourcePack(Enchiridion.asResource("vanilla_enchantment_modifications"), modContainer, Component.translatable("dataPack.enchiridion.vanilla_enchantment_modifications.name"), ResourcePackActivationType.DEFAULT_ENABLED); }); + if (Enchiridion.getHelper().isDevelopmentEnvironment()) { + CommandRegistrationCallback.EVENT.register((dispatcher, context, commandSelection) -> { + BlockHighlightCommand.register(dispatcher, context); + }); + } + + PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { + var miningEnchantmentComponents = player.getMainHandItem().getEnchantments().entrySet().stream().filter(entry -> entry.getKey().isBound() && !entry.getKey().value().getEffects(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN).isEmpty()).map(entry -> Triple.of(entry.getKey(), entry.getKey().value().getEffects(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN), entry.getIntValue())).toList(); + if (miningEnchantmentComponents.isEmpty()) return; + ServerPlayer serverPlayer = (ServerPlayer) player; + LootParams.Builder params = new LootParams.Builder(serverPlayer.serverLevel()); + params.withParameter(LootContextParams.BLOCK_STATE, state); + params.withParameter(LootContextParams.ORIGIN, pos.getCenter()); + params.withParameter(LootContextParams.TOOL, player.getMainHandItem()); + params.withParameter(LootContextParams.THIS_ENTITY, player); + params.withOptionalParameter(LootContextParams.BLOCK_ENTITY, player.level().getBlockEntity(pos)); + for (Triple, List>, Integer> entry : miningEnchantmentComponents) { + for (ConditionalEffect effect : entry.getMiddle()) { + params.withParameter(LootContextParams.ENCHANTMENT_LEVEL, entry.getRight()); + LootContext context = new LootContext.Builder(params.create(EnchiridionLootContextParamSets.ENCHANTED_BLOCK)).create(Optional.empty()); + if (effect.matches(context)) { + if (effect.effect() instanceof BlockMinedEffect blockMinedEffect) { + blockMinedEffect.onBlockMined( + (ServerLevel) player.level(), + entry.getRight(), + new EnchantedItemInUse(player.getMainHandItem(), EquipmentSlot.MAINHAND, player), + player, + pos.getCenter(), + state + ); + } + } + } + } + }); } public static void registerPackets() { @@ -155,6 +199,7 @@ public static void registerPackets() { PayloadTypeRegistry.playS2C().register(SyncEnchantedFrozenStateClientboundPacket.TYPE, SyncEnchantedFrozenStateClientboundPacket.STREAM_CODEC); PayloadTypeRegistry.playS2C().register(SyncEnchantmentLevelUpSeedsPacket.TYPE, SyncEnchantmentLevelUpSeedsPacket.STREAM_CODEC); PayloadTypeRegistry.playC2S().register(SyncEnchantScrollIndexServerboundPacket.TYPE, SyncEnchantScrollIndexServerboundPacket.STREAM_CODEC); + PayloadTypeRegistry.playS2C().register(SetOutlinedBlocksClientboundPacket.TYPE, SetOutlinedBlocksClientboundPacket.STREAM_CODEC); ServerPlayNetworking.registerGlobalReceiver(SyncEnchantScrollIndexServerboundPacket.TYPE, (payload, context) -> payload.handle(context.player())); } @@ -163,6 +208,7 @@ public static void registerContents() { EnchiridionDataComponents.registerAll(Registry::register); EnchiridionEnchantmentEffectComponents.registerAll(Registry::register); EnchiridionEntityEnchantmentEffects.registerAll(Registry::register); + EnchiridionLocationEnchantmentEffects.registerAll(Registry::register); DynamicRegistries.registerSynced(EnchiridionRegistries.ENCHANTMENT_CATEGORY, EnchantmentCategory.DIRECT_CODEC); } diff --git a/fabric/src/main/java/dev/greenhouseteam/enchiridion/client/EnchiridionFabricClient.java b/fabric/src/main/java/dev/greenhouseteam/enchiridion/client/EnchiridionFabricClient.java index 1eb821f..49cffef 100644 --- a/fabric/src/main/java/dev/greenhouseteam/enchiridion/client/EnchiridionFabricClient.java +++ b/fabric/src/main/java/dev/greenhouseteam/enchiridion/client/EnchiridionFabricClient.java @@ -1,14 +1,17 @@ package dev.greenhouseteam.enchiridion.client; import dev.greenhouseteam.enchiridion.client.util.EnchiridionModelUtil; +import dev.greenhouseteam.enchiridion.network.clientbound.SetOutlinedBlocksClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantScrollIndexClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantedFrozenStateClientboundPacket; import dev.greenhouseteam.enchiridion.network.clientbound.SyncEnchantmentLevelUpSeedsPacket; import dev.greenhouseteam.enchiridion.util.TooltipUtil; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.fabricmc.fabric.api.client.model.loading.v1.PreparableModelLoadingPlugin; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import java.util.concurrent.CompletableFuture; @@ -26,11 +29,17 @@ public void onInitializeClient() { }); ItemTooltipCallback.EVENT.register(TooltipUtil::modifyEnchantmentTooltips); + + WorldRenderEvents.AFTER_ENTITIES.register((context) -> { + GlowingBlocksClientHolder.render(context.gameRenderer(), context.camera(), context.matrixStack(), context.positionMatrix(), context.projectionMatrix(), context.consumers()); + }); + ClientTickEvents.END_WORLD_TICK.register(GlowingBlocksClientHolder::tick); } public static void registerPackets() { ClientPlayNetworking.registerGlobalReceiver(SyncEnchantScrollIndexClientboundPacket.TYPE, (payload, context) -> payload.handle()); ClientPlayNetworking.registerGlobalReceiver(SyncEnchantedFrozenStateClientboundPacket.TYPE, (payload, context) -> payload.handle()); ClientPlayNetworking.registerGlobalReceiver(SyncEnchantmentLevelUpSeedsPacket.TYPE, (payload, context) -> payload.handle()); + ClientPlayNetworking.registerGlobalReceiver(SetOutlinedBlocksClientboundPacket.TYPE, (payload, context) -> payload.handle()); } } diff --git a/fabric/src/main/java/dev/greenhouseteam/enchiridion/datagen/EnchiridionDatagen.java b/fabric/src/main/java/dev/greenhouseteam/enchiridion/datagen/EnchiridionDatagen.java index ba3bbf5..314a0d2 100644 --- a/fabric/src/main/java/dev/greenhouseteam/enchiridion/datagen/EnchiridionDatagen.java +++ b/fabric/src/main/java/dev/greenhouseteam/enchiridion/datagen/EnchiridionDatagen.java @@ -98,7 +98,8 @@ protected void addTags(HolderLookup.Provider wrapperLookup) { .add(EnchiridionEnchantments.CRUMBLE); getOrCreateTagBuilder(EnchantmentTags.MINING_EXCLUSIVE) - .add(EnchiridionEnchantments.CRUMBLE); + .add(EnchiridionEnchantments.CRUMBLE) + .add(EnchiridionEnchantments.SEISMIC_SENSE); getOrCreateTagBuilder(Enchiridion.EnchantmentTags.ELEMENTAL_EXCLUSIVE) .add(Enchantments.FIRE_ASPECT) @@ -136,7 +137,8 @@ protected void addTags(HolderLookup.Provider wrapperLookup) { Enchantments.SWIFT_SNEAK, EnchiridionEnchantments.EXHILARATING, EnchiridionEnchantments.ICE_STRIKE, - EnchiridionEnchantments.REACH + EnchiridionEnchantments.REACH, + EnchiridionEnchantments.SEISMIC_SENSE ); getOrCreateTagBuilder(Enchiridion.EnchantmentTags.TERTIARY_CATEGORY) .add( @@ -179,6 +181,11 @@ protected void addTags(HolderLookup.Provider wrapperLookup) { getOrCreateTagBuilder(Enchiridion.BlockTags.HARDER_STONE) .add(Blocks.DEEPSLATE) .add(Blocks.END_STONE); + getOrCreateTagBuilder(Enchiridion.BlockTags.SEISMIC_SENSE_BLACKLIST) + .add(Blocks.STONE) + .add(Blocks.DEEPSLATE) + .add(Blocks.NETHERRACK) + .add(Blocks.END_STONE); } } From 40182231bed9f6a56b6dd226c5cfe0d26dc827e4 Mon Sep 17 00:00:00 2001 From: Pug <81167232+MerchantPug@users.noreply.github.com> Date: Wed, 29 May 2024 12:20:15 +1000 Subject: [PATCH 2/4] Translate Seismic Sense. --- common/src/main/resources/assets/enchiridion/lang/en_us.json | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/resources/assets/enchiridion/lang/en_us.json b/common/src/main/resources/assets/enchiridion/lang/en_us.json index 237118c..e2a5556 100644 --- a/common/src/main/resources/assets/enchiridion/lang/en_us.json +++ b/common/src/main/resources/assets/enchiridion/lang/en_us.json @@ -6,6 +6,7 @@ "enchantment.enchiridion.ice_strike": "Ice Strike", "enchantment.enchiridion.jousting": "Jousting", "enchantment.enchiridion.reach": "Reach", + "enchantment.enchiridion.seismic_sense": "Seismic Sense", "enchiridion.category.enchiridion.primary": "Primary", "enchiridion.category.enchiridion.secondary": "Secondary", From cab5d1c8b6ba25445338c03ec6fa96d60cdf8c7f Mon Sep 17 00:00:00 2001 From: Pug <81167232+MerchantPug@users.noreply.github.com> Date: Wed, 29 May 2024 12:20:29 +1000 Subject: [PATCH 3/4] Increase Seismic Sense max level. --- .../resources/data/enchiridion/enchantment/seismic_sense.json | 2 +- .../enchiridion/registry/EnchiridionEnchantments.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json index 43da844..ee9ba4f 100644 --- a/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json +++ b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json @@ -28,7 +28,7 @@ "base": 35, "per_level_above_first": 0 }, - "max_level": 1, + "max_level": 2, "min_cost": { "base": 12, "per_level_above_first": 4 diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java index 5911339..5490c21 100644 --- a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java @@ -180,8 +180,8 @@ public static void bootstrap(BootstrapContext context) { ).withEffect(EnchantmentEffectComponents.ATTRIBUTES, new EnchantmentAttributeEffect("enchantment.enchiridion.reach", Attributes.BLOCK_INTERACTION_RANGE, LevelBasedValue.perLevel(0.5F, 0.5F), AttributeModifier.Operation.ADD_VALUE, UUID.fromString("164c937c-f04c-4730-b8e9-d299a3a187fa"))) .build(REACH.location()); Enchantment seismicSense = Enchantment.enchantment( - Enchantment.definition(miningEnchantable, 1, 1, Enchantment.dynamicCost(12, 4), Enchantment.constantCost(35), 1, EquipmentSlotGroup.MAINHAND) - ).withEffect(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN, new HighlightMinedBlocksEffect(LevelBasedValue.perLevel(40.0f, 20.0f), LevelBasedValue.perLevel(3.0f, 2.0f), BlockTags.BASE_STONE_OVERWORLD, false)) + Enchantment.definition(miningEnchantable, 1, 2, Enchantment.dynamicCost(12, 4), Enchantment.constantCost(35), 1, EquipmentSlotGroup.MAINHAND) + ).withEffect(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN, new HighlightMinedBlocksEffect(LevelBasedValue.perLevel(40.0F, 20.0F), LevelBasedValue.perLevel(3.0F, 2.0F), BlockTags.BASE_STONE_OVERWORLD, false)) .build(SEISMIC_SENSE.location()); context.register(ASHES_CURSE, ashesCurse); From ad374b32f9ddfae8cf2102954637b9bddc7e033c Mon Sep 17 00:00:00 2001 From: Pug <81167232+MerchantPug@users.noreply.github.com> Date: Wed, 29 May 2024 12:38:54 +1000 Subject: [PATCH 4/4] Use Seismic Sense blacklist tag instead of base stone overworld. --- .../resources/data/enchiridion/enchantment/seismic_sense.json | 2 +- .../enchiridion/registry/EnchiridionEnchantments.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json index ee9ba4f..b628646 100644 --- a/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json +++ b/common/src/generated/resources/data/enchiridion/enchantment/seismic_sense.json @@ -8,7 +8,7 @@ { "effect": { "type": "enchiridion:highlight_blocks", - "blacklist": "minecraft:base_stone_overworld", + "blacklist": "enchiridion:seismic_sense_blacklist", "duration": { "type": "minecraft:linear", "base": 40.0, diff --git a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java index 5490c21..76f9c48 100644 --- a/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java +++ b/common/src/main/java/dev/greenhouseteam/enchiridion/registry/EnchiridionEnchantments.java @@ -181,7 +181,7 @@ public static void bootstrap(BootstrapContext context) { .build(REACH.location()); Enchantment seismicSense = Enchantment.enchantment( Enchantment.definition(miningEnchantable, 1, 2, Enchantment.dynamicCost(12, 4), Enchantment.constantCost(35), 1, EquipmentSlotGroup.MAINHAND) - ).withEffect(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN, new HighlightMinedBlocksEffect(LevelBasedValue.perLevel(40.0F, 20.0F), LevelBasedValue.perLevel(3.0F, 2.0F), BlockTags.BASE_STONE_OVERWORLD, false)) + ).withEffect(EnchiridionEnchantmentEffectComponents.BLOCK_BROKEN, new HighlightMinedBlocksEffect(LevelBasedValue.perLevel(40.0F, 20.0F), LevelBasedValue.perLevel(3.0F, 2.0F), Enchiridion.BlockTags.SEISMIC_SENSE_BLACKLIST, false)) .build(SEISMIC_SENSE.location()); context.register(ASHES_CURSE, ashesCurse);