Skip to content

Commit

Permalink
Merge pull request #1271 from ZhuRuoLing/releases/1.20.1
Browse files Browse the repository at this point in the history
修复铁砧锤不能调整侦测器
  • Loading branch information
Gu-ZT authored Dec 6, 2024
2 parents 475fe6c + 47d3ed3 commit d91421b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ uniform vec4 ColorModulator;
uniform vec2 FramebufferSize;
uniform vec2 Center;
uniform float Radius;
uniform float AntiAliasingRadius;

out vec4 fragColor;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@
"values": [
0.0
]
},
{
"name": "AntiAliasingRadius",
"type": "float",
"count": 1,
"values": [
1.5
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BlockState> possibleStates = StateUtil.findPossibleStatesForProperty(targetBlockState, property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BlockState> possibleStates = StateUtil.findPossibleStatesForProperty(targetBlockState, property);
Expand Down

0 comments on commit d91421b

Please sign in to comment.