diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f408858ca..702e74b3f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,4 +4,4 @@ Make sure to clear this after each release Put changelog here: ----------------- -- Allowed malformed properties in ItemBlockStateTagUtils.getProperty() +- Fixed mob spawners not running `finalizeSpawn()` when spawning mobs diff --git a/gradle.properties b/gradle.properties index 89d37ecaa..3d5efb1e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ loader_version=0.14.19 # Mod Properties - mod_version = 1.2.5 + mod_version = 1.2.6 mod_loader = Fabric maven_group = net.frozenblock archives_base_name = FrozenLib diff --git a/src/main/java/net/frozenblock/lib/spotting_icons/api/SpottingIconManager.java b/src/main/java/net/frozenblock/lib/spotting_icons/api/SpottingIconManager.java index 05650175f..87988916d 100644 --- a/src/main/java/net/frozenblock/lib/spotting_icons/api/SpottingIconManager.java +++ b/src/main/java/net/frozenblock/lib/spotting_icons/api/SpottingIconManager.java @@ -54,7 +54,7 @@ public void tick() { this.ticksToCheck = 20; if (this.icon != null) { if (this.entity.level.isClientSide) { - this.clientHasIconResource = ClientSpottingIconMethods.hasTexture(this.icon.getTexture()); + this.clientHasIconResource = ClientSpottingIconMethods.hasTexture(this.icon.texture()); } if (!SpottingIconPredicate.getPredicate(this.icon.restrictionID).test(this.entity)) { this.removeIcon(); @@ -76,7 +76,7 @@ public void setIcon(ResourceLocation texture, float startFade, float endFade, Re ServerPlayNetworking.send(player, FrozenMain.SPOTTING_ICON_PACKET, byteBuf); } } else { - this.clientHasIconResource = ClientSpottingIconMethods.hasTexture(this.icon.getTexture()); + this.clientHasIconResource = ClientSpottingIconMethods.hasTexture(this.icon.texture()); } SpottingIconPredicate.getPredicate(this.icon.restrictionID).onAdded(this.entity); } @@ -106,7 +106,7 @@ public void sendIconPacket(ServerPlayer player) { } public void load(CompoundTag nbt) { - nbt.putInt("frozenSpottingIconTicksToCheck", this.ticksToCheck); + this.ticksToCheck = nbt.getInt("frozenSpottingIconTicksToCheck"); if (nbt.contains("frozenSpottingIcons")) { this.icon = null; DataResult var10000 = SpottingIcon.CODEC.parse(new Dynamic<>(NbtOps.INSTANCE, nbt.getCompound("frozenSpottingIcons"))); @@ -118,7 +118,7 @@ public void load(CompoundTag nbt) { } public void save(CompoundTag nbt) { - this.ticksToCheck = nbt.getInt("frozenSpottingIconTicksToCheck"); + nbt.putInt("frozenSpottingIconTicksToCheck", this.ticksToCheck); if (this.icon != null) { DataResult var10000 = SpottingIcon.CODEC.encodeStart(NbtOps.INSTANCE, this.icon); Logger var10001 = FrozenMain.LOGGER4; @@ -129,40 +129,12 @@ public void save(CompoundTag nbt) { } } - public static class SpottingIcon { - public final ResourceLocation texture; - public final float startFadeDist; - public final float endFadeDist; - public final ResourceLocation restrictionID; - - public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( - ResourceLocation.CODEC.fieldOf("texture").forGetter(SpottingIcon::getTexture), - Codec.FLOAT.fieldOf("startFadeDist").forGetter(SpottingIcon::getStartFadeDist), - Codec.FLOAT.fieldOf("endFadeDist").forGetter(SpottingIcon::getEndFadeDist), - ResourceLocation.CODEC.fieldOf("restrictionID").forGetter(SpottingIcon::getRestrictionID) - ).apply(instance, SpottingIcon::new)); - - public SpottingIcon(ResourceLocation texture, float startFadeDist, float endFadeDist, ResourceLocation restrictionID) { - this.texture = texture; - this.startFadeDist = startFadeDist; - this.endFadeDist = endFadeDist; - this.restrictionID = restrictionID; - } - - public ResourceLocation getTexture() { - return this.texture; - } - - public float getStartFadeDist() { - return this.startFadeDist; - } - - public float getEndFadeDist() { - return this.endFadeDist; - } - - public ResourceLocation getRestrictionID() { - return this.restrictionID; - } + public record SpottingIcon(ResourceLocation texture, float startFadeDist, float endFadeDist, ResourceLocation restrictionID) { + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( + ResourceLocation.CODEC.fieldOf("texture").forGetter(SpottingIcon::texture), + Codec.FLOAT.fieldOf("startFadeDist").forGetter(SpottingIcon::startFadeDist), + Codec.FLOAT.fieldOf("endFadeDist").forGetter(SpottingIcon::endFadeDist), + ResourceLocation.CODEC.fieldOf("restrictionID").forGetter(SpottingIcon::restrictionID) + ).apply(instance, SpottingIcon::new)); } } diff --git a/src/main/java/net/frozenblock/lib/spotting_icons/mixin/client/EntityRendererMixin.java b/src/main/java/net/frozenblock/lib/spotting_icons/mixin/client/EntityRendererMixin.java index 0d072bfde..a8ae813a6 100644 --- a/src/main/java/net/frozenblock/lib/spotting_icons/mixin/client/EntityRendererMixin.java +++ b/src/main/java/net/frozenblock/lib/spotting_icons/mixin/client/EntityRendererMixin.java @@ -51,9 +51,9 @@ public void renderIcon(T entity, float entityYaw, float parti SpottingIconManager.SpottingIcon icon = iconManager.icon; if (icon != null) { double dist = Mth.sqrt((float) this.entityRenderDispatcher.distanceToSqr(entity)); - if (dist > icon.startFadeDist && iconManager.clientHasIconResource) { - float endDist = icon.endFadeDist - icon.startFadeDist; - dist -= icon.startFadeDist; + if (dist > icon.startFadeDist() && iconManager.clientHasIconResource) { + float endDist = icon.endFadeDist() - icon.startFadeDist(); + dist -= icon.startFadeDist(); float alpha = dist > endDist ? 1F : (float) Math.min(1F, dist / endDist); float f = entity.getBbHeight() + 1F; matrixStack.pushPose(); @@ -63,7 +63,7 @@ public void renderIcon(T entity, float entityYaw, float parti Matrix4f matrix4f = matrixStack.last().pose(); Matrix3f matrix3f = matrixStack.last().normal(); int overlay = OverlayTexture.pack(OverlayTexture.u(0F), OverlayTexture.v(false)); - VertexConsumer vertexConsumer = buffer.getBuffer(FrozenRenderType.entityTranslucentEmissiveAlwaysRender(((EntitySpottingIconInterface) entity).getSpottingIconManager().icon.getTexture())); + VertexConsumer vertexConsumer = buffer.getBuffer(FrozenRenderType.entityTranslucentEmissiveAlwaysRender(((EntitySpottingIconInterface) entity).getSpottingIconManager().icon.texture())); vertexConsumer .vertex(matrix4f, -0.5F, -0.5F, 0.0F) .color(1, 1, 1, alpha)