Skip to content

Commit 7d9d1c1

Browse files
authored
Update to 1.21.11
1 parent db80ca6 commit 7d9d1c1

File tree

12 files changed

+103
-188
lines changed

12 files changed

+103
-188
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
plugins {
2-
id 'fabric-loom' version '1.10-SNAPSHOT'
2+
id 'fabric-loom' version '1.14-SNAPSHOT'
33
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_21
7-
targetCompatibility = JavaVersion.VERSION_21
6+
//sourceCompatibility = JavaVersion.VERSION_25
7+
//targetCompatibility = JavaVersion.VERSION_25
8+
89

9-
archivesBaseName = project.archives_base_name
1010
version = project.mod_version
1111
group = project.maven_group
1212

@@ -62,7 +62,7 @@ java {
6262

6363
jar {
6464
from("LICENSE") {
65-
rename { "${it}_${project.archivesBaseName}"}
65+
rename { "${it}_${project.archives_base_name}"}
6666
}
6767
}
6868

gradle.properties

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Done to increase the memory available to gradle.
22
org.gradle.jvmargs=-Xmx1G
3+
org.gradle.caching=false
34

45
# Fabric Properties
56
# check these on https://fabricmc.net/versions.html
6-
minecraft_version=1.21.5
7-
yarn_mappings=1.21.5+build.1
8-
loader_version=0.16.13
9-
modmenu_version=14.0.0-rc.2
7+
minecraft_version=1.21.11
8+
yarn_mappings=1.21.11+build.3
9+
loader_version=0.18.3
10+
modmenu_version=17.0.0-beta.2
1011

1112
# Mod Properties
12-
mod_version = 1.3.7-1.21.5
13+
mod_version = 1.3.8-1.21.11
1314

1415
maven_group = fr.alice
1516
archives_base_name = More-QoL
1617

1718
# Dependencies
18-
fabric_version=0.119.9+1.21.5
19+
fabric_version=0.140.2+1.21.11

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-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/fr/idarkay/morefeatures/FeaturesClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package fr.idarkay.morefeatures;
22

3+
import fr.idarkay.morefeatures.features.HudRenderer;
34
import fr.idarkay.morefeatures.options.FeaturesGameOptions;
45
import fr.idarkay.morefeatures.options.Options;
56
import fr.idarkay.morefeatures.options.screen.FeaturesOptionsScreen;
67
import net.fabricmc.api.ClientModInitializer;
78
import net.fabricmc.api.EnvType;
89
import net.fabricmc.api.Environment;
910
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
11+
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
12+
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
1013
import net.minecraft.client.MinecraftClient;
1114
import net.minecraft.item.ItemStack;
1215
import net.minecraft.registry.Registries;
@@ -37,6 +40,7 @@ public class FeaturesClient implements ClientModInitializer {
3740
@Override
3841
public void onInitializeClient() {
3942
Registry.register(Registries.SOUND_EVENT, FeaturesClient.BREAK_SAFE_ID, BREAK_SAFE_EVENT);
43+
HudElementRegistry.attachElementBefore(VanillaHudElements.CHAT, Identifier.of(MOD_ID, "before_chat"), new HudRenderer()::render);
4044
KeyBindings.init();
4145

4246
startClientTickEvents();

src/main/java/fr/idarkay/morefeatures/KeyBindings.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,32 @@
33
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
44
import net.minecraft.client.option.KeyBinding;
55
import net.minecraft.client.util.InputUtil;
6+
import net.minecraft.util.Identifier;
67
import org.lwjgl.glfw.GLFW;
78

89
public abstract class KeyBindings {
910
private static final String MOD_ID = FeaturesMod.MOD_ID;
11+
private static final KeyBinding.Category featuresCategory = KeyBinding.Category.create(Identifier.of("key.categories." + MOD_ID));
1012

1113
public static final KeyBinding OPEN_OPTIONS_KEYS = new KeyBinding("key." + MOD_ID + ".options",
1214
InputUtil.Type.KEYSYM,
1315
GLFW.GLFW_KEY_F,
14-
"key.categories." + MOD_ID);
16+
featuresCategory);
1517
public static final KeyBinding ADD_LOCAL_TIME_KEYS = new KeyBinding("key." + MOD_ID + ".addTime",
1618
InputUtil.Type.KEYSYM,
1719
GLFW.GLFW_KEY_KP_ADD,
18-
"key.categories." + MOD_ID);
20+
featuresCategory);
1921
public static final KeyBinding REMOVE_LOCAL_TIME_KEYS = new KeyBinding("key." + MOD_ID + ".removeTime",
2022
InputUtil.Type.KEYSYM,
2123
GLFW.GLFW_KEY_KP_SUBTRACT,
22-
"key.categories." + MOD_ID);
24+
featuresCategory);
2325
public static final KeyBinding ACTIVE_LOCAL_TIME = new KeyBinding("key." + MOD_ID + ".localTime",
2426
InputUtil.Type.KEYSYM,
2527
GLFW.GLFW_KEY_J,
26-
"key.categories." + MOD_ID);
28+
featuresCategory);
2729
public static final KeyBinding TOGGLE_BREAK_PROTECTION = new KeyBinding("key." + MOD_ID + ".toggleBreakProtection",
2830
InputUtil.UNKNOWN_KEY.getCode(),
29-
"key.categories." + MOD_ID);
31+
featuresCategory);
3032

