diff --git a/.circleci/config.yml b/.circleci/config.yml index c3cb2f2b2..848945f2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -118,7 +118,7 @@ jobs: - discord/status: success_message: ${DISCORD_MSG} success_only: true - webhook: ${VS2_1192_WEBHOOK} + webhook: ${VS2_1194_WEBHOOK} # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 6b541cd89..36b251c71 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -17,7 +17,8 @@ body: options: - 1.16 - 1.18 - - 1.19 + - 1.19.2 + - 1.19.4 - 1.20.x validations: required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbb07ea83..126148a04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: branches: - '1.18.x/*' - '1.19.2/*' + - '1.19.4/*' pull_request: types: [ opened, synchronize, reopened ] jobs: diff --git a/common/build.gradle b/common/build.gradle index 9a179885f..35429cb47 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -31,14 +31,14 @@ dependencies { //Common create compat, //We just use a version from a platform and hope the classes exist on both versions and mixins apply correctly - modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") - { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } + //modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") + // { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } modCompileOnly("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") - modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") + //modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") //implementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") - modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") + //modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") // modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") //Bluemap fabric 1.19 diff --git a/common/gradle.properties b/common/gradle.properties index 6d2b61dc9..cf59f5e32 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -3,7 +3,7 @@ port_lib_version=2.1.1096 port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer # https://modrinth.com/mod/cloth-config/version/8.3.103+fabric -cloth_config_version = 8.3.103 +cloth_config_version = 10.1.135 # https://modrinth.com/mod/sodium/versions -sodium_version = mc1.19.2-0.4.4 +sodium_version = mc1.19.4-0.4.10 diff --git a/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java b/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java deleted file mode 100644 index 8e5076018..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.valkyrienskies.mod.compat; - -import com.jozufozu.flywheel.backend.instancing.InstanceWorld; -import java.util.Collections; -import java.util.Set; -import java.util.WeakHashMap; -import org.valkyrienskies.core.impl.hooks.VSEvents.ShipUnloadEventClient; -import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; - -public class FlywheelEvents { - static { - registerEvents(); - } - - private static final Set weakLoadedInstanceWorlds = - Collections.newSetFromMap( - new WeakHashMap<>() - ); - - private static synchronized void registerEvents() { - ShipUnloadEventClient.Companion.on(event -> { - for (final InstanceWorld instanceWorld : weakLoadedInstanceWorlds) { - ((MixinBlockEntityInstanceManagerDuck) instanceWorld.getBlockEntityInstanceManager()).vs$removeShipManager(event.getShip()); - } - }); - } - - public static void onInstanceWorldLoad(final InstanceWorld instanceWorld) { - weakLoadedInstanceWorlds.add(instanceWorld); - } - - public static void onInstanceWorldUnload(final InstanceWorld instanceWorld) { - weakLoadedInstanceWorlds.remove(instanceWorld); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java index ba5ad1b0a..3bc09f14e 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -7,7 +7,6 @@ import org.spongepowered.asm.mixin.Mixins; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; -import org.spongepowered.asm.service.MixinService; import org.valkyrienskies.mod.compat.VSRenderer; /** @@ -73,15 +72,6 @@ public boolean shouldApplyMixin(final String s, final String mixinClassName) { if (mixinClassName.contains("org.valkyrienskies.mod.mixin.feature.render_pathfinding")) { return PATH_FINDING_DEBUG; } - if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines")) { - //interactive has its own track outline stuff so disable fixed version of VS2's track outline stuff - if (classExists("org.valkyrienskies.create_interactive.mixin.client.MixinTrackBlockOutline")) { - MixinService.getService().getLogger("mixin") - .info("[VS2] found Interactive, disabling VS2's trackOutline Compat - " + - mixinClassName.substring(mixinClassName.lastIndexOf(".") + 1)); - return false; - } - } return true; } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java index a5fa9a31d..52d011744 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java @@ -10,9 +10,7 @@ public class ValkyrienMixinErrorHandler implements IMixinErrorHandler { private final Set warnList = new HashSet<>(Arrays.asList( - "org.valkyrienskies.mod.mixin.feature.water_in_ships_entity.MixinEntity", - "org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons.MixinAbstractCannonProjectile", - "org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity" + "org.valkyrienskies.mod.mixin.feature.water_in_ships_entity.MixinEntity" )); @Override diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/resource/ResourceKeyAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/resource/ResourceKeyAccessor.java index 8f72f4988..462518ebc 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/resource/ResourceKeyAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/resource/ResourceKeyAccessor.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixin.accessors.resource; -import java.util.Map; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; @@ -10,11 +9,6 @@ @Mixin(ResourceKey.class) public interface ResourceKeyAccessor { - @Accessor("VALUES") - static Map> getValues() { - throw new AssertionError(); - } - @Accessor ResourceLocation getRegistryName(); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/util/math/Matrix4fAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/util/math/Matrix4fAccessor.java deleted file mode 100644 index 27c9ce982..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/util/math/Matrix4fAccessor.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.valkyrienskies.mod.mixin.accessors.util.math; - -import com.mojang.math.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(Matrix4f.class) -public interface Matrix4fAccessor { - // region Setters - @Accessor("m00") - void setM00(float a00); - - @Accessor("m01") - void setM01(float a01); - - @Accessor("m02") - void setM02(float a02); - - @Accessor("m03") - void setM03(float a03); - - @Accessor("m10") - void setM10(float a10); - - @Accessor("m11") - void setM11(float a11); - - @Accessor("m12") - void setM12(float a12); - - @Accessor("m13") - void setM13(float a13); - - @Accessor("m20") - void setM20(float a20); - - @Accessor("m21") - void setM21(float a21); - - @Accessor("m22") - void setM22(float a22); - - @Accessor("m23") - void setM23(float a23); - - @Accessor("m30") - void setM30(float a30); - - @Accessor("m31") - void setM31(float a31); - - @Accessor("m32") - void setM32(float a32); - - @Accessor("m33") - void setM33(float a33); - - // endregion - // region Getters - @Accessor("m00") - float getM00(); - - @Accessor("m01") - float getM01(); - - @Accessor("m02") - float getM02(); - - @Accessor("m03") - float getM03(); - - @Accessor("m10") - float getM10(); - - @Accessor("m11") - float getM11(); - - @Accessor("m12") - float getM12(); - - @Accessor("m13") - float getM13(); - - @Accessor("m20") - float getM20(); - - @Accessor("m21") - float getM21(); - - @Accessor("m22") - float getM22(); - - @Accessor("m23") - float getM23(); - - @Accessor("m30") - float getM30(); - - @Accessor("m31") - float getM31(); - - @Accessor("m32") - float getM32(); - - @Accessor("m33") - float getM33(); - // endregion -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinCamera.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinCamera.java index d8ccabe22..6142e3de8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinCamera.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinCamera.java @@ -1,7 +1,5 @@ package org.valkyrienskies.mod.mixin.client; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; import net.minecraft.client.Camera; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; @@ -16,8 +14,10 @@ import org.jetbrains.annotations.NotNull; import org.joml.Quaterniond; import org.joml.Quaterniondc; +import org.joml.Quaternionf; import org.joml.Vector3d; import org.joml.Vector3dc; +import org.joml.Vector3f; import org.joml.primitives.AABBi; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -26,7 +26,6 @@ import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.core.api.ships.properties.ShipTransform; import org.valkyrienskies.mod.client.IVSCamera; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.RaycastUtilsKt; @Mixin(Camera.class) @@ -53,7 +52,7 @@ public abstract class MixinCamera implements IVSCamera { private float yRot; @Shadow @Final - private Quaternion rotation; + private Quaternionf rotation; @Shadow private boolean detached; @Shadow @@ -119,13 +118,13 @@ private void setRotationWithShipTransform(final float yaw, final float pitch, fi renderTransform.getShipCoordinatesToWorldCoordinatesRotation().mul(originalRotation, new Quaterniond()); this.xRot = pitch; this.yRot = yaw; - VectorConversionsMCKt.set(this.rotation, newRotation); + this.rotation.set(newRotation); this.forwards.set(0.0F, 0.0F, 1.0F); - this.forwards.transform(this.rotation); + this.rotation.transform(this.forwards); this.up.set(0.0F, 1.0F, 0.0F); - this.up.transform(this.rotation); + this.rotation.transform(this.up); this.left.set(1.0F, 0.0F, 0.0F); - this.left.transform(this.rotation); + this.rotation.transform(this.left); } /** diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java deleted file mode 100644 index c87b5dde2..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.mixin.client; - -import net.minecraft.client.Game; -import net.minecraft.client.Minecraft; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.mod.common.IShipObjectWorldClientCreator; - -@Mixin(Game.class) -public class MixinGame { - @Shadow - @Final - private Minecraft minecraft; - - /** - * @reason Destroy the [ShipObjectClientWorld] when we leave a game session. - */ - @Inject(method = "onLeaveGameSession", at = @At("HEAD")) - private void preOnLeaveGameSession(final CallbackInfo ci) { - ((IShipObjectWorldClientCreator) minecraft).deleteShipObjectWorldClient(); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinGameRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinGameRenderer.java index 43f480fa0..bac73ee76 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinGameRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinGameRenderer.java @@ -4,9 +4,6 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -16,7 +13,10 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import org.joml.Quaterniond; +import org.joml.Quaternionf; import org.joml.Vector3d; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Final; @@ -25,17 +25,15 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.core.apigame.world.ClientShipWorldCore; import org.valkyrienskies.mod.client.IVSCamera; import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider; -import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.util.EntityDraggingInformation; import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.RaycastUtilsKt; import org.valkyrienskies.mod.mixinducks.client.MinecraftDuck; @@ -94,23 +92,17 @@ public HitResult modifyCrosshairTargetBlocks(final Entity receiver, final double return pick.call(receiver, maxDistance, tickDelta, includeFluids); } - @Redirect( + @WrapOperation( method = "pick", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" ) ) - public double correctDistanceChecks(final Vec3 instance, final Vec3 vec) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips( - this.minecraft.level, - vec.x, - vec.y, - vec.z, - instance.x, - instance.y, - instance.z - ); + public double correctDistanceChecks(final Vec3 instance, final Vec3 vec, final Operation distanceToSqr) { + return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.minecraft.level, + vec.x, vec.y, vec.z, + instance.x, instance.y, instance.z); } @Inject(method = "render", at = @At("HEAD")) @@ -235,7 +227,7 @@ private void postRender(final float tickDelta, final long startTime, final boole method = "renderLevel", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/renderer/LevelRenderer;prepareCullFrustum(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/phys/Vec3;Lcom/mojang/math/Matrix4f;)V" + target = "Lnet/minecraft/client/renderer/LevelRenderer;prepareCullFrustum(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/phys/Vec3;Lorg/joml/Matrix4f;)V" ) ) private void setupCameraWithMountedShip(final LevelRenderer instance, final PoseStack ignore, final Vec3 vec3, @@ -282,17 +274,14 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose ); // Apply the ship render transform to [matrixStack] - final Quaternion invShipRenderRotation = VectorConversionsMCKt.toMinecraft( - clientShip.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond()) - ); - matrixStack.mulPose(invShipRenderRotation); + final Quaterniond invShipRenderRotation = clientShip.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond()); + matrixStack.mulPose(new Quaternionf().set(invShipRenderRotation)); // We also need to recompute [inverseViewRotationMatrix] after updating [matrixStack] { - final Matrix3f matrix3f = matrixStack.last().normal().copy(); - if (matrix3f.invert()) { - RenderSystem.setInverseViewRotationMatrix(matrix3f); - } + final Matrix3f matrix3f = new Matrix3f(matrixStack.last().normal()); + matrix3f.invert(); + RenderSystem.setInverseViewRotationMatrix(matrix3f); } // Camera FOV changes based on the position of the camera, so recompute FOV to account for the change of camera diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java index 7b5178cfc..c8359a9f8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java @@ -71,8 +71,8 @@ private void afterCheckInside(final CallbackInfo ci) { @Unique private void originalCheckInside(final AABBd aABB) { final Entity self = Entity.class.cast(this); - final BlockPos blockPos = new BlockPos(aABB.minX + 0.001, aABB.minY + 0.001, aABB.minZ + 0.001); - final BlockPos blockPos2 = new BlockPos(aABB.maxX - 0.001, aABB.maxY - 0.001, aABB.maxZ - 0.001); + final BlockPos blockPos = BlockPos.containing(aABB.minX + 0.001, aABB.minY + 0.001, aABB.minZ + 0.001); + final BlockPos blockPos2 = BlockPos.containing(aABB.maxX - 0.001, aABB.maxY - 0.001, aABB.maxZ - 0.001); final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); if (this.level.hasChunksAt(blockPos, blockPos2)) { for (int i = blockPos.getX(); i <= blockPos2.getX(); ++i) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/SwimNodeEvaluatorMixin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/SwimNodeEvaluatorMixin.java index aefad24fa..a30fcbb8e 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/SwimNodeEvaluatorMixin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/SwimNodeEvaluatorMixin.java @@ -44,7 +44,7 @@ private FluidState getFluidStateRedirectPathType(final BlockGetter instance, fin VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos groundPos = new BlockPos(x, y, z); + final BlockPos groundPos = BlockPos.containing(x, y, z); final FluidState tempFluidState = getFluidState.call(finalLevel, groundPos); if (!tempFluidState.isEmpty()) { // Skip any empty results for the case of intersecting ships fluidState[0] = tempFluidState; @@ -72,7 +72,7 @@ private BlockState getBlockStateRedirectPathType(final BlockGetter instance, fin VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos groundPos = new BlockPos(x, y, z); + final BlockPos groundPos = BlockPos.containing(x, y, z); final BlockState tempBlockState = getBlockState.call(level, groundPos); if (!tempBlockState.isAir()) { // Skip any empty results for the case of intersecting ships blockState[0] = tempBlockState; @@ -106,7 +106,7 @@ private boolean isPathFindableRedirectPathType(final BlockState instance, final VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos groundPos = new BlockPos(x, y, z); + final BlockPos groundPos = BlockPos.containing(x, y, z); final boolean pathfindable = isPathfindable.call(instance, finalLevel, groundPos, pathComputationType); if (pathfindable) { // Try to give a true result, not 100% accurate but method expects a single result @@ -136,7 +136,7 @@ private FluidState getFluidStateRedirectGetNode(final PathNavigationRegion insta VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos groundPos = new BlockPos(x, y, z); + final BlockPos groundPos = BlockPos.containing(x, y, z); final FluidState tempFluidState = getFluidState.call(instance, groundPos); if (!tempFluidState.isEmpty()) { // Skip any empty results for the case of intersecting ships fluidState[0] = tempFluidState; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/WalkNodeEvaluatorMixin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/WalkNodeEvaluatorMixin.java index 6d28810b5..7458292cb 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/WalkNodeEvaluatorMixin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ai/node_evaluator/WalkNodeEvaluatorMixin.java @@ -45,7 +45,7 @@ private static void getBlockPathTypeForShips(final BlockGetter blockGetter, fina VSGameUtilsKt.transformToNearbyShipsAndWorld(((PathNavigationRegionAccessor) blockGetter).getLevel(), origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos groundPos = new BlockPos(x, y, z); + final BlockPos groundPos = BlockPos.containing(x, y, z); BlockPathTypes pathType = getBlockPathTypeRaw(((PathNavigationRegionAccessor) blockGetter).getLevel(), groundPos); //Check block path types all around target for walkable space. Not accurate, but helps with pathfinding on ships. diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java index 7142276d8..a796effba 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java @@ -35,7 +35,7 @@ private BlockPos fixBlockPos(final BlockPos old) { ) ); - return new BlockPos( + return BlockPos.containing( newPos.x, newPos.y, newPos.z diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/clip_replace/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/clip_replace/MixinLevel.java index c7960e665..a03c66190 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/clip_replace/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/clip_replace/MixinLevel.java @@ -27,7 +27,7 @@ public BlockHitResult clip(final ClipContext clipContext) { final Vec3 vec3 = clipContext.getFrom().subtract(clipContext.getTo()); return BlockHitResult.miss( clipContext.getTo(), Direction.getNearest(vec3.x, vec3.y, vec3.z), - new BlockPos(clipContext.getTo()) + BlockPos.containing(clipContext.getTo()) ); } else { return RaycastUtilsKt.clipIncludeShips(Level.class.cast(this), clipContext); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinEntity.java index f6bbf72f1..2ba9ad6ee 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinEntity.java @@ -136,7 +136,7 @@ private BlockPos getPosStandingOnFromShips(final Vector3dc blockPosInGlobal) { for (final Ship ship : intersectingShips) { final Vector3dc blockPosInLocal = ship.getTransform().getWorldToShip().transformPosition(blockPosInGlobal, new Vector3d()); - final BlockPos blockPos = new BlockPos( + final BlockPos blockPos = BlockPos.containing( Math.floor(blockPosInLocal.x()), Math.floor(blockPosInLocal.y()), Math.floor(blockPosInLocal.z()) ); final BlockState blockState = level.getBlockState(blockPos); @@ -147,7 +147,7 @@ private BlockPos getPosStandingOnFromShips(final Vector3dc blockPosInGlobal) { final Vector3dc blockPosInLocal2 = ship.getTransform().getWorldToShip() .transformPosition( new Vector3d(blockPosInGlobal.x(), blockPosInGlobal.y() - 1.0, blockPosInGlobal.z())); - final BlockPos blockPos2 = new BlockPos( + final BlockPos blockPos2 = BlockPos.containing( Math.round(blockPosInLocal2.x()), Math.round(blockPosInLocal2.y()), Math.round(blockPosInLocal2.z()) ); final BlockState blockState2 = level.getBlockState(blockPos2); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/explosions/MixinExplosion.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/explosions/MixinExplosion.java index f689fc9d6..ad96562bc 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/explosions/MixinExplosion.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/explosions/MixinExplosion.java @@ -62,7 +62,7 @@ public abstract class MixinExplosion { private void doExplodeForce() { // Custom forces final Vector3d originPos = new Vector3d(this.x, this.y, this.z); - final BlockPos explodePos = new BlockPos(originPos.x(), originPos.y(), originPos.z()); + final BlockPos explodePos = BlockPos.containing(originPos.x(), originPos.y(), originPos.z()); final int radius = (int) Math.ceil(this.radius); for (int x = radius; x >= -radius; x--) { for (int y = radius; y >= -radius; y--) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fire_between_ship_and_world/LavaFluidMixin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fire_between_ship_and_world/LavaFluidMixin.java index 212503680..7a52e2c8f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fire_between_ship_and_world/LavaFluidMixin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fire_between_ship_and_world/LavaFluidMixin.java @@ -32,7 +32,7 @@ public void fireTickMixin(final Level level, final BlockPos pos, final FluidStat final double origZ = pos.getZ(); VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 3, (x, y, z) -> { - randomTick(level, new BlockPos(x, y, z), state, random); + randomTick(level, BlockPos.containing(x, y, z), state, random); }); isModifyingFireTick = false; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_camera_fix/MixinCamera.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_camera_fix/MixinCamera.java index 0ea5299ba..56de71ba2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_camera_fix/MixinCamera.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_camera_fix/MixinCamera.java @@ -39,7 +39,7 @@ private FluidState getFluidInCamera(final BlockGetter instance, final BlockPos b VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - fluidState[0] = instance.getBlockState(new BlockPos(x, y, z)) + fluidState[0] = instance.getBlockState(BlockPos.containing(x, y, z)) .getFluidState(); if (!fluidState[0].isEmpty()) { isShipWater = true; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java index 12cb64517..01f0deaaa 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java @@ -56,7 +56,7 @@ private void onClimbableMixin(final CallbackInfoReturnable cir) { // Only run this if we haven't modified cir yet if (cir.getReturnValue() != Boolean.TRUE) { // Modify the block position, then check if we can climb ladders - thisAsAccessor.setBlockPosition(new BlockPos(Mth.floor(x), Mth.floor(y), Mth.floor(z))); + thisAsAccessor.setBlockPosition(BlockPos.containing(Mth.floor(x), Mth.floor(y), Mth.floor(z))); thisAsAccessor.setFeetBlockState(null); if (onClimbable()) { cir.setReturnValue(true); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntityRenderDispatcher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntityRenderDispatcher.java index 95a93dc7a..63c0a55bb 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntityRenderDispatcher.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntityRenderDispatcher.java @@ -59,7 +59,7 @@ void render( final Vector3dc scale = renderTransform.getShipToWorldScaling(); matrixStack.translate(transformed.x() + camX, transformed.y() + camY, transformed.z() + camZ); - matrixStack.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); + matrixStack.mulPose(VectorConversionsMCKt.toFloat(renderTransform.getShipToWorldRotation())); matrixStack.scale((float) scale.x(), (float) scale.y(), (float) scale.z()); matrixStack.translate(offset.x, offset.y, offset.z); } else { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySection.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySection.java index a710d1a05..59779a80b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySection.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySection.java @@ -27,7 +27,7 @@ public void setShip(final Ship ship) { } @ModifyVariable( - method = "getEntities(Lnet/minecraft/world/phys/AABB;Ljava/util/function/Consumer;)V", + method = "getEntities(Lnet/minecraft/world/phys/AABB;Ljava/util/function/;)V", at = @At("HEAD"), ordinal = 0, argsOnly = true) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/world_border/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/world_border/MixinLevel.java index eba9fbc57..4d663230b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/world_border/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/world_border/MixinLevel.java @@ -2,11 +2,10 @@ import java.util.function.Supplier; import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.Level; import net.minecraft.world.level.border.WorldBorder; -import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.storage.WritableLevelData; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -28,10 +27,8 @@ public class MixinLevel { method = "" ) private void setWorldBorderLevel( - final WritableLevelData writableLevelData, final ResourceKey resourceKey, - final Holder holder, - final Supplier supplier, final boolean bl, final boolean bl2, final long l, final int i, - final CallbackInfo ci) { + WritableLevelData writableLevelData, ResourceKey resourceKey, RegistryAccess registryAccess, Holder holder, + Supplier supplier, boolean bl, boolean bl2, long l, int i, CallbackInfo ci) { ((OfLevel) this.worldBorder).setLevel(Level.class.cast(this)); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java deleted file mode 100644 index 5cbe5475b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.kinetics.deployer.DeployerHandler; -import javax.annotation.Nullable; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(DeployerHandler.class) -public interface IMixinDeployerHandler { - @Invoker("shouldActivate") - static boolean invokeShouldActivate(ItemStack held, Level world, BlockPos targetPos, @Nullable Direction facing){ - throw new AssertionError(); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java deleted file mode 100644 index 821f697ea..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.kinetics.deployer.DeployerMovementBehaviour; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(DeployerMovementBehaviour.class) -public interface IMixinDeployerMovementBehaviour { - @Invoker("tryGrabbingItem") - void invokeTryGrabbingItem(MovementContext movementContext); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java deleted file mode 100644 index 70c1592e9..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.kinetics.fan.AirCurrent; -import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; -import com.simibubi.create.foundation.utility.VecHelper; -import java.util.Iterator; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.joml.primitives.AABBd; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.common.world.RaycastUtilsKt; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; - -@Mixin(AirCurrent.class) -public abstract class MixinAirCurrent { - - @Unique - private final float maxAcceleration = 5; - @Shadow - @Final - public IAirCurrentSource source; - @Unique - private Vec3 transformedFlow = Vec3.ZERO; - @Unique - private float acceleration; - - @Unique - private Ship getShip() { - if (source instanceof IExtendedAirCurrentSource se) - return se.getShip(); - else if (source.getAirCurrentWorld() != null) - return VSGameUtilsKt.getShipManagingPos(source.getAirCurrentWorld(), source.getAirCurrentPos()); - else - return null; - } - - @Inject(method = "getFlowLimit", at = @At("HEAD"), cancellable = true) - private static void clipFlowLimit(Level level, BlockPos start, float max, Direction facing, CallbackInfoReturnable cir) { - Ship ship = VSGameUtilsKt.getShipManagingPos(level, start); - if (ship != null) { - Vector3d startVec = ship.getTransform().getShipToWorld().transformPosition(new Vector3d(start.getX() + 0.5, start.getY() + 0.5, start.getZ() + 0.5)); - Vector3d direction = ship.getTransform().getShipToWorld().transformDirection(VectorConversionsMCKt.toJOMLD(facing.getNormal())); - startVec.add(direction.x, direction.y, direction.z); - direction.mul(max); - Vec3 mcStart = VectorConversionsMCKt.toMinecraft(startVec); - BlockHitResult result = RaycastUtilsKt.clipIncludeShips(level, - new ClipContext( - mcStart, - VectorConversionsMCKt.toMinecraft(startVec.add(direction.x, direction.y, direction.z)), - ClipContext.Block.OUTLINE, - ClipContext.Fluid.NONE, - null)); - - // Distance from start to end but, its not squared so, slow -_- - cir.setReturnValue((float) result.getLocation().distanceTo(mcStart)); - } else { - BlockPos end = start.relative(facing, (int) max); - if (VSGameUtilsKt.getShipsIntersecting(level, - new AABB(start.getX(), start.getY(), start.getZ(), - end.getX() + 1.0, end.getY() + 1.0, end.getZ() + 1.0)).iterator().hasNext()) { - Vec3 centerStart = Vec3.atCenterOf(start); - BlockHitResult result = RaycastUtilsKt.clipIncludeShips(level, - new ClipContext( - centerStart.add(facing.getStepX(), facing.getStepY(), facing.getStepZ()), - Vec3.atCenterOf(end), - ClipContext.Block.OUTLINE, - ClipContext.Fluid.NONE, - null)); - - // Distance from start to end but, its not squared so, slow -_- - cir.setReturnValue((float) result.getLocation().distanceTo(centerStart)); - } - } - } - - // Require 0 because this mixin doesn't work in create 0.5.1f - @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z"), require = 0) - private boolean redirectIntersects(AABB instance, AABB other) { - Ship ship = getShip(); - if (ship != null) { - AABBd thisAABB = VectorConversionsMCKt.toJOML(instance); - thisAABB.transform(ship.getWorldToShip()); - return other.intersects(thisAABB.minX, thisAABB.minY, thisAABB.minZ, thisAABB.maxX, thisAABB.maxY, thisAABB.maxZ); - } else return instance.intersects(other); - } - - // Require 0 because this mixin doesn't work in create 0.5.1f - @Inject( - method = "tickAffectedEntities", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;" - ), - locals = LocalCapture.CAPTURE_FAILSOFT, - require = 0 - ) - private void harvester(Level world, Direction facing, CallbackInfo ci, Iterator iterator, Entity entity, Vec3 center, Vec3i flow, float sneakModifier, float speed, double entityDistance, float acceleration) { - Ship ship = getShip(); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformDirection(flow.getX(), flow.getY(), flow.getZ(), tempVec); - transformedFlow = VectorConversionsMCKt.toMinecraft(tempVec); - } - this.acceleration = acceleration; - } - - // Require 0 because this mixin doesn't work in create 0.5.1f - @Redirect(method = "tickAffectedEntities", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"), require = 0 - ) - private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { - Ship ship = getShip(); - if (ship != null) { - Vec3 previousMotion = instance.getDeltaMovement(); - double xIn = Mth.clamp(transformedFlow.x * acceleration - previousMotion.x, -maxAcceleration, maxAcceleration); - double yIn = Mth.clamp(transformedFlow.y * acceleration - previousMotion.y, -maxAcceleration, maxAcceleration); - double zIn = Mth.clamp(transformedFlow.z * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration); - instance.setDeltaMovement(previousMotion.add(new Vec3(xIn, yIn, zIn).scale(1 / 8f))); - } else { - instance.setDeltaMovement(motion); - } - } - - // Require 0 because this mixin doesn't work in create 0.5.1f - @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1, require = 0) - private Vec3 redirectGetCenterOf(Vec3i pos) { - Ship ship = getShip(); - Vec3 result = VecHelper.getCenterOf(pos); - if (ship != null && this.source.getAirCurrentWorld() != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java deleted file mode 100644 index 623e7196c..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.kinetics.fan.AirCurrent; -import com.simibubi.create.content.kinetics.fan.AirFlowParticle; -import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; -import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.particle.SimpleAnimatedParticle; -import net.minecraft.client.particle.SpriteSet; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; - -@Mixin(AirFlowParticle.class) -public abstract class MixinAirFlowParticle extends SimpleAnimatedParticle { - - @Shadow - @Final - private IAirCurrentSource source; - - protected MixinAirFlowParticle(ClientLevel level, double x, double y, double z, SpriteSet sprites, float gravity) { - super(level, x, y, z, sprites, gravity); - } - - @Unique - private Ship getShip() { - if (source instanceof IExtendedAirCurrentSource se) - return se.getShip(); - else if (source.getAirCurrentWorld() != null) - return VSGameUtilsKt.getShipManagingPos(source.getAirCurrentWorld(), source.getAirCurrentPos()); - else - return null; - } - - @Redirect(method = "tick", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/AABB;contains(DDD)Z" - )) - private boolean redirectBounds(AABB instance, double x, double y, double z) { - AirCurrent current = source.getAirCurrent(); - Level level = source.getAirCurrentWorld(); - if (current != null && level != null) { - return VSGameUtilsKt.transformAabbToWorld(level, instance).contains(x, y, z); - } - - return instance.contains(x, y, z); - } - - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) - private Vec3 redirectGetCenterOf(Vec3i pos) { - Ship ship = getShip(); - Vec3 result = VecHelper.getCenterOf(pos); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;atLowerCornerOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) - private Vec3 redirectToLowerCorner(Vec3i pos) { - Vec3 result = Vec3.atLowerCornerOf(pos); - Ship ship = getShip(); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java deleted file mode 100644 index 5ec2e0c3e..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.kinetics.belt.BeltBlockEntity; -import com.simibubi.create.content.kinetics.belt.transport.BeltMovementHandler; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.MoverType; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(BeltMovementHandler.class) -public abstract class MixinBeltMovementHandler { - - @Unique - private static Vector3d blockPos; - - @Unique - private static Level level; - - @Unique - private static Ship ship; - - @Unique - private static Direction.Axis axis; - - @Unique - private static Entity entity; - - @Inject(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Direction;fromAxisAndDirection(Lnet/minecraft/core/Direction$Axis;Lnet/minecraft/core/Direction$AxisDirection;)Lnet/minecraft/core/Direction;"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void injectHead(BeltBlockEntity beltTe, Entity entityIn, BeltMovementHandler.TransportedEntityInfo info, CallbackInfo ci, BlockPos pos) { - blockPos = VectorConversionsMCKt.toJOMLD(pos); - entity = entityIn; - level = beltTe.getLevel(); - if (level != null) { - ship = VSGameUtilsKt.getShipManagingPos(level, blockPos); - } - } - - @ModifyVariable(method = "transportEntity", at = @At(value = "STORE"), name = "axis") - private static Direction.Axis injectHarvestAxis(Direction.Axis value) { - axis = value; - return value; - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V", ordinal = 2)) - private static void redirectMove1(Entity instance, MoverType type, Vec3 pos) { - if (ship != null) { - instance.move(type, new Vec3(pos.x * 3, 0.2, pos.z * 3)); - } else - instance.move(type, pos); - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V", ordinal = 1)) - private static void redirectMove2(Entity instance, MoverType type, Vec3 pos) { - if (ship != null) { - instance.move(type, new Vec3(pos.x * 3, 0, pos.z * 3)); - } else - instance.move(type, pos); - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Direction$Axis;choose(DDD)D")) - private static double redirectChoose(Direction.Axis instance, double x, double y, double z) { - if (ship != null) { - Vec3 mul = new Vec3(0, 0, 0); - if (instance == Direction.Axis.X) { - mul = redirectGetNormal(new Vec3i(1, 0, 0)); - } - if (instance == Direction.Axis.Y) { - mul = redirectGetNormal(new Vec3i(0, 1, 0)); - } - if (instance == Direction.Axis.Z) { - mul = redirectGetNormal(new Vec3i(0, 0, 1)); - } - return Math.abs(x * mul.x) + Math.abs(y * mul.y) + Math.abs(z * mul.z); - } - return instance.choose(x, y, z); - } - - @ModifyVariable(method = "transportEntity", at = @At(value = "STORE"), name = "diffCenter") - private static double modDiffCenter(double value) { - //if (ship != null) value = value + Math.copySign(value) ); - return axis == Direction.Axis.Z ? (blockPos.x + .5 - getPos(entity).x) : (blockPos.z + .5 - getPos(entity).z); - } - - @Redirect( - method = "transportEntity", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;atLowerCornerOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - private static Vec3 redirectGetNormal(Vec3i toCopy) { - Vec3 result = Vec3.atLowerCornerOf(toCopy); - if (level != null) { - if (ship != null) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - Quaterniond tempQuat = new Quaterniond(); - ship.getTransform().getShipToWorld().getNormalizedRotation(tempQuat); - tempVec.rotate(tempQuat); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - } - return result; - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) - private static double redirectGetX(Entity instance) { - return getPos(instance).x; - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) - private static double redirectGetY(Entity instance) { - return getPos(instance).y; - } - - @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) - private static double redirectGetZ(Entity instance) { - return getPos(instance).z; - } - - @Unique - private static Vec3 getPos(Entity entity) { - Vec3 result = entity.position(); - if (level != null) { - if (ship != null) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - ship.getTransform().getWorldToShip().transformPosition(tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java deleted file mode 100644 index bd6125806..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.contraptions.Contraption; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Contraption.class) -public class MixinContraption { - @Redirect(method = "onEntityCreated", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) - private boolean wrapOp(Level level, Entity entity) { - // BlockPos anchor = blockFace.getConnectedPos(); - // movedContraption.setPos(anchor.getX() + .5f, anchor.getY(), anchor.getZ() + .5f); - // - // Derive anchor from the code above - final BlockPos anchor = new BlockPos((int) Math.floor(entity.getX()), (int) Math.floor(entity.getY()), (int) Math.floor(entity.getZ())); - boolean added = level.addFreshEntity(entity); - if (added) { - entity.moveTo(anchor.getX() + .5, anchor.getY(), anchor.getZ() + .5); - } - return added; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java deleted file mode 100644 index 2b8910713..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java +++ /dev/null @@ -1,342 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ContraptionCollider; -import com.simibubi.create.foundation.collision.Matrix3d; -import com.simibubi.create.foundation.utility.VecHelper; -import javax.annotation.Nullable; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.joml.Vector3d; -import org.joml.primitives.AABBd; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ContraptionCollider.class) -public abstract class MixinContraptionCollider { - @Shadow - static Vec3 collide(Vec3 p_20273_, Entity e) { - return p_20273_; - } - - @Unique - private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinContraptionCollider"); - - @Unique - private static AbstractContraptionEntity contraptionEnt; - - @Unique - private static AABB entityGetBoundingBox(AbstractContraptionEntity abstractContraptionEntity, Entity instance) { - AABB tempAabb = instance.getBoundingBox(); - if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(contraptionEnt.getCommandSenderWorld(), new BlockPos(contraptionEnt.getAnchorVec()))) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), contraptionEnt.getAnchorVec()); - if (ship != null) { - AABBd temp = new AABBd(); - temp.set(toJOML(tempAabb)).transform(ship.getWorldToShip()); - tempAabb = toMinecraft(temp); - } - } - return tempAabb; - } - - @Unique - private static Vec3 entityPosition(AbstractContraptionEntity abstractContraptionEntity, Entity instance, boolean old) { - Vec3 tempVec = old ? new Vec3(instance.xo, instance.yo, instance.zo) : instance.position(); - if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getAnchorVec()))) { - Ship ship = VSGameUtilsKt.getShipManagingPos(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); - if (ship != null) { - Vector3d translatedPos = ship.getTransform().getWorldToShip().transformPosition(toJOML(tempVec)); - tempVec = toMinecraft(translatedPos); - } - } - return tempVec; - } - - @Unique - private static Vec3 getSetEntityDeltaMovement(AbstractContraptionEntity abstractContraptionEntity, Entity instance, @Nullable Vec3 motion) { - Vec3 tempVec = instance.getDeltaMovement(); - if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getContraption().anchor))) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); - if (ship != null) { - if (motion != null) { - if (!VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getAnchorVec()))) { - motion = toMinecraft(ship.getWorldToShip().transformDirection(toJOML(motion))); - } else { - motion = toMinecraft(ship.getShipToWorld().transformDirection(toJOML(motion))); - } - instance.setDeltaMovement(motion); - motion = null; - } - tempVec = toMinecraft(ship.getWorldToShip().transformDirection(toJOML(tempVec))); - } - } - if (motion != null) { - instance.setDeltaMovement(motion); - } - return tempVec; - } - - @Inject(method = "collideEntities", at = @At("HEAD"), remap = false) - private static void injectHead(AbstractContraptionEntity contraptionEntity, CallbackInfo ci) { - contraptionEnt = contraptionEntity; - } - - private static void warn1(Vector3d vec3) { - LOGGER.warn("Warning setPosDistance too high ignoring setPos request [" + vec3.x + "," + vec3.y + "," + vec3.z + "]"); - } - - private static void warn2(double x, double y, double z) { - LOGGER.warn("Warning DEFAULT setPosDistance too high ignoring setPos request [" + x + "," + y + "," + z + "]"); - } - - private static void setOfPos(AbstractContraptionEntity abstractContraptionEntity, Entity instance, double x, double y, double z) { - if (VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(x, y, z)) && - !VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition())) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); - if (ship != null) { - Vector3d newPos = new Vector3d(x, y, z); - ship.getShipToWorld().transformPosition(newPos, newPos); - if (instance.position().distanceTo(toMinecraft(newPos)) < 20) { - instance.setPos(newPos.x, newPos.y, newPos.z); - } else - warn1(newPos); - } - } else { - - if (instance.position().distanceTo(new Vec3(x, y, z)) < 20) { - instance.setPos(x, y, z); - } else - warn2(x, y, z); - } - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V")) - private static void redirectSetPos(Entity instance, double x, double y, double z) { - setOfPos(contraptionEnt, instance, x, y, z); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB redirectContraptionGetBoundingBox(AbstractContraptionEntity instance) { - return VSGameUtilsKt.transformAabbToWorld(instance.getCommandSenderWorld(), instance.getBoundingBox()); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB redirectEntityGetBoundingBox(Entity instance) { - return entityGetBoundingBox(contraptionEnt, instance); - } - - /* - @Redirect(method="collideEntities",at = @At(value="INVOKE_ASSIGN",target = "Lnet/minecraft/world/phys/AABB;getCenter()Lnet/minecraft/world/phys/Vec3;",ordinal = 3)) - private static Vec3 redirectGetCenter(AABB instance){ - if(instance) - return instance.getCenter(); - }*/ - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityPosition(Entity instance) { - return entityPosition(contraptionEnt, instance, false); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityGetDeltaMovement(Entity instance) { - return getSetEntityDeltaMovement(contraptionEnt, instance, null); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) - private static void redirectEntitySetDeltaMovement(Entity instance, Vec3 motion) { - getSetEntityDeltaMovement(contraptionEnt, instance, motion); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) - private static double redirectEntityGetX(Entity instance) { - return entityPosition(contraptionEnt, instance, false).x; - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) - private static double redirectEntityGetY(Entity instance) { - return entityPosition(contraptionEnt, instance, false).y; - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) - private static double redirectEntityGetZ(Entity instance) { - return entityPosition(contraptionEnt, instance, false).z; - } - - - @Redirect(method = "collideEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;xo:D", opcode = Opcodes.GETFIELD)) - private static double redirectEntityGetXo(Entity instance) { - return entityPosition(contraptionEnt, instance, true).x; - } - - @Redirect(method = "collideEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;zo:D", opcode = Opcodes.GETFIELD)) - private static double redirectEntityGetZo(Entity instance) { - return entityPosition(contraptionEnt, instance, true).z; - } - - private static Vec3 aaaaaaaaaaaaaa(AbstractContraptionEntity abstractContraptionEntity, Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { - - if (VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor) - && !VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), entity.blockPosition())) { - - Ship ship = VSGameUtilsKt.getShipManagingPos(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); - if (ship != null) { - Vec3 entityPosition = entityPosition(abstractContraptionEntity, entity, false); - Vec3 centerY = new Vec3(0, entityGetBoundingBox(contraptionEnt, entity) - .getYsize() / 2, 0); - Vec3 position = entityPosition; - position = position.add(centerY); - position = position.subtract(VecHelper.CENTER_OF_ORIGIN); - position = position.subtract(anchorVec); - position = VecHelper.rotate(position, -yawOffset, Direction.Axis.Y); - position = rotationMatrix.transform(position); - position = position.add(VecHelper.CENTER_OF_ORIGIN); - position = position.subtract(centerY); - position = position.subtract(entityPosition); - - return position;//toMinecraft(ship.getShipToWorld().transformPosition(position.x, position.y, position.z, new Vector3d())); - } - } - return ContraptionCollider.getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset); - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getPrevPositionVec()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectGetPrevPositionVec(AbstractContraptionEntity instance) { - - Vec3 prevPos = instance.getPrevPositionVec(); - - if (VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(instance.getAnchorVec())) && !VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(instance.getPrevAnchorVec()))) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getAnchorVec()); - if (ship != null) { - Vec3 result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(instance.getPrevPositionVec()))); - instance.xo = result.x; - instance.yo = result.y; - instance.zo = result.z; - prevPos = result; - } - } - - - if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(prevPos)) && VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(instance.position()))) { - //instance.setOldPosAndRot(); - //prevPos = instance.position(); - /* - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), instance.position()); - if (ship != null) { - Vec3 transformedPrevPos = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(prevPos))); - prevPos = transformedPrevPos; - }*/ - } - return prevPos; - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/ContraptionCollider;getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectGetWorldToLocalTranslation(Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { - return aaaaaaaaaaaaaa(contraptionEnt, entity, anchorVec, rotationMatrix, yawOffset); - } - - @Unique - private static Vec3 adjustCollide(Vec3 contactPoint, Entity entity) { - Vec3 result = collide(contactPoint, entity); - - if (VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), contactPoint.x, contactPoint.y, contactPoint.z) - && !VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), entity.blockPosition())) { - Ship ship = VSGameUtilsKt.getShipManagingPos(entity.getCommandSenderWorld(), contactPoint); - if (ship != null) { - Vec3 temp = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(contactPoint))); - result = collide(temp, entity); - result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(result))); - } - } else if (!VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), contactPoint.x, contactPoint.y, contactPoint.z) - && VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), entity.blockPosition())) { - Ship ship = VSGameUtilsKt.getShipManagingPos(entity.getCommandSenderWorld(), entity.blockPosition()); - if (ship != null) { - Vec3 temp = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(contactPoint))); - result = collide(temp, entity); - result = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(result))); - } - } - - return result; - } - - @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/ContraptionCollider;collide(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityGetBoundingBoxCollide(Vec3 contactPoint, Entity entity) { - return adjustCollide(contactPoint, entity); - } - - //@Redirect(method = "getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB redirectEntityGetBoundingBox2(Entity instance) { - return entityGetBoundingBox(contraptionEnt, instance); - } - - //@Redirect(method = "getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityPosition2(Entity instance) { - return entityPosition(contraptionEnt, instance, false); - } - - @Inject(method = "worldToLocalPos(Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;)Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true) - private static void modPosition(Vec3 entity, AbstractContraptionEntity contraptionEntity, CallbackInfoReturnable cir) { - if (VSGameUtilsKt.isBlockInShipyard(contraptionEntity.getCommandSenderWorld(), new BlockPos(contraptionEntity.getContraption().anchor)) - && !VSGameUtilsKt.isBlockInShipyard(contraptionEntity.getCommandSenderWorld(), new BlockPos(entity))) { - - Ship ship = VSGameUtilsKt.getShipManagingPos(contraptionEntity.getCommandSenderWorld(), contraptionEntity.getContraption().anchor); - if (ship != null) { - cir.setReturnValue(ContraptionCollider.worldToLocalPos(entity, toMinecraft(ship.getShipToWorld().transformPosition(toJOML(contraptionEntity.getAnchorVec()))), contraptionEntity.getRotationState())); - } - } - } - - @Unique - private static AbstractContraptionEntity hDFTContraptionEntity; - - @ModifyVariable(method = "handleDamageFromTrain", at = @At("HEAD"), argsOnly = true) - private static AbstractContraptionEntity injectHandleDamageFromTrain(AbstractContraptionEntity abstractContraptionEntity) { - return hDFTContraptionEntity = abstractContraptionEntity; - } - - @Redirect(method = "handleDamageFromTrain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityGetDeltaMovementFromTrain(Entity instance) { - return getSetEntityDeltaMovement(hDFTContraptionEntity, instance, null); - } - - @Unique - private static AbstractContraptionEntity bounceEntityContraptionEntity; - - @ModifyVariable(method = "bounceEntity", at = @At("HEAD"), argsOnly = true) - private static AbstractContraptionEntity injectBounceEntity(AbstractContraptionEntity abstractContraptionEntity) { - return bounceEntityContraptionEntity = abstractContraptionEntity; - } - - @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityPositionBounceEntity(Entity instance) { - return entityPosition(bounceEntityContraptionEntity, instance, false); - } - - @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectEntityGetDeltaMovementBounceEntity(Entity instance) { - return getSetEntityDeltaMovement(bounceEntityContraptionEntity, instance, null); - } - - @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) - private static void redirectEntitySetDeltaMovementBounceEntity(Entity instance, Vec3 motion) { - getSetEntityDeltaMovement(bounceEntityContraptionEntity, instance, motion); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java deleted file mode 100644 index 8d311cd22..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.logistics.depot.EntityLauncher; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(EntityLauncher.class) -public abstract class MixinEntityLauncher { - - @Unique - private BlockPos launcher; - - @Inject(method = "getGlobalPos", at = @At("HEAD")) - private void harvestBlockPos(double t, Direction d, BlockPos launcher, CallbackInfoReturnable cir) { - this.launcher = launcher; - } - - @ModifyVariable(method = "getGlobalPos", at = @At("STORE"), name = "start") - private Vec3 modStart(Vec3 value) { - return new Vec3(launcher.getX() + .5, launcher.getY() + .5, launcher.getZ() + .5); - } - - @Redirect(method = "applyMotion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(DDD)V")) - private void redirectSetDeltaMovement(Entity instance, double x, double y, double z) { - instance.setDeltaMovement(outMotion(instance, new Vec3(x, y, z))); - } - - @Unique - private Vec3 outMotion(Entity entity, Vec3 motion) { - Ship ship = VSGameUtilsKt.getShipManagingPos(entity.level, entity.getOnPos()); - if (ship != null) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(motion); - ship.getTransform().getShipToWorld().transformDirection(tempVec); - motion = VectorConversionsMCKt.toMinecraft(tempVec); - } - return motion; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java deleted file mode 100644 index c1b6e3afb..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.redstone.link.IRedstoneLinkable; -import com.simibubi.create.content.redstone.link.RedstoneLinkNetworkHandler; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(RedstoneLinkNetworkHandler.class) -public abstract class MixinRedstoneLinkNetworkHandler { - - @Unique - private static Level harvestedWorld; - - @Redirect( - method = "withinRange", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" - ) - ) - private static boolean redirectCloserThan(BlockPos instance, Vec3i vec3i, double v) { - Ship ship1 = VSGameUtilsKt.getShipManagingPos(harvestedWorld, instance); - Ship ship2 = VSGameUtilsKt.getShipManagingPos(harvestedWorld, new BlockPos(vec3i)); - Vec3 pos1 = Vec3.atLowerCornerOf(instance); - Vec3 pos2 = Vec3.atLowerCornerOf(vec3i); - if (ship1 != null) { - pos1 = VectorConversionsMCKt.toMinecraft(ship1.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(pos1))); - } - if (ship2 != null) { - pos2 = VectorConversionsMCKt.toMinecraft(ship2.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(pos2))); - } - return pos1.closerThan(pos2, v); - } - - @Inject(method = "updateNetworkOf", at = @At("HEAD")) - private void harvestLevel(LevelAccessor world, IRedstoneLinkable actor, CallbackInfo ci) { - harvestedWorld = (Level) world; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java deleted file mode 100644 index 927e5241e..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create; - -import com.simibubi.create.content.logistics.depot.SharedDepotBlockMethods; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(SharedDepotBlockMethods.class) -public abstract class MixinSharedDepotBlockMethods { - @Redirect(method = "onLanded", at = @At( - value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - )) - private static BlockPos redirectBlockPosition(Entity instance) { - BlockPos result = instance.blockPosition(); - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level, instance.getOnPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(instance.position().x, instance.position().y, instance.position().z); - ship.getWorldToShip().transformPosition(tempVec, tempVec); - result = new BlockPos(Math.floor(tempVec.x), Math.floor(tempVec.y), Math.floor(tempVec.z)); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md deleted file mode 100644 index 2784f766a..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Create Compat - -This package contains the Create compatibility code - -## Attributions - -Most of this code was originally created by [FluffyJenkins](https://github.com/FluffyJenkins/). However, the git history -got clobbered when we transferred it over from the Clockwork repository, causing it to be attributed to StewStrong. diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/ChuteBlockEntityAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/ChuteBlockEntityAccessor.java deleted file mode 100644 index 917b5c175..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/ChuteBlockEntityAccessor.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.accessors; - -import com.simibubi.create.content.logistics.chute.ChuteBlockEntity; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(ChuteBlockEntity.class) -public interface ChuteBlockEntityAccessor { - @Accessor("bottomPullDistance") - float getBottomPullDistance(); - - @Invoker - boolean callCanAcceptItem(ItemStack item); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java deleted file mode 100644 index cb571c775..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.accessors; - -import com.simibubi.create.foundation.collision.Matrix3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(Matrix3d.class) -public interface Matrix3dAccessor { - @Accessor("m00") - double getM00(); - - @Accessor("m01") - double getM01(); - - @Accessor("m02") - double getM02(); - - @Accessor("m10") - double getM10(); - - @Accessor("m11") - double getM11(); - - @Accessor("m12") - double getM12(); - - @Accessor("m20") - double getM20(); - - @Accessor("m21") - double getM21(); - - @Accessor("m22") - double getM22(); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java deleted file mode 100644 index 6c4fd3a9b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.accessors; - -import com.simibubi.create.AllSpecialTextures; -import com.simibubi.create.foundation.outliner.Outline; -import java.util.Optional; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(Outline.OutlineParams.class) -public interface OutlineParamsAccessor { - @Accessor("alpha") - float getAlpha(); - - @Accessor("alpha") - void setAlpha(float alpha); - - @Accessor - boolean getDisableCull(); - - @Accessor - Optional getFaceTexture(); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java deleted file mode 100644 index 8d8897327..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; - -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(BlockBreakingMovementBehaviour.class) -public class MixinBlockBreakingMovementBehaviour { - //Region start - fix equals -0 != 0 - private Vec3 flatten(Vec3 vec3) { - if (vec3.x == -0) { - vec3 = new Vec3(0, vec3.y, vec3.z); - } - if (vec3.y == -0) { - vec3 = new Vec3(vec3.x, 0, vec3.z); - } - if (vec3.z == -0) { - vec3 = new Vec3(vec3.x, vec3.y, 0); - } - return vec3; - } - - @Redirect(method = "tickBreaker", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;equals(Ljava/lang/Object;)Z")) - private boolean redirectEquals(Vec3 instance, final Object vec3) { - Vec3 other = (Vec3) vec3; - other = flatten(other); - instance = flatten(instance); - return instance.equals(other); - } - //Region end - //Region start - fix entity throwing not being aligned to ship - @Unique - private MovementContext movementContext; - - @Inject(method = "throwEntity", at = @At("HEAD")) - private void injectThrowEntity(final MovementContext context, final Entity entity, final CallbackInfo ci) { - movementContext = context; - } - - @Redirect(method = "throwEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) - private void redirectSetDeltaMovement(final Entity instance, Vec3 motion) { - if (movementContext != null && VSGameUtilsKt.isBlockInShipyard(movementContext.world, movementContext.contraption.anchor)) { - Ship ship = VSGameUtilsKt.getShipManagingPos(movementContext.world, movementContext.contraption.anchor); - if (ship != null) - motion = VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformDirection(VectorConversionsMCKt.toJOML(motion), new Vector3d())); - } - instance.setDeltaMovement(motion); - } - //Region end -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java deleted file mode 100644 index ae9e47bd8..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; - -import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(FilteringBehaviour.class) -public class MixinFilteringBehaviour { - @Redirect( - method = "testHit", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { - Level level = ((FilteringBehaviour) (Object) this).getWorld(); - - Vec3 pos1 = instance; - Vec3 pos2 = vec; - - if (level != null) { - Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); - Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); - if (ship1 != null && ship2 == null) { - pos2 = VectorConversionsMCKt.toMinecraft( - ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) - ); - } else if (ship1 == null && ship2 != null) { - pos1 = VectorConversionsMCKt.toMinecraft( - ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) - ); - } - } - return pos1.subtract(pos2); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java deleted file mode 100644 index 5abbba6d8..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; - -import com.simibubi.create.content.redstone.link.LinkBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(LinkBehaviour.class) -public class MixinLinkBehaviour { - @Redirect( - method = "testHit", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { - Level level = ((LinkBehaviour) (Object) this).getWorld(); - - Vec3 pos1 = instance; - Vec3 pos2 = vec; - - if (level != null) { - Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); - Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); - if (ship1 != null && ship2 == null) { - pos2 = VectorConversionsMCKt.toMinecraft( - ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) - ); - } else if (ship1 == null && ship2 != null) { - pos1 = VectorConversionsMCKt.toMinecraft( - ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) - ); - } - } - return pos1.subtract(pos2); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java deleted file mode 100644 index fc052d56d..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; - -import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(ScrollValueBehaviour.class) -public class MixinScrollValueBehaviour { - - @Redirect( - method = "testHit", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { - Level level = ((ScrollValueBehaviour) (Object) this).getWorld(); - - Vec3 pos1 = instance; - Vec3 pos2 = vec; - - if (level != null) { - Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); - Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); - if (ship1 != null && ship2 == null) { - pos2 = VectorConversionsMCKt.toMinecraft( - ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) - ); - } else if (ship1 == null && ship2 != null) { - pos1 = VectorConversionsMCKt.toMinecraft( - ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) - ); - } - } - return pos1.subtract(pos2); - } -} - diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java deleted file mode 100644 index a9f3fee09..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; - -import com.simibubi.create.foundation.blockEntity.behaviour.filtering.SidedFilteringBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(SidedFilteringBehaviour.class) -public class MixinSidedFilteringBehaviour { - @Redirect( - method = "testHit", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { - Level level = ((SidedFilteringBehaviour) (Object) this).getWorld(); - - Vec3 pos1 = instance; - Vec3 pos2 = vec; - - if (level != null) { - Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); - Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); - if (ship1 != null && ship2 == null) { - pos2 = VectorConversionsMCKt.toMinecraft(ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2))); - } else if (ship1 == null && ship2 != null) { - pos1 = VectorConversionsMCKt.toMinecraft(ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1))); - } - } - return pos1.subtract(pos2); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java deleted file mode 100644 index 067725275..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.block; - -import com.simibubi.create.content.kinetics.crusher.CrushingWheelBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(CrushingWheelBlock.class) -public class MixinCrushingWheelBlock { - - @Unique - private BlockPos blockPosInside; - @Unique - private Level levelInside; - - @Inject(method = "entityInside", at = @At("HEAD")) - void startInside( - final BlockState state, final Level worldIn, final BlockPos pos, final Entity entityIn, - final CallbackInfo info) { - blockPosInside = pos; - levelInside = worldIn; - } - - @Unique - void transform(final Vector3d in) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(levelInside, blockPosInside); - if (ship != null) { - ship.getWorldToShip().transformPosition(in); - } - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getX()D" - ) - ) - double getXPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getY()D" - ) - ) - double getYPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getZ()D" - ) - ) - double getZPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java deleted file mode 100644 index 4759a6b94..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.block; - -import com.simibubi.create.content.logistics.depot.EjectorBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(EjectorBlock.class) -public abstract class MixinEjectorBlock { - @Redirect(method = "updateEntityAfterFallOn", at = @At( - value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - )) - private BlockPos redirectBlockPosition(Entity instance) { - return instance.getOnPos(); - } - - @Redirect(method = "updateEntityAfterFallOn", at = @At( - value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" - )) - private Vec3 redirectEntityPosition(Entity instance) { - Vec3 result = instance.position(); - if (VSGameUtilsKt.getShipManagingPos(instance.level, instance.position()) == null) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getOnPos()); - if (ship != null) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - ship.getWorldToShip().transformPosition(tempVec, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - } - return result; - } - - @Redirect(method = "updateEntityAfterFallOn", at = @At( - value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V" - )) - private void redirectSetPos(Entity instance, double x, double y, double z) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getOnPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformPosition(x, y, z, tempVec); - instance.setPos(tempVec.x, tempVec.y, tempVec.z); - } else { - instance.setPos(x, y, z); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java deleted file mode 100644 index f87322cca..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.block; - -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; - -import com.mojang.datafixers.util.Pair; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.redstone.contact.RedstoneContactBlock; -import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import net.minecraft.world.ticks.TickPriority; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(RedstoneContactBlock.class) -public abstract class MixinRedstoneContactBlock extends WrenchableDirectionalBlock { - - private static Map, BlockPos> contactCache = new HashMap<>(); - - @Shadow - @Final - public static BooleanProperty POWERED; - @Unique - private static final double MAX_ALIGNMENT_ANGLE = -0.93972176; //Mth.cos(20*(Mth.DEG_TO_RAD)) - - public MixinRedstoneContactBlock(Properties properties) { - super(properties); - } - - @Inject(method = "onRemove", at = @At("HEAD")) - private void injectOnRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving, CallbackInfo ci) { - if (state.getBlock() == this && newState.isAir()) { - Pair key = Pair.of(worldIn, pos); - if (state.getValue(POWERED) && contactCache.containsKey(key)) { - worldIn.scheduleTick(contactCache.get(key), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); - contactCache.remove(key); - } - } - } - - @Inject(method = "tick", at = @At(value = "INVOKE_ASSIGN", shift = At.Shift.BY, by = 2, target = "Lcom/simibubi/create/content/redstone/contact/RedstoneContactBlock;hasValidContact(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z"), locals = LocalCapture.CAPTURE_FAILHARD) - private void injectTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource random, CallbackInfo ci, boolean hasValidContact) { - if (VSGameUtilsKt.isBlockInShipyard(worldIn, pos)) { - Pair key = Pair.of(worldIn, pos); - if (!hasValidContact && state.getValue(POWERED) && contactCache.containsKey(key)) { - worldIn.scheduleTick(contactCache.get(key), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); - contactCache.remove(key); - } - worldIn.scheduleTick(pos, AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); - } - } - - @Unique - private static boolean hasContact(Level world, Ship ship, Vector3d searchPos, Direction direction, Ship shipItr) { - BlockState blockState = world.getBlockState(new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos))); - if (AllBlocks.REDSTONE_CONTACT.has(blockState)) { - Vector3d worldDirection = toJOML(Vec3.atLowerCornerOf(direction.getNormal())); - Vector3d targetDirection = toJOML(Vec3.atLowerCornerOf(blockState.getValue(FACING).getNormal())); - if (ship != null) { - ship.getShipToWorld().transformDirection(worldDirection, worldDirection); - } - if (shipItr != null) { - shipItr.getShipToWorld().transformDirection(targetDirection, targetDirection); - } - double dotAngle = worldDirection.dot(targetDirection); - return dotAngle < MAX_ALIGNMENT_ANGLE; - } - return false; - } - - @Inject(method = "hasValidContact", at = @At("RETURN"), cancellable = true) - private static void injectHasValidContact(LevelAccessor world, BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - boolean result = false; - Level worldLevel = (Level) world; - BlockState blockState = world.getBlockState(pos.relative(direction)); - if (AllBlocks.REDSTONE_CONTACT.has(blockState)) { - cir.setReturnValue(blockState.getValue(FACING) == direction.getOpposite()); - } else { - - AABB searchAABB = new AABB(pos.relative(direction)); - Vector3d searchPos = toJOML(Vec3.atCenterOf(pos.relative(direction))); - Ship ship = VSGameUtilsKt.getShipManagingPos(worldLevel, pos); - if (VSGameUtilsKt.isBlockInShipyard(worldLevel, pos) && ship != null) { - Vector3d tempVec = toJOML(Vec3.atCenterOf(pos.relative(direction))); - searchPos = ship.getShipToWorld().transformPosition(tempVec, new Vector3d()); - ship.getShipToWorld().transformPosition(tempVec, tempVec); - double bounds = 0.25; - searchAABB = new AABB(tempVec.x - bounds, tempVec.y - bounds, tempVec.z - bounds, - tempVec.x + bounds, tempVec.y + bounds, tempVec.z + bounds); - - result = hasContact(worldLevel, ship, searchPos, direction, null); - } - Iterator ships = VSGameUtilsKt.getShipsIntersecting(worldLevel, searchAABB).iterator(); - if (ships.hasNext() && !result) { - do { - Ship shipItr = ships.next(); - if (shipItr == ship) continue; - Vector3d newSearchPos = shipItr.getWorldToShip().transformPosition(searchPos, new Vector3d()); - result = hasContact(worldLevel, ship, newSearchPos, direction, shipItr); - if (result) searchPos = newSearchPos; - } while (ships.hasNext() && !result); - } - if (result) { - contactCache.put(Pair.of(worldLevel, pos), new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos))); - world.scheduleTick(new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos)), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); - } - cir.setReturnValue(result); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java deleted file mode 100644 index ab6a7a908..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.block; - -import com.simibubi.create.content.contraptions.chassis.StickerBlock; -import com.simibubi.create.content.contraptions.chassis.StickerBlockEntity; -import com.simibubi.create.foundation.block.IBE; -import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.IMixinStickerTileEntity; - -@Mixin(StickerBlock.class) -public abstract class MixinStickerBlock extends WrenchableDirectionalBlock implements IBE { - - public MixinStickerBlock(final Properties properties) { - super(properties); - } - - @Override - public void onRemove( - @NotNull final BlockState state, - @NotNull final Level world, - @NotNull final BlockPos pos, - @NotNull final BlockState newState, - final boolean isMoving - ) { - IBE.onRemove(state, world, pos, newState); - } - - @Inject( - method = "neighborChanged", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), - cancellable = true - ) - private void injectNeighbourChanged( - final BlockState state, - final Level worldIn, - final BlockPos pos, - final Block blockIn, - final BlockPos fromPos, - final boolean isMoving, - final CallbackInfo ci - ) { - final StickerBlockEntity ste = getBlockEntity(worldIn, pos); - // By checking `instanceof IMixinStickerTileEntity` we only run this code if Clockwork is installed - if (ste instanceof final IMixinStickerTileEntity iMixinStickerTileEntity && iMixinStickerTileEntity.isAlreadyPowered(false)) { - if (!worldIn.hasNeighborSignal(pos)) { - ci.cancel(); - } else { - iMixinStickerTileEntity.isAlreadyPowered(true); - } - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java deleted file mode 100644 index a27061283..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; - -import com.simibubi.create.content.contraptions.bearing.MechanicalBearingBlockEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(MechanicalBearingBlockEntity.class) -public interface IMixinMechanicalBearingTileEntity { - @Accessor boolean isAssembleNextTick(); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java deleted file mode 100644 index a8c8f864d..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; - -import com.simibubi.create.content.kinetics.crusher.CrushingWheelControllerBlock; -import com.simibubi.create.content.kinetics.crusher.CrushingWheelControllerBlockEntity; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.function.Predicate; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.joml.primitives.AABBd; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(CrushingWheelControllerBlockEntity.class) -public abstract class MixinCrushingWheelControllerTileEntity { - - @Shadow - public float crushingspeed; - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;")) - private List redirectBounds(Level instance, Entity entity, AABB area, Predicate predicate) { - if (instance != null) { - area = VSGameUtilsKt.transformAabbToWorld(instance, area); - return instance.getEntities(entity, area, predicate); - } - return new ArrayList(); - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z")) - private boolean redirectIntersects(AABB instance, AABB other) { - Level level = ((CrushingWheelControllerBlockEntity) (Object) this).getLevel(); - if (level != null) { - Iterator ships = VSGameUtilsKt.getShipsIntersecting(level, instance).iterator(); - if (ships.hasNext()) { - AABBd result = new AABBd(); - VectorConversionsMCKt.toJOML(instance).transform(ships.next().getTransform().getWorldToShip(), result); - instance = VectorConversionsMCKt.toMinecraft(result); - } - } - return instance.intersects(other); - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) - private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { - - BlockPos worldPosition = ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos(); - Direction facing = ((CrushingWheelControllerBlockEntity) (Object) this) - .getBlockState().getValue(CrushingWheelControllerBlock.FACING); - Vec3 transformedPos = getTransformedPosition(instance); - double xMotion = ((worldPosition.getX() + .5) - transformedPos.x) / 2; - double zMotion = ((worldPosition.getZ() + .5) - transformedPos.z) / 2; - - if (instance.isShiftKeyDown()) - xMotion = zMotion = 0; - double movement = Math.max(-(this.crushingspeed * 4) / 4f, -.5f) * -facing.getAxisDirection().getStep(); - - Vec3 transformedDirection = directionShip2World(instance, - new Vec3( - facing.getAxis() == Direction.Axis.X ? movement : xMotion, - facing.getAxis() == Direction.Axis.Y ? movement : 0f, - facing.getAxis() == Direction.Axis.Z ? movement : zMotion - )); - - instance.setDeltaMovement(transformedDirection); - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) - private double redirectEntityGetX(Entity instance) { - return getTransformedPosition(instance).x; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) - private double redirectEntityGetY(Entity instance) { - return getTransformedPosition(instance).y; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) - private double redirectEntityGetZ(Entity instance) { - return getTransformedPosition(instance).z; - } - - private Vec3 getTransformedPosition(Entity instance) { - Vec3 result = instance.position(); - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getWorldToShip().transformPosition(result.x, result.y, result.z, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } - - private Vec3 directionShip2World(Entity instance, Vec3 direction) { - Vec3 result = direction; - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java deleted file mode 100644 index d1ff39aa5..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; - -import com.simibubi.create.content.logistics.depot.EjectorBlockEntity; -import java.util.List; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(EjectorBlockEntity.class) -public abstract class MixinEjectorTileEntity { - @ModifyVariable(method = "*", at = @At("STORE"), name = "ejectVec") - private Vec3 modEjectVec(Vec3 ejectVec) { - Vec3 result = ejectVec; - Level level = ((EjectorBlockEntity) (Object) this).getLevel(); - if (level != null) { - Ship ship = VSGameUtilsKt.getShipManagingPos(level, ((EjectorBlockEntity) (Object) this).getBlockPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); - result = new Vec3(tempVec.x, tempVec.y, tempVec.z); - } - } - return result; - } - - @ModifyVariable(method = "*", at = @At("STORE"), name = "ejectMotionVec") - private Vec3 modEjectMotionVec(Vec3 ejectMotionVec) { - Vec3 result = ejectMotionVec; - Level level = ((EjectorBlockEntity) (Object) this).getLevel(); - if (level != null) { - Ship ship = VSGameUtilsKt.getShipManagingPos(level, ((EjectorBlockEntity) (Object) this).getBlockPos()); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); - result = new Vec3(tempVec.x, tempVec.y, tempVec.z); - } - } - return result; - } - - @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;")) - private List redirectGetEntitiesOfClass(Level instance, Class aClass, AABB aabb) { - return instance.getEntitiesOfClass(aClass, VSGameUtilsKt.transformAabbToWorld(instance, aabb)); - } - - @Redirect(method = "activateDeferred", at = @At( - value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V" - )) - private void redirectSetPos(Entity instance, double x, double y, double z) { - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((EjectorBlockEntity) (Object) this).getBlockPos()); - if (ship != null) { - BlockPos temp = ((EjectorBlockEntity) (Object) this).getBlockPos(); - Vector3d tempVec = new Vector3d(temp.getX() + .5, temp.getY() + 1, temp.getZ() + .5); - ship.getTransform().getShipToWorld().transformPosition(tempVec, tempVec); - instance.setPos(tempVec.x, tempVec.y, tempVec.z); - } else { - instance.setPos(x, y, z); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java deleted file mode 100644 index 2c317a400..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; - -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.content.kinetics.fan.EncasedFanBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; - -@Mixin(EncasedFanBlockEntity.class) -public abstract class MixinEncasedFanTileEntity extends KineticBlockEntity implements IExtendedAirCurrentSource { - @Unique - private Ship ship = null; - - public MixinEncasedFanTileEntity(BlockEntityType typeIn, BlockPos pos, BlockState state) { - super(typeIn, pos, state); - } - - @Override - public void setLevel(@NotNull Level level) { - super.setLevel(level); - ship = VSGameUtilsKt.getShipManagingPos(level, getBlockPos()); - } - - @Override - public Ship getShip() { - return ship; - } - - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java deleted file mode 100644 index 593834577..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.cannons; - -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.LoadedServerShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption; -import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity; - -@Mixin(CannonMountBlockEntity.class) -public abstract class MixinCannonMount extends KineticBlockEntity implements ControlPitchContraption.Block { - - private Integer cannonID = null; - private boolean alreadyAdded = false; - - Vector3d recoilVec = null; - double recoilForce = 0; - - public MixinCannonMount(BlockEntityType typeIn, BlockPos pos, BlockState state) { - super(typeIn, pos, state); - } - - /*TODO? - @Override - public void cacheRecoilVector(Vec3 vector, AbstractContraptionEntity cannon) { - recoilVec = VectorConversionsMCKt.toJOML(vector); - } - */ - - @Unique - private void handleAssembly() { - LoadedServerShip ship = null; - if (!level.isClientSide) { - if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { - ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); - } - } - - if (ship != null) { - if (!alreadyAdded && cannonID == null) { - Vector3dc pos = VectorConversionsMCKt.toJOMLD(worldPosition); - //final CannonCreateData data = new CannonCreateData(pos); - //cannonID = CannonController.getOrCreate(ship).addCannon(data); - alreadyAdded = true; - } - } - } - - @Unique - private void handleDisassembly() { - LoadedServerShip ship = null; - if (!level.isClientSide) { - if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { - ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); - } - } - if (cannonID != null) { - //CannonController.getOrCreate(ship).removeCannon(cannonID); - cannonID = null; - alreadyAdded = false; - recoilVec = null; - } - - } - - @Unique - private void handleController() { - //do stuff here (I like to have the inject call to a separate function so the breakpoint will work properly for this function) - - LoadedServerShip ship = null; - if (!level.isClientSide) { - if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { - ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); - } - } - if (ship != null) { - if (alreadyAdded && cannonID != null) { - if (recoilVec != null) { - //final CannonUpdateData data = new CannonUpdateData(recoilVec); - //CannonController.getOrCreate(ship).updateCannon(cannonID, data); - } - } - if (this.isRemoved()) { - if (cannonID != null) { - //CannonController.getOrCreate(ship).removeCannon(cannonID); - cannonID = null; - alreadyAdded = false; - } - } - } - } - @Inject(method = "tick", at = @At("HEAD"), remap = false) - private void injectTick(CallbackInfo ci) { - handleController(); - } - - @Inject(method = "assemble", at = @At("RETURN"), remap = false) - private void injectAssemble(CallbackInfo ci) { - handleAssembly(); - } - - @Inject(method = "disassemble", at = @At("HEAD"), remap = false) - private void injectDisassemble(CallbackInfo ci) { - handleDisassembly(); - } - - @Unique - private CompoundTag writeToCompound(CompoundTag compound, boolean clientPacket){ - //write here - compound.putBoolean("alreadyAdded", alreadyAdded); - if (cannonID != null) { - compound.putInt("cannonID", cannonID); - } - return compound; - } - @Inject(method = "write", at = @At("HEAD"), cancellable = true, remap = false) - private void injectWrite(CompoundTag compound, boolean clientPacket, CallbackInfo ci) { - compound = writeToCompound(compound,clientPacket); - super.write(compound, clientPacket); - ci.cancel(); - } - - @Unique - private CompoundTag readFromCompound(CompoundTag compound, boolean clientPacket){ - //read (and remove before it passes up?) here - alreadyAdded = compound.getBoolean("alreadyAdded"); - if (compound.contains("cannonID")) { - cannonID = compound.getInt("cannonID"); - } - return compound; - } - @Inject(method = "read", at = @At("HEAD"), cancellable = true, remap = false) - private void injectRead(CompoundTag compound, boolean clientPacket, CallbackInfo ci) { - compound = readFromCompound(compound,clientPacket); - super.read(compound, clientPacket); - ci.cancel(); - } - -} - diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java deleted file mode 100644 index 3e7c98b72..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; -import com.simibubi.create.foundation.outliner.AABBOutline; -import com.simibubi.create.foundation.outliner.Outline; -import com.simibubi.create.foundation.render.RenderTypes; -import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.client.Minecraft; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.OutlineParamsAccessor; - -@Mixin(AABBOutline.class) -public abstract class MixinAABBOutline extends Outline { - @Shadow - protected abstract void renderBoxFaces(PoseStack ms, SuperRenderTypeBuffer buffer, boolean cull, Direction highlightedFace, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap); - - @Shadow - protected abstract void renderBoxEdges(PoseStack ms, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, float lineWidth, Vector4f color, int lightmap, boolean disableNormals); - - @Inject(method = "renderBox", at = @At("HEAD"), cancellable = true) - private void preRenderBox(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, AABB box, Vector4f color, int lightmap, boolean disableLineNormals, CallbackInfo ci) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Vector3dc average = VectorConversionsMCKt.toJOML(box.getCenter()); - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); - if (ship != null) { - final ShipTransform renderTransform = ship.getRenderTransform(); - Vector3f minPos = new Vector3f(); - Vector3f maxPos = new Vector3f(); - - final Vector3dc cameraInShip = renderTransform.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(camera)); - - boolean cameraInside = box.contains(VectorConversionsMCKt.toMinecraft(cameraInShip)); - boolean cull = !cameraInside && !((OutlineParamsAccessor) params).getDisableCull(); - float inflate = cameraInside ? -1 / 128f : 1 / 128f; - - final AABB boxRelShipCenter = box.move(-renderTransform.getPositionInShip().x(), -renderTransform.getPositionInShip().y(), -renderTransform.getPositionInShip().z()); - - minPos.set((float) boxRelShipCenter.minX - inflate, (float) boxRelShipCenter.minY - inflate, (float) boxRelShipCenter.minZ - inflate); - maxPos.set((float) boxRelShipCenter.maxX + inflate, (float) boxRelShipCenter.maxY + inflate, (float) boxRelShipCenter.maxZ + inflate); - - ms.pushPose(); - ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); - ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); - ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); - renderBoxFaces(ms, buffer, cull, params.getHighlightedFace(), minPos, maxPos, color, lightmap); - - float lineWidth = params.getLineWidth(); - if (lineWidth == 0) - return; - - VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); - renderBoxEdges(ms, consumer, minPos, maxPos, lineWidth, color, lightmap, disableLineNormals); - - ms.popPose(); - ci.cancel(); - } - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java deleted file mode 100644 index 78b2c7014..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; -import com.simibubi.create.AllSpecialTextures; -import com.simibubi.create.foundation.outliner.BlockClusterOutline; -import com.simibubi.create.foundation.outliner.Outline; -import com.simibubi.create.foundation.render.RenderTypes; -import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import java.util.Iterator; -import java.util.Optional; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.OutlineParamsAccessor; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.CWCluster; - -@Mixin(BlockClusterOutline.class) -public abstract class MixinBlockClusterOutline extends Outline { - @Unique - private CWCluster cw$cluster = null; - - @Shadow - @Final - protected Vector3f originTemp; - - @Shadow - protected abstract void bufferBlockFace(PoseStack.Pose pose, VertexConsumer consumer, BlockPos pos, Direction face, Vector4f color, int lightmap); - - @Inject(method = "", at = @At("RETURN")) - private void postInit(final Iterable positions, final CallbackInfo ci) { - final Iterator iterator = positions.iterator(); - final BlockPos firstPos = iterator.hasNext() ? iterator.next() : null; - if (firstPos != null) { - final Level level = Minecraft.getInstance().level; - if (level != null && VSGameUtilsKt.getShipManagingPos(level, firstPos) != null) { - // Only generate cw$cluster if we're on a ship - cw$cluster = new CWCluster(); - positions.forEach(cw$cluster::include); - } - } - } - - @Inject(method = "renderFaces", at = @At("HEAD"), cancellable = true) - private void preRenderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, CallbackInfo ci) { - if (cw$cluster != null) { - final BlockPos anchorPos = cw$cluster.anchor; - if (anchorPos == null) { - return; - } - final Level level = Minecraft.getInstance().level; - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, anchorPos); - if (ship != null) { - Optional optionalFaceTexture = ((OutlineParamsAccessor) params).getFaceTexture(); - if (optionalFaceTexture.isEmpty()) - return; - - final ShipTransform renderTransform = ship.getRenderTransform(); - - ms.pushPose(); - ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); - ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); - ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); - ms.translate( - cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), - cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), - cw$cluster.anchor.getZ() - renderTransform.getPositionInShip().z() - ); - - AllSpecialTextures faceTexture = optionalFaceTexture.get(); - PoseStack.Pose pose = ms.last(); - RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true); - VertexConsumer consumer = buffer.getLateBuffer(renderType); - - cw$cluster.visibleFaces.forEach((face, axisDirection) -> { - Direction direction = Direction.get(axisDirection, face.axis); - BlockPos pos = face.pos; - if (axisDirection == Direction.AxisDirection.POSITIVE) - pos = pos.relative(direction.getOpposite()); - - bufferBlockFace(pose, consumer, pos, direction, color, lightmap); - }); - - ms.popPose(); - ci.cancel(); - } - } - } - - @Inject(method = "renderEdges", at = @At("HEAD"), cancellable = true) - private void preRenderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { - if (cw$cluster != null) { - final BlockPos anchorPos = cw$cluster.anchor; - if (anchorPos == null) { - return; - } - final Level level = Minecraft.getInstance().level; - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, anchorPos); - if (ship != null) { - float lineWidth = params.getLineWidth(); - if (lineWidth == 0) - return; - if (cw$cluster.isEmpty()) - return; - - final ShipTransform renderTransform = ship.getRenderTransform(); - - ms.pushPose(); - ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); - ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); - ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); - ms.translate( - cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), - cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), - cw$cluster.anchor.getZ() - renderTransform.getPositionInShip().z() - ); - - PoseStack.Pose pose = ms.last(); - VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); - - cw$cluster.visibleEdges.forEach(edge -> { - BlockPos pos = edge.pos; - Vector3f origin = originTemp; - origin.set(pos.getX(), pos.getY(), pos.getZ()); - Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, edge.axis); - bufferCuboidLine(pose, consumer, origin, direction, 1, lineWidth, color, lightmap, disableNormals); - }); - - ms.popPose(); - - ci.cancel(); - } - } - } -} - diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java deleted file mode 100644 index 68db4f5c9..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; -import com.jozufozu.flywheel.util.AnimationTickHolder; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; -import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; -import com.simibubi.create.content.trains.entity.CarriageContraptionInstance; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4d; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(CarriageContraptionInstance.class) -public abstract class MixinCarriageContraptionInstance extends EntityInstance { - - public MixinCarriageContraptionInstance(MaterialManager materialManager, Entity entity) { - super(materialManager, entity); - } - - @Redirect( - method = "beginFrame", at = @At(value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lcom/mojang/math/Vector3f;)Ljava/lang/Object;") - ) - private Object redirectTranslate(final TransformStack instance, final Vector3f vector3f) { - - final float partialTicks = AnimationTickHolder.getPartialTicks(); - final Level level = this.world; - final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(level, vector3f.x(), vector3f.y(), vector3f.z()); - - if (ship != null) { - final CarriageContraptionEntity carriageContraptionEntity = (CarriageContraptionEntity) this.entity; - final Vector3d origin = VectorConversionsMCKt.toJOMLD(this.materialManager.getOriginCoordinate()); - final Vec3 pos = carriageContraptionEntity.position(); - final Vector3d newPosition = - new Vector3d( - Mth.lerp(partialTicks, carriageContraptionEntity.xOld, pos.x), - Mth.lerp(partialTicks, carriageContraptionEntity.yOld, pos.y), - Mth.lerp(partialTicks, carriageContraptionEntity.zOld, pos.z) - ); - final ShipTransform transform = ship.getRenderTransform(); - Matrix4d renderMatrix = new Matrix4d() - .translate(origin.mul(-1)) - .mul(transform.getShipToWorld()) - .translate(newPosition); - Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); - ((PoseStack) instance).last().pose().multiply(mat4f); - } else { - instance.translate(vector3f); - } - return null; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java deleted file mode 100644 index 644e81581..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import net.minecraft.client.Minecraft; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(targets = { - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$SmallCogHelper", - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$LargeCogHelper", - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$DiagonalCogHelper", - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$IntegratedLargeCogHelper", - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$IntegratedSmallCogHelper" -}) -public class MixinCogwheelBlockItem { - @Redirect(method = "getOffset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetLocation(BlockHitResult instance) { - Vec3 result = instance.getLocation(); - Level world = Minecraft.getInstance().level; - if (world != null) { - Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); - if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world, result.x, result.y, result.z)) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - ship.getWorldToShip().transformPosition(tempVec, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java deleted file mode 100644 index bb68b92d0..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import net.minecraft.client.Minecraft; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(targets = { - "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$DiagonalCogHelper" -}) -public class MixinCogwheelBlockItemHitOnShaft { - @Redirect(method = "hitOnShaft", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetLocation(BlockHitResult instance) { - Vec3 result = instance.getLocation(); - Level world = Minecraft.getInstance().level; - if(world!=null) { - Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); - if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world, result.x, result.y, result.z)) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - ship.getWorldToShip().transformPosition(tempVec, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java deleted file mode 100644 index 17ec80da9..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; -import net.minecraft.core.Vec3i; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSClientGameUtils; - -@Mixin(ContraptionRenderDispatcher.class) -public abstract class MixinContraptionRenderDispatcher { - - @Redirect( - method = "renderActors", - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lnet/minecraft/core/Vec3i;)Ljava/lang/Object;" - ) - ) - private static Object redirectTranslate(final TransformStack instance, final Vec3i vec3i) { - VSClientGameUtils.transformRenderIfInShipyard((PoseStack) instance, vec3i.getX(), vec3i.getY(), vec3i.getZ()); - return instance; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java deleted file mode 100644 index b24a697b0..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Mth; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ContraptionRenderInfo.class) -public class MixinContraptionRenderInfo { - - @Shadow - @Final - public Contraption contraption; - @Shadow - @Final - private ContraptionMatrices matrices; - - @Inject(method = "setupMatrices", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"), cancellable = true) - private void injectAndDoTransformation(PoseStack viewProjection, double camX, double camY, double camZ, CallbackInfo ci) { - AbstractContraptionEntity entity = contraption.entity; - - if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { - viewProjection.pushPose(); - - double partialTick = AnimationTickHolder.getPartialTicks(); - VSClientGameUtils.transformRenderWithShip( - ship.getRenderTransform(), - viewProjection, - Mth.lerp(partialTick, entity.xOld, entity.getX()), - Mth.lerp(partialTick, entity.yOld, entity.getY()), - Mth.lerp(partialTick, entity.zOld, entity.getZ()), - camX, - camY, - camZ - ); - matrices.setup(viewProjection, entity); - viewProjection.popPose(); - ci.cancel(); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java deleted file mode 100644 index f10487ac3..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.schematics.client.tools.DeployTool; -import com.simibubi.create.content.schematics.client.tools.SchematicToolBase; -import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.Minecraft; -import net.minecraft.util.Mth; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -/** - * DeployTool is responsible for the render transform of the placement bounding box (not the preview) - *

