Skip to content

Commit

Permalink
Ok it builds now, but needs manual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Sep 27, 2024
1 parent 6d4802c commit b03bf63
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.valkyrienskies.mod.mixin.mod_compat.bluemap;

import de.bluecolored.bluemap.core.map.hires.HiresTileModel;
import de.bluecolored.bluemap.core.map.hires.TileModel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(HiresTileModel.class)
@Mixin(TileModel.class)
@Pseudo
public interface HiresTileModelAccessor {

@Accessor("position")
double[] getPositions();
float[] getPositions();

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import de.bluecolored.bluemap.core.map.TileMetaConsumer;
import de.bluecolored.bluemap.core.map.hires.HiresModelManager;
import de.bluecolored.bluemap.core.map.hires.HiresModelRenderer;
import de.bluecolored.bluemap.core.map.hires.HiresTileModel;
import de.bluecolored.bluemap.core.map.hires.TileModel;
import de.bluecolored.bluemap.core.world.World;
import org.joml.Matrix4dc;
import org.joml.Vector3d;
Expand All @@ -26,11 +26,11 @@ public class MixinHiresModelManager {
@Redirect(
remap = false,
method = "render",
at = @At(value = "INVOKE", target = "Lde/bluecolored/bluemap/core/map/hires/HiresModelRenderer;render(Lde/bluecolored/bluemap/core/world/World;Lcom/flowpowered/math/vector/Vector3i;Lcom/flowpowered/math/vector/Vector3i;Lde/bluecolored/bluemap/core/map/hires/HiresTileModel;Lde/bluecolored/bluemap/core/map/TileMetaConsumer;)V")
at = @At(value = "INVOKE", target = "Lde/bluecolored/bluemap/core/map/hires/HiresModelRenderer;render(Lde/bluecolored/bluemap/core/world/World;Lcom/flowpowered/math/vector/Vector3i;Lcom/flowpowered/math/vector/Vector3i;Lde/bluecolored/bluemap/core/map/hires/TileModel;Lde/bluecolored/bluemap/core/map/TileMetaConsumer;)V")
)
void renderModel(final HiresModelRenderer instance, final World world,
final Vector3i min, final Vector3i max,
final HiresTileModel model, final TileMetaConsumer tmc
final TileModel model, final TileMetaConsumer tmc
) {
final var aabb = new AABBd(
min.getX(), min.getY(), min.getZ(),
Expand Down Expand Up @@ -82,18 +82,23 @@ void renderModel(final HiresModelRenderer instance, final World world,
}

@Unique
private void valkyrienskies$transformModel(final int start, final int end, final HiresTileModel model, final Vector3dc preTranslation, final Vector3dc postTranslation, final Matrix4dc transform) {
private void valkyrienskies$transformModel(final int start, final int end, final TileModel model, final Vector3dc preTranslation, final Vector3dc postTranslation, final Matrix4dc transform) {
final var positions = ((HiresTileModelAccessor) model).getPositions();

for(int face = start; face < end; ++face) {
for(int i = 0; i < 3; ++i) {
final int index = face * 9 + i * 3;
final double x = positions[index] + preTranslation.x();
final double y = positions[index + 1] + preTranslation.y();
final double z = positions[index + 2] + preTranslation.z();
positions[index] = (x * transform.m00()) + (y * transform.m10()) + (z * transform.m20()) + transform.m30() + postTranslation.x();
positions[index + 1] = (x * transform.m01()) + (y * transform.m11()) + (z * transform.m21()) + transform.m31() + postTranslation.y();
positions[index + 2] = (x * transform.m02()) + (y * transform.m12()) + (z * transform.m22()) + transform.m32() + postTranslation.z();
final double x = ((double) positions[index]) + preTranslation.x();
final double y = ((double) positions[index + 1]) + preTranslation.y();
final double z = ((double) positions[index + 2]) + preTranslation.z();

final double newX = (x * transform.m00()) + (y * transform.m10()) + (z * transform.m20()) + transform.m30() + postTranslation.x();
final double newY = (x * transform.m01()) + (y * transform.m11()) + (z * transform.m21()) + transform.m31() + postTranslation.y();
final double newZ = (x * transform.m02()) + (y * transform.m12()) + (z * transform.m22()) + transform.m32() + postTranslation.z();

positions[index] = (float) newX;
positions[index + 1] = (float) newY;
positions[index + 2] = (float) newZ;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.valkyrienskies.mod.mixin.mod_compat.bluemap;

import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
import java.nio.file.Path;
import java.util.Objects;
import net.minecraft.world.level.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public StructureTransform getStructureTransform() {
@Nullable
@Override
public ShipMountedToData provideShipMountedToData(@NotNull final Entity passenger, @Nullable final Float partialTicks) {
final LoadedShip shipObjectEntityMountedTo = VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position()));
final LoadedShip shipObjectEntityMountedTo = VSGameUtilsKt.getShipObjectManagingPos(passenger.level(), toJOML(this.position()));
if (shipObjectEntityMountedTo == null) return null;

final Vector3dc mountedPosInShip = toJOML(this.getPassengerPosition(passenger, partialTicks == null ? 1 : partialTicks));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void vsProcesssRiderPositionHook(

@Inject(method="getPassengerPosition", at = @At("RETURN"), cancellable = true, remap = false)
protected void vsGetPassengerPosition(Entity passenger, float partialTicks, CallbackInfoReturnable<Vec3> cir) {
if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())) != null) {
if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level(), toJOML(this.position())) != null) {
cir.setReturnValue(cir.getReturnValue().add(0,0.1,0));
}
}
Expand Down
2 changes: 1 addition & 1 deletion fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ no_indium_version=1.1.0+1.20
sodium_version = mc1.20.1-0.5.8

# https://modrinth.com/mod/cc-tweaked/version/Zoo9N9Dv
cc_tweaked_version = 1.113.1
cc_tweaked_version = 1.113.1-fabric

kotlin_fabric_version = 1.10.10+kotlin.1.9.10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) {
ms.translate(worldVec.x - valkyrienskies$cameraVec3.x,
worldVec.y - valkyrienskies$cameraVec3.y,
worldVec.z - valkyrienskies$cameraVec3.z);
ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation));
ms.mulPose(VectorConversionsMCKt.toFloat(rotation));
ms.translate(-.5, -.125f, -.5);
}
}
Expand All @@ -96,7 +96,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) {
if (level != null) {
final Ship ship;
if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) {
return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld()
return BlockPos.containing(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld()
.transformPosition(VectorConversionsMCKt.toJOMLD(blockPos))));
}
}
Expand Down
2 changes: 1 addition & 1 deletion forge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cloth_config_version = 11.1.106
create_version = 0.5.1.e-22
flywheel_version = 0.6.10-7
registrate_version = MC1.20-1.3.3
cc_tweaked_version = 1.109.0
cc_tweaked_version = 1.109.0-forge
#Extra
# https://modrinth.com/mod/tis3d/version/MC1.19.2-forge-1.7.4
tis3d_version = MC1.20.1-forge-1.7.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) {
ms.translate(worldVec.x - valkyrienskies$cameraVec3.x,
worldVec.y - valkyrienskies$cameraVec3.y,
worldVec.z - valkyrienskies$cameraVec3.z);
ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation));
ms.mulPose(VectorConversionsMCKt.toFloat(rotation));
ms.translate(-.5, -.125f, -.5);
}
}
Expand All @@ -91,7 +91,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) {
if (level != null) {
final Ship ship;
if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) {
return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld()
return BlockPos.containing(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld()
.transformPosition(VectorConversionsMCKt.toJOMLD(blockPos))));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private Coord4D MixinDumpRadiation(final Coord4D coord4D) {
if (ship == null){
return coord4D;
}else{
return new Coord4D(new BlockPos(
return new Coord4D(BlockPos.containing(
VectorConversionsMCKt.toMinecraft(VSGameUtilsKt.toWorldCoordinates(ship, coord4D.getPos()))), coord4D.dimension);
}
}
Expand Down

0 comments on commit b03bf63

Please sign in to comment.