diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AnvilHammerScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AnvilHammerScreen.java index 8319c41bb..87b0ebfd7 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AnvilHammerScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AnvilHammerScreen.java @@ -8,6 +8,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; +import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.hammer.IHasHammerEffect; import dev.dubhe.anvilcraft.api.input.IMouseHandlerExtension; import dev.dubhe.anvilcraft.client.init.ModRenderTypes; @@ -31,7 +32,9 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Objects; @ParametersAreNonnullByDefault public class AnvilHammerScreen extends Screen implements IHasHammerEffect { @@ -41,7 +44,11 @@ public class AnvilHammerScreen extends Screen implements IHasHammerEffect { public static final int CLOSING_ANIMATION_T = 150; //ms public static final float ZOOM = 13.5f; public static final int IGNORE_CURSOR_MOVE_LENGTH = 15; - + private static final String[] ALL_GETNAME_METHODS = { + "getName", + "method_11901", + "m_6940_" + }; private static final MethodHandle PROPERTY_TOSTRING; private static final int RING_COLOR = 0x88000000; @@ -59,16 +66,21 @@ public class AnvilHammerScreen extends Screen implements IHasHammerEffect { String.class, Comparable.class ); - try { - PROPERTY_TOSTRING = MethodHandles.lookup() - .findVirtual( - Property.class, - "getName", - mt - ); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new RuntimeException(e); - } + PROPERTY_TOSTRING = Arrays.stream(ALL_GETNAME_METHODS) + .map(it -> { + try { + return MethodHandles.lookup() + .findVirtual( + Property.class, + it, + mt + ); + } catch (Exception e) { + return null; + } + }).filter(Objects::nonNull) + .findFirst() + .orElseThrow(); } private final Minecraft minecraft = Minecraft.getInstance(); diff --git a/common/src/main/resources/assets/anvilcraft/shaders/core/selection.fsh b/common/src/main/resources/assets/anvilcraft/shaders/core/selection.fsh index fa10af90a..77c1d12e4 100644 --- a/common/src/main/resources/assets/anvilcraft/shaders/core/selection.fsh +++ b/common/src/main/resources/assets/anvilcraft/shaders/core/selection.fsh @@ -6,7 +6,6 @@ uniform vec4 ColorModulator; uniform vec2 FramebufferSize; uniform vec2 Center; uniform float Radius; -uniform float AntiAliasingRadius; out vec4 fragColor; @@ -16,7 +15,7 @@ void main() { vec4 color = vec4(0, 0, 0, 0); if (distance <= Radius) { color = vertexColor; - color.a = smoothstep(Radius, 0f, distance); + color.a = smoothstep(Radius, 0.0f, distance); } fragColor = color * ColorModulator; diff --git a/common/src/main/resources/assets/anvilcraft/shaders/core/selection.json b/common/src/main/resources/assets/anvilcraft/shaders/core/selection.json index da14e47b7..acef6b9b1 100644 --- a/common/src/main/resources/assets/anvilcraft/shaders/core/selection.json +++ b/common/src/main/resources/assets/anvilcraft/shaders/core/selection.json @@ -91,14 +91,6 @@ "values": [ 0.0 ] - }, - { - "name": "AntiAliasingRadius", - "type": "float", - "count": 1, - "values": [ - 1.5 - ] } ] } diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/BlockEventListener.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/BlockEventListener.java index 32945efa5..b22a21982 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/BlockEventListener.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/BlockEventListener.java @@ -3,6 +3,7 @@ import dev.dubhe.anvilcraft.api.hammer.IHammerChangeable; import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; import dev.dubhe.anvilcraft.client.gui.screen.inventory.AnvilHammerScreen; +import dev.dubhe.anvilcraft.init.ModBlockTags; import dev.dubhe.anvilcraft.item.AnvilHammerItem; import dev.dubhe.anvilcraft.network.HammerUsePack; import dev.dubhe.anvilcraft.util.StateUtil; @@ -80,8 +81,8 @@ private static void clientHandler( && AnvilHammerItem.possibleToUseEnhancedHammerChange(targetBlockState) && property != null ) { - if (targetBlockState.getBlock() instanceof IHammerChangeable ihc - && ihc.checkBlockState(targetBlockState) + if ((targetBlockState.getBlock() instanceof IHammerChangeable ihc + && ihc.checkBlockState(targetBlockState)) || (targetBlockState.is(ModBlockTags.HAMMER_CHANGEABLE)) && player.getAbilities().mayBuild ) { List possibleStates = StateUtil.findPossibleStatesForProperty(targetBlockState, property); diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ClientBlockEventListener.java b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ClientBlockEventListener.java index 00f4ffa9b..52f5fd792 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ClientBlockEventListener.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ClientBlockEventListener.java @@ -4,6 +4,7 @@ import dev.dubhe.anvilcraft.api.hammer.IHammerChangeable; import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; import dev.dubhe.anvilcraft.client.gui.screen.inventory.AnvilHammerScreen; +import dev.dubhe.anvilcraft.init.ModBlockTags; import dev.dubhe.anvilcraft.item.AnvilHammerItem; import dev.dubhe.anvilcraft.network.HammerUsePack; import dev.dubhe.anvilcraft.util.StateUtil; @@ -61,8 +62,9 @@ private static void clientHandle( && AnvilHammerItem.possibleToUseEnhancedHammerChange(targetBlockState) && property != null ) { - if (targetBlockState.getBlock() instanceof IHammerChangeable ihc - && ihc.checkBlockState(targetBlockState) + if ((targetBlockState.getBlock() instanceof IHammerChangeable ihc + && ihc.checkBlockState(targetBlockState)) + || (targetBlockState.is(ModBlockTags.HAMMER_CHANGEABLE)) && event.getEntity().getAbilities().mayBuild ) { List possibleStates = StateUtil.findPossibleStatesForProperty(targetBlockState, property);