Skip to content

Commit 5da5ed9

Browse files
committed
2.10
1 parent 953d388 commit 5da5ed9

File tree

14 files changed

+93
-95
lines changed

14 files changed

+93
-95
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "fabric-loom" version "1.10-SNAPSHOT"
2+
id "fabric-loom" version "1.13-SNAPSHOT"
33
// id "org.ajoberstar.grgit" version "3.1.1"
44
}
55

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ done
8686
# shellcheck disable=SC2034
8787
APP_BASE_NAME=${0##*/}
8888
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90-
' "$PWD" ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9190

9291
# Use the maximum available, or set MAX_FD != -1 to use that value.
9392
MAX_FD=maximum
@@ -115,7 +114,7 @@ case "$( uname )" in #(
115114
NONSTOP* ) nonstop=true ;;
116115
esac
117116

118-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
119118

120119

121120
# Determine the Java command to use to start the JVM.
@@ -206,15 +205,15 @@ fi
206205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207206

208207
# Collect all arguments for the java command:
209-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210209
# and any embedded shellness will be escaped.
211210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212211
# treated as '${Hostname}' itself on the command line.
213212

214213
set -- \
215214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
216215
-classpath "$CLASSPATH" \
217-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
218217
"$@"
219218

220219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

src/main/java/win/baruna/blockmeter/BlockMeterClient.java

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
99
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
1010
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
11-
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
12-
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
11+
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderContext;
12+
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderEvents;
1313
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
1414
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
1515
import net.fabricmc.fabric.api.event.player.UseItemCallback;
1616
import net.fabricmc.fabric.api.networking.v1.PacketSender;
1717
import net.minecraft.client.MinecraftClient;
18-
import net.minecraft.client.gui.screen.Screen;
1918
import net.minecraft.client.network.ClientPlayNetworkHandler;
2019
import net.minecraft.client.network.ClientPlayerEntity;
2120
import net.minecraft.client.option.KeyBinding;
2221
import net.minecraft.client.util.InputUtil;
22+
import net.minecraft.client.util.Window;
2323
import net.minecraft.item.Item;
2424
import net.minecraft.item.ItemStack;
2525
import net.minecraft.text.Text;
@@ -41,17 +41,11 @@
4141
import java.util.stream.Collectors;
4242