- * Create applies both the camera and bounding-box position in the same PoseStack operation, - * the latter of which does not respect ship-space. - * This mixin cancels the aforementioned operation and injects the fix in front. - */ -@Mixin(value={DeployTool.class}) -public abstract class MixinDeployTool extends SchematicToolBase { - @Redirect( - method = "renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", - ordinal = 0 - ) - ) - private void redirectTranslate(PoseStack ms, double _x, double _y, double _z) { - } - - @Inject( - method = "renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", - ordinal = 0 - ) - ) - private void mixinRenderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, CallbackInfo ci) { - float pt = AnimationTickHolder.getPartialTicks(); - double x = Mth.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); - double y = Mth.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); - double z = Mth.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z); - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, x, y, z); - - AABB bounds = schematicHandler.getBounds(); - Vec3 center = bounds.getCenter(); - int centerX = (int) center.x; - int centerZ = (int) center.z; - - if (ship != null) { - VSClientGameUtils.transformRenderWithShip(ship.getTransform(), ms, x - centerX, y, z - centerZ, camera.x, camera.y, camera.z); - } else { - ms.translate(x - centerX - camera.x, y - camera.y, z - centerZ - camera.z); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java deleted file mode 100644 index 0d200f69b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.elevator.ElevatorControlsHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.AABB; -import org.joml.primitives.AABBdc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(ElevatorControlsHandler.class) -public class MixinElevatorControlsHandler { - // Fixes raytracing contraptions on ships - @WrapOperation(method = "onScroll", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB onScrollGetBoundingBox(final AbstractContraptionEntity instance, final Operation getBoundingBox) { - final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); - if (clientShip != null) { - final AABB original = getBoundingBox.call(instance); - final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); - return VectorConversionsMCKt.toMinecraft(modified); - } - return getBoundingBox.call(instance); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java deleted file mode 100644 index 352bcf2c2..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(FilteringRenderer.class) -public class MixinFilteringRenderer { - - @Redirect( - method = "tick", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;") - ) - private static Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { - Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); - return result.subtract(vec); - } - - @Redirect( - method = "renderOnBlockEntity", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") - ) - private static double redirectDistanceToSqr(Vec3 instance, Vec3 vec) { - Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); - return result.distanceToSqr(vec); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java deleted file mode 100644 index cbf095eaa..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSClientGameUtils; - -@Mixin(targets = {"com.simibubi.create.foundation.utility.ghost.GhostBlockRenderer$DefaultGhostBlockRenderer", - "com.simibubi.create.foundation.utility.ghost.GhostBlockRenderer$TransparentGhostBlockRenderer"}) -public class MixinGhostBlockRenderer { - - @Redirect( - method = "render", - at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", ordinal = 0) - ) - private void redirectTranslate( - final PoseStack instance, final double pose, final double d, final double e) { - VSClientGameUtils.transformRenderIfInShipyard(instance, pose, d, e); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java deleted file mode 100644 index 8178ff275..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.content.redstone.link.LinkRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(LinkRenderer.class) -public class MixinLinkRenderer { - @Redirect( - method = "renderOnBlockEntity", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") - ) - private static double redirectDistanceToSqr(Vec3 instance, Vec3 vec) { - Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); - return result.distanceToSqr(vec); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java deleted file mode 100644 index 630dc7075..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; -import com.jozufozu.flywheel.util.AnimationTickHolder; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.jozufozu.flywheel.vanilla.MinecartInstance; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4d; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(MinecartInstance.class) -public abstract class MixinMinecartInstance extends EntityInstance { - - - public MixinMinecartInstance(MaterialManager materialManager, Entity entity) { - super(materialManager, entity); - } - - @Redirect( - method = "beginFrame", at = @At(value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(DDD)Ljava/lang/Object;", ordinal = 0), - remap = false - ) - private Object redirectTranslate(TransformStack instance, double x, double y, double z) { - final float partialTicks = AnimationTickHolder.getPartialTicks(); - if (VSGameUtilsKt.getShipManaging(entity) instanceof ClientShip ship) { - final Vector3d origin = VectorConversionsMCKt.toJOMLD(materialManager.getOriginCoordinate()); - final Vec3 pos = entity.position(); - final Vector3d newPosition = - new Vector3d( - Mth.lerp(partialTicks, entity.xOld, pos.x), - Mth.lerp(partialTicks, entity.yOld, pos.y), - Mth.lerp(partialTicks, entity.zOld, pos.z) - ); - final ShipTransform transform = ship.getRenderTransform(); - Matrix4d renderMatrix = new Matrix4d() - .translate(origin.mul(-1)) - .mul(transform.getShipToWorld()) - .translate(newPosition); - Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); - ((PoseStack) instance).last().pose().multiply(mat4f); - } else { - instance.translate(x, y, z); - } - return null; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java deleted file mode 100644 index 609047cc0..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.foundation.placement.PlacementOffset; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(targets = { - "com.simibubi.create.content.contraptions.bearing.SailBlock$PlacementHelper", - "com.simibubi.create.foundation.placement.PoleHelper", - "com.simibubi.create.content.decoration.girder.GirderPlacementHelper", - "com.simibubi.create.content.trains.display.FlapDisplayBlock$PlacementHelper" -}) -public class MixinMultiplePlacementHelpers { - - @Unique - private Level world; - - @Inject(method = "getOffset", at = @At("HEAD")) - private void harvestWorld(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray, CallbackInfoReturnable cir) { - this.world = world; - } - - @Redirect(method = "getOffset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetLocation(BlockHitResult instance) { - Vec3 result = instance.getLocation(); - Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); - if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world,result.x,result.y,result.z)) { - Vector3d tempVec = VectorConversionsMCKt.toJOML(result); - ship.getWorldToShip().transformPosition(tempVec, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java deleted file mode 100644 index 7c2f112b2..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java +++ /dev/null @@ -1,421 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; -import com.simibubi.create.foundation.outliner.Outline; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4dc; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(Outline.class) -public abstract class MixinOutline { - @Shadow - public abstract void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, com.mojang.math.Vector3d start, com.mojang.math.Vector3d end, float width, Vector4f color, int lightmap, boolean disableNormals); - - @Shadow - public abstract void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal); - - @Inject(method = "bufferCuboidLine(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/phys/Vec3;Lcom/mojang/math/Vector3d;Lcom/mojang/math/Vector3d;FLcom/mojang/math/Vector4f;IZ)V", at = @At("HEAD"), cancellable = true) - private void preBufferCuboidLine0(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, com.mojang.math.Vector3d start, com.mojang.math.Vector3d end, float width, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Vector3dc average = new Vector3d((start.x + end.x) / 2.0, (start.y + end.y) / 2.0, (start.z + end.z) / 2.0); - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); - if (ship != null) { - final ShipTransform transform = ship.getRenderTransform(); - final Vector3dc startTransformed = transform.getShipToWorld().transformPosition(new Vector3d(start.x, start.y, start.z)); - final Vector3dc endTransformed = transform.getShipToWorld().transformPosition(new Vector3d(end.x, end.y, end.z)); - float scaledWidth = (float) (width * transform.getShipToWorldScaling().x()); - bufferCuboidLine(poseStack, consumer, camera, new com.mojang.math.Vector3d(startTransformed.x(), startTransformed.y(), startTransformed.z()), new com.mojang.math.Vector3d(endTransformed.x(), endTransformed.y(), endTransformed.z()), scaledWidth, color, lightmap, disableNormals); - ci.cancel(); - } - } - } - - @Inject(method = "bufferCuboid", at = @At("HEAD"), cancellable = true) - private void preBufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Vector3dc average = new Vector3d((minPos.x() + maxPos.x()) / 2.0, (minPos.y() + maxPos.y()) / 2.0, (minPos.z() + maxPos.z()) / 2.0); - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); - if (ship != null) { - final ShipTransform transform = ship.getRenderTransform(); - - final Vector3d temp = new Vector3d(); - - float minX = minPos.x(); - float minY = minPos.y(); - float minZ = minPos.z(); - float maxX = maxPos.x(); - float maxY = maxPos.y(); - float maxZ = maxPos.z(); - - final Matrix4dc newPosMatrix = VectorConversionsMCKt.toJOML(pose.pose()).mul(transform.getShipToWorld()); - - temp.set(minX, minY, maxZ); - newPosMatrix.transformPosition(temp); - double x0 = temp.x(); - double y0 = temp.y(); - double z0 = temp.z(); - //System.out.println("temp is " + temp); - - temp.set(minX, minY, minZ); - newPosMatrix.transformPosition(temp); - double x1 = temp.x(); - double y1 = temp.y(); - double z1 = temp.z(); - - temp.set(maxX, minY, minZ); - newPosMatrix.transformPosition(temp); - double x2 = temp.x(); - double y2 = temp.y(); - double z2 = temp.z(); - - temp.set(maxX, minY, maxZ); - newPosMatrix.transformPosition(temp); - double x3 = temp.x(); - double y3 = temp.y(); - double z3 = temp.z(); - - temp.set(minX, maxY, minZ); - newPosMatrix.transformPosition(temp); - double x4 = temp.x(); - double y4 = temp.y(); - double z4 = temp.z(); - - temp.set(minX, maxY, maxZ); - newPosMatrix.transformPosition(temp); - double x5 = temp.x(); - double y5 = temp.y(); - double z5 = temp.z(); - - temp.set(maxX, maxY, maxZ); - newPosMatrix.transformPosition(temp); - double x6 = temp.x(); - double y6 = temp.y(); - double z6 = temp.z(); - - temp.set(maxX, maxY, minZ); - newPosMatrix.transformPosition(temp); - double x7 = temp.x(); - double y7 = temp.y(); - double z7 = temp.z(); - - float r = color.x(); - float g = color.y(); - float b = color.z(); - float a = color.w(); - - // down - - if (disableNormals) { - temp.set(0, 1, 0); - } else { - temp.set(0, -1, 0); - } - newPosMatrix.transformDirection(temp).normalize(); - float nx0 = (float) temp.x(); - float ny0 = (float) temp.y(); - float nz0 = (float) temp.z(); - - consumer.vertex(x0, y0, z0) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx0, ny0, nz0) - .endVertex(); - - consumer.vertex(x1, y1, z1) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx0, ny0, nz0) - .endVertex(); - - consumer.vertex(x2, y2, z2) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx0, ny0, nz0) - .endVertex(); - - consumer.vertex(x3, y3, z3) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx0, ny0, nz0) - .endVertex(); - - // up - - temp.set(0, 1, 0); - newPosMatrix.transformDirection(temp).normalize(); - float nx1 = (float) temp.x(); - float ny1 = (float) temp.y(); - float nz1 = (float) temp.z(); - - consumer.vertex(x4, y4, z4) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx1, ny1, nz1) - .endVertex(); - - consumer.vertex(x5, y5, z5) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx1, ny1, nz1) - .endVertex(); - - consumer.vertex(x6, y6, z6) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx1, ny1, nz1) - .endVertex(); - - consumer.vertex(x7, y7, z7) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx1, ny1, nz1) - .endVertex(); - - // north - - if (disableNormals) { - temp.set(0, 1, 0); - } else { - temp.set(0, 0, -1); - } - newPosMatrix.transformDirection(temp).normalize(); - float nx2 = (float) temp.x(); - float ny2 = (float) temp.y(); - float nz2 = (float) temp.z(); - - consumer.vertex(x7, y7, z7) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx2, ny2, nz2) - .endVertex(); - - consumer.vertex(x2, y2, z2) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx2, ny2, nz2) - .endVertex(); - - consumer.vertex(x1, y1, z1) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx2, ny2, nz2) - .endVertex(); - - consumer.vertex(x4, y4, z4) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx2, ny2, nz2) - .endVertex(); - - // south - - if (disableNormals) { - temp.set(0, 1, 0); - } else { - temp.set(0, 0, 1); - } - newPosMatrix.transformDirection(temp).normalize(); - float nx3 = (float) temp.x(); - float ny3 = (float) temp.y(); - float nz3 = (float) temp.z(); - - consumer.vertex(x5, y5, z5) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx3, ny3, nz3) - .endVertex(); - - consumer.vertex(x0, y0, z0) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx3, ny3, nz3) - .endVertex(); - - consumer.vertex(x3, y3, z3) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx3, ny3, nz3) - .endVertex(); - - consumer.vertex(x6, y6, z6) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx3, ny3, nz3) - .endVertex(); - - // west - - if (disableNormals) { - temp.set(0, 1, 0); - } else { - temp.set(-1, 0, 0); - } - newPosMatrix.transformDirection(temp).normalize(); - float nx4 = (float) temp.x(); - float ny4 = (float) temp.y(); - float nz4 = (float) temp.z(); - - consumer.vertex(x4, y4, z4) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx4, ny4, nz4) - .endVertex(); - - consumer.vertex(x1, y1, z1) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx4, ny4, nz4) - .endVertex(); - - consumer.vertex(x0, y0, z0) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx4, ny4, nz4) - .endVertex(); - - consumer.vertex(x5, y5, z5) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx4, ny4, nz4) - .endVertex(); - - // east - - if (disableNormals) { - temp.set(0, 1, 0); - } else { - temp.set(1, 0, 0); - } - newPosMatrix.transformDirection(temp).normalize(); - float nx5 = (float) temp.x(); - float ny5 = (float) temp.y(); - float nz5 = (float) temp.z(); - - consumer.vertex(x6, y6, z6) - .color(r, g, b, a) - .uv(0, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx5, ny5, nz5) - .endVertex(); - - consumer.vertex(x3, y3, z3) - .color(r, g, b, a) - .uv(0, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx5, ny5, nz5) - .endVertex(); - - consumer.vertex(x2, y2, z2) - .color(r, g, b, a) - .uv(1, 1) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx5, ny5, nz5) - .endVertex(); - - consumer.vertex(x7, y7, z7) - .color(r, g, b, a) - .uv(1, 0) - .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(lightmap) - .normal(nx5, ny5, nz5) - .endVertex(); - - ci.cancel(); - } - } - } - - @Inject(method = "bufferQuad(Lcom/mojang/blaze3d/vertex/PoseStack$Pose;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector4f;FFFFILcom/mojang/math/Vector3f;)V", at = @At("HEAD"), cancellable = true) - private void preBufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal, CallbackInfo ci) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Vector3dc average = new Vector3d((pos0.x() + pos1.x() + pos2.x() + pos3.x()) / 4.0, (pos0.y() + pos1.y() + pos2.y() + pos3.y()) / 4.0, (pos0.z() + pos1.z() + pos2.z() + pos3.z()) / 4.0); - final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); - if (ship != null) { - final ShipTransform transform = ship.getRenderTransform(); - final Vector3dc pos0Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos0.x(), pos0.y(), pos0.z())); - final Vector3dc pos1Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos1.x(), pos1.y(), pos1.z())); - final Vector3dc pos2Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos2.x(), pos2.y(), pos2.z())); - final Vector3dc pos3Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos3.x(), pos3.y(), pos3.z())); - final Vector3dc normalTransformed = transform.getShipToWorld().transformDirection(new Vector3d(normal.x(), normal.y(), normal.z())); - bufferQuad( - pose, - consumer, - new Vector3f((float) pos0Transformed.x(), (float) pos0Transformed.y(), (float) pos0Transformed.z()), - new Vector3f((float) pos1Transformed.x(), (float) pos1Transformed.y(), (float) pos1Transformed.z()), - new Vector3f((float) pos2Transformed.x(), (float) pos2Transformed.y(), (float) pos2Transformed.z()), - new Vector3f((float) pos3Transformed.x(), (float) pos3Transformed.y(), (float) pos3Transformed.z()), - color, - minU, - minV, - maxU, - maxV, - lightmap, - new Vector3f((float) normalTransformed.x(), (float) normalTransformed.y(), (float) normalTransformed.z()) - ); - ci.cancel(); - } - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java deleted file mode 100644 index 093fe2061..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.foundation.placement.PlacementHelpers; -import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.Minecraft; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(PlacementHelpers.class) -public class MixinPlacementHelpers { - @Redirect(method = "drawDirectionIndicator", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 redirectGetCenterOf(Vec3i pos) { - Vec3 result = VecHelper.getCenterOf(pos); - Level world = Minecraft.getInstance().level; - if (world != null && VSGameUtilsKt.isBlockInShipyard(world, pos.getX(),pos.getY(),pos.getZ()) && VSGameUtilsKt.getShipManagingPos(world, pos.getX(),pos.getY(),pos.getZ()) instanceof ClientShip ship) { - Vector3d tempVec = new Vector3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5); - ship.getShipToWorld().transformPosition(tempVec, tempVec); - result = VectorConversionsMCKt.toMinecraft(tempVec); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java deleted file mode 100644 index 32a196e4e..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.schematics.client.SchematicTransformation; -import com.simibubi.create.content.schematics.client.tools.SchematicToolBase; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -/** - * SchematicToolBase is responsible for the placement position of the schematic. - */ -@Mixin(value={SchematicToolBase.class}) -public abstract class MixinSchematicToolBase { - /** - * Create uses HitResult::getLocation to get the schematic placement position, which doesn't respect ship-space. - * This mixin conditionally changes it to BlockHitResult::getBlockPos instead which *does* respect ship-space. - * The original behaviour is otherwise not changed. - */ - @Redirect( - method = "updateTargetPos()V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;", - ordinal = 0 - ) - ) - public Vec3 redirectGetLocation(BlockHitResult instance) { - BlockPos b = instance.getBlockPos(); - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, b); - if (ship != null) { - // The return value is used to form a BlockPos, - // so the vec position within a block should not make a difference - return Vec3.atLowerCornerOf(b); - } else { - return instance.getLocation(); - } - } - - /** - * Create chose to... uh... evaluate the player look in the local space of the transform. That means we need to - * mixin toLocalSpace and transform the player position to the ship-space this schematic is on. - * The original behaviour is otherwise not changed. - */ - @WrapOperation( - method = "updateTargetPos", - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/content/schematics/client/SchematicTransformation;toLocalSpace(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - public Vec3 wrapLocalSpaceToShip(SchematicTransformation transformation, Vec3 vec, Operation original) { - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, transformation.getAnchor()); - if (ship != null) { - return original.call(transformation, toMinecraft(ship.getWorldToShip().transformPosition(toJOML(vec)))); - } - - return original.call(transformation, vec); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java deleted file mode 100644 index 5c6d76c84..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.schematics.client.SchematicTransformation; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -/** - * SchematicTransformation is responsible for the render transform of the schematic preview - *

- * Create applies both the camera and schematic positions in the same operation, the latter of which does not respect ship-space. - * This mixin redirects the operation and fixes it by extracting the position components from the argument. - * I can't think of a better way to get around it. - */ -@Mixin(value = {SchematicTransformation.class}, remap = false) -public abstract class MixinSchematicTransformation { - @Shadow - private BlockPos target; - @Shadow - private Vec3 chasingPos; - @Shadow - private Vec3 prevChasingPos; - - @Redirect( - method = {"applyTransformations(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/phys/Vec3;)V"}, - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lnet/minecraft/world/phys/Vec3;)Ljava/lang/Object;", - ordinal = 0 - ) - ) - private Object redirectTranslate(TransformStack instance, Vec3 orig) { - PoseStack ms = (PoseStack)instance; - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, target.getX(), target.getY(), target.getZ()); - - if (ship != null) { - float pt = AnimationTickHolder.getPartialTicks(); - Vec3 pos = VecHelper.lerp(pt, prevChasingPos, chasingPos); - Vec3 camera = pos.subtract(orig); - VSClientGameUtils.transformRenderWithShip(ship.getTransform(), ms, pos.x, pos.y, pos.z, camera.x, camera.y, camera.z); - return instance; - } else { - return instance.translate(orig); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java deleted file mode 100644 index b0aa8caad..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.foundation.sound.SoundScapes; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(SoundScapes.class) -public abstract class MixinSoundScapes { - - @Redirect(method = "outOfRange", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z")) - private static boolean redirectCloserThan(BlockPos instance, Vec3i vec3i, double v) { - Vec3 newVec3 = new Vec3(vec3i.getX(), vec3i.getY(), vec3i.getZ()); - Level world = Minecraft.getInstance().player.level; - final Ship ship = VSGameUtilsKt.getShipManagingPos(world, newVec3); - if (ship != null) { - newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, newVec3); - } - return new Vec3(instance.getX(), instance.getY(), instance.getZ()).closerThan(newVec3, v); - } - - @ModifyVariable(method = "play", at = @At("HEAD"), index = 1, argsOnly = true) - private static BlockPos modBlockPos(BlockPos value) { - BlockPos result = value; - Level world = Minecraft.getInstance().player.level; - final Ship ship = VSGameUtilsKt.getShipManagingPos(world, value); - if (ship != null) { - Vector3d tempVec = new Vector3d(); - ship.getTransform().getShipToWorld().transformPosition(value.getX(), value.getY(), value.getZ(), tempVec); - result = new BlockPos(tempVec.x, tempVec.y, tempVec.z); - } - return result; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java deleted file mode 100644 index 5b15a5eef..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.render.BlockEntityRenderHelper; -import net.minecraft.core.Vec3i; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSClientGameUtils; - -@Mixin(BlockEntityRenderHelper.class) -public abstract class MixinTileEntityRenderHelper { - @Redirect( - method = "renderBlockEntities(Lnet/minecraft/world/level/Level;Lcom/jozufozu/flywheel/core/virtual/VirtualRenderWorld;Ljava/lang/Iterable;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;F)V", - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lnet/minecraft/core/Vec3i;)Ljava/lang/Object;" - ) - ) - private static Object redirectTranslate(final TransformStack instance, final Vec3i vec3i) { - VSClientGameUtils.transformRenderIfInShipyard((PoseStack) instance, vec3i.getX(), vec3i.getY(), vec3i.getZ()); - return instance; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrainRelocator.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrainRelocator.java deleted file mode 100644 index c59d5bf4f..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrainRelocator.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.content.trains.entity.TrainRelocator; -import net.minecraft.client.Minecraft; -import net.minecraft.core.Position; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(TrainRelocator.class) -public abstract class MixinTrainRelocator { - - @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z")) - private static boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { - Vec3 newVec3 = (Vec3) arg; - Level world = Minecraft.getInstance().player.level; - final Ship ship = VSGameUtilsKt.getShipManagingPos(world, arg); - if (ship != null) { - newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, (Vec3) arg); - } - return instance.closerThan(newVec3, d); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java deleted file mode 100644 index acd4792f1..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSClientGameUtils; - -@Mixin(ValueBox.class) -public class MixinValueBox { - - @Shadow - protected BlockPos pos; - - @WrapOperation( - method = "render", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", - ordinal = 0 - ) - ) - public void wrapOpTranslate(final PoseStack instance, final double x, final double y, final double z, final Operation operation) { - final ClientShip ship = VSClientGameUtils.getClientShip(x, y, z); - if (ship != null) { - final var camera = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); - VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, pos.getX(),pos.getY(),pos.getZ(), camera.x, camera.y, camera.z ); - } else { - operation.call(instance, x, y, z); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java deleted file mode 100644 index cc559d91b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines; - -import com.simibubi.create.foundation.block.BigOutlines; -import com.simibubi.create.foundation.utility.RaycastHelper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult.Type; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(BigOutlines.class) -public class MixinBigOutlines { - @Unique - private static boolean valkyrienskies$toShip = false; - - @Unique - private static Ship valkyrienskies$ship; - @Unique - private static Vec3 valkyrienskies$originalOrigin; - - @Inject( - method = "pick", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ), locals = LocalCapture.CAPTURE_FAILHARD - ) - private static void injectPick(final CallbackInfo ci, final Minecraft mc) { - if (mc.hitResult != null && mc.level != null && mc.player != null && mc.hitResult.getType() == Type.BLOCK) { - valkyrienskies$toShip = false; - final boolean playerOnShip = VSGameUtilsKt.isBlockInShipyard(mc.level, mc.player.getOnPos()); - final boolean hitResultOnShip = - VSGameUtilsKt.isBlockInShipyard(mc.level, ((BlockHitResult) mc.hitResult).getBlockPos()); - if (playerOnShip && !hitResultOnShip) { - valkyrienskies$ship = VSGameUtilsKt.getShipManagingPos(mc.level, mc.player.getOnPos()); - //if blockstate is air then transform to ship - valkyrienskies$toShip = mc.level.getBlockState(new BlockPos(mc.hitResult.location)).isAir(); - } else if (hitResultOnShip) { - valkyrienskies$toShip = true; - valkyrienskies$ship = - VSGameUtilsKt.getShipManagingPos(mc.level, ((BlockHitResult) mc.hitResult).getBlockPos()); - } - } - } - - @Redirect( - method = "pick", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ) - ) - private static Vec3 redirectedOrigin(final LocalPlayer instance, final float v) { - final Vec3 eyePos = instance.getEyePosition(v); - if (valkyrienskies$toShip) { - valkyrienskies$originalOrigin = eyePos; - return VectorConversionsMCKt.toMinecraft( - valkyrienskies$ship.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(eyePos))); - } else { - return eyePos; - } - } - - @Redirect( - method = "pick", - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceTarget(Lnet/minecraft/world/entity/player/Player;DLnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ) - ) - private static Vec3 redirectedTarget(final Player playerIn, final double range, final Vec3 origin) { - if (valkyrienskies$toShip) { - return VectorConversionsMCKt.toMinecraft( - valkyrienskies$ship.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML( - RaycastHelper.getTraceTarget(playerIn, range, valkyrienskies$originalOrigin)))); - } else { - return RaycastHelper.getTraceTarget(playerIn, range, origin); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java deleted file mode 100644 index fb9a150e1..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java +++ /dev/null @@ -1,333 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.entity; - -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; - -import com.simibubi.create.AllMovementBehaviours; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.OrientedContraptionEntity; -import com.simibubi.create.content.contraptions.StructureTransform; -import com.simibubi.create.content.contraptions.actors.harvester.HarvesterMovementBehaviour; -import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; -import com.simibubi.create.content.kinetics.deployer.DeployerMovementBehaviour; -import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.core.BlockPos; -import net.minecraft.network.syncher.EntityDataAccessor; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.AbstractMinecart; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; -import net.minecraft.world.phys.Vec3; -import org.apache.commons.lang3.tuple.MutablePair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.joml.Matrix3d; -import org.joml.Matrix4d; -import org.joml.Matrix4dc; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.ContraptionWingProvider; -import org.valkyrienskies.core.api.ships.LoadedServerShip; -import org.valkyrienskies.core.api.ships.LoadedShip; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.core.api.ships.WingManager; -import org.valkyrienskies.mod.common.CompatUtil; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.entity.ShipMountedToData; -import org.valkyrienskies.mod.common.entity.ShipMountedToDataProvider; -import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.compat.CreateConversionsKt; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck; - -@Mixin(AbstractContraptionEntity.class) -public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck, - ContraptionWingProvider, IEntityDraggingInformationProvider, ShipMountedToDataProvider { - - public MixinAbstractContraptionEntity(EntityType entityType, Level level) { - super(entityType, level); - } - - @Shadow - protected abstract StructureTransform makeStructureTransform(); - - public StructureTransform getStructureTransform() { - return this.makeStructureTransform(); - } - - @Unique - private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinAbstractContraptionEntity"); - - @Unique - private int wingGroupId = -1; - - @Shadow(remap = false) - protected Contraption contraption; - - @Shadow - public abstract Vec3 getPassengerPosition(Entity passenger, float partialTicks); - - @Shadow - public abstract Vec3 applyRotation(Vec3 localPos, float partialTicks); - - @Shadow - public abstract Vec3 getAnchorVec(); - - @Shadow - public abstract Vec3 getPrevAnchorVec(); - - @Nullable - @Override - public ShipMountedToData provideShipMountedToData(@NotNull final Entity passenger, @Nullable final Float partialTicks) { - 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)); - return new ShipMountedToData(shipObjectEntityMountedTo, mountedPosInShip); - } - - //Region start - fix being sent to the ̶s̶h̶a̶d̶o̶w̶r̶e̶a̶l̶m̶ shipyard on ship contraption disassembly - @Redirect(method = "moveCollidedEntitiesOnDisassembly", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V")) - private void redirectSetPos(Entity instance, double x, double y, double z) { - Vec3 result = CompatUtil.INSTANCE.toSameSpaceAs(instance.getCommandSenderWorld(), x, y, z, instance.position()); - if (instance.position().distanceTo(result) < 20) { - instance.setPos(result.x, result.y, result.z); - } else LOGGER.warn("Warning distance too high ignoring setPos request"); - } - - @Redirect(method = "moveCollidedEntitiesOnDisassembly", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;teleportTo(DDD)V")) - private void redirectTeleportTo(Entity instance, double x, double y, double z) { - Vec3 result = CompatUtil.INSTANCE.toSameSpaceAs(instance.getCommandSenderWorld(), x, y, z, instance.position()); - if (instance.position().distanceTo(result) < 20) { - if (VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), result.x, result.y, result.z) && instance instanceof AbstractMinecart) { - result.add(0, 0.5, 0); - } - instance.teleportTo(result.x, result.y, result.z); - } else { - LOGGER.warn("Warning distance too high ignoring teleportTo request"); - } - } - - @Inject(method = "toGlobalVector(Lnet/minecraft/world/phys/Vec3;FZ)Lnet/minecraft/world/phys/Vec3;", - at = @At("HEAD"), cancellable = true) - private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, final boolean prevAnchor, final CallbackInfoReturnable cir) { - if (partialTicks != 1 && !prevAnchor) { - final Vec3 anchor = getAnchorVec(); - final Vec3 oldAnchor = getPrevAnchorVec(); - final Vec3 lerpedAnchor = - new Vec3( - Mth.lerp(partialTicks, oldAnchor.x, anchor.x), - Mth.lerp(partialTicks, oldAnchor.y, anchor.y), - Mth.lerp(partialTicks, oldAnchor.z, anchor.z) - ); - final Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); - localVec = localVec.subtract(rotationOffset); - localVec = applyRotation(localVec, partialTicks); - localVec = localVec.add(rotationOffset) - .add(lerpedAnchor); - cir.setReturnValue(localVec); - } - } - - //Region end - //Region start - Ship contraption actors affecting world - @Shadow - public abstract Vec3 toGlobalVector(Vec3 localVec, float partialTicks); - - @Shadow - public abstract Vec3 getPrevPositionVec(); - - @Unique - private boolean vs$shouldMod(final MovementBehaviour moveBehaviour) { - return ((moveBehaviour instanceof BlockBreakingMovementBehaviour) || (moveBehaviour instanceof HarvesterMovementBehaviour) || (moveBehaviour instanceof DeployerMovementBehaviour)); - } - - @Unique - private BlockPos vs$getTargetPos(final MovementBehaviour instance, final MovementContext context, final BlockPos pos, final Vec3 actorPosition) { - if (vs$shouldMod(instance) && context.world.getBlockState(pos).isAir() && VSGameUtilsKt.isBlockInShipyard(context.world, pos)) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(context.world, pos); - if (ship != null) { - final Vector3dc actorPosInWorld = ship.getTransform().getShipToWorld().transformPosition(toJOML(actorPosition)); - return new BlockPos(actorPosInWorld.x(), actorPosInWorld.y(), actorPosInWorld.z()); - } - } - return pos; - } - - @Unique - private boolean vs$forceStall = false; - - @Shadow - private boolean skipActorStop; - - @Shadow - @Final - private static EntityDataAccessor STALLED; - - @Shadow - public abstract boolean isStalled(); - - @Shadow - protected abstract boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor, Vec3 actorPosition, BlockPos gridPosition); - - @Shadow - protected abstract boolean isActorActive(MovementContext context, MovementBehaviour actor); - - @Shadow - protected abstract void onContraptionStalled(); - - @Inject(method = "tickActors", at = @At("HEAD"), cancellable = true, remap = false) - private void preTickActors(final CallbackInfo ci) { - ci.cancel(); - - final boolean stalledPreviously = contraption.stalled; - - if (!level.isClientSide) - contraption.stalled = vs$forceStall; - - skipActorStop = true; - for (final MutablePair pair : contraption.getActors()) { - final MovementContext context = pair.right; - final StructureBlockInfo blockInfo = pair.left; - final MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state); - - if (actor == null) - continue; - - final Vec3 oldMotion = context.motion; - final Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) - .add(actor.getActiveAreaOffset(context)), 1); - final BlockPos gridPosition = vs$getTargetPos(actor, context, new BlockPos(actorPosition), actorPosition); // new BlockPos(actorPosition); - final boolean newPosVisited = - !context.stall && shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition); - - context.rotation = v -> applyRotation(v, 1); - context.position = actorPosition; - if (!isActorActive(context, actor) && !actor.mustTickWhileDisabled()) - continue; - if (newPosVisited && !context.stall) { - actor.visitNewPosition(context, gridPosition); - if (!isAlive()) - break; - context.firstMovement = false; - } - if (!oldMotion.equals(context.motion)) { - actor.onSpeedChanged(context, oldMotion, context.motion); - if (!isAlive()) - break; - } - actor.tick(context); - if (!isAlive()) - break; - contraption.stalled |= context.stall; - } - if (!isAlive()) { - contraption.stop(level); - return; - } - skipActorStop = false; - - for (final Entity entity : getPassengers()) { - if (!(entity instanceof final OrientedContraptionEntity orientedCE)) - continue; - if (contraption.getBearingPosOf(entity.getUUID()) == null) - continue; - if (orientedCE.getContraption() != null && orientedCE.getContraption().stalled) { - contraption.stalled = true; - break; - } - } - - if (!level.isClientSide) { - if (!stalledPreviously && contraption.stalled) - onContraptionStalled(); - entityData.set(STALLED, contraption.stalled); - return; - } - - contraption.stalled = isStalled(); - } - - @Override - public void vs$setForceStall(final boolean forceStall) { - this.vs$forceStall = forceStall; - } - - //Region end - //Region start - Contraption Entity Collision - @Inject(method = "getContactPointMotion", at = @At("HEAD")) - private void modGetContactPointMotion(Vec3 globalContactPoint, CallbackInfoReturnable cir) { - if (VSGameUtilsKt.isBlockInShipyard(level, getAnchorVec().x, getAnchorVec().y, getAnchorVec().z) != VSGameUtilsKt.isBlockInShipyard(level, getPrevAnchorVec().x, getPrevAnchorVec().y, getPrevAnchorVec().z)) { - Ship ship = VSGameUtilsKt.getShipManagingPos(level, getAnchorVec()); - if (ship != null) { - Vec3 result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(getPrevPositionVec()))); - xo = result.x; - yo = result.y; - zo = result.z; - } - } - } - //Region end - - @Override - public int getWingGroupId() { - return wingGroupId; - } - - @Override - public void setWingGroupId(final int wingGroupId) { - this.wingGroupId = wingGroupId; - } - - @Inject(method = "tick", at = @At("HEAD")) - private void postTick(final CallbackInfo ci) { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { - final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, - VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); - if (ship != null) { - try { - // This can happen if a player moves a train contraption from ship to world using a wrench - ship.getAttachment(WingManager.class) - .setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); - } catch (final Exception e) { - // I'm not sure why, but this fails sometimes. For now just catch the error and print it - e.printStackTrace(); - } - } - } - } - - @NotNull - @Override - public Matrix4dc computeContraptionWingTransform() { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Matrix3d rotationMatrix = - CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); - final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); - return new Matrix4d(rotationMatrix).setTranslation(pos); - } - - @Override - public boolean vs$shouldDrag() { - return false; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinCarriageContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinCarriageContraptionEntity.java deleted file mode 100644 index c2031e472..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinCarriageContraptionEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.entity; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; -import java.util.Collection; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Position; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(CarriageContraptionEntity.class) -public abstract class MixinCarriageContraptionEntity { - @Unique - private Level vs$world; - - @Inject( - method = "control", - at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD - ) - private void injectCaptureLevel( - final BlockPos controlsLocalPos, final Collection heldControls, final Player player, - final CallbackInfoReturnable cir) { - this.vs$world = player.level; - } - - @WrapOperation( - method = "control", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z" - ) - ) - private boolean wrapCloserThan(final Vec3 instance, final Position arg, final double d, final Operation closerThan) { - Vec3 newVec3 = instance; - if (VSGameUtilsKt.isBlockInShipyard(this.vs$world, new BlockPos(instance.x, instance.y, instance.z))) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(this.vs$world, instance); - newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); - } - return closerThan.call(newVec3, arg, d); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java deleted file mode 100644 index c8edbc7cc..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.entity; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ControlledContraptionEntity; -import com.simibubi.create.content.contraptions.IControlContraption; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.mixinducks.mod_compat.create.IMixinControlledContraptionEntity; - -@Mixin(ControlledContraptionEntity.class) -public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity implements - IMixinControlledContraptionEntity { - @Shadow protected abstract IControlContraption getController(); - - public MixinControlledContraptionEntity(EntityType entityTypeIn, Level worldIn) { - super(entityTypeIn, worldIn); - } - - //Region start - fix equals -0 != 0 - private Vec3 flatten(Vec3 vec3) { - if (vec3.x == -0) - vec3 = new Vec3(0, vec3.y, vec3.z); - if (vec3.y == -0) - vec3 = new Vec3(vec3.x, 0, vec3.z); - if (vec3.z == -0) - vec3 = new Vec3(vec3.x, vec3.y, 0); - return vec3; - } - - @Redirect(method = "shouldActorTrigger", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;equals(Ljava/lang/Object;)Z")) - private boolean redirectEquals(Vec3 instance, Object vec3) { - Vec3 other = (Vec3) vec3; - other = flatten(other); - instance = flatten(instance); - return instance.equals(other); - } - - //Region end - - @Override - public IControlContraption grabController(){ - return getController(); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java deleted file mode 100644 index a299409d7..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.entity; - -import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(SeatEntity.class) -public abstract class MixinSeatEntity extends Entity { - public MixinSeatEntity(final EntityType entityType, final Level level) { - super(entityType, level); - } - - /** - * @author Triode - * @reason Fix dismount position when ship or seat is destroyed - */ - @Overwrite - public @NotNull Vec3 getDismountLocationForPassenger(final @NotNull LivingEntity livingEntity) { - if (VSGameUtilsKt.isBlockInShipyard(level, position()) && VSGameUtilsKt.getShipManagingPos(level, position()) == null) { - // Don't teleport to the ship if we can't find the ship - return livingEntity.position(); - } - return super.getDismountLocationForPassenger(livingEntity).add(0, 0.5f, 0); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinControlsInputPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinControlsInputPacket.java deleted file mode 100644 index fcebd0771..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinControlsInputPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.packets; - -import com.simibubi.create.content.contraptions.actors.trainControls.ControlsInputPacket; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Position; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ControlsInputPacket.class) -public abstract class MixinControlsInputPacket { - @Unique - private Level level; - - @Redirect( - method = "lambda$handle$0", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z" - ) - ) - private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { - Vec3 newVec3 = instance; - if (VSGameUtilsKt.isBlockInShipyard(this.level, new BlockPos(instance.x, instance.y, instance.z))) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, instance); - newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); - } - return newVec3.closerThan(arg, d); - } - - @Redirect( - method = "lambda$handle$0", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerPlayer;getCommandSenderWorld()Lnet/minecraft/world/level/Level;" - ) - ) - private Level stealLevel(ServerPlayer player) { - return (level = player.getCommandSenderWorld()); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java deleted file mode 100644 index 24763945c..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.packets; - -import com.simibubi.create.content.trains.track.CurvedTrackDestroyPacket; -import com.simibubi.create.content.trains.track.TrackBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Vec3i; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.level.Level; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(CurvedTrackDestroyPacket.class) -public abstract class MixinCurvedTrackDestroyPacket { - @Unique - private Level world; - - @Redirect( - method = "applySettings(Lnet/minecraft/server/level/ServerPlayer;Lcom/simibubi/create/content/trains/track/TrackBlockEntity;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" - ) - ) - private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, final double v) { - BlockPos blockPos = instance; - if (VSGameUtilsKt.isBlockInShipyard(this.world, instance)) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(this.world, instance); - final Vector3d tempVec = VSGameUtilsKt.toWorldCoordinates(ship, instance); - blockPos = new BlockPos(tempVec.x, tempVec.y, tempVec.z); - } - return blockPos.closerThan(vec3i, v); - } - - @Inject( - method = "applySettings(Lnet/minecraft/server/level/ServerPlayer;Lcom/simibubi/create/content/trains/track/TrackBlockEntity;)V", - at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD - ) - private void injectCaptureLevel(final ServerPlayer player, final TrackBlockEntity te, final CallbackInfo ci) { - this.world = player.level; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java deleted file mode 100644 index 3b034986d..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.packets; - -import com.simibubi.create.content.contraptions.glue.SuperGlueRemovalPacket; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(SuperGlueRemovalPacket.class) -public abstract class MixinSuperGlueRemovalPacket { - @Redirect(method = "lambda$handle$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D")) - private double redirectPlayerDistanceToSqr(final ServerPlayer instance, final Vec3 vec3) { - Vec3 newVec3 = vec3; - if (VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(vec3.x, vec3.y, vec3.z))) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, vec3); - if (ship != null) { - newVec3 = VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformPosition(new Vector3d(vec3.x, vec3.y, vec3.z))); - } - } - return instance.distanceToSqr(newVec3); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java deleted file mode 100644 index d1eea4999..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.packets; - -import com.simibubi.create.foundation.networking.BlockEntityConfigurationPacket; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(BlockEntityConfigurationPacket.class) -public abstract class MixinTileEntityConfigurationPacket { - @Unique - private Level _clockworkLevel; - - @Redirect( - method = "lambda$handle$0", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" - ) - ) - private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, final double v) { - BlockPos blockPos = instance; - if (VSGameUtilsKt.isBlockInShipyard(this._clockworkLevel, instance)) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(this._clockworkLevel, instance); - final Vector3d tempVec = VSGameUtilsKt.toWorldCoordinates(ship, instance); - blockPos = new BlockPos(tempVec.x, tempVec.y, tempVec.z); - } - return blockPos.closerThan(vec3i, v); - } - - @Redirect( - method = "lambda$handle$0", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/Level;isLoaded(Lnet/minecraft/core/BlockPos;)Z" - ) - ) - private boolean injectCaptureLevel(final Level instance, final BlockPos pos) { - this._clockworkLevel = instance; - return instance.isLoaded(pos); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java deleted file mode 100644 index c46630797..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.packets; - -import com.simibubi.create.content.trains.entity.TrainRelocationPacket; -import net.minecraft.core.Position; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(TrainRelocationPacket.class) -public abstract class MixinTrainRelocationPacket { - @Unique - private Level level; - - @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z")) - private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { - Vec3 newVec3 = (Vec3) arg; - final Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, arg); - if (ship != null) { - newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, (Vec3) arg); - } - return instance.closerThan(newVec3, d); - } - - @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntity(I)Lnet/minecraft/world/entity/Entity;")) - private Entity stealLevel(Level instance, int i) { - return (level = instance).getEntity(i); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java deleted file mode 100644 index 19d90ac43..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.pr; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.contraptions.actors.seat.SeatBlock; -import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.EntityDraggingInformation; -import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; - -@Mixin(SeatBlock.class) -public abstract class MixinSeatBlock extends Block { - public MixinSeatBlock(final Properties properties) { - super(properties); - } - - /** - * Use doubles instead of floats when invoking setPos() - */ - @WrapOperation(method = "sitDown", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/actors/seat/SeatEntity;setPos(DDD)V")) - private static void wrapSitDownSetPos(final SeatEntity seatEntity, final double origX, final double origY, final double origZ, final Operation setPosOperation, final Level world, final BlockPos pos, final Entity entity) { - setPosOperation.call(seatEntity, pos.getX() + .5, (double) pos.getY(), pos.getZ() + .5); - } - - /** - * @author Triode - * @reason Fix entities not sitting in seats on ships - */ - @WrapOperation( - method = "updateEntityAfterFallOn", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - ) - ) - private BlockPos wrapBlockPosInUpdateEntityAfterFallOn( - final Entity entity, - final Operation getBlockPosition - ) { - final EntityDraggingInformation draggingInformation = ((IEntityDraggingInformationProvider) entity).getDraggingInformation(); - if (draggingInformation.isEntityBeingDraggedByAShip()) { - final Long shipStandingOnId = draggingInformation.getLastShipStoodOn(); - if (shipStandingOnId != null) { - final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId); - if (ship != null) { - final Vector3dc posInShip = ship.getTransform().getWorldToShip() - .transformPosition(entity.getX(), entity.getY(), entity.getZ(), new Vector3d()); - return new BlockPos(posInShip.x(), posInShip.y(), posInShip.z()); - } - } - } - return getBlockPosition.call(entity); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinPitchOrientedContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinPitchOrientedContraptionEntity.java deleted file mode 100644 index fd88191d2..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinPitchOrientedContraptionEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons; - -import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; - -import com.simibubi.create.content.contraptions.OrientedContraptionEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.Nullable; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Pseudo -@Mixin(targets = "rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity") -public abstract class MixinPitchOrientedContraptionEntity extends OrientedContraptionEntity { - - @Shadow - private BlockPos controllerPos; - - public MixinPitchOrientedContraptionEntity(final EntityType type, - final Level world) { - super(type, world); - } - - @Inject(method = "processRiderPositionHook", at = @At("HEAD"), cancellable = true, remap = false) - protected void vsProcesssRiderPositionHook( - final Entity passenger, @Nullable Vec3 original, final CallbackInfoReturnable ci) { - - if (original != null && controllerPos != null) { - final Vector3d editOriginal = VectorConversionsMCKt.toJOML(original); - - final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level, controllerPos); - - if (ship != null) { - ship.getShipToWorld().transformPosition(editOriginal); - - original = VectorConversionsMCKt.toMinecraft(editOriginal).add(0.5, 1, 0.5) - .subtract(0, passenger.getEyeHeight(), 0); - ci.setReturnValue(original); - } - } - } - - @Inject(method="getPassengerPosition", at = @At("RETURN"), cancellable = true, remap = false) - protected void vsGetPassengerPosition(Entity passenger, float partialTicks, CallbackInfoReturnable cir) { - if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())) != null) { - cir.setReturnValue(cir.getReturnValue().add(0,0.1,0)); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java deleted file mode 100644 index dc644a299..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.flywheel; - -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import net.minecraft.core.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Pseudo -@Mixin(value = InstancingEngine.class, remap = false) -public interface InstancingEngineAccessor { - @Accessor - void setOriginCoordinate(BlockPos pos); - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java deleted file mode 100644 index e3408c46f..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.flywheel; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.Instance; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.instancing.InstanceManager; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import com.jozufozu.flywheel.backend.instancing.RenderDispatcher; -import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import com.jozufozu.flywheel.config.BackendType; -import com.jozufozu.flywheel.core.Contexts; -import java.util.WeakHashMap; -import javax.annotation.ParametersAreNonnullByDefault; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import org.joml.Vector3i; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; - -@Pseudo -@Mixin(value = BlockEntityInstanceManager.class) -@ParametersAreNonnullByDefault -public abstract class MixinBlockEntityInstanceManager extends InstanceManager implements - MixinBlockEntityInstanceManagerDuck { - - @Unique - private final WeakHashMap vs$shipMaterialManagers = - new WeakHashMap<>(); - - public MixinBlockEntityInstanceManager(final MaterialManager materialManager) { - super(materialManager); - } - - @Inject( - method = "createRaw(Lnet/minecraft/world/level/block/entity/BlockEntity;)Lcom/jozufozu/flywheel/backend/instancing/AbstractInstance;", - at = @At("HEAD"), - cancellable = true - ) - void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable cir) { - - final Level nullableLevel = blockEntity.getLevel(); - if (nullableLevel instanceof final ClientLevel level) { - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos( - level, blockEntity.getBlockPos()); - if (ship != null) { - final MaterialManager manager = - vs$shipMaterialManagers.computeIfAbsent(ship, k -> vs$createMaterialManager()); - final Vector3i c = - ship.getChunkClaim().getCenterBlockCoordinates(VSGameUtilsKt.getYRange(nullableLevel), new Vector3i()); - if (manager instanceof InstancingEngineAccessor) - ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); - - cir.setReturnValue(InstancedRenderRegistry.createInstance(manager, blockEntity)); - } - } - } - - @Override - public WeakHashMap vs$getShipMaterialManagers() { - return vs$shipMaterialManagers; - } - - @Override - public void vs$removeShipManager(final ClientShip clientShip) { - final MaterialManager removed = vs$shipMaterialManagers.remove(clientShip); - if (removed instanceof final RenderDispatcher removedRenderer) { - removedRenderer.delete(); - } - } - - @Unique - private MaterialManager vs$createMaterialManager() { - if (Backend.getBackendType() == BackendType.INSTANCING) { - return InstancingEngine.builder(Contexts.WORLD).build(); - } else if (Backend.getBackendType() == BackendType.BATCHING) { - return new BatchingEngine(); - } else { - throw new IllegalArgumentException("Unknown engine type"); - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java deleted file mode 100644 index 1418ee7ce..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.flywheel; - -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.api.instance.TickableInstance; -import com.jozufozu.flywheel.backend.instancing.InstanceManager; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Pseudo -@Mixin(InstanceManager.class) -public class MixinInstanceManager { - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/api/instance/DynamicInstance;getWorldPosition()Lnet/minecraft/core/BlockPos;" - ), - method = "*" - ) - private BlockPos redirectGetWorldPos1(final DynamicInstance receiver) { - final Vector3d v = VSGameUtilsKt.getWorldCoordinates( - Minecraft.getInstance().level, - receiver.getWorldPosition(), - VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition()) - ); - - return new BlockPos(v.x, v.y, v.z); - } - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/api/instance/TickableInstance;getWorldPosition()Lnet/minecraft/core/BlockPos;" - ), - method = "*" - ) - private BlockPos redirectGetWorldPos2(final TickableInstance receiver) { - final Vector3d v = VSGameUtilsKt.getWorldCoordinates(Minecraft.getInstance().level, - receiver.getWorldPosition(), - VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition())); - - return new BlockPos(v.x, v.y, v.z); - } - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java deleted file mode 100644 index a66ba50c8..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.flywheel; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.gl.GlStateTracker; -import com.jozufozu.flywheel.backend.instancing.InstanceManager; -import com.jozufozu.flywheel.backend.instancing.InstanceWorld; -import com.jozufozu.flywheel.backend.instancing.ParallelTaskEngine; -import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.mojang.math.Matrix4f; -import net.minecraft.world.level.block.entity.BlockEntity; -import org.joml.Matrix4d; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.compat.FlywheelEvents; -import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; -import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; - -@Pseudo -@Mixin(value = InstanceWorld.class, remap = false) -public class MixinInstanceWorld { - - @Shadow - @Final - protected InstanceManager blockEntityInstanceManager; - - @Shadow - @Final - public ParallelTaskEngine taskEngine; - - @Inject( - method = "renderLayer", - at = @At( - value = "INVOKE", - target = "Lcom/jozufozu/flywheel/backend/instancing/Engine;render(Lcom/jozufozu/flywheel/backend/instancing/TaskEngine;Lcom/jozufozu/flywheel/event/RenderLayerEvent;)V" - ) - ) - void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { - //not sure if restoreState stuff should be here or in the ((MixinInstancingEngineDuck) manager).render() method - final GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); - final var shipManagers = - ((MixinBlockEntityInstanceManagerDuck) blockEntityInstanceManager).vs$getShipMaterialManagers(); - - shipManagers.forEach((ship, manager) -> vs$render(ship, manager, event)); - restoreState.restore(); - } - - @Unique - private void vs$render(final ClientShip ship, final MaterialManager manager, final RenderLayerEvent event) { - if (manager instanceof final InstancingEngine engine) { - final Vector3d origin = VectorConversionsMCKt.toJOMLD(engine.getOriginCoordinate()); - - final Matrix4d viewProjection = VectorConversionsMCKt.toJOML(event.viewProjection); - - final Matrix4d finalProjection = new Matrix4d() - .mul(viewProjection) - .translate(-event.camX, -event.camY, -event.camZ) - .mul(ship.getRenderTransform().getShipToWorld()) - .translate(origin); - - final Vector3d camInShipLocal = ship.getRenderTransform().getWorldToShip() - .transformPosition(event.camX, event.camY, event.camZ, new Vector3d()) - .sub(origin); - - final Matrix4f fnlProj = VectorConversionsMCKt.toMinecraft(finalProjection); - - ((MixinInstancingEngineDuck) engine).vs$render( - fnlProj, - camInShipLocal.x, - camInShipLocal.y, - camInShipLocal.z, - event.layer - ); - } else if (manager instanceof final BatchingEngine engine) { - event.stack.pushPose(); - VSClientGameUtils.multiplyWithShipToWorld(event.stack, ship); - engine.render(taskEngine, event); - event.stack.popPose(); - } else { - throw new IllegalArgumentException("unrecognized engine"); - } - } - - @Inject(method = "", at = @At("RETURN")) - private void postInit(final CallbackInfo ci) { - FlywheelEvents.onInstanceWorldLoad(InstanceWorld.class.cast(this)); - } - - @Inject(method = "delete", at = @At("RETURN")) - private void postDelete(final CallbackInfo ci) { - FlywheelEvents.onInstanceWorldUnload(InstanceWorld.class.cast(this)); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java deleted file mode 100644 index cb843a8fd..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.flywheel; - -import com.jozufozu.flywheel.backend.RenderLayer; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import com.jozufozu.flywheel.core.shader.WorldProgram; -import com.mojang.math.Matrix4f; -import java.util.stream.Stream; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; - -@Pseudo -@Mixin(value = InstancingEngine.class, remap = false) -public abstract class MixinInstancingEngine

implements MixinInstancingEngineDuck { - @Shadow - protected abstract Stream> getGroupsToRender(@Nullable RenderLayer layer); - - @Override - public void vs$render(final Matrix4f viewProjection, final double camX, final double camY, final double camZ, - final RenderLayer layer) { - this.getGroupsToRender(layer).forEach(g -> g.render(viewProjection, camX, camY, camZ, layer)); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java index 43f3bd67d..544e33716 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java @@ -48,7 +48,7 @@ public abstract class MixinClaimedChunkManager { } final Vector3d vec = ship.getShipToWorld().transformPosition(new Vector3d(pos.getX(), pos.getY(), pos.getZ())); - final BlockPos newPos = new BlockPos(VectorConversionsMCKt.toMinecraft(vec)); + final BlockPos newPos = BlockPos.containing(VectorConversionsMCKt.toMinecraft(vec)); if ( (newPos.getY() > level.getMaxBuildHeight() || newPos.getY() < level.getMinBuildHeight()) && diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinViewAreaOptifine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinViewAreaOptifine.java index 5198789ea..965d69457 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinViewAreaOptifine.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinViewAreaOptifine.java @@ -89,9 +89,9 @@ private void preScheduleRebuild(final int x, final int y, final int z, final boo @Inject(method = "getRenderChunkAt", at = @At("HEAD"), cancellable = true) private void preGetRenderedChunk(final BlockPos pos, final CallbackInfoReturnable callbackInfoReturnable) { - final int chunkX = Mth.intFloorDiv(pos.getX(), 16); - final int chunkY = Mth.intFloorDiv(pos.getY(), 16); - final int chunkZ = Mth.intFloorDiv(pos.getZ(), 16); + final int chunkX = Mth.floorDiv(pos.getX(), 16); + final int chunkY = Mth.floorDiv(pos.getY(), 16); + final int chunkZ = Mth.floorDiv(pos.getZ(), 16); if (chunkY < 0 || chunkY >= chunkGridSizeY) { return; // Weird, but ignore it diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine_vanilla/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine_vanilla/MixinLevelRenderer.java index 56dd49216..8e58f1908 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine_vanilla/MixinLevelRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine_vanilla/MixinLevelRenderer.java @@ -3,7 +3,6 @@ import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.GameRenderer; @@ -16,6 +15,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java deleted file mode 100644 index d6f48d905..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.reachentityattributes; - -import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(ReachEntityAttributes.class) -public class MixinReachEntityAttributes { - @Shadow - public static double getReachDistance(final LivingEntity entity, final double baseReachDistance) { - return 0.0; - } - - /** - * @author Triode - * @reason Fix getting players within reach of ship blocks - */ - @Overwrite - public static List getPlayersWithinReach(final Predicate viewerPredicate, final Level world, final int x, final int y, final int z, final double baseReachDistance) { - final List playersWithinReach = new ArrayList<>(0); - for (final Player player : world.players()) { - if (viewerPredicate.test(player)) { - final var reach = getReachDistance(player, baseReachDistance); - if (VSGameUtilsKt.squaredDistanceBetweenInclShips(world, x + 0.5, y + 0.5, z + 0.5, player.getX(), player.getEyeY(), player.getZ()) <= (reach * reach)) { - playersWithinReach.add(player); - } - } - } - return playersWithinReach; - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinLevelRendererVanilla.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinLevelRendererVanilla.java index 2d4f7be96..39e1c97ee 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinLevelRendererVanilla.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinLevelRendererVanilla.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexBuffer; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.ListIterator; @@ -28,6 +26,7 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import org.joml.Vector3dc; import org.joml.primitives.AABBd; import org.spongepowered.asm.mixin.Final; @@ -175,7 +174,7 @@ private void clearShipChunks(final CallbackInfo ci) { @WrapOperation( at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V" + target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V" ), method = "*" ) @@ -303,7 +302,7 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS } if (uniform != null) { - uniform.set(Vector3f.ZERO); + uniform.set(0, 0, 0); } shaderInstance.clear(); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinViewAreaVanilla.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinViewAreaVanilla.java index 0d18a2c02..856565a68 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinViewAreaVanilla.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinViewAreaVanilla.java @@ -87,9 +87,9 @@ private void preScheduleRebuild(final int x, final int y, final int z, final boo @Inject(method = "getRenderChunkAt", at = @At("HEAD"), cancellable = true) private void preGetRenderedChunk(final BlockPos pos, final CallbackInfoReturnable callbackInfoReturnable) { - final int chunkX = Mth.intFloorDiv(pos.getX(), 16); - final int chunkY = Mth.intFloorDiv(pos.getY() - level.getMinBuildHeight(), 16); - final int chunkZ = Mth.intFloorDiv(pos.getZ(), 16); + final int chunkX = Mth.floorDiv(pos.getX(), 16); + final int chunkY = Mth.floorDiv(pos.getY() - level.getMinBuildHeight(), 16); + final int chunkZ = Mth.floorDiv(pos.getZ(), 16); if (chunkY < 0 || chunkY >= chunkGridSizeY) { return; // Weird, but ignore it diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinMinecraftServer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinMinecraftServer.java index c3ff37678..1955e9f81 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinMinecraftServer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinMinecraftServer.java @@ -13,6 +13,7 @@ import net.minecraft.BlockUtil.FoundRectangle; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -30,7 +31,10 @@ import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.portal.PortalInfo; import net.minecraft.world.level.portal.PortalShape; +import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.Vector3d; @@ -252,8 +256,8 @@ private void handleShipPortals() { final ServerLevel level = dimensionToLevelMap.get(shipObject.getChunkClaimDimension()); final Vector3dc shipPos = shipObject.getTransform().getPositionInWorld(); final double bbRadius = 0.5; - final BlockPos blockPos = new BlockPos(shipPos.x() - bbRadius, shipPos.y() - bbRadius, shipPos.z() - bbRadius); - final BlockPos blockPos2 = new BlockPos(shipPos.x() + bbRadius, shipPos.y() + bbRadius, shipPos.z() + bbRadius); + final BlockPos blockPos = BlockPos.containing(shipPos.x() - bbRadius, shipPos.y() - bbRadius, shipPos.z() - bbRadius); + final BlockPos blockPos2 = BlockPos.containing(shipPos.x() + bbRadius, shipPos.y() + bbRadius, shipPos.z() + bbRadius); // Only run this code if the chunks between blockPos and blockPos2 are loaded if (level.hasChunksAt(blockPos, blockPos2)) { shipObject.decayPortalCoolDown(); @@ -349,10 +353,48 @@ private PortalInfo findDimensionEntryPoint(@NotNull final ServerLevel srcLevel, axis = Direction.Axis.X; vec3 = new Vec3(0.5, 0.0, 0.0); } - return PortalShape.createPortalInfo(destLevel, foundRectangle, axis, vec3, entityDimensions, deltaMovement, 0.0f, 0.0f); + // originally PortalShape.createPortalInfo + return createPortalInfo(destLevel, foundRectangle, axis, vec3, entityDimensions, deltaMovement); }).orElse(null); } + @Unique + private static PortalInfo createPortalInfo(final ServerLevel serverLevel, final BlockUtil.FoundRectangle foundRectangle, final Direction.Axis axis, final Vec3 vec3, final EntityDimensions entityDimensions, final Vec3 vec32) { + final BlockPos blockPos = foundRectangle.minCorner; + final BlockState blockState = serverLevel.getBlockState(blockPos); + final Direction.Axis axis2 = blockState.getOptionalValue(BlockStateProperties.HORIZONTAL_AXIS).orElse( + Axis.X); + final double d = foundRectangle.axis1Size; + final double e = foundRectangle.axis2Size; + final int i = axis == axis2 ? 0 : 90; + final Vec3 vec33 = axis == axis2 ? vec32 : new Vec3(vec32.z, vec32.y, -vec32.x); + final double h = (double)entityDimensions.width / 2.0 + (d - (double)entityDimensions.width) * vec3.x(); + final double j = (e - (double)entityDimensions.height) * vec3.y(); + final double k = 0.5 + vec3.z(); + final boolean bl = axis2 == Axis.X; + final Vec3 vec34 = new Vec3((double)blockPos.getX() + (bl ? h : k), (double)blockPos.getY() + j, (double)blockPos.getZ() + (bl ? k : h)); + final Vec3 vec35 = findCollisionFreePosition(vec34, serverLevel, entityDimensions); + return new PortalInfo(vec35, vec33, (float)i, 0); + } + + @Unique + private static Vec3 findCollisionFreePosition(final Vec3 vec3, final ServerLevel serverLevel, final EntityDimensions entityDimensions) { + if (!(entityDimensions.width > 4.0F) && !(entityDimensions.height > 4.0F)) { + double d = (double)entityDimensions.height / 2.0; + final Vec3 vec32 = vec3.add(0.0, d, 0.0); + final VoxelShape voxelShape = Shapes.create( + AABB.ofSize(vec32, entityDimensions.width, 0.0, entityDimensions.width).expandTowards(0.0, 1.0, 0.0).inflate(1.0E-6)); + final Optional optional = serverLevel.findFreePosition(null, voxelShape, vec32, entityDimensions.width, entityDimensions.height, + entityDimensions.width); + final Optional optional2 = optional.map((vec3x) -> { + return vec3x.subtract(0.0, d, 0.0); + }); + return optional2.orElse(vec3); + } else { + return vec3; + } + } + @Unique private Vec3 getRelativePortalPosition(final Direction.Axis axis, final BlockUtil.FoundRectangle foundRectangle, final EntityDimensions entityDimensions, final Vec3 position) { return PortalShape.getRelativePosition(foundRectangle, axis, position, entityDimensions); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerGamePacketListenerImpl.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerGamePacketListenerImpl.java index e92553a08..7a7ee0274 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerGamePacketListenerImpl.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerGamePacketListenerImpl.java @@ -14,6 +14,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.world.entity.RelativeMovement; import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; @@ -139,13 +140,13 @@ private boolean shouldSkipMoveCheck(final ServerPlayerGameMode instance, cancellable = true ) private void transformTeleport(final double x, final double y, final double z, final float yaw, final float pitch, - final Set relativeSet, final CallbackInfo ci) { + final Set relativeSet, final CallbackInfo ci) { if (!VSGameConfig.SERVER.getTransformTeleports()) { return; } - final BlockPos blockPos = new BlockPos(x, y, z); + final BlockPos blockPos = BlockPos.containing(x, y, z); final ServerShip ship = VSGameUtilsKt.getShipManagingPos((ServerLevel) player.level, blockPos); // TODO add flag to disable this https://github.com/ValkyrienSkies/Valkyrien-Skies-2/issues/30 @@ -162,7 +163,7 @@ private void transformTeleport(final double x, final double y, final double z, f this.send( new ClientboundPlayerPositionPacket(pos.x, pos.y, pos.z, yaw, pitch, Collections.emptySet(), - awaitingTeleport, false)); + awaitingTeleport)); ci.cancel(); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/chunk/MixinLevelChunk.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/chunk/MixinLevelChunk.java index c1b6d962c..7eeb6224d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/chunk/MixinLevelChunk.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/chunk/MixinLevelChunk.java @@ -5,6 +5,7 @@ import java.util.Set; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; @@ -85,7 +86,7 @@ public void clearChunk() { // Set terrain to empty heightmaps.clear(); Arrays.fill(sections, null); - final Registry registry = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + final Registry registry = level.registryAccess().registryOrThrow(Registries.BIOME); for (int i = 0; i < sections.length; ++i) { if (sections[i] != null) continue; sections[i] = new LevelChunkSection(levelHeightAccessor.getSectionYFromSectionIndex(i), registry); @@ -122,7 +123,7 @@ public void copyChunkFromOtherDimension(@NotNull final VSLevelChunk srcChunkVS) for (int i = 0; i < sections.length; i++) { sections[i] = protoChunk.getSection(i); } - final Registry registry = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + final Registry registry = level.registryAccess().registryOrThrow(Registries.BIOME); for (int i = 0; i < sections.length; ++i) { if (sections[i] != null) continue; sections[i] = new LevelChunkSection(levelHeightAccessor.getSectionYFromSectionIndex(i), registry); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java deleted file mode 100644 index 00be12a98..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.valkyrienskies.mod.mixinducks; - -import com.jozufozu.flywheel.api.MaterialManager; -import java.util.WeakHashMap; -import org.valkyrienskies.core.api.ships.ClientShip; - -public interface MixinBlockEntityInstanceManagerDuck { - - WeakHashMap vs$getShipMaterialManagers(); - - void vs$removeShipManager(ClientShip clientShip); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java deleted file mode 100644 index ff8cb7cf7..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.valkyrienskies.mod.mixinducks; - -import com.jozufozu.flywheel.backend.RenderLayer; -import com.mojang.math.Matrix4f; - -public interface MixinInstancingEngineDuck { - void vs$render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java index 162811d5f..0091c4bb9 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixinducks.mod_compat.bluemap; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; public interface WorldDuck { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java deleted file mode 100644 index 4aada2a8b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import com.simibubi.create.foundation.utility.Iterate; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; - -/** - * This class only exists because Creates Cluster class is private, and I can't get an access widener to work on it >.< - */ -public class CWCluster { - public BlockPos anchor; - public final Map visibleFaces; - public final Set visibleEdges; - - public CWCluster() { - visibleEdges = new HashSet<>(); - visibleFaces = new HashMap<>(); - } - - public boolean isEmpty() { - return anchor == null; - } - - public void include(BlockPos pos) { - if (anchor == null) - anchor = pos; - - pos = pos.subtract(anchor); - - // 6 FACES - for (Direction.Axis axis : Iterate.axes) { - Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis); - for (int offset : Iterate.zeroAndOne) { - CWMergeEntry entry = new CWMergeEntry(axis, pos.relative(direction, offset)); - if (visibleFaces.remove(entry) == null) - visibleFaces.put(entry, offset == 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE); - } - } - - // 12 EDGES - for (Direction.Axis axis : Iterate.axes) { - for (Direction.Axis axis2 : Iterate.axes) { - if (axis == axis2) - continue; - for (Direction.Axis axis3 : Iterate.axes) { - if (axis == axis3) - continue; - if (axis2 == axis3) - continue; - - Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis2); - Direction direction2 = Direction.get(Direction.AxisDirection.POSITIVE, axis3); - - for (int offset : Iterate.zeroAndOne) { - BlockPos entryPos = pos.relative(direction, offset); - for (int offset2 : Iterate.zeroAndOne) { - entryPos = entryPos.relative(direction2, offset2); - CWMergeEntry entry = new CWMergeEntry(axis, entryPos); - if (!visibleEdges.remove(entry)) - visibleEdges.add(entry); - } - } - } - - break; - } - } - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java deleted file mode 100644 index 7029d1172..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; - -/** - * This class only exists because Creates MergeEntry class is private, and I can't get an access widener to work on it >.< - */ -public class CWMergeEntry { - public final Direction.Axis axis; - public final BlockPos pos; - - public CWMergeEntry(Direction.Axis axis, BlockPos pos) { - this.axis = axis; - this.pos = pos; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof CWMergeEntry other)) - return false; - - return this.axis == other.axis && this.pos.equals(other.pos); - } - - @Override - public int hashCode() { - return this.pos.hashCode() * 31 + axis.ordinal(); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java deleted file mode 100644 index 0b7f04184..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; -import org.valkyrienskies.core.api.ships.Ship; - -public interface IExtendedAirCurrentSource extends IAirCurrentSource { - - Ship getShip(); - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java deleted file mode 100644 index 9c8214d43..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import com.simibubi.create.content.contraptions.IControlContraption; - -public interface IMixinControlledContraptionEntity { - IControlContraption grabController(); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java deleted file mode 100644 index ca09a4ed9..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -public interface IMixinStickerTileEntity { - - boolean isAlreadyPowered(boolean reset); -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java deleted file mode 100644 index b7eca7b8b..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import com.simibubi.create.content.contraptions.StructureTransform; - -public interface MixinAbstractContraptionEntityDuck { - void vs$setForceStall(boolean forceStall); - - StructureTransform getStructureTransform(); -} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt index 2fa8f8e04..093a1d425 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -17,6 +17,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipObjectClientWorld import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.entity.VSPhysicsEntity +import org.valkyrienskies.mod.common.util.toFloat import org.valkyrienskies.mod.common.util.toMinecraft import java.util.Random @@ -51,10 +52,10 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR val offsetZ = renderTransform.positionInWorld.z() - expectedZ poseStack.pushPose() - val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) + val blockPos = BlockPos(fallingBlockEntity.x.toInt(), fallingBlockEntity.boundingBox.maxY.toInt(), fallingBlockEntity.z.toInt()) poseStack.translate(offsetX, offsetY, offsetZ) - poseStack.mulPose(renderTransform.shipToWorldRotation.toMinecraft()) + poseStack.mulPose(renderTransform.shipToWorldRotation.toFloat()) poseStack.translate(-0.5, -0.5, -0.5) val blockRenderDispatcher = Minecraft.getInstance().blockRenderer blockRenderDispatcher.modelRenderer.tesselateBlock( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt index 9178dfb7a..a2a5f0128 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -38,7 +38,7 @@ object BlockStateInfo { val REGISTRY = MappedRegistry( ResourceKey.createRegistryKey(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "blockstate_providers")), Lifecycle.experimental(), - null + false ) private lateinit var SORTED_REGISTRY: List diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt index 116d3658c..5c9508fd7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt @@ -8,7 +8,6 @@ import org.joml.Matrix4f import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ShipTransform import org.valkyrienskies.mod.common.util.multiply -import com.mojang.math.Matrix4f as Matrix4fMC object VSClientGameUtils { @@ -66,29 +65,6 @@ object VSClientGameUtils { poseStack.multiply(renderMatrix, renderTransform.shipToWorldRotation) } - @JvmStatic - fun transformRenderWithShip( - renderTransform: ShipTransform, - matrix: Matrix4fMC, - offsetX: Double, - offsetY: Double, - offsetZ: Double, - camX: Double, - camY: Double, - camZ: Double - ) { - val shipToWorldMatrix = renderTransform.shipToWorld - - // Create the render matrix from the render transform and player position - val renderMatrix = Matrix4d() - renderMatrix.translate(-camX, -camY, -camZ) - renderMatrix.mul(shipToWorldMatrix) - renderMatrix.translate(offsetX, offsetY, offsetZ) - - // Multiply the last transform of [poseStack] by [shipToWorldMatrix] - matrix.multiply(renderMatrix) - } - @JvmStatic fun transformRenderWithShip( renderTransform: ShipTransform, diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt index 8c4160db7..796e76e49 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -76,8 +76,10 @@ val Level.dimensionId: DimensionId return dimensionId } +private val levelResourceKeyMap: MutableMap> = HashMap() + fun getResourceKey(dimensionId: DimensionId): ResourceKey { - @Suppress("UNCHECKED_CAST") val cached = ResourceKeyAccessor.getValues()[dimensionId] as ResourceKey? + val cached = levelResourceKeyMap[dimensionId] if (cached == null) { val (registryNamespace, registryName, namespace, name) = dimensionId.split(":") return ResourceKeyAccessor.callCreate( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSEntityHandlerDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSEntityHandlerDataLoader.kt index 9279b6aea..6ea7d043b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSEntityHandlerDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSEntityHandlerDataLoader.kt @@ -2,7 +2,7 @@ package org.valkyrienskies.mod.common.config import com.google.gson.Gson import com.google.gson.JsonElement -import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener @@ -20,7 +20,7 @@ object VSEntityHandlerDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_ list.forEach { (l, v) -> try { - val type = Registry.ENTITY_TYPE.getOptional(l).orElse(null) ?: return@forEach + val type = BuiltInRegistries.ENTITY_TYPE.getOptional(l).orElse(null) ?: return@forEach val handler = VSEntityManager.getHandler(ResourceLocation(v.asJsonObject.get("handler").asString)) ?: throw Exception("Handler not found") diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSMassDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSMassDataLoader.kt index 6ec62527c..c3291e765 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSMassDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSMassDataLoader.kt @@ -4,7 +4,8 @@ import com.google.gson.Gson import com.google.gson.JsonElement import net.minecraft.core.BlockPos import net.minecraft.core.HolderSet -import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener @@ -64,7 +65,7 @@ object MassDatapackResolver : BlockStateInfoProvider { get() = 100 override fun getBlockStateMass(blockState: BlockState): Double? = - map[Registry.BLOCK.getKey(blockState.block)]?.mass + map[BuiltInRegistries.BLOCK.getKey(blockState.block)]?.mass override fun getBlockStateType(blockState: BlockState): BlockType? { val vsState = mcBlockStateToVs[blockState] ?: return null @@ -103,7 +104,7 @@ object MassDatapackResolver : BlockStateInfoProvider { VSGameEvents.tagsAreLoaded.on { _, _ -> tags.forEach { tagInfo -> val tag: Optional>? = - Registry.BLOCK.getTag(TagKey.create(Registry.BLOCK_REGISTRY, tagInfo.id)) + BuiltInRegistries.BLOCK.getTag(TagKey.create(Registries.BLOCK, tagInfo.id)) if (tag != null) { if (!tag.isPresent()) { @@ -114,7 +115,7 @@ object MassDatapackResolver : BlockStateInfoProvider { tag.get().forEach { add( VSBlockStateInfo( - Registry.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.friction, + BuiltInRegistries.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.friction, tagInfo.elasticity, tagInfo.type ) ) @@ -351,7 +352,7 @@ object MassDatapackResolver : BlockStateInfoProvider { generated ?: fullBlockCollisionShape } - val vsBlockStateInfo = map[Registry.BLOCK.getKey(blockState.block)] + val vsBlockStateInfo = map[BuiltInRegistries.BLOCK.getKey(blockState.block)] // Create new solid block state val solidState = vsCore.newSolidStateBuilder() diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountingEntity.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountingEntity.kt index 34da4e64b..b6b58ac5e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountingEntity.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountingEntity.kt @@ -3,6 +3,7 @@ package org.valkyrienskies.mod.common.entity import net.minecraft.client.Minecraft import net.minecraft.nbt.CompoundTag import net.minecraft.network.protocol.Packet +import net.minecraft.network.protocol.game.ClientGamePacketListener import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType @@ -101,11 +102,15 @@ open class ShipMountingEntity(type: EntityType, level: Level } } - override fun getControllingPassenger(): Entity? { - return if (isController) this.passengers.getOrNull(0) else null + override fun getControllingPassenger(): LivingEntity? { + return if (isController) { + this.passengers.getOrNull(0) as? LivingEntity + } else { + null + } } - override fun getAddEntityPacket(): Packet<*> { + override fun getAddEntityPacket(): Packet { return ClientboundAddEntityPacket(this) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt index 9adbc52d4..56c84b4c1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt @@ -5,6 +5,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import net.minecraft.core.Rotations import net.minecraft.nbt.CompoundTag import net.minecraft.network.protocol.Packet +import net.minecraft.network.protocol.game.ClientGamePacketListener import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.network.syncher.EntityDataAccessor import net.minecraft.network.syncher.EntityDataSerializers @@ -122,7 +123,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En override fun addAdditionalSaveData(compoundTag: CompoundTag) { } - override fun getAddEntityPacket(): Packet<*> { + override fun getAddEntityPacket(): Packet { return ClientboundAddEntityPacket(this) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt index 6e985e016..e47476889 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt @@ -7,6 +7,7 @@ import net.minecraft.world.entity.Entity import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.mod.common.util.toFloat import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft @@ -35,7 +36,7 @@ abstract class AbstractShipyardEntityHandler : VSEntityHandler { val scale = transform.shipToWorldScaling matrixStack.translate(transformed.x + camX, transformed.y + camY, transformed.z + camZ) - matrixStack.mulPose(transform.shipToWorldRotation.toMinecraft()) + matrixStack.mulPose(transform.shipToWorldRotation.toFloat()) matrixStack.scale(scale.x().toFloat(), scale.y().toFloat(), scale.z().toFloat()) matrixStack.translate(offset.x, offset.y, offset.z) } @@ -53,6 +54,6 @@ abstract class AbstractShipyardEntityHandler : VSEntityHandler { ) { // TODO: somewhere else position is already applied in the matrix stack // EW: i think it was in entity dragging logic - matrixStack.mulPose(ship.renderTransform.shipToWorldRotation.toMinecraft()) + matrixStack.mulPose(ship.renderTransform.shipToWorldRotation.toFloat()) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityManager.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityManager.kt index f7ac714cc..74f631174 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityManager.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityManager.kt @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.common.entity.handling import com.google.common.cache.CacheBuilder -import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType @@ -9,7 +9,6 @@ import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.networking.PacketSyncVSEntityTypes import org.valkyrienskies.mod.common.util.MinecraftPlayer import org.valkyrienskies.mod.common.vsCore -import org.valkyrienskies.mod.compat.CreateCompat import java.time.Duration import kotlin.text.RegexOption.IGNORE_CASE @@ -56,9 +55,6 @@ object VSEntityManager { } fun getHandler(entity: Entity): VSEntityHandler { - if (CreateCompat.isContraption(entity)) { - return contraptionHandler - } return entityHandlers[entity.type] ?: getDefaultHandler(entity) } @@ -72,7 +68,7 @@ object VSEntityManager { private fun determineDefaultHandler(entity: Entity): VSEntityHandler { try { val className = entity::class.java.simpleName - val registryName = Registry.ENTITY_TYPE.getKey(entity.type) + val registryName = BuiltInRegistries.ENTITY_TYPE.getKey(entity.type) if (className.contains("SeatEntity", true) || registryName.path.contains(seatRegistryName)) { return DefaultShipyardEntityHandler @@ -91,10 +87,10 @@ object VSEntityManager { // Sends a packet with all the entity -> handler pairs to the client fun syncHandlers(player: MinecraftPlayer) { val entityTypes: Map = - (0 until Registry.ENTITY_TYPE.count()) + (0 until BuiltInRegistries.ENTITY_TYPE.count()) .asSequence() .mapNotNull { i -> - val handler = entityHandlers[Registry.ENTITY_TYPE.byId(i)] ?: return@mapNotNull null + val handler = entityHandlers[BuiltInRegistries.ENTITY_TYPE.byId(i)] ?: return@mapNotNull null i to namedEntityHandlers[handler].toString() } .toMap() diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt index 6a5608cc3..c743b308c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt @@ -1,11 +1,11 @@ package org.valkyrienskies.mod.common.hooks import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.math.Matrix4f import it.unimi.dsi.fastutil.objects.ObjectList import net.minecraft.client.renderer.LevelRenderer import net.minecraft.client.renderer.LevelRenderer.RenderChunkInfo import net.minecraft.client.renderer.RenderType +import org.joml.Matrix4f import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.util.events.EventEmitterImpl diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/networking/VSGamePackets.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/networking/VSGamePackets.kt index 4be65f6eb..da2cb68e6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/networking/VSGamePackets.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/networking/VSGamePackets.kt @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.common.networking -import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import org.valkyrienskies.core.api.ships.LoadedServerShip @@ -46,7 +46,7 @@ object VSGamePackets { PacketSyncVSEntityTypes::class.registerClientHandler { syncEntities -> syncEntities.entity2Handler.forEach { (id, handler) -> VSEntityManager.pair( - Registry.ENTITY_TYPE.byId(id), + BuiltInRegistries.ENTITY_TYPE.byId(id), ResourceLocation.tryParse(handler)?.let { VSEntityManager.getHandler(it) } ?: throw IllegalStateException("No handler: $handler") ) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityShipCollisionUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityShipCollisionUtils.kt index 4b4109ae1..1c643c26b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityShipCollisionUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityShipCollisionUtils.kt @@ -76,7 +76,8 @@ object EntityShipCollisionUtils { // Inflate the bounding box more for players than other entities, to give players a better collision result. // Note that this increases the cost of doing collision, so we only do it for the players val inflation = if (entity is Player) 0.5 else 0.1 - val stepHeight: Double = entity?.maxUpStep?.toDouble() ?: 0.0 + //val stepHeight: Double = entity?.maxUpStep?.toDouble() ?: 0.0 + val stepHeight: Double = 0.0 // Add [max(stepHeight - inflation, 0.0)] to search for polygons we might collide with while stepping val collidingShipPolygons = getShipPolygonsCollidingWithEntity( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/RaycastUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/RaycastUtils.kt index 6e1699db8..83a1bdd3a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/RaycastUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/RaycastUtils.kt @@ -100,7 +100,7 @@ private fun Level.clip(context: ClipContext, realStart: Vec3, realEnd: Vec3): Bl } ) { raycastContext: ClipContext -> val vec3d = realStart.subtract(realEnd) - BlockHitResult.miss(realEnd, Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos(realEnd)) + BlockHitResult.miss(realEnd, Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(realEnd)) } as BlockHitResult } @@ -267,6 +267,6 @@ fun BlockGetter.vanillaClip(context: ClipContext): BlockHitResult = val vec3 = ctx.from.subtract(ctx.to) BlockHitResult.miss( ctx.to, Direction.getNearest(vec3.x, vec3.y, vec3.z), - BlockPos(ctx.to) + BlockPos.containing(ctx.to) ) }) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt deleted file mode 100644 index bb880bf56..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.valkyrienskies.mod.compat - -import net.minecraft.world.entity.Entity - -object CreateCompat { - - private val contraptionClass = runCatching { - Class.forName("com.simibubi.create.content.contraptions.AbstractContraptionEntity") - }.getOrNull() - - @JvmStatic - fun isContraption(entity: Entity): Boolean { - return contraptionClass?.isInstance(entity) ?: false - } -} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt deleted file mode 100644 index 93b73338c..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.valkyrienskies.mod.compat - -import org.joml.Matrix3d -import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.Matrix3dAccessor - -fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { - val accessor = this as Matrix3dAccessor - return Matrix3d( - accessor.m00, accessor.m01, accessor.m02, - accessor.m10, accessor.m11, accessor.m12, - accessor.m20, accessor.m21, accessor.m22 - ) -} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt index 964379f76..a5253c42e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt @@ -1,8 +1,6 @@ package org.valkyrienskies.mod.common.util import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.math.Quaternion -import com.mojang.math.Vector4f import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.Position @@ -10,11 +8,12 @@ import net.minecraft.core.Vec3i import net.minecraft.world.level.ChunkPos import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 +import org.joml.Matrix3f import org.joml.Matrix4d import org.joml.Matrix4dc import org.joml.Matrix4fc import org.joml.Quaterniondc -import org.joml.Quaternionfc +import org.joml.Quaternionf import org.joml.Vector2i import org.joml.Vector2ic import org.joml.Vector3d @@ -22,10 +21,9 @@ import org.joml.Vector3dc import org.joml.Vector3f import org.joml.Vector3i import org.joml.Vector3ic +import org.joml.Vector4f import org.joml.primitives.AABBd import org.joml.primitives.AABBdc -import org.valkyrienskies.mod.mixin.accessors.util.math.Matrix4fAccessor -import com.mojang.math.Matrix4f as Matrix4fMC // region JOML @@ -67,16 +65,8 @@ fun AABBd.set(v: AABB) = also { fun Vector3ic.toBlockPos() = BlockPos(x(), y(), z()) fun Vector3dc.toMinecraft() = Vec3(x(), y(), z()) -fun Quaternionfc.toMinecraft() = Quaternion(x(), y(), z(), w()) -fun Quaterniondc.toMinecraft() = Quaternion(x().toFloat(), y().toFloat(), z().toFloat(), w().toFloat()) - -fun Matrix4fc.toMinecraft() = Matrix4fMC().set(this) -fun Matrix4dc.toMinecraft() = Matrix4fMC().set(this) - -fun Matrix4d.mul(m: Matrix4fMC): Matrix4d = mul(m.toJOML(), this) -fun Matrix4dc.mul(m: Matrix4fMC, dest: Matrix4d): Matrix4d = mul(m.toJOML(), dest) - -fun Matrix4fMC.toJOML() = Matrix4d().set(this) +fun Matrix4d.mul(m: Matrix4fc): Matrix4d = mul(m, this) +fun Matrix4dc.mul(m: Matrix4fc, dest: Matrix4d): Matrix4d = mul(m, dest) fun AABBdc.toMinecraft() = AABB(minX(), minY(), minZ(), maxX(), maxY(), maxZ()) fun AABB.toJOML() = AABBd().set(this) @@ -119,16 +109,18 @@ fun Matrix4dc.transform(v: Vector4f) = v.also { fun PoseStack.multiply(modelTransform: Matrix4dc, normalTransform: Quaterniondc) = also { val last = last() - last.pose().multiply(modelTransform.toMinecraft()) - last.normal().mul(normalTransform.toMinecraft()) -} -fun PoseStack.multiply(modelTransform: Matrix4dc) = also { - last().pose().multiply(modelTransform.toMinecraft()) + val newPose = Matrix4d().set(last.pose()).mul(modelTransform) + val newNormal = last.normal().mul(Matrix3f().set(normalTransform)) + + last.pose().set(newPose) + last.normal().set(newNormal) } -fun Matrix4fMC.multiply(m: Matrix4dc): Matrix4fMC = also { - multiply(m.toMinecraft()) +fun PoseStack.multiply(modelTransform: Matrix4dc) = also { + val last = last() + val newPose = Matrix4d().set(last.pose()).mul(modelTransform) + last.pose().set(newPose) } fun Vec3i.toJOML() = Vector3i().set(this) @@ -137,70 +129,5 @@ fun Vec3i.toJOMLF() = Vector3f().set(this) fun Position.toJOML() = Vector3d().set(this) -fun Quaternion.set(source: Quaterniondc) = - set(source.x().toFloat(), source.y().toFloat(), source.z().toFloat(), source.w().toFloat()) - -fun Matrix4fMC.set(m: Matrix4fc) = also { - @Suppress("CAST_NEVER_SUCCEEDS") - this as Matrix4fAccessor - m00 = m.m00() - m01 = m.m10() - m02 = m.m20() - m03 = m.m30() - m10 = m.m01() - m11 = m.m11() - m12 = m.m21() - m13 = m.m31() - m20 = m.m02() - m21 = m.m12() - m22 = m.m22() - m23 = m.m32() - m30 = m.m03() - m31 = m.m13() - m32 = m.m23() - m33 = m.m33() -} - -fun Matrix4fMC.set(m: Matrix4dc) = also { - @Suppress("CAST_NEVER_SUCCEEDS") - this as Matrix4fAccessor - m00 = m.m00().toFloat() - m01 = m.m10().toFloat() - m02 = m.m20().toFloat() - m03 = m.m30().toFloat() - m10 = m.m01().toFloat() - m11 = m.m11().toFloat() - m12 = m.m21().toFloat() - m13 = m.m31().toFloat() - m20 = m.m02().toFloat() - m21 = m.m12().toFloat() - m22 = m.m22().toFloat() - m23 = m.m32().toFloat() - m30 = m.m03().toFloat() - m31 = m.m13().toFloat() - m32 = m.m23().toFloat() - m33 = m.m33().toFloat() -} - -fun Matrix4d.set(m: Matrix4fMC) = also { - @Suppress("CAST_NEVER_SUCCEEDS") - m as Matrix4fAccessor - m00(m.m00.toDouble()) - m01(m.m10.toDouble()) - m02(m.m20.toDouble()) - m03(m.m30.toDouble()) - m10(m.m01.toDouble()) - m11(m.m11.toDouble()) - m12(m.m21.toDouble()) - m13(m.m31.toDouble()) - m20(m.m02.toDouble()) - m21(m.m12.toDouble()) - m22(m.m22.toDouble()) - m23(m.m32.toDouble()) - m30(m.m03.toDouble()) - m31(m.m13.toDouble()) - m32(m.m23.toDouble()) - m33(m.m33.toDouble()) -} - +fun Quaterniondc.toFloat() = Quaternionf(x(), y(), z(), w()) // endregion diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 08c5f8bb8..0f26881be 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -10,7 +10,6 @@ "accessors.server.level.ChunkMapAccessor", "accessors.server.level.DistanceManagerAccessor", "accessors.server.level.ServerChunkCacheAccessor", - "accessors.util.math.Matrix4fAccessor", "accessors.world.level.block.SlabBlockAccessor", "accessors.world.level.block.StairBlockAccessor", "accessors.world.level.pathfinder.PathAccessor", @@ -54,45 +53,7 @@ "mod_compat.bluemap.MixinBmMap", "mod_compat.bluemap.MixinHiresModelManager", "mod_compat.bluemap.MixinWorld", - "mod_compat.create.IMixinDeployerHandler", - "mod_compat.create.IMixinDeployerMovementBehaviour", - "mod_compat.create.MixinAirCurrent", - "mod_compat.create.MixinAirFlowParticle", - "mod_compat.create.MixinBeltMovementHandler", - "mod_compat.create.MixinContraption", - "mod_compat.create.MixinContraptionCollider", - "mod_compat.create.MixinEntityLauncher", - "mod_compat.create.MixinRedstoneLinkNetworkHandler", - "mod_compat.create.MixinSharedDepotBlockMethods", - "mod_compat.create.accessors.ChuteBlockEntityAccessor", - "mod_compat.create.accessors.Matrix3dAccessor", - "mod_compat.create.accessors.OutlineParamsAccessor", - "mod_compat.create.behaviour.MixinBlockBreakingMovementBehaviour", - "mod_compat.create.behaviour.MixinFilteringBehaviour", - "mod_compat.create.behaviour.MixinLinkBehaviour", - "mod_compat.create.behaviour.MixinScrollValueBehaviour", - "mod_compat.create.behaviour.MixinSidedFilteringBehaviour", - "mod_compat.create.block.MixinCrushingWheelBlock", - "mod_compat.create.block.MixinEjectorBlock", - "mod_compat.create.block.MixinRedstoneContactBlock", - "mod_compat.create.block.MixinStickerBlock", - "mod_compat.create.blockentity.IMixinMechanicalBearingTileEntity", - "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", - "mod_compat.create.blockentity.MixinEjectorTileEntity", - "mod_compat.create.blockentity.MixinEncasedFanTileEntity", - "mod_compat.create.entity.MixinAbstractContraptionEntity", - "mod_compat.create.entity.MixinCarriageContraptionEntity", - "mod_compat.create.entity.MixinControlledContraptionEntity", - "mod_compat.create.entity.MixinSeatEntity", - "mod_compat.create.packets.MixinControlsInputPacket", - "mod_compat.create.packets.MixinCurvedTrackDestroyPacket", - "mod_compat.create.packets.MixinSuperGlueRemovalPacket", - "mod_compat.create.packets.MixinTileEntityConfigurationPacket", - "mod_compat.create.packets.MixinTrainRelocationPacket", - "mod_compat.create.pr.MixinSeatBlock", - "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.ftb_chunks.MixinClaimedChunkManager", - "mod_compat.reachentityattributes.MixinReachEntityAttributes", "server.MinecraftServerAccessor", "server.MixinMinecraftServer", "server.MixinPlayerList", @@ -119,7 +80,6 @@ "accessors.client.render.chunk.RenderChunkAccessor", "accessors.client.world.ClientChunkCacheStorageAccessor", "client.MixinCamera", - "client.MixinGame", "client.MixinMinecraft", "client.multiplayer.MixinClientPacketListener", "client.player.MixinLocalPlayer", @@ -146,34 +106,6 @@ "feature.transform_particles.MixinLevelRenderer", "feature.transform_particles.MixinParticle", "feature.vs2_alpha_hud.MixinGui", - "mod_compat.create.client.MixinAABBOutline", - "mod_compat.create.client.MixinBlockClusterOutline", - "mod_compat.create.client.MixinCarriageContraptionInstance", - "mod_compat.create.client.MixinCogwheelBlockItem", - "mod_compat.create.client.MixinCogwheelBlockItemHitOnShaft", - "mod_compat.create.client.MixinContraptionRenderDispatcher", - "mod_compat.create.client.MixinContraptionRenderInfo", - "mod_compat.create.client.MixinElevatorControlsHandler", - "mod_compat.create.client.MixinFilteringRenderer", - "mod_compat.create.client.MixinGhostBlockRenderer", - "mod_compat.create.client.MixinLinkRenderer", - "mod_compat.create.client.MixinMinecartInstance", - "mod_compat.create.client.MixinMultiplePlacementHelpers", - "mod_compat.create.client.MixinOutline", - "mod_compat.create.client.MixinPlacementHelpers", - "mod_compat.create.client.MixinSoundScapes", - "mod_compat.create.client.MixinTileEntityRenderHelper", - "mod_compat.create.client.MixinTrainRelocator", - "mod_compat.create.client.MixinDeployTool", - "mod_compat.create.client.MixinSchematicToolBase", - "mod_compat.create.client.MixinSchematicTransformation", - "mod_compat.create.client.MixinValueBox", - "mod_compat.create.client.trackOutlines.MixinBigOutlines", - "mod_compat.flywheel.InstancingEngineAccessor", - "mod_compat.flywheel.MixinBlockEntityInstanceManager", - "mod_compat.flywheel.MixinInstanceManager", - "mod_compat.flywheel.MixinInstanceWorld", - "mod_compat.flywheel.MixinInstancingEngine", "mod_compat.optifine.MixinViewAreaOptifine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", diff --git a/fabric/build.gradle b/fabric/build.gradle index 28c9639ae..fe7c933aa 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -73,13 +73,14 @@ dependencies { modImplementation("maven.modrinth:cc-restitched:${cc_restitched_version}") // Create compat - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { - exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' - } - modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") - modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") - - modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") + //modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { + // exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' + //} + //modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") + //modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") + + // https://modrinth.com/mod/porting_lib/versions + //modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") //modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 46c0a545e..a0ea80a85 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,5 +1,5 @@ loader_platform=Fabric -create_version=0.5.1-c-build.1160+mc1.19.2 +#create_version=0.5.1-c-build.1160+mc1.19.2 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L24 config_api_id=4143545 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L25 @@ -9,33 +9,33 @@ fake_player_api_version=0.4.0 # https://github.com/JamiesWhiteShirt/reach-entity-attributes/tags reach_entity_attributes_version=2.3.0 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L32C14-L32C14 -registrate_version=1.1.58-MC1.19.2 +#registrate_version=1.1.58-MC1.19.2 forge_tags_version=2.1 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L33 milk_lib_version=1.0.51 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L35 -port_lib_version=2.1.1096 +port_lib_version=2.1.1308 port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer night_config_core_version=3.6.3 night_config_toml_version=3.6.3 jsr305_version=3.0.2 # https://modrinth.com/mod/no-indium/ -no_indium_version=1.1.0+1.19 +no_indium_version=1.1.0+1.19.4 #https://modrinth.com/mod/sodium/versions -sodium_version = mc1.19.2-0.4.4 +sodium_version = mc1.19.4-0.4.10 #https://modrinth.com/mod/cc-restitched/versions -cc_restitched_version = 1.101.2+1.19.1 +cc_restitched_version = 1.102.0+1.19.3 kotlin_fabric_version = 1.10.10+kotlin.1.9.10 -# https://modrinth.com/mod/indium/version/1.0.9+mc1.19.2 -indium_version = 1.0.9+mc1.19.2 +# https://modrinth.com/mod/indium/version/1.0.19+mc1.19.4 +indium_version = 1.0.19+mc1.19.4 -# https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 -modmenu_version = 4.2.0-beta.2 +# https://linkie.shedaniel.dev/dependencies?loader=fabric&version=1.19.4 +modmenu_version = 6.3.1 -# https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 -cloth_config_version = 8.3.103 +# https://linkie.shedaniel.dev/dependencies?loader=fabric&version=1.19.4 +cloth_config_version = 10.1.135 diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java index 8bb3bdc91..667a9b002 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.GameRenderer; @@ -19,6 +17,8 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -57,14 +57,14 @@ private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, f transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z); - final Matrix3f newNormalMatrix = matrixStack.last().normal().copy(); - final Matrix4f newModelMatrix = matrixStack.last().pose().copy(); + final Matrix3f newNormalMatrix = new Matrix3f(matrixStack.last().normal()); + final Matrix4f newModelMatrix = new Matrix4f(matrixStack.last().pose()); // Then update the matrices in vertexConsumer (I'm guessing vertexConsumer is responsible for mapping // textures, so we need to update its matrices otherwise the block damage texture looks wrong) final SheetedDecalTextureGenerator newVertexConsumer = new SheetedDecalTextureGenerator(((OverlayVertexConsumerAccessor) vertexConsumer).getDelegate(), - newModelMatrix, newNormalMatrix); + newModelMatrix, newNormalMatrix, 1); // Finally, invoke the render damage function. renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleBrain.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleBrain.java index 654235c89..f4e864ef8 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleBrain.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleBrain.java @@ -109,7 +109,7 @@ private static BlockPos getWorldPosFromShipPos(final Ship ship, final BlockPos p final Vec3 tPos = VectorConversionsMCKt.toMinecraft( VSGameUtilsKt.toWorldCoordinates(ship, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)); - final BlockPos newPos = new BlockPos(tPos.x, tPos.y, tPos.z); + final BlockPos newPos = BlockPos.containing(tPos.x, tPos.y, tPos.z); return newPos; } } diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java deleted file mode 100644 index ef2cb5122..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create; - -import com.simibubi.create.content.kinetics.base.BlockBreakingKineticBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(BlockBreakingKineticBlockEntity.class) -public abstract class MixinBlockBreakingKineticTileEntity { - - @Shadow - protected abstract BlockPos getBreakingPos(); - - @Redirect( - method = "tick", - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/content/kinetics/base/BlockBreakingKineticBlockEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" - ) - ) - private BlockPos getBreakingBlockPos(final BlockBreakingKineticBlockEntity self) { - final BlockPos orig = this.getBreakingPos(); - final Vec3 origin; - final Vec3 target; - final Ship ship = VSGameUtilsKt.getShipManagingPos(self.getLevel(), self.getBlockPos()); - - if (ship != null) { - origin = VectorConversionsMCKt.toMinecraft( - ship.getShipToWorld() - .transformPosition(VectorConversionsMCKt.toJOMLD(self.getBlockPos()).add(0.5, 0.5, 0.5)) - ); - target = VectorConversionsMCKt.toMinecraft( - ship.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOMLD(orig).add(0.5, 0.5, 0.5)) - ); - } else { - origin = Vec3.atCenterOf(self.getBlockPos()); - target = Vec3.atCenterOf(orig); - } - - final Vec3 diff = target.subtract(origin); - final BlockHitResult result = self.getLevel().clip(new ClipContext( - origin.add(diff.scale(0.4)), - target.add(diff.scale(0.2)), - ClipContext.Block.COLLIDER, - ClipContext.Fluid.NONE, - null - )); - - if (result.getType() == HitResult.Type.MISS) { - return orig; - } - - return result.getBlockPos(); - } - -} - diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java deleted file mode 100644 index ac355ef2f..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create; - -import com.simibubi.create.content.kinetics.millstone.MillstoneBlock; -import com.simibubi.create.content.logistics.chute.AbstractChuteBlock; -import com.simibubi.create.content.processing.basin.BasinBlock; -import java.util.Iterator; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(value = { - MillstoneBlock.class, - BasinBlock.class, - AbstractChuteBlock.class -}) -public class MixinBlocks { - - @Redirect( - method = "updateEntityAfterFallOn", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - ), - require = 0 - ) - protected BlockPos redirectBlockPosition(final Entity entity) { - final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); - if (ships.hasNext()) { - final Vector3d pos = ships.next().getWorldToShip() - .transformPosition(VectorConversionsMCKt.toJOML(entity.position())); - return new BlockPos(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); - } else { - return entity.blockPosition(); - } - } - - @Redirect( - method = "updateEntityAfterFallOn", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" - ), - require = 0 - ) - Vec3 redirectPosition(final Entity entity) { - final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); - if (ships.hasNext()) { - return VectorConversionsMCKt.toMinecraft(ships.next().getWorldToShip() - .transformPosition(VectorConversionsMCKt.toJOML(entity.position()))); - } else { - return entity.position(); - } - } - -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java deleted file mode 100644 index 75dc5f991..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create; - -import com.llamalad7.mixinextras.sugar.Local; -import com.simibubi.create.content.logistics.chute.ChuteBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ServerShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.ChuteBlockEntityAccessor; - -@Mixin(value = ChuteBlockEntity.class, remap = false) -public class MixinChuteBlockEntity { - - @Inject(method = "findEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;)V", shift = Shift.AFTER), cancellable = true) - private void preFindEntities(float itemSpeed, CallbackInfo ci, @Local Vec3 center) { - ChuteBlockEntity be = ChuteBlockEntity.class.cast(this); - - if (be.getLevel() != null) { - - final ChuteBlockEntityAccessor bea = (ChuteBlockEntityAccessor) be; - Level level = be.getLevel(); - - BlockPos pos = be.getBlockPos(); - - AABB searchArea = new AABB(center.add(0, -bea.getBottomPullDistance() - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); - - if (VSGameUtilsKt.getShipObjectManagingPos(level, pos) instanceof ServerShip ship) { - Vector3d searchAreaMin = new Vector3d(searchArea.minX, searchArea.minY, searchArea.minZ); - Vector3d searchAreaMax = new Vector3d(searchArea.maxX, searchArea.maxY, searchArea.maxZ); - - Vector3d searchAreaReturnMin = new Vector3d(); - Vector3d searchAreaReturnMax = new Vector3d(); - - ship.getTransform().getShipToWorld().transformAab(searchAreaMin, searchAreaMax, searchAreaReturnMin, searchAreaReturnMax); - - searchArea = new AABB(searchAreaReturnMin.x, searchAreaReturnMin.y, searchAreaReturnMin.z, searchAreaReturnMax.x, searchAreaReturnMax.y, searchAreaReturnMax.z); - - for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, searchArea)) { - if (!itemEntity.isAlive()) - continue; - ItemStack entityItem = itemEntity.getItem(); - if (!bea.callCanAcceptItem(entityItem)) - continue; - be.setItem(entityItem.copy(), (float) (itemEntity.getBoundingBox() - .getCenter().y - be.getBlockPos().getY())); - itemEntity.discard(); - break; - } - ci.cancel(); - } - } - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java deleted file mode 100644 index 7d2e49ff9..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ControlledContraptionEntity; -import com.simibubi.create.content.contraptions.bearing.BearingContraption; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Math; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ControlledContraptionEntity.class) -public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity { - public MixinControlledContraptionEntity(EntityType entityTypeIn, Level worldIn) { - super(entityTypeIn, worldIn); - } - - //Region start - fix actors in the center of a bearing contraption not triggering correctly (vanilla create bug) - @Shadow - protected float angleDelta; - - @Redirect(method = "shouldActorTrigger", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;motion:Lnet/minecraft/world/phys/Vec3;")) - private void redirectPutMotion(MovementContext instance, Vec3 value) { - BearingContraption bc = (BearingContraption) contraption; - Direction facing = bc.getFacing(); - Vec3i dir = facing.getNormal(); - - double scalar = Math.abs(angleDelta / 360.0) * Math.signum(dir.getX() + dir.getY() + dir.getZ()); - - instance.motion = new Vec3(Math.abs(dir.getX()), Math.abs(dir.getY()), Math.abs(dir.getZ())).scale(scalar); - } - //Region end -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java deleted file mode 100644 index ec38248d9..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ContraptionHandlerClient; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.primitives.AABBdc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(ContraptionHandlerClient.class) -public class MixinContraptionHandlerClient { - // Fixes raytracing contraptions on ships - @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;")) - private static Vec3 wrapRayTraceContraptionToLocalVector( - final AbstractContraptionEntity instance, final Vec3 localVec, final float partialTicks, final Operation toLocalVector - ) { - final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); - if (clientShip != null) { - final Vec3 newLocalVec = VectorConversionsMCKt.toMinecraft(clientShip.getRenderTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(localVec))); - return toLocalVector.call(instance, newLocalVec, partialTicks); - } - return toLocalVector.call(instance, localVec, partialTicks); - } - - // Fixes raytracing contraptions on ships - @WrapOperation(method = "rightClickingOnContraptionsGetsHandledLocally", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB wrapRightClickingOnContraptionsGetsHandledLocallyGetBoundingBox(final AbstractContraptionEntity instance, final Operation getBoundingBox) { - final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); - if (clientShip != null) { - final AABB original = getBoundingBox.call(instance); - final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); - return VectorConversionsMCKt.toMinecraft(modified); - } - return getBoundingBox.call(instance); - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java deleted file mode 100644 index be7946f45..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ContraptionRenderInfo.class) -public class MixinContraptionRenderInfo { - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBoxForCulling()Lnet/minecraft/world/phys/AABB;" - ), - method = "beginFrame" - ) - private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) { - return VSGameUtilsKt.transformRenderAABBToWorld(((ClientLevel) receiver.level), receiver.position(), - receiver.getBoundingBoxForCulling()); - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java deleted file mode 100644 index 60e8b7ecc..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import io.github.fabricators_of_create.porting_lib.block.CullingBlockEntityIterator; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(CullingBlockEntityIterator.class) -public abstract class MixinCullingBlockEntityIterator { - @Redirect(method = "nextCulled", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/renderer/culling/Frustum;isVisible(Lnet/minecraft/world/phys/AABB;)Z") - ) - private boolean inject(final Frustum instance, final AABB arg) { - AABB newAABB = arg; - final Level level = Minecraft.getInstance().level; - if (level != null) { - newAABB = VSGameUtilsKt.transformAabbToWorld(level, arg); - } - return instance.isVisible(newAABB); - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java deleted file mode 100644 index dadc3e560..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.mojang.math.Matrix4f; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; -import com.simibubi.create.content.contraptions.render.FlwContraption; -import net.minecraft.util.Mth; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(FlwContraption.class) -public class MixinFlwContraption extends ContraptionRenderInfo { - - public MixinFlwContraption( - final Contraption contraption, - final VirtualRenderWorld renderWorld) { - super(contraption, renderWorld); - } - - @Inject(at = @At("HEAD"), method = "setupModelViewPartial", cancellable = true, remap = false) - private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Matrix4f modelMatrix, - final AbstractContraptionEntity entity, final double camX, final double camY, final double camZ, final float pt, - final CallbackInfo ci) { - - if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { - VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), - matrix, - Mth.lerp(pt, entity.xOld, entity.getX()), - Mth.lerp(pt, entity.yOld, entity.getY()), - Mth.lerp(pt, entity.zOld, entity.getZ()), - camX, - camY, - camZ - ); - - matrix.multiply(modelMatrix); - ci.cancel(); - } - } - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/AABB;move(DDD)Lnet/minecraft/world/phys/AABB;" - ), - method = "beginFrame" - ) - private AABB transformLightboxToWorld(final AABB aabb, final double negCamX, final double negCamY, - final double negCamZ) { - return VSGameUtilsKt.transformAabbToWorld(this.contraption.entity.level, aabb).move(negCamX, negCamY, negCamZ); - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java deleted file mode 100644 index 3bfbff08f..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; -import com.simibubi.create.content.contraptions.glue.SuperGlueSelectionHandler; -import com.simibubi.create.foundation.utility.RaycastHelper; -import java.util.Iterator; -import net.minecraft.client.Minecraft; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4d; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.joml.primitives.AABBic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(SuperGlueSelectionHandler.class) -public abstract class MixinSuperGlueSelectionHandler { - @Unique - private Vec3 newTarget; - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceOrigin(Lnet/minecraft/world/entity/player/Player;)Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetTraceOrigin(Player playerIn) { - Minecraft mc = Minecraft.getInstance(); - double range = ReachEntityAttributes.getReachDistance(playerIn, playerIn.isCreative() ? 5.0 : 4.5); // PlatformUtils.getReachDistance(playerIn) + 1; - Vec3 origin = RaycastHelper.getTraceOrigin(playerIn); - Vec3 target = RaycastHelper.getTraceTarget(playerIn, range, origin); - - - AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); - final Iterator ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level, searchAABB).iterator(); - - if (ships.hasNext()) { - Ship ship = ships.next(); - - Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); - AABBic shAABBi = ship.getShipAABB(); - AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); - - - origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); - target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); - - Quaterniond tempQuat = new Quaterniond(); - if (playerIn.getVehicle() != null && playerIn.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { - ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); - tempQuat.invert(); - Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); - tempQuat.transform(offset); - target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); - } - } - - newTarget = target; - return origin; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceTarget(Lnet/minecraft/world/entity/player/Player;DLnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetTraceTarget(final Player playerIn, final double range, final Vec3 origin) { - return newTarget; - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java deleted file mode 100644 index 535f54ba1..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.simibubi.create.content.trains.track.TrackBlockOutline; -import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(TrackBlockOutline.class) -public class MixinTrackBlockOutline { - @Unique - private static Vec3 valkyrienskies$cameraVec3; - @Unique - private static Vec3 valkyrienskies$vec; - @Unique - private static Vec3 valkyrienskies$angles; - - @Inject(method = "drawCurveSelection", - at = @At(value = "INVOKE", - target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline$BezierPointSelection;angles()Lnet/minecraft/world/phys/Vec3;"), - locals = LocalCapture.CAPTURE_FAILHARD) - private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBufferSource buffer, final Vec3 camera, - final CallbackInfo ci, final Minecraft mc, - final BezierPointSelection result, final VertexConsumer vb, final Vec3 vec) { - valkyrienskies$cameraVec3 = camera; - valkyrienskies$vec = result.vec(); - valkyrienskies$angles = result.angles(); - } - @ModifyArg(method = "drawCurveSelection", - at = @At(value = "INVOKE", - target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline;renderShape(Lnet/minecraft/world/phys/shapes/VoxelShape;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/lang/Boolean;)V"), - index = 1) - private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { - - final Level level = Minecraft.getInstance().level; - if (level != null && valkyrienskies$vec != null) { - final ClientShip ship; - if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, valkyrienskies$vec)) != null) { - final Quaterniond rotation = new Quaterniond().identity(); - final Quaterniond yawQuat = new Quaterniond().rotateY(valkyrienskies$angles.y); - final Quaterniond pitchQuat = new Quaterniond().rotateX(valkyrienskies$angles.x); - - yawQuat.mul(pitchQuat, rotation); - ship.getRenderTransform().getShipToWorldRotation().mul(rotation, rotation); - - final Vector3d worldVec = ship.getRenderTransform().getShipToWorld() - .transformPosition( - new Vector3d(valkyrienskies$vec.x, valkyrienskies$vec.y + .125, valkyrienskies$vec.z), - new Vector3d()); - - ms.popPose(); - ms.pushPose(); - ms.translate(worldVec.x - valkyrienskies$cameraVec3.x, - worldVec.y - valkyrienskies$cameraVec3.y, - worldVec.z - valkyrienskies$cameraVec3.z); - ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation)); - ms.translate(-.5, -.125f, -.5); - } - } - return ms; - } - - @Unique - private static Camera valkyrienskies$info; - @Unique - private static BlockHitResult valkyrienskies$hitResult; - - @ModifyArg(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/border/WorldBorder;isWithinBounds(Lnet/minecraft/core/BlockPos;)Z")) - private static BlockPos modIsWithinBounds(final BlockPos blockPos) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Ship ship; - if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) { - return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() - .transformPosition(VectorConversionsMCKt.toJOMLD(blockPos)))); - } - } - return blockPos; - } - - @Inject(method = "drawCustomBlockSelection", - at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) - private static void harvest(final LevelRenderer context, final Camera info, final HitResult hitResult, - final float partialTicks, - final PoseStack ms, final MultiBufferSource buffers, final CallbackInfoReturnable cir) { - valkyrienskies$info = info; - valkyrienskies$hitResult = (BlockHitResult) hitResult; - } - - @Redirect(method = "drawCustomBlockSelection", - at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) - private static void redirectTranslate(final PoseStack instance, final double d, final double e, final double f) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final ClientShip ship; - if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, - valkyrienskies$hitResult.getBlockPos())) != null) { - final Vec3 camPos = valkyrienskies$info.getPosition(); - VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, - valkyrienskies$hitResult.getBlockPos(), - camPos.x, camPos.y, camPos.z); - } else { - instance.translate(d, e, f); - } - } else { - instance.translate(d, e, f); - } - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/water_in_ships_entity/MixinEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/water_in_ships_entity/MixinEntity.java index a54f535e1..3c67f5099 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/water_in_ships_entity/MixinEntity.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/water_in_ships_entity/MixinEntity.java @@ -169,7 +169,7 @@ private FluidState getFluidStateRedirect(final Level level, final BlockPos block VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, this.bb.getSize(), (x, y, z) -> { - fluidState[0] = getFluidState.call(level, new BlockPos(x, y, z)); + fluidState[0] = getFluidState.call(level, BlockPos.containing(x, y, z)); }); isShipWater = true; } diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java index 44087ce6f..d6f2cb882 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java @@ -34,7 +34,7 @@ public class MixinServerPlayerGameMode { target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") ) public double handleBlockBreakAction(final Vec3 instance, final Vec3 vec3) { - final BlockPos pos = new BlockPos(vec3.subtract(0.5, 0.5, 0.5)); + final BlockPos pos = BlockPos.containing(vec3.subtract(0.5, 0.5, 0.5)); if (VSGameConfig.SERVER.getEnableInteractDistanceChecks()) { final Vector3d blockCenter = VectorConversionsMCKt.toJOMLD(pos).add(0.5, 0.5, 0.5); return VSGameUtilsKt.getWorldCoordinates(level, pos, blockCenter) diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/world/level/block/FireMixin.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/world/level/block/FireMixin.java index 5f12bdf60..6b31a6ee5 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/world/level/block/FireMixin.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/world/level/block/FireMixin.java @@ -43,7 +43,7 @@ public void fireTickMixin(BlockState state, ServerLevel level, BlockPos pos, VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 3, (x, y, z) -> { - final BlockPos newPos = new BlockPos(x, y, z); + final BlockPos newPos = BlockPos.containing(x, y, z); if (level.isWaterAt(newPos)) { level.removeBlock(pos, false); @@ -51,7 +51,7 @@ public void fireTickMixin(BlockState state, ServerLevel level, BlockPos pos, final int i = state.getValue(AGE); - final boolean bl2 = level.isHumidAt(newPos); + final boolean bl2 = level.isRainingAt(newPos); final int k = bl2 ? -50 : 0; this.checkBurnOut(level, newPos.east(), 300 + k, random, i); this.checkBurnOut(level, newPos.west(), 300 + k, random, i); @@ -104,7 +104,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos newPos = new BlockPos(x, y, z); + final BlockPos newPos = BlockPos.containing(x, y, z); if (level.isWaterAt(newPos)) { level.removeBlock(pos, false); } diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt deleted file mode 100644 index 81b8f43ac..000000000 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.valkyrienskies.mod.fabric.common - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity -import net.minecraft.core.BlockPos -import net.minecraft.world.entity.Entity -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate -import org.valkyrienskies.core.api.ships.ContraptionWingProvider -import org.valkyrienskies.core.api.ships.LoadedServerShip -import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.api.ships.WingManager -import org.valkyrienskies.mod.common.block.WingBlock -import org.valkyrienskies.mod.common.entity.handling.AbstractShipyardEntityHandler - -object ContraptionShipyardEntityHandlerFabric: AbstractShipyardEntityHandler() { - override fun freshEntityInShipyard(entity: Entity, ship: Ship) { - if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { - entity as ContraptionWingProvider - val attachment = ship.getAttachment(WingManager::class.java)!! - entity.wingGroupId = attachment.createWingGroup() - entity.contraption.blocks.forEach { (pos: BlockPos, blockInfo: StructureTemplate.StructureBlockInfo) -> - val block = blockInfo.state.block - if (block is WingBlock) { - val wing = block.getWing(null, null, blockInfo.state) - attachment.setWing(entity.wingGroupId, pos.x, pos.y, pos.z, wing) - } - } - val transform = entity.computeContraptionWingTransform() - attachment.setWingGroupTransform(entity.wingGroupId, transform) - } - } - - override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { - if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { - entity as ContraptionWingProvider - val attachment = ship.getAttachment(WingManager::class.java)!! - attachment.deleteWingGroup(entity.wingGroupId) - entity.wingGroupId = -1 - } - } -} diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt index dbe5aa938..faaa65cdf 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt @@ -12,6 +12,7 @@ import net.fabricmc.fabric.api.resource.ResourceManagerHelper import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.renderer.entity.EntityRendererProvider.Context import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackType.SERVER_DATA import net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier @@ -20,7 +21,6 @@ import net.minecraft.util.profiling.ProfilerFiller import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import org.valkyrienskies.core.apigame.VSCoreFactory @@ -40,7 +40,6 @@ import org.valkyrienskies.mod.common.config.VSGameConfig import org.valkyrienskies.mod.common.config.VSKeyBindings import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity -import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.common.item.AreaAssemblerItem import org.valkyrienskies.mod.common.item.ConnectionCheckerItem @@ -66,27 +65,27 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_WING = TestWingBlock ValkyrienSkiesMod.TEST_SPHERE = TestSphereBlock ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM = ConnectionCheckerItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling } ) ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling } ) - ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) + ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties()) ValkyrienSkiesMod.AREA_ASSEMBLER_ITEM = AreaAssemblerItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling } ) ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) - ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM = PhysicsEntityCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC)) + ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM = PhysicsEntityCreatorItem(Properties()) ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = EntityType.Builder.of( ::ShipMountingEntity, @@ -119,7 +118,6 @@ class ValkyrienSkiesModFabric : ModInitializer { if (isClient) onInitializeClient() ValkyrienSkiesMod.init(vsCore) - VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerFabric) registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) @@ -127,39 +125,39 @@ class ValkyrienSkiesModFabric : ModInitializer { registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) registerBlockAndItem("test_sphere", ValkyrienSkiesMod.TEST_SPHERE) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "connection_checker"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "connection_checker"), ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "area_assembler"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "area_assembler"), ValkyrienSkiesMod.AREA_ASSEMBLER_ITEM ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_creator"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_creator"), ValkyrienSkiesMod.SHIP_CREATOR_ITEM ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_creator_smaller"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_creator_smaller"), ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "physics_entity_creator"), + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "physics_entity_creator"), ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM ) Registry.register( - Registry.ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity"), + BuiltInRegistries.ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity"), ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE ) Registry.register( - Registry.ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity"), + BuiltInRegistries.ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity"), ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE ) Registry.register( - Registry.BLOCK_ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "test_hinge_block_entity"), + BuiltInRegistries.BLOCK_ENTITY_TYPE, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "test_hinge_block_entity"), ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE ) @@ -228,12 +226,12 @@ class ValkyrienSkiesModFabric : ModInitializer { private fun registerBlockAndItem(registryName: String, block: Block) { Registry.register( - Registry.BLOCK, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), + BuiltInRegistries.BLOCK, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), block ) Registry.register( - Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), - BlockItem(block, Properties().tab(CreativeModeTab.TAB_MISC)) + BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), + BlockItem(block, Properties()) ) } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 34b9878f6..782722fd7 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ "accessWidener": "valkyrienskies-common.accesswidener", "depends": { "fabricloader": ">=0.14.9", - "minecraft": "1.19.2", + "minecraft": "1.19.4", "fabric-api": "*" }, "breaks": { diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index de0571ea6..ae6ffbc7d 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -6,11 +6,6 @@ "compat.cc_restitched.MixinTurtleBrain", "compat.cc_restitched.MixinTurtleMoveCommand", "compat.cc_restitched.MixinWirelessNetwork", - "compat.create.MixinBlockBreakingKineticTileEntity", - "compat.create.MixinBlocks", - "compat.create.MixinChuteBlockEntity", - "compat.create.MixinControlledContraptionEntity", - "compat.create.client.MixinTrackBlockOutline", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "feature.shipyard_entities.MixinPersistentEntitySectionManager", @@ -19,12 +14,7 @@ "server.network.MixinServerGamePacketListenerImpl" ], "client": [ - "compat.cc_restitched.MixinSpeakerSound", - "compat.create.client.MixinContraptionHandlerClient", - "compat.create.client.MixinContraptionRenderInfo", - "compat.create.client.MixinCullingBlockEntityIterator", - "compat.create.client.MixinFlwContraption", - "compat.create.client.MixinSuperGlueSelectionHandler" + "compat.cc_restitched.MixinSpeakerSound" ], "injectors": { "defaultRequire": 1 diff --git a/forge/build.gradle b/forge/build.gradle index 80d4ee261..3bb4bbac8 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -65,22 +65,22 @@ dependencies { } //modCompileOnly("curse.maven:rubidium-574856:4024781") - modCompileOnly("maven.modrinth:embeddium:${embeddium_version}") + //modCompileOnly("maven.modrinth:embeddium:${embeddium_version}") // Create compat - modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } - modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") - modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") + //modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } + //modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") + //modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") // Weather2 1.18 // modImplementation("curse.maven:weather-storms-tornadoes-237746:4426524") modImplementation("curse.maven:coroutil-237749:5010129") // CC Tweaked - modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + //modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") // TIS-3d - modCompileOnly("maven.modrinth:tis3d:${tis3d_version}") + //modCompileOnly("maven.modrinth:tis3d:${tis3d_version}") // Modular Routers modCompileOnly("curse.maven:mr-250294:4695682") diff --git a/forge/gradle.properties b/forge/gradle.properties index 6b56dff03..a5bac4ff1 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -2,17 +2,17 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false #Deps -kotlin_version = 3.12.0 -cloth_config_version = 8.3.103 +kotlin_version = 4.11.0 +cloth_config_version = 10.1.135 #Compat # https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create -create_version = 0.5.1.e-44 -flywheel_version = 0.6.10-20 -registrate_version = MC1.19-1.1.5 -cc_tweaked_version = 1.19.2-1.101.3 +#create_version = 0.5.1.e-44 +#flywheel_version = 0.6.10-20 +#registrate_version = MC1.19-1.1.5 +#cc_tweaked_version = 1.19.4-1.108.0 #Extra # https://modrinth.com/mod/tis3d/version/MC1.19.2-forge-1.7.4 -tis3d_version = MC1.19.2-forge-1.7.4 +#tis3d_version = MC1.19.2-forge-1.7.4 # https://modrinth.com/mod/embeddium/versions -embeddium_version = 0.2.9+mc1.19.2 +#embeddium_version = 0.2.9+mc1.19.2 diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/client/render/MixinLevelRenderer.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/client/render/MixinLevelRenderer.java index d7f3579d3..dbace45a5 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/client/render/MixinLevelRenderer.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/client/render/MixinLevelRenderer.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.GameRenderer; @@ -22,6 +20,8 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.model.data.ModelData; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -67,14 +67,14 @@ private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, f transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z); - final Matrix3f newNormalMatrix = matrixStack.last().normal().copy(); - final Matrix4f newModelMatrix = matrixStack.last().pose().copy(); + final Matrix3f newNormalMatrix = new Matrix3f(matrixStack.last().normal()); + final Matrix4f newModelMatrix = new Matrix4f(matrixStack.last().pose()); // Then update the matrices in vertexConsumer (I'm guessing vertexConsumer is responsible for mapping // textures, so we need to update its matrices otherwise the block damage texture looks wrong) final SheetedDecalTextureGenerator newVertexConsumer = new SheetedDecalTextureGenerator(((OverlayVertexConsumerAccessor) vertexConsumer).getDelegate(), - newModelMatrix, newNormalMatrix); + newModelMatrix, newNormalMatrix, 1); // Finally, invoke the render damage function. renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java deleted file mode 100644 index 907ec7493..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.client.sound.SpeakerSound; -import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; -import net.minecraft.client.resources.sounds.AbstractSoundInstance; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundSource; -import net.minecraft.util.RandomSource; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.client.audio.VelocityTickableSoundInstance; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(SpeakerSound.class) -public abstract class MixinSpeakerSound extends AbstractSoundInstance implements VelocityTickableSoundInstance { - @Unique private SpeakerPosition speakerPosition; - @Unique private Ship ship; - - protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2, RandomSource arg3) { - super(arg, arg2, arg3); - } - - @Inject( - method = "setPosition", - at = @At("RETURN"), - remap = false - ) - private void isOnShip(SpeakerPosition position, CallbackInfo ci) { - this.speakerPosition = position; - this.ship = VSGameUtilsKt.getShipManagingPos(position.level(), position.position()); - if (this.ship != null) { - Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); - x = worldPos.x; - y = worldPos.y; - z = worldPos.z; - } - } - - @Inject( - method = "tick", - at = @At("HEAD") - ) - private void updateWorldPos(CallbackInfo ci) { - if (this.ship != null) { - Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); - x = worldPos.x; - y = worldPos.y; - z = worldPos.z; - } - } - - @NotNull - @Override - public Vector3dc getVelocity() { - return ship != null ? ship.getVelocity() : new Vector3d(); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleBrain.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleBrain.java deleted file mode 100644 index a5ca0bd71..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleBrain.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.shared.turtle.blocks.TileTurtle; -import dan200.computercraft.shared.turtle.core.TurtleBrain; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4dc; -import org.joml.Vector3d; -import org.joml.Vector3dc; -import org.joml.primitives.AABBic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.config.VSGameConfig; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Pseudo -@Mixin(TurtleBrain.class) -public abstract class MixinTurtleBrain { - @Shadow - public abstract TileTurtle getOwner(); - - @Shadow - public abstract void setOwner(TileTurtle owner); - - @Shadow - public abstract Level getLevel(); - - @ModifyVariable( - method = "Ldan200/computercraft/shared/turtle/core/TurtleBrain;teleportTo(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z", - at = @At(value = "HEAD"), - index = 2, - remap = false - ) - private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { - final TileTurtle currentOwner = getOwner(); - final BlockPos oldPos = currentOwner.getAccess().getPosition(); - final Level world = getLevel(); - - final Ship ship = VSGameUtilsKt.getShipManagingPos(world, oldPos); - if (ship != null) { - // THERE IS A SHIP - final Direction d = getNewDirection(ship, currentOwner.getDirection()); - if (!doesShipContainPoint(ship, pos)) { - // POSITION IS OUTSIDE THE SHIP'S AABB - - currentOwner.setDirection(d); - setOwner(currentOwner); - - if (!isShipScaled(ship)) { - // SHIP IS NOT SCALED - - return getWorldPosFromShipPos(ship, pos); - } else if (turtlesLeaveScaledShips()) { - // SHIP IS SCALED AND TURTLES CAN LEAVE SCALED SHIPS - - return getWorldPosFromShipPos(ship, pos); - } - } - } - return pos; - } - - // CUSTOM METHODS - - @Unique - private static Direction getNewDirection(final Ship ship, final Direction direction) { - final Matrix4dc matrix = ship.getShipToWorld(); - final Vec3i turtleDirectionVector = direction.getNormal(); - final Vector3d directionVec = - matrix.transformDirection(turtleDirectionVector.getX(), turtleDirectionVector.getY(), - turtleDirectionVector.getZ(), new Vector3d()); - final Direction dir = Direction.getNearest(directionVec.x, directionVec.y, directionVec.z); - - return dir; - } - - @Unique - private static boolean turtlesLeaveScaledShips() { - return VSGameConfig.SERVER.getComputerCraft().getCanTurtlesLeaveScaledShips(); - } - - @Unique - private static boolean isShipScaled(final Ship ship) { - final Vector3dc scale = ship.getTransform().getShipToWorldScaling(); - final Vector3dc normalScale = new Vector3d(1.000E+0, 1.000E+0, 1.000E+0); - return !scale.equals(normalScale); - } - - @Unique - private static boolean doesShipContainPoint(final Ship ship, final BlockPos pos) { - final AABBic shipAABB = ship.getShipAABB(); - - final AABB t = new AABB(shipAABB.maxX(), shipAABB.maxY(), shipAABB.maxZ(), shipAABB.minX(), shipAABB.minY(), - shipAABB.minZ()); - return t.intersects(new AABB(pos)); - } - - @Unique - private static BlockPos getWorldPosFromShipPos(final Ship ship, final BlockPos pos) { - final Vec3 tPos = VectorConversionsMCKt.toMinecraft( - VSGameUtilsKt.toWorldCoordinates(ship, pos.getX() + 0.5, pos.getY() + 0.5, - pos.getZ() + 0.5)); - final BlockPos newPos = new BlockPos(tPos.x, tPos.y, tPos.z); - return newPos; - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleMoveCommand.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleMoveCommand.java deleted file mode 100644 index 4798d7249..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleMoveCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.api.turtle.TurtleCommandResult; -import dan200.computercraft.shared.turtle.core.TurtleMoveCommand; -import dan200.computercraft.shared.turtle.core.TurtlePlayer; -import java.util.List; -import javax.annotation.Nonnull; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(TurtleMoveCommand.class) -public abstract class MixinTurtleMoveCommand { - @Inject(method = "canEnter", at = @At("RETURN"), remap = false, cancellable = true) - private static void ValkyrienSkies2$canEnter( - final TurtlePlayer turtlePlayer, final Level world, @Nonnull final BlockPos position, - final CallbackInfoReturnable cir) { - if (cir.getReturnValue().isSuccess()) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(world, position); - if (ship == null) { - final Ship iShip = VSGameUtilsKt.getShipManagingPos(world, getShipPosFromWorldPos(world, position)); - if (iShip != null) { - cir.setReturnValue(TurtleCommandResult.failure("ship")); - } - } else { - final ChunkPos chunk = world.getChunkAt(position).getPos(); - if (!ship.getChunkClaim().contains(chunk.x, chunk.z)) { - cir.setReturnValue(TurtleCommandResult.failure("out of ship")); - } - } - } - } - - //CUSTOM METHODS - @Unique - private static Vector3d getShipPosFromWorldPos(final Level world, final BlockPos position) { - final List detectedShips = - VSGameUtilsKt.transformToNearbyShipsAndWorld(world, position.getX() + 0.5, position.getY() + 0.5, - position.getZ() + 0.5, 0.1); - for (final Vector3d vec : detectedShips) { - if (vec != null) { - return vec; - } - } - return new Vector3d(position.getX(), position.getY(), position.getZ()); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinWirelessNetwork.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinWirelessNetwork.java deleted file mode 100644 index f623cc254..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinWirelessNetwork.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.api.network.IPacketReceiver; -import dan200.computercraft.api.network.IPacketSender; -import dan200.computercraft.api.network.Packet; -import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(WirelessNetwork.class) -public class MixinWirelessNetwork { - private static IPacketReceiver shipReceiver; - private static IPacketSender shipSender; - - @Redirect( - method = "tryTransmit", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ) - ) - private static double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(shipReceiver.getLevel(), instance.x, instance.y, - instance.z, d.x, d.y, d.z); - } - - @Inject(at = @At("HEAD"), method = "tryTransmit", remap = false) - private static void ValkyrienSkies2$tryTransmit(final IPacketReceiver receiver, final Packet packet, - final double range, - final boolean interdimensional, final CallbackInfo ci) { - shipReceiver = receiver; - shipSender = packet.sender(); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD deleted file mode 100644 index 86cfc1995..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD +++ /dev/null @@ -1,15 +0,0 @@ -Minimal ComputerCraft Compatibility Mixins - -- MixinSpeakerSound - - Fixes Speakers on Ships not playing sounds in worldspace but in Shipyard -- MixinTurtleBrain - - Fails Movement if the turtle is in worldspace and the target position is a - ship (returns "ship") - - Fails Movement if the turtle is on ship and the target position is outside - a ship's ActiveChunkSet (returns "out of ship") -- MixinTurtleMoveCommand - - Allows a Turtle to Leave Ships if the target position is outside of ship's - VoxelAABB and ship is not scaled up or down -- MixinWirelessNetwork - - Fixes Modems not being able to communicate from/to ships despite being - within range diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java deleted file mode 100644 index 8a926d0fb..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.simibubi.create.content.kinetics.base.BlockBreakingKineticBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(BlockBreakingKineticBlockEntity.class) -public abstract class MixinBlockBreakingKineticTileEntity { - - @Shadow - protected abstract BlockPos getBreakingPos(); - - @Redirect( - method = "tick", - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/content/kinetics/base/BlockBreakingKineticBlockEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" - ), remap = false - ) - private BlockPos getBreakingBlockPos(final BlockBreakingKineticBlockEntity self) { - final BlockPos orig = this.getBreakingPos(); - final Vec3 origin; - final Vec3 target; - final Ship ship = VSGameUtilsKt.getShipManagingPos(self.getLevel(), self.getBlockPos()); - - if (ship != null) { - origin = VectorConversionsMCKt.toMinecraft( - ship.getShipToWorld() - .transformPosition(VectorConversionsMCKt.toJOMLD(self.getBlockPos()).add(0.5, 0.5, 0.5)) - ); - target = VectorConversionsMCKt.toMinecraft( - ship.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOMLD(orig).add(0.5, 0.5, 0.5)) - ); - } else { - origin = Vec3.atCenterOf(self.getBlockPos()); - target = Vec3.atCenterOf(orig); - } - - final Vec3 diff = target.subtract(origin); - final BlockHitResult result = self.getLevel().clip(new ClipContext( - origin.add(diff.scale(0.4)), - target.add(diff.scale(0.2)), - ClipContext.Block.COLLIDER, - ClipContext.Fluid.NONE, - null - )); - - if (result.getType() == HitResult.Type.MISS) { - return orig; - } - - return result.getBlockPos(); - } - -} - diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlocks.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlocks.java deleted file mode 100644 index 685ee1b7c..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlocks.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.simibubi.create.content.kinetics.millstone.MillstoneBlock; -import com.simibubi.create.content.logistics.chute.AbstractChuteBlock; -import com.simibubi.create.content.processing.basin.BasinBlock; -import java.util.Iterator; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(value = { - MillstoneBlock.class, - BasinBlock.class, - AbstractChuteBlock.class -}) -public class MixinBlocks { - - @Redirect( - method = "updateEntityAfterFallOn", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - ), - require = 0, remap = false - ) - protected BlockPos redirectBlockPosition(final Entity entity) { - final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); - if (ships.hasNext()) { - final Vector3d pos = ships.next().getWorldToShip() - .transformPosition(VectorConversionsMCKt.toJOML(entity.position())); - return new BlockPos(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); - } else { - return entity.blockPosition(); - } - } - - @Redirect( - method = "updateEntityAfterFallOn", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" - ), - require = 0, remap = false - ) - Vec3 redirectPosition(final Entity entity) { - final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); - if (ships.hasNext()) { - return VectorConversionsMCKt.toMinecraft(ships.next().getWorldToShip() - .transformPosition(VectorConversionsMCKt.toJOML(entity.position()))); - } else { - return entity.position(); - } - } - -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java deleted file mode 100644 index 21e60e3ca..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.llamalad7.mixinextras.sugar.Local; -import com.simibubi.create.content.logistics.chute.ChuteBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ServerShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.ChuteBlockEntityAccessor; - -@Mixin(value = ChuteBlockEntity.class, remap = false) -public class MixinChuteBlockEntity { - - @Inject(method = "findEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;)V", shift = Shift.AFTER), cancellable = true) - private void preFindEntities(float itemSpeed, CallbackInfo ci, @Local Vec3 center) { - ChuteBlockEntity be = ChuteBlockEntity.class.cast(this); - - if (be.getLevel() != null) { - - final ChuteBlockEntityAccessor bea = (ChuteBlockEntityAccessor) be; - Level level = be.getLevel(); - - BlockPos pos = be.getBlockPos(); - - AABB searchArea = new AABB(center.add(0, -bea.getBottomPullDistance() - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); - - if (VSGameUtilsKt.getShipObjectManagingPos(level, pos) instanceof ServerShip ship) { - Vector3d searchAreaMin = new Vector3d(searchArea.minX, searchArea.minY, searchArea.minZ); - Vector3d searchAreaMax = new Vector3d(searchArea.maxX, searchArea.maxY, searchArea.maxZ); - - Vector3d searchAreaReturnMin = new Vector3d(); - Vector3d searchAreaReturnMax = new Vector3d(); - - ship.getTransform().getShipToWorld().transformAab(searchAreaMin, searchAreaMax, searchAreaReturnMin, searchAreaReturnMax); - - searchArea = new AABB(searchAreaReturnMin.x, searchAreaReturnMin.y, searchAreaReturnMin.z, searchAreaReturnMax.x, searchAreaReturnMax.y, searchAreaReturnMax.z); - - for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, searchArea)) { - if (!itemEntity.isAlive()) - continue; - ItemStack entityItem = itemEntity.getItem(); - if (!bea.callCanAcceptItem(entityItem)) - continue; - be.setItem(entityItem.copy(), (float) (itemEntity.getBoundingBox() - .getCenter().y - be.getBlockPos().getY())); - itemEntity.discard(); - break; - } - ci.cancel(); - } - } - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java deleted file mode 100644 index 9bfa2693e..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ControlledContraptionEntity; -import com.simibubi.create.content.contraptions.bearing.BearingContraption; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import net.minecraft.core.Direction; -import net.minecraft.core.Vec3i; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.joml.Math; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ControlledContraptionEntity.class) -public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity { - public MixinControlledContraptionEntity(EntityType entityTypeIn, Level worldIn) { - super(entityTypeIn, worldIn); - } - - //Region start - fix actors in the center of a bearing contraption not triggering correctly (vanilla create bug) - @Shadow - protected float angleDelta; - - @Redirect(method = "shouldActorTrigger", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;motion:Lnet/minecraft/world/phys/Vec3;"), - remap = false) - private void redirectPutMotion(MovementContext instance, Vec3 value) { - BearingContraption bc = (BearingContraption) contraption; - Direction facing = bc.getFacing(); - Vec3i dir = facing.getNormal(); - - double scalar = Math.abs(angleDelta / 360.0) * Math.signum(dir.getX() + dir.getY() + dir.getZ()); - - instance.motion = new Vec3(Math.abs(dir.getX()), Math.abs(dir.getY()), Math.abs(dir.getZ())).scale(scalar); - } - //Region end -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java deleted file mode 100644 index 7d2797ece..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.ContraptionHandlerClient; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.joml.primitives.AABBdc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(ContraptionHandlerClient.class) -public class MixinContraptionHandlerClient { - // Fixes raytracing contraptions on ships - @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;"), remap = false) - private static Vec3 wrapRayTraceContraptionToLocalVector( - final AbstractContraptionEntity instance, final Vec3 localVec, final float partialTicks, final Operation toLocalVector - ) { - final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); - if (clientShip != null) { - final Vec3 newLocalVec = VectorConversionsMCKt.toMinecraft(clientShip.getRenderTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(localVec))); - return toLocalVector.call(instance, newLocalVec, partialTicks); - } - return toLocalVector.call(instance, localVec, partialTicks); - } - - // Fixes raytracing contraptions on ships - @WrapOperation(method = "rightClickingOnContraptionsGetsHandledLocally", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) - private static AABB wrapRightClickingOnContraptionsGetsHandledLocallyGetBoundingBox(final AbstractContraptionEntity instance, final Operation getBoundingBox) { - final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); - if (clientShip != null) { - final AABB original = getBoundingBox.call(instance); - final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); - return VectorConversionsMCKt.toMinecraft(modified); - } - return getBoundingBox.call(instance); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionRenderInfo.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionRenderInfo.java deleted file mode 100644 index 8dc7af3b2..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionRenderInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ContraptionRenderInfo.class) -public class MixinContraptionRenderInfo { - @Redirect( - at = @At( - value = "INVOKE", - target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBoxForCulling()Lnet/minecraft/world/phys/AABB;" - ), - method = "beginFrame" - ) - private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) { - return VSGameUtilsKt.transformRenderAABBToWorld(((ClientLevel) receiver.level), receiver.position(), - receiver.getBoundingBoxForCulling()); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinFlwContraption.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinFlwContraption.java deleted file mode 100644 index e96a27a1d..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinFlwContraption.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.mojang.math.Matrix4f; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; -import com.simibubi.create.content.contraptions.render.FlwContraption; -import net.minecraft.util.Mth; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(FlwContraption.class) -public class MixinFlwContraption extends ContraptionRenderInfo { - - public MixinFlwContraption( - final Contraption contraption, - final VirtualRenderWorld renderWorld) { - super(contraption, renderWorld); - } - - @Inject(at = @At("HEAD"), method = "setupModelViewPartial", cancellable = true, remap = false) - private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Matrix4f modelMatrix, - final AbstractContraptionEntity entity, final double camX, final double camY, final double camZ, final float pt, - final CallbackInfo ci) { - - if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { - VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), - matrix, - Mth.lerp(pt, entity.xOld, entity.getX()), - Mth.lerp(pt, entity.yOld, entity.getY()), - Mth.lerp(pt, entity.zOld, entity.getZ()), - camX, - camY, - camZ - ); - - matrix.multiply(modelMatrix); - ci.cancel(); - } - } - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/AABB;move(DDD)Lnet/minecraft/world/phys/AABB;" - ), - method = "beginFrame" - ) - private AABB transformLightboxToWorld(final AABB aabb, final double negCamX, final double negCamY, - final double negCamZ) { - return VSGameUtilsKt.transformAabbToWorld(this.contraption.entity.level, aabb).move(negCamX, negCamY, negCamZ); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java deleted file mode 100644 index f8e013bb0..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.simibubi.create.content.contraptions.glue.SuperGlueSelectionHandler; -import com.simibubi.create.foundation.utility.RaycastHelper; -import java.util.Iterator; -import net.minecraft.client.Minecraft; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.common.ForgeMod; -import org.joml.Matrix4d; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.joml.primitives.AABBic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(SuperGlueSelectionHandler.class) -public abstract class MixinSuperGlueSelectionHandler { - @Unique - private Vec3 newTarget; - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceOrigin(Lnet/minecraft/world/entity/player/Player;)Lnet/minecraft/world/phys/Vec3;"), remap = false) - private Vec3 redirectGetTraceOrigin(Player playerIn) { - Minecraft mc = Minecraft.getInstance(); - double range = playerIn.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue() + 1; - Vec3 origin = RaycastHelper.getTraceOrigin(playerIn); - Vec3 target = RaycastHelper.getTraceTarget(playerIn, range, origin); - - - AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); - final Iterator ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level, searchAABB).iterator(); - - if (ships.hasNext()) { - Ship ship = ships.next(); - - Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); - AABBic shAABBi = ship.getShipAABB(); - AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); - - - origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); - target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); - - Quaterniond tempQuat = new Quaterniond(); - if (playerIn.getVehicle() != null && playerIn.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { - ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); - tempQuat.invert(); - Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); - tempQuat.transform(offset); - target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); - } - } - - newTarget = target; - return origin; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceTarget(Lnet/minecraft/world/entity/player/Player;DLnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;"), remap = false) - private Vec3 redirectGetTraceTarget(final Player playerIn, final double range, final Vec3 origin) { - return newTarget; - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java deleted file mode 100644 index efcf27ae7..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.simibubi.create.content.trains.track.TrackBlockOutline; -import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.event.RenderHighlightEvent; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(value = TrackBlockOutline.class) -public class MixinTrackBlockOutline { - @Unique - private static Vec3 valkyrienskies$cameraVec3; - @Unique - private static Vec3 valkyrienskies$vec; - @Unique - private static Vec3 valkyrienskies$angles; - - @Inject(method = "drawCurveSelection", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline$BezierPointSelection;angles()Lnet/minecraft/world/phys/Vec3;"), locals = LocalCapture.CAPTURE_FAILHARD, remap = false) - private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBufferSource buffer, final Vec3 camera, - final CallbackInfo ci, final Minecraft mc, - final BezierPointSelection result, final VertexConsumer vb, final Vec3 vec) { - valkyrienskies$cameraVec3 = camera; - valkyrienskies$vec = result.vec(); - valkyrienskies$angles = result.angles(); - } - @ModifyArg(method = "drawCurveSelection", - at = @At(value = "INVOKE", - target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline;renderShape(Lnet/minecraft/world/phys/shapes/VoxelShape;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/lang/Boolean;)V"), - index = 1, - remap = false) - private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { - - final Level level = Minecraft.getInstance().level; - if (level != null && valkyrienskies$vec != null) { - final ClientShip ship; - if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, valkyrienskies$vec)) != null) { - final Quaterniond rotation = new Quaterniond().identity(); - final Quaterniond yawQuat = new Quaterniond().rotateY(valkyrienskies$angles.y); - final Quaterniond pitchQuat = new Quaterniond().rotateX(valkyrienskies$angles.x); - - yawQuat.mul(pitchQuat, rotation); - ship.getRenderTransform().getShipToWorldRotation().mul(rotation, rotation); - - final Vector3d worldVec = ship.getRenderTransform().getShipToWorld() - .transformPosition( - new Vector3d(valkyrienskies$vec.x, valkyrienskies$vec.y + .125, valkyrienskies$vec.z), - new Vector3d()); - - ms.popPose(); - ms.pushPose(); - ms.translate(worldVec.x - valkyrienskies$cameraVec3.x, - worldVec.y - valkyrienskies$cameraVec3.y, - worldVec.z - valkyrienskies$cameraVec3.z); - ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation)); - ms.translate(-.5, -.125f, -.5); - } - } - return ms; - } - - @Unique - private static Camera valkyrienskies$info; - @Unique - private static BlockHitResult valkyrienskies$hitResult; - - @ModifyArg(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/border/WorldBorder;isWithinBounds(Lnet/minecraft/core/BlockPos;)Z")) - private static BlockPos modIsWithinBounds(final BlockPos blockPos) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final Ship ship; - if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) { - return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() - .transformPosition(VectorConversionsMCKt.toJOMLD(blockPos)))); - } - } - return blockPos; - } - - @Inject(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) - private static void harvest(RenderHighlightEvent.Block event, CallbackInfo ci) { - valkyrienskies$info = event.getCamera(); - valkyrienskies$hitResult = (BlockHitResult) event.getTarget(); - } - - @Redirect(method = "drawCustomBlockSelection", - at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) - private static void redirectTranslate(final PoseStack instance, final double d, final double e, final double f) { - final Level level = Minecraft.getInstance().level; - if (level != null) { - final ClientShip ship; - if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, - valkyrienskies$hitResult.getBlockPos())) != null) { - final Vec3 camPos = valkyrienskies$info.getPosition(); - VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, - valkyrienskies$hitResult.getBlockPos(), - camPos.x, camPos.y, camPos.z); - } else { - instance.translate(d, e, f); - } - } else { - instance.translate(d, e, f); - } - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java index 229a7d65f..431309194 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java @@ -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); } } diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/MixinRenderSectionManager.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/MixinRenderSectionManager.java deleted file mode 100644 index b62c9af72..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/MixinRenderSectionManager.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.sodium; - -import me.jellysquid.mods.sodium.client.gl.device.CommandList; -import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderMatrices; -import me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer; -import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; -import org.joml.Vector3dc; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RegionChunkRendererDuck; -import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RenderSectionManagerDuck; -import repack.joml.Matrix4d; -import repack.joml.Matrix4f; - -@Mixin(value = RenderSectionManager.class, remap = false) -public class MixinRenderSectionManager { - @Shadow - @Final - private RegionChunkRenderer chunkRenderer; - - @Redirect(at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gl/device/CommandList;flush()V"), - method = "renderLayer") - private void redirectRenderLayer(final CommandList list, final ChunkRenderMatrices matrices, - final BlockRenderPass pass, final double camX, final double camY, final double camZ) { - - RenderDevice.INSTANCE.makeActive(); - - ((RenderSectionManagerDuck) this).getShipRenderLists().forEach((ship, renderList) -> { - final Vector3dc center = ship.getRenderTransform().getPositionInShip(); - final org.joml.Matrix4dc s = ship.getRenderTransform().getShipToWorld(); - final Matrix4d newModelView = new Matrix4d(matrices.modelView()) - .translate(-camX, -camY, -camZ) - .mul(s.m00(), s.m01(), s.m02(), s.m03(), s.m10(), s.m11(), s.m12(), s.m13(), s.m20(), - s.m21(), s.m22(), s.m23(), s.m30(), s.m31(), s.m32(), s.m33()) - .translate(center.x(), center.y(), center.z()); - - final ChunkRenderMatrices newMatrices = - new ChunkRenderMatrices(matrices.projection(), new Matrix4f(newModelView)); - ((RegionChunkRendererDuck) chunkRenderer).setCameraForCulling(camX, camY, camZ); - chunkRenderer.render(newMatrices, list, renderList, pass, - new ChunkCameraContext(center.x(), center.y(), center.z())); - list.close(); - }); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java deleted file mode 100644 index 8dca7c147..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.tfc; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import net.minecraft.core.RegistryAccess; -import net.minecraft.server.level.WorldGenRegion; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.LevelHeightAccessor; -import net.minecraft.world.level.NoiseColumn; -import net.minecraft.world.level.StructureManager; -import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.biome.BiomeManager; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.levelgen.GenerationStep; -import net.minecraft.world.level.levelgen.RandomState; -import net.minecraft.world.level.levelgen.blending.Blender; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.mod.common.VS2ChunkAllocator; - -@Pseudo -@Mixin(targets = "net.dries007.tfc.world.TFCChunkGenerator") -public class MixinTFCChunkGenerator { - @Inject(method = "m_213609_", at = @At("HEAD"), cancellable = true) - private void preApplyBiomeDecoration( - WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureManager structureManager, CallbackInfo callbackInfo - ) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - callbackInfo.cancel(); - } - } - - @Inject(method = "m_223164_", at = @At("HEAD"), cancellable = true) - private void preCreateStructures( - RegistryAccess registryAccess, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess, StructureTemplateManager structureTemplateManager, long l, CallbackInfo callbackInfo - ) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - callbackInfo.cancel(); - } - } - - @Inject(method = "m_223076_", at = @At("HEAD"), cancellable = true) - private void preCreateReferences( - WorldGenLevel worldGenLevel, StructureManager structureManager, ChunkAccess chunkAccess, CallbackInfo callbackInfo - ) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - callbackInfo.cancel(); - } - } - - @Inject(method = "m_214184_", at = @At("HEAD"), cancellable = true) - private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, CallbackInfoReturnable cir) { - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(i, j)) { - cir.setReturnValue(new NoiseColumn(0, new BlockState[0])); - } - } - - @Inject(method = "m_214194_", at = @At("HEAD"), cancellable = true) - private void preBuildSurface(WorldGenRegion worldGenRegion, StructureManager structureManager, RandomState randomState, ChunkAccess chunkAccess, CallbackInfo ci) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - ci.cancel(); - } - } - - @Inject(method = "m_213679_", at = @At("HEAD"), cancellable = true) - private void preApplyCarvers(WorldGenRegion worldGenRegion, long l, RandomState randomState, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunkAccess, GenerationStep.Carving carving, CallbackInfo ci) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - ci.cancel(); - } - } - - @Inject(method = "m_213974_", at = @At("HEAD"), cancellable = true) - private void preFillFromNoise(Executor executor, Blender blender, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess, CallbackInfoReturnable> cir) { - final ChunkPos chunkPos = chunkAccess.getPos(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - cir.setReturnValue(CompletableFuture.completedFuture(chunkAccess)); - } - } - - @Inject(method = "m_6929_", at = @At("HEAD"), cancellable = true) - private void preSpawnOriginalMobs(WorldGenRegion worldGenRegion, CallbackInfo ci) { - final ChunkPos chunkPos = worldGenRegion.getCenter(); - if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { - ci.cancel(); - } - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinCasingTileEntityRender.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinCasingTileEntityRender.java deleted file mode 100644 index 56518b307..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinCasingTileEntityRender.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.tis3d; - -import li.cil.tis3d.client.renderer.block.entity.CasingBlockEntityRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(CasingBlockEntityRenderer.class) -public abstract class MixinCasingTileEntityRender { - @ModifyVariable(remap = false, method = "isBackFace", - at = @At("STORE"), ordinal = 0) - private Vec3 vs$isBackFace(final Vec3 original, final BlockPos position) { - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, position); - if (ship != null) { - final Vector3d v3 = new Vector3d(original.x, original.y, original.z); - final Vector3d shipyard_camera = ship.getTransform().getWorldToShip().transformPosition(v3); - return new Vec3(shipyard_camera.x, shipyard_camera.y, shipyard_camera.z); - } else { - return original; - } - } -} - diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java deleted file mode 100644 index dc7e88889..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.tis3d; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import li.cil.tis3d.common.entity.InfraredPacketEntity; -import li.cil.tis3d.util.Raytracing; -import net.minecraft.world.level.ClipContext.Block; -import net.minecraft.world.level.ClipContext.Fluid; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.mod.common.world.RaycastUtilsKt; -import org.valkyrienskies.mod.forge.compat.tis3d.Tis3dClipContext; - -@Pseudo -@Mixin(InfraredPacketEntity.class) -public class MixinInfraredPacketEntity { - @WrapOperation( - remap = false, - method = "checkCollision()Lnet/minecraft/world/phys/HitResult;", - at = @At(value = "INVOKE", remap = true, - target = "li/cil/tis3d/util/Raytracing.raytrace (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lli/cil/tis3d/util/Raytracing$CollisionDetector;)Lnet/minecraft/world/phys/HitResult;") - ) - private HitResult vs$raytrace(final Level level, final Vec3 start, final Vec3 target, - final Raytracing.CollisionDetector collisionDetector, - final Operation orig) { - return RaycastUtilsKt.clipIncludeShips(level, - new Tis3dClipContext(start, target, Block.VISUAL, Fluid.ANY, null)); - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java deleted file mode 100644 index 864e2edec..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.tis3d; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import li.cil.tis3d.client.renderer.RenderContextImpl; -import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Position; -import net.minecraft.world.phys.Vec3; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(RenderContextImpl.class) -public abstract class MixinRenderContextImpl { - @WrapOperation( - remap = false, - method = "closeEnoughForDetails(Lnet/minecraft/core/BlockPos;)Z", - at = @At(value = "INVOKE", - remap = true, - target = "Lnet/minecraft/core/BlockPos;closerToCenterThan(Lnet/minecraft/core/Position;D)Z" - ) - ) - private boolean vs$closerToCenterThan(final BlockPos instance, final Position pos, final double dist, - final Operation orig) { - // this code has been deemed better by those at the forge discord (since it calls the og function) - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance); - if (ship != null) { - final Vector3d spos = ship.getTransform().getWorldToShip().transformPosition( - new Vector3d(pos.x(), pos.y(), pos.z()) - ); - return orig.call(instance, new Vec3(spos.x, spos.y, spos.z), dist); - } else { - return orig.call(instance, pos, dist); - } - } -} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md deleted file mode 100644 index 4ce819a8b..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Minimal TIS-3d Compatibility Mixins - -- MixinCasingBlockEntityRender - - Fixes it skipping rendering on faces that are facing away from the player - (when they are actually facing the player) -- MixinRenderContextImpl - - Fixes distance culling checks on blocks that are in the shipyard -- MixinInfaredPacketEntity - - Fixes Infrared packets to/from ship to world/world to ship/ship to - ship/ship within ship raycast diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java index 70d1f439b..b615b4b50 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java @@ -152,7 +152,7 @@ private FluidState getFluidStateRedirect(final Level level, final BlockPos block VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, this.bb.getSize(), (x, y, z) -> { - fluidState[0] = getFluidState.call(level, new BlockPos(x, y, z)); + fluidState[0] = getFluidState.call(level, BlockPos.containing(x, y, z)); }); isShipWater = true; } diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/world/level/block/FireMixin.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/world/level/block/FireMixin.java index aed12e5ae..b6f121125 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/world/level/block/FireMixin.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/world/level/block/FireMixin.java @@ -43,7 +43,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final final double origZ = pos.getZ(); VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 3, (x, y, z) -> { - final BlockPos newPos = new BlockPos(x, y, z); + final BlockPos newPos = BlockPos.containing(x, y, z); if (level.isWaterAt(newPos)) { level.removeBlock(pos, false); @@ -51,7 +51,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final final int i = state.getValue(AGE); - final boolean bl2 = level.isHumidAt(newPos); + final boolean bl2 = level.isRainingAt(newPos); final int k = bl2 ? -50 : 0; this.tryCatchFire(level, pos.east(), 300 + k, random, i, Direction.WEST); this.tryCatchFire(level, pos.west(), 300 + k, random, i, Direction.EAST); @@ -104,7 +104,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP VSGameUtilsKt.transformToNearbyShipsAndWorld(level, origX, origY, origZ, 1, (x, y, z) -> { - final BlockPos newPos = new BlockPos(x, y, z); + final BlockPos newPos = BlockPos.containing(x, y, z); if (level.isWaterAt(newPos)) { level.removeBlock(pos, false); } diff --git a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt deleted file mode 100644 index 2770a0b09..000000000 --- a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.valkyrienskies.mod.forge.common - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity -import net.minecraft.core.BlockPos -import net.minecraft.world.entity.Entity -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate -import org.valkyrienskies.core.api.ships.ContraptionWingProvider -import org.valkyrienskies.core.api.ships.LoadedServerShip -import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.api.ships.WingManager -import org.valkyrienskies.mod.common.block.WingBlock -import org.valkyrienskies.mod.common.entity.handling.AbstractShipyardEntityHandler - -object ContraptionShipyardEntityHandlerForge: AbstractShipyardEntityHandler() { - override fun freshEntityInShipyard(entity: Entity, ship: Ship) { - if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { - entity as ContraptionWingProvider - val attachment = ship.getAttachment(WingManager::class.java)!! - entity.wingGroupId = attachment.createWingGroup() - entity.contraption.blocks.forEach { (pos: BlockPos, blockInfo: StructureTemplate.StructureBlockInfo) -> - val block = blockInfo.state.block - if (block is WingBlock) { - val wing = block.getWing(null, null, blockInfo.state) - attachment.setWing(entity.wingGroupId, pos.x, pos.y, pos.z, wing) - } - } - val transform = entity.computeContraptionWingTransform() - attachment.setWingGroupTransform(entity.wingGroupId, transform) - } - } - - override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { - if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { - entity as ContraptionWingProvider - val attachment = ship.getAttachment(WingManager::class.java)!! - attachment.deleteWingGroup(entity.wingGroupId) - entity.wingGroupId = -1 - } - } -} diff --git a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt index 69d106e2f..3f5ec75d5 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt @@ -84,7 +84,6 @@ class ValkyrienSkiesModForge { VSForgeNetworking.registerPacketHandlers(vsCore.hooks) ValkyrienSkiesMod.init(vsCore) - VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerForge) val modBus = Bus.MOD.bus().get() val forgeBus = Bus.FORGE.bus().get() @@ -120,14 +119,14 @@ class ValkyrienSkiesModForge { TEST_SPHERE_REGISTRY = registerBlockAndItem("test_sphere") { TestSphereBlock } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { - ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), + ShipCreatorItem(Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling }) } CONNECTION_CHECKER_ITEM_REGISTRY = ITEMS.register("connection_checker") { ConnectionCheckerItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling } ) @@ -135,14 +134,14 @@ class ValkyrienSkiesModForge { SHIP_CREATOR_SMALLER_ITEM_REGISTRY = ITEMS.register("ship_creator_smaller") { ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) } AREA_ASSEMBLER_ITEM_REGISTRY = ITEMS.register("area_assembler") { AreaAssemblerItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling } ) @@ -150,7 +149,7 @@ class ValkyrienSkiesModForge { PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY = ITEMS.register("physics_entity_creator") { PhysicsEntityCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), ) } @@ -173,7 +172,7 @@ class ValkyrienSkiesModForge { } SHIP_ASSEMBLER_ITEM_REGISTRY = - ITEMS.register("ship_assembler") { ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) } + ITEMS.register("ship_assembler") { ShipAssemblerItem(Properties()) } TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY = BLOCK_ENTITIES.register("test_hinge_block_entity") { BlockEntityType.Builder.of(::TestHingeBlockEntity, TestHingeBlock).build(null) } @@ -197,7 +196,7 @@ class ValkyrienSkiesModForge { private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): RegistryObject { val blockRegistry = BLOCKS.register(registryName, blockSupplier) - ITEMS.register(registryName) { BlockItem(blockRegistry.get(), Properties().tab(CreativeModeTab.TAB_MISC)) } + ITEMS.register(registryName) { BlockItem(blockRegistry.get(), Properties()) } return blockRegistry } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index ecd097609..d6d65d1ee 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -23,6 +23,6 @@ side = "BOTH" [[dependencies.valkyrienskies]] modId = "minecraft" mandatory = true -versionRange = "[1.19.2]" +versionRange = "[1.19.4]" ordering = "NONE" side = "BOTH" diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 296d3d29f..3746f740e 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -3,18 +3,9 @@ "package": "org.valkyrienskies.mod.forge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "compat.cc_tweaked.MixinTurtleBrain", - "compat.cc_tweaked.MixinTurtleMoveCommand", - "compat.cc_tweaked.MixinWirelessNetwork", - "compat.create.MixinBlockBreakingKineticTileEntity", - "compat.create.MixinBlocks", - "compat.create.MixinChuteBlockEntity", - "compat.create.MixinControlledContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.mekanism.MixinRadiationManager", - "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", - "compat.tis3d.MixinInfraredPacketEntity", "compat.modular_routers.MixinRouterMenu", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", @@ -22,16 +13,7 @@ "world.level.block.FireMixin" ], "client": [ - "client.render.MixinLevelRenderer", - "compat.cc_tweaked.MixinSpeakerSound", - "compat.create.client.MixinContraptionHandlerClient", - "compat.create.client.MixinContraptionRenderInfo", - "compat.create.client.MixinFlwContraption", - "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinTrackBlockOutline", - "compat.sodium.MixinRenderSectionManager", - "compat.tis3d.MixinCasingTileEntityRender", - "compat.tis3d.MixinRenderContextImpl" + "client.render.MixinLevelRenderer" ], "injectors": { "defaultRequire": 1 diff --git a/gradle.properties b/gradle.properties index 157c5f24c..62b8ce796 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,30 +1,30 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -minecraft_version=1.19.2 +minecraft_version=1.19.4 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-119 -mod_version=2.1.2-beta.2 +archives_base_name=valkyrienskies-1194 +mod_version=2.1.2-beta.3 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ architectury_version=6.5.85 # https://fabricmc.net/develop/ -fabric_loader_version=0.14.24 +fabric_loader_version=0.16.9 # https://fabricmc.net/develop/ -fabric_api_version=0.76.1+1.19.2 +fabric_api_version=0.87.2+1.19.4 # https://files.minecraftforge.net/net/minecraftforge/forge/ -forge_version=1.19.2-43.3.0 +forge_version=1.19.4-45.3.0 -# https://modrinth.com/mod/create-fabric/version/ -create_fabric_version=0.5.1-c-build.1160+mc1.19.2 +# https://modrinth.com/mod/create-fabric/versions/ +#create_fabric_version=0.5.1-c-build.1160+mc1.19.4 # https://github.com/Fabricators-of-Create/Create/blob/mc1.19/fabric/dev/gradle.properties -flywheel_version_fabric=0.6.9-6 +#flywheel_version_fabric=0.6.9-6 -# https://modrinth.com/mod/create-big-cannons/version/ -createbigcannons_version=0.5.2.a +# https://modrinth.com/mod/create-big-cannons/versions/ +#createbigcannons_version=0.5.2.a vs_core_version=1.1.0+2a62e6a823 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks