Skip to content

Commit d66cb35

Browse files
committed
Updated to suit JDK21
1 parent eb67bc1 commit d66cb35

File tree

5 files changed

+94
-39
lines changed

5 files changed

+94
-39
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ When hovering over location icons in the SeedMap it will display text telling yo
3232

3333
### Added Elytra/End Ship Locations
3434
Can now find Elytra via locating End Ships with the locate command ```/sm:locate feature end_city_ship``` or simply selecting the Elytra icon in the SeedMap
35+
This has now been implemented by upstream. I have however kept my original Elytra icon, because we aren't going to the ships for anything else are we?
3536

3637
### Export SeedMap
3738
- Added **Export JSON** button on the top right of the SeedMap screen which will export all selected locations to a JSON

src/main/java/dev/xpple/seedmapper/config/MapFeatureAdapter.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package dev.xpple.seedmapper.config;
22

3+
import com.google.gson.JsonSyntaxException;
34
import com.google.gson.TypeAdapter;
45
import com.google.gson.stream.JsonReader;
6+
import com.google.gson.stream.JsonToken;
57
import com.google.gson.stream.JsonWriter;
68
import dev.xpple.seedmapper.seedmap.MapFeature;
9+
import net.minecraft.Util;
710

811
import java.io.IOException;
912

@@ -15,6 +18,15 @@ public void write(JsonWriter writer, MapFeature feature) throws IOException {
1518

1619
@Override
1720
public MapFeature read(JsonReader reader) throws IOException {
18-
return MapFeature.BY_NAME.get(reader.nextString());
21+
if (reader.peek() == JsonToken.NULL) {
22+
reader.nextNull();
23+
throw new JsonSyntaxException("Expected map feature name but found null");
24+
}
25+
String name = reader.nextString();
26+
MapFeature feature = MapFeature.BY_NAME.get(name);
27+
if (feature == null) {
28+
throw new JsonSyntaxException("Unknown map feature: " + name);
29+
}
30+
return feature;
1931
}
2032
}

src/main/java/dev/xpple/seedmapper/seedmap/FeatureToggleWidget.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class FeatureToggleWidget extends Button {
1111
private final MapFeature feature;
1212

1313
public FeatureToggleWidget(MapFeature feature, int x, int y) {
14-
super(x, y, feature.getDefaultTexture().width(), feature.getDefaultTexture().height(), Component.literal(feature.getName()), FeatureToggleWidget::onButtonPress, DEFAULT_NARRATION);
14+
super(x, y, feature.getDefaultTexture().width(), feature.getDefaultTexture().height(), feature.getDisplayName(), FeatureToggleWidget::onButtonPress, DEFAULT_NARRATION);
1515
this.feature = feature;
1616
}
1717

@@ -24,6 +24,10 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo
2424
SeedMapScreen.FeatureWidget.drawFeatureIcon(guiGraphics, this.feature.getDefaultTexture(), this.getX(), this.getY(), colour);
2525
}
2626