3133
public static void init() {
3234
KeyBindingHelper.registerKeyBinding(OPEN_OPTIONS_KEYS);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package fr.idarkay.morefeatures.features;
2+
3+
import fr.idarkay.morefeatures.FeaturesClient;
4+
import net.minecraft.client.MinecraftClient;
5+
import net.minecraft.client.gui.DrawContext;
6+
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
7+
import net.minecraft.client.render.RenderTickCounter;
8+
import net.minecraft.entity.effect.StatusEffectInstance;
9+
10+
import java.util.logging.Logger;
11+
12+
/**
13+
* Renders remaining effect time under the effect icons
14+
*/
15+
public class HudRenderer {
16+
public void render(DrawContext drawContext, RenderTickCounter renderTickCounter) {
17+
if (!FeaturesClient.options().effectTime) {
18+
return;
19+
}
20+
MinecraftClient client = MinecraftClient.getInstance();
21+
if (client.player == null) return;
22+
if (client.currentScreen instanceof InventoryScreen) {
23+
return;
24+
}
25+
26+
boolean hasEffects = !client.player.getStatusEffects().isEmpty();
27+
if (!hasEffects) return;
28+
29+
int iconSize = 24;
30+
int x = drawContext.getScaledWindowWidth() - iconSize;
31+
int y = 1;
32+
33+
for (StatusEffectInstance effect : client.player.getStatusEffects()) {
34+
Logger.getAnonymousLogger().info(effect.toString());
35+
36+
int duration = effect.getDuration();
37+
int seconds = duration / 20;
38+
int minutes = seconds / 60;
39+
seconds = seconds % 60;
40+
41+
String timeText = String.format("%d:%02d", minutes, seconds);
42+
43+
int textWidth = client.textRenderer.getWidth(timeText);
44+
int centeredX = x + (iconSize - textWidth) / 2;
45+
46+
drawContext.drawText(client.textRenderer, timeText, centeredX, y + iconSize + 2, 0xFFFFFFFF, true);
47+
48+
x -= (iconSize + 2);
49+
}
50+
}
51+
}

src/main/java/fr/idarkay/morefeatures/mixin/BeaconBlockEntityRendererMixin.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import net.minecraft.block.entity.BlockEntity;
66
import net.minecraft.client.render.VertexConsumerProvider;
77
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer;
8+
import net.minecraft.client.render.block.entity.state.BeaconBlockEntityRenderState;
9+
import net.minecraft.client.render.command.OrderedRenderCommandQueue;
10+
import net.minecraft.client.render.state.CameraRenderState;
811
import net.minecraft.client.util.math.MatrixStack;
912
import net.minecraft.util.math.Vec3d;
1013
import org.spongepowered.asm.mixin.Mixin;
@@ -18,8 +21,8 @@
1821
@Mixin(BeaconBlockEntityRenderer.class)
1922
public abstract class BeaconBlockEntityRendererMixin<T extends BlockEntity & BeamEmitter> {
2023

21-
@Inject(method = "render(Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/util/math/Vec3d;)V", at = @At("HEAD"), cancellable = true)
22-
public void render(T entity, float tickProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, Vec3d cameraPos, CallbackInfo ci) {
24+
@Inject(method = "render(Lnet/minecraft/client/render/block/entity/state/BeaconBlockEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/render/state/CameraRenderState;)V", at = @At("HEAD"), cancellable = true)
25+
public void render(BeaconBlockEntityRenderState beaconBlockEntityRenderState, MatrixStack matrixStack, OrderedRenderCommandQueue orderedRenderCommandQueue, CameraRenderState cameraRenderState, CallbackInfo ci) {
2326
if (!FeaturesClient.options().renderBeaconBeam) {
2427
ci.cancel();
2528
}

src/main/java/fr/idarkay/morefeatures/mixin/HandledScreenMixin.java

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package fr.idarkay.morefeatures.mixin;
22

33
import fr.idarkay.morefeatures.FeaturesClient;
4+
import net.minecraft.client.gui.Click;
45
import net.minecraft.client.gui.DrawContext;
56
import net.minecraft.client.gui.screen.Screen;
67
import net.minecraft.client.gui.screen.ingame.HandledScreen;
78
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
9+
import net.minecraft.client.input.KeyInput;
810
import net.minecraft.item.Item;
911
import net.minecraft.item.ItemStack;
1012
import net.minecraft.item.Items;
@@ -28,7 +30,7 @@
2830
@Mixin(HandledScreen.class)
2931
public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen implements ScreenHandlerProvider<T> {
3032
@Shadow
31-
protected abstract boolean handleHotbarKeyPressed(int keyCode, int scanCode);
33+
protected abstract boolean handleHotbarKeyPressed(KeyInput keyInput);
3234

3335
@Shadow
3436
@Nullable
@@ -50,17 +52,17 @@ protected HandledScreenMixin(Text title) {
5052
}
5153

5254
@Overwrite
53-
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
54-
if (super.keyPressed(keyCode, scanCode, modifiers)) {
55+
public boolean keyPressed(KeyInput keyInput) {
56+
if (super.keyPressed(keyInput)) {
5557
return true;
56-
} else if (keyCode != 256 && !this.client.options.inventoryKey.matchesKey(keyCode, scanCode)) {
57-
this.handleHotbarKeyPressed(keyCode, scanCode);
58+
} else if (keyInput.getKeycode() != 256 && !this.client.options.inventoryKey.matchesKey(keyInput)) {
59+
this.handleHotbarKeyPressed(keyInput);
5860
if (this.focusedSlot != null && this.focusedSlot.hasStack()) {
59-
if (this.client.options.pickItemKey.matchesKey(keyCode, scanCode)) {
61+
if (this.client.options.pickItemKey.matchesKey(keyInput)) {
6062
this.onMouseClick(this.focusedSlot, this.focusedSlot.id, 0, SlotActionType.CLONE);
61-
} else if (this.client.options.dropKey.matchesKey(keyCode, scanCode)) {
62-
boolean control = hasControlDown();
63-
if (hasShiftDown() && control) {
63+
} else if (this.client.options.dropKey.matchesKey(keyInput)) {
64+
boolean control = keyInput.hasCtrlOrCmd();
65+
if (keyInput.hasShift() && control) {
6466
Item focusedType = this.focusedSlot.getStack().getItem();
6567
if (!focusedType.equals(Items.AIR)) {
6668
for (Slot slot : handler.slots) {
@@ -80,50 +82,26 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
8082
}
8183
}
8284

83-
@Inject(method = "mouseDragged(DDIDD)Z", at = @At("TAIL"))
84-
public void mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY,
85-
CallbackInfoReturnable<Boolean> cir) {
86-
if ((button == 0 || button == 1) && hasShiftDown()
85+
@Inject(method = "mouseDragged", at = @At("TAIL"))
86+
public void mouseDragged(Click click, double offsetX, double offsetY, CallbackInfoReturnable<Boolean> cir) {
87+
if ((click.button() == 0 || click.button() == 1) && click.hasShift()
8788
&& this.client.player.currentScreenHandler.getCursorStack().isEmpty()) {
88-
Slot slot = this.getSlotAt(mouseX, mouseY);
89+
Slot slot = this.getSlotAt(click.x(), click.y());
8990
if (slot != null && !slot.getStack().isEmpty()) {
90-
this.onMouseClick(slot, slot.id, button, SlotActionType.QUICK_MOVE);
91+
this.onMouseClick(slot, slot.id, click.button(), SlotActionType.QUICK_MOVE);
9192
}
9293
}
9394
}
9495

95-
@Inject(method = "drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V",
96-
at = @At("RETURN"))
97-
private void drawSlot(DrawContext context, Slot slot, CallbackInfo ci) {
98-
// final boolean maj = (InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT));
96+
@Inject(method = "drawSlot", at = @At("RETURN"))
97+
private void drawSlot(DrawContext context, Slot slot, int mouseX, int mouseY, CallbackInfo ci) {
9998
final ItemStack cursor = this.handler.getCursorStack();
10099
final ItemStack slotIT = slot.getStack();
101100
if ((FeaturesClient.options().lightSameItem && !slotIT.isEmpty()
102101
&& !cursor.isEmpty()
103102
&& slot.getStack().getItem().equals(cursor.getItem()))
104-
// || (maj && !slotIT.isEmpty() && this.focusedSlot != null
105-
// && !this.focusedSlot.getStack().isEmpty()
106-
// && this.focusedSlot.getStack().getItem().equals(slotIT.getItem()))
107103
) {
108104
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, FeaturesClient.options().getLightSameItemColor());
109105
}
110106
}
111-
112-
// @Inject(method = "drawItem(Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD"))
113-
// private void drawItem(ItemStack stack, int x, int y, String amountText, CallbackInfo ci) {
114-
//
115-
// final boolean maj = (InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_KEY_RIGHT_SHIFT));
116-
// final ItemStack cursor = this.handler.getCursorStack();
117-
// if ((FeaturesClient.options().lightSameItem && !stack.isEmpty()
118-
// && !cursor.isEmpty()
119-
// && stack.getItem().equals(cursor.getItem()))
120-
// || (maj && !stack.isEmpty() && this.focusedSlot != null
121-
// && !this.focusedSlot.getStack().isEmpty()
122-
// && this.focusedSlot.getStack().getItem().equals(stack.getItem()))
123-
// )
124-
// {
125-
// fill(RenderSystem.getModelViewStack(), x, y, x + 16, y + 16, FeaturesClient.options().getLightSameItemColor());
126-
// }
127-
// }
128-
129-
}
107+
}

0 commit comments

Comments
 (0)