Skip to content

Commit 3e9018e

Browse files
committed
WIP port to 25w09b
1 parent 7f1e221 commit 3e9018e

37 files changed

+423
-235
lines changed

gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ mod_file_name = minihud-fabric
1212
mod_version = 0.34.999-dev
1313

1414
# Required malilib version
15-
malilib_version = 0d242510ac
15+
malilib_version = b79e24ab59
1616

1717
# Minecraft, Fabric Loader and API and mappings versions
18-
minecraft_version_out = 25w08a
19-
minecraft_version = 25w08a
20-
mappings_version = 25w08a+build.4
18+
minecraft_version_out = 25w09b
19+
minecraft_version = 25w09b
20+
mappings_version = 25w09b+build.6
2121

2222
fabric_loader_version = 0.16.10
2323
mod_menu_version = 14.0.0-beta.1
24-
# fabric_api_version = 0.118.0+1.21.5
24+
# fabric_api_version = 0.118.2+1.21.5

src/main/java/fi/dy/masa/minihud/data/DebugDataManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ public boolean receiveMetadata(NbtCompound data)
203203
{
204204
MiniHUD.debugLog("DebugDataManager#receiveMetadata(): received METADATA from Servux");
205205

206-
if (data.getInt("version") != ServuxDebugPacket.PROTOCOL_VERSION)
206+
if (data.getInt("version", -1) != ServuxDebugPacket.PROTOCOL_VERSION)
207207
{
208208
MiniHUD.LOGGER.warn("debugDataChannel: Mis-matched protocol version!");
209209
}
210210

211-
this.setServuxVersion(data.getString("servux"));
211+
this.setServuxVersion(data.getString("servux", "?"));
212212
this.setIsServuxServer();
213213

214214
if (RendererToggle.DEBUG_DATA_MAIN_TOGGLE.getBooleanValue())

src/main/java/fi/dy/masa/minihud/data/EntitiesDataManager.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@ public boolean receiveServuxMetadata(NbtCompound data)
438438

439439
if (Configs.Generic.ENTITY_DATA_SYNC.getBooleanValue())
440440
{
441-
if (data.getInt("version") != ServuxEntitiesPacket.PROTOCOL_VERSION)
441+
if (data.getInt("version", -1) != ServuxEntitiesPacket.PROTOCOL_VERSION)
442442
{
443443
MiniHUD.LOGGER.warn("entityDataChannel: Mis-matched protocol version!");
444444
}
445445

446-
this.setServuxVersion(data.getString("servux"));
446+
this.setServuxVersion(data.getString("servux", "?"));
447447
this.setIsServuxServer();
448448

449449
return true;
@@ -734,7 +734,7 @@ public BlockEntity handleBlockEntityData(BlockPos pos, NbtCompound nbt, @Nullabl
734734

735735
if (blockEntity != null && (type == null || type.equals(BlockEntityType.getId(blockEntity.getType()))))
736736
{
737-
if (!nbt.contains(NbtKeys.ID, Constants.NBT.TAG_STRING))
737+
if (!nbt.contains(NbtKeys.ID))
738738
{
739739
Identifier id = BlockEntityType.getId(blockEntity.getType());
740740

@@ -764,7 +764,7 @@ public BlockEntity handleBlockEntityData(BlockPos pos, NbtCompound nbt, @Nullabl
764764

765765
if (blockEntity2 != null)
766766
{
767-
if (!nbt.contains(NbtKeys.ID, Constants.NBT.TAG_STRING))
767+
if (!nbt.contains(NbtKeys.ID))
768768
{
769769
Identifier id = BlockEntityType.getId(beType);
770770

@@ -802,7 +802,7 @@ public Entity handleEntityData(int entityId, NbtCompound nbt)
802802

803803
if (entity != null)
804804
{
805-
if (!nbt.contains(NbtKeys.ID, Constants.NBT.TAG_STRING))
805+
if (!nbt.contains(NbtKeys.ID))
806806
{
807807
Identifier id = EntityType.getId(entity.getType());
808808

src/main/java/fi/dy/masa/minihud/data/HudDataManager.java

+24-24
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,18 @@ public boolean receiveMetadata(NbtCompound data)
522522
{
523523
MiniHUD.debugLog("HudDataStorage#receiveMetadata(): received METADATA from Servux");
524524

525-
if (data.getInt("version") != ServuxHudPacket.PROTOCOL_VERSION)
525+
if (data.getInt("version", -1) != ServuxHudPacket.PROTOCOL_VERSION)
526526
{
527527
MiniHUD.LOGGER.warn("hudDataChannel: Mis-matched protocol version!");
528528
}
529529

530-
this.setServuxVersion(data.getString("servux"));
531-
this.setWorldSpawn(new BlockPos(data.getInt("spawnPosX"), data.getInt("spawnPosY"), data.getInt("spawnPosZ")));
532-
this.setSpawnChunkRadius(data.getInt("spawnChunkRadius"), true);
530+
this.setServuxVersion(data.getString("servux", "?"));
531+
this.setWorldSpawn(new BlockPos(data.getInt("spawnPosX", 0), data.getInt("spawnPosY", 0), data.getInt("spawnPosZ", 0)));
532+
this.setSpawnChunkRadius(data.getInt("spawnChunkRadius", 2), true);
533533

534-
if (data.contains("worldSeed", Constants.NBT.TAG_LONG))
534+
if (data.contains("worldSeed"))
535535
{
536-
this.setWorldSeed(data.getLong("worldSeed"));
536+
this.setWorldSeed(data.getLong("worldSeed", -1L));
537537
}
538538

539539
this.setIsServuxServer();
@@ -588,13 +588,13 @@ public void receiveSpawnMetadata(NbtCompound data)
588588
{
589589
MiniHUD.debugLog("HudDataStorage#receiveSpawnMetadata(): from Servux");
590590

591-
this.setServuxVersion(data.getString("servux"));
592-
this.setWorldSpawn(new BlockPos(data.getInt("spawnPosX"), data.getInt("spawnPosY"), data.getInt("spawnPosZ")));
593-
this.setSpawnChunkRadius(data.getInt("spawnChunkRadius"), true);
591+
this.setServuxVersion(data.getString("servux", "?"));
592+
this.setWorldSpawn(new BlockPos(data.getInt("spawnPosX", 0), data.getInt("spawnPosY", 0), data.getInt("spawnPosZ", 0)));
593+
this.setSpawnChunkRadius(data.getInt("spawnChunkRadius", 2), true);
594594

595-
if (data.contains("worldSeed", Constants.NBT.TAG_LONG))
595+
if (data.contains("worldSeed"))
596596
{
597-
this.setWorldSeed(data.getLong("worldSeed"));
597+
this.setWorldSeed(data.getLong("worldSeed", -1L));
598598
}
599599

600600
if (Configs.Generic.HUD_DATA_SYNC.getBooleanValue())
@@ -618,25 +618,25 @@ public void receiveWeatherData(NbtCompound data)
618618
{
619619
//MiniHUD.printDebug("HudDataStorage#receiveWeatherData(): from Servux");
620620

621-
if (data.contains("SetRaining", Constants.NBT.TAG_INT))
621+
if (data.contains("SetRaining"))
622622
{
623-
this.rainWeatherTimer = data.getInt("SetRaining");
623+
this.rainWeatherTimer = data.getInt("SetRaining", -1);
624624
}
625625
if (data.contains("isRaining"))
626626
{
627-
this.isRaining = data.getBoolean("isRaining");
627+
this.isRaining = data.getBoolean("isRaining", false);
628628
}
629-
if (data.contains("SetThundering", Constants.NBT.TAG_INT))
629+
if (data.contains("SetThundering"))
630630
{
631-
this.thunderWeatherTimer = data.getInt("SetThundering");
631+
this.thunderWeatherTimer = data.getInt("SetThundering", -1);
632632
}
633633
if (data.contains("isThundering"))
634634
{
635-
this.isThundering = data.getBoolean("isThundering");
635+
this.isThundering = data.getBoolean("isThundering", false);
636636
}
637-
if (data.contains("SetClear", Constants.NBT.TAG_INT))
637+
if (data.contains("SetClear"))
638638
{
639-
this.clearWeatherTimer = data.getInt("SetClear");
639+
this.clearWeatherTimer = data.getInt("SetClear", -1);
640640
}
641641

642642
if (!this.hasServuxServer() && DataStorage.getInstance().hasServuxServer())
@@ -677,17 +677,17 @@ public void receiveRecipeManager(NbtCompound data)
677677
if (!DataStorage.getInstance().hasIntegratedServer() && data.contains("RecipeManager"))
678678
{
679679
Collection<RecipeEntry<?>> recipes = new ArrayList<>();
680-
NbtList list = data.getList("RecipeManager", Constants.NBT.TAG_COMPOUND);
680+
NbtList list = data.getOrCreateList("RecipeManager");
681681
int count = 0;
682682

683683
this.preparedRecipes = PreparedRecipes.EMPTY;
684684
this.recipeCount = 0;
685685

686686
for (int i = 0; i < list.size(); i++)
687687
{
688-
NbtCompound item = list.getCompound(i);
689-
Identifier idReg = Identifier.tryParse(item.getString("id_reg"));
690-
Identifier idValue = Identifier.tryParse(item.getString("id_value"));
688+
NbtCompound item = list.getOrCreateCompound(i);
689+
Identifier idReg = Identifier.tryParse(item.getString("id_reg", ""));
690+
Identifier idValue = Identifier.tryParse(item.getString("id_value", ""));
691691

692692
if (idReg == null || idValue == null)
693693
{
@@ -697,7 +697,7 @@ public void receiveRecipeManager(NbtCompound data)
697697
try
698698
{
699699
RegistryKey<Recipe<?>> key = RegistryKey.of(RegistryKey.ofRegistry(idReg), idValue);
700-
Pair<Recipe<?>, NbtElement> pair = Recipe.CODEC.decode(DataStorage.getInstance().getWorldRegistryManager().getOps(NbtOps.INSTANCE), item.getCompound("recipe")).getOrThrow();
700+
Pair<Recipe<?>, NbtElement> pair = Recipe.CODEC.decode(DataStorage.getInstance().getWorldRegistryManager().getOps(NbtOps.INSTANCE), item.getOrCreateCompound("recipe")).getOrThrow();
701701
RecipeEntry<?> entry = new RecipeEntry<>(key, pair.getFirst());
702702
recipes.add(entry);
703703
count++;

src/main/java/fi/dy/masa/minihud/event/RenderHandler.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
import net.minecraft.block.entity.*;
2121
import net.minecraft.block.enums.ChestType;
2222
import net.minecraft.client.MinecraftClient;
23+
import net.minecraft.client.gl.Framebuffer;
2324
import net.minecraft.client.gui.DrawContext;
2425
import net.minecraft.client.network.PlayerListEntry;
26+
import net.minecraft.client.render.BufferBuilderStorage;
2527
import net.minecraft.client.render.Camera;
2628
import net.minecraft.client.render.Fog;
2729
import net.minecraft.client.render.Frustum;
@@ -258,7 +260,7 @@ public Supplier<String> getProfilerSectionSupplier()
258260
}
259261

260262
@Override
261-
public void onRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler)
263+
public void onRenderWorldPreWeather(Framebuffer fb, Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, BufferBuilderStorage buffers, Profiler profiler)
262264
{
263265
if (Configs.Generic.MAIN_RENDERING_TOGGLE.getBooleanValue() &&
264266
this.mc.world != null && this.mc.player != null && this.mc.options.hudHidden == false)
@@ -1470,7 +1472,7 @@ private boolean isEntityDataValid(@Nonnull NbtCompound nbt)
14701472
// If `Fire == 0` instead of `-1` means it's ClientWorld; it's ridiculous, but it works.
14711473
case NbtKeys.FIRE ->
14721474
{
1473-
int fire = nbt.getShort(NbtKeys.FIRE);
1475+
int fire = nbt.getShort(NbtKeys.FIRE, (short) -1);
14741476

14751477
if (fire < 0 || fire > 0)
14761478
{
@@ -1480,7 +1482,7 @@ private boolean isEntityDataValid(@Nonnull NbtCompound nbt)
14801482
// If `Age == -1 or 1 instead of 0 or > 1 it's ClientWorld; it's ridiculous, but it works.
14811483
case NbtKeys.AGE ->
14821484
{
1483-
int age = nbt.getInt(NbtKeys.AGE);
1485+
int age = nbt.getInt(NbtKeys.AGE, -1);
14841486

14851487
if (age == 0 || age > 1)
14861488
{
@@ -1490,7 +1492,7 @@ private boolean isEntityDataValid(@Nonnull NbtCompound nbt)
14901492
// Has a Brain besides the default = ServerWorld
14911493
case NbtKeys.BRAIN ->
14921494
{
1493-
NbtCompound tag = nbt.getCompound(NbtKeys.BRAIN);
1495+
NbtCompound tag = nbt.getOrCreateCompound(NbtKeys.BRAIN);
14941496

14951497
if (!tag.isEmpty() && !tag.getCompound(NbtKeys.MEMORIES).isEmpty())
14961498
{
@@ -1501,21 +1503,21 @@ private boolean isEntityDataValid(@Nonnull NbtCompound nbt)
15011503
case NbtKeys.TRADE_RECIPES -> { return true; }
15021504
case NbtKeys.ZOMBIE_CONVERSION ->
15031505
{
1504-
if (nbt.getInt(NbtKeys.ZOMBIE_CONVERSION) > 0)
1506+
if (nbt.getInt(NbtKeys.ZOMBIE_CONVERSION, -1) > 0)
15051507
{
15061508
return true;
15071509
}
15081510
}
15091511
case NbtKeys.DROWNED_CONVERSION ->
15101512
{
1511-
if (nbt.getInt(NbtKeys.DROWNED_CONVERSION) > 0)
1513+
if (nbt.getInt(NbtKeys.DROWNED_CONVERSION, -1) > 0)
15121514
{
15131515
return true;
15141516
}
15151517
}
15161518
case NbtKeys.STRAY_CONVERSION ->
15171519
{
1518-
if (nbt.getInt(NbtKeys.STRAY_CONVERSION) > 0)
1520+
if (nbt.getInt(NbtKeys.STRAY_CONVERSION, -1) > 0)
15191521
{
15201522
return true;
15211523
}

src/main/java/fi/dy/masa/minihud/gui/widgets/WidgetShapeEntry.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ else if (this.isOdd)
9999
this.drawString(this.x + 4, this.y + 7, 0xFFFFFFFF, name, context);
100100

101101
RenderUtils.color(1f, 1f, 1f, 1f);
102-
RenderSystem.disableBlend();
102+
//RenderSystem.disableBlend();
103+
RenderUtils.blend(false);
103104

104105
super.render(mouseX, mouseY, selected, context);
105106
}

src/main/java/fi/dy/masa/minihud/network/ServuxStructuresHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void decodeStructuresPacket(Identifier channel, ServuxStructuresPacket pa
9090

9191
if (nbt != null)
9292
{
93-
NbtList structures = nbt.getList("Structures", Constants.NBT.TAG_COMPOUND);
93+
NbtList structures = nbt.getOrCreateList("Structures");
9494
//MiniHUD.printDebug("decodeStructuresPacket(): received Structures Data of size {} (in bytes) // structures [{}]", nbt.getSizeInBytes(), structures.size());
9595

9696
DataStorage.getInstance().addOrUpdateStructuresFromServer(structures, this.servuxRegistered);

src/main/java/fi/dy/masa/minihud/renderer/BaseBlockRangeOverlay.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.block.entity.BlockEntity;
77
import net.minecraft.block.entity.BlockEntityType;
88
import net.minecraft.client.MinecraftClient;
9+
import net.minecraft.client.gl.GlUsage;
910
import net.minecraft.client.render.VertexFormats;
1011
import net.minecraft.client.world.ClientChunkManager;
1112
import net.minecraft.client.world.ClientWorld;
@@ -17,6 +18,7 @@
1718
import net.minecraft.world.chunk.WorldChunk;
1819

1920
import fi.dy.masa.malilib.config.IConfigBoolean;
21+
import fi.dy.masa.malilib.render.MaLiLibPipelines;
2022
import fi.dy.masa.malilib.util.WorldUtils;
2123

2224
public abstract class BaseBlockRangeOverlay<T extends BlockEntity> extends OverlayRendererBase
@@ -133,14 +135,19 @@ public void update(Vec3d cameraPos, Entity entity, MinecraftClient mc)
133135

134136
protected void startBuffers()
135137
{
136-
BUFFER_1 = TESSELLATOR_1.begin(this.renderObjects.get(0).getGlMode(), VertexFormats.POSITION_COLOR);
137-
BUFFER_2 = TESSELLATOR_2.begin(this.renderObjects.get(1).getGlMode(), VertexFormats.POSITION_COLOR);
138+
// BUFFER_1 = TESSELLATOR_1.begin(this.renderObjects.get(0).getGlMode(), VertexFormats.POSITION_COLOR);
139+
// BUFFER_2 = TESSELLATOR_2.begin(this.renderObjects.get(1).getGlMode(), VertexFormats.POSITION_COLOR);
140+
141+
CONTEXT_1.startNoShader(() -> this.renderObjects.get(0).getClass().getName(), VertexFormats.POSITION_COLOR, this.renderObjects.get(0).getGlMode(), GlUsage.STATIC_WRITE);
142+
CONTEXT_2.startNoShader(() -> this.renderObjects.get(1).getClass().getName(), VertexFormats.POSITION_COLOR, this.renderObjects.get(1).getGlMode(), GlUsage.STATIC_WRITE);
143+
CONTEXT_1.setShader(MaLiLibPipelines.POSITION_COLOR_SIMPLE);
144+
CONTEXT_2.setShader(MaLiLibPipelines.POSITION_COLOR_SIMPLE);
138145
}
139146

140147
protected void uploadBuffers()
141148
{
142-
this.renderObjects.get(0).uploadData(BUFFER_1);
143-
this.renderObjects.get(1).uploadData(BUFFER_2);
149+
this.renderObjects.get(0).uploadData(CONTEXT_1.getBuilder());
150+
this.renderObjects.get(1).uploadData(CONTEXT_2.getBuilder());
144151
}
145152

146153
protected boolean fetchAllTargetBlockEntityPositions(ClientWorld world, BlockPos centerPos, MinecraftClient mc)

src/main/java/fi/dy/masa/minihud/renderer/InventoryOverlayHandler.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import fi.dy.masa.malilib.util.EntityUtils;
4040
import fi.dy.masa.malilib.util.InventoryUtils;
4141
import fi.dy.masa.malilib.util.WorldUtils;
42-
import fi.dy.masa.malilib.util.data.Constants;
4342
import fi.dy.masa.malilib.util.nbt.NbtBlockUtils;
4443
import fi.dy.masa.malilib.util.nbt.NbtKeys;
4544
import fi.dy.masa.minihud.Reference;
@@ -450,7 +449,7 @@ else if (entity instanceof PiglinEntity)
450449
// Fix for empty horse inv
451450
if (inv != null &&
452451
nbt.contains(NbtKeys.ITEMS) &&
453-
nbt.getList(NbtKeys.ITEMS, Constants.NBT.TAG_COMPOUND).size() > 1)
452+
nbt.getOrCreateList(NbtKeys.ITEMS).size() > 1)
454453
{
455454
if (entity instanceof AbstractHorseEntity)
456455
{
@@ -473,7 +472,7 @@ else if (inv != null &&
473472
// Fix for empty Villager/Piglin inv
474473
else if (inv != null && inv.size() == 8 &&
475474
nbt.contains(NbtKeys.INVENTORY) &&
476-
!nbt.getList(NbtKeys.INVENTORY, Constants.NBT.TAG_COMPOUND).isEmpty())
475+
!nbt.getOrCreateList(NbtKeys.INVENTORY).isEmpty())
477476
{
478477
inv2 = InventoryUtils.getNbtInventory(nbt, 8, entity.getRegistryManager());
479478
inv = null;

0 commit comments

Comments
 (0)