Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Oct 4, 2023
1 parent d72cfb1 commit 2718260
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 32 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultPropertyBundle> implements TickingRenderable<DefaultPropertyBundle> {

Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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<Vec3d> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down

0 comments on commit 2718260

Please sign in to comment.