4343
@SuppressWarnings("UnstableApiUsage")
44-
public class BlockMeterClient implements ClientModInitializer {
45-
/**
46-
* Currently running Instance of BlockMeterClient
47-
*/
44+
public class BlockMeterClient implements ClientModInitializer, InputUtils {
45+
/// Currently running Instance of BlockMeterClient
4846
private static BlockMeterClient instance;
4947

50-
/**
51-
* Accessor for the BlockMeterClient Instance
52-
*
53-
* @return running Instance of BlockMeterClient
54-
*/
48+
/// Currently running Instance of BlockMeterClient
5549
public static BlockMeterClient getInstance() {
5650
return instance;
5751
}
@@ -60,54 +54,38 @@ private static ClientPlayerEntity getPlayer() {
6054
return Objects.requireNonNull(MinecraftClient.getInstance().player);
6155
}
6256

63-
/**
64-
* ConfigManager of BlockMeter
65-
*/
57+
private static Window getWindow() {
58+
return MinecraftClient.getInstance().getWindow();
59+
}
60+
6661
private static ConfigManager<ModConfig> confMgr;
6762

68-
/**
69-
* Accessor for the ModConfigManager
70-
*
71-
* @return ConfigManager for handling the Config
72-
*/
63+
/// Accessor for the ModConfigManager
7364
public static ConfigManager<ModConfig> getConfigManager() {
74-
7565
return confMgr;
7666
}
7767

7868
public static ModConfig getConfig() {
7969
return confMgr.getConfig();
8070
}
8171

82-
/**
83-
* The current state of the BlockMeter (activated/deactivated)
84-
*/
72+
/// The current state of the BlockMeter (activated/deactivated)
8573
private boolean active;
8674

87-
/**
88-
* The Item selected as BlockMeter
89-
*/
75+
/// The Item selected as BlockMeter
9076
private Item currentItem;
9177

92-
/**
93-
* The List of Measuring-Boxes currently created by the current User
94-
*/
78+
/// The List of Measuring-Boxes currently created by the current User
9579
private final List<ClientMeasureBox> boxes = new ArrayList<>();
9680

97-
/**
98-
* A Map of Lists of Boxes currently created by other Users, with Text being the
99-
* Username
100-
*/
81+
/// A Map of Lists of Boxes currently created by other Users, with Text being the
82+
/// Username
10183
private Map<String, List<ClientMeasureBox>> otherUsersBoxes;
10284

103-
/**
104-
* The QuickMenu for changing of Color etc.
105-
*/
85+
/// The QuickMenu for changing of Color etc.
10686
private final OptionsGui quickMenu;
10787

108-
/**
109-
* The QuickMenu for selecting on of multiple Boxes.
110-
*/
88+
/// The QuickMenu for selecting on of multiple Boxes.
11189
private final SelectBoxGui selectBoxGui;
11290
private final EditBoxGui editBoxGui;
11391

@@ -185,7 +163,7 @@ public boolean undo() {
185163
}
186164

187165
public void renderOverlay(WorldRenderContext context) {
188-
final Identifier currentDimension = getPlayer().clientWorld.getRegistryKey().getValue();
166+
final Identifier currentDimension = getPlayer().getEntityWorld().getRegistryKey().getValue();
189167

190168
final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
191169

@@ -241,17 +219,19 @@ public ClientMeasureBox getCurrentBox() {
241219

242220
@Override
243221
public void onInitializeClient() {
222+
var category = KeyBinding.Category.create(Identifier.of("category.blockmeter.key"));
223+
var window = MinecraftClient.getInstance().getWindow();
244224
final KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.blockmeter.assign",
245-
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_M, "category.blockmeter.key"));
225+
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_M, category));
246226
final KeyBinding keyBindingMenu = new KeyBinding("key.blockmeter.menu", InputUtil.Type.KEYSYM,
247-
GLFW.GLFW_KEY_LEFT_ALT, "category.blockmeter.key");
227+
GLFW.GLFW_KEY_LEFT_ALT, category);
248228
KeyBindingHelper.registerKeyBinding(keyBindingMenu);
249229

250230
final KeyBinding keyBindingMeasureWithItem = new KeyBinding("key.blockmeter.useItem", -1,
251-
"category.blockmeter.key");
231+
category);
252232
KeyBindingHelper.registerKeyBinding(keyBindingMeasureWithItem);
253233
final KeyBinding keyBindingMeasure = new KeyBinding("key.blockmeter.measure", InputUtil.Type.MOUSE,
254-
GLFW.GLFW_MOUSE_BUTTON_4, "category.blockmeter.key");
234+
GLFW.GLFW_MOUSE_BUTTON_4, category);
255235
KeyBindingHelper.registerKeyBinding(keyBindingMeasure);
256236

