From 27182602569cc6083c58a4e1a05892b1340a5839 Mon Sep 17 00:00:00 2001 From: glisco Date: Wed, 4 Oct 2023 12:58:27 +0200 Subject: [PATCH] 1.20.2 --- build.gradle | 3 +- gradle.properties | 12 +++---- gradle/wrapper/gradle-wrapper.properties | 2 +- .../render/AreaRenderable.java | 6 ++-- .../render/EntityRenderable.java | 31 +++++++++++++------ .../isometricrenders/screen/RenderScreen.java | 12 +++---- src/main/resources/fabric.mod.json | 10 +++--- 7 files changed, 44 insertions(+), 32 deletions(-) diff --git a/build.gradle b/build.gradle index 80f63ce..1022704 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,7 @@ //file:noinspection GradlePackageVersionRange plugins { - id 'fabric-loom' version '1.3-SNAPSHOT' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'maven-publish' - id 'io.github.juuxel.loom-quiltflower' version '1.7.1' } version = "${project.mod_version}+${project.minecraft_base_version}" diff --git a/gradle.properties b/gradle.properties index 01699c7..385c51c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,17 +2,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_base_version=1.20 -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.9 -loader_version=0.14.21 +minecraft_base_version=1.20.2 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.2 +loader_version=0.14.22 # Mod Properties mod_version=0.4.5 maven_group=com.glisco archives_base_name=isometric-renders # Dependencies -fabric_version=0.87.0+1.20.1 +fabric_version=0.89.3+1.20.2 # https://maven.wispforest.io/io/wispforest/worldmesher/ worldmesher_version=0.4.2+1.20 @@ -21,4 +21,4 @@ worldmesher_version=0.4.2+1.20 exo_version=0.1.5+1.19 # https://maven.wispforest.io/io/wispforest/owo-lib/ -owo_version=0.11.1+1.20 +owo_version=0.11.3+1.20.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15de902..db9a6b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/glisco/isometricrenders/render/AreaRenderable.java b/src/main/java/com/glisco/isometricrenders/render/AreaRenderable.java index 86e6ef8..0562abf 100644 --- a/src/main/java/com/glisco/isometricrenders/render/AreaRenderable.java +++ b/src/main/java/com/glisco/isometricrenders/render/AreaRenderable.java @@ -36,9 +36,9 @@ public AreaRenderable(WorldMesh mesh) { this.mesh = mesh; final var dimensions = mesh.dimensions(); - this.xSize = (int) dimensions.getXLength() + 1; - this.ySize = (int) dimensions.getYLength() + 1; - this.zSize = (int) dimensions.getZLength() + 1; + this.xSize = (int) dimensions.getLengthX() + 1; + this.ySize = (int) dimensions.getLengthY() + 1; + this.zSize = (int) dimensions.getLengthZ() + 1; } public static AreaRenderable of(BlockPos origin, BlockPos end) { diff --git a/src/main/java/com/glisco/isometricrenders/render/EntityRenderable.java b/src/main/java/com/glisco/isometricrenders/render/EntityRenderable.java index 7629574..c4c4d8f 100644 --- a/src/main/java/com/glisco/isometricrenders/render/EntityRenderable.java +++ b/src/main/java/com/glisco/isometricrenders/render/EntityRenderable.java @@ -17,10 +17,12 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.Registries; import net.minecraft.util.math.RotationAxis; -import org.apache.commons.lang3.mutable.MutableFloat; +import net.minecraft.util.math.Vec3d; +import org.apache.commons.lang3.mutable.MutableObject; import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; +import java.util.function.Function; public class EntityRenderable extends DefaultRenderable implements TickingRenderable { @@ -34,8 +36,13 @@ public EntityRenderable(Entity entity) { public static EntityRenderable of(EntityType type, @Nullable NbtCompound nbt) { final var client = MinecraftClient.getInstance(); - final var entity = type.create(client.world); - if (nbt != null) entity.readNbt(nbt); + if (nbt == null) { + nbt = new NbtCompound(); + } + + nbt.putString("id", type.getRegistryEntry().registryKey().getValue().toString()); + + final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, Function.identity()); entity.updatePosition(client.player.getX(), client.player.getY(), client.player.getZ()); return new EntityRenderable(entity); @@ -44,9 +51,12 @@ public static EntityRenderable of(EntityType type, @Nullable NbtCompound nbt) public static EntityRenderable copyOf(Entity source) { final var client = MinecraftClient.getInstance(); - final var entity = source.getType().create(client.world); - entity.copyFrom(source); - entity.tick(); + var nbt = new NbtCompound(); + source.writeNbt(nbt); + nbt.putString("id", source.getType().getRegistryEntry().registryKey().getValue().toString()); + + final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, Function.identity()); + applyToEntityAndPassengers(entity, Entity::tick); return new EntityRenderable(entity); } @@ -71,13 +81,16 @@ public void emitVertices(MatrixStack matrices, VertexConsumerProvider vertexCons this.entity.setPitch(properties.pitch.get()); this.entity.prevPitch = properties.pitch.get(); - final MutableFloat y = new MutableFloat(); + final MutableObject offset = new MutableObject<>(Vec3d.ZERO); applyToEntityAndPassengers(this.entity, entity -> { entity.setPos(client.player.getX(), client.player.getY(), client.player.getZ()); - y.add(entity.hasVehicle() ? entity.getVehicle().getMountedHeightOffset() + entity.getHeightOffset() : 0); + if (entity.hasVehicle()) { + offset.setValue(offset.getValue().add(entity.getVehicle().getPassengerRidingPos(entity).subtract(entity.getPos()))); + } - client.getEntityRenderDispatcher().render(entity, 0, y.floatValue(), 0, 0, tickDelta, matrices, vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE); + var offsetPos = offset.getValue(); + client.getEntityRenderDispatcher().render(entity, offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), 0, tickDelta, matrices, vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE); }); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-180)); diff --git a/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java b/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java index a77eea4..ec17ed3 100644 --- a/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java +++ b/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java @@ -177,7 +177,7 @@ protected void build(FlowLayout rootComponent) { var colorField = IsometricUI.labelledTextField(rightColumn, "#000000", "background_color", Sizing.fixed(50)); colorField.setTextPredicate(s -> s.matches("^#([A-Fa-f\\d]{0,6})$")); colorField.setText("#" + String.format("%02X", backgroundColor >> 16) + String.format("%02X", backgroundColor >> 8 & 0xFF) + String.format("%02X", backgroundColor & 0xFF)); - colorField.setCursorToStart(); + colorField.setCursorToStart(false); colorField.setChangedListener(s -> { if (s.substring(1).length() < 6) return; backgroundColor = Integer.parseInt(s.substring(1), 16); @@ -319,7 +319,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { if (this.drawOnlyBackground) { context.fill(0, 0, this.width, this.height, GlobalProperties.backgroundColor | 255 << 24); } else { - renderBackground(context); + this.renderBackground(context, mouseX, mouseY, delta); } final var window = client.getWindow(); @@ -497,15 +497,15 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - if (!(this.renderable.properties() instanceof DefaultPropertyBundle properties)) return super.mouseScrolled(mouseX, mouseY, amount); + public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) { + if (!(this.renderable.properties() instanceof DefaultPropertyBundle properties)) return super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount); if (this.isInViewport(mouseX)) { - properties.scale.modify((int) (amount * Math.max(1, properties.scale.get() * 0.075))); + properties.scale.modify((int) (verticalAmount * Math.max(1, properties.scale.get() * 0.075))); return true; } - return super.mouseScrolled(mouseX, mouseY, amount); + return super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount); } @Override diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a87154b..4289867 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -8,8 +8,8 @@ "glisco" ], "contact": { - "issues": "https://github.com/glisco03/isometric-renders/issues", - "sources": "https://github.com/glisco03/isometric-renders" + "issues": "https://github.com/gliscowo/isometric-renders/issues", + "sources": "https://github.com/gliscowo/isometric-renders" }, "license": "MIT", "icon": "assets/isometric-renders/icon.png", @@ -32,9 +32,9 @@ "depends": { "fabricloader": ">=0.11.3", "fabric": ">=0.85.0", - "worldmesher": ">=0.3.0", - "minecraft": ">=1.19", - "owo": ">=0.9.0" + "worldmesher": ">=0.4.2", + "minecraft": ">=1.20.2", + "owo": ">=0.11.3" }, "custom": { "modmenu": {