27+
public Component getTooltip() {
28+
return this.feature.getDisplayName();
29+
}
30+
2731
private static void onButtonPress(Button button) {
2832
if (!(button instanceof FeatureToggleWidget widget)) {
2933
return;

src/main/java/dev/xpple/seedmapper/seedmap/MapFeature.java

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66
import dev.xpple.seedmapper.SeedMapper;
77
import dev.xpple.seedmapper.feature.StructureChecks;
88
import dev.xpple.seedmapper.util.WorldIdentifier;
9+
import net.minecraft.network.chat.Component;
910
import net.minecraft.resources.ResourceLocation;
1011

1112
import java.lang.foreign.Arena;
1213
import java.lang.foreign.MemorySegment;
1314
import java.util.Arrays;
15+
import java.util.HashMap;
1416
import java.util.Map;
1517
import java.util.stream.Collectors;
1618
import java.util.stream.IntStream;
1719

1820
public enum MapFeature {
19-
DESERT_PYRAMID("desert_pyramid", Cubiomes.Desert_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "cubiomes_viewer_icons", 19, 20),
20-
JUNGLE_PYRAMID("jungle_pyramid", Cubiomes.Jungle_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "cubiomes_viewer_icons", 19, 20),
21-
SWAMP_HUT("swamp_hut", Cubiomes.Swamp_Hut(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_4(), "cubiomes_viewer_icons", 20, 20),
22-
STRONGHOLD("stronghold", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 19, 20),
23-
IGLOO("igloo", Cubiomes.Igloo(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_9(), "cubiomes_viewer_icons", 20, 20) {
21+
DESERT_PYRAMID("desert_pyramid", Cubiomes.Desert_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "Desert Pyramid", "cubiomes_viewer_icons", 19, 20),
22+
JUNGLE_PYRAMID("jungle_pyramid", Cubiomes.Jungle_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "Jungle Pyramid", "cubiomes_viewer_icons", 19, 20),
23+
SWAMP_HUT("swamp_hut", Cubiomes.Swamp_Hut(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_4(), "Swamp Hut", "cubiomes_viewer_icons", 20, 20),
24+
STRONGHOLD("stronghold", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Stronghold", "cubiomes_viewer_icons", 19, 20),
25+
IGLOO("igloo", Cubiomes.Igloo(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_9(), "Igloo", "cubiomes_viewer_icons", 20, 20) {
2426
private static final Texture IGLOO_BASEMENT_TEXTURE = new Texture("igloo_basement", "cubiomes_viewer_icons", 20, 20);
2527
@Override
2628
public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ, int biome) {
@@ -34,7 +36,7 @@ public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ,
3436
}
3537
}
3638
},
37-
VILLAGE("village", Cubiomes.Village(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 19, 20) {
39+
VILLAGE("village", Cubiomes.Village(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Village", "cubiomes_viewer_icons", 19, 20) {
3840
private static final Texture ZOMBIE_VILLAGE_TEXTURE = new Texture("zombie", "cubiomes_viewer_icons", 19, 20);
3941
@Override
4042
public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ, int biome) {
@@ -48,12 +50,12 @@ public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ,
4850
}
4951
}
5052
},
51-
OCEAN_RUIN("ocean_ruin", Cubiomes.Ocean_Ruin(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
52-
SHIPWRECK("shipwreck", Cubiomes.Shipwreck(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
53-
MONUMENT("monument", Cubiomes.Monument(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_8(), "cubiomes_viewer_icons", 20, 20),
54-
MANSION("mansion", Cubiomes.Mansion(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_11(), "cubiomes_viewer_icons", 20, 20),
55-
OUTPOST("pillager_outpost", Cubiomes.Outpost(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_14(), "cubiomes_viewer_icons", 19, 20),
56-
RUINED_PORTAL("ruined_portal", Cubiomes.Ruined_Portal(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20) {
53+
OCEAN_RUIN("ocean_ruin", Cubiomes.Ocean_Ruin(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Ocean Ruin", "cubiomes_viewer_icons", 19, 19),
54+
SHIPWRECK("shipwreck", Cubiomes.Shipwreck(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Shipwreck", "cubiomes_viewer_icons", 19, 19),
55+
MONUMENT("monument", Cubiomes.Monument(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_8(), "Ocean Monument", "cubiomes_viewer_icons", 20, 20),
56+
MANSION("mansion", Cubiomes.Mansion(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_11(), "Woodland Mansion", "cubiomes_viewer_icons", 20, 20),
57+
OUTPOST("pillager_outpost", Cubiomes.Outpost(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_14(), "Pillager Outpost", "cubiomes_viewer_icons", 19, 20),
58+
RUINED_PORTAL("ruined_portal", Cubiomes.Ruined_Portal(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_16_1(), "Ruined Portal", "cubiomes_viewer_icons", 20, 20) {
5759
private static final Texture RUINED_PORTAL_GIANT_TEXTURE = new Texture("portal_giant", "cubiomes_viewer_icons", 20, 20);
5860
@Override
5961
public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ, int biome) {
@@ -67,23 +69,23 @@ public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ,
6769
}
6870
}
6971
},
70-
RUINED_PORTAL_N("ruined_portal_n", Cubiomes.Ruined_Portal_N(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20) {
72+
RUINED_PORTAL_N("ruined_portal_n", Cubiomes.Ruined_Portal_N(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "Ruined Portal (Nether)", "cubiomes_viewer_icons", 20, 20) {
7173
@Override
7274
public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ, int biome) {
7375
return RUINED_PORTAL.getVariantTexture(identifier, posX, posZ, biome);
7476
}
7577
},
76-
ANCIENT_CITY("ancient_city", Cubiomes.Ancient_City(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_19_2(), "cubiomes_viewer_icons", 20, 20),
77-
TREASURE("buried_treasure", Cubiomes.Treasure(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
78-
MINESHAFT("mineshaft", Cubiomes.Mineshaft(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 20, 19),
79-
DESERT_WELL("desert_well", Cubiomes.Desert_Well(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 20, 20),
80-
GEODE("geode", Cubiomes.Geode(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_17(), "cubiomes_viewer_icons", 20, 20),
81-
COPPER_ORE_VEIN("copper_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "feature_icons", 20, 20),
82-
IRON_ORE_VEIN("iron_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "feature_icons", 20, 20),
83-
CANYON("canyon", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "feature_icons", 20, 20),
84-
FORTRESS("fortress", Cubiomes.Fortress(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_0(), "cubiomes_viewer_icons", 20, 20),
85-
BASTION("bastion_remnant", Cubiomes.Bastion(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20),
86-
END_CITY("end_city", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "cubiomes_viewer_icons", 20, 20) {
78+
ANCIENT_CITY("ancient_city", Cubiomes.Ancient_City(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_19_2(), "Ancient City", "cubiomes_viewer_icons", 20, 20),
79+
TREASURE("buried_treasure", Cubiomes.Treasure(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Buried Treasure", "cubiomes_viewer_icons", 19, 19),
80+
MINESHAFT("mineshaft", Cubiomes.Mineshaft(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Mineshaft", "cubiomes_viewer_icons", 20, 19),
81+
DESERT_WELL("desert_well", Cubiomes.Desert_Well(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Desert Well", "cubiomes_viewer_icons", 20, 20),
82+
GEODE("geode", Cubiomes.Geode(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_17(), "Geode", "cubiomes_viewer_icons", 20, 20),
83+
COPPER_ORE_VEIN("copper_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "Copper Ore Vein", "feature_icons", 20, 20),
84+
IRON_ORE_VEIN("iron_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "Iron Ore Vein", "feature_icons", 20, 20),
85+
CANYON("canyon", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Canyon", "feature_icons", 20, 20),
86+
FORTRESS("fortress", Cubiomes.Fortress(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_0(), "Nether Fortress", "cubiomes_viewer_icons", 20, 20),
87+
BASTION("bastion_remnant", Cubiomes.Bastion(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "Bastion Remnant", "cubiomes_viewer_icons", 20, 20),
88+
END_CITY("end_city", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "End City", "cubiomes_viewer_icons", 20, 20) {
8789
private static final Texture END_CITY_SHIP_TEXTURE = new Texture("elytra", "cubiomes_viewer_icons", 20, 20);
8890
@Override
8991
public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ, int biome) {
@@ -100,21 +102,28 @@ public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ,
100102
}
101103
}
102104
},
103-
END_GATEWAY("end_gateway", Cubiomes.End_Gateway(), Cubiomes.DIM_END(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 20, 20),
104-
TRAIL_RUINS("trail_ruins", Cubiomes.Trail_Ruins(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_20(), "cubiomes_viewer_icons", 20, 20),
105-
TRIAL_CHAMBERS("trial_chambers", Cubiomes.Trial_Chambers(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_21_1(), "cubiomes_viewer_icons", 20, 20),
106-
SLIME_CHUNK("slime_chunk", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "feature_icons", 20, 20),
107-
WORLD_SPAWN("world_spawn", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "cubiomes_viewer_icons", 20, 20),
108-
WAYPOINT("waypoint", -1, Cubiomes.DIM_UNDEF(), Cubiomes.MC_B1_7(), "feature_icons", 20, 20),
105+
END_GATEWAY("end_gateway", Cubiomes.End_Gateway(), Cubiomes.DIM_END(), Cubiomes.MC_1_13(), "End Gateway", "cubiomes_viewer_icons", 20, 20),
106+
TRAIL_RUINS("trail_ruins", Cubiomes.Trail_Ruins(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_20(), "Trail Ruins", "cubiomes_viewer_icons", 20, 20),
107+
TRIAL_CHAMBERS("trial_chambers", Cubiomes.Trial_Chambers(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_21_1(), "Trial Chambers", "cubiomes_viewer_icons", 20, 20),
108+
SLIME_CHUNK("slime_chunk", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "Slime Chunk", "feature_icons", 20, 20),
109+
WORLD_SPAWN("world_spawn", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "World Spawn", "cubiomes_viewer_icons", 20, 20),
110+
WAYPOINT("waypoint", -1, Cubiomes.DIM_UNDEF(), Cubiomes.MC_B1_7(), "Waypoint", "feature_icons", 20, 20),
109111
;
110112

111-
public static final Map<String, MapFeature> BY_NAME = Arrays.stream(values())
112-
.collect(Collectors.toUnmodifiableMap(MapFeature::getName, f -> f));
113+
public static final Map<String, MapFeature> BY_NAME;
114+
static {
115+
Map<String, MapFeature> map = Arrays.stream(values())
116+
.collect(Collectors.toMap(MapFeature::getName, f -> f, (left, right) -> left, HashMap::new));
117+
map.put("end_city_ship", END_CITY);
118+
BY_NAME = Map.copyOf(map);
119+
}
113120

114121
private final String name;
115122
private final int structureId;
116123
private final int dimension;
117124
private final int availableSince;
125+
private final Component displayName;
126+
private final String translationKey;
118127
private final Texture defaultTexture;
119128

120129
MapFeature(String name, int structureId, int dimension, int availableSince, String displayName, String directory, int textureWidth, int textureHeight) {
@@ -126,7 +135,9 @@ public Texture getVariantTexture(WorldIdentifier identifier, int posX, int posZ,
126135
this.structureId = structureId;
127136
this.dimension = dimension;
128137
this.availableSince = availableSince;
129-
this.defaultTexture = new Texture(name, directory, textureWidth, textureHeight);
138+
this.translationKey = "seedMap.feature." + name;
139+
this.displayName = Component.translatableWithFallback(this.translationKey, displayName);
140+
this.defaultTexture = new Texture(textureName, directory, textureWidth, textureHeight);
130141
}
131142

132143
public String getName() {
@@ -145,6 +156,14 @@ public int availableSince() {
145156
return this.availableSince;
146157
}
147158

159+
public Component getDisplayName() {
160+
return this.displayName;
161+
}
162+
163+
public String getTranslationKey() {
164+
return this.translationKey;
165+
}
166+
148167
public Texture getDefaultTexture() {
149168
return this.defaultTexture;
150169
}

src/main/java/dev/xpple/seedmapper/seedmap/SeedMapScreen.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
import net.minecraft.client.gui.render.state.BlitRenderState;
6262
import net.minecraft.client.gui.screens.Screen;
6363
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
64-
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
64+
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
6565
import net.minecraft.client.input.KeyEvent;
6666
import net.minecraft.client.input.MouseButtonEvent;
6767
import net.minecraft.client.player.LocalPlayer;
@@ -92,6 +92,7 @@
9292
import org.jetbrains.annotations.Nullable;
9393
import org.slf4j.Logger;
9494
import org.joml.Matrix3x2f;
95+
import org.joml.Vector2i;
9596

9697
import java.lang.foreign.Arena;
9798
import java.lang.foreign.MemoryLayout;
@@ -192,6 +193,21 @@ public class SeedMapScreen extends Screen {
192193
private static final Object2ObjectMap<WorldIdentifier, Object2ObjectMap<TilePos, BitSet>> canyonDataCache = new Object2ObjectOpenHashMap<>();
193194
private static final Object2ObjectMap<WorldIdentifier, Object2ObjectMap<TilePos, BitSet>> slimeChunkDataCache = new Object2ObjectOpenHashMap<>();
194195
private static final Object2ObjectMap<WorldIdentifier, BlockPos> spawnDataCache = new Object2ObjectOpenHashMap<>();
196+
private static final ClientTooltipPositioner BELOW_MOUSE_TOOLTIP_POSITIONER = (screenWidth, screenHeight, mouseX, mouseY, tooltipWidth, tooltipHeight) -> {
197+
int x = mouseX + 12;
198+
if (x + tooltipWidth > screenWidth) {
199+
x = mouseX - 12 - tooltipWidth;
200+
}
201+
x = Mth.clamp(x, 4, Math.max(4, screenWidth - tooltipWidth - 4));
202+
203+
int y = mouseY + 12;
204+
if (y + tooltipHeight > screenHeight) {
205+
y = mouseY - 12 - tooltipHeight;
206+
}
207+
y = Mth.clamp(y, 4, Math.max(4, screenHeight - tooltipHeight - 4));
208+
209+
return new Vector2i(x, y);
210+
};
195211

196212
private static int tileSizePixels() {
197213
double baseSize = TilePos.TILE_SIZE_CHUNKS * (double) SCALED_CHUNK_SIZE;
@@ -653,7 +669,7 @@ private void renderFeatureToggleTooltip(GuiGraphics guiGraphics, int mouseX, int
653669
for (FeatureToggleWidget widget : this.featureToggleWidgets) {
654670
if (widget.isMouseOver(mouseX, mouseY)) {
655671
List<ClientTooltipComponent> tooltip = List.of(ClientTooltipComponent.create(widget.getTooltip().getVisualOrderText()));
656-
guiGraphics.renderTooltip(this.font, tooltip, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null);
672+
guiGraphics.renderTooltip(this.font, tooltip, mouseX, mouseY, BELOW_MOUSE_TOOLTIP_POSITIONER, null);
657673
return;
658674
}
659675
}
@@ -678,7 +694,9 @@ private void createFeatureTogglesInner(int row, int togglesPerRow, int maxToggle
678694
for (int toggle = 0; toggle < maxToggles; toggle++) {
679695
MapFeature feature = this.toggleableFeatures.get(row * togglesPerRow + toggle);
680696
MapFeature.Texture featureIcon = feature.getDefaultTexture();
681-
this.addRenderableWidget(new FeatureToggleWidget(feature, toggleMinX, toggleMinY));
697+
FeatureToggleWidget widget = new FeatureToggleWidget(feature, toggleMinX, toggleMinY);
698+
this.featureToggleWidgets.add(widget);
699+
this.addRenderableWidget(widget);
682700
toggleMinX += featureIcon.width() + HORIZONTAL_FEATURE_TOGGLE_SPACING;
683701
}
684702
}
@@ -699,7 +717,8 @@ private int[] calculateBiomeData(TilePos tilePos) {
699717
Range.sy(range, 1);
700718

701719
long cacheSize = Cubiomes.getMinCacheSize(this.biomeGenerator, Range.scale(range), Range.sx(range), Range.sy(range), Range.sz(range));
702-
MemorySegment biomeIds = tempArena.allocate(Cubiomes.C_INT, cacheSize);
720+
long biomeBytes = Math.multiplyExact(cacheSize, (long) Cubiomes.C_INT.byteSize());
721+
MemorySegment biomeIds = tempArena.allocate(biomeBytes, Cubiomes.C_INT.byteAlignment());
703722
if (Cubiomes.genBiomes(this.biomeGenerator, biomeIds, range) == 0) {
704723
return biomeIds.toArray(Cubiomes.C_INT);
705724
}

0 commit comments

Comments
 (0)