Skip to content

Commit a7b9df9

Browse files
committed
chore(bouquet): update to 26.2-snapshot-3
fixes wailua to support this version
1 parent 21f6c95 commit a7b9df9

8 files changed

Lines changed: 41 additions & 38 deletions

File tree

bouquet/examples/wailua/reloadable.lua

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,30 @@ if allium.environment() ~= "client" then return end
88
local events = require("bouquet").events
99
local Component = require("net.minecraft.network.chat.Component")
1010
local BuiltInRegistries = require("net.minecraft.core.registries.BuiltInRegistries")
11+
local Type = require("net.minecraft.world.phys.HitResult.Type")
1112

12-
local renderComponent -- The text to be shared between the render event and tick event
13-
14-
events.client.guiRenderTail:register(script, function(client, context, deltaTracker, gui)
15-
if renderComponent then -- If there's text, then draw it at the top center
16-
context:centeredText(gui:getFont(), renderComponent, context:guiWidth()/2, 5, 0xffffffff)
17-
-- The position 5 was arbitrarily chosen, and was the first value I picked just to test. It worked perfectly.
18-
-- Exercise for the reader - Create a background frame behind the text, so it can be viewed on white backgrounds.
19-
-- Note that while text rendering uses RGB, background rendering uses ARGB.
20-
end
21-
end)
22-
23-
events.common.playerTick:register(script, function(player)
24-
local level = player:level()
25-
if level:isClientSide() then
13+
events.client.guiRenderTail:register(script, function(gui, minecraft, graphics, deltaTracker, shouldRenderLevel, resourcesLoaded)
14+
if minecraft.hitResult and minecraft.hitResult:getType() == Type.BLOCK then
2615
-- Finally, use the block to get the identifier of the block
2716
local identifier = BuiltInRegistries.BLOCK:getKey(
28-
-- Use the position to get the state, then the block attributed to that state
29-
level:getBlockState(
17+
-- Use the position to get the state, then the block attributed to that state
18+
minecraft.level:getBlockState(
3019
-- Get the block position the player is looking at <- START HERE read UP ^
31-
player:pick(5, 0, false):getBlockPos()
32-
):getBlock()
20+
minecraft.hitResult:getBlockPos()
21+
):getBlock()
3322
)
3423
local namespace, path = identifier:getNamespace(), identifier:getPath()
35-
if namespace == "minecraft" and path == "air" then -- If we're just looking at air, don't create a text object.
36-
renderComponent = nil
37-
else -- Otherwise, pull the name of the block from the language.
38-
renderComponent = Component.translatable("block."..namespace.."."..path)
24+
if not (namespace == "minecraft" and path == "air") then -- If we're just looking at air, don't write text.
25+
graphics:centeredText(
26+
minecraft.font,
27+
Component.translatable("block."..namespace.."."..path),
28+
graphics:guiWidth()/2,
29+
5,
30+
0xffffffff
31+
)
32+
-- The position 5 was arbitrarily chosen, and was the first value I picked just to test. It worked perfectly.
33+
-- Exercise for the reader - Create a background frame behind the text, so it can be viewed on white backgrounds.
34+
-- Note that while text rendering uses RGB, background rendering uses ARGB.
3935
end
4036
end
4137
end)

bouquet/src/client/java/dev/moongarden/bouquet/api/event/ClientEventHandlers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
public class ClientEventHandlers {
1313

1414
public interface GuiRender {
15-
void onGuiRender(Minecraft client, GuiGraphicsExtractor context, DeltaTracker deltaTracker, Gui hud);
15+
void onGuiRender(Gui hud, Minecraft client, GuiGraphicsExtractor context, DeltaTracker deltaTracker, boolean shouldRenderLevel, boolean resourcesLoaded);
1616
}
1717
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package dev.moongarden.bouquet.mixin.client.gui.hud;
22

3+
import com.llamalad7.mixinextras.expression.Definition;
4+
import com.llamalad7.mixinextras.expression.Expression;
5+
import com.llamalad7.mixinextras.sugar.Local;
36
import dev.moongarden.bouquet.api.event.ClientEvents;
47
import net.minecraft.client.DeltaTracker;
58
import net.minecraft.client.Minecraft;
@@ -8,7 +11,6 @@
811
import org.spongepowered.asm.mixin.Final;
912
import org.spongepowered.asm.mixin.Mixin;
1013
import org.spongepowered.asm.mixin.Shadow;
11-
import org.spongepowered.asm.mixin.Unique;
1214
import org.spongepowered.asm.mixin.injection.At;
1315
import org.spongepowered.asm.mixin.injection.Inject;
1416
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -19,16 +21,15 @@ public class GuiMixin {
1921
@Final
2022
private Minecraft minecraft;
2123

22-
@Unique
23-
private final Gui thiz = (Gui) (Object) this;
24-
25-
@Inject(at = @At("HEAD"), method = "extractRenderState")
26-
private void renderHead(GuiGraphicsExtractor context, DeltaTracker deltaTracker, CallbackInfo ci) {
27-
ClientEvents.GUI_RENDER_HEAD.invoker().onGuiRender(minecraft, context, deltaTracker, thiz);
24+
@Definition(id = "GuiGraphicsExtractor", type = GuiGraphicsExtractor.class)
25+
@Expression("? = new GuiGraphicsExtractor(?,?,?,?)")
26+
@Inject(at = @At(value = "MIXINEXTRAS:EXPRESSION", shift = At.Shift.AFTER), method = "extractRenderState")
27+
private void renderHead(DeltaTracker deltaTracker, boolean shouldRenderLevel, boolean resourcesLoaded, CallbackInfo ci, @Local(name = "graphics") GuiGraphicsExtractor graphics) {
28+
ClientEvents.GUI_RENDER_HEAD.invoker().onGuiRender((Gui) (Object) this, minecraft, graphics, deltaTracker, shouldRenderLevel, resourcesLoaded);
2829
}
2930

3031
@Inject(at = @At("TAIL"), method = "extractRenderState")
31-
private void renderTail(GuiGraphicsExtractor context, DeltaTracker deltaTracker, CallbackInfo ci) {
32-
ClientEvents.GUI_RENDER_TAIL.invoker().onGuiRender(minecraft, context, deltaTracker, thiz);
32+
private void renderTail(DeltaTracker deltaTracker, boolean shouldRenderLevel, boolean resourcesLoaded, CallbackInfo ci, @Local(name = "graphics") GuiGraphicsExtractor graphics) {
33+
ClientEvents.GUI_RENDER_TAIL.invoker().onGuiRender((Gui) (Object) this, minecraft, graphics, deltaTracker, shouldRenderLevel, resourcesLoaded);
3334
}
3435
}

bouquet/src/client/resources/bouquet.client.mixins.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
],
99
"injectors": {
1010
"defaultRequire": 1
11-
}
11+
},
12+
"mixinextras": {
13+
"minVersion": "0.5.0"
14+
}
1215
}

bouquet/src/main/resources/bouquet.mixins.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
],
2525
"injectors": {
2626
"defaultRequire": 1
27+
},
28+
"mixinextras": {
29+
"minVersion": "0.5.0"
2730
}
2831
}

bouquet/src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
],
3636
"depends": {
37-
"minecraft": "~26.1",
37+
"minecraft": "~26.2-",
3838
"fabricloader": ">=0.18.3",
3939
"java": ">=25"
4040
},

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ bouquetBaseName=bouquet
1717

1818
# Fabric Properties
1919
# check these on https://fabricmc.net/develop
20-
minecraftVersion=26.1
20+
minecraftVersion=26.2-snapshot-3
2121
loaderVersion=0.18.4
22-
loomVersion=1.15-SNAPSHOT
22+
loomVersion=1.16-SNAPSHOT
2323

2424
# Common Dependencies
2525
cobalt=0.9.7
@@ -29,4 +29,4 @@ enhancedReflections=0.1.6
2929
combine=2.3.0-rc.2
3030

3131
# Bouquet Example Script Dependencies
32-
fabricApi=0.143.15+26.1
32+
fabricApi=0.146.1+26.2

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-9.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)