257237
WorldRenderEvents.BEFORE_DEBUG_RENDER.register(this::renderOverlay);
@@ -267,10 +247,10 @@ public void onInitializeClient() {
267247
confMgr = (ConfigManager<ModConfig>) AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
268248
ClientTickEvents.START_CLIENT_TICK.register(e -> {
269249
if (keyBinding.wasPressed()) {
270-
if (Screen.hasShiftDown()) {
250+
if (isShift()) {
271251
if (undo())
272252
getPlayer().sendMessage(Text.translatable("blockmeter.clearLast"), true);
273-
} else if (Screen.hasControlDown()) {
253+
} else if (isCtrl()) {
274254
if (clear())
275255
getPlayer().sendMessage(Text.translatable("blockmeter.clearAll"), true);
276256
} else if (this.active) {
@@ -348,7 +328,7 @@ public void onInitializeClient() {
348328
var outside = this.boxes.stream()
349329
.filter(box -> box.miningRestriction == ClientMeasureBox.MiningRestriction.Outside)
350330
.anyMatch(box -> box.contains(pos));
351-
if (!Screen.hasShiftDown() && (inside || outside)) {
331+
if (!isShift() && (inside || outside)) {
352332
return ActionResult.FAIL;
353333
} else {
354334
return ActionResult.PASS;
@@ -382,7 +362,7 @@ private void onBlockMeterClick(final BlockPos block) {
382362
ClientMeasureBox currentBox = getCurrentBox();
383363

384364
if (currentBox == null) {
385-
if (Screen.hasShiftDown()) {
365+
if (isShift()) {
386366
ClientMeasureBox[] boxes = findBoxes(block);
387367
switch (boxes.length) {
388368
case 0:
@@ -398,7 +378,7 @@ private void onBlockMeterClick(final BlockPos block) {
398378
}
399379
} else {
400380
final ClientMeasureBox box = ClientMeasureBox.getBox(block,
401-
getPlayer().getWorld().getRegistryKey().getValue());
381+
getPlayer().getEntityWorld().getRegistryKey().getValue());
402382
this.boxes.add(box);
403383
}
404384
} else {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package win.baruna.blockmeter;
2+
3+
import net.minecraft.client.MinecraftClient;
4+
import net.minecraft.client.util.InputUtil;
5+
import net.minecraft.client.util.Window;
6+
7+
import java.util.function.Function;
8+
import java.util.function.Supplier;
9+
10+
public interface InputUtils {
11+
default Window window() {
12+
return MinecraftClient.getInstance().getWindow();
13+
}
14+
15+
default boolean isKey(int key) {
16+
return InputUtil.isKeyPressed(window(), key);
17+
}
18+
19+
default boolean isShift() {
20+
return isKey(InputUtil.GLFW_KEY_LEFT_SHIFT) || isKey(InputUtil.GLFW_KEY_RIGHT_SHIFT);
21+
}
22+
23+
default boolean isCtrl() {
24+
return isKey(InputUtil.GLFW_KEY_LEFT_CONTROL) || isKey(InputUtil.GLFW_KEY_RIGHT_CONTROL);
25+
}
26+
}

src/main/java/win/baruna/blockmeter/gui/EditBoxGui.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ protected void init() {
5151

5252
@Override
5353
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
54-
super.renderBackground(context, mouseX, mouseY, delta);
5554
super.render(context, mouseX, mouseY, delta);
5655
}
5756

src/main/java/win/baruna/blockmeter/gui/OptionsGui.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.minecraft.client.gui.screen.ButtonTextures;
1212
import net.minecraft.client.gui.screen.Screen;
1313
import net.minecraft.client.gui.widget.ButtonWidget;
14+
import net.minecraft.client.input.AbstractInput;
1415
import net.minecraft.client.render.*;
1516
import net.minecraft.client.util.NarratorManager;
1617
import net.minecraft.text.MutableText;
@@ -90,7 +91,6 @@ protected void init() {
9091

9192
@Override
9293
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
93-
// super.renderBackground(context, mouseX, mouseY, delta);
9494
super.render(context, mouseX, mouseY, delta);
9595
}
9696

@@ -115,12 +115,12 @@ class ColorButton extends ButtonWidget {
115115
);
116116

117117
@Override
118-
public void onPress() {
118+
public void onPress(AbstractInput input) {
119119
System.out.println(color.getRed());
120120
System.out.println(color.getGreen());
121121
System.out.println(color.getBlue());
122122
System.err.println("IK WHAT YOU ARE DOING");
123-
super.onPress();
123+
super.onPress(input);
124124
}
125125

126126
ColorButton(final int x, final int y, final int width, final int height, final MutableText label, final Color color,

0 commit comments

Comments
 (0)