Skip to content

Commit 1137cc5

Browse files
committed
1.1.2, closes #18, closes #15
1 parent 53ec7ba commit 1137cc5

16 files changed

Lines changed: 229 additions & 282 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ body:
4242
label: Mod Version
4343
description: The version of the mod you were using
4444
options:
45+
- "1.1.2"
4546
- "1.1.1"
4647
- "1.1.0"
4748
- "1.0.3"

CHANGELOG-LATEST.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
### Fixed
22

3-
- Fixed bosses tag not populating properly.
4-
- Fixed possible networking-related NPE.
3+
- Improve networking performance for 1.21.1.
4+
- Fixed crashes with scanning multipart entities.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.2] - 2026-03-01
9+
10+
### Fixed
11+
12+
- Improve networking performance for 1.21.1.
13+
- Fixed crashes with scanning multipart entities.
14+
815
## [1.1.1] - 2026-03-01
916

1017
### Fixed

common/src/main/java/com/evandev/fieldguide/client/render/ScanOverlayRenderer.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ public static void render(PoseStack poseStack, float partialTick, Camera camera,
4545
FieldGuideScanner scanner = FieldGuideScanner.getInstance();
4646
Minecraft mc = Minecraft.getInstance();
4747

48-
Entity outOfRangeEntity = scanner.getOutOfRangeEntity();
49-
Entity targetEntity = scanner.getScanningEntity() != null ? scanner.getScanningEntity() : (scanner.getFadingEntity() != null ? scanner.getFadingEntity() : outOfRangeEntity);
48+
Entity outOfRangeEntity = resolveEntity(scanner.getOutOfRangeEntity());
49+
Entity scanningRaw = scanner.getScanningEntity() != null ? scanner.getScanningEntity() : (scanner.getFadingEntity() != null ? scanner.getFadingEntity() : scanner.getOutOfRangeEntity());
50+
Entity targetEntity = resolveEntity(scanningRaw);
51+
5052
BlockPos outOfRangePos = scanner.getOutOfRangePos();
5153
BlockPos targetBlock = (scanner.getScanningTarget() instanceof Block && scanner.getScanningPos() != null) ? scanner.getScanningPos() : (scanner.getFadingPos() != null ? scanner.getFadingPos() : outOfRangePos);
5254

@@ -82,6 +84,22 @@ public static void render(PoseStack poseStack, float partialTick, Camera camera,
8284
}
8385
}
8486

87+
private static Entity resolveEntity(Entity entity) {
88+
if (entity == null) return null;
89+
if (entity instanceof net.minecraft.world.entity.boss.EnderDragonPart dragonPart) {
90+
return dragonPart.parentMob;
91+
}
92+
try {
93+
java.lang.reflect.Method getParent = entity.getClass().getMethod("getParent");
94+
Object parent = getParent.invoke(entity);
95+
if (parent instanceof Entity parentEntity) {
96+
return parentEntity;
97+
}
98+
} catch (Exception ignored) {
99+
}
100+
return entity;
101+
}
102+
85103
private static VertexConsumer createTintedConsumer(VertexConsumer delegate, MultiBufferSource provider, float r, float g, float b, float a) {
86104
if (Services.PLATFORM.isModLoaded("entity_texture_features")) {
87105
return EtfCompat.createTintedConsumer(delegate, provider, r, g, b, a);
@@ -404,15 +422,22 @@ private static void renderEntityOverlay(PoseStack poseStack, float partialTick,
404422
}
405423

406424
MultiBufferSource depthSource = new ScanBufferSourceWrapper(bufferSource, 1, 1, 1, 1, true);
407-
mc.getEntityRenderDispatcher().render(targetEntity, 0.0D, 0.0D, 0.0D, yaw, partialTick, poseStack, depthSource, 15728880);
425+
try {
426+
mc.getEntityRenderDispatcher().render(targetEntity, 0.0D, 0.0D, 0.0D, yaw, partialTick, poseStack, depthSource, 15728880);
427+
} catch (Exception ignored) {
428+
// Failsafe catch for entity parts trying to utilize incorrect render layers
429+
}
408430
bufferSource.endBatch();
409431

410432
if (ModRenderTypes.SCAN_ENTITY_SHADER != null && ModRenderTypes.SCAN_ENTITY_SHADER.getUniform("ColorModulator") != null) {
411433
ModRenderTypes.SCAN_ENTITY_SHADER.getUniform("ColorModulator").set(red, green, blue, alpha);
412434
}
413435

414436
MultiBufferSource forcedSource = new ScanBufferSourceWrapper(bufferSource, red, green, blue, alpha, false);
415-
mc.getEntityRenderDispatcher().render(targetEntity, 0.0D, 0.0D, 0.0D, yaw, partialTick, poseStack, forcedSource, 15728880);
437+
try {
438+
mc.getEntityRenderDispatcher().render(targetEntity, 0.0D, 0.0D, 0.0D, yaw, partialTick, poseStack, forcedSource, 15728880);
439+
} catch (Exception ignored) {
440+
}
416441
bufferSource.endBatch();
417442

418443
if (isEtfLoaded) {

common/src/main/java/com/evandev/fieldguide/data/Category.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
package com.evandev.fieldguide.data;
22

33
import com.evandev.fieldguide.Constants;
4+
import net.minecraft.network.RegistryFriendlyByteBuf;
5+
import net.minecraft.network.codec.ByteBufCodecs;
6+
import net.minecraft.network.codec.StreamCodec;
47
import net.minecraft.resources.ResourceLocation;
58

69
import java.util.ArrayList;
710
import java.util.List;
811

912
public class Category {
13+
public static final StreamCodec<RegistryFriendlyByteBuf, Category> CODEC = StreamCodec.of(
14+
(buf, cat) -> {
15+
buf.writeResourceLocation(cat.getId());
16+
buf.writeInt(cat.getSortIndex());
17+
buf.writeResourceLocation(cat.getIcon());
18+
ByteBufCodecs.stringUtf8(32767).apply(ByteBufCodecs.list()).encode(buf, cat.getGroupByQueries());
19+
CategoryEntry.CODEC.apply(ByteBufCodecs.list()).encode(buf, cat.getEntries());
20+
},
21+
buf -> {
22+
Category cat = new Category(buf.readResourceLocation());
23+
cat.setSortIndex(buf.readInt());
24+
cat.setIcon(buf.readResourceLocation());
25+
cat.setGroupByQueries(ByteBufCodecs.stringUtf8(32767).apply(ByteBufCodecs.list()).decode(buf));
26+
List<CategoryEntry> decodedEntries = CategoryEntry.CODEC.apply(ByteBufCodecs.list()).decode(buf);
27+
cat.getEntries().addAll(decodedEntries);
28+
return cat;
29+
}
30+
);
31+
1032
private final ResourceLocation id;
1133
private final List<CategoryEntry> entries = new ArrayList<>();
1234
private List<String> groupByQueries = new ArrayList<>();
Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,47 @@
11
package com.evandev.fieldguide.data;
22

3+
import net.minecraft.network.RegistryFriendlyByteBuf;
4+
import net.minecraft.network.codec.ByteBufCodecs;
5+
import net.minecraft.network.codec.StreamCodec;
36
import net.minecraft.resources.ResourceLocation;
47

58
import java.util.List;
9+
import java.util.Optional;
610

7-
public record CategoryEntry(Type type, ResourceLocation id, ResourceLocation displayId, String strategy,
11+
public record CategoryEntry(CategoryType.Type type, ResourceLocation id, ResourceLocation displayId, String strategy,
812
List<ResourceLocation> components,
913
ResourceLocation structureNbt,
1014
List<String> stackedBlocks) {
11-
public enum Type {ENTRY, AUTO_POPULATE, COMPOSITE}
15+
16+
public static final StreamCodec<RegistryFriendlyByteBuf, CategoryEntry> CODEC = StreamCodec.of(
17+
(buf, entry) -> {
18+
CategoryType.Type.CODEC.encode(buf, entry.type());
19+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).encode(buf, Optional.ofNullable(entry.id()));
20+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).encode(buf, Optional.ofNullable(entry.displayId()));
21+
ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8).encode(buf, Optional.ofNullable(entry.strategy()));
22+
23+
buf.writeBoolean(entry.components() != null);
24+
if (entry.components() != null) {
25+
ResourceLocation.STREAM_CODEC.apply(ByteBufCodecs.list()).encode(buf, entry.components());
26+
}
27+
28+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).encode(buf, Optional.ofNullable(entry.structureNbt()));
29+
30+
buf.writeBoolean(entry.stackedBlocks() != null);
31+
if (entry.stackedBlocks() != null) {
32+
ByteBufCodecs.stringUtf8(32767).apply(ByteBufCodecs.list()).encode(buf, entry.stackedBlocks());
33+
}
34+
},
35+
buf -> new CategoryEntry(
36+
CategoryType.Type.CODEC.decode(buf),
37+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).decode(buf).orElse(null),
38+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).decode(buf).orElse(null),
39+
ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8).decode(buf).orElse(null),
40+
buf.readBoolean() ? ResourceLocation.STREAM_CODEC.apply(ByteBufCodecs.list()).decode(buf) : null,
41+
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC).decode(buf).orElse(null),
42+
buf.readBoolean() ? ByteBufCodecs.stringUtf8(32767).apply(ByteBufCodecs.list()).decode(buf) : null
43+
)
44+
);
45+
46+
1247
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.evandev.fieldguide.data;
2+
3+
import io.netty.buffer.ByteBuf;
4+
import net.minecraft.network.codec.ByteBufCodecs;
5+
import net.minecraft.network.codec.StreamCodec;
6+
import net.minecraft.util.ByIdMap;
7+
8+
import java.util.function.IntFunction;
9+
10+
public class CategoryType {
11+
public enum Type {
12+
ENTRY, AUTO_POPULATE, COMPOSITE;
13+
14+
private static final IntFunction<Type> BY_ID = ByIdMap.continuous(
15+
Type::ordinal,
16+
Type.values(),
17+
ByIdMap.OutOfBoundsStrategy.ZERO
18+
);
19+
20+
public static final StreamCodec<ByteBuf, Type> CODEC = ByteBufCodecs.idMapper(
21+
BY_ID,
22+
Type::ordinal